:root {
    --navy-950: #071220;
    --navy-900: #0b192c;
    --navy-800: #13294b;
    --navy-700: #1e3a5f;
    --gold: #b8860b;
    --gold-bright: #d4a634;
    --bg: #eef2f6;
    --surface: #ffffff;
    --border: #dde4ee;
    --text: #0f172a;
    --muted: #64748b;
    --caminos-bg: #e0f2fe;
    --caminos-fg: #0369a1;
    --edif-bg: #fef3c7;
    --edif-fg: #92400e;
    --radius: 12px;
    --shadow: 0 4px 18px rgba(11, 25, 44, 0.07);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
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; }

/* AUTH SCREEN */
.auth-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: radial-gradient(circle at top right, #1e3a5f 0%, #0b192c 55%, #071220 100%);
}
.auth-card {
    width: 100%;
    max-width: 410px;
    background: var(--surface);
    border-radius: 18px;
    padding: 36px 28px;
    text-align: center;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.35);
}
.auth-logo {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--navy-900), var(--navy-700));
    color: #fff;
    font-size: 1.4rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--gold-bright);
}
.auth-card h1 { font-size: 1.35rem; color: var(--navy-900); margin-bottom: 4px; }
.auth-subtitle { font-size: 0.88rem; color: var(--muted); margin-bottom: 26px; }
.auth-form { text-align: left; display: flex; flex-direction: column; gap: 12px; }
.auth-form label { font-size: 0.82rem; font-weight: 600; color: var(--navy-800); }
.auth-form input {
    padding: 13px 14px;
    border: 1.5px solid #cbd5e1;
    border-radius: 10px;
    font-size: 1rem;
    letter-spacing: 0.8px;
    text-align: center;
    font-weight: 600;
    color: var(--navy-900);
}
.auth-form input:focus {
    outline: none;
    border-color: var(--navy-700);
    box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.14);
}
.error-box {
    background: #fee2e2;
    color: #991b1b;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 0.84rem;
    text-align: center;
}
.btn-exec {
    background: linear-gradient(135deg, var(--navy-900), var(--navy-700));
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 13px 18px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
}
.btn-block { width: 100%; }
.auth-hint { font-size: 0.78rem; color: var(--muted); margin-top: 18px; }
.auth-links { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.link-subtle { color: var(--navy-700); font-size: 0.83rem; text-decoration: none; font-weight: 500; }

/* HEADER */
.exec-header {
    background: var(--navy-900);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 40;
    padding-top: env(safe-area-inset-top);
    box-shadow: 0 2px 14px rgba(0, 0, 0, 0.2);
}
.exec-header-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.exec-brand { display: flex; align-items: center; gap: 10px; }
.exec-badge {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--navy-700);
    border: 1.5px solid var(--gold-bright);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.95rem;
}
.exec-title { font-weight: 700; font-size: 1rem; line-height: 1.2; }
.exec-sub { font-size: 0.76rem; color: #cbd5e1; }
.exec-actions { display: flex; gap: 8px; align-items: center; }
.icon-btn {
    background: rgba(255,255,255,0.12);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.18);
    padding: 7px 12px;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
}
.icon-btn.danger { background: rgba(185, 28, 28, 0.28); border-color: rgba(254, 202, 202, 0.3); }
.btn-gold {
    background: linear-gradient(135deg, var(--gold), var(--gold-bright));
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
}

/* CONTAINER & SUMMARY */
.exec-container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 18px 16px 48px;
}
.summary-strip {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}
.summary-tile {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    box-shadow: var(--shadow);
}
.summary-tile span { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; }
.summary-tile strong { display: block; font-size: 1.5rem; color: var(--navy-900); margin-top: 2px; }

/* TOOLBAR */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.search-field {
    flex: 1;
    min-width: 220px;
    padding: 10px 14px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    background: var(--surface);
    font-size: 0.9rem;
}
.chip-group { display: flex; gap: 6px; }
.chip {
    border: 1px solid #cbd5e1;
    background: var(--surface);
    color: var(--navy-800);
    padding: 8px 14px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
}
.chip.active { background: var(--navy-900); color: #fff; border-color: var(--navy-900); }

/* SORTABLE TABLE */
.table-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.exec-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.exec-table th {
    background: #f8fafc;
    color: var(--navy-800);
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    text-align: left;
    padding: 13px 14px;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
    user-select: none;
}
.exec-table th.sortable { cursor: pointer; }
.exec-table th.sortable:hover { background: #edf2f7; }
.exec-table th.active-sort { color: var(--navy-900); }
.sort-ind { margin-left: 4px; font-size: 0.7rem; color: var(--gold); }
.exec-table td {
    padding: 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.exec-table tbody tr { cursor: pointer; transition: background 0.12s; }
.exec-table tbody tr:hover { background: #f1f5f9; }
.table-empty { text-align: center; color: var(--muted); padding: 36px !important; }
.table-footnote {
    padding: 10px 14px;
    font-size: 0.78rem;
    color: var(--muted);
    background: #f8fafc;
    border-top: 1px solid var(--border);
}

.pill {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.4px;
}
.pill-caminos { background: var(--caminos-bg); color: var(--caminos-fg); }
.pill-edificacion { background: var(--edif-bg); color: var(--edif-fg); }

.exec-progress {
    height: 7px;
    background: #e2e8f0;
    border-radius: 999px;
    overflow: hidden;
    margin-top: 5px;
    min-width: 85px;
}
.exec-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--navy-700), var(--gold));
    border-radius: 999px;
}

/* FICHA EJECUTIVA */
.ficha-sheet { display: flex; flex-direction: column; gap: 16px; }
.ficha-hero {
    background: linear-gradient(135deg, var(--navy-900) 0%, var(--navy-700) 100%);
    color: #fff;
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow);
}
.ficha-hero-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.ficha-updated { font-size: 0.8rem; color: #cbd5e1; }
.ficha-hero h1 { font-size: 1.45rem; line-height: 1.3; margin-bottom: 18px; }
.ficha-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
}
.ficha-kpi {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.14);
    border-radius: 10px;
    padding: 12px 14px;
}
.ficha-kpi span { font-size: 0.74rem; color: #cbd5e1; text-transform: uppercase; letter-spacing: 0.4px; }
.ficha-kpi strong { display: block; font-size: 1.12rem; margin-top: 3px; }

.ficha-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px;
    box-shadow: var(--shadow);
    page-break-inside: avoid;
}
.ficha-card h2 {
    font-size: 1rem;
    color: var(--navy-900);
    margin-bottom: 14px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.timeline-chart-wrap { width: 100%; overflow-x: auto; }
.impacto-text { font-size: 0.94rem; color: #1e293b; white-space: pre-line; }

.geo-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 12px;
    margin-bottom: 14px;
}
.geo-point-card {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    font-size: 0.86rem;
}
.geo-point-card a { color: var(--navy-700); font-weight: 600; text-decoration: none; font-size: 0.82rem; }
.ficha-map { height: 290px; width: 100%; border-radius: 10px; border: 1px solid var(--border); z-index: 1; }

.bitacora-timeline {
    display: flex;
    flex-direction: column;
    gap: 12px;
    border-left: 3px solid var(--navy-700);
    padding-left: 16px;
    margin-left: 6px;
}
.bitacora-entry {
    position: relative;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
}
.bitacora-entry::before {
    content: '';
    position: absolute;
    left: -24px;
    top: 16px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--gold);
    border: 2px solid #fff;
}
.bitacora-entry-head {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 0.82rem;
    color: var(--muted);
    margin-bottom: 5px;
}
.bitacora-pct-tag {
    background: var(--navy-900);
    color: #fff;
    padding: 2px 9px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.78rem;
}

.ficha-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
    gap: 12px;
}
.gallery-thumb {
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    background: #fff;
}
.gallery-thumb img { width: 100%; height: 145px; object-fit: cover; display: block; }
.gallery-thumb-cap { padding: 8px 10px; font-size: 0.78rem; color: var(--muted); }

/* LIGHTBOX */
.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(7, 18, 32, 0.92);
    z-index: 200;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.lightbox img { max-width: 94vw; max-height: 80vh; border-radius: 10px; object-fit: contain; }
.lightbox-close {
    position: absolute;
    top: 18px;
    right: 22px;
    background: none;
    border: none;
    color: #fff;
    font-size: 2.2rem;
    cursor: pointer;
}
.lightbox-caption { color: #e2e8f0; margin-top: 12px; font-size: 0.9rem; text-align: center; }

.app-toast {
    position: fixed;
    bottom: 22px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--navy-900);
    color: #fff;
    padding: 11px 18px;
    border-radius: 10px;
    box-shadow: 0 10px 28px rgba(0,0,0,0.3);
    z-index: 300;
    font-size: 0.86rem;
}

@media (max-width: 720px) {
    .summary-strip { grid-template-columns: repeat(2, 1fr); }
    .ficha-hero { padding: 18px; }
    .ficha-hero h1 { font-size: 1.2rem; }
}
