/* ============================================
   INFRATRACK DASHBOARD LAYOUT
   ============================================ */

/* ── Two-column shell: sidebar + main ─────── */
body {
    display: grid;
    grid-template-columns: 250px 1fr;
    min-height: 100vh;
    min-height: 100dvh;
}

@media (max-width: 768px) {
    body {
        display: block !important;
        grid-template-columns: unset !important;
    }
}

/* ── Sidebar ──────────────────────────────── */
.sidebar {
    background: var(--sidebar-bg, #0d1323);
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    padding: 20px 16px 20px 16px;
    position: fixed;
    left: 0;
    top: 0;
    width: 250px;
    height: 100vh;
    overflow-y: auto;
    grid-column: 1;
    z-index: 100;
}

.sidebar-header {
    margin-bottom: 20px;
    padding-bottom: 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

/* ── Nav items ────────────────────────────── */
.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.55);
    text-decoration: none;
    transition: background 0.16s, color 0.16s;
    font-size: 14px;
    font-weight: 600;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.88);
}

.nav-item.active {
    background: rgba(30, 91, 255, 0.2);
    color: #ffffff;
    box-shadow: inset 3px 0 0 var(--blue, #1E5BFF);
    font-weight: 700;
}

/* ── Main content ─────────────────────────── */
.main-content {
    padding: 32px;
    grid-column: 2;
    background: var(--bg, #f4f6fb);
    min-height: 100vh;
    min-height: 100dvh;
    min-width: 0;
}

[data-theme="dark"] .main-content {
    background: var(--bg, #0d1020);
}

/* ── Dashboard header ─────────────────────── */
.dashboard-header {
    margin-bottom: 24px;
    background: var(--card, #ffffff);
    border: 1.5px solid var(--line, #e4e8f2);
    border-radius: 14px;
    padding: 22px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    box-shadow: var(--shadow-sm, 0 1px 3px rgba(10, 15, 30, 0.06));
}

.dashboard-header h1 {
    margin: 0;
    font-size: 24px;
    font-weight: 800;
    color: var(--ink, #0a0f1e);
}

[data-theme="dark"] .dashboard-header {
    background: var(--card, #131826);
    border-color: var(--line, #1e273e);
}

/* ── Top Bar Search Wrap Width Limit ───────── */
.dash-top-actions .search-wrap {
    width: 240px !important;
    max-width: 240px !important;
    flex: 0 0 240px !important;
}

@media (max-width: 600px) {
    .dash-top-actions .search-wrap {
        width: 100% !important;
        max-width: 100% !important;
        flex: 1 1 100% !important;
    }
}

/* ── Section Title Row ────────────────────── */
.section-title-row {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 12px !important;
    margin-bottom: 14px !important;
    flex-wrap: nowrap !important;
    width: 100% !important;
}

.section-title-row h2 {
    margin: 0 !important;
    font-size: 18px !important;
    font-weight: 800 !important;
    color: var(--ink, #0a0f1e) !important;
    white-space: nowrap !important;
}

.section-title-row .btn,
.section-title-row a {
    width: auto !important;
    min-width: unset !important;
    flex-shrink: 0 !important;
    padding: 6px 14px !important;
    font-size: 12px !important;
    font-weight: 700 !important;
    border-radius: 8px !important;
    white-space: nowrap !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* ── Stats grid ───────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--card, #ffffff);
    border: 1.5px solid var(--line, #e4e8f2);
    border-radius: 14px;
    padding: 22px;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-sm, 0 1px 3px rgba(10, 15, 30, 0.06));
    min-width: 0;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--blue, #1E5BFF);
    border-radius: 14px 14px 0 0;
}

.stat-card h4 {
    color: var(--ink-3, #7c84a0);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    margin: 0 0 10px;
}

.stat-value {
    font-size: clamp(1.15rem, 2.2vw, 2rem);
    font-weight: 800;
    color: var(--ink, #0a0f1e);
    margin: 0 0 4px;
    letter-spacing: 0;
    line-height: 1.1;
    max-width: 100%;
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.summary-card-value,
.fin-stat-value,
.plan-price,
.metric-box strong {
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.stat-label {
    color: var(--ink-3, #7c84a0);
    font-size: 12px;
    font-weight: 500;
}

/* ── Table hover ──────────────────────────── */
table tbody tr:hover td {
    background: rgba(30, 91, 255, 0.03);
}

[data-theme="dark"] table tbody tr:hover td {
    background: rgba(255, 255, 255, 0.03);
}

/* ── Modal ────────────────────────────────── */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(10, 15, 30, 0.55);
    z-index: var(--z-modal, 1050);
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}

.modal.active {
    display: flex;
}

/* ── Mobile overrides ─────────────────────── */
@media (max-width: 768px) {
    body {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        width: 280px;
        height: 100vh;
        height: 100dvh;
        z-index: 1050;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 8px 0 48px rgba(0, 0, 0, 0.4);
    }

    .main-content {
        grid-column: 1;
        padding: 16px;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }
}