/* RegulaView · Admin Portal — calm, dense, mission-critical. */

:root {
    --navy-950:#06101f;
    --navy-900:#0b1a33;
    --navy-800:#13243f;
    --navy-700:#1c3457;
    --slate-700:#334155;
    --slate-600:#475569;
    --slate-500:#64748b;
    --slate-400:#94a3b8;
    --slate-300:#cbd5e1;
    --slate-200:#e2e8f0;
    --slate-100:#f1f5f9;
    --slate-50:#f8fafc;
    --white:#ffffff;
    --accent:#3b82f6;
    --accent-strong:#1d4ed8;
    --good:#10b981;
    --warn:#f59e0b;
    --bad:#ef4444;
    --radius:10px;
    --shadow-sm:0 1px 2px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.05);

    /* Semantic surface tokens — remapped wholesale by the dark theme so panels,
       cards, tables and modals follow the theme without per-rule overrides. */
    --surface:#ffffff;        /* cards, panels, tables, topbar, modals, popovers */
    --surface-2:#f8fafc;      /* insets / hover fills */
    --border:#e2e8f0;         /* default surface border */
    --accent-bar:#0b1a33;     /* solid accent surfaces (bulk bar, active chips) */

    /* Sidebar is intentionally dark in BOTH themes — its own tokens never remap. */
    --sidebar-bg:#0b1a33;
    --sidebar-link:#cbd5e1;
    --sidebar-active:#1d4ed8;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body { font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif; color: var(--slate-700); background: var(--slate-50); }
a { color: var(--accent-strong); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; }

.btn { display: inline-flex; align-items: center; justify-content: center; padding: 9px 14px; border-radius: 8px; font-weight: 600; font-size: .92rem; border: 1px solid transparent; cursor: pointer; }
.btn.lg { padding: 12px 18px; font-size: 1rem; }
.btn.small { padding: 6px 10px; font-size: .85rem; }
.btn.full { width: 100%; }
.btn-primary { background: var(--accent-bar); color: #fff; }
.btn-primary:hover { background: #13243f; }
.btn.primary { background: var(--accent-bar); color: #fff; }
.btn.primary:hover { background: #13243f; }
.btn-secondary { background: var(--slate-100); color: var(--navy-900); border-color: var(--slate-200); }
.btn-secondary:hover { background: var(--slate-200); text-decoration: none; }
.btn-ghost { background: transparent; color: var(--navy-900); border-color: var(--slate-300); }
.btn-ghost:hover { border-color: var(--navy-900); }
.btn-sm { padding: 6px 10px; font-size: .82rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.muted { color: var(--slate-500); }
.small { font-size: .85rem; }
.xs { font-size: .76rem; }
.txt-good { color: var(--good); }
.txt-warn { color: var(--warn); }
.txt-bad { color: var(--bad); }

/* Auth shell */
.auth-shell { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(180deg, #0b1a33, #13243f); padding: 24px; }
.auth-card { width: 100%; max-width: 420px; background: #fff; border-radius: 14px; padding: 32px; box-shadow: 0 30px 60px -20px rgba(0,0,0,.5); }
.auth-brand { display: flex; align-items: center; gap: 10px; font-weight: 600; color: var(--navy-900); margin-bottom: 22px; }
.auth-brand .brand-mark { width: 24px; height: 24px; display: block; object-fit: contain; }
.auth-card h1 { font-size: 1.5rem; margin: 0 0 6px; color: var(--navy-900); }
.auth-card .field { display: flex; flex-direction: column; gap: 6px; margin: 14px 0; }
.auth-card .field label { font-weight: 600; font-size: .9rem; color: var(--navy-900); }
.auth-card .field input { padding: 11px 12px; border: 1px solid var(--slate-300); border-radius: 8px; font: inherit; }
.auth-card .field input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.auth-foot { margin-top: 18px; }
.notice { padding: 10px 12px; border-radius: 8px; margin: 12px 0; }
.notice.error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.notice.success, .notice.ok { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.notice.warn { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }

/* App shell */
.app-shell { display: grid; grid-template-columns: 260px 1fr; height: 100dvh; overflow: hidden; }
.sidebar { background: var(--sidebar-bg); color: var(--slate-200); display: flex; flex-direction: column; min-height: 0; padding: 22px 16px; }
.sidebar .brand { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 4px 8px 18px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand-lockup { display: flex; align-items: center; gap: 10px; min-width: 0; }
.sidebar .brand strong { display: block; color: #fff; }
.sidebar .brand-mark { width: 34px; height: 34px; flex: 0 0 34px; display: block; object-fit: contain; padding: 4px; border: 1px solid rgba(255,255,255,.28); border-radius: 8px; background: #fff; }
.regulator-brand { display: grid; grid-template-columns: 34px minmax(0, 1fr); align-items: center; gap: 10px; margin: 14px 8px 4px; padding: 9px 10px; border: 1px solid rgba(148,163,184,.25); border-radius: 8px; background: rgba(255,255,255,.045); }
.regulator-brand-mark { width: 34px; height: 34px; display: grid; place-items: center; object-fit: contain; padding: 4px; border-radius: 8px; background: #fff; border: 1px solid rgba(226,232,240,.8); color: var(--navy-900); font-size: .72rem; font-weight: 800; line-height: 1; }
.regulator-brand-initials { overflow: hidden; text-overflow: clip; }
.regulator-brand-label { display: block; color: rgba(226,232,240,.62); font-size: .64rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.regulator-brand strong { display: block; color: #fff; font-size: .9rem; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mobile-menu-btn, .mobile-close-btn, .mobile-nav-backdrop { display: none; }
.sidebar nav { display: flex; flex-direction: column; gap: 12px; padding: 14px 0; flex: 1; min-height: 0; overflow-y: auto; }
.sidebar nav {
    scrollbar-width: thin;
    scrollbar-color: rgba(148,163,184,.58) transparent;
}
.sidebar nav::-webkit-scrollbar { width: 10px; }
.sidebar nav::-webkit-scrollbar-track { background: transparent; }
.sidebar nav::-webkit-scrollbar-thumb {
    min-height: 44px;
    border: 3px solid var(--sidebar-bg);
    border-radius: 999px;
    background: rgba(148,163,184,.5);
}
.sidebar nav::-webkit-scrollbar-thumb:hover { background: rgba(203,213,225,.72); }
.sidebar nav::-webkit-scrollbar-button { width: 0; height: 0; display: none; }
.nav-section { display: grid; gap: 2px; }
.nav-title { padding: 8px 10px 3px; color: rgba(226,232,240,.62); font-size: .68rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.sidebar nav a { color: var(--sidebar-link); padding: 9px 10px; border-radius: 7px; display: flex; align-items: center; gap: 10px; font-size: .92rem; }
.sidebar nav a:hover { background: rgba(255,255,255,.05); color: #fff; text-decoration: none; }
.sidebar nav a.active { background: var(--sidebar-active); color: #fff; }
.sidebar .ico { display: inline-block; width: 18px; text-align: center; opacity: .8; }
.sidebar-foot { border-top: 1px solid rgba(255,255,255,.08); padding-top: 14px; }

/* Collapse-to-rail toggle next to the brand */
.nav-collapse-btn { flex: 0 0 auto; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px; color: var(--slate-300); border: 1px solid rgba(226,232,240,.18); background: rgba(255,255,255,.04); cursor: pointer; font-size: 1rem; line-height: 1; }
.nav-collapse-btn:hover { color: #fff; border-color: rgba(255,255,255,.55); background: rgba(255,255,255,.1); }

/* Account trigger + popup menu */
.user-menu-wrap { position: relative; }
.user-trigger { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px; border: 1px solid transparent; border-radius: 10px; background: transparent; color: inherit; cursor: pointer; text-align: left; }
.user-trigger:hover, .user-trigger.is-open { border-color: rgba(226,232,240,.22); background: rgba(255,255,255,.05); }
.user-trigger .avatar { width: 36px; height: 36px; background: var(--accent); color: #fff; border-radius: 50%; display: grid; place-items: center; font-weight: 700; flex: 0 0 auto; }
.user-trigger .user-meta { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.user-trigger .user-meta strong { display: block; color: #fff; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-caret { flex: 0 0 auto; color: var(--slate-300); font-size: .8rem; line-height: 1; transition: transform .15s ease; }
.user-trigger.is-open .user-caret { transform: rotate(180deg); }

.user-menu-backdrop { position: fixed; inset: 0; z-index: 45; width: 100vw; height: 100vh; border: 0; padding: 0; background: transparent; cursor: default; }
.user-menu { position: absolute; z-index: 46; left: 0; right: 0; bottom: calc(100% + 8px); display: flex; flex-direction: column; padding: 6px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); box-shadow: 0 18px 44px rgba(15,23,42,.34); min-width: 190px; }
.user-menu-head { padding: 6px 10px 8px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.user-menu-head strong { display: block; color: var(--navy-900); font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 7px; color: var(--slate-700); font-size: .9rem; text-decoration: none; }
.user-menu-item:hover { background: var(--surface-2); text-decoration: none; }
.user-menu-item .ico { display: inline-block; width: 18px; text-align: center; opacity: .8; }

/* Collapsed icon-only rail (desktop only; on mobile the sidebar is a full slide-in) */
@media (min-width: 801px) {
    .app-shell.nav-rail { grid-template-columns: 72px 1fr; }
    .nav-rail .sidebar { padding-left: 10px; padding-right: 10px; }
    .nav-rail .brand { flex-direction: column; justify-content: center; gap: 10px; padding: 4px 0 16px; }
    .nav-rail .brand-lockup > div { display: none; }
    .nav-rail .regulator-brand { display: none; }
    .nav-rail .nav-title { display: none; }
    .nav-rail .sidebar nav a { justify-content: center; gap: 0; font-size: 0; padding: 10px 0; }
    .nav-rail .sidebar nav a .ico { font-size: 1.05rem; opacity: .9; }
    .nav-rail .user-trigger { justify-content: center; padding: 6px 0; }
    .nav-rail .user-trigger .user-meta, .nav-rail .user-caret { display: none; }
    /* popup floats up from the avatar; don't stretch it to the narrow rail width */
    .nav-rail .user-menu { left: 0; right: auto; min-width: 210px; }
}

.main { display: flex; flex-direction: column; min-width: 0; height: 100dvh; overflow: hidden; }
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 14px 28px; background: var(--surface); border-bottom: 1px solid var(--border); }
.env-badge { font-size: .85rem; color: var(--slate-500); }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.content { flex: 1; min-height: 0; overflow: auto; padding: 28px; }

.page-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.page-header h1 { margin: 0 0 4px; font-size: 1.6rem; color: var(--navy-900); font-family: 'Inter', sans-serif; font-weight: 600; }
.page-header h1:focus { outline: none; }
.page-header p { margin: 0; }
.page-actions, .row-actions { display: inline-flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

/* KPI cards */
.kpi-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; margin-bottom: 22px; }
.kpi-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-sm); }
.kpi-card span { font-size: .76rem; text-transform: uppercase; letter-spacing: .08em; color: var(--slate-500); display: block; }
.kpi-card strong { font-size: 1.6rem; color: var(--navy-900); display: block; margin-top: 4px; font-weight: 600; }
.kpi-card small { display: block; margin-top: 4px; }

.panel, .card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm); margin-top:10px;}
.panel header, .card header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.panel header h2, .card header h2 { margin: 0; font-size: 1rem; color: var(--navy-900); font-family: 'Inter', sans-serif; font-weight: 600; }
.section-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 14px; }
.section-head h2 { margin: 0; font-size: 1rem; color: var(--navy-900); }
.section-head p { margin: 3px 0 0; }
.section-head.compact { margin-bottom: 10px; }
.bars-lg { display: flex; align-items: flex-end; gap: 4px; height: 180px; }
.bars-lg span { flex: 1; background: linear-gradient(180deg, var(--accent), var(--navy-700)); border-radius: 3px 3px 0 0; opacity: .85; }
.stages { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.stages li { display: flex; align-items: center; gap: 8px; font-size: .92rem; color: var(--slate-700); }

.grid { display: grid; gap: 16px; }
.two-thirds { grid-template-columns: 2fr 1fr; }
.two { grid-template-columns: 1fr 1fr; }
.workflow-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 22px; }
.queue-panel header { min-height: 30px; }
.queue-list { display: grid; gap: 8px; }
.queue-item { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; min-height: 56px; padding: 10px 12px; border: 1px solid var(--slate-200); border-radius: 8px; background: var(--slate-50); color: var(--slate-700); }
.queue-item:hover { border-color: var(--accent); background: var(--surface); text-decoration: none; }
.queue-item span { display: grid; gap: 2px; }
.queue-item span strong { color: var(--navy-900); font-size: .92rem; }
.queue-item span small { color: var(--slate-500); font-size: .78rem; }
.queue-item > strong { color: var(--navy-900); font-size: 1.15rem; font-weight: 700; }
.queue-item.warn { border-color: #fde68a; background: #fffbeb; }
.queue-item.danger { border-color: #fecaca; background: #fef2f2; }

/* Status dot */
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--slate-300); }
.status-dot.ok { background: var(--good); box-shadow: 0 0 0 3px rgba(16,185,129,.18); }
.status-dot.warn { background: var(--warn); box-shadow: 0 0 0 3px rgba(245,158,11,.18); }
.status-dot.bad { background: var(--bad); box-shadow: 0 0 0 3px rgba(239,68,68,.18); }

/* Toolbar */
.toolbar { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.filter-strip { display: grid; grid-template-columns: minmax(220px, 2fr) repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; align-items: end; margin-bottom: 16px; }
.filter-panel { margin-bottom: 16px; }
.filter-panel.compact .filter-strip { margin-bottom: 0; }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; align-items: end; }
.filter-grid .field, .filter-strip .field { margin: 0; }
.filter-actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; }
.check { display: flex; align-items: center; min-height: 40px; gap: 8px; font-weight: 500; color: var(--slate-700); }
.input { padding: 9px 12px; border: 1px solid var(--slate-300); border-radius: 8px; font: inherit; background: #fff; min-width: 200px; }
.filter-grid .input, .filter-strip .input { width: 100%; min-width: 0; }
.input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }

/* Data tables */
/* A single real table layout so the header, column-filter, and body rows ALWAYS share the same column
   widths. The previous approach (display:block table + thead/tbody each set to display:table) sized the
   header and body as two independent tables, so their columns drifted apart — misaligning every .data table.
   Very wide tables overflow into the scrollable .content pane (or a .table-scroll wrapper where one is used). */
table.data { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.table-scroll { width: 100%; overflow-x: auto; }
table.data th, table.data td { padding: 11px 14px; text-align: left; vertical-align: top; }
table.data th.num, table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data th.center, table.data td.center { text-align: center; }
table.data th.time-col { width: 170px; }
table.data thead { background: var(--slate-50); }
table.data th { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--slate-500); font-weight: 600; border-bottom: 1px solid var(--slate-200); }
table.data tbody tr { border-top: 1px solid var(--slate-100); }
table.data tbody tr:hover { background: var(--slate-50); }
table.data tbody tr.clickable-row { cursor: pointer; }
table.data .row-actions { white-space: nowrap; text-align: right; }
table.data tr.row-warn { background: #fffbeb; }
table.data tr.row-warn:hover { background: #fef3c7; }
.link { background: none; border: none; color: var(--accent-strong); cursor: pointer; padding: 0 6px; font-weight: 600; font-size: .9rem; }
.link:hover { text-decoration: underline; }
.code-link { padding: 0; vertical-align: inherit; }

code { font-family: ui-monospace, 'JetBrains Mono', Menlo, monospace; font-size: .85em; background: var(--slate-100); padding: 2px 6px; border-radius: 4px; }

/* Badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .76rem; font-weight: 600; background: var(--slate-100); color: var(--slate-700); border: 1px solid var(--slate-200); }
.badge.ok, .badge.badge-ok, .badge.sev-low { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.badge.warn, .badge.badge-warn, .badge.sev-medium { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.badge.bad, .badge.sev-high { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.badge.sev-critical { background: #7f1d1d; color: #fff; border-color: #7f1d1d; }
.badge.sev-info { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }
.badge.small { font-size: .68rem; padding: 1px 6px; }

.empty { background: var(--surface); border: 1px dashed var(--slate-300); padding: 28px; border-radius: var(--radius); text-align: center; }

.callout { padding: 12px 14px; border: 1px solid var(--slate-200); border-radius: 8px; background: var(--slate-50); }
.callout.ok { border-color: #a7f3d0; background: #ecfdf5; color: #065f46; }
.callout.danger { border-color: #fecaca; background: #fef2f2; color: #991b1b; }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0; }

/* Generic form fields (used outside .auth-card) */
.field { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.field label { font-weight: 600; font-size: .85rem; color: var(--navy-900); }
.field .span-two { grid-column: span 2; }
.field.span-two { grid-column: span 2; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(180px, 1fr)); gap: 12px; align-items: end; }
.form-grid .input { width: 100%; min-width: 0; }
/* Style native controls placed in a form-grid even when authors forget the .input class. */
.form-grid input[type="text"], .form-grid input[type="email"], .form-grid input[type="url"],
.form-grid input[type="password"], .form-grid input[type="number"], .form-grid input[type="date"],
.form-grid input[type="datetime-local"], .form-grid input[type="search"], .form-grid input[type="tel"],
.form-grid select, .form-grid textarea {
    width: 100%; min-width: 0; padding: 9px 12px; border: 1px solid var(--slate-300);
    border-radius: 8px; font: inherit; background: var(--surface); color: var(--navy-900);
}
.form-grid select { appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--slate-500) 50%), linear-gradient(135deg, var(--slate-500) 50%, transparent 50%); background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
.form-grid textarea { resize: vertical; min-height: 80px; }
.form-grid label { display: flex; flex-direction: column; gap: 6px; font-size: .85rem; font-weight: 600; color: var(--navy-900); }
.form-grid label > .input, .form-grid label > input, .form-grid label > select, .form-grid label > textarea { margin-top: 0; }
.form-grid .full { grid-column: 1 / -1; }
.btn-danger { background: var(--bad); color: #fff; }
.btn-danger:hover { background: #b91c1c; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .55); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal { background: var(--surface); border-radius: 12px; padding: 22px; min-width: 360px; max-width: 720px; width: 100%; box-shadow: 0 24px 48px -12px rgba(0,0,0,.45); max-height: 92vh; overflow-y: auto; }
.modal.wide { max-width: 920px; }
.modal.extra-wide { max-width: 980px; }
.modal.jurisdiction-detail { max-width: 900px; }
.modal.jurisdiction-editor { max-width: min(1120px, calc(100vw - 32px)); padding: 0; display: flex; flex-direction: column; overflow: hidden; }
.modal.small { max-width: 420px; }
.modal header h2 { margin: 0 0 8px; font-size: 1.15rem; color: var(--navy-900); }
.modal-body { margin: 12px 0; }
.modal-body.grid.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--slate-100); }

.banner { padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; }
.banner-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.banner-warn { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }

.jurisdiction-editor > header { flex: 0 0 auto; padding: 18px 22px; border-bottom: 1px solid var(--slate-200); background: var(--surface); }
.jurisdiction-editor form { min-height: 0; display: flex; flex: 1 1 auto; flex-direction: column; }
.jurisdiction-editor .modal-body { margin: 0; padding: 18px 22px; overflow: auto; background: var(--slate-50); display: grid; gap: 14px; }
.jurisdiction-editor .modal-foot { flex: 0 0 auto; margin: 0; padding: 14px 22px; background: var(--surface); border-top: 1px solid var(--slate-200); box-shadow: 0 -10px 24px rgba(15,23,42,.06); }
.jurisdiction-editor .modal-body > h3 { margin: 6px 0 -6px; color: var(--slate-500); font-size: .76rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.jurisdiction-editor .grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; padding: 14px; background: var(--surface); border: 1px solid var(--slate-200); border-radius: 8px; box-shadow: var(--shadow-sm); }
.jurisdiction-editor .span-two { grid-column: span 2; }
.jurisdiction-editor .span-four { grid-column: 1 / -1; }
.jurisdiction-editor .auto-prefill-hint { margin: 4px 2px 12px; }
.jurisdiction-editor .grid.four > label:not(.check),
.jurisdiction-editor .modal-body > label:not(.check) { display: flex; flex-direction: column; gap: 6px; margin: 0; color: var(--navy-900); font-size: .85rem; font-weight: 600; }
.jurisdiction-editor .grid.four > .check { min-height: 38px; align-self: end; margin: 0; padding: 8px 10px; border: 1px solid var(--slate-200); border-radius: 8px; background: var(--slate-50); }
.jurisdiction-editor .grid.four .input,
.jurisdiction-editor .modal-body > label .input { width: 100%; min-width: 0; }
.jurisdiction-editor .grid.four textarea.input,
.jurisdiction-editor .modal-body > label textarea.input { resize: vertical; }
.jurisdiction-editor .choice-grid { display: flex; flex-wrap: wrap; gap: 8px; padding: 14px; background: var(--surface); border: 1px solid var(--slate-200); border-radius: 8px; box-shadow: var(--shadow-sm); }
.jurisdiction-editor .choice-grid.compact { align-items: center; }
.jurisdiction-editor .choice-label { flex: 0 0 100%; font-weight: 700; color: var(--slate-500); text-transform: uppercase; letter-spacing: .06em; }
.jurisdiction-editor .chip { min-height: 32px; display: inline-flex; align-items: center; gap: 7px; padding: 6px 10px; border: 1px solid var(--slate-200); border-radius: 999px; background: var(--surface); color: var(--slate-700); font-size: .83rem; font-weight: 600; cursor: pointer; user-select: none; }
.jurisdiction-editor .chip input { width: 14px; height: 14px; margin: 0; flex: 0 0 auto; }
.jurisdiction-editor .chip-on { border-color: #bfdbfe; background: #eff6ff; color: #1e40af; }
.jurisdiction-editor .chip:hover { border-color: var(--accent); }

.permission-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.permission-summary > div { border: 1px solid var(--slate-200); border-radius: 8px; padding: 10px 12px; background: var(--slate-50); }
.permission-summary strong { display: block; margin-top: 3px; color: var(--navy-900); font-size: 1.25rem; }
.permissions-table { max-height: 52vh; }
.permissions-table td:nth-child(2), .permissions-table td:nth-child(4) { white-space: nowrap; }

/* Compact data table variant */
table.data.compact th, table.data.compact td { padding: 6px 10px; font-size: .85rem; }
.input.compact { padding: 5px 8px; font-size: .85rem; min-width: 120px; }

/* Tiny button variant for inline row actions */
.btn.xs { padding: 2px 8px; font-size: .76rem; }

/* Inline code block (used by audit detail / before-after JSON) */
pre.code-block {
    background: var(--slate-50, #f8fafc);
    border: 1px solid var(--slate-100, #e2e8f0);
    border-radius: 6px;
    padding: 10px 12px;
    font-size: .78rem;
    line-height: 1.4;
    max-height: 280px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-all;
    margin: 0;
}

/* Definition list (key/value) */
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
dl.kv dt { font-weight: 600; color: var(--slate-500); font-size: .85rem; }
dl.kv dd { margin: 0; }

/* Activity timeline */
ol.timeline { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
ol.timeline li { position: relative; padding: 8px 12px 8px 18px; border-left: 3px solid var(--accent); background: var(--slate-50); border-radius: 0 8px 8px 0; }

/* Responsive */
@media (max-width: 1100px) {
    .kpi-grid { grid-template-columns: repeat(3, 1fr); }
    .workflow-grid { grid-template-columns: 1fr; }
    .two-thirds { grid-template-columns: 1fr; }
    .jurisdiction-editor .grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 800px) {
    .app-shell { display: block; min-height: 100vh; height: auto; overflow: visible; }
    .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 40; width: min(84vw, 320px); height: 100dvh; max-width: 320px; transform: translateX(-105%); transition: transform .18s ease; box-shadow: 18px 0 48px rgba(15,23,42,.32); }
    .app-shell.nav-open .sidebar { transform: translateX(0); }
    .sidebar nav { flex-direction: column; flex-wrap: nowrap; min-height: 0; overflow-y: auto; }
    .nav-section { display: grid; }
    .nav-collapse-btn { display: none; }
    .mobile-close-btn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border: 1px solid rgba(226,232,240,.45); border-radius: 8px; background: rgba(255,255,255,.05); color: #fff; cursor: pointer; font-size: 1.35rem; line-height: 1; }
    .mobile-close-btn:hover { background: rgba(255,255,255,.1); }
    .mobile-nav-backdrop { display: block; position: fixed; inset: 0; z-index: 35; width: 100vw; height: 100vh; border: 0; padding: 0; background: rgba(15,23,42,.48); cursor: pointer; }
    .mobile-menu-btn { display: inline-flex; flex: 0 0 auto; width: 40px; height: 40px; align-items: center; justify-content: center; flex-direction: column; gap: 4px; border: 1px solid var(--slate-200); border-radius: 8px; background: #fff; cursor: pointer; }
    .mobile-menu-btn span { width: 18px; height: 2px; border-radius: 99px; background: var(--navy-900); }
    .main { height: auto; overflow: visible; }
    .topbar { position: sticky; top: 0; z-index: 20; justify-content: flex-start; gap: 12px; padding: 10px 14px; }
    .topbar-actions { margin-left: auto; }
    .content { overflow: visible; padding: 18px 14px; }
    .page-header { align-items: flex-start; flex-direction: column; }
    .toolbar { align-items: stretch; }
    .toolbar .input, .toolbar .btn { width: 100%; }
    .filter-strip, .filter-grid { grid-template-columns: 1fr; }
    .jurisdiction-editor { min-width: 0; }
    .jurisdiction-editor .grid.four { grid-template-columns: 1fr; }
    .jurisdiction-editor .span-two { grid-column: 1 / -1; }
    .section-head { display: grid; gap: 10px; }
    .filter-actions { justify-content: stretch; }
    .filter-actions .btn { flex: 1; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .two { grid-template-columns: 1fr; }
    .form-grid, .form-grid.ms-form-2col { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
    .kpi-grid { grid-template-columns: 1fr; }
    .topbar-actions .small { display: none; }
}

/* ---- One-time secret reveal (API credentials) ---- */
.secret-reveal { margin-top: 8px; display: grid; gap: 6px; }
.secret-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.secret-row code { background: var(--slate-100); border: 1px solid var(--slate-200); border-radius: 6px; padding: 4px 8px; font-size: .85rem; word-break: break-all; }
.secret-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--slate-500); min-width: 86px; }

/* ---- Sortable table headers ---- */
table.data th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
table.data th.sortable:hover { color: var(--navy-900); }
table.data th.sortable .sort-ind { margin-left: 4px; font-size: .7rem; color: var(--slate-400); }
table.data th.sortable.sorted .sort-ind { color: var(--navy-900); }

/* ---- Inline per-column filter row inside table headers ---- */
table.data tr.col-filters th { padding: 6px 10px; background: var(--surface); border-bottom: 1px solid var(--slate-200); text-transform: none; letter-spacing: normal; }
table.data tr.col-filters .input { width: 100%; min-width: 90px; padding: 5px 8px; font-size: .82rem; }
table.data tr.col-filters th.filter-empty { background: var(--surface); }

/* ---- Compact table toolbar (filters that don't belong in a column) ---- */
.table-toolbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.table-toolbar .toolbar-filters { display: flex; gap: 12px; flex-wrap: wrap; }
.table-toolbar .field { margin: 0; min-width: 180px; }
.table-toolbar .field label { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--slate-500); }

/* ---- Inline info "(i)" hint icon with native tooltip ---- */
.hint-i { display: inline-flex; align-items: center; justify-content: center; width: 15px; height: 15px; margin-left: 5px; border-radius: 50%; border: 1px solid var(--slate-300); background: var(--slate-50); color: var(--slate-500); font-size: .68rem; font-weight: 700; font-style: normal; line-height: 1; cursor: help; vertical-align: middle; }
.hint-i:hover, .hint-i:focus { border-color: var(--navy-900); color: var(--navy-900); outline: none; }

/* ---- Inline "how to use" link button (no chrome, reads as a link) ---- */
.link-inline { background: none; border: none; padding: 0; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; text-decoration: underline; }
.link-inline:hover { color: var(--navy-900); }

/* ---- Full-width sub-section label inside a two-column modal grid ---- */
.modal-section { grid-column: 1 / -1; margin: 6px 0 -4px; color: var(--slate-500); font-size: .74rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; }
.modal-section.first { margin-top: 0; }
.modal-hint { grid-column: 1 / -1; margin: 0; }

/* ---- Numbered help steps (How-to modals) ---- */
.help-list { margin: 10px 0; padding-left: 20px; display: grid; gap: 8px; }
.help-list li { line-height: 1.45; }

/* ---- Combo (autocomplete) field ---- */
.combo { position: relative; }
.combo .input { width: 100%; }
.combo small.hint { display: block; margin-top: 2px; color: var(--slate-500); font-size: .72rem; }

/* ===================================================================== */
/* UI/UX enhancement layer (toasts, modals, palette, theme, etc.)         */
/* ===================================================================== */

/* ---- Topbar environment badge + system-health pill ---- */
.env-badge.env-prod strong { color: var(--bad); }
.env-badge.env-nonprod strong { color: var(--warn); }
.health-pill { display: inline-flex; align-items: center; gap: 7px; padding: 5px 10px; border-radius: 999px; border: 1px solid var(--slate-200); background: var(--slate-50); }
.health-pill:hover { text-decoration: none; border-color: var(--slate-300); }
.health-pill.warn { border-color: #fde68a; background: #fffbeb; }
.health-pill.bad { border-color: #fecaca; background: #fef2f2; }

/* ---- Toast notifications ---- */
.toast-host { position: fixed; top: 16px; right: 16px; z-index: 1200; display: flex; flex-direction: column; gap: 10px; max-width: min(380px, calc(100vw - 32px)); }
.toast { display: grid; grid-template-columns: 18px 1fr auto; gap: 10px; align-items: start; padding: 12px 14px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); box-shadow: 0 12px 30px -12px rgba(15,23,42,.35); animation: toast-in .18s ease-out; }
.toast .toast-ico { font-weight: 800; line-height: 1.2; }
.toast .toast-body { min-width: 0; }
.toast .toast-title { font-weight: 700; font-size: .9rem; color: var(--navy-900); }
.toast .toast-msg { font-size: .84rem; color: var(--slate-600); margin-top: 2px; word-wrap: break-word; }
.toast .toast-close { background: none; border: 0; color: var(--slate-400); cursor: pointer; font-size: 1.1rem; line-height: 1; padding: 0 2px; }
.toast .toast-close:hover { color: var(--slate-700); }
.toast.success { border-left: 4px solid var(--good); } .toast.success .toast-ico { color: var(--good); }
.toast.error { border-left: 4px solid var(--bad); } .toast.error .toast-ico { color: var(--bad); }
.toast.warn { border-left: 4px solid var(--warn); } .toast.warn .toast-ico { color: var(--warn); }
.toast.info { border-left: 4px solid var(--accent); } .toast.info .toast-ico { color: var(--accent); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

/* ---- Skeleton loaders ---- */
.skeleton { display: block; border-radius: 6px; background: linear-gradient(90deg, var(--slate-100) 25%, var(--slate-200) 37%, var(--slate-100) 63%); background-size: 400% 100%; animation: skeleton-shimmer 1.3s ease-in-out infinite; }
.skeleton.text { height: .8rem; margin: 6px 0; }
.skeleton.line-lg { height: 1.4rem; }
.skeleton-row td { padding: 12px 10px; }
@keyframes skeleton-shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ---- Clickable table rows ---- */
table.data tr.clickable-row { cursor: pointer; }
table.data tr.clickable-row:hover td { background: var(--slate-50); }
table.data tr.clickable-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ---- Auto-refresh toggle ---- */
.refresh-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: .82rem; color: var(--slate-500); }
.refresh-toggle .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--slate-300); }
.refresh-toggle.on .dot { background: var(--good); box-shadow: 0 0 0 3px rgba(16,185,129,.18); animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .45; } }

/* ---- Reusable modal scaffolding (Esc/backdrop/focus aware) ---- */
.rv-modal-backdrop { position: fixed; inset: 0; z-index: 1000; background: rgba(15,23,42,.5); display: grid; place-items: center; padding: 24px; animation: toast-in .12s ease-out; }
.rv-modal { width: 100%; max-width: 560px; max-height: calc(100dvh - 48px); overflow: auto; background: var(--surface); border-radius: 14px; box-shadow: 0 30px 70px -20px rgba(0,0,0,.45); }
.rv-modal.lg { max-width: 760px; }
.rv-modal.sm { max-width: 420px; }
.rv-modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px 8px; }
.rv-modal-head h3 { margin: 0; color: var(--navy-900); font-size: 1.1rem; }
.rv-modal-body { padding: 8px 20px; }
.rv-modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px 20px; }
.rv-modal .icon-close { background: none; border: 0; font-size: 1.4rem; line-height: 1; color: var(--slate-400); cursor: pointer; }
.rv-modal .icon-close:hover { color: var(--slate-700); }

/* ---- Command palette ---- */
.cmdk-backdrop { position: fixed; inset: 0; z-index: 1100; background: rgba(15,23,42,.45); display: flex; justify-content: center; align-items: flex-start; padding: 14vh 16px 16px; }
.cmdk { width: 100%; max-width: 620px; background: var(--surface); border-radius: 14px; box-shadow: 0 30px 80px -20px rgba(0,0,0,.5); overflow: hidden; display: flex; flex-direction: column; max-height: 60vh; }
.cmdk-input { border: 0; border-bottom: 1px solid var(--slate-200); padding: 16px 18px; font-size: 1rem; outline: none; }
.cmdk-results { overflow: auto; padding: 6px; }
.cmdk-group-title { padding: 8px 12px 4px; font-size: .68rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--slate-400); }
.cmdk-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; cursor: pointer; }
.cmdk-item .ci-ico { width: 18px; text-align: center; opacity: .7; }
.cmdk-item .ci-sub { margin-left: auto; font-size: .78rem; color: var(--slate-400); }
.cmdk-item.active, .cmdk-item:hover { background: var(--slate-100); }
.cmdk-empty { padding: 24px; text-align: center; color: var(--slate-400); }
.cmdk-foot { border-top: 1px solid var(--slate-200); padding: 8px 14px; font-size: .74rem; color: var(--slate-400); display: flex; gap: 14px; }
kbd { font-family: inherit; font-size: .72rem; background: var(--slate-100); border: 1px solid var(--slate-200); border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px; color: var(--slate-600); }
.cmdk-trigger { display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--slate-200); background: var(--slate-50); color: var(--slate-500); cursor: pointer; font-size: .82rem; }
.cmdk-trigger:hover { border-color: var(--slate-300); color: var(--slate-700); }

/* ---- Bulk action bar ---- */
.bulk-bar { display: flex; align-items: center; gap: 12px; padding: 10px 14px; margin-bottom: 12px; border-radius: 10px; background: var(--accent-bar); color: #fff; animation: toast-in .15s ease-out; }
.bulk-bar .bulk-count { font-weight: 700; }
.bulk-bar .spacer { margin-left: auto; }
.bulk-bar .btn-ghost { color: #fff; border-color: rgba(255,255,255,.4); }
.bulk-bar .btn-ghost:hover { border-color: #fff; background: rgba(255,255,255,.08); }
td.sel-cell, th.sel-cell { width: 34px; text-align: center; }

/* ---- Notification bell ---- */
.bell { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--slate-200); background: var(--slate-50); cursor: pointer; color: var(--slate-600); }
.bell:hover { border-color: var(--slate-300); color: var(--slate-800); }
.bell .badge { position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 999px; background: var(--bad); color: #fff; font-size: .68rem; font-weight: 700; display: grid; place-items: center; }
.bell-panel { position: absolute; top: 46px; right: 0; width: 360px; max-width: calc(100vw - 24px); max-height: 70vh; overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 24px 60px -18px rgba(15,23,42,.4); z-index: 60; }
.bell-panel header { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--slate-100); font-weight: 700; color: var(--navy-900); }
.bell-item { display: block; padding: 10px 14px; border-bottom: 1px solid var(--slate-100); }
.bell-item:hover { background: var(--slate-50); text-decoration: none; }
.bell-item .bi-title { font-weight: 600; color: var(--navy-900); font-size: .88rem; }
.bell-item .bi-meta { font-size: .76rem; color: var(--slate-500); margin-top: 2px; }
.bell-empty { padding: 22px; text-align: center; color: var(--slate-400); }
.topbar-wrap { position: relative; }

/* ---- Theme / preferences ---- */
.theme-toggle { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--slate-200); background: var(--slate-50); cursor: pointer; color: var(--slate-600); font-size: 1rem; }
.theme-toggle:hover { border-color: var(--slate-300); color: var(--slate-800); }
.pref-grid { display: grid; gap: 16px; max-width: 520px; }
.pref-row { display: grid; gap: 6px; }
.pref-row label { font-weight: 600; color: var(--navy-900); font-size: .9rem; }

/* Compact density */
body.density-compact table.data th, body.density-compact table.data td { padding-top: 6px; padding-bottom: 6px; }
body.density-compact .kpi-card { padding: 12px 14px; }
body.density-compact .card { padding: 14px; }

/* Saved views chips */
.view-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 10px; }
.view-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--slate-200); background: var(--slate-50); font-size: .8rem; cursor: pointer; }
.view-chip:hover { border-color: var(--slate-300); }
.view-chip.active { background: var(--accent-bar); color: #fff; border-color: var(--accent-bar); }
.view-chip .x { opacity: .6; } .view-chip .x:hover { opacity: 1; }

/* ===================================================================== */
/* Dark theme                                                             */
/* ===================================================================== */
[data-theme="dark"] {
    /* Text/neutral ramp (lighter as numbers go up, inverted for dark) */
    --slate-700:#cbd5e1; --slate-600:#b4c0d0; --slate-500:#94a3b8; --slate-400:#7c8aa0;
    --slate-300:#3a475c; --slate-200:#2a3548; --slate-100:#1e2939; --slate-50:#172033;
    --white:#0f1827; --navy-900:#e8eef7; --navy-800:#dbe5f2; --accent-strong:#60a5fa;
    --shadow-sm:0 1px 2px rgba(0,0,0,.4);

    /* Surfaces remap once — every panel/card/table/modal follows automatically. */
    --surface:#141d2e;
    --surface-2:#1a2335;
    --border:#2a3548;
    /* --accent-bar / --sidebar-* intentionally NOT remapped: they stay dark in both themes. */
}
[data-theme="dark"] body { background: #0b1220; color: var(--slate-700); }
[data-theme="dark"] .content { background: #0b1220; }
[data-theme="dark"] .mobile-menu-btn { background: var(--surface-2); border-color: var(--slate-300); }
[data-theme="dark"] .mobile-menu-btn span { background: var(--navy-900); }
[data-theme="dark"] .health-pill,
[data-theme="dark"] .cmdk-trigger,
[data-theme="dark"] .bell,
[data-theme="dark"] .theme-toggle { background: var(--surface-2); }
[data-theme="dark"] .input, [data-theme="dark"] select, [data-theme="dark"] textarea { background: #0f1827; color: var(--slate-700); border-color: var(--slate-300); }
[data-theme="dark"] .auth-card { background: var(--surface); border: 1px solid var(--border); box-shadow: 0 30px 60px -20px rgba(0,0,0,.7); }
[data-theme="dark"] table.data tr.clickable-row:hover td { background: var(--surface-2); }
[data-theme="dark"] a { color: var(--accent-strong); }

/* Semantic (status) tints — dark variants so pastel boxes aren't bright islands. */
[data-theme="dark"] .notice.error,
[data-theme="dark"] .banner-error,
[data-theme="dark"] .callout.danger,
[data-theme="dark"] .badge.bad,
[data-theme="dark"] .badge.sev-high { background: #3a1416; color: #fecaca; border-color: #7f2227; }
[data-theme="dark"] .notice.success, [data-theme="dark"] .notice.ok,
[data-theme="dark"] .callout.ok,
[data-theme="dark"] .badge.ok, [data-theme="dark"] .badge.badge-ok, [data-theme="dark"] .badge.sev-low { background: #0f2c22; color: #a7f3d0; border-color: #1f5e48; }
[data-theme="dark"] .notice.warn,
[data-theme="dark"] .banner-warn,
[data-theme="dark"] .badge.warn, [data-theme="dark"] .badge.badge-warn, [data-theme="dark"] .badge.sev-medium { background: #34260a; color: #fde68a; border-color: #6b4f12; }
[data-theme="dark"] .badge.sev-info, [data-theme="dark"] .jurisdiction-editor .chip-on { background: #14233f; color: #bfdbfe; border-color: #2c4a78; }
[data-theme="dark"] .health-pill.warn,
[data-theme="dark"] .queue-item.warn,
[data-theme="dark"] table.data tr.row-warn { background: #34260a; border-color: #6b4f12; }
[data-theme="dark"] table.data tr.row-warn:hover { background: #44320e; }
[data-theme="dark"] .health-pill.bad,
[data-theme="dark"] .queue-item.danger { background: #3a1416; border-color: #7f2227; }

/* ===================================================================== */
/* Risk gauge (speedometer) + risk standing                              */
/* ===================================================================== */
.risk-standing { display: grid; grid-template-columns: minmax(180px, 240px) 1fr; gap: 18px; align-items: center; }
.risk-gauge { max-width: 240px; }
.risk-gauge svg { width: 100%; height: auto; display: block; }
.risk-gauge .rg-value { font-size: 40px; font-weight: 800; font-family: 'Inter', system-ui, sans-serif; }
.risk-gauge .rg-cap { font-size: 11px; fill: var(--slate-500); text-transform: uppercase; letter-spacing: .08em; }
.risk-gauge .rg-bands { display: flex; justify-content: space-between; font-size: .68rem; color: var(--slate-400); margin-top: -6px; padding: 0 6px; }
.risk-detail .risk-bench { margin: 0 0 10px; font-size: 1.05rem; color: var(--navy-900); }
.risk-detail .risk-bench strong { color: var(--good); }
.risk-bars { display: grid; gap: 8px; margin: 10px 0; }
.risk-bars > div { display: grid; grid-template-columns: 110px 1fr 34px; gap: 8px; align-items: center; font-size: .82rem; }
.risk-bars span { color: var(--slate-500); }
.risk-bars em { font-style: normal; font-variant-numeric: tabular-nums; text-align: right; color: var(--navy-900); font-weight: 600; }
.rb-track { height: 8px; border-radius: 999px; background: var(--slate-200); overflow: hidden; }
.rb-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--accent-strong)); }
@media (max-width: 560px) { .risk-standing { grid-template-columns: 1fr; } .risk-gauge { margin: 0 auto; } }

/* ---- Platform load (admin diagnostics) ---- */
.txt-accent { color: var(--accent-bar); }
.txt-bad { color: var(--bad); }
[data-theme="dark"] .txt-accent { color: var(--accent); }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg-btn { padding: 6px 12px; background: var(--surface); color: var(--slate-500); border: none; border-right: 1px solid var(--border); cursor: pointer; font-size: .85rem; }
.seg-btn:last-child { border-right: none; }
.seg-btn.active { background: var(--accent-bar); color: #fff; }
.seg-btn:disabled { opacity: .6; cursor: default; }
.spark { width: 100%; height: 220px; display: block; }
.spark-axis { display: flex; justify-content: space-between; font-size: .72rem; color: var(--slate-400); margin-top: 4px; }
.heatmap { display: grid; gap: 3px; }
.heat-row { display: grid; grid-template-columns: 38px repeat(24, 1fr); gap: 2px; align-items: center; }
.heat-head .heat-htick { font-size: .62rem; color: var(--slate-400); text-align: left; }
.heat-label { font-size: .68rem; color: var(--slate-500); }
.heat-cell { height: 16px; border-radius: 3px; background: var(--surface-2); }
.mix-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--slate-400); margin: 14px 0 6px; }
.load-mix { display: grid; gap: 6px; }
.mix-row { display: grid; grid-template-columns: 120px 1fr 48px; gap: 8px; align-items: center; font-size: .82rem; }
.mix-label { color: var(--slate-600); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mix-track { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.mix-fill { display: block; height: 100%; border-radius: 999px; background: var(--accent-bar); }
.mix-val { text-align: right; font-variant-numeric: tabular-nums; color: var(--slate-500); }
.hint-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; margin: 10px 0; }
.hint-grid > div { display: flex; flex-direction: column; gap: 2px; }
.hint-grid strong { font-size: 1.05rem; color: var(--navy-900); }
.panel-warn { border-left: 3px solid var(--warn); background: color-mix(in srgb, var(--warn) 8%, transparent); border-radius: 0 8px 8px 0; padding: 12px 14px; color: var(--navy-900); }
.panel-warn :last-child { margin-bottom: 0; }
[data-theme="dark"] .hint-grid strong { color: var(--text); }

/* ---- Onboarding funnel ---- */
.funnel { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.funnel-step { display: flex; flex-direction: column; gap: 4px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.funnel-count { font-size: 1.6rem; font-weight: 800; color: var(--navy-900); }
[data-theme="dark"] .funnel-count { color: var(--text); }
.funnel-label { font-size: .78rem; color: var(--slate-500); text-transform: uppercase; letter-spacing: .05em; }
.funnel-bar { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-top: 2px; }
.funnel-fill { display: block; height: 100%; border-radius: 999px; background: var(--accent-bar); }

/* ---- Notifications admin ---- */
.page-actions .spacer { margin-left: auto; }
label.chk { display: inline-flex; flex-direction: row; align-items: center; gap: 8px; font-weight: 600; color: var(--slate-700); }
label.chk input { width: 15px; height: 15px; margin: 0; }
[data-theme="dark"] label.chk { color: var(--text); }
.report-card { border: 1px solid var(--slate-200); border-radius: 10px; padding: 12px 14px; margin-top: 10px; background: var(--surface); }
[data-theme="dark"] .report-card { border-color: var(--border); }
.report-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.recipients { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.recipients .chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border: 1px solid var(--slate-200); border-radius: 999px; background: var(--surface-2); font-size: .8rem; color: var(--slate-700); }
[data-theme="dark"] .recipients .chip { border-color: var(--border); color: var(--text); }
.chip-x { border: none; background: none; cursor: pointer; font-size: 1rem; line-height: 1; color: var(--slate-500); padding: 0; }
.chip-x:hover { color: var(--bad); }
.pref-flags { display: flex; flex-wrap: wrap; gap: 12px 18px; margin: 12px 0; padding: 10px 12px; border: 1px solid var(--slate-200); border-radius: 10px; background: var(--surface-2); }
[data-theme="dark"] .pref-flags { border-color: var(--border); }
.bulk-operator-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px; }
.bulk-operator-grid .chip { display: inline-flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--slate-200); border-radius: 10px; background: var(--surface-2); color: var(--slate-700); }
[data-theme="dark"] .bulk-operator-grid .chip { border-color: var(--border); color: var(--text); }
.ops-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; margin-top: 16px; }
.ops-slices { display: grid; gap: 8px; }
.ops-slice { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 10px; border: 1px solid var(--slate-200); border-radius: 10px; background: var(--surface-2); }
[data-theme="dark"] .ops-slice { border-color: var(--border); }

/* ---- Shared page polish ---- */
.block-gap { margin-top: 16px; }
.back-link-row { margin-bottom: 12px; }
.inline-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.product-badges { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.pre-wrap { white-space: pre-wrap; }
.modal-header-split { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.modal-header-split.center { align-items: center; }
.modal-title-plain { margin: 0; }
.compact-list { margin: 6px 0 0 18px; }
.auto-left { margin-right: auto; }
.scope-block .scope-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: .5rem; }
@media (max-width: 720px) { .scope-block .scope-grid { grid-template-columns: 1fr; } }
.scope-col { border: 1px solid var(--border); border-radius: 8px; padding: .6rem .7rem; background: var(--surface-2); }
.scope-col-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: .4rem; }
.scope-list { max-height: 220px; overflow-y: auto; margin-top: .5rem; display: flex; flex-direction: column; gap: .15rem; }
.scope-item { display: flex; align-items: center; gap: .5rem; padding: .2rem .25rem; border-radius: 6px; cursor: pointer; }
.scope-item:hover { background: color-mix(in srgb, var(--surface-2) 70%, var(--accent) 8%); }
.scope-item input { margin: 0; }
.scope-radio { display: flex; align-items: center; gap: .5rem; margin: .25rem 0; cursor: pointer; }
.input.small { padding: .3rem .5rem; font-size: .85rem; }
.notice.small { padding: .4rem .6rem; font-size: .85rem; margin: .25rem 0 .5rem; }
.user-scope-summary { display: block; margin-top: .15rem; }
.checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.checklist li { display: flex; align-items: baseline; gap: 8px; font-size: .9rem; color: var(--slate-700); }
.checklist li:first-child { margin-top: 2px; }
[data-theme="dark"] .checklist li { color: var(--text); }

/* ===== Market scan ===== */
/* KPI accent tones (reusable) */
.kpi-card.tone-bad { border-left: 3px solid var(--bad); }
.kpi-card.tone-warn { border-left: 3px solid var(--warn); }
.kpi-card.tone-good { border-left: 3px solid var(--good); }
.kpi-card.tone-accent { border-left: 3px solid var(--accent); }
.kpi-card strong.bad { color: var(--bad); }
.kpi-card strong.good { color: var(--good); }

/* Scan bar (jurisdiction picker + run) */
.ms-scanbar { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.ms-scanbar .field { margin: 0; min-width: 240px; flex: 1 1 240px; }
.ms-scanbar .btn { flex: 0 0 auto; }
@media (max-width: 560px) { .ms-scanbar .btn { flex: 1 1 auto; } }

/* Calibration / chip rows */
.ms-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; }

/* High-possibility table row tint */
table.data tbody tr.ms-flagged td { background: #fef2f2; }
table.data tbody tr.ms-flagged:hover td { background: #fee2e2; }
[data-theme="dark"] table.data tbody tr.ms-flagged td { background: #3a1416; }

/* Lead detail */
.ms-detail { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.ms-kv { display: grid; gap: 2px; margin: 0; }
.ms-kv > div { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--slate-100); }
.ms-kv dt { color: var(--slate-500); font-size: .82rem; }
.ms-kv dd { margin: 0; font-weight: 600; color: var(--navy-900); text-align: right; word-break: break-word; }
.ms-why { margin: 0; }
.ms-why p { margin: 4px 0 12px; }
.ms-evidence { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 8px; }
.ms-evidence li { padding: 10px 12px; border: 1px solid var(--slate-200); border-radius: 8px; background: var(--slate-50); }
.ms-evidence a { font-weight: 600; word-break: break-word; }
.ms-evidence .src { display: block; margin-top: 4px; }
.ms-ev-chips { display: flex; flex-wrap: wrap; gap: 5px; margin: 6px 0 2px; }
.ms-section-label { color: var(--slate-500); font-size: .74rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; margin: 16px 0 6px; }

/* Confidence-basis factor list */
.ms-factors { list-style: none; margin: 4px 0 4px; padding: 0; display: grid; gap: 6px; }
.ms-factors li { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 7px 10px; border: 1px solid var(--slate-200); border-radius: 8px; background: var(--slate-50); }
.ms-factors .ms-factor-k { color: var(--slate-500); font-size: .82rem; flex: 0 0 auto; }
.ms-factors li > span:last-child { text-align: right; word-break: break-word; }

/* Expandable captured page text / raw JSON */
.ms-captured { margin-top: 6px; }
.ms-captured > summary { color: var(--accent-strong); font-size: .82rem; cursor: pointer; user-select: none; }
.ms-captured > summary:hover { text-decoration: underline; }
.ms-captured-text { margin: 8px 0 0; max-height: 260px; overflow: auto; padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; font-size: .78rem; line-height: 1.5; white-space: pre-wrap; word-break: break-word; color: var(--slate-700); }

/* "More details" expander */
.ms-more { margin-top: 16px; border-top: 1px dashed var(--slate-200); padding-top: 6px; }
.ms-more > summary { color: var(--slate-500); font-size: .74rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; cursor: pointer; user-select: none; padding: 8px 0; }
.ms-more > summary:hover { color: var(--navy-900); }
.ms-more code { font-size: .78rem; word-break: break-all; }
@media (max-width: 680px) {
    .ms-detail { grid-template-columns: 1fr; gap: 10px; }
    .modal-foot { flex-wrap: wrap; }
    .modal-foot .btn { flex: 1 1 auto; }
}

/* KPI cards used as triage filters */
button.kpi-card { text-align: left; width: 100%; font: inherit; color: inherit; cursor: pointer; transition: border-color .12s, box-shadow .12s; }
button.kpi-card:hover { border-color: var(--accent); }
button.kpi-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.kpi-card.is-active { border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }

/* Review drawer (master-detail triage) */
.ms-drawer-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 90; border: 0; padding: 0; cursor: pointer; }
.ms-drawer { position: fixed; top: 0; right: 0; height: 100dvh; width: min(580px, 100vw); background: var(--surface); box-shadow: -20px 0 48px rgba(0,0,0,.28); z-index: 91; display: flex; flex-direction: column; outline: none; }
.ms-drawer-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.ms-drawer-head h2 { margin: 0 0 4px; font-size: 1.1rem; color: var(--navy-900); }
.ms-drawer-title { min-width: 0; }
.ms-drawer-title .muted { word-break: break-word; }
.ms-drawer-nav { display: flex; gap: 4px; align-items: center; flex: 0 0 auto; }
.ms-drawer-nav .btn { padding: 6px 10px; }
.ms-drawer-body { padding: 16px 20px; overflow-y: auto; flex: 1 1 auto; }
.ms-drawer-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; flex-wrap: wrap; }
.ms-drawer-foot .btn { flex: 1 1 auto; }
@media (max-width: 640px) { .ms-drawer { width: 100vw; } }
.ms-drawer .ms-detail { grid-template-columns: 1fr; gap: 10px; }

/* Drawer severity stripe + keyboard hint */
.ms-drawer.sev-bad { border-left: 4px solid var(--bad); }
.ms-drawer.sev-warn { border-left: 4px solid var(--warn); }
.ms-drawer.sev-ok { border-left: 4px solid var(--good); }
.ms-drawer-hint { color: var(--slate-500); font-size: .76rem; margin: 14px 0 0; padding-top: 10px; border-top: 1px dashed var(--slate-200); }
.ms-drawer-hint kbd { font: inherit; font-size: .72rem; background: var(--slate-100); border: 1px solid var(--slate-300); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; color: var(--navy-900); }

/* Config summary chips (settings) */
.ms-config-summary { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 2px 0 14px; }
/* Provider list + add/edit modal */
.ms-col-actions { white-space: nowrap; text-align: right; }
.ms-modal-toggles { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 12px; }
/* Queue: separate the scan-bar card from the KPI filters below it */
.ms-kpi { margin-top: 16px; }
/* "Scan in progress" banner (shown to anyone viewing the queue while a scan runs) */
.ms-active-scans { border-left: 3px solid var(--accent); }
.ms-active-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.ms-active-run { margin-top: 10px; }
.ms-active-label { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; margin-bottom: 4px; }
.ms-spinner { width: 14px; height: 14px; border: 2px solid var(--slate-300); border-top-color: var(--accent); border-radius: 50%; display: inline-block; animation: ms-spin .8s linear infinite; }
@keyframes ms-spin { to { transform: rotate(360deg); } }
/* Live scan progress bar */
.ms-progress { height: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; margin-top: 12px; }
.ms-progress-bar { height: 100%; background: var(--accent); transition: width .4s ease; min-width: 2%; }
/* Last-scan "search terms used" expander */
.ms-run-terms { margin-top: 6px; }
.ms-run-terms > summary { cursor: pointer; color: var(--slate-600); }
.ms-run-terms > div { margin-top: 4px; padding: 8px 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; font-size: .82rem; color: var(--slate-700); word-break: break-word; }
.ms-run-note { font-size: .82rem; color: var(--slate-600); max-width: 38ch; }
/* Provider modal form: 2-column rows (Name / Type+Model / API key / Base URL) */
.form-grid.ms-form-2col { grid-template-columns: 1fr 1fr; }
