:root {
    --bg: #f3f5fb;
    --bg-accent: #e9eefb;
    --surface: rgba(255, 255, 255, 0.88);
    --surface-strong: #ffffff;
    --sidebar: linear-gradient(180deg, #0f172a 0%, #172554 100%);
    --sidebar-border: rgba(148, 163, 184, 0.16);
    --text: #0f172a;
    --muted: #64748b;
    --line: #dbe3f0;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --danger: #dc2626;
    --warning: #d97706;
    --secondary: #475569;
    --shadow-soft: 0 18px 45px rgba(15, 23, 42, 0.08);
    --shadow-card: 0 14px 30px rgba(15, 23, 42, 0.07);
    --radius-lg: 24px;
    --radius-md: 18px;
    --radius-sm: 12px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Trebuchet MS", "Segoe UI", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, 0.12), transparent 30%),
        radial-gradient(circle at bottom right, rgba(14, 165, 233, 0.10), transparent 26%),
        linear-gradient(180deg, #f8fbff 0%, var(--bg) 100%);
}

h1, h2, h3, h4, p {
    margin-top: 0;
}

.app-container {
    display: flex;
    min-height: 100vh;
    position: relative;
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    z-index: 40;
}

.sidebar {
    width: 290px;
    background: var(--sidebar);
    color: white;
    min-height: 100vh;
    padding: 28px 20px;
    position: sticky;
    top: 0;
    border-right: 1px solid var(--sidebar-border);
    box-shadow: 18px 0 40px rgba(15, 23, 42, 0.14);
    z-index: 50;
}

.sidebar-brand {
    padding: 10px 10px 24px;
}

.sidebar-brand h2 {
    margin-bottom: 10px;
    font-size: 1.8rem;
    letter-spacing: 0.02em;
}

.sidebar-brand p {
    margin: 0;
    color: rgba(226, 232, 240, 0.78);
    line-height: 1.5;
    font-size: 0.92rem;
}

.sidebar-eyebrow {
    display: inline-block;
    margin-bottom: 10px;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: #93c5fd;
}

.sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 8px;
}

.sidebar-menu a {
    color: rgba(255, 255, 255, 0.88);
    text-decoration: none;
    display: block;
    padding: 12px 14px;
    border-radius: 14px;
    transition: transform 0.2s ease, background 0.2s ease, color 0.2s ease;
    border: 1px solid transparent;
}

.sidebar-menu a.active,
.sidebar-menu a:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    border-color: rgba(191, 219, 254, 0.2);
    transform: translateX(3px);
}

.main-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.navbar {
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(14px);
    padding: 18px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    border-bottom: 1px solid rgba(219, 227, 240, 0.8);
    position: sticky;
    top: 0;
    z-index: 30;
}

.navbar-left,
.navbar-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.navbar h3 {
    margin: 0;
    font-size: 1.35rem;
}

.navbar-kicker {
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.16em;
    font-size: 0.72rem;
}

.user-badge {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(37, 99, 235, 0.08);
    color: var(--text);
    line-height: 1.2;
}

.user-badge span {
    color: var(--muted);
    font-size: 0.86rem;
}

.sidebar-toggle {
    display: none;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--surface-strong);
    cursor: pointer;
    padding: 10px 9px;
}

.sidebar-toggle span {
    display: block;
    height: 2px;
    background: var(--text);
    border-radius: 999px;
    margin: 5px 0;
}

.content-wrapper {
    padding: 28px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 24px;
    gap: 16px;
    flex-wrap: wrap;
}

.page-header h1 {
    margin-bottom: 8px;
    font-size: clamp(1.8rem, 3vw, 2.5rem);
}

.page-header p {
    margin: 0;
    color: var(--muted);
    max-width: 720px;
}

.page-header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
}

.section-tag {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    border-radius: 999px;
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary-dark);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    margin-bottom: 12px;
}

.card {
    background: var(--surface);
    border: 1px solid rgba(219, 227, 240, 0.8);
    border-radius: var(--radius-lg);
    padding: 22px;
    box-shadow: var(--shadow-card);
    backdrop-filter: blur(10px);
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
}

.cards-grid .card {
    position: relative;
    overflow: hidden;
}

.cards-grid .card::after {
    content: "";
    position: absolute;
    inset: auto -20% -35% auto;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(37, 99, 235, 0.16), transparent 70%);
}

.metric-card {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.92) 0%, rgba(248, 250, 252, 0.95) 100%);
    border: 1px solid rgba(219, 227, 240, 0.85);
    border-radius: var(--radius-md);
    padding: 18px;
    box-shadow: var(--shadow-card);
}

.metric-card h3,
.metric-card p {
    margin: 0;
}

.metric-card h3 {
    color: var(--muted);
    font-size: 0.98rem;
    font-weight: 600;
}

.metric-card p {
    margin-top: 10px;
    font-size: 1.8rem;
    font-weight: 700;
}

.form-group {
    margin-bottom: 14px;
}

.filters-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.filters-bar .form-group {
    margin-bottom: 0;
}

.form-control {
    width: 100%;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.96);
    color: var(--text);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.form-control:focus {
    outline: none;
    border-color: rgba(37, 99, 235, 0.55);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.btn {
    border: none;
    padding: 11px 16px;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 12px;
    font-weight: 600;
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
    box-shadow: 0 10px 20px rgba(15, 23, 42, 0.08);
}

.btn:hover {
    transform: translateY(-1px);
}

.btn-primary { background: linear-gradient(135deg, var(--primary) 0%, #3b82f6 100%); color: white; }
.btn-danger { background: linear-gradient(135deg, var(--danger) 0%, #ef4444 100%); color: white; }
.btn-warning { background: linear-gradient(135deg, var(--warning) 0%, #f59e0b 100%); color: white; }
.btn-secondary { background: linear-gradient(135deg, var(--secondary) 0%, #64748b 100%); color: white; }
.btn-sm { padding: 8px 12px; font-size: 12px; border-radius: 10px; }
.w-100 { width: 100%; }

.text-right {
    text-align: right;
}

.table-responsive {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid rgba(219, 227, 240, 0.85);
    background: rgba(255, 255, 255, 0.92);
}

.table {
    width: 100%;
    border-collapse: collapse;
    min-width: 720px;
}

.table th,
.table td {
    border-bottom: 1px solid rgba(219, 227, 240, 0.9);
    padding: 12px 14px;
    text-align: left;
}

.table th {
    background: #eef4ff;
    color: #1e3a8a;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.table tr:hover td {
    background: rgba(37, 99, 235, 0.03);
}

.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal-content {
    background: var(--surface-strong);
    width: 560px;
    max-width: 100%;
    padding: 24px;
    border-radius: var(--radius-lg);
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-soft);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.close {
    cursor: pointer;
    font-size: 24px;
    color: var(--muted);
}

.login-body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, 0.22), transparent 28%),
        radial-gradient(circle at bottom right, rgba(14, 165, 233, 0.18), transparent 28%),
        linear-gradient(180deg, #e8eefc 0%, #f8fbff 100%);
}

.login-box {
    width: 380px;
    max-width: 100%;
    background: rgba(255, 255, 255, 0.94);
    padding: 30px;
    border-radius: 28px;
    box-shadow: var(--shadow-soft);
    border: 1px solid rgba(219, 227, 240, 0.9);
}

.login-box h2 {
    font-size: 1.8rem;
    margin-bottom: 18px;
}

.alert {
    padding: 12px 14px;
    margin-bottom: 16px;
    border-radius: 12px;
}

.alert-danger {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.table-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 14px 4px 4px;
    flex-wrap: wrap;
}

.table-pagination-info,
.table-pagination-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    color: var(--muted);
    font-size: 0.92rem;
}

.table-pagination-info label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.table-pagination-select {
    width: auto;
    min-width: 86px;
    padding: 8px 12px;
}

.text-muted {
    color: var(--muted);
}

.mapa-layout {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(280px, 0.95fr);
    gap: 18px;
}

.mapa-canvas-card,
.mapa-detalle-card {
    min-height: 520px;
}

.mapa-resumen-fase {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.mapa-summary-chip {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 12px;
    border-radius: 14px;
    background: #eef4ff;
    border: 1px solid rgba(37, 99, 235, 0.12);
}

.mapa-summary-chip strong {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #1d4ed8;
}

.mapa-lotes-container {
    min-height: 420px;
}

.mapa-stage {
    overflow: auto;
    border-radius: 18px;
    border: 1px solid var(--line);
    background:
        linear-gradient(90deg, rgba(148, 163, 184, 0.08) 1px, transparent 1px),
        linear-gradient(rgba(148, 163, 184, 0.08) 1px, transparent 1px),
        #f8fbff;
    background-size: 28px 28px;
    padding: 14px;
    min-height: 430px;
}

.mapa-svg-wrap {
    width: max-content;
    transition: transform 0.2s ease;
}

.mapa-svg {
    width: 1000px;
    max-width: none;
    height: auto;
}

.mapa-leyenda {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
    color: var(--muted);
    font-size: 0.9rem;
}

.mapa-leyenda span {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.mapa-leyenda i {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 4px;
}

.mapa-detalle-empty,
.mapa-vacio {
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 220px;
    text-align: center;
}

.mapa-detalle-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 12px;
}

.mapa-detalle-grid div {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px;
    border-radius: 14px;
    background: #f8fbff;
    border: 1px solid var(--line);
}

.mapa-detalle-note {
    margin-top: 16px;
    padding: 14px;
    border-radius: 14px;
    background: #fff7ed;
    border: 1px solid #fed7aa;
}

.mapa-detalle-note p {
    margin: 8px 0 0;
}

@media (max-width: 960px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        width: min(84vw, 310px);
    }

    .sidebar-toggle {
        display: inline-block;
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    body.sidebar-open .sidebar-overlay {
        opacity: 1;
        pointer-events: auto;
    }

    .navbar {
        padding: 16px 18px;
    }

    .content-wrapper {
        padding: 20px 16px 28px;
    }

    .user-badge {
        display: none;
    }
}

@media (max-width: 640px) {
    .navbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .navbar-left,
    .navbar-right {
        width: 100%;
        justify-content: space-between;
    }

    .page-header {
        align-items: flex-start;
    }

    .page-header-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .card,
    .metric-card,
    .modal-content,
    .login-box {
        padding: 18px;
        border-radius: 18px;
    }

    .table {
        min-width: 640px;
    }
}

@media (max-width: 980px) {
    .mapa-layout {
        grid-template-columns: 1fr;
    }
}
