/* ── Design tokens ───────────────────────────────────────────── */
:root {
    --yellow:        #fcc201;
    --yellow-dim:    rgba(252,194,1,0.12);
    --dark:          #0d0d0d;
    --dark-2:        #1a1a1a;
    --bg:            #f4f6f9;
    --bg-card:       #ffffff;
    --text:          #0f172a;
    --text-2:        #475569;
    --text-3:        #94a3b8;
    --border:        rgba(0,0,0,0.07);
    --border-strong: rgba(0,0,0,0.12);
    --shadow-xs:     0 1px 2px rgba(0,0,0,0.05);
    --shadow-sm:     0 1px 3px rgba(0,0,0,0.06), 0 2px 8px rgba(0,0,0,0.04);
    --shadow-md:     0 4px 12px rgba(0,0,0,0.07), 0 1px 3px rgba(0,0,0,0.05);
    --r-sm:          6px;
    --r-md:          10px;
    --r-lg:          14px;
}

/* ── Reset ───────────────────────────────────────────────────── */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    font-size: 14px;
    line-height: 1.5;
}

/* ── Login ───────────────────────────────────────────────────── */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: #f5f5f5;
}

.login-container {
    background: #161616;
    padding: 44px 40px;
    border-radius: var(--r-lg);
    width: 400px;
    text-align: center;
    border: 1px solid rgba(255,255,255,0.08);
    box-shadow: 0 24px 64px rgba(0,0,0,0.5);
}

.login-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 10px;
}

.login-container h2 {
    color: var(--yellow);
    font-size: 0.88em;
    font-weight: 400;
    margin-bottom: 32px;
}

.login-container label {
    display: block;
    text-align: left;
    font-size: 0.78em;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 5px;
    margin-top: 18px;
}

.login-container input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--r-sm);
    font-size: 0.94em;
    font-family: inherit;
    background: rgba(255,255,255,0.05);
    color: white;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.login-container input:focus {
    outline: none;
    border-color: var(--yellow);
    box-shadow: 0 0 0 3px rgba(252,194,1,0.15);
}

.login-container button {
    width: 100%;
    padding: 11px;
    margin-top: 26px;
    background: var(--yellow);
    color: #111;
    border: none;
    border-radius: var(--r-sm);
    font-size: 0.9em;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    letter-spacing: 0.5px;
    transition: opacity 0.15s, transform 0.1s;
}

.login-container button:hover { opacity: 0.9; transform: translateY(-1px); }
.login-container button:active { transform: translateY(0); }

.error-msg {
    background: rgba(239,68,68,0.1);
    color: #f87171;
    border: 1px solid rgba(239,68,68,0.25);
    padding: 10px 14px;
    border-radius: var(--r-sm);
    font-size: 0.88em;
    margin-bottom: 12px;
}

.login-note {
    margin-top: 22px;
    font-size: 0.78em;
    color: var(--yellow);
}

/* ── Page loading overlay (global, shown on any filter/form change) ── */
#page-loading-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(244,246,249,0.78);
    z-index: 500;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 14px;
}
#page-loading-overlay.active { display: flex; }
#page-loading-overlay .overlay-spinner {
    width: 38px;
    height: 38px;
    border: 3px solid rgba(0,0,0,0.1);
    border-top-color: var(--yellow);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
#page-loading-overlay p {
    font-size: 0.88em;
    color: #666;
    margin: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Top bar ─────────────────────────────────────────────────── */
.topbar {
    background: var(--dark);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 54px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 0 rgba(255,255,255,0.06), 0 2px 12px rgba(0,0,0,0.3);
}

.topbar-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: 24px;
    text-decoration: none;
    flex-shrink: 0;
}

.topbar-logo-badge {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    flex-shrink: 0;
}

.topbar-logo-text {
    font-family: 'Montserrat', sans-serif;
    font-weight: 900;
    font-size: 1.35rem;
    color: #ffffff;
    letter-spacing: 1.5px;
    line-height: 1;
}

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

.topbar-user {
    font-size: 0.82em;
    color: rgba(255,255,255,0.4);
    margin-right: 10px;
    white-space: nowrap;
}

.topbar-logout {
    color: rgba(255,255,255,0.55);
    text-decoration: none;
    font-size: 0.8em;
    font-weight: 500;
    padding: 5px 12px;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 20px;
    transition: all 0.15s;
    white-space: nowrap;
}

.topbar-logout:hover {
    color: white;
    border-color: rgba(255,255,255,0.3);
    background: rgba(255,255,255,0.06);
}

/* ── Nav links ───────────────────────────────────────────────── */
.nav-links {
    display: flex;
    align-items: center;
    gap: 2px;
}

.nav-link {
    color: rgba(255,255,255,0.5);
    text-decoration: none;
    font-size: 0.82em;
    font-weight: 500;
    padding: 5px 13px;
    border-radius: 20px;
    transition: all 0.15s;
    white-space: nowrap;
    letter-spacing: 0.1px;
}

.nav-link:hover {
    color: rgba(255,255,255,0.9);
    background: rgba(255,255,255,0.07);
}

.nav-link.active {
    background: var(--yellow);
    color: #111;
    font-weight: 600;
}

/* ── Page content ────────────────────────────────────────────── */
.page-content {
    max-width: 1440px;
    margin: 0 auto;
    padding: 28px 32px;
}

/* ── Alert ───────────────────────────────────────────────────── */
.alert-error {
    background: #fff1f2;
    color: #be123c;
    border: 1px solid #fecdd3;
    padding: 12px 16px;
    border-radius: var(--r-md);
    margin-bottom: 20px;
    font-size: 0.88em;
}

/* ── Summary cards ───────────────────────────────────────────── */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 28px;
}

.card {
    background: var(--bg-card);
    padding: 22px 24px;
    border-radius: var(--r-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
    transition: box-shadow 0.2s, transform 0.2s;
}

.card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--yellow);
    border-radius: var(--r-lg) var(--r-lg) 0 0;
}

.card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.card-value {
    font-size: 2em;
    font-weight: 700;
    color: var(--text);
    line-height: 1.1;
    letter-spacing: -0.5px;
}

.card-label {
    font-size: 0.75em;
    color: var(--text-3);
    margin-top: 6px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.card-delta {
    font-size: 0.75em;
    margin-top: 8px;
    color: var(--text-3);
    font-weight: 500;
}

/* ── Chart boxes ─────────────────────────────────────────────── */
.chart-box {
    background: var(--bg-card);
    border-radius: var(--r-lg);
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.chart-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 16px;
}
.chart-grid-2 > div { min-width: 0; }
@media (max-width: 900px) { .chart-grid-2 { grid-template-columns: 1fr; } }

/* ── Section header ──────────────────────────────────────────── */
.section-header {
    font-size: 0.78em;
    font-weight: 700;
    color: var(--text-3);
    margin: 28px 0 12px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

/* ── Filter form ─────────────────────────────────────────────── */
.filter-bar {
    background: #1a1a1a;
    padding: 10px 20px;
    margin-bottom: 24px;
    border-bottom: 3px solid var(--yellow);
    box-shadow: 0 4px 12px rgba(0,0,0,0.18);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
    position: sticky;
    top: 54px;
    z-index: 90;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.filter-group label {
    font-size: 0.68em;
    font-weight: 600;
    color: rgba(255,255,255,0.45);
    text-transform: uppercase;
    letter-spacing: 0.7px;
}

.filter-select, .filter-input {
    padding: 6px 12px;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: var(--r-sm);
    font-size: 0.84em;
    font-family: inherit;
    background: rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.9);
    transition: border-color 0.15s, background 0.15s;
    min-width: 130px;
    cursor: pointer;
}

.filter-select:focus, .filter-input:focus {
    outline: none;
    border-color: var(--yellow);
    background: rgba(255,255,255,0.12);
}

.filter-select option { background: #1a1a1a; color: white; }

.filter-actions {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding-bottom: 0;
    margin-top: auto;
}

.btn-primary {
    padding: 7px 18px;
    background: var(--dark);
    color: var(--yellow);
    border: none;
    border-radius: var(--r-sm);
    font-size: 0.86em;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: opacity 0.15s;
}
.btn-primary:hover { opacity: 0.85; }

.btn-secondary {
    padding: 7px 14px;
    background: transparent;
    color: var(--text-2);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    font-size: 0.86em;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
    display: inline-block;
}
.btn-secondary:hover {
    background: var(--bg);
    border-color: #999;
    color: var(--text);
}

/* Filter bar dark-context overrides */
.filter-bar .btn-secondary {
    color: rgba(255,255,255,0.85);
    border-color: rgba(255,255,255,0.35);
}
.filter-bar .btn-secondary:hover {
    background: rgba(255,255,255,0.12);
    border-color: white;
    color: white;
}
.filter-bar .btn-preset {
    background: rgba(255,255,255,0.07);
    color: rgba(255,255,255,0.75);
    border-color: rgba(255,255,255,0.15);
}
.filter-bar .btn-preset:hover {
    background: rgba(255,255,255,0.15);
    color: white;
    border-color: rgba(255,255,255,0.3);
}
.filter-bar .btn-preset.active {
    background: var(--yellow);
    color: #111;
    border-color: var(--yellow);
    font-weight: 700;
}

.btn-export {
    padding: 5px 12px;
    background: white;
    color: var(--text-2);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    font-size: 0.78em;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
}
.btn-export:hover { background: var(--bg); }

/* ── Date range picker ───────────────────────────────────────── */
/* Nav bar filters (env, team, analyst, granularity, reset) */
.nav-filter-form {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-right: 10px;
}
.nav-filter-select {
    padding: 4px 26px 4px 10px;
    border: 1px solid rgba(255,255,255,0.16);
    border-radius: 20px;
    font-size: 0.76em;
    font-family: inherit;
    background: rgba(255,255,255,0.08)
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath fill='rgba(255,255,255,0.5)' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E")
        no-repeat right 9px center;
    color: rgba(255,255,255,0.85);
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    transition: all 0.15s;
}
.nav-filter-select:focus {
    outline: none;
    border-color: var(--yellow);
    background-color: rgba(255,255,255,0.12);
}
.nav-filter-select option { background: #1a1a1a; color: white; }
.nav-filter-sep {
    width: 1px;
    height: 18px;
    background: rgba(255,255,255,0.12);
    margin: 0 4px;
}
.nav-reset-btn {
    color: rgba(255,255,255,0.45);
    font-size: 0.76em;
    text-decoration: none;
    padding: 4px 11px;
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.12);
    transition: all 0.15s;
    white-space: nowrap;
}
.nav-reset-btn:hover { color: white; border-color: rgba(255,255,255,0.3); background: rgba(255,255,255,0.07); }
/* Env toggle buttons inside nav (dark background variant) */
.nav-filter-form .btn-preset {
    background: rgba(255,255,255,0.07);
    color: rgba(255,255,255,0.75);
    border-color: rgba(255,255,255,0.15);
}
.nav-filter-form .btn-preset:hover {
    background: rgba(255,255,255,0.15);
    color: white;
    border-color: rgba(255,255,255,0.3);
}

/* Nav bar date picker button */
.nav-dp-wrap { position: relative; }
.nav-dp-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 13px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.16);
    border-radius: 20px;
    color: rgba(255,255,255,0.85);
    font-size: 0.78em;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
    margin-right: 12px;
}
.nav-dp-btn:hover { background: rgba(255,255,255,0.14); border-color: rgba(255,255,255,0.28); }
.nav-dp-btn.dp-active { background: var(--yellow); border-color: var(--yellow); color: #111; }
.nav-dp-btn.dp-active .dp-arrow { color: #555; }

.dp-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 7px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    font-size: 0.86em;
    font-family: inherit;
    background: var(--bg);
    color: var(--text);
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
    white-space: nowrap;
    min-width: 170px;
}
.dp-btn:hover, .dp-btn.dp-active {
    border-color: var(--yellow);
    box-shadow: 0 0 0 3px var(--yellow-dim);
    background: white;
}
.dp-arrow { color: var(--text-3); font-size: 0.72em; margin-left: 4px; }

.dp-popover {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    z-index: 9999;
    background: white;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: row;
    width: 420px;
    overflow: hidden;
}

.dp-presets {
    flex: 0 0 160px;
    background: var(--bg);
    border-right: 1px solid var(--border);
    padding: 8px 0;
    display: flex;
    flex-direction: column;
}
.dp-presets-title {
    font-size: 0.68em;
    font-weight: 700;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.7px;
    padding: 6px 14px 8px;
}
.dp-preset {
    padding: 7px 14px;
    font-size: 0.86em;
    font-family: inherit;
    color: var(--text-2);
    cursor: pointer;
    transition: background 0.1s;
    border: none;
    background: none;
    text-align: left;
    width: 100%;
}
.dp-preset:hover  { background: white; color: var(--text); }
.dp-preset.active { background: var(--yellow); color: #111; font-weight: 600; }

.dp-custom {
    flex: 1;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.dp-custom-title {
    font-size: 0.68em;
    font-weight: 700;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.7px;
    margin-bottom: 2px;
}
.dp-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.dp-field label {
    font-size: 0.75em;
    font-weight: 600;
    color: var(--text-2);
    text-transform: none;
    letter-spacing: 0;
}
.dp-date-input {
    padding: 7px 10px;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    font-size: 0.86em;
    font-family: inherit;
    color: var(--text);
    background: var(--bg);
    width: 100%;
    box-sizing: border-box;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.dp-date-input:focus {
    outline: none;
    border-color: var(--yellow);
    box-shadow: 0 0 0 3px var(--yellow-dim);
    background: white;
}
.dp-apply {
    margin-top: 4px;
    padding: 8px 0;
    background: var(--dark);
    color: var(--yellow);
    border: none;
    border-radius: var(--r-sm);
    font-size: 0.86em;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    width: 100%;
    transition: opacity 0.15s;
}
.dp-apply:hover { opacity: 0.85; }

.preset-buttons {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-top: auto;
}

.btn-preset {
    padding: 5px 12px;
    background: var(--bg);
    color: var(--text-2);
    border: 1px solid var(--border-strong);
    border-radius: 20px;
    font-size: 0.78em;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
}
.btn-preset:hover { background: var(--yellow); color: #111; border-color: var(--yellow); }
.btn-preset-on { background: var(--yellow) !important; color: #111 !important; border-color: var(--yellow) !important; }

.env-toggle { display: flex; gap: 5px; flex-wrap: wrap; }

/* ── KPI Table ───────────────────────────────────────────────── */
.table-wrap {
    background: var(--bg-card);
    border-radius: var(--r-lg);
    overflow: auto;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
}

.kpi-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.86em;
}

.kpi-table thead th {
    background: var(--bg);
    color: var(--text-3);
    padding: 11px 16px;
    text-align: left;
    font-weight: 700;
    font-size: 0.72em;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    border-bottom: 1px solid var(--border-strong);
    transition: background 0.1s;
}

.kpi-table thead th:hover { background: #edf0f4; color: var(--text-2); }
.kpi-table thead th.num { text-align: right; }

.kpi-table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background 0.1s;
}
.kpi-table tbody tr:last-child { border-bottom: none; }
.kpi-table tbody tr:hover { background: #fafbff; }

.kpi-table td {
    padding: 10px 16px;
    color: var(--text);
}

.kpi-table td.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: var(--text-2);
}
.kpi-table td.analyst-name { font-weight: 500; }

/* ── Severity badges ─────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.75em;
    font-weight: 600;
}
.badge-pending  { background: #fef9c3; color: #854d0e; }
.badge-approved { background: #dcfce7; color: #166534; }
.badge-rejected { background: #fee2e2; color: #991b1b; }
.badge-default  { background: var(--bg); color: var(--text-2); border: 1px solid var(--border-strong); }

/* ── Sparkline ───────────────────────────────────────────────── */
.sparkline-box {
    background: var(--bg);
    border-radius: var(--r-sm);
    padding: 10px;
    margin-top: 8px;
    height: 80px;
}

/* ── Stat grid (system health) ───────────────────────────────── */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--r-lg);
    padding: 18px 20px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 14px;
    transition: box-shadow 0.15s;
}
.stat-card:hover { box-shadow: var(--shadow-md); }

.stat-icon {
    font-size: 1.6em;
    width: 40px;
    text-align: center;
    flex-shrink: 0;
}

.stat-value {
    font-size: 1.6em;
    font-weight: 700;
    color: var(--text);
    line-height: 1.1;
    letter-spacing: -0.5px;
}

.stat-label {
    font-size: 0.72em;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
    margin-top: 2px;
}

.env-label {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 0.72em;
    font-weight: 600;
}
.env-amazon    { background: #eff6ff; color: #1d4ed8; }
.env-nonamazon { background: #fff7ed; color: #c2410c; }

/* ── Misc ────────────────────────────────────────────────────── */
.loading { color: var(--text-3); font-size: 0.88em; }

.no-data {
    color: var(--text-3);
    font-size: 0.88em;
    padding: 40px 20px;
    text-align: center;
}

.spinner {
    width: 28px;
    height: 28px;
    border: 2.5px solid var(--border-strong);
    border-top-color: var(--yellow);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin: 40px auto;
    display: block;
}
@keyframes spin { to { transform: rotate(360deg); } }
