/* ============================================
   SEBI Design System — Editorial Finance
   ============================================ */

/* ---- Base Typography ---- */
body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
.font-display { font-weight: 700; }
.font-data { font-variant-numeric: tabular-nums; }

/* ---- CSS Custom Properties ---- */
:root {
    --bg-paper: #FAF8F5;
    --bg-card: #FFFFFF;
    --text-primary: #1B1B1E;
    --text-secondary: #5A6474;
    --text-muted: #8A94A4;
    --shadow-xs: 0 1px 2px rgba(10,22,40,0.04);
    --shadow-sm: 0 1px 3px rgba(10,22,40,0.06), 0 1px 2px rgba(10,22,40,0.04);
    --shadow-md: 0 4px 12px rgba(10,22,40,0.07), 0 2px 4px rgba(10,22,40,0.04);
    --shadow-lg: 0 8px 24px rgba(10,22,40,0.08), 0 4px 8px rgba(10,22,40,0.04);
    --shadow-xl: 0 16px 40px rgba(10,22,40,0.10), 0 8px 16px rgba(10,22,40,0.05);
    --radius-card: 14px;
    --radius-lg: 18px;
}

/* ---- HTMX Indicators ---- */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline-flex; }
.htmx-request.htmx-indicator { display: inline-flex; }
@keyframes spin { to { transform: rotate(360deg); } }
.animate-spin { animation: spin 1s linear infinite; }

/* ---- Sidebar ---- */
.sidebar-link {
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    margin-left: -3px;
}
.sidebar-link:hover {
    background: rgba(255,255,255,0.06);
    border-left-color: rgba(255,255,255,0.15);
}
.sidebar-link.active {
    background: var(--accent-bg);
    border-left-color: var(--accent-border);
    color: #fff;
}

/* ---- Skeleton Loaders ---- */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}
.skeleton {
    background: linear-gradient(90deg, #e5e7eb 25%, #f3f4f6 50%, #e5e7eb 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: 0.375rem;
}
.skeleton-text { height: 0.875rem; margin-bottom: 0.5rem; }
.skeleton-lg { height: 1.5rem; width: 40%; margin-bottom: 0.75rem; }
.skeleton-row { display: flex; gap: 1rem; margin-bottom: 0.5rem; }
.skeleton-row > * { flex: 1; height: 2rem; }

/* ---- Toast Notifications ---- */
#toast-container {
    position: fixed; top: 1rem; right: 1rem; z-index: 9999;
    display: flex; flex-direction: column; gap: 0.5rem; pointer-events: none;
}
.toast {
    pointer-events: auto; display: flex; align-items: center; gap: 0.5rem;
    padding: 0.75rem 1rem; border-radius: 0.75rem; font-size: 0.8125rem;
    font-weight: 500; box-shadow: var(--shadow-lg);
    transform: translateX(110%); transition: transform 0.3s ease, opacity 0.3s ease;
    opacity: 0; max-width: 360px; backdrop-filter: blur(8px);
}
.toast.show { transform: translateX(0); opacity: 1; }
.toast-success { background: rgba(236,253,245,0.95); color: #065f46; border: 1px solid #a7f3d0; }
.toast-error { background: rgba(254,242,242,0.95); color: #991b1b; border: 1px solid #fecaca; }
.toast-info { background: rgba(239,246,255,0.95); color: #1e40af; border: 1px solid #bfdbfe; }
.toast-warning { background: rgba(255,251,235,0.95); color: #92400e; border: 1px solid #fde68a; }

/* ---- Badge Palette ---- */
.badge-pending  { background: #dbeafe; color: #1d4ed8; }
.badge-due      { background: #fef3c7; color: #b45309; }
.badge-overdue  { background: #ffedd5; color: #c2410c; }
.badge-critical { background: #fee2e2; color: #b91c1c; }
.badge-paid     { background: #dcfce7; color: #15803d; }
.badge-partial  { background: #fef9c3; color: #a16207; }
.badge-avoir    { background: #f3e8ff; color: #7e22ce; }
.badge-unknown  { background: #f3f4f6; color: #4b5563; }
.badge-active   { background: #dcfce7; color: #15803d; }
.badge-dormant  { background: #fef3c7; color: #b45309; }
.badge-prospect { background: #dbeafe; color: #1d4ed8; }
.badge-a        { background: #dcfce7; color: #15803d; }
.badge-b        { background: #fef3c7; color: #b45309; }
.badge-c        { background: #fee2e2; color: #b91c1c; }

/* ---- Card System ---- */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(10,22,40,0.04);
    transition: box-shadow 0.25s ease;
}
.card:hover { box-shadow: var(--shadow-md); }
.card-flat {
    background: var(--bg-card);
    border-radius: var(--radius-card);
    border: 1px solid rgba(10,22,40,0.06);
}

/* ---- Page Animations ---- */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
main > .px-3, main > .px-4, main > .page-content { animation: fadeInUp 0.35s ease-out; }

/* Staggered entry for children */
.stagger-in > * {
    opacity: 0;
    animation: fadeInUp 0.4s ease-out forwards;
}
.stagger-in > *:nth-child(1) { animation-delay: 0.04s; }
.stagger-in > *:nth-child(2) { animation-delay: 0.08s; }
.stagger-in > *:nth-child(3) { animation-delay: 0.12s; }
.stagger-in > *:nth-child(4) { animation-delay: 0.16s; }
.stagger-in > *:nth-child(5) { animation-delay: 0.20s; }
.stagger-in > *:nth-child(6) { animation-delay: 0.24s; }
.stagger-in > *:nth-child(7) { animation-delay: 0.28s; }
.stagger-in > *:nth-child(8) { animation-delay: 0.32s; }

/* HTMX swap effects */
.htmx-swapping { opacity: 0; transition: opacity 0.15s ease-out; }
.htmx-settling > * { animation: fadeInUp 0.2s ease-out; }

/* ---- KPI Metric Styles (legacy — used in secondary cards) ---- */
.kpi-metric {
    padding: 1.25rem 1.5rem;
    border-left: 3px solid transparent;
    transition: border-color 0.2s ease;
}
.kpi-label {
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}
.kpi-value {
    font-weight: 700;
    line-height: 1.1;
}
.kpi-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.375rem;
}
.kpi-detail {
    font-size: 0.6875rem;
    margin-top: 0.25rem;
}

/* ---- KPI Strip — Dashboard ticker ---- */
.kpi-strip {
    display: flex;
    align-items: stretch;
    background: var(--bg-card);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(10,22,40,0.04);
    overflow: hidden;
    position: relative;
}
.kpi-strip::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, #ef4444 0%, #ef4444 20%, #22c55e 20%, #22c55e 40%, #E8A020 40%, #E8A020 60%, #f59e0b 60%, #f59e0b 80%, #6366f1 80%, #6366f1 100%);
    opacity: 0.7;
}

.kpi-strip__sep {
    width: 1px;
    align-self: stretch;
    background: rgba(10,22,40,0.06);
    flex-shrink: 0;
}

.kpi-cell {
    flex: 1;
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
    padding: 0.875rem 1rem;
    min-width: 0;
    transition: background 0.2s ease;
}
.kpi-cell:hover {
    background: rgba(10,22,40,0.015);
}

/* Icon */
.kpi-cell__icon {
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 1px;
}
.kpi-cell__icon svg {
    width: 1rem;
    height: 1rem;
}
.kpi-cell--danger .kpi-cell__icon  { background: #fef2f2; color: #ef4444; }
.kpi-cell--success .kpi-cell__icon { background: #f0fdf4; color: #22c55e; }
.kpi-cell--warning .kpi-cell__icon { background: #fffbeb; color: #f59e0b; }
.kpi-cell--neutral .kpi-cell__icon { background: #eef2ff; color: #6366f1; }

/* Body — stacks label, value, meta vertically */
.kpi-cell__body {
    min-width: 0;
    flex: 1;
}

.kpi-cell__label {
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    line-height: 1;
    margin-bottom: 0.3rem;
}

.kpi-cell__value {
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1;
    color: #1A2E4A;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
    white-space: nowrap;
}
.kpi-cell--danger .kpi-cell__value  { color: #dc2626; }
.kpi-cell--success .kpi-cell__value { color: #16a34a; }
.kpi-cell--warning .kpi-cell__value { color: #d97706; }
.kpi-cell--neutral .kpi-cell__value { color: #4f46e5; }

.kpi-cell__unit {
    font-size: 0.6875rem;
    font-weight: 500;
    opacity: 0.55;
    margin-left: 1px;
}
.kpi-cell__unit--sm {
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-left: 0.25rem;
}

/* Meta — now below value */
.kpi-cell__meta {
    font-size: 0.6875rem;
    color: var(--text-muted);
    line-height: 1.4;
    margin-top: 0.3rem;
}
.kpi-cell__count {
    font-weight: 700;
    color: var(--text-secondary);
}
.kpi-cell__sub {
    font-size: 0.625rem;
    opacity: 0.8;
}
.kpi-cell__sub--warn { color: #d97706; }
.kpi-cell__sub--good { color: #16a34a; }
.kpi-cell__sub--info { color: #0891b2; }

/* Trends */
.kpi-cell__trend {
    display: inline-flex;
    align-items: center;
    font-size: 0.625rem;
    font-weight: 600;
    padding: 1px 5px;
    border-radius: 4px;
}
.kpi-cell__trend--up {
    color: #dc2626;
    background: #fef2f2;
}
.kpi-cell__trend--down {
    color: #16a34a;
    background: #f0fdf4;
}

/* Gauge (rate) */
.kpi-cell__gauge {
    width: 2.5rem;
    height: 2.5rem;
    position: relative;
    flex-shrink: 0;
    margin-top: 1px;
}
.kpi-cell__gauge svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}
.kpi-gauge__bg {
    stroke: rgba(10,22,40,0.06);
}
.kpi-gauge__fill {
    stroke: #E8A020;
    stroke-linecap: round;
    transition: stroke-dasharray 0.8s ease;
}
.kpi-gauge__text {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.5625rem;
    font-weight: 700;
    color: #1A2E4A;
    letter-spacing: -0.01em;
}

/* ---- KPI Strip — Mobile (stack 2+3) ---- */
@media (max-width: 1023px) {
    .kpi-strip {
        flex-wrap: wrap;
    }
    .kpi-cell {
        flex: 1 1 45%;
        min-width: 160px;
    }
    .kpi-strip__sep {
        display: none;
    }
    .kpi-cell:not(:last-child) {
        border-bottom: 1px solid rgba(10,22,40,0.04);
    }
    /* 3-col rate cell takes full width on tablet */
    .kpi-cell--rate {
        flex: 1 1 100%;
        border-bottom: 1px solid rgba(10,22,40,0.04);
    }
}
@media (max-width: 639px) {
    .kpi-cell {
        flex: 1 1 100%;
        padding: 0.75rem 1rem;
    }
    .kpi-cell--rate {
        flex: 1 1 100%;
    }
    .kpi-cell__gauge {
        width: 2.5rem;
        height: 2.5rem;
    }
}

/* ---- KPI Strip — Dark mode ---- */
html.dark .kpi-strip {
    background: var(--bg-card);
    border-color: rgba(255,255,255,0.04);
}
html.dark .kpi-strip::before { opacity: 0.5; }
html.dark .kpi-strip__sep { background: rgba(255,255,255,0.06); }
html.dark .kpi-cell:hover { background: rgba(255,255,255,0.02); }
html.dark .kpi-cell__value { color: #e5e7eb; }
html.dark .kpi-cell--danger .kpi-cell__value  { color: #f87171; }
html.dark .kpi-cell--success .kpi-cell__value { color: #4ade80; }
html.dark .kpi-cell--warning .kpi-cell__value { color: #fbbf24; }
html.dark .kpi-cell--neutral .kpi-cell__value { color: #818cf8; }
html.dark .kpi-cell--danger .kpi-cell__icon  { background: rgba(239,68,68,0.12); color: #f87171; }
html.dark .kpi-cell--success .kpi-cell__icon { background: rgba(34,197,94,0.12); color: #4ade80; }
html.dark .kpi-cell--warning .kpi-cell__icon { background: rgba(245,158,11,0.12); color: #fbbf24; }
html.dark .kpi-cell--neutral .kpi-cell__icon { background: rgba(99,102,241,0.12); color: #818cf8; }
html.dark .kpi-gauge__bg { stroke: rgba(255,255,255,0.08); }
html.dark .kpi-gauge__fill { stroke: #F0B840; }
html.dark .kpi-gauge__text { color: #e5e7eb; }
html.dark .kpi-cell__trend--up { color: #f87171; background: rgba(239,68,68,0.12); }
html.dark .kpi-cell__trend--down { color: #4ade80; background: rgba(34,197,94,0.12); }

/* ---- Tab Bar ---- */
.tab-bar {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    border-bottom: 1px solid rgba(10,22,40,0.06);
}
.tab-btn {
    padding: 0.625rem 1rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color 0.2s, border-color 0.2s;
    cursor: pointer;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active {
    color: #1A2E4A;
    border-bottom-color: var(--accent-border);
    font-weight: 600;
}

/* Tab badges (counters inside tabs) */
.tab-btn .badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 0.375rem;
    border-radius: 9999px;
    font-size: 0.5625rem;
    font-weight: 700;
    margin-left: 0.5rem;
    vertical-align: middle;
}
.tab-btn .badge--danger  { background: #fef2f2; color: #dc2626; }
.tab-btn .badge--success { background: #f0fdf4; color: #16a34a; }
.tab-btn .badge--muted   { background: #f3f4f6; color: #6b7280; }
.tab-btn .badge--warning { background: #fffbeb; color: #d97706; }

/* ---- Data Tables ---- */
.data-table {
    width: 100%;
    font-size: 0.8125rem;
}
.data-table thead th {
    text-align: left;
    padding: 0.625rem 0.75rem;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    border-bottom: 1px solid rgba(10,22,40,0.06);
}
.data-table tbody td {
    padding: 0.625rem 0.75rem;
    border-bottom: 1px solid rgba(10,22,40,0.03);
    vertical-align: middle;
}
.data-table tbody tr {
    transition: background 0.15s;
}
.data-table tbody tr:hover {
    background: rgba(var(--accent-rgb, 232,160,32), 0.03);
}

/* ---- Status Pills ---- */
.pill {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.1875rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}
.pill--green  { background: #f0fdf4; color: #15803d; }
.pill--amber  { background: #fffbeb; color: #b45309; }
.pill--red    { background: #fef2f2; color: #dc2626; }
.pill--blue   { background: #eff6ff; color: #1d4ed8; }
.pill--black  { background: #1f2937; color: #f9fafb; }

/* ---- Section Headers ---- */
.section-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: #1A2E4A;
}

/* ---- Page Header ---- */
.page-header {
    position: relative;
    padding: 1.5rem 0;
}
.page-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(10,22,40,0.06) 20%, rgba(10,22,40,0.06) 80%, transparent);
}
.page-header__title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1A2E4A;
    letter-spacing: -0.01em;
}
.page-header__subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* ---- Trend Indicators ---- */
.trend-up { color: #dc2626; }
.trend-down { color: #059669; }
.trend-flat { color: var(--text-muted); }

/* ---- Chart Containers ---- */
.chart-container {
    position: relative;
    background: var(--bg-card);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(10,22,40,0.04);
    padding: 1.5rem;
}

/* ---- Chart Card (titled chart wrapper) ---- */
.chart-card {
    background: var(--bg-card);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(10,22,40,0.04);
    padding: 1.25rem;
}
.chart-card__title {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #1A2E4A;
    margin-bottom: 1rem;
}

/* ---- Data Table ---- */
.data-table {
    width: 100%;
    font-size: 0.75rem;
    border-collapse: collapse;
}
.data-table thead th {
    padding: 0.5rem 0.75rem;
    font-size: 0.5625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    border-bottom: 1px solid rgba(10,22,40,0.06);
    text-align: left;
}
.data-table tbody td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid rgba(10,22,40,0.03);
    vertical-align: middle;
}
.data-table tbody tr { transition: background 0.12s; }
.data-table tbody tr:hover { background: rgba(var(--accent-rgb, 232,160,32), 0.025); }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.8125rem;
    font-weight: 600;
    border-radius: 10px;
    border: 1.5px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 0.01em;
    line-height: 1.4;
}
.btn svg { width: 0.875rem; height: 0.875rem; }

.btn--primary {
    background: linear-gradient(135deg, #1A2E4A 0%, #2A4060 100%);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 2px 8px rgba(26,46,74,0.25);
}
.btn--primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(26,46,74,0.35);
}

.btn--ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: rgba(10,22,40,0.12);
}
.btn--ghost:hover {
    background: rgba(10,22,40,0.03);
    border-color: rgba(10,22,40,0.2);
    color: var(--text-primary);
}

.btn--danger {
    background: #fef2f2;
    color: #dc2626;
    border-color: #fecaca;
}
.btn--danger:hover {
    background: #fee2e2;
    border-color: #f87171;
}

.btn--success {
    background: #f0fdf4;
    color: #15803d;
    border-color: #bbf7d0;
}
.btn--success:hover {
    background: #dcfce7;
    border-color: #4ade80;
}

.btn--sm {
    padding: 0.3rem 0.625rem;
    font-size: 0.75rem;
    border-radius: 8px;
}
.btn--sm svg { width: 0.75rem; height: 0.75rem; }

/* ---- Form Select ---- */
.form-select {
    appearance: none;
    -webkit-appearance: none;
    padding: 0.4rem 2rem 0.4rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 500;
    border: 1.5px solid rgba(10,22,40,0.08);
    border-radius: 8px;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%236B7280'%3E%3Cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z'/%3E%3C/svg%3E") right 0.5rem center / 0.875rem no-repeat;
    color: #1A2E4A;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-select:focus {
    outline: none;
    border-color: var(--accent-border, #E8A020);
    box-shadow: 0 0 0 3px rgba(var(--accent-rgb, 232,160,32), 0.1);
}

/* ---- Action Group ---- */
.action-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ---- Loading Spinner ---- */
.loading-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 1rem;
    gap: 1rem;
}
.loading-area__spinner {
    width: 2.5rem;
    height: 2.5rem;
    border: 3px solid rgba(26,46,74,0.1);
    border-top-color: #E8A020;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
.loading-area__text {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* ---- Dark Mode ---- */
html.dark {
    --bg-paper: #0F1118;
    --bg-card: #1A1D27;
    --text-primary: #E8EAF0;
    --text-secondary: #9CA3AF;
    --text-muted: #6B7280;
}
html.dark body { background: #0F1118; color: #e5e7eb; }
html.dark .bg-cream { background: #0F1118; }
html.dark .bg-white, html.dark .card, html.dark .card-flat, html.dark .chart-container, html.dark .chart-card { background: #1A1D27; }
html.dark .text-navy { color: #93c5fd; }
html.dark .text-ink { color: #e5e7eb; }
html.dark .text-gray-500, html.dark .text-gray-400,
html.dark .text-gray-600, html.dark .text-gray-700 { color: #9ca3af; }
html.dark .text-gray-800, html.dark .text-gray-900 { color: #e5e7eb; }
html.dark .border-gray-200, html.dark .border-gray-100,
html.dark .border-gray-50 { border-color: #2A2D37; }
html.dark .bg-gray-50 { background: #1A1D27; }
html.dark input, html.dark select { background: #252830; color: #e5e7eb; border-color: #3A3D47; }
html.dark .hover\:bg-cream\/50:hover { background: rgba(26,29,39,0.5); }
html.dark .card, html.dark .card-flat, html.dark .chart-container, html.dark .chart-card {
    border-color: rgba(255,255,255,0.04);
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
html.dark .toast-success { background: rgba(6,95,70,0.9); color: #a7f3d0; border-color: rgba(167,243,208,0.2); }
html.dark .toast-error { background: rgba(153,27,27,0.9); color: #fecaca; border-color: rgba(254,202,202,0.2); }
html.dark .kpi-label { color: #6B7280; }
html.dark .kpi-sub { color: #6B7280; }
html.dark .section-title { color: #93c5fd; }
html.dark .tab-btn.active { color: #e5e7eb; }
html.dark .tab-bar { border-color: #2A2D37; }
html.dark .data-table thead th { color: #6B7280; border-color: #2A2D37; }
html.dark .data-table tbody td { border-color: rgba(255,255,255,0.03); }
html.dark .data-table tbody tr:hover { background: rgba(232,160,32,0.05); }

/* New components — dark mode */
html.dark .page-header__title { color: #e5e7eb; }
html.dark .page-header::after { background: linear-gradient(90deg, transparent, rgba(255,255,255,0.06) 20%, rgba(255,255,255,0.06) 80%, transparent); }
html.dark .chart-card__title { color: #e5e7eb; }
html.dark .tab-btn .badge--danger  { background: rgba(239,68,68,0.15); color: #f87171; }
html.dark .tab-btn .badge--success { background: rgba(34,197,94,0.15); color: #4ade80; }
html.dark .tab-btn .badge--muted   { background: rgba(255,255,255,0.08); color: #9ca3af; }
html.dark .tab-btn .badge--warning { background: rgba(245,158,11,0.15); color: #fbbf24; }
html.dark .pill--green  { background: rgba(34,197,94,0.15); color: #4ade80; }
html.dark .pill--amber  { background: rgba(245,158,11,0.15); color: #fbbf24; }
html.dark .pill--red    { background: rgba(239,68,68,0.15); color: #f87171; }
html.dark .pill--blue   { background: rgba(59,130,246,0.15); color: #93c5fd; }
html.dark .pill--black  { background: #374151; color: #f9fafb; }
html.dark .btn--primary { background: linear-gradient(135deg, #2A4060 0%, #3A5580 100%); box-shadow: 0 2px 8px rgba(0,0,0,0.3); }
html.dark .btn--ghost { color: #9ca3af; border-color: rgba(255,255,255,0.1); }
html.dark .btn--ghost:hover { background: rgba(255,255,255,0.05); border-color: rgba(255,255,255,0.2); color: #e5e7eb; }
html.dark .btn--danger { background: rgba(239,68,68,0.12); color: #f87171; border-color: rgba(239,68,68,0.25); }
html.dark .btn--danger:hover { background: rgba(239,68,68,0.2); border-color: rgba(239,68,68,0.4); }
html.dark .btn--success { background: rgba(34,197,94,0.12); color: #4ade80; border-color: rgba(34,197,94,0.25); }
html.dark .btn--success:hover { background: rgba(34,197,94,0.2); border-color: rgba(34,197,94,0.4); }
html.dark .form-select { background-color: #252830; color: #e5e7eb; border-color: #3A3D47; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%239CA3AF'%3E%3Cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z'/%3E%3C/svg%3E"); }
html.dark .form-select:focus { border-color: #F0B840; box-shadow: 0 0 0 3px rgba(240,184,64,0.15); }
html.dark .loading-area__spinner { border-color: rgba(255,255,255,0.08); border-top-color: #F0B840; }

/* ---- Cmd+K Search ---- */
#cmdk-overlay {
    position: fixed; inset: 0; z-index: 9998;
    background: rgba(10,22,40,0.5); backdrop-filter: blur(4px);
    display: flex; align-items: flex-start; justify-content: center; padding-top: 15vh;
}
#cmdk-dialog {
    background: #fff; border-radius: 1rem;
    box-shadow: 0 25px 60px rgba(10,22,40,0.25), 0 0 0 1px rgba(10,22,40,0.05);
    width: 100%; max-width: 540px; overflow: hidden;
}
html.dark #cmdk-dialog { background: #1A1D27; }
#cmdk-input {
    width: 100%; padding: 1rem 1.25rem; border: none; outline: none;
    font-size: 1rem; background: transparent; color: inherit;
    font-family: inherit;
}
#cmdk-results { max-height: 320px; overflow-y: auto; border-top: 1px solid #e5e7eb; }
html.dark #cmdk-results { border-color: #2A2D37; }
.cmdk-item {
    padding: 0.625rem 1.25rem; cursor: pointer; display: flex; align-items: center;
    gap: 0.5rem; font-size: 0.875rem; color: #374151; transition: background 0.1s;
}
html.dark .cmdk-item { color: #d1d5db; }
.cmdk-item:hover, .cmdk-item.active { background: rgba(232,160,32,0.06); }
html.dark .cmdk-item:hover, html.dark .cmdk-item.active { background: rgba(232,160,32,0.1); }
.cmdk-item .cmdk-section {
    font-size: 0.625rem; text-transform: uppercase; letter-spacing: 0.05em;
    color: #9ca3af; margin-left: auto;
}
@media (max-width: 639px) {
    #cmdk-overlay { padding-top: 5vh; }
    #cmdk-dialog { max-width: calc(100% - 2rem); }
}

/* ---- Mobile: Table → Cards ---- */
@media (max-width: 639px) {
    .table-responsive thead { display: none; }
    .table-responsive tbody tr {
        display: block; border-radius: var(--radius-card);
        margin-bottom: 0.75rem; padding: 0.75rem;
        background: var(--bg-card); box-shadow: var(--shadow-xs);
    }
    .table-responsive tbody td {
        display: flex; justify-content: space-between; align-items: center;
        padding: 0.25rem 0; border: none;
    }
    .table-responsive tbody td::before {
        content: attr(data-label); font-weight: 600; font-size: 0.75rem;
        color: var(--text-muted); margin-right: 0.5rem; flex-shrink: 0;
    }
    .table-responsive tfoot { display: none; }
}

/* ---- Mobile: Modals → Bottom Sheet ---- */
@media (max-width: 639px) {
    .modal-content {
        max-width: 100% !important; margin: 0 !important;
        border-radius: 1rem 1rem 0 0 !important; max-height: 90vh;
        position: fixed !important; bottom: 0; left: 0; right: 0;
    }
}

/* ---- Mobile: Touch Targets ---- */
@media (max-width: 639px) {
    button, [role="button"], select { min-height: 44px; }
    .status-chip, .preset-btn, .cedant-filter-btn { min-height: 36px; display: inline-flex; align-items: center; }
}

/* ---- Bottom Navigation ---- */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
    background: linear-gradient(180deg, #152740 0%, #0A1628 100%);
    display: flex; justify-content: space-around; align-items: center;
    padding: 0.25rem 0; padding-bottom: max(0.25rem, env(safe-area-inset-bottom));
    border-top: 1px solid rgba(255,255,255,0.06);
}
.bottom-nav-item {
    display: flex; flex-direction: column; align-items: center; gap: 0.125rem;
    padding: 0.375rem 0.5rem; border-radius: 0.5rem;
    color: rgba(255,255,255,0.5); font-size: 0.625rem; font-weight: 500;
    text-decoration: none; transition: all 0.15s; min-width: 3.5rem;
}
.bottom-nav-item:hover, .bottom-nav-item.active { color: var(--accent-border); }
.bottom-nav-item.active { background: var(--accent-bg); }
.bottom-nav-item svg { width: 1.25rem; height: 1.25rem; }

/* ---- More Drawer ---- */
.more-drawer-overlay { position: fixed; inset: 0; z-index: 45; background: rgba(10,22,40,0.5); backdrop-filter: blur(2px); }
.more-drawer {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 46;
    background: #fff; border-radius: 1.25rem 1.25rem 0 0; padding: 1.5rem 1rem;
    padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
    transform: translateY(100%); transition: transform 0.3s ease;
    box-shadow: 0 -8px 32px rgba(10,22,40,0.12);
}
.more-drawer.open { transform: translateY(0); }
.more-drawer-item {
    display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem;
    border-radius: 0.75rem; color: #374151; font-size: 0.875rem; font-weight: 500;
    text-decoration: none; transition: background 0.15s;
}
.more-drawer-item:hover { background: #f3f4f6; }
.more-drawer-item svg { width: 1.25rem; height: 1.25rem; color: #6b7280; }
html.dark .more-drawer { background: #1A1D27; }
html.dark .more-drawer-item { color: #d1d5db; }
html.dark .more-drawer-item:hover { background: #252830; }

/* ---- Collapsible Filters (mobile) ---- */
@media (max-width: 639px) {
    .filters-collapsible {
        max-height: 0; overflow: hidden; opacity: 0;
        transition: max-height 0.3s ease, opacity 0.25s ease;
    }
    .filters-collapsible.open { max-height: 1000px; opacity: 1; }
}

/* ---- Keyboard Shortcuts ---- */
#shortcuts-overlay {
    position: fixed; inset: 0; z-index: 9997;
    background: rgba(10,22,40,0.5); backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
}
#shortcuts-dialog {
    background: #fff; border-radius: 1rem; padding: 1.5rem;
    box-shadow: var(--shadow-xl); max-width: 420px; width: 100%;
}
html.dark #shortcuts-dialog { background: #1A1D27; color: #e5e7eb; }
.kbd {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 1.5rem; padding: 0.125rem 0.375rem;
    background: #f3f4f6; border: 1px solid #d1d5db; border-bottom-width: 2px;
    border-radius: 0.375rem; font-size: 0.6875rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: #374151;
}
html.dark .kbd { background: #252830; border-color: #3A3D47; color: #d1d5db; }

/* ---- Module Switcher ---- */
.module-switcher-menu {
    position: absolute; top: 100%; left: 0.75rem; right: 0.75rem; margin-top: 0.25rem;
    background: #152740; border: 1px solid rgba(255,255,255,0.08); border-radius: 0.75rem;
    overflow: hidden; z-index: 50; box-shadow: 0 10px 30px rgba(0,0,0,0.35);
    max-height: 0; opacity: 0; transition: max-height 0.25s ease, opacity 0.2s ease;
}
.module-switcher-menu.open { max-height: 300px; opacity: 1; }
.module-switcher-item {
    display: flex; align-items: center; gap: 0.5rem; padding: 0.625rem 0.75rem;
    font-size: 0.8125rem; color: rgba(255,255,255,0.65); transition: all 0.15s; text-decoration: none;
}
.module-switcher-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.module-switcher-item.current { color: var(--accent-border); font-weight: 600; }

/* ---- Accent Button ---- */
.btn--accent {
    background: linear-gradient(135deg, var(--accent-border) 0%, var(--accent-border) 100%);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 2px 8px rgba(var(--accent-rgb, 20,184,166), 0.3);
}
.btn--accent:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(var(--accent-rgb, 20,184,166), 0.4);
    filter: brightness(1.08);
}
html.dark .btn--accent {
    box-shadow: 0 2px 8px rgba(var(--accent-rgb, 20,184,166), 0.2);
}

/* ---- KPI Cell — Accent variant ---- */
.kpi-cell--accent .kpi-cell__icon { background: rgba(var(--accent-rgb, 20,184,166), 0.1); color: var(--accent-border); }
.kpi-cell--accent .kpi-cell__value { color: var(--accent-border); }
html.dark .kpi-cell--accent .kpi-cell__icon { background: rgba(var(--accent-rgb, 20,184,166), 0.15); color: var(--accent-border); }
html.dark .kpi-cell--accent .kpi-cell__value { color: var(--accent-border); }

/* ---- Form Input ---- */
.form-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
    border: 1.5px solid rgba(10,22,40,0.08);
    border-radius: 8px;
    background: #fff;
    color: #1A2E4A;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-input:focus {
    outline: none;
    border-color: var(--accent-border, #E8A020);
    box-shadow: 0 0 0 3px rgba(var(--accent-rgb, 232,160,32), 0.1);
}
.form-input::placeholder { color: var(--text-muted); }
html.dark .form-input { background: #252830; color: #e5e7eb; border-color: #3A3D47; }
html.dark .form-input:focus { border-color: var(--accent-border, #F0B840); box-shadow: 0 0 0 3px rgba(var(--accent-rgb, 240,184,64), 0.15); }

/* ---- Form Label ---- */
.form-label {
    display: block;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-bottom: 0.375rem;
}

/* ---- Pill — Teal & Purple variants ---- */
.pill--teal   { background: #f0fdfa; color: #0f766e; }
.pill--purple { background: #faf5ff; color: #7e22ce; }
html.dark .pill--teal   { background: rgba(20,184,166,0.15); color: #5eead4; }
html.dark .pill--purple { background: rgba(168,85,247,0.15); color: #c4b5fd; }

/* ---- Progress Bar ---- */
.progress-bar {
    width: 100%;
    height: 0.625rem;
    background: rgba(10,22,40,0.06);
    border-radius: 9999px;
    overflow: hidden;
}
.progress-bar__fill {
    height: 100%;
    border-radius: 9999px;
    background: var(--accent-border, #14b8a6);
    transition: width 0.5s ease;
}
html.dark .progress-bar { background: rgba(255,255,255,0.08); }

/* ---- Timeline ---- */
.timeline__item {
    position: relative;
    padding-left: 0.875rem;
    border-left: 2px solid rgba(10,22,40,0.08);
    padding-bottom: 0.75rem;
}
.timeline__item:last-child { padding-bottom: 0; }
.timeline__item--green  { border-left-color: #22c55e; }
.timeline__item--purple { border-left-color: #a855f7; }
.timeline__item--blue   { border-left-color: #3b82f6; }
.timeline__item--amber  { border-left-color: #f59e0b; }
.timeline__item--red    { border-left-color: #ef4444; }
.timeline__item--gray   { border-left-color: rgba(10,22,40,0.12); }
html.dark .timeline__item { border-left-color: rgba(255,255,255,0.08); }
html.dark .timeline__item--green  { border-left-color: #4ade80; }
html.dark .timeline__item--purple { border-left-color: #c084fc; }
html.dark .timeline__item--blue   { border-left-color: #60a5fa; }
html.dark .timeline__item--amber  { border-left-color: #fbbf24; }
html.dark .timeline__item--red    { border-left-color: #f87171; }
html.dark .timeline__item--gray   { border-left-color: rgba(255,255,255,0.12); }

/* ---- Accent Utilities ---- */
.accent-bar { border-left: 3px solid var(--accent-border); }
.gold-text { color: #C88810; }
