:root {
    --navy-900: #0b192c;
    --navy-800: #13294b;
    --navy-700: #1e3a5f;
    --accent: #b8860b;
    --accent-light: #d4a634;
    --bg: #f1f5f9;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text: #0f172a;
    --muted: #64748b;
    --success: #0f766e;
    --danger: #b91c1c;
    --caminos-bg: #e0f2fe;
    --caminos-fg: #0369a1;
    --edif-bg: #fef3c7;
    --edif-fg: #92400e;
    --radius: 10px;
    --shadow: 0 4px 16px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}
.hidden { display: none !important; }

/* LOGIN */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, var(--navy-900) 0%, var(--navy-700) 100%);
}
.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border-radius: 14px;
    padding: 32px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}
.login-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 10px;
    margin-bottom: 22px;
}
.login-logo-img {
    width: 155px;
    max-width: 70%;
    height: auto;
    object-fit: contain;
    display: block;
}
.topbar-logo-wrap {
    background: #ffffff;
    border-radius: 9px;
    padding: 3px 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 40px;
}
.topbar-logo-img {
    height: 34px;
    width: auto;
    object-fit: contain;
    display: block;
}
.login-brand h1 { font-size: 1.25rem; color: var(--navy-900); }
.login-brand p { font-size: 0.85rem; color: var(--muted); }
.brand-emblem {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--navy-900), var(--navy-700));
    color: #fff;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    letter-spacing: 0.5px;
    border: 2px solid var(--accent-light);
    flex-shrink: 0;
}
.brand-emblem.sm { width: 38px; height: 38px; font-size: 0.95rem; }
.login-footer { margin-top: 20px; text-align: center; }
.link-muted { color: var(--muted); font-size: 0.85rem; text-decoration: none; }
.link-muted:hover { color: var(--navy-800); text-decoration: underline; }

/* TOPBAR */
.topbar {
    background: var(--navy-900);
    color: #fff;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 2px 12px rgba(0,0,0,0.18);
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-title { font-weight: 700; font-size: 1rem; }
.topbar-subtitle { font-size: 0.78rem; color: #cbd5e1; }
.topbar-nav { display: flex; gap: 8px; }
.nav-tab {
    background: rgba(255,255,255,0.08);
    color: #e2e8f0;
    border: 1px solid transparent;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.88rem;
}
.nav-tab.active {
    background: var(--accent);
    color: #fff;
}
.topbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.user-pill {
    font-size: 0.82rem;
    background: rgba(255,255,255,0.12);
    padding: 5px 12px;
    border-radius: 999px;
}

/* MAIN */
.main-content {
    max-width: 1320px;
    margin: 24px auto;
    padding: 0 20px 48px;
}
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}
.section-header h2 { font-size: 1.4rem; color: var(--navy-900); }
.text-muted { color: var(--muted); font-size: 0.9rem; }
.section-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* KPIs */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}
.kpi-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow);
}
.kpi-label { font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; }
.kpi-value { display: block; font-size: 1.65rem; color: var(--navy-900); margin-top: 4px; }

/* CARDS & TABLES */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 18px;
}
.form-inline-card { padding: 18px; }
.token-create-grid {
    display: grid;
    grid-template-columns: 1.4fr 1.2fr auto;
    gap: 14px;
    align-items: end;
}
.table-responsive { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.data-table th {
    text-align: left;
    padding: 13px 14px;
    background: #f8fafc;
    color: var(--muted);
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}
.data-table td {
    padding: 13px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.data-table tr:hover td { background: #f8fafc; }
.empty-cell { text-align: center; color: var(--muted); padding: 32px !important; }
.text-right { text-align: right; }

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 600;
    letter-spacing: 0.3px;
}
.badge-caminos { background: var(--caminos-bg); color: var(--caminos-fg); }
.badge-edificacion { background: var(--edif-bg); color: var(--edif-fg); }
.badge-active { background: #dcfce7; color: #166534; }
.badge-inactive { background: #fee2e2; color: #991b1b; }

.progress-wrap { min-width: 110px; }
.progress-bar {
    height: 8px;
    background: #e2e8f0;
    border-radius: 999px;
    overflow: hidden;
    margin-top: 4px;
}
.progress-fill { height: 100%; background: var(--navy-700); border-radius: 999px; }

.action-group { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }

/* FORMS & BUTTONS */
.form-stack { display: flex; flex-direction: column; gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.form-group label { font-size: 0.82rem; font-weight: 600; color: var(--navy-800); }
input[type="text"], input[type="password"], input[type="date"], input[type="number"], input[type="search"], select, textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.9rem;
    background: #fff;
    color: var(--text);
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--navy-700);
    box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.12);
}
.input-search { width: 220px !important; }
.input-select { width: 200px !important; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

.btn {
    border: none;
    border-radius: 8px;
    padding: 9px 16px;
    font-weight: 600;
    font-size: 0.88rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    text-decoration: none;
    transition: opacity 0.15s, background 0.15s;
}
.btn:hover { opacity: 0.92; }
.btn-primary { background: var(--navy-800); color: #fff; }
.btn-outline { background: transparent; border: 1px solid #cbd5e1; color: var(--text); }
.topbar .btn-outline { color: #fff; border-color: rgba(255,255,255,0.3); }
.btn-ghost { background: rgba(255,255,255,0.12); color: #fff; }
.btn-danger { background: #fee2e2; color: var(--danger); }
.btn-sm { padding: 6px 11px; font-size: 0.8rem; }
.btn-block { width: 100%; }

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
}

/* MODALS */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 100;
}
.modal-dialog {
    background: var(--surface);
    border-radius: 14px;
    width: 100%;
    max-width: 640px;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 24px 60px rgba(0,0,0,0.3);
}
.modal-lg { max-width: 860px; }
.modal-header {
    padding: 16px 22px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8fafc;
}
.modal-subtitle { font-size: 0.84rem; color: var(--muted); }
.modal-close {
    background: none;
    border: none;
    font-size: 1.6rem;
    cursor: pointer;
    color: var(--muted);
    line-height: 1;
}
.modal-body { padding: 20px 22px; overflow-y: auto; }
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
    margin-top: 12px;
}

/* GEO MAP PICKER */
.geo-fieldset {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 12px;
}
.geo-fieldset legend { font-weight: 600; font-size: 0.88rem; padding: 0 8px; color: var(--navy-800); }
.geo-help { font-size: 0.8rem; color: var(--muted); margin-bottom: 10px; }
.geo-mode-bar { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.map-picker { height: 240px; width: 100%; border-radius: 8px; border: 1px solid var(--border); margin-bottom: 12px; z-index: 1; }
.geo-box { background: #f8fafc; padding: 10px; border-radius: 8px; border: 1px solid var(--border); }
.geo-box h4 { font-size: 0.82rem; color: var(--navy-800); margin-bottom: 8px; }

/* BITACORA & GALERIA */
.card-subform {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 16px;
}
.bitacora-list { display: flex; flex-direction: column; gap: 10px; }
.bitacora-item {
    border: 1px solid var(--border);
    border-left: 4px solid var(--navy-700);
    border-radius: 8px;
    padding: 12px 14px;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
}
.bitacora-meta { font-size: 0.8rem; color: var(--muted); margin-bottom: 4px; }
.gallery-admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 12px;
}
.gallery-card {
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
}
.gallery-card img { width: 100%; height: 130px; object-fit: cover; display: block; }
.gallery-card-body { padding: 8px 10px; font-size: 0.8rem; }

.token-code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    background: #f1f5f9;
    padding: 4px 8px;
    border-radius: 6px;
    font-weight: 600;
    color: var(--navy-900);
}

.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--navy-900);
    color: #fff;
    padding: 12px 18px;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.25);
    z-index: 200;
    font-size: 0.88rem;
}

@media (max-width: 768px) {
    .topbar { padding: 10px 14px; gap: 10px; }
    .topbar-nav, .topbar-right { width: 100%; justify-content: flex-start; }
    .main-content { margin: 14px auto; padding: 0 12px 36px; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .form-row-2, .form-row-3, .token-create-grid { grid-template-columns: 1fr; }
    .input-search, .input-select { width: 100% !important; }
    .section-actions { width: 100%; }
    .section-actions .btn { width: 100%; }
}
