/* ===========================================================================
   Cloud Cost Intelligence - core design system
   A single source of truth for colour, spacing, typography and components.
   Page-specific rules live in their own files (dashboard.css, etc.).
   =========================================================================== */

/* ---------------------------------------------------------------- tokens */
:root {
    /* Brand + interface colours (enterprise financial-analytics palette) */
    --navy-900: #0b1220;
    --navy-800: #111c31;
    --navy-700: #1b2942;
    --navy-600: #26364f;

    --brand-600: #2563eb;
    --brand-500: #3b82f6;
    --brand-100: #dbeafe;
    --brand-50:  #eff6ff;

    --accent-600: #4f46e5;
    --accent-100: #e0e7ff;

    /* Semantic colours */
    --success-700: #047857;
    --success-600: #059669;
    --success-100: #d1fae5;
    --warning-700: #b45309;
    --warning-600: #d97706;
    --warning-100: #fef3c7;
    --danger-700:  #b91c1c;
    --danger-600:  #dc2626;
    --danger-100:  #fee2e2;
    --info-600:    #0891b2;
    --info-100:    #cffafe;

    /* Neutrals */
    --ink-900: #0f172a;
    --ink-700: #334155;
    --ink-500: #64748b;
    --ink-400: #94a3b8;
    --ink-300: #cbd5e1;
    --line:    #e5e9f0;
    --line-soft: #eef2f7;
    --surface: #ffffff;
    --surface-alt: #f8fafc;
    --canvas:  #f4f6fa;

    /* Chart series palette (colour-blind friendly, used by charts.js) */
    --chart-1: #2563eb;
    --chart-2: #0891b2;
    --chart-3: #7c3aed;
    --chart-4: #059669;
    --chart-5: #d97706;
    --chart-6: #db2777;
    --chart-7: #475569;

    /* Elevation + geometry */
    --radius-sm: 6px;
    --radius:    10px;
    --radius-lg: 14px;
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, .06);
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, .08);
    --shadow-lg: 0 12px 32px rgba(15, 23, 42, .12);

    /* Layout metrics */
    --sidebar-w: 252px;
    --topbar-h: 62px;

    --font: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    --font-mono: "JetBrains Mono", "Consolas", "SF Mono", monospace;
}

/* ---------------------------------------------------------------- reset */
*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.55;
    color: var(--ink-900);
    background: var(--canvas);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
p  { margin: 0 0 10px; }
a  { color: var(--brand-600); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, select, textarea { font: inherit; color: inherit; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--ink-300); border-radius: 8px; border: 3px solid var(--canvas); }
::-webkit-scrollbar-thumb:hover { background: var(--ink-400); }

/* ---------------------------------------------------------------- shell */
.app-shell { display: flex; min-height: 100vh; }

/* ------------------------------------------------------------- sidebar */
.sidebar {
    width: var(--sidebar-w);
    flex: 0 0 var(--sidebar-w);
    background: linear-gradient(180deg, var(--navy-900) 0%, var(--navy-800) 100%);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    transition: transform .22s ease;
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: 11px;
    height: var(--topbar-h);
    padding: 0 18px;
    border-bottom: 1px solid rgba(255, 255, 255, .07);
    flex: 0 0 auto;
}

.sidebar__logo {
    width: 34px; height: 34px;
    flex: 0 0 34px;
    border-radius: 9px;
    background: linear-gradient(135deg, var(--brand-500), var(--accent-600));
    display: grid; place-items: center;
    color: #fff; font-weight: 700; font-size: 13px;
    box-shadow: 0 3px 10px rgba(59, 130, 246, .35);
}

.sidebar__title { color: #fff; font-size: 14px; font-weight: 650; line-height: 1.2; }
.sidebar__subtitle { font-size: 10.5px; color: #7e8ca3; text-transform: uppercase; letter-spacing: .07em; }

.sidebar__nav { flex: 1 1 auto; overflow-y: auto; padding: 14px 12px 20px; }
.sidebar__nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.14); border-color: transparent; }

.nav-group__label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .09em;
    color: #64748b;
    font-weight: 600;
    padding: 14px 10px 7px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 11px;
    margin-bottom: 2px;
    border-radius: 8px;
    color: #b6c2d4;
    font-size: 13.2px;
    font-weight: 500;
    transition: background .15s, color .15s;
}
.nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.nav-link.is-active {
    background: linear-gradient(90deg, rgba(59,130,246,.20), rgba(79,70,229,.10));
    color: #fff;
    box-shadow: inset 3px 0 0 var(--brand-500);
}
.nav-link__icon { width: 18px; height: 18px; flex: 0 0 18px; opacity: .9; }
.nav-link__badge {
    margin-left: auto;
    background: var(--danger-600);
    color: #fff;
    font-size: 10.5px;
    font-weight: 600;
    padding: 1px 7px;
    border-radius: 999px;
}

.sidebar__footer {
    flex: 0 0 auto;
    padding: 12px 14px;
    border-top: 1px solid rgba(255, 255, 255, .07);
    font-size: 11px;
    color: #64748b;
}

/* -------------------------------------------------------------- topbar */
.main { flex: 1 1 auto; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }

.topbar {
    height: var(--topbar-h);
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 30;
}

.topbar__toggle {
    display: none;
    background: none; border: none; cursor: pointer;
    padding: 6px; border-radius: 8px; color: var(--ink-700);
}
.topbar__toggle:hover { background: var(--surface-alt); }

.topbar__heading { min-width: 0; }
.topbar__title { font-size: 16px; font-weight: 650; }
.topbar__subtitle {
    font-size: 12px; color: var(--ink-500);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.topbar__actions { margin-left: auto; display: flex; align-items: center; gap: 12px; }

.env-pill {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--success-100); color: var(--success-700);
    font-size: 11.5px; font-weight: 600;
    padding: 4px 10px; border-radius: 999px;
}
.env-pill__dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.user-chip {
    display: flex; align-items: center; gap: 9px;
    padding: 4px 6px 4px 4px; border-radius: 999px;
    border: 1px solid var(--line); background: #fff;
}
.user-chip__avatar {
    width: 30px; height: 30px; border-radius: 50%;
    background: linear-gradient(135deg, var(--brand-600), var(--accent-600));
    color: #fff; font-size: 12px; font-weight: 600;
    display: grid; place-items: center;
}
.user-chip__name { font-size: 12.5px; font-weight: 600; line-height: 1.1; }
.user-chip__role { font-size: 10.5px; color: var(--ink-500); text-transform: capitalize; }

/* ------------------------------------------------------------- content */
.content { flex: 1 1 auto; padding: 22px 24px 40px; max-width: 1600px; width: 100%; }

.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head__title { font-size: 20px; font-weight: 650; }
.page-head__desc { font-size: 13px; color: var(--ink-500); }
.page-head__actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* Slim strip above page content: data freshness on the left, actions right.
   The sticky topbar already shows the page title, so it is not repeated here. */
.page-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-toolbar__stamp { font-size: 12.5px; color: var(--ink-500); display: inline-flex; align-items: center; gap: 6px; }

/* --------------------------------------------------------------- cards */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
}
.card__head {
    display: flex; align-items: center; gap: 12px;
    padding: 15px 18px;
    border-bottom: 1px solid var(--line-soft);
}
.card__title { font-size: 14px; font-weight: 620; }
.card__hint { font-size: 12px; color: var(--ink-500); }
.card__actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card__body { padding: 18px; }
.card__body--flush { padding: 0; }

/* ------------------------------------------------------------ kpi tile */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.kpi {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 16px 17px;
    box-shadow: var(--shadow-xs);
    position: relative;
    overflow: hidden;
}
.kpi::after {
    content: ""; position: absolute; inset: 0 0 auto 0; height: 3px;
    background: var(--brand-500); opacity: .9;
}
.kpi--success::after { background: var(--success-600); }
.kpi--warning::after { background: var(--warning-600); }
.kpi--danger::after  { background: var(--danger-600); }
.kpi--accent::after  { background: var(--accent-600); }

.kpi__label {
    font-size: 11.5px; font-weight: 600; color: var(--ink-500);
    text-transform: uppercase; letter-spacing: .05em;
    display: flex; align-items: center; gap: 6px;
}
.kpi__value { font-size: 24px; font-weight: 680; letter-spacing: -.02em; margin-top: 6px; }
.kpi__meta { font-size: 12px; color: var(--ink-500); margin-top: 4px; display: flex; align-items: center; gap: 6px; }

.trend { display: inline-flex; align-items: center; gap: 3px; font-weight: 600; font-size: 12px; }
.trend--up   { color: var(--danger-600); }    /* cost going up is bad news */
.trend--down { color: var(--success-600); }
.trend--flat { color: var(--ink-500); }

/* -------------------------------------------------------------- charts */
.chart-grid { display: grid; gap: 14px; margin-bottom: 18px; }
.chart-grid--2 { grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); }
.chart-grid--3 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }

.chart-box { position: relative; width: 100%; }
.chart-box--sm { height: 220px; }
.chart-box--md { height: 280px; }
.chart-box--lg { height: 340px; }

/* -------------------------------------------------------------- tables */
.table-wrap { width: 100%; overflow-x: auto; }

.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table thead th {
    text-align: left;
    font-size: 11px; font-weight: 650;
    text-transform: uppercase; letter-spacing: .05em;
    color: var(--ink-500);
    background: var(--surface-alt);
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
    position: sticky; top: 0; z-index: 1;
}
.table tbody td { padding: 11px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--brand-50); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .strong { font-weight: 620; }
.table__foot td { font-weight: 650; background: var(--surface-alt); border-top: 1px solid var(--line); }

.table--sortable thead th { cursor: pointer; user-select: none; }
.table--sortable thead th::after { content: "\2195"; opacity: .28; margin-left: 5px; font-size: 10px; }
.table--sortable thead th.sort-asc::after  { content: "\2191"; opacity: .85; }
.table--sortable thead th.sort-desc::after { content: "\2193"; opacity: .85; }

/* -------------------------------------------------------------- badges */
.badge {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 11.5px; font-weight: 600;
    padding: 3px 9px; border-radius: 999px;
    background: var(--surface-alt); color: var(--ink-700);
    border: 1px solid var(--line);
    white-space: nowrap;
}
.badge--critical { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.badge--high     { background: var(--danger-100); color: var(--danger-700); border-color: #fecaca; }
.badge--medium   { background: var(--warning-100); color: var(--warning-700); border-color: #fde68a; }
.badge--low      { background: var(--success-100); color: var(--success-700); border-color: #a7f3d0; }
.badge--info     { background: var(--info-100); color: #0e7490; border-color: #a5f3fc; }
.badge--neutral  { background: #f1f5f9; color: var(--ink-700); }
.badge--open     { background: var(--brand-100); color: #1d4ed8; border-color: #bfdbfe; }
.badge--progress { background: var(--warning-100); color: var(--warning-700); border-color: #fde68a; }
.badge--done     { background: var(--success-100); color: var(--success-700); border-color: #a7f3d0; }

.badge--aws   { background: #fff7ed; color: #c2410c; border-color: #fed7aa; }
.badge--azure { background: var(--brand-50); color: #1d4ed8; border-color: #bfdbfe; }
.badge--gcp   { background: #f0fdf4; color: #15803d; border-color: #bbf7d0; }

/* ------------------------------------------------------------- buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink-700);
    font-size: 13px; font-weight: 560;
    cursor: pointer;
    transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
    text-decoration: none;
    white-space: nowrap;
}
.btn:hover { background: var(--surface-alt); border-color: var(--ink-300); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn.is-disabled { opacity: .55; cursor: not-allowed; }

.btn--primary { background: var(--brand-600); border-color: var(--brand-600); color: #fff; box-shadow: var(--shadow-xs); }
.btn--primary:hover { background: #1d4ed8; border-color: #1d4ed8; color: #fff; }
.btn--success { background: var(--success-600); border-color: var(--success-600); color: #fff; }
.btn--success:hover { background: var(--success-700); border-color: var(--success-700); color: #fff; }
.btn--danger  { background: var(--danger-600); border-color: var(--danger-600); color: #fff; }
.btn--danger:hover { background: var(--danger-700); border-color: var(--danger-700); color: #fff; }
.btn--ghost   { background: transparent; border-color: transparent; }
.btn--ghost:hover { background: var(--surface-alt); }
.btn--sm { padding: 5px 10px; font-size: 12px; }
.btn--block { width: 100%; }

/* --------------------------------------------------------------- forms */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field__label { font-size: 12px; font-weight: 600; color: var(--ink-700); }
.field__hint  { font-size: 11.5px; color: var(--ink-500); }

.input, .select, .textarea {
    width: 100%;
    padding: 8px 11px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: #fff;
    font-size: 13px;
    transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--brand-500);
    box-shadow: 0 0 0 3px var(--brand-100);
}
.input::placeholder { color: var(--ink-400); }
.select { appearance: none; padding-right: 30px;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8.5 1.5 4h9z'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 10px center; }

.filter-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    align-items: end;
}
.filter-bar__actions { display: flex; gap: 8px; align-items: end; }

/* ------------------------------------------------------- states / misc */
.empty-state { text-align: center; padding: 42px 20px; color: var(--ink-500); }
.empty-state__icon {
    width: 46px; height: 46px; margin: 0 auto 12px;
    border-radius: 12px; background: var(--surface-alt);
    display: grid; place-items: center; color: var(--ink-400);
}
.empty-state__title { font-size: 14px; font-weight: 620; color: var(--ink-700); margin-bottom: 4px; }
.empty-state__text  { font-size: 12.5px; max-width: 420px; margin: 0 auto; }

.skeleton {
    background: linear-gradient(90deg, #eef2f7 25%, #e2e8f0 37%, #eef2f7 63%);
    background-size: 400% 100%;
    animation: skeleton 1.3s ease-in-out infinite;
    border-radius: 6px;
}
@keyframes skeleton { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

.spinner {
    width: 16px; height: 16px;
    border: 2px solid var(--brand-100);
    border-top-color: var(--brand-600);
    border-radius: 50%;
    animation: spin .7s linear infinite;
    display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
    position: absolute; inset: 0;
    background: rgba(255, 255, 255, .72);
    display: grid; place-items: center;
    border-radius: inherit;
    z-index: 5;
}

.alert {
    display: flex; gap: 10px; align-items: flex-start;
    padding: 11px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    border: 1px solid;
    margin-bottom: 14px;
}
.alert--info    { background: var(--brand-50); border-color: #bfdbfe; color: #1e40af; }
.alert--success { background: var(--success-100); border-color: #a7f3d0; color: var(--success-700); }
.alert--warning { background: var(--warning-100); border-color: #fde68a; color: var(--warning-700); }
.alert--danger  { background: var(--danger-100); border-color: #fecaca; color: var(--danger-700); }

/* ------------------------------------------------------------- toasts */
.toast-stack {
    position: fixed; right: 22px; bottom: 22px;
    display: flex; flex-direction: column; gap: 10px;
    z-index: 90; pointer-events: none;
}

.toast {
    pointer-events: auto;
    position: relative;
    display: flex; align-items: flex-start; gap: 11px;
    min-width: 300px; max-width: 400px;
    padding: 12px 14px 13px;
    background: #fff;
    border: 1px solid var(--line);
    border-left: 3px solid var(--ink-400);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    font-size: 13px;
    overflow: hidden;
    animation: toast-in .22s cubic-bezier(.21, 1.02, .73, 1);
}
.toast.is-leaving { animation: toast-out .2s ease forwards; }

.toast__icon {
    flex: 0 0 22px; width: 22px; height: 22px;
    border-radius: 50%;
    display: grid; place-items: center;
    margin-top: 1px;
}
.toast__body  { flex: 1 1 auto; min-width: 0; }
.toast__title { display: block; font-weight: 650; margin-bottom: 2px; }
.toast__message { display: block; color: var(--ink-700); line-height: 1.5; word-break: break-word; }

.toast__close {
    flex: 0 0 auto;
    background: none; border: none; cursor: pointer;
    color: var(--ink-400); font-size: 17px; line-height: 1;
    padding: 0 2px; margin: -2px -2px 0 0;
}
.toast__close:hover { color: var(--ink-700); }

/* Countdown bar showing how long the toast will remain. */
.toast__progress {
    position: absolute; left: 0; bottom: 0; height: 2px;
    background: currentColor; opacity: .35;
    animation: toast-progress linear forwards;
}

.toast--success { border-left-color: var(--success-600); color: var(--success-700); }
.toast--success .toast__icon { background: var(--success-100); color: var(--success-700); }
.toast--danger  { border-left-color: var(--danger-600); color: var(--danger-700); }
.toast--danger .toast__icon  { background: var(--danger-100); color: var(--danger-700); }
.toast--warning { border-left-color: var(--warning-600); color: var(--warning-700); }
.toast--warning .toast__icon { background: var(--warning-100); color: var(--warning-700); }
.toast--info    { border-left-color: var(--brand-600); color: #1d4ed8; }
.toast--info .toast__icon    { background: var(--brand-100); color: #1d4ed8; }

.toast__title { color: var(--ink-900); }

@keyframes toast-in  { from { opacity: 0; transform: translateY(10px) scale(.98); } }
@keyframes toast-out { to   { opacity: 0; transform: translateX(14px); } }
@keyframes toast-progress { from { width: 100%; } to { width: 0; } }

.progress { height: 7px; background: var(--line-soft); border-radius: 999px; overflow: hidden; }
.progress__bar { height: 100%; background: var(--brand-600); border-radius: 999px; transition: width .4s ease; }
.progress__bar--over { background: var(--danger-600); }
.progress__bar--warn { background: var(--warning-600); }
.progress__bar--good { background: var(--success-600); }

/* ------------------------------------------------------------ utilities */
.muted { color: var(--ink-500); }
.small { font-size: 12px; }
.mono  { font-family: var(--font-mono); font-size: 12px; }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }
.pos { color: var(--success-600); }
.neg { color: var(--danger-600); }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mb-14 { margin-bottom: 14px; }
.mb-18 { margin-bottom: 18px; }
.hidden { display: none !important; }

/* ---------------------------------------------------------- responsive */
@media (max-width: 1024px) {
    .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
    .sidebar.is-open { transform: translateX(0); }
    .main { margin-left: 0; }
    .topbar__toggle { display: inline-flex; }
    .sidebar-scrim {
        position: fixed; inset: 0; background: rgba(15, 23, 42, .45);
        z-index: 35; backdrop-filter: blur(1px);
    }
}

@media (max-width: 640px) {
    .content { padding: 16px 14px 32px; }
    .topbar { padding: 0 14px; gap: 10px; }
    .topbar__subtitle { display: none; }
    .user-chip__name, .user-chip__role { display: none; }
    .kpi__value { font-size: 21px; }
    .chart-grid--2, .chart-grid--3 { grid-template-columns: 1fr; }
}

/* ===========================================================================
   Components added for the analytics pages (Phase 8)
   =========================================================================== */

/* Empty state shown inside a chart box when a selection returns no data. */
.chart-empty {
    position: absolute; inset: 0;
    display: grid; place-items: center;
    font-size: 12.5px; color: var(--ink-400);
    text-align: center; padding: 20px;
}

/* Compact statistic used inside cards and page headers. */
.stat-row { display: flex; flex-wrap: wrap; gap: 26px; }
.stat__label { font-size: 11px; font-weight: 600; color: var(--ink-500);
               text-transform: uppercase; letter-spacing: .05em; }
.stat__value { font-size: 17px; font-weight: 650; margin-top: 2px; }
.stat__sub   { font-size: 11.5px; color: var(--ink-500); }

/* Two-column split used by allocation and forecasting. */
.split { display: grid; gap: 14px; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.split--even { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
@media (max-width: 1100px) { .split { grid-template-columns: 1fr; } }

/* Segmented control for switching views (showback / chargeback, etc). */
.segmented { display: inline-flex; background: var(--surface-alt);
             border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 2px; }
.segmented button {
    border: none; background: none; cursor: pointer;
    padding: 5px 12px; border-radius: 4px;
    font-size: 12.5px; font-weight: 560; color: var(--ink-500);
}
.segmented button.is-active { background: #fff; color: var(--ink-900); box-shadow: var(--shadow-xs); }

/* Anomaly / recommendation detail row. */
.detail-list { display: flex; flex-direction: column; gap: 10px; }
.detail-item {
    border: 1px solid var(--line); border-radius: var(--radius);
    padding: 13px 15px; background: #fff;
    border-left: 3px solid var(--ink-300);
}
.detail-item--critical { border-left-color: #b91c1c; }
.detail-item--high     { border-left-color: var(--danger-600); }
.detail-item--medium   { border-left-color: var(--warning-600); }
.detail-item--low      { border-left-color: var(--success-600); }
.detail-item__head { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-bottom: 6px; }
.detail-item__title { font-weight: 620; font-size: 13.5px; }
.detail-item__body { font-size: 12.8px; color: var(--ink-700); line-height: 1.55; }
.detail-item__meta { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 9px;
                     padding-top: 9px; border-top: 1px dashed var(--line); font-size: 12px; }
.detail-item__actions { margin-left: auto; display: flex; gap: 6px; }

/* Evidence figures inside an anomaly or recommendation. */
.evidence { display: flex; gap: 20px; flex-wrap: wrap; }
.evidence__item { min-width: 96px; }
.evidence__label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em;
                   color: var(--ink-500); font-weight: 600; }
.evidence__value { font-size: 14px; font-weight: 650; font-variant-numeric: tabular-nums; }

/* Upload drop zone on the Data Import page. */
.dropzone {
    border: 2px dashed var(--ink-300); border-radius: var(--radius-lg);
    padding: 34px 20px; text-align: center; background: var(--surface-alt);
    transition: border-color .15s, background .15s; cursor: pointer;
}
.dropzone:hover, .dropzone.is-over { border-color: var(--brand-500); background: var(--brand-50); }
.dropzone__icon { color: var(--ink-400); margin-bottom: 8px; }
.dropzone__title { font-weight: 620; font-size: 14px; margin-bottom: 3px; }
.dropzone__hint { font-size: 12.5px; color: var(--ink-500); }

/* Key/value grid used on the Settings page. */
/* Label column is capped as a fraction of the card, so a value never gets
   squeezed into a two-word-per-line column inside a narrow panel. */
.kv { display: grid; grid-template-columns: minmax(96px, 38%) 1fr; gap: 10px 16px; font-size: 13px; }
@media (max-width: 520px) { .kv { grid-template-columns: 1fr; gap: 2px 0; } }
.kv dt { color: var(--ink-500); font-weight: 560; }
.kv dd { margin: 0; font-weight: 560; }

/* Inline pagination controls. */
.pager { display: flex; align-items: center; gap: 10px; padding: 12px 16px;
         border-top: 1px solid var(--line-soft); font-size: 12.5px; color: var(--ink-500); }
.pager__spacer { margin-left: auto; }

/* Sticky filter panel. */
.filter-card { margin-bottom: 16px; }
.filter-card .card__body { padding: 14px 16px; }


/* ===========================================================================
   Avatars
   =========================================================================== */
.avatar {
    display: inline-grid; place-items: center;
    width: 30px; height: 30px; flex: 0 0 30px;
    border-radius: 50%;
    color: #fff;
    font-size: 11px; font-weight: 650; letter-spacing: .02em;
    user-select: none;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18);
}
.avatar--sm { width: 24px; height: 24px; flex-basis: 24px; font-size: 9.5px; }
.avatar--lg { width: 38px; height: 38px; flex-basis: 38px; font-size: 13px; }
.avatar--xl { width: 52px; height: 52px; flex-basis: 52px; font-size: 17px; }

/* An avatar next to its label, the pairing used across the tables. */
.avatar-label { display: inline-flex; align-items: center; gap: 9px; min-width: 0; }
.avatar-label__text { min-width: 0; }
.avatar-label__name { display: block; font-weight: 560; line-height: 1.25; }
.avatar-label__sub  { display: block; font-size: 11.5px; color: var(--ink-500); line-height: 1.3; }

/* Overlapping avatars, for showing several owners in one cell. */
.avatar-group { display: inline-flex; }
.avatar-group .avatar { margin-left: -8px; border: 2px solid #fff; }
.avatar-group .avatar:first-child { margin-left: 0; }

/* ===========================================================================
   Modal dialogs (replacing window.confirm / window.prompt)
   =========================================================================== */
.modal-overlay {
    position: fixed; inset: 0; z-index: 120;
    background: rgba(15, 23, 42, .48);
    backdrop-filter: blur(2px);
    display: grid; place-items: center;
    padding: 20px;
    animation: overlay-in .16s ease;
}

.modal {
    width: 100%; max-width: 440px;
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: 0 24px 60px rgba(15, 23, 42, .28);
    padding: 22px;
    animation: modal-in .2s cubic-bezier(.21, 1.02, .73, 1);
}

.modal__head { display: flex; gap: 14px; align-items: flex-start; }
.modal__icon {
    flex: 0 0 38px; width: 38px; height: 38px;
    border-radius: 50%;
    display: grid; place-items: center;
    font-size: 18px; font-weight: 700;
}
.modal__icon--info   { background: var(--brand-100); color: #1d4ed8; }
.modal__icon--danger { background: var(--danger-100); color: var(--danger-700); }

.modal__title   { font-size: 16px; font-weight: 650; }
.modal__message { font-size: 13.2px; color: var(--ink-500); margin-top: 4px; line-height: 1.55; }
.modal__actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 20px; }

@keyframes overlay-in { from { opacity: 0; } }
@keyframes modal-in   { from { opacity: 0; transform: translateY(12px) scale(.97); } }

/* ===========================================================================
   Product polish
   =========================================================================== */

/* Workspace switcher in the sidebar footer. */
.workspace {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 10px; border-radius: 9px;
    background: rgba(255, 255, 255, .05);
}
.workspace__name { color: #e2e8f0; font-size: 12.5px; font-weight: 600; line-height: 1.2; }
.workspace__meta { color: #7e8ca3; font-size: 10.5px; }

/* Section heading inside a card body. */
.section-title {
    font-size: 12px; font-weight: 650; text-transform: uppercase;
    letter-spacing: .06em; color: var(--ink-500); margin-bottom: 10px;
}

/* A quiet inline separator between metadata items. */
.dot-sep::before { content: "\00B7"; margin: 0 7px; color: var(--ink-300); }

/* Table cells holding an avatar need a little more breathing room. */
.table td .avatar-label { padding: 1px 0; }
