:root {
    /* Editorial accents — primary action is ink (dark on cream, landing-style) */
    --primary: #14202B;          /* ink — primary actions, active state, focus */
    --primary-light: #46545E;    /* ink-2 — focus ring lighter */
    --secondary: #155E63;        /* petrol — success / positive */
    --secondary-light: #1C7A7F;
    --tertiary: #C8761E;         /* signal — warning */
    --tertiary-light: #D78628;
    --danger: #B5472E;            /* clay — error */
    --danger-light: #C25B3F;

    /* Light editorial surfaces (paper) — matches landing.html */
    --bg: #E9EAE4;                /* app background (paper) */
    --bg-light: #F2F2EC;          /* elevated surface (paper-2) */
    --card: #F2F2EC;              /* card surface */
    --card-border: #C9CBC2;       /* rule hairline */
    --border: #C9CBC2;            /* rule hairline */
    --muted: #DEDFD8;             /* hover / accent fills (paper-3) */
    --muted-strong: #D2D4CB;
    --text: #14202B;              /* ink */
    --text-muted: #46545E;        /* ink-2 — secondary text (AA on paper) */
    --text-placeholder: #6B7680;  /* ink-3 — placeholder (AA on white inputs) */
    --success: #155E63;           /* petrol */
    --warning: #C8761E;           /* signal */

    /* Editorial identity (matches landing.html) */
    --font-sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-serif: 'Instrument Serif', Georgia, 'Times New Roman', serif;
    --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
    /* Editorial accents — used sparingly (provenance, ledger, cite refs) */
    --signal: #C8761E;            /* signal orange */
    --signal-soft: rgba(200, 118, 30, 0.14);
    --petrol: #155E63;            /* petrol teal */
    --petrol-soft: rgba(21, 94, 99, 0.18);
    --clay: #B5472E;              /* clay red */
    --clay-soft: rgba(181, 71, 46, 0.14);

    --radius: 12px;           /* cards */
    --radius-sm: 8px;         /* buttons / inputs / badges */
    --ring: 0 0 0 1px var(--border);                       /* 1px hairline outline */
    --shadow: 0 1px 2px rgba(20, 32, 43, 0.08), var(--ring);  /* calm elevation */
    --shadow-lg: 0 12px 32px rgba(20, 32, 43, 0.16), var(--ring);
    --ring-accent: 0 0 0 3px rgba(20, 32, 43, 0.22);        /* focus ring (ink) */
    --transition: all 0.18s ease;
    /* Derived tokens — kept here so every literal has a name (no ad-hoc hexes). */
    --on-primary: #FFFFFF;        /* text/icon color on ink primary fills */
    --signal-strong: #9A6A1E;     /* darker signal — risk-medium (distinct from risk-high) */
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Animated background / orbs removed for clean, solid backgrounds. */

/* Notifications */
#notification-area {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 360px;
}
.notification {
    padding: 14px 18px;
    border-radius: 12px;
    font-size: 14px;
    backdrop-filter: none;
    box-shadow: var(--shadow);
    cursor: pointer;
    animation: slideIn 0.3s ease;
    border: 1px solid;
}
.notification.success { background: var(--petrol-soft); border-color: var(--secondary); color: #0E3A40; }
.notification.error { background: var(--clay-soft); border-color: var(--danger); color: #8A3522; }
.notification.info { background: rgba(20, 32, 43, 0.06); border-color: var(--primary); color: #14202B; }
.notification.warning { background: var(--signal-soft); border-color: var(--tertiary); color: #8A4A12; }
@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(20, 32, 43, 0.45);
    backdrop-filter: none;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}
.modal {
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    padding: 36px;
    max-width: 560px;
    width: 90%;
    box-shadow: var(--shadow);
    animation: modalIn 0.3s ease;
}
@keyframes modalIn {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}
.modal-title { font-family: var(--font-serif); font-size: 28px; font-weight: 400; letter-spacing: -0.02em; margin-bottom: 8px; line-height: 1.1; }
.modal-subtitle { color: var(--text-muted); margin-bottom: 28px; font-size: 15px; }
.modal-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* Header (now sidebar) */
.app-layout {
    display: flex;
    min-height: 100vh;
}
.sidebar {
    width: 256px;
    min-width: 256px;
    background: var(--bg);
    backdrop-filter: none;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 50;
    padding: 20px 0;
    transition: transform 0.25s ease;
}
.sidebar .logo {
    font-size: 20px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.02em;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 18px 16px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border);
}
.sidebar .logo-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.sidebar .logo-badge {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 3px 7px;
    border-radius: 6px;
    background: var(--muted);
    color: var(--text-muted);
    -webkit-text-fill-color: var(--text-muted);
    margin-left: auto;
    flex: 0 0 auto;
    border: 1px solid var(--border);
}
.sidebar .logo:hover .logo-badge { background: var(--muted-strong); }
.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0 10px;
    flex: 1;
    overflow-y: auto;
}
.sidebar-divider {
    height: 1px;
    background: var(--border);
    margin: 10px 12px;
}
.nav-tab {
    width: 100%;
    text-align: left;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
    overflow: hidden;
}
.nav-tab .nav-ico { flex: 0 0 auto; font-size: 15px; line-height: 1; }
.nav-tab .nav-label { overflow: hidden; text-overflow: ellipsis; }
.nav-tab:hover { background: var(--muted); color: var(--text); }
.nav-tab.active {
    background: var(--primary);
    color: var(--on-primary);
    font-weight: 600;
    box-shadow: var(--shadow);
}
.nav-tab.active:hover { background: var(--primary-light); color: var(--on-primary); }
.nav-tab.active .nav-ico { filter: none; }
.sidebar-footer {
    padding: 16px 20px 0;
    margin-top: 12px;
}
#auth-area { display: flex; align-items: center; gap: 12px; }
#auth-area .btn { width: 100%; justify-content: center; }

/* Layout */
.main-content {
    flex: 1;
    min-width: 0;
    overflow-y: auto;
    min-height: 100vh;
    background: var(--bg);
    position: relative;
    z-index: 1;
}
.container { position: relative; z-index: 2; max-width: 1400px; margin: 0 auto; padding: 28px 24px; min-height: calc(100vh - 56px); }
.tab-content { display: none; animation: fadeIn 0.3s ease; }
.tab-content.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.section-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 8px; flex-wrap: wrap; }
.section-header .btn { align-self: center; }
/* Page titles — Instrument Serif display (one per page; not a per-section kicker) */
.section-title {
    font-family: var(--font-serif);
    font-weight: 400;
    font-size: clamp(26px, 3vw, 33px);
    line-height: 1.08;
    letter-spacing: -0.02em;
    margin-bottom: 6px;
    color: var(--text);
}
.section-title em { font-style: italic; color: var(--signal); }
.section-subtitle { color: var(--text-muted); margin-bottom: 22px; font-size: 15px; line-height: 1.5; max-width: 72ch; }
/* Per-scan selector bar (Classification/Compliance/Lineage/Risk/Quality + Audit) */
.scan-select-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.scan-select-bar .form-label { text-transform: uppercase; letter-spacing: 0.5px; font-size: 11.5px; color: var(--text-muted); flex: 0 0 auto; }
.scan-select { min-width: 240px; cursor: pointer; }

/* Cards — shadcn-style: solid surface, 1px ring, calm (no translucency/heavy shadow) */
.glass-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    backdrop-filter: none;
    box-shadow: var(--shadow);
}
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}
.stat-card {
    padding: 20px;
    text-align: center;
    transition: var(--transition);
}
.stat-card:hover { border-color: rgba(20, 32, 43, 0.35); box-shadow: var(--shadow); }
.stat-icon { font-size: 26px; margin-bottom: 10px; }
.stat-value { font-size: 30px; font-weight: 700; margin-bottom: 4px; letter-spacing: -0.02em; }
.stat-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

/* Buttons — shadcn variants: solid, subtle, no gradients/lift */
button { font-family: inherit; cursor: pointer; }
.btn-primary, .btn-secondary, .cta-button, .preset-btn {
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-weight: 600;
    border: 1px solid transparent;
    transition: var(--transition);
    line-height: 1.2;
}
.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: none;
}
.btn-primary:hover { background: var(--secondary); }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-secondary {
    background: var(--muted);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--muted-strong); }
.btn-danger {
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-weight: 600;
    border: 1px solid rgba(181, 71, 46, 0.3);
    background: var(--clay-soft);
    color: #8A3522;
    transition: var(--transition);
}
.btn-danger:hover { background: rgba(181, 71, 46, 0.2); }
.cta-button {
    background: var(--secondary);
    color: #E9EAE4;
    font-size: 15px;
    padding: 12px 24px;
    box-shadow: none;
}
.cta-button:hover { background: var(--secondary-light); }
.quick-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 24px; }

/* Inset group — a subtle muted panel for grouping fields inside a card (NOT a nested card). */
.inset {
    background: var(--muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
}

/* Code block — dark inset for SQL/code previews (high-contrast, monospace). */
.code-block {
    background: var(--text);
    color: var(--bg-light);
    font-family: var(--font-mono);
    font-size: 12.5px;
    line-height: 1.55;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    overflow: auto;
    white-space: pre;
}

/* Getting Started stepper (Overview) */
.getting-started-steps { list-style: none; margin: 0 0 4px; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.getting-started-steps li { display: flex; align-items: flex-start; gap: 12px; }
.getting-started-steps .gs-num {
    flex: 0 0 24px; height: 24px; border-radius: 999px; display: grid; place-items: center;
    background: var(--primary); color: #fff; font-size: 12px; font-weight: 700;
    font-variant-numeric: tabular-nums; letter-spacing: 0;
}
.getting-started-steps .gs-text { color: var(--text); font-size: 13.5px; line-height: 1.45; padding-top: 2px; }
.getting-started-steps .gs-text strong { color: var(--text); font-weight: 700; }
.preset-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.preset-btn {
    background: var(--muted);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 9px 14px;
}
.preset-btn:hover { background: var(--muted-strong); border-color: var(--muted-strong); }

.conn-help { margin: 0 0 20px; border: 1px solid var(--border); border-radius: 10px; background: var(--muted); }
.conn-help > summary {
    cursor: pointer; list-style: none; padding: 11px 14px; font-size: 14px; font-weight: 600;
    color: var(--text); user-select: none;
}
.conn-help > summary::-webkit-details-marker { display: none; }
.conn-help > summary::before { content: "▸ "; color: var(--text-muted); }
.conn-help[open] > summary::before { content: "▾ "; }
.conn-help-body { padding: 0 14px 14px; font-size: 13.5px; line-height: 1.55; color: var(--text); max-width: 72ch; }
.conn-help-body p { margin: 10px 0 4px; }
.conn-help-body ol { margin: 4px 0 10px; padding-left: 20px; }
.conn-help-body li { margin: 4px 0; }
.conn-help-body code { background: var(--bg); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; font-size: 12.5px; }
.conn-help-note { color: var(--text-muted); font-style: italic; }
.preset-btn.supabase { background: #3ecf8e; color: #04231a; border-color: transparent; }
.preset-btn.supabase:hover { background: #34b37a; }

/* Forms */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); }
.form-input {
    background: #FFFFFF;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    color: var(--text);
    font-size: 14px;
    transition: var(--transition);
    width: 100%;
    box-sizing: border-box;
}
.form-input::placeholder { color: var(--text-placeholder); }
/* Global safety net so search inputs and any bare input share the AA placeholder color */
input::placeholder, textarea::placeholder { color: var(--text-placeholder); opacity: 1; }
.form-input:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring-accent); }
.form-input.error { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(181, 71, 46, 0.2); }
.form-select { appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2346545E' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; cursor: pointer; transition: var(--transition); }
.form-select:hover { border-color: var(--text-muted); }
.form-select:focus { border-color: var(--primary); box-shadow: var(--ring-accent); outline: none; }
.form-select option { color: var(--text); background: var(--card); }
.form-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 12px; }
.form-error { color: var(--danger-light); font-size: 12px; margin-top: 4px; display: none; }
.form-error.visible { display: block; }

/* Connection cards */
.connection-grid { display: grid; grid-template-columns: 1fr; gap: 20px; }
@media (min-width: 1440px) {
    .connection-grid { grid-template-columns: repeat(auto-fill, minmax(620px, 1fr)); }
}
.connection-card {
    padding: 24px;
    min-width: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.connection-card .form-input,
.connection-card .form-select,
.connection-card .form-row {
    max-width: 100%;
    min-width: 0;
}
.connection-card .form-row {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    gap: 12px;
}
.connection-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.connection-title { font-weight: 700; font-size: 16px; }
.connection-status {
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    text-transform: uppercase;
}
.status-disconnected { background: var(--clay-soft); color: #8A3522; }
.status-pending { background: var(--signal-soft); color: #8A4A12; }
.status-connected { background: var(--petrol-soft); color: #0E3A40; }
.status-demo { background: rgba(20, 32, 43, 0.06); color: var(--text-muted); }
.connection-actions { display: flex; gap: 10px; margin-top: 16px; }
.connection-result {
    margin-top: 12px;
    padding: 12px;
    border-radius: 10px;
    font-size: 13px;
    display: none;
}
/* AI Tools status messages and the Risk-tab lineage card set innerHTML (not
   inline display), so override the hidden-by-default base for those scopes. */
#tab-ai-tools .connection-result,
#risk-lineage-exposure.connection-result { display: block; }
.result-success { background: var(--petrol-soft); color: #0E3A40; }
.result-error { background: var(--clay-soft); color: #8A3522; }

/* Connect page — reshaped into sections (pool + add) with refined cards */
.conn-section { margin-bottom: 28px; }
.conn-section-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.conn-section-head h3 { font-family: var(--font-sans); font-size: 16px; font-weight: 700; letter-spacing: -0.01em; margin: 0; color: var(--text); }
.conn-add-hint { margin-bottom: 16px; }

.conn-pool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.conn-pool-card { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.conn-pool-top { display: flex; align-items: flex-start; gap: 12px; }
.conn-pool-icon { font-size: 22px; line-height: 1.4; flex: 0 0 22px; }
.conn-pool-id { flex: 1 1 auto; min-width: 0; }
.conn-pool-name { font-size: 15px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conn-pool-meta { font-size: 11.5px; color: var(--text-muted); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conn-pool-tested { font-size: 12px; color: var(--text-muted); padding-top: 10px; border-top: 1px solid var(--border); }
.conn-pool-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.conn-pool-actions .btn { padding: 7px 14px; font-size: 12.5px; }

.conn-pill { font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 999px; white-space: nowrap; flex: 0 0 auto; }
.conn-pill-ok { background: var(--petrol-soft); color: #0E3A40; border: 1px solid rgba(21,94,99,0.3); }
.conn-pill-bad { background: var(--clay-soft); color: #8A3522; border: 1px solid rgba(181,71,46,0.3); }
.conn-pill-idle { background: var(--muted); color: var(--text-muted); border: 1px solid var(--border); }

.conn-add-actions { display: flex; gap: 10px; justify-content: center; margin-top: 22px; }

/* Refine the edit-connection card + preset bar within the add section */
.preset-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.preset-btn { display: inline-flex; align-items: center; gap: 6px; }
.connection-card { padding: 22px; }
.connection-header { align-items: center; }
.connection-title { display: inline-flex; align-items: center; gap: 8px; font-size: 15px; }
.connection-status { border-radius: 999px; }

/* Scan progress */
.scan-panel { padding: 28px; }
.scan-source-list {
    max-height: 220px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--card);
    padding: 6px;
}
.scan-source-list:empty::before {
    content: "No saved connections yet. Add one on the Connect tab.";
    display: block;
    color: var(--text-muted);
    font-size: 13px;
    padding: 12px 8px;
}
.scan-source-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background .15s ease;
}
.scan-source-row:hover { background: var(--muted); }
.scan-source-row input[type="checkbox"] { width: 18px; height: 18px; flex: 0 0 auto; }
.scan-source-row .ssr-label { font-size: 14px; font-weight: 600; }
.scan-source-row .ssr-meta { margin-left: auto; font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.scan-source-row .ssr-mark { font-weight: 700; }
.scan-source-row .ssr-mark.ok { color: var(--success, #2ea043); }
.scan-source-row .ssr-mark.fail { color: var(--danger, #d14343); }
.scan-source-actions { display: flex; gap: 8px; margin-top: 8px; }
.scan-source-action { font-size: 12.5px; padding: 5px 12px; }
.progress-bar {
    height: 10px;
    background: var(--muted);
    border-radius: 5px;
    overflow: hidden;
    margin-top: 20px;
}
.progress-fill {
    height: 100%;
    width: 100%;
    transform: scaleX(0);
    transform-origin: left center;
    background: var(--primary);
    border-radius: 5px;
    transition: transform 0.4s ease;
}
/* Metric bars (quality scores) — one-shot width, no animation. */
.metric-fill { height: 100%; border-radius: 5px; }
.progress-info { display: flex; justify-content: space-between; margin-top: 10px; font-size: 13px; color: var(--text-muted); }
.progress-percent { font-weight: 700; color: var(--text); }
.progress-stats { display: flex; gap: 24px; margin-top: 16px; }
.progress-stat { text-align: center; }
.progress-stat-value { font-size: 22px; font-weight: 700; }
.progress-stat-label { font-size: 12px; color: var(--text-muted); }

/* Tables — shadcn-style: muted header, hairline row borders, subtle hover */
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th {
    text-align: left;
    padding: 10px 12px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.4px;
    border-bottom: 1px solid var(--border);
    background: transparent;
}
.data-table td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(20, 32, 43, 0.04); }
.data-table .cell-recommendation { max-width: 320px; line-height: 1.45; }
.table-scroll { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }

/* Badges — subtle muted fills (shadcn badge) */
.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border: 1px solid transparent;
}
.badge-pii { background: var(--signal-soft); color: #8A4A12; border-color: rgba(200, 118, 30, 0.3); }
.badge-phi { background: var(--clay-soft); color: #8A3522; border-color: rgba(181, 71, 46, 0.3); }
.badge-pci { background: var(--petrol-soft); color: #0E3A40; border-color: rgba(21, 94, 99, 0.32); }
.badge-public { background: rgba(107, 118, 128, 0.14); color: #46545E; border-color: rgba(107, 118, 128, 0.25); }
/* Severity (audit log) + role badges — their own ramp, not the classification
 * palette, so "admin" never reads as "PII" and "error" never reads as "PHI". */
.badge-info { background: var(--petrol-soft); color: #0E3A40; border-color: rgba(21, 94, 99, 0.3); }
.badge-warning { background: var(--signal-soft); color: #8A4A12; border-color: rgba(200, 118, 30, 0.3); }
.badge-error { background: var(--clay-soft); color: #8A3522; border-color: rgba(181, 71, 46, 0.3); }
.badge-admin { background: var(--petrol-soft); color: #0E3A40; border-color: rgba(21, 94, 99, 0.32); }

/* Risk */
.risk-score { font-weight: 800; }
.risk-critical { color: var(--danger); }
.risk-high { color: var(--tertiary); }
.risk-medium { color: var(--signal-strong); }
.risk-low { color: var(--secondary); }

/* Alerts */
.alert {
    display: flex;
    gap: 16px;
    padding: 18px;
    border-radius: 12px;
    margin-bottom: 24px;
    backdrop-filter: none;
}
.alert-info { background: rgba(20, 32, 43, 0.05); border: 1px solid rgba(20, 32, 43, 0.15); }
.alert-success { background: var(--petrol-soft); border: 1px solid rgba(21, 94, 99, 0.2); }
.alert-icon { font-size: 24px; }
.alert-title { font-weight: 700; margin-bottom: 4px; }
.alert-text { color: var(--text-muted); font-size: 14px; line-height: 1.5; }

/* Backend status banner */
.backend-status {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    padding: 10px 16px;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    z-index: 2000;
    transition: var(--transition);
}
.backend-status.online { background: var(--petrol-soft); color: #0E3A40; border-bottom: 1px solid rgba(21, 94, 99, 0.3); }
.backend-status.offline { background: var(--clay-soft); color: #8A3522; border-bottom: 1px solid rgba(181, 71, 46, 0.4); }
.backend-status.hidden { transform: translateY(-100%); }

/* Lineage */
/* Lineage — data-flow graph + side panel */
.lineage-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.lineage-canvas-card { padding: 16px; }
.lineage-viz { min-height: 420px; }
.lineage-link { stroke: rgba(70, 84, 94, 0.35); stroke-width: 1.5px; fill: none; }
.lineage-label { fill: var(--text); font-size: 12px; font-weight: 500; pointer-events: none; }
.lineage-chev { fill: var(--text-muted); font-size: 13px; font-weight: 700; pointer-events: none; text-anchor: end; }
.lineage-node { cursor: default; }
.lineage-node-bg { fill: var(--card); stroke: var(--border); stroke-width: 1; transition: stroke 0.18s ease, fill 0.18s ease; }
.lineage-node:hover .lineage-node-bg { stroke: var(--primary); }
.lineage-node.lineage-drillable { cursor: pointer; }
.lineage-node.lineage-drillable .lineage-node-bg { stroke: var(--text-muted); }
.lineage-node.lineage-drillable:hover .lineage-node-bg { stroke: var(--tertiary); fill: var(--bg-light); }
.lineage-empty { text-align: center; padding: 56px 20px; }

.lineage-side { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 84px; }
.lineage-legend, .lineage-paths { padding: 18px; }
.leg-section { margin-bottom: 14px; }
.leg-section:last-child { margin-bottom: 0; }
.leg-title { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); margin-bottom: 8px; }
.leg-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); padding: 3px 0; }
.leg-dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 10px; border: 1px solid rgba(20,32,43,0.15); }
.lineage-paths-list { display: flex; flex-direction: column; gap: 10px; max-height: 360px; overflow-y: auto; }
.lineage-path-item { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.lineage-path-item:last-child { border-bottom: none; }
.lp-main { min-width: 0; }
.lp-name { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lp-meta { font-size: 11.5px; color: var(--text-muted); }

@media (max-width: 1024px) {
    .lineage-layout { grid-template-columns: 1fr; }
    .lineage-side { position: static; flex-direction: row; flex-wrap: wrap; }
    .lineage-side > .glass-card { flex: 1 1 240px; }
}

/* Interactive lineage controls */
.lineage-controls { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.lineage-controls-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; width: 100%; }
.lineage-crumb { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; font-size: 13px; min-width: 0; }
.lineage-crumb-item { background: transparent; border: none; color: var(--text-muted); font: inherit; font-size: 13px; padding: 3px 7px; border-radius: 6px; cursor: pointer; }
.lineage-crumb-item:hover { background: var(--muted); color: var(--text); }
.lineage-crumb-item[data-id=""] { font-weight: 600; color: var(--text); }
.lineage-crumb-sep { color: var(--text-muted); padding: 0 2px; }
.lineage-filter { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; flex: 1 1 320px; min-width: 220px; }
.lineage-search { flex: 1 1 200px; min-width: 160px; max-width: 280px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--card); color: var(--text); font: inherit; font-size: 13px; }
.lineage-search:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring-accent); }
.lineage-chips { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.lineage-chip { display: inline-flex; align-items: center; gap: 5px; padding: 4px 9px; border: 1px solid var(--border); border-radius: 999px; font-size: 12px; font-weight: 600; cursor: pointer; user-select: none; }
.lineage-chip input { width: 13px; height: 13px; margin: 0; }
.lineage-chip .leg-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.lineage-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.lineage-export-btn { font-size: 12.5px; padding: 6px 12px; }
.lineage-zoom { display: flex; gap: 6px; }
.lineage-zoom .btn-icon { width: 40px; height: 40px; font-size: 15px; }
.lineage-canvas-wrap { border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); overflow: hidden; }
.lineage-svg { width: 100%; height: 480px; display: block; cursor: grab; touch-action: none; }
.lineage-help { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); margin-top: 8px; }
.lineage-dim { opacity: 0.18; transition: opacity 0.15s ease; }
.lineage-node.lineage-hit .lineage-node-bg { stroke: var(--primary); stroke-width: 2.5px; fill: var(--bg-light); }
.lineage-link.lineage-dim { stroke: rgba(70, 84, 94, 0.12); }

/* Scan investigating — dark-terminal ledger (mirrors the landing page scan panel) */
.inv-term {
    --it-bg: #0B1115; --it-ink: #D6E2D5; --it-dim: #6E7E7B; --it-rule: rgba(214,226,213,0.12);
    --it-mono: var(--font-mono, 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace);
    background: var(--it-bg); border-radius: 12px; overflow: hidden; color: var(--it-ink);
    box-shadow: 0 24px 48px -20px rgba(20,32,43,0.40), 0 0 0 1px rgba(20,32,43,0.08);
    font-family: var(--it-mono);
}
.inv-term-bar { display: flex; align-items: center; gap: 10px; padding: 11px 15px;
    border-bottom: 1px solid var(--it-rule); background: rgba(255,255,255,0.02); }
.inv-term-bar .tdots { display: flex; gap: 6px; }
.inv-term-bar .tdots i { width: 10px; height: 10px; border-radius: 50%; background: rgba(214,226,213,0.18); display: block; }
.inv-term-bar .title { font-size: 11.5px; color: var(--it-dim); letter-spacing: 0.02em; }
.inv-term-bar .live { margin-left: auto; display: inline-flex; align-items: center; gap: 6px;
    font-size: 10.5px; color: var(--signal, #C8761E); letter-spacing: 0.08em; }
.inv-term-bar .live i { width: 6px; height: 6px; border-radius: 50%; background: var(--signal, #C8761E);
    animation: inv-blink 1.4s steps(2, end) infinite; }
.inv-term-bar .live.done i { background: #5FB6BB; animation: none; }
@keyframes inv-blink { 50% { opacity: 0.25; } }
.inv-term-body { padding: 14px 16px 16px; font-size: 12.5px; line-height: 1.85; max-height: 360px;
    overflow-y: auto; position: relative; }
.inv-term-body::after { content: ""; position: sticky; bottom: 0; display: block; height: 0; }
.inv-term-row { display: grid; grid-template-columns: 1.4fr 0.9fr 0.7fr 0.9fr; gap: 10px; white-space: nowrap;
    padding: 2px 0; }
.inv-term-row .f { color: var(--it-ink); overflow: hidden; text-overflow: ellipsis; }
.inv-term-row .src { color: var(--it-dim); overflow: hidden; text-overflow: ellipsis; }
.inv-term-row .kind { color: var(--it-dim); }
.inv-term-row .conf { color: var(--it-dim); }
.inv-term-row .conf b { color: var(--it-ink); font-weight: 500; }
.inv-tag { font-weight: 600; font-size: 11px; padding: 1px 7px; border-radius: 4px; display: inline-block;
    height: 16px; line-height: 14px; text-align: center; }
.inv-tag.pii { background: rgba(200,118,30,0.16); color: #E69A47; }
.inv-tag.phi { background: rgba(181,71,46,0.18); color: #D6754E; }
.inv-tag.pci { background: rgba(21,94,99,0.30); color: #5FB6BB; }
.inv-tag.public { background: rgba(214,226,213,0.10); color: var(--it-dim); }
.inv-term-empty { color: var(--it-dim); font-size: 12.5px; }

/* Scan investigating — completion CTA + ledger (shown below the terminal) */
.scan-investigating-complete { background: var(--petrol-soft); border: 1px solid rgba(21,94,99,0.3); border-radius: var(--radius-sm); padding: 14px 16px; margin-bottom: 14px; }
.sic-msg { font-size: 14px; font-weight: 600; color: #0E3A40; margin-bottom: 10px; }
.sic-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.scan-investigating-ledger { border-top: 1px solid var(--border); padding-top: 12px; max-height: 320px; overflow-y: auto; }

/* Loading spinner */
.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(20,32,43,0.25);
    border-top-color: var(--text);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* SweetAlert-style custom modal */
.swal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(20, 32, 43, 0.5);
    backdrop-filter: none;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 3000;
}
.swal-overlay.active { display: flex; }
.swal-modal {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    max-width: 480px;
    width: 90%;
    text-align: center;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.25s ease;
}
.swal-icon { font-size: 56px; margin-bottom: 16px; }
.swal-title { font-size: 22px; font-weight: 700; margin-bottom: 8px; }
.swal-text { color: var(--text-muted); font-size: 15px; margin-bottom: 24px; line-height: 1.5; }
.swal-actions { display: flex; gap: 12px; justify-content: center; }

/* Auth area in header */
#auth-area { display: flex; align-items: center; gap: 12px; margin-left: auto; }
#current-user-name { font-weight: 600; color: var(--text); }

/* Responsive */
@media (max-width: 1024px) {
    .app-layout { flex-direction: column; }
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        padding: 12px 16px;
        gap: 12px;
    }
    .sidebar .logo {
        padding: 0;
        margin: 0;
        border: none;
        flex: 1;
    }
    .sidebar-nav {
        flex-direction: row;
        flex-wrap: wrap;
        padding: 0;
        flex: 1 1 100%;
        overflow-x: auto;
        gap: 6px;
    }
    .sidebar-divider { display: none; }
    .nav-tab { width: auto; white-space: nowrap; }
    .sidebar-footer {
        border: none;
        padding: 0;
        margin: 0;
    }
    #auth-area .btn { width: auto; }
}
@media (max-width: 768px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .form-row { grid-template-columns: 1fr; }
    .sidebar-nav { justify-content: center; }
    /* Mobile readability + touch-target floors (WCAG): no text below 14px, no
     * interactive target below 44px on touch. */
    .nav-tab, .form-label, .badge, .stat-label, .data-table, .inv-term, .ledger { font-size: 14px; }
    .btn-icon { width: 44px; height: 44px; }
    .nav-tab { min-height: 44px; }
}

/* ───────────────────────────────────────────────────────────────
   UI/UX polish (topbar, searchable tables, focus, scrollbars)
   ─────────────────────────────────────────────────────────────── */

/* Topbar (sticky page header inside main content) */
.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 24px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}
.scan-context {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--text-muted);
    background: var(--muted);
    border: 1px solid var(--border);
    padding: 6px 12px;
    border-radius: 999px;
    max-width: 46vw;
    overflow: hidden;
}
.scan-context[hidden] { display: none; }
.scan-context #scan-context-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); font-weight: 600; }
.scan-context .btn-secondary { padding: 4px 12px; font-size: 12px; white-space: nowrap; }

/* AI Assistant chat */
.ast-msg { max-width: 80%; padding: 11px 15px; border-radius: 14px; font-size: 14px; line-height: 1.5; white-space: pre-wrap; word-wrap: break-word; }
.ast-user { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.ast-bot { align-self: flex-start; background: var(--muted); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.ast-bot em { color: var(--secondary); font-style: italic; }
.ast-tool { align-self: flex-start; font-size: 12px; color: var(--text-muted); background: var(--petrol-soft); border: 1px solid rgba(21, 94, 99, 0.2); padding: 6px 10px; border-radius: 8px; max-width: 90%; }
.ast-tool code { color: var(--secondary); }
.ast-typing { align-self: flex-start; color: var(--text-muted); font-size: 13px; padding: 8px 14px; }
.ast-typing .spinner { margin-right: 6px; }
.ast-msg code, .ast-tool code { background: var(--muted); color: var(--secondary); padding: 1px 5px; border-radius: 4px; font-size: 12px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.ast-msg ul { margin: 6px 0 6px 18px; padding: 0; }
.ast-msg li { margin: 2px 0; }

/* Settings */
/* Settings — scannable config panel (group nav + overview + rows) */
.schedule-target-list { display: flex; flex-direction: column; gap: 6px; max-height: 200px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px; background: #FFFFFF; }
.schedule-target-item { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 6px; cursor: pointer; transition: background 0.15s ease; }
.schedule-target-item:hover { background: var(--muted); }
.schedule-target-item input { width: 16px; height: 16px; flex: 0 0 16px; }
.schedule-target-name { font-size: 14px; font-weight: 600; color: var(--text); flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.schedule-target-meta { font-size: 11px; color: var(--text-muted); flex: 0 0 auto; }
.chip { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 3px 8px; border-radius: 999px; background: var(--muted); border: 1px solid var(--border); color: var(--text); margin: 0 4px 2px 0; }
.settings-header-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.settings-overview { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 20px; }
.settings-overview-item { background: var(--card); padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.settings-overview-item .so-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); }
.settings-overview-item .so-value { font-size: 15px; font-weight: 600; color: var(--text); }
.settings-overview-item .so-muted { color: var(--text-muted); font-weight: 400; font-size: 12.5px; }
.so-ref { font-family: var(--font-mono); font-size: 11px; color: var(--tertiary); font-weight: 600; }

.settings-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 24px; align-items: start; }
.settings-nav { position: sticky; top: 84px; display: flex; flex-direction: column; gap: 2px; padding: 6px 0; }
.settings-nav-item { display: flex; align-items: center; gap: 10px; text-align: left; background: transparent; border: none; color: var(--text-muted); font: inherit; font-size: 13.5px; font-weight: 500; padding: 9px 12px; border-radius: var(--radius-sm); cursor: pointer; transition: var(--transition); }
.settings-nav-item:hover { background: var(--muted); color: var(--text); }
.settings-nav-item.active { background: var(--muted); color: var(--text); font-weight: 600; }
.settings-nav-item .so-ref { opacity: 0.7; }

.settings-content { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.settings-group { padding: 20px 22px; display: none; }
.settings-group.is-active { display: block; }
.settings-group-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.settings-group-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.settings-group-ttl { display: flex; align-items: center; gap: 10px; }
.settings-group-ttl h3 { font-family: var(--font-sans); font-size: 17px; font-weight: 700; letter-spacing: -0.01em; margin: 0; color: var(--text); }
.settings-group-desc { color: var(--text-muted); font-size: 13px; margin: 0 0 16px; max-width: 70ch; }
.llm-help-card { background: var(--bg-light); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; margin: 0 0 18px; }
.llm-help-title { font-weight: 700; font-size: 13.5px; margin-bottom: 4px; }
.llm-help-sub { font-size: 12.5px; color: var(--text-muted); margin: 0 0 12px; line-height: 1.5; }
.llm-help-sub b { color: var(--text); font-weight: 600; }
.llm-help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 720px) { .llm-help-grid { grid-template-columns: 1fr; } }
.llm-help-col ul { margin: 4px 0 12px; padding-left: 18px; font-size: 12.5px; line-height: 1.65; color: var(--text); }
.llm-help-col li { margin: 1px 0; }
.llm-help-col code { background: var(--card); border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px; font-family: var(--font-mono); font-size: 11.5px; }
.llm-help-h { font-weight: 600; font-size: 12.5px; margin-top: 2px; }
.llm-help-note { font-size: 12px; color: var(--text-muted); margin-top: 4px; line-height: 1.5; }
.settings-rows { display: flex; flex-direction: column; }
.settings-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: center; padding: 12px 0; border-top: 1px solid var(--border); }
.settings-row:first-child { border-top: none; }
.settings-row-label { display: flex; flex-direction: column; gap: 6px; }
.settings-row-label .form-label { text-transform: uppercase; letter-spacing: 0.5px; font-size: 11.5px; }
.settings-row-readonly .setting-readonly { background: var(--muted); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 9px 12px; color: var(--text); font-size: 13.5px; font-family: var(--font-mono); word-break: break-all; }

.pill { display: inline-block; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; padding: 2px 7px; border-radius: 999px; border: 1px solid transparent; }
.pill-restart { background: var(--signal-soft); color: #8A4A12; border-color: rgba(200,118,30,0.3); }
.pill-secret { background: var(--muted); color: var(--text-muted); border-color: var(--border); }

/* Toggle switch for bool settings */
.settings-toggle { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.settings-toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.settings-toggle-track { width: 38px; height: 22px; border-radius: 999px; background: var(--muted-strong); border: 1px solid var(--border); position: relative; transition: background 0.18s ease, border-color 0.18s ease; flex: 0 0 38px; }
.settings-toggle-thumb { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--text); transition: transform 0.18s ease; }
.settings-toggle input:checked + .settings-toggle-track { background: var(--secondary); border-color: var(--secondary); }
.settings-toggle input:checked + .settings-toggle-track .settings-toggle-thumb { transform: translateX(16px); background: #fff; }
.settings-toggle input:focus-visible + .settings-toggle-track { box-shadow: var(--ring-accent); }
.settings-toggle-text { font-size: 13.5px; font-weight: 600; color: var(--text); }

@media (max-width: 900px) {
    .settings-layout { grid-template-columns: 1fr; }
    .settings-nav { position: static; flex-direction: row; flex-wrap: wrap; gap: 6px; }
    .settings-nav-item { width: auto; }
    .settings-row { grid-template-columns: 1fr; gap: 8px; }
}
.topbar-title {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.2px;
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.topbar-actions { display: flex; gap: 8px; align-items: center; }
.topbar-menu { display: inline-flex; } /* collapse (desktop) / open (mobile) toggle */

/* Icon buttons */
.btn-icon {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--muted);
    color: var(--text);
    font-size: 18px;
    cursor: pointer;
    transition: var(--transition);
}
.btn-icon:hover { background: rgba(20, 32, 43, 0.08); border-color: var(--card-border); transform: none; }
.btn-icon:active { transform: scale(0.96); }

/* Sidebar active indicator — the filled muted surface + bold weight on
   .nav-tab.active is the single indicator (no side-stripe accent). */
.nav-tab { padding-left: 12px; }

/* Sidebar collapsed (desktop icon-only rail). Toggled by #sidebar-toggle;
   state persisted in localStorage by app.js. Smooth width transition above. */
.sidebar.collapsed { width: 68px; min-width: 68px; }
.sidebar.collapsed .logo { padding: 0 0 16px; justify-content: center; gap: 0; }
.sidebar.collapsed .logo-name,
.sidebar.collapsed .logo-badge { display: none; }
.sidebar.collapsed .nav-label { display: none; }
.sidebar.collapsed .nav-tab { justify-content: center; padding: 9px 0; gap: 0; }
.sidebar.collapsed .sidebar-divider { margin: 10px 14px; }
.sidebar.collapsed #current-user-name,
.sidebar.collapsed .auth-user-role,
.sidebar.collapsed .btn-label { display: none; }
.sidebar.collapsed #auth-area { justify-content: center; gap: 0; }
.sidebar.collapsed #auth-area .btn { width: 100%; padding: 9px 0; justify-content: center; }

/* Stat cards: aligned numbers + lift */
.stat-value { font-variant-numeric: tabular-nums; letter-spacing: -0.5px; }

/* Tables: sticky headers, zebra, refined hover, denser */
.table-scroll { max-height: 560px; overflow: auto; }
.data-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--bg-light);
}
.data-table tbody tr:nth-child(even) td { background: rgba(20, 32, 43, 0.025); }
.data-table tbody tr:hover td { background: rgba(20, 32, 43, 0.05); }
.data-table td { transition: background 0.12s ease; }

/* Empty-state rows (cells spanning all columns) read as muted, centered notices */
.data-table tbody td[colspan] {
    text-align: center;
    color: var(--text-muted);
    padding: 36px 16px;
    font-style: italic;
}

/* Table search toolbar (injected above data tables) */
.table-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}
.table-search {
    flex: 1;
    max-width: 280px;
    background: #FFFFFF;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 7px 12px;
    color: var(--text);
    font-size: 13px;
}
.table-search:focus { outline: none; border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(20, 32, 43, 0.15); }
.table-count { font-size: 12px; color: var(--text-muted); margin-left: auto; font-variant-numeric: tabular-nums; }
.table-loading {
    text-align: center;
    padding: 48px 16px;
    color: var(--text-muted);
    font-size: 14px;
}

/* Custom scrollbar (webkit) */
.table-scroll::-webkit-scrollbar,
.sidebar-nav::-webkit-scrollbar { width: 8px; height: 8px; }
.table-scroll::-webkit-scrollbar-thumb,
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(20,32,43,0.18); border-radius: 8px; }
.table-scroll::-webkit-scrollbar-thumb:hover,
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: rgba(20,32,43,0.28); }
.table-scroll::-webkit-scrollbar-track,
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }

/* Accessibility: visible focus ring for keyboard nav */
:focus-visible {
    outline: 2px solid var(--primary-light);
    outline-offset: 2px;
    border-radius: 6px;
}
.btn-icon:focus-visible, .nav-tab:focus-visible { outline-offset: -2px; }

/* Reduced-motion preference */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* Mobile: collapsible sidebar via topbar menu button */
@media (max-width: 1024px) {
    .topbar-menu { display: inline-flex; }
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        width: 260px;
        z-index: 60;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        box-shadow: var(--shadow);
    }
    .sidebar.open { transform: translateX(0); }
    .app-layout { display: block; }
    .main-content { width: 100%; }
}

/* ── Enterprise UX additions: saved connections, overview, activity, empty states ── */

/* Overview: two-column layout (getting-started + recent activity) */
.overview-cols {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
    gap: 16px;
    margin-top: 8px;
}
@media (max-width: 900px) { .overview-cols { grid-template-columns: 1fr; } }

/* Recent activity timeline */
.activity-feed { display: flex; flex-direction: column; gap: 10px; max-height: 320px; overflow-y: auto; }
.activity-item { display: flex; gap: 10px; align-items: flex-start; }
.activity-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); margin-top: 6px; flex: 0 0 8px; }
.activity-body { min-width: 0; }
.activity-title { font-size: 13px; font-weight: 600; }
.activity-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.muted-count { color: var(--text-muted); font-weight: 500; font-size: 12px; }

/* Saved connections panel */
.saved-connections { margin-bottom: 20px; }
.saved-connections-header { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.saved-connections-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.saved-conn-chip { padding: 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.saved-conn-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.saved-conn-icon { font-size: 22px; flex: 0 0 22px; }
.saved-conn-info { min-width: 0; }
.saved-conn-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.saved-conn-meta { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.saved-conn-actions { display: flex; gap: 8px; flex: 0 0 auto; }
.saved-conn-actions .btn { padding: 6px 12px; font-size: 12.5px; }

/* Empty states */
.empty-state { text-align: center; padding: 28px 20px; color: var(--text-muted); }
.empty-icon { font-size: 34px; margin-bottom: 8px; opacity: 0.85; }
.empty-title { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.empty-hint { font-size: 13px; line-height: 1.5; max-width: 420px; margin: 0 auto; }

/* ───────────────────────────────────────────────────────────────
   Editorial-ops layer — landing.html craft motifs on the dark base.
   Serif page titles (above) carry the editorial voice; the utilities below
   add provenance lines, a ledger/terminal widget, citation cards, and a risk
   callout where the data semantically earns them. Used sparingly per page.
   ─────────────────────────────────────────────────────────────── */

.mono { font-family: var(--font-mono); }
.num { font-variant-numeric: tabular-nums; font-family: var(--font-mono); }

/* Section head — mono ref + serif title + hairline rule (mirrors landing §-heads) */
.section-head { display: flex; align-items: baseline; gap: 14px; margin: 4px 0 24px; flex-wrap: wrap; }
.section-head .ref { font-family: var(--font-mono); font-size: 12px; color: var(--signal); font-weight: 600; white-space: nowrap; }
.section-head .ttl { font-family: var(--font-serif); font-weight: 400; font-size: clamp(26px, 3vw, 33px); letter-spacing: -0.02em; color: var(--text); line-height: 1.08; }
.section-head .ttl em { font-style: italic; color: var(--signal); }
.section-head .rule { flex: 1 1 60px; height: 1px; background: var(--border); margin-left: 4px; min-width: 20px; }
.section-head .actions { margin-left: auto; }

/* Provenance line — mono, dim, hairline top, for "where this number came from" */
.provenance {
    font-family: var(--font-mono); font-size: 12.5px; color: var(--text-muted);
    line-height: 1.7; border-top: 1px solid var(--border); padding-top: 14px;
    margin-top: 18px; max-width: 90ch;
}
.provenance b { color: var(--text); font-weight: 600; }
.provenance .arrow { color: var(--signal); }

/* Citation card grid — for cited compliance mappings */
.cite-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1px;
    background: var(--border); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.cite-card { background: var(--card); padding: 18px 16px; display: flex; flex-direction: column; gap: 8px; }
.cite-card .cid { font-family: var(--font-mono); font-size: 12px; color: var(--signal); font-weight: 600; }
.cite-card .cname { font-size: 14px; color: var(--text); font-weight: 600; line-height: 1.35; }
.cite-card .cev { font-size: 12.5px; color: var(--text-muted); line-height: 1.5; }
.cite-card .cstat { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); margin-top: auto; }

/* Ledger / terminal widget — live scan/classify output */
.ledger {
    background: #0B1115; border-radius: 12px; overflow: hidden;
    box-shadow: 0 14px 34px -16px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.05);
    font-family: var(--font-mono); color: #D6E2D5;
}
.ledger-bar { display: flex; align-items: center; gap: 10px; padding: 11px 15px;
    border-bottom: 1px solid rgba(214,226,213,0.10); background: rgba(255,255,255,0.02); }
.ledger-bar .dots { display: flex; gap: 6px; }
.ledger-bar .dots i { width: 10px; height: 10px; border-radius: 50%; background: rgba(214,226,213,0.16); display: block; }
.ledger-bar .ltitle { font-size: 11.5px; color: #6E7E7B; }
.ledger-bar .live { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; font-size: 10.5px; color: var(--signal); letter-spacing: 0.06em; }
.ledger-bar .live i { width: 6px; height: 6px; border-radius: 50%; background: var(--signal); animation: dg-blink 1.4s steps(2,end) infinite; }
.ledger-body { padding: 14px 16px 16px; font-size: 12.5px; line-height: 1.8; max-height: 320px; overflow: hidden auto; }
.ledger-row { display: grid; grid-template-columns: 1.5fr 0.5fr 0.7fr 1fr; gap: 10px; white-space: nowrap; }
.ledger-row .f { color: #D6E2D5; overflow: hidden; text-overflow: ellipsis; }
.ledger-row .kind { color: #6E7E7B; }
.ledger-row .conf { color: #6E7E7B; }
.ledger-row .conf b { color: #D6E2D5; font-weight: 500; }
.ledger-foot { border-top: 1px solid rgba(214,226,213,0.10); padding: 10px 16px; font-size: 11px;
    color: #6E7E7B; display: flex; justify-content: space-between; }
.ledger-foot b { color: #D6E2D5; font-weight: 500; }
.ledger .tag { font-weight: 600; font-size: 10.5px; padding: 1px 7px; border-radius: 4px; display: inline-block; height: 16px; line-height: 14px; text-align: center; }
.ledger .tag.pii { background: var(--signal-soft); color: #E69A47; }
.ledger .tag.phi { background: rgba(181,71,46,0.20); color: #D6754E; }
.ledger .tag.pci { background: var(--petrol-soft); color: #5FB6BB; }
@keyframes dg-blink { 50% { opacity: 0.25; } }

/* Risk callout — the single dollar number leadership acts on */
.risk-callout { display: grid; grid-template-columns: 1.2fr 1fr; gap: 36px; align-items: end; padding: 4px 0 8px; }
.risk-callout .big { font-family: var(--font-serif); font-weight: 400; font-size: clamp(60px, 9vw, 96px);
    line-height: 0.9; color: var(--text); letter-spacing: -2px; }
.risk-callout .big .cur { color: var(--signal); font-size: 0.5em; vertical-align: top; line-height: 1.6; margin-right: 2px; }
.risk-callout .big .unit { font-size: 0.28em; color: var(--text-muted); margin-left: 6px; letter-spacing: 0; }
.risk-callout .cap-l { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 14px; }
.risk-callout .prov { font-size: 14px; color: var(--text-muted); line-height: 1.6; max-width: 52ch; }
.risk-callout .prov b { color: var(--text); }
@media (max-width: 720px) { .risk-callout { grid-template-columns: 1fr; gap: 20px; } }

/* Subtle hairline divider between stacked report cards */
.report-card { padding: 20px; margin-top: 16px; }
.report-card > h3 { font-size: 16px; font-weight: 600; margin-bottom: 14px; color: var(--text); display: flex; align-items: baseline; gap: 10px; }
.report-card > h3 .h3-ref { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); font-weight: 500; }

/* Stat card: serif numeral option for headline page metrics */
.stat-card .stat-value { font-family: var(--font-sans); }

/* ───────────────────────────────────────────────────────────────
   Sign-in page — editorial card matching landing.html's brand mark.
   ─────────────────────────────────────────────────────────────── */
.signin-overlay { padding: 28px; }
.signin-card {
    max-width: 420px; width: 100%; padding: 40px 38px 34px;
    box-shadow: var(--shadow-lg);
}
.signin-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 26px; }
.signin-glyph {
    width: 34px; height: 34px; border-radius: 8px; background: var(--petrol); color: var(--signal);
    display: grid; place-items: center; font-family: var(--font-serif); font-weight: 700;
    font-size: 18px; line-height: 1; letter-spacing: -0.5px;
}
.signin-name { font-weight: 700; font-size: 16px; letter-spacing: -0.2px; }
.signin-title { font-family: var(--font-serif); font-weight: 400; font-size: 34px; letter-spacing: -0.02em; line-height: 1.05; margin-bottom: 6px; }
.signin-sub { color: var(--text-muted); font-size: 14.5px; line-height: 1.5; margin-bottom: 26px; max-width: 38ch; }
.signin-form { display: flex; flex-direction: column; gap: 14px; }
.signin-error { color: var(--danger); font-size: 13px; display: none; }
.signin-btn { width: 100%; padding: 12px; font-size: 15px; margin-top: 2px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.signin-arr { transition: transform 0.18s ease; }
.signin-btn:hover .signin-arr { transform: translateX(2px); }
.signin-divider { display: flex; align-items: center; gap: 12px; margin: 14px 0 6px; color: var(--text-muted); font-size: 12px; }
.signin-divider::before, .signin-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.signin-hint { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.signin-hint b { color: var(--text); font-weight: 600; }
.signin-foot { font-size: 11.5px; color: var(--text-muted); margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--border); }
.signin-info { color: var(--secondary); }
.link-btn { background: none; border: none; color: var(--secondary); font: inherit; font-size: 12.5px; font-weight: 600; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.link-btn:hover { color: var(--text); }
@media (max-width: 480px) { .signin-card { padding: 32px 22px 26px; } .signin-title { font-size: 28px; } }

/* LLM-availability gating: AI surfaces (the "use AI" toggles) carry data-ai-feature
 * and are hidden by default via the ai-feature-off class until the frontend confirms
 * the org's central LLM is enabled (see applyLlmGating in app.js). A plain class
 * (no !important) so RBAC inline display:none on data-admin-only elements still wins
 * for non-admins — the AI Policies card stays hidden for members even with the LLM on. */
.ai-feature-off { display: none; }
