/* =========================================================
   THEME.CSS — JorproA, rebuilt from scratch
   Modern SaaS / Neo-minimal design system.
   Single indigo accent, neutral gray-white surfaces, sidebar
   app shell, clean data tables. Replaces the old style.css
   (still on disk, no longer linked) on every live page.

   DARK MODE: this file is light-mode-first. Every token below
   is re-declared for dark under [data-theme="dark"] at the very
   end of the file (kept there, not inline here, so it always
   wins the cascade regardless of where else a var is declared).
   Theme is chosen by theme-boot.js (sets data-theme on <html>
   before first paint) and switched by theme-toggle.js. Always
   consume colors via var(--x) in new rules — a literal hex/rgba
   here silently breaks dark mode.
   ========================================================= */

:root {
    color-scheme: light;

    /* Accent */
    --ac: #4F46E5;
    --ac-hover: #4338CA;
    --ac-tint: #EEF2FF;
    --ac-ring: rgba(79, 70, 229, 0.18);
    --ac-border: #C7D2FE;

    /* Neutrals */
    --ink: #0F172A;
    --body: #475569;
    --muted: #94A3B8;
    --border: #E2E8F0;
    --border-soft: #EDF1F7;
    --canvas: #F8FAFC;
    --surface: #FFFFFF;

    /* Text/icon color that sits on top of a solid --ac fill (buttons,
       active dots) — stays white in both themes, kept as a token so
       nothing has to hardcode #fff. */
    --on-accent: #FFFFFF;

    /* Status */
    --low: #059669;
    --low-tint: #ECFDF5;
    --low-border: #A7F3D0;
    --medium: #D97706;
    --medium-tint: #FFFBEB;
    --medium-border: #FDE68A;
    --high: #EA580C;
    --high-tint: #FFF7ED;
    --high-border: #FED7AA;
    --special: #E11D48;
    --special-tint: #FFF1F2;
    --special-tint-strong: #FFE4E8;
    --special-border: #FECDD3;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 6px 16px -4px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 16px 40px -12px rgba(15, 23, 42, 0.16);
}

* { box-sizing: border-box; }

/* Utility relied on by existing page JS (classList.add/remove/toggle
   ("hidden")) across the reused business-logic files — kept as a tiny,
   framework-free utility now that Tailwind's CDN utilities are gone. */
.hidden { display: none !important; }

html {
    scroll-behavior: smooth;
    /* Explicit (not left to propagate from body) so the UA never
       hoists body's scrolling fade-to-canvas gradient onto the
       canvas itself — see the note on html::before below for why
       that distinction matters here. */
    background: var(--canvas);
}

/* =========================================================
   APP SKY — a single, site-wide fixed sky+cloud backdrop.
   Pure CSS (no image asset), painted once via html::before so
   every page that loads this stylesheet gets it automatically —
   nothing to add per-page, nothing to duplicate.

   Uses a real `position: fixed` box (the ::before), not
   `background-attachment: fixed`, which is unreliable on iOS
   Safari. It sits at z-index -1, behind the normal document
   flow, so it never needs special z-index handling from content
   above it (see the body rule below for how the fade to canvas
   works as you scroll).
   ========================================================= */

html::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
        radial-gradient(ellipse 460px 160px at 6% 8%, rgba(255, 255, 255, 0.90), transparent 70%),
        radial-gradient(ellipse 360px 130px at 84% 14%, rgba(255, 255, 255, 0.75), transparent 70%),
        radial-gradient(ellipse 420px 150px at 30% 27%, rgba(255, 255, 255, 0.55), transparent 72%),
        radial-gradient(ellipse 380px 140px at 66% 35%, rgba(255, 255, 255, 0.40), transparent 72%),
        linear-gradient(180deg, #DCEBFF 0%, #EAF3FF 30%, #F4F8FE 55%, var(--canvas) 80%);
    transition: background 0.2s ease;
}

html[data-theme="dark"]::before {
    /* Night sky — same blob layout, dimmed to a haze instead of
       solid clouds. No stars/moon by design; this is a working
       app, not a landing-page flourish. */
    background:
        radial-gradient(ellipse 460px 160px at 6% 8%, rgba(255, 255, 255, 0.07), transparent 70%),
        radial-gradient(ellipse 360px 130px at 84% 14%, rgba(255, 255, 255, 0.05), transparent 70%),
        radial-gradient(ellipse 420px 150px at 30% 27%, rgba(255, 255, 255, 0.04), transparent 72%),
        radial-gradient(ellipse 380px 140px at 66% 35%, rgba(255, 255, 255, 0.03), transparent 72%),
        linear-gradient(180deg, #0B1220 0%, #10203A 35%, #16294A 60%, var(--canvas) 85%);
}

@media (max-width: 640px) {
    /* Keep the visible sky/cloud band to roughly the top 40% of a
       phone screen instead of the ~80% used on desktop. */
    html::before {
        background:
            radial-gradient(ellipse 220px 90px at 8% 6%, rgba(255, 255, 255, 0.85), transparent 70%),
            radial-gradient(ellipse 180px 75px at 80% 12%, rgba(255, 255, 255, 0.65), transparent 70%),
            linear-gradient(180deg, #DCEBFF 0%, #EAF3FF 22%, var(--canvas) 42%);
    }
    html[data-theme="dark"]::before {
        background:
            radial-gradient(ellipse 220px 90px at 8% 6%, rgba(255, 255, 255, 0.06), transparent 70%),
            radial-gradient(ellipse 180px 75px at 80% 12%, rgba(255, 255, 255, 0.04), transparent 70%),
            linear-gradient(180deg, #0B1220 0%, #10203A 24%, var(--canvas) 42%);
    }
}

body {
    margin: 0;
    /* Transparent at the top (so html::before's fixed sky shows
       through), settling into the flat --canvas fill by ~1 screen
       down, so long pages read exactly as before once scrolled
       past the hero band. */
    background: linear-gradient(180deg, transparent 0, transparent 55vh, var(--canvas) 100vh);
    color: var(--ink);
    font-family: "Plus Jakarta Sans", "Noto Sans Thai", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.2s ease, color 0.2s ease;
}

@media (max-width: 640px) {
    body { background: linear-gradient(180deg, transparent 0, transparent 20vh, var(--canvas) 42vh); }
}

h1, h2, h3, h4 { font-family: "Plus Jakarta Sans", "Noto Sans Thai", Arial, sans-serif; }

::selection { background: var(--ac-tint); color: var(--ac-hover); }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { border-radius: 999px; background: var(--border); }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

button, input, textarea, select { font-family: inherit; }
button { cursor: pointer; }

a { color: var(--ac); }

button:focus-visible, a:focus-visible, input:focus-visible,
textarea:focus-visible, select:focus-visible {
    outline: 2px solid var(--ac);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}


/* =========================================================
   APP SHELL — fixed sidebar (desktop) + slim topbar + drawer
   ========================================================= */

.app-shell {
    min-height: 100vh;
    display: flex;
}

.sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 248px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px 14px;
    /* Above the mobile drawer scrim and the sticky bottom action bar —
       when the drawer is open on a form page it must sit on top of
       .ui-sticky-actions (also fixed to the bottom), not underneath it,
       or the "switch role" pill becomes unclickable. */
    z-index: 50;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px 20px;
}

.sidebar-brand-mark {
    width: 34px; height: 34px;
    border-radius: 10px;
    overflow: hidden;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}

.sidebar-brand-name { font-weight: 800; font-size: 15px; color: var(--ink); line-height: 1.1; }
.sidebar-brand-sub { font-size: 10.5px; color: var(--muted); margin-top: 1px; }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.sidebar-section-label {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--muted);
    padding: 14px 10px 6px;
}

.sidebar-nav-link {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 10px;
    border-radius: var(--radius-sm);
    color: var(--body);
    font-size: 13.5px;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.sidebar-nav-link svg { flex-shrink: 0; color: var(--muted); transition: color 0.15s ease; }

.sidebar-nav-link:hover { background: var(--canvas); color: var(--ink); }
.sidebar-nav-link:hover svg { color: var(--body); }

.sidebar-nav-link.active { background: var(--ac-tint); color: var(--ac-hover); }
.sidebar-nav-link.active svg { color: var(--ac); }

/* New-result notification count — rendered by shell.js next to "Analysis
   Result" for Safety Officer whenever Expert has completed analyses SO
   hasn't opened yet (Shell.getPendingSoReviewRecords()). */
.sidebar-nav-badge {
    margin-left: auto;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--special);
    color: var(--on-accent);
    font-size: 10.5px;
    font-weight: 800;
    line-height: 18px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-footer {
    border-top: 1px solid var(--border-soft);
    padding-top: 12px;
    margin-top: 8px;
}

.sidebar-role-pill {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    background: var(--canvas);
    border: 1px solid var(--border-soft);
    font-size: 11.5px;
    font-weight: 700;
    color: var(--body);
}

.sidebar-role-dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--low);
    box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.14);
    flex-shrink: 0;
}

.main-area {
    flex: 1;
    margin-left: 248px;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 14px;
    height: 60px;
    padding: 0 20px;
    background: rgba(248, 250, 252, 0.85);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}

[data-theme="dark"] .topbar { background: rgba(11, 18, 32, 0.82); }

.topbar-menu-btn {
    display: none;
    width: 36px; height: 36px;
    align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--body);
    flex-shrink: 0;
}

.topbar-title {
    font-weight: 800;
    font-size: 14px;
    color: var(--ink);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

/* Back / Home — shown on every shell page, desktop and mobile alike
   (unlike .topbar-menu-btn, which is mobile-only). */
.topbar-nav-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.topbar-icon-btn {
    display: inline-flex;
    width: 36px; height: 36px;
    align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--body);
    flex-shrink: 0;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.topbar-icon-btn:hover { color: var(--ac); border-color: var(--ac-border); background: var(--ac-tint); }
.topbar-icon-btn:active { transform: translateY(1px); }
.topbar-icon-btn:focus-visible { outline: 2px solid var(--ac); outline-offset: 2px; }

.main-content {
    flex: 1;
    padding: 24px 28px 48px;
    max-width: 1180px;
    width: 100%;
    margin: 0 auto;
}

/* Mobile drawer nav (reuses the sidebar markup, slid in from the left) */
.drawer-scrim {
    display: none;
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 39;
}

.drawer-scrim.open { display: block; }

@media (max-width: 960px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
        box-shadow: var(--shadow-lg);
    }
    .sidebar.open { transform: translateX(0); }
    .main-area { margin-left: 0; }
    .topbar-menu-btn { display: inline-flex; }
    .main-content { padding: 18px 16px 40px; }
}


/* =========================================================
   CARDS / SURFACES
   ========================================================= */

.ui-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.ui-card-pad { padding: 22px; }

@media (min-width: 768px) {
    .ui-card-pad { padding: 28px; }
}

.ui-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-soft);
}

.ui-eyebrow {
    display: block;
    font-size: 10.5px;
    font-weight: 800;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--ac);
    margin-bottom: 4px;
}

.ui-h1 { font-size: 24px; font-weight: 800; color: var(--ink); letter-spacing: -0.01em; }
.ui-h2 { font-size: 18px; font-weight: 800; color: var(--ink); }
.ui-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }


/* =========================================================
   BUTTONS
   ========================================================= */

.ui-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 40px;
    padding: 0 16px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.ui-btn:active { transform: scale(0.98); }

.ui-btn-primary { background: var(--ac); color: var(--on-accent); }
.ui-btn-primary:hover { background: var(--ac-hover); }

.ui-btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--border); }
.ui-btn-secondary:hover { background: var(--canvas); border-color: var(--muted); }

.ui-btn-ghost { background: transparent; color: var(--body); }
.ui-btn-ghost:hover { background: var(--canvas); color: var(--ink); }

.ui-btn-danger { background: var(--special-tint); color: var(--special); border-color: var(--special-border); }
.ui-btn-danger:hover { background: var(--special-tint-strong); }

.ui-btn-sm { height: 32px; padding: 0 12px; font-size: 12px; }
.ui-btn-block { width: 100%; }


/* =========================================================
   FORM FIELDS
   ========================================================= */

.ui-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; }

.ui-label { font-size: 13px; font-weight: 700; color: var(--ink); }
.ui-label-sub { font-weight: 400; color: var(--muted); font-size: 12px; margin-left: 4px; }

.ui-help { font-size: 11.5px; color: var(--muted); }

.ui-input, .ui-textarea, .ui-select,
input[type="text"].ui-input, input[type="datetime-local"].ui-input {
    width: 100%;
    padding: 10px 13px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--ink);
    font-size: 13.5px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ui-textarea { resize: vertical; min-height: 100px; }

.ui-input:focus, .ui-textarea:focus, .ui-select:focus {
    outline: none;
    border-color: var(--ac);
    box-shadow: 0 0 0 3px var(--ac-ring);
}

.ui-input::placeholder, .ui-textarea::placeholder { color: var(--muted); }

.ui-note {
    display: flex;
    gap: 10px;
    padding: 13px 14px;
    border-radius: var(--radius-md);
    background: var(--ac-tint);
    border: 1px solid var(--ac-border);
    color: var(--ac-hover);
    font-size: 12px;
    line-height: 1.5;
}

/* Dashboard "new result from Expert" banner — safety-officer.html,
   populated by Shell.getPendingSoReviewRecords(). */
.ui-notify-banner {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 20px;
    margin-bottom: 20px;
    border-radius: var(--radius-lg);
    background: var(--ac-tint);
    border: 1px solid var(--ac-border);
}

.ui-notify-banner-icon {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--ac);
    color: var(--on-accent);
}

.ui-notify-banner-body { flex: 1; min-width: 0; }
.ui-notify-banner-title { font-size: 13.5px; font-weight: 800; color: var(--ink); }
.ui-notify-banner-sub {
    font-size: 12px;
    color: var(--body);
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ui-notify-banner .ui-btn { flex-shrink: 0; }

@media (max-width: 560px) {
    .ui-notify-banner { flex-wrap: wrap; }
    .ui-notify-banner-sub { white-space: normal; }
    .ui-notify-banner .ui-btn { width: 100%; }
}


/* =========================================================
   STAT TILES — dashboard KPI numbers
   ========================================================= */

.ui-stat-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

@media (min-width: 640px) {
    .ui-stat-row { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.ui-stat-tile {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
}

.ui-stat-label {
    font-size: 10.5px;
    font-weight: 800;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.ui-stat-value { font-size: 26px; font-weight: 800; color: var(--ink); margin-top: 6px; }


/* =========================================================
   STEPPER — slim top progress bar for multi-step flows
   ========================================================= */

.ui-stepper {
    display: flex;
    align-items: center;
    gap: 0;
}

.ui-step {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.ui-step-dot {
    width: 22px; height: 22px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 800;
    background: var(--canvas);
    color: var(--muted);
    border: 1px solid var(--border);
    flex-shrink: 0;
}

.ui-step.done .ui-step-dot { background: var(--ac); color: var(--on-accent); border-color: var(--ac); }
.ui-step.active .ui-step-dot { background: var(--ac-tint); color: var(--ac); border-color: var(--ac); }

.ui-step-label { font-size: 11.5px; font-weight: 700; color: var(--muted); white-space: nowrap; }
.ui-step.active .ui-step-label, .ui-step.done .ui-step-label { color: var(--ink); }

.ui-step-line { flex: 1; height: 2px; background: var(--border); margin: 0 8px; }
.ui-step.done + .ui-step-line-wrap .ui-step-line,
.ui-step-line.done { background: var(--ac); }


/* =========================================================
   STICKY ACTION BAR — bottom form actions on mobile
   ========================================================= */

.ui-sticky-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding-top: 18px;
    margin-top: 6px;
    border-top: 1px solid var(--border-soft);
}

@media (max-width: 640px) {
    .ui-sticky-actions {
        position: fixed;
        left: 0; right: 0; bottom: 0;
        z-index: 30;
        background: rgba(255, 255, 255, 0.92);
        backdrop-filter: blur(10px);
        border-top: 1px solid var(--border);
        padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
        margin: 0;
    }
    .ui-sticky-actions .ui-btn { flex: 1; }
    .ui-sticky-spacer { height: 78px; }

    [data-theme="dark"] .ui-sticky-actions { background: rgba(19, 27, 44, 0.92); }
}


/* =========================================================
   STATUS BADGES (reused by data-table.js / list rows / tables)
   ========================================================= */

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.3px;
    white-space: nowrap;
    text-transform: uppercase;
    border: 1px solid transparent;
}

/* Plain text-color utilities for status text that isn't a full
   badge/chip (e.g. a page's own custom "final status" line) — use
   these instead of inline style="color:#hex", which silently
   breaks dark mode. */
.text-risk-low { color: var(--low); }
.text-risk-medium { color: var(--medium); }
.text-risk-high { color: var(--high); }
.text-risk-special { color: var(--special); }

.status-badge-blue { background: var(--ac-tint); color: var(--ac-hover); }
.status-badge-amber { background: var(--medium-tint); color: var(--medium); border-color: var(--medium-border); }
.status-badge-green { background: var(--low-tint); color: var(--low); border-color: var(--low-border); }
.status-badge-red { background: var(--special-tint); color: var(--special); border-color: var(--special-border); }
.status-badge-slate { background: var(--canvas); color: var(--body); border-color: var(--border); }


/* =========================================================
   DATA TABLE — toolbar, table, mobile list-row collapse
   (rendered by data-table.js, logic untouched — skin only)
   ========================================================= */

.table-toolbar {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
}

.dt-search-wrap { position: relative; display: flex; align-items: center; }

.dt-search-icon { position: absolute; left: 13px; color: var(--muted); font-size: 13px; pointer-events: none; display: flex; }

.dt-search {
    width: 100%;
    padding: 10px 13px 10px 36px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--ink);
    font-size: 13px;
}

.dt-search:focus {
    outline: none;
    border-color: var(--ac);
    box-shadow: 0 0 0 3px var(--ac-ring);
}

.dt-filter-row { display: flex; flex-wrap: wrap; gap: 8px; }

.dt-filter-chip {
    padding: 6px 13px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--body);
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}

.dt-filter-chip.active { background: var(--ac); border-color: var(--ac); color: var(--on-accent); }

.data-table-desktop { display: none; }
.data-table-mobile { display: block; }

@media (min-width: 768px) {
    .data-table-desktop { display: block; }
    .data-table-mobile { display: none; }
}

.data-table-scroll {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

table.data-table { width: 100%; min-width: 640px; border-collapse: collapse; background: var(--surface); }

table.data-table thead th {
    position: sticky; top: 0; z-index: 1;
    background: var(--canvas);
    color: var(--muted);
    font-size: 10.5px;
    font-weight: 800;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    padding: 11px 16px;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

table.data-table tbody td {
    padding: 13px 16px;
    font-size: 12.5px;
    color: var(--body);
    border-bottom: 1px solid var(--border-soft);
    vertical-align: middle;
}

table.data-table tbody tr:last-child td { border-bottom: none; }
table.data-table tbody tr.dt-row:hover { background: var(--ac-tint); }

.dt-action-group { display: flex; justify-content: flex-end; gap: 6px; }
.dt-action-group-mobile { justify-content: flex-start; margin-top: 8px; }

.dt-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 11px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--ac);
    font-size: 10.5px;
    font-weight: 800;
    white-space: nowrap;
}

.dt-action-btn:hover { border-color: var(--ac); background: var(--ac-tint); }
.dt-action-btn-primary { background: var(--ac); border-color: var(--ac); color: var(--on-accent); }
.dt-action-btn-primary:hover { background: var(--ac-hover); }
.dt-action-btn-danger { color: var(--special); border-color: var(--special-border); }
.dt-action-btn-danger:hover { background: var(--special-tint); }
.dt-action-icon { display: inline-flex; }

.dt-list { display: flex; flex-direction: column; gap: 10px; }

.dt-empty {
    padding: 46px 20px;
    text-align: center;
    color: var(--muted);
    font-size: 13px;
    border: 1px dashed var(--border);
    border-radius: var(--radius-md);
    background: var(--canvas);
}

.dt-pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 16px;
}

.dt-pagination-info { font-size: 11.5px; color: var(--muted); }
.dt-pagination-controls { display: flex; align-items: center; gap: 10px; }

.dt-page-btn {
    padding: 7px 14px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--ac);
    font-size: 11px;
    font-weight: 800;
}

.dt-page-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.dt-page-indicator { font-size: 11.5px; font-weight: 700; color: var(--body); }


/* =========================================================
   LIST ROW — mobile collapse target for data-table.js
   ========================================================= */

.list-row {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 64px;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    background: var(--surface);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.list-row:hover { border-color: var(--ac); box-shadow: var(--shadow-sm); }
.list-row:active { transform: scale(0.995); }

.list-row-icon {
    width: 38px; height: 38px;
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    border-radius: 11px;
    background: var(--ac-tint);
    color: var(--ac);
    font-size: 15px;
}

.list-row-body { flex: 1; min-width: 0; }

.list-row-title-line { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.list-row-title {
    font-size: 13.5px; font-weight: 800; color: var(--ink);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.list-row-subtitle {
    margin-top: 2px; font-size: 12px; color: var(--muted);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.list-row-chevron { flex-shrink: 0; color: var(--muted); display: flex; }


/* =========================================================
   RISK MATRIX (FAA 5x5) — grid built by risk-assessment.js
   ========================================================= */

.risk-matrix { width: 100%; }

.matrix-cell {
    min-height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--body);
    font-size: 12px;
    font-weight: 700;
    text-align: center;
    transition: transform 0.12s ease, filter 0.12s ease;
}

.matrix-header { background: var(--canvas); color: var(--muted); font-weight: 800; font-size: 10.5px; }

.risk-low-cell { background: var(--low-tint); border-color: var(--low-border); color: var(--low); }
.risk-medium-cell { background: var(--medium-tint); border-color: var(--medium-border); color: var(--medium); }
.risk-high-cell { background: var(--high-tint); border-color: var(--high-border); color: var(--high); }
.risk-special-cell { background: var(--special-tint); border-color: var(--special-border); color: var(--special); }

.matrix-cell:not(.matrix-header):hover { transform: translateY(-1px); filter: brightness(0.97); }
[data-theme="dark"] .matrix-cell:not(.matrix-header):hover { filter: brightness(1.18); }

.selected-risk {
    outline: 2px solid var(--ac);
    outline-offset: 1px;
    box-shadow: 0 0 0 3px var(--ac-ring);
}

@media (max-width: 480px) {
    .matrix-cell { min-height: 38px; font-size: 10.5px; padding: 5px; }
}


/* =========================================================
   LANDING PAGE — role select
   Fully superseded by the jp-* prefixed styles inside
   index.html's own <style> block (see the comment there).
   Removed rather than left dead: same class names
   (.landing-logo, .role-grid, .role-card-icon, ...) used to
   silently collide with the jp- rules at equal specificity,
   which broke things like the logo's aspect-ratio the moment
   index.html stopped setting an explicit height.
   ========================================================= */


/* =========================================================
   THEME TOGGLE — sun/moon button, rendered by theme-toggle.js
   into the sidebar footer (shell pages) or the landing page.
   ========================================================= */

.theme-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--body);
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.theme-toggle-btn:hover { background: var(--canvas); color: var(--ink); border-color: var(--muted); }

.sidebar-footer-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-footer-row .sidebar-role-pill { flex: 1; min-width: 0; }

.landing-theme-toggle {
    position: absolute;
    top: 18px;
    right: 18px;
}


/* =========================================================
   SWEETALERT2 — theme overrides (hooks used by notify.js)
   ========================================================= */

.jorpro-swal-popup {
    border-radius: var(--radius-lg) !important;
    font-family: "Plus Jakarta Sans", "Noto Sans Thai", Arial, sans-serif !important;
}

.jorpro-swal-confirm, .jorpro-swal-cancel {
    border-radius: var(--radius-sm) !important;
    font-weight: 700 !important;
    font-size: 13px !important;
    padding: 10px 20px !important;
}

.jorpro-swal-toast {
    border-radius: var(--radius-md) !important;
    font-family: "Plus Jakarta Sans", "Noto Sans Thai", Arial, sans-serif !important;
    font-size: 12.5px !important;
}

[data-theme="dark"] .swal2-popup.jorpro-swal-popup {
    background: var(--surface);
    color: var(--ink);
}

[data-theme="dark"] .jorpro-swal-popup .swal2-html-container,
[data-theme="dark"] .jorpro-swal-popup #swal2-title { color: var(--ink); }

[data-theme="dark"] .jorpro-swal-toast.swal2-popup {
    background: var(--surface);
    color: var(--ink);
}


/* =========================================================
   DARK THEME — token overrides.
   Deliberately kept as the LAST rule in the file: every token
   this file defines lives in the :root block up top, so a plain
   [data-theme="dark"] block here (same specificity as :root,
   later in source order) is guaranteed to win the cascade for
   every var() consumer above, without touching a single
   component rule. Applied via the `data-theme` attribute that
   theme-boot.js sets on <html> before first paint, and flipped
   at runtime by theme-toggle.js.
   ========================================================= */

[data-theme="dark"] {
    color-scheme: dark;

    /* Accent — brightened so it still reads on dark surfaces */
    --ac: #818CF8;
    --ac-hover: #A5B4FC;
    --ac-tint: rgba(129, 140, 248, 0.16);
    --ac-ring: rgba(129, 140, 248, 0.30);
    --ac-border: rgba(129, 140, 248, 0.35);

    /* Neutrals — inverted ramp */
    --ink: #F1F5F9;
    --body: #CBD5E1;
    --muted: #64748B;
    --border: #293548;
    --border-soft: #1E293B;
    --canvas: #0B1220;
    --surface: #131B2C;

    /* Status — desaturated a touch, tints become low-alpha overlays
       instead of near-white pastels (which would look like solid
       light chips floating on a dark page). */
    --low: #34D399;
    --low-tint: rgba(52, 211, 153, 0.14);
    --low-border: rgba(52, 211, 153, 0.35);
    --medium: #FBBF24;
    --medium-tint: rgba(251, 191, 36, 0.14);
    --medium-border: rgba(251, 191, 36, 0.35);
    --high: #FB923C;
    --high-tint: rgba(251, 146, 60, 0.14);
    --high-border: rgba(251, 146, 60, 0.35);
    --special: #FB7185;
    --special-tint: rgba(251, 113, 133, 0.14);
    --special-tint-strong: rgba(251, 113, 133, 0.24);
    --special-border: rgba(251, 113, 133, 0.35);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 6px 16px -4px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 16px 40px -12px rgba(0, 0, 0, 0.65);
}
