/* === MdgUfcp PWA — design system === */

:root {
    --primary: #0f3460;
    --primary-light: #1a5276;
    --accent: #e94560;
    --success: #27ae60;
    --warning: #f39c12;
    --danger: #e74c3c;
    --info: #2563eb;
    --bg: #f5f6fa;
    --bg-dark: #1a1a2e;
    --card: #eef2f7;
    --card-bg: #ffffff;
    --bg-secondary: #eef2f7;
    --text: #2c3e50;
    --text-light: #7f8c8d;
    --text-muted: #6b7280;
    --surface-1: #eef2f7;
    --surface-2: #e2e8f0;
    --surface-grey: #f5f5f5;
    --surface-grey-fg: #6b7280;
    --surface-amber-bg: #fff3e0;
    --surface-amber-fg: #9c4221;
    --surface-red-bg: #ffebee;
    --surface-red-fg: #7f1d1d;
    --surface-yellow-bg: #fffbea;
    --surface-yellow-fg: #78350f;
    --surface-green-bg: #e8f5e9;
    --surface-green-fg: #14532d;
    --surface-blue-bg: #e0f2fe;
    --surface-blue-fg: #075985;
    --selection-bg: #dbeafe;
    --selection-fg: #1e3a8a;
    --selection-border: #60a5fa;
    --border: #dcdde1;
    --input-bg: #ffffff;
    --hover-bg: #e2e8f0;
    --radius: 8px;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
}
:root[data-theme="dark"] {
    color-scheme: dark;
    --primary: #60a5fa;
    --primary-light: #2563eb;
    --accent: #fb7185;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #f87171;
    --info: #38bdf8;
    --bg: #0f172a;
    --bg-dark: #020617;
    --card: #1e293b;
    --card-bg: #111827;
    --bg-secondary: #1e293b;
    --text: #e5e7eb;
    --text-light: #94a3b8;
    --text-muted: #94a3b8;
    --border: #334155;
    --surface-1: #1e293b;
    --surface-2: #0f172a;
    --surface-grey: #1e293b;
    --surface-grey-fg: #94a3b8;
    --surface-amber-bg: #422006;
    --surface-amber-fg: #fcd34d;
    --surface-red-bg: #450a0a;
    --surface-red-fg: #fca5a5;
    --surface-yellow-bg: #422006;
    --surface-yellow-fg: #fde047;
    --surface-green-bg: #14532d;
    --surface-green-fg: #bbf7d0;
    --surface-blue-bg: #0c4a6e;
    --surface-blue-fg: #bae6fd;
    --selection-bg: #1e3a8a;
    --selection-fg: #dbeafe;
    --selection-border: #60a5fa;
    --input-bg: #172033;
    --hover-bg: #1e293b;
    --shadow: 0 2px 10px rgba(0,0,0,0.35);
    --shadow-lg: 0 8px 28px rgba(0,0,0,0.45);
}

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

/* Form control baseline — used by AI Setup, decisions form, and any
   admin page that wraps inputs/selects with class="form-control". The
   class was referenced from JS but never defined here, so the browser
   was painting square-cornered defaults. 6px matches the chat
   dropdowns + the bumped setup-form inline styles, so an operator's
   eye doesn't retrain switching between Agent Governance, AI Setup
   and the persona chat dropdowns on the same screen. */
.form-control {
    font-family: inherit;
    font-size: 14px;
    color: var(--text, #2c3e50);
    background: var(--input-bg, #fff);
    border: 1px solid var(--border, #d1d5db);
    border-radius: 6px;
    padding: 6px 10px;
    line-height: 1.4;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary, #2563eb);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.18);
}
.form-control:disabled {
    background: #f3f4f6;
    color: var(--text-light, #7f8c8d);
    cursor: not-allowed;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 16px;
    line-height: 1.5;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
    transition: background-color 0.2s, color 0.2s;
}

.theme-toggle-mini {
    /* 2026-04-30: lives INSIDE the topbar as a real flex child immediately
       before #sync-indicator. margin-left: auto anchors it as the first
       element of the right-side cluster (toggle → sync dot → user → logout). */
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 24px;
    padding: 0 9px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    font: 700 11px/1 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    cursor: pointer;
}
.theme-toggle-mini:hover { background: rgba(255, 255, 255, 0.24); border-color: rgba(255, 255, 255, 0.7); }
.theme-toggle-mini-icon {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #fff;
    box-shadow: inset 3px 0 0 rgba(15, 23, 42, 0.35);
}
:root[data-theme="dark"] .theme-toggle-mini-icon {
    background: var(--warning);
    box-shadow: 0 0 9px rgba(245, 158, 11, 0.55);
}

/* ─── Login screen (WMS-aligned) ───────────────────────────── */
#loginView {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    min-height: 100vh;
    padding: clamp(2rem, 8vh, 6rem) 2rem 2rem;
    background: var(--bg-dark);
    color: #fff;
}
#loginView[data-active="true"] { display: flex; }

/* ─── TOTP modals (overlay on top of login view) ───────────── */
#totpEnrollView, #totpVerifyView {
    display: none;
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    align-items: center; justify-content: center;
    background: rgba(0, 0, 0, 0.75); backdrop-filter: blur(4px);
    z-index: 1000; padding: clamp(12px, 3vw, 32px); color: #fff;
    overflow: hidden;
}
#totpEnrollView[data-active="true"],
#totpVerifyView[data-active="true"] { display: flex; }
#totpEnrollView .login-card, #totpVerifyView .login-card {
    width: min(420px, calc(100vw - 24px));
    max-width: 420px; background: #16213e;
    border: 1px solid #334155; border-radius: var(--radius);
    padding: 28px; box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    box-sizing: border-box;
    max-height: calc(100vh - 24px); overflow-y: auto; overflow-x: hidden;
}
#totpEnrollView .login-card {
    width: min(760px, calc(100vw - 24px));
    max-width: 760px;
}
#totpVerifyView .login-card { max-width: 420px; }
#totpEnrollView .login-card h1, #totpVerifyView .login-card h1 { font-size: 1.75rem; }
.totp-intro, .totp-account, .totp-hint {
    font-size: 13px; color: var(--text-light); margin-bottom: 12px; text-align: center;
}
.totp-enroll-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(190px, 0.75fr); gap: 16px; align-items: stretch; margin-bottom: 14px; }
.totp-enroll-primary, .totp-enroll-secondary {
    background: rgba(15, 23, 42, 0.35);
    border: 1px solid #334155;
    border-radius: var(--radius);
    padding: 14px;
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.totp-enroll-primary .totp-intro { margin-bottom: 10px; }
.totp-enroll-secondary .totp-codes-label { margin-top: 0; }
.totp-qr-wrap { display: flex; justify-content: center; padding: 10px; background: #fff; border-radius: var(--radius); margin: auto auto 0; width: fit-content; max-width: 100%; box-sizing: border-box; }
#enrollQr { width: min(260px, 100%); height: auto; max-width: 100%; aspect-ratio: 1; }
.totp-secret-label, .totp-codes-label { font-size: 13px; color: #cbd5e0; margin: 8px 0 4px; }
/* Secret moved out of the QR card into a dedicated full-width row below
   the two symmetric cards — Base32 value fits on one line at normal
   modal widths. No <wbr>, no spaces; copies cleanly into authenticator. */
.totp-secret-row { margin: 14px 0; text-align: center; }
.totp-secret-row .totp-secret-label { margin-bottom: 6px; }
.totp-secret { display: inline-block; padding: 8px 14px; background: #0f172a; border-radius: 4px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; letter-spacing: 0.5px; color: #fff; white-space: nowrap; max-width: 100%; overflow-x: auto; }
/* Backup codes grid: auto-fit instead of fixed 3-col so each cell is at
   least wide enough to hold one full code (nowrap). The dash inside
   codes like "czaz-ehh4" is a natural break-point for the browser —
   without nowrap the renderer would split at the dash, producing
   codes-wrapped-in-two-lines that are impossible to read back from a
   printout. */
.totp-codes { display: grid; grid-template-columns: repeat(2, minmax(84px, 1fr)); gap: 6px 10px; margin-bottom: 8px; }
.totp-codes code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; color: #cbd5e0; background: #16213e; padding: 4px 8px; border-radius: 3px; text-align: center; white-space: nowrap; }
.totp-copy-btn { margin-top: 0; margin-bottom: 0; }
.totp-confirm-label { margin-top: 4px; }
.btn-link { background: none; border: none; color: #94a3b8; font-size: 13px; cursor: pointer; margin-top: 12px; text-decoration: underline; font-family: inherit; padding: 4px 8px; width: 100%; }
.btn-link:hover { color: #fff; }
.login-card {
    width: 100%;
    max-width: 420px;
    background: transparent;
    border: none;
    padding: 0;
}
.login-logo { display: block; margin: 0 auto 12px; opacity: 0.95; }
.login-card h1 {
    font-size: clamp(1.5rem, 6vw, 2rem);
    margin-bottom: 0.25rem;
    font-weight: 700;
    text-align: center;
    white-space: nowrap;
}
.login-card .subtitle { color: var(--text-light); margin-bottom: 0.25rem; font-size: 14px; text-align: center; }
.login-card .product-subtitle { color: rgba(255,255,255,0.72); margin-bottom: 2rem; font-size: 13px; text-align: center; }
#loginView #loginEmail { margin-top: 3px; }
.login-card label {
    display: block;
    margin-bottom: 12px;
    font-size: 13px;
    font-weight: 600;
    color: #cbd5e0;
    text-align: left;
}
#loginView input[type=text],
#loginView input[type=email],
#loginView input[type=password],
#loginView select,
#totpEnrollView input[type=text],
#totpEnrollView input[type=password],
#totpVerifyView input[type=text],
#totpVerifyView input[type=password] {
    width: 100%;
    padding: 14px 16px;
    margin-bottom: 12px;
    border: 1px solid #444;
    border-radius: var(--radius);
    background: #16213e;
    color: #fff;
    font-size: 16px;
    font-family: inherit;
    box-sizing: border-box;
}
#loginView label input, #totpEnrollView label input, #totpVerifyView label input { margin-top: 6px; margin-bottom: 0; }
#loginView input::placeholder,
#totpEnrollView input::placeholder,
#totpVerifyView input::placeholder { color: #4a5a75; }
#loginView input:focus,
#totpEnrollView input:focus,
#totpVerifyView input:focus { outline: none; border-color: var(--primary-light); }

#loginView input[type=text],
#loginView input[type=email],
#loginView input[type=password],
#loginView select {
    height: 54px;
    line-height: 1.5;
}

#companyHint:empty { display: none; }

/* Large, tracked 6-digit code input */
#confirmCode, #verifyCode {
    font-size: clamp(22px, 5vw, 28px) !important;
    letter-spacing: clamp(4px, 1.4vw, 8px);
    text-align: center;
    font-family: ui-monospace, Menlo, Consolas, monospace !important;
    padding: 12px 16px !important;
}
.tabs-inline {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    border-bottom: 1px solid #334155;
}
.tabs-inline .tab {
    flex: 1;
    background: transparent;
    border: none;
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 600;
    color: #94a3b8;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    font-family: inherit;
}
.tabs-inline .tab.active { color: #fff; border-bottom-color: var(--selection-border); }
#loginView button.primary,
#totpEnrollView button.primary,
#totpVerifyView button.primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 14px 28px;
    margin-top: 8px;
    background: var(--primary);
    color: #fff;
    border: 2px solid var(--primary);
    border-radius: var(--radius);
    font-size: 17px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
    font-family: inherit;
}
#loginView button.primary:active,
#totpEnrollView button.primary:active,
#totpVerifyView button.primary:active { opacity: 0.7; }
#loginView button.primary:hover,
#totpEnrollView button.primary:hover,
#totpVerifyView button.primary:hover { background: var(--primary-light); border-color: var(--primary-light); }
.login-features {
    margin-top: 28px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-width: 360px;
}
.feature {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    font-size: 13px;
    color: rgba(255,255,255,0.6);
    line-height: 1.5;
    text-align: left;
}
.feature b { color: rgba(255,255,255,0.85); }
.feature-icon { font-size: 20px; flex-shrink: 0; margin-top: 2px; }

.version-footer {
    margin-top: 8px;
    font-size: 11px;
    color: #666;
    line-height: 1.4;
    text-align: center;
}
.version-footer strong { color: #94a3b8; font-weight: 500; }

.login-footer-links {
    margin-top: 16px;
    font-size: 11px;
    color: rgba(255,255,255,0.45);
    text-align: center;
    line-height: 1.6;
}
.login-footer-links a {
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    margin: 0 6px;
}
.login-footer-links a:hover { color: rgba(255,255,255,0.95); text-decoration: underline; }

/* ─── App shell ────────────────────────────────────────────── */
#app {
    display: none;
    min-height: 100vh;
}
#app[data-active="true"] { display: flex; flex-direction: column; }

#topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: #334155;
    color: white;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}
#topbar-title {
    flex: 1;
    font-size: 18px;
    font-weight: 600;
}
#btn-menu-toggle {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
}
#topbar-user { font-size: 13px; opacity: 0.8; }
#btn-logout {
    background: none;
    border: 1px solid rgba(255,255,255,0.4);
    color: white;
    font-size: 16px;
    padding: 2px 8px;
    border-radius: 4px;
    cursor: pointer;
    opacity: 0.8;
    transition: background 0.15s, opacity 0.15s;
}
#btn-logout:hover { opacity: 1; background: rgba(255,255,255,0.15); }

/* Sync indicator (green / amber / red dot) — mirrors WMS shell */
#sync-indicator { font-size: 13px; line-height: 1; }
.sync-online { color: #22c55e; }
.sync-syncing { color: #f59e0b; animation: pulse 1s infinite; }
.sync-offline { color: #ef4444; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }

#main { display: flex; flex: 1; position: relative; }

/* ─── Side menu (overlay, WMS-style) ─────────────────────────── */
#sidemenu {
    position: fixed;
    top: 44px;
    left: 0;
    width: 310px;
    height: calc(100vh - 44px);
    background: var(--bg-dark);
    color: white;
    z-index: 200;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
}
#sidemenu.open { transform: translateX(0); }
#sidemenu.hidden { display: block; }
.menu-overlay {
    position: fixed;
    top: 44px;
    left: 0;
    width: 100vw;
    height: calc(100vh - 44px);
    background: rgba(0,0,0,0.5);
    z-index: 199;
}
.menu-user {
    padding: 24px 16px 12px;
    border-bottom: 1px solid #333;
}
.menu-user .name { display: block; font-size: 18px; font-weight: 600; color: white; line-height: 1.3; word-break: break-word; }
.menu-user .tenant { display: block; font-size: 13px; color: #94a3b8; margin-top: 2px; }
.menu-user .badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    background: var(--accent);
    margin-top: 4px;
    color: white;
}
.menu-link {
    display: block;
    margin-top: 8px;
    font-size: 11px;
    color: #94a3b8;
    text-decoration: none;
}
.menu-link:hover { color: white; }
.menu-panel {
    padding: 12px 16px;
    border-bottom: 1px solid #333;
}
.menu-panel-label {
    display: block;
    margin-bottom: 4px;
    font-size: 11px;
    font-weight: 600;
    color: #94a3b8;
}
.menu-input {
    width: 100%;
    margin-bottom: 4px;
    padding: 7px 10px;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius);
    background: #fff;
    color: #111827;
    font-size: 14px;
    font-family: inherit;
}
.menu-panel > .menu-input:last-of-type { margin-bottom: 0; }
.menu-input::placeholder { color: #94a3b8; }
.menu-input:focus { outline: none; border-color: var(--primary-light); }
.menu-panel-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}
.menu-status {
    font-size: 11px;
    margin-top: 6px;
}
#cpSuccess { color: var(--success); }
.menu-items { padding: 8px 0; }
#sidemenu .menu-group-label {
    padding: 14px 16px 4px 14px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: #a8b4c3;
    user-select: none;
    cursor: pointer;
}
#sidemenu .menu-group-label::before {
    content: '▾';
    display: inline-block;
    width: 14px;
    font-size: 11px;
    color: #6b7a8c;
    transition: transform 0.15s ease;
}
#sidemenu .menu-group-label.collapsed::before { content: '▸'; }
#sidemenu .menu-group-label:hover { color: #fff; }
#sidemenu .menu-group-label:hover::before { color: #e2e8f0; }
/* Sub-items under a group label indent to form the tree.
   Only items that *follow* a .menu-group-label receive the indent; the
   top-level Jobs button keeps its base alignment. The vertical guide
   line is painted in the chevron column. */
#sidemenu .menu-group-label ~ .menu-item {
    padding-left: 44px;
    position: relative;
    font-size: 13px;
}
#sidemenu .menu-group-label ~ .menu-item::before {
    content: '';
    position: absolute;
    left: 21px;
    top: 0;
    bottom: 0;
    width: 1px;
    background: rgba(255, 255, 255, 0.08);
}
#sidemenu .menu-item {
    display: block;
    width: 100%;
    padding: 12px 16px;
    color: white;
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    transition: background 0.2s;
}
#sidemenu .menu-item:hover { background: #16213e; }
#sidemenu .menu-item.active {
    background: var(--selection-bg);
    color: var(--selection-fg);
    font-weight: 600;
}
.menu-footer {
    padding: 16px;
    border-top: 1px solid #333;
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
}
#appVersionFooter { background: transparent; }
.menu-footer strong { color: #94a3b8; font-weight: 500; }
#appVersionFooter { background: transparent; }
#btn-logout-menu {
    padding: 6px 12px;
    font-size: 13px;
}
#btn-logout-menu:hover { background: #c0392b; border-color: #c0392b; }
#btn-about-menu {
    padding: 6px 12px;
    font-size: 13px;
}
.menu-footer .btn.outline {
    color: #cbd5e0;
    border-color: #475569;
}
.menu-footer .btn.outline:hover {
    background: rgba(255,255,255,0.08);
}

/* ─── Content area ─────────────────────────────────────────── */
#content { flex: 1; padding: 16px; max-width: 1400px; margin: 0 auto; width: 100%; }
.page { max-width: 1400px; margin: 0 auto; }
.page.narrow { max-width: 800px; }
/* 2FA idle-countdown pill rendered inside the submit button. */
.totp-timer { opacity: 0.7; font-size: 13px; margin-left: 6px; font-weight: 400; }

/* Shared forms (UfcpSettingsForm / SettingsForm) wrap their fields in a
   .page-narrow container. Mirror the WMS shell so the COO Setup / CFO
   Setup pages render at the same width across both apps. */
.page-narrow {
    max-width: 800px; margin: 0 auto;
    background: var(--card, #fff);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 24px 32px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.page-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.page-header h2 { font-size: 24px; font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 10px; }
.btn-back { background: none; border: none; cursor: pointer; font-size: 22px; color: var(--text-light); padding: 0 6px; line-height: 1; font-family: inherit; }
.btn-back:hover { color: var(--primary); }

/* ─── Cards ─────────────────────────────────────────────────── */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 14px;
    margin-bottom: 10px;
    margin-left: auto;
    margin-right: auto;
}
.card h3 { font-size: 16px; font-weight: 600; margin-bottom: 8px; color: var(--text); }
.card h4 { font-size: 13px; font-weight: 600; color: var(--text-light); text-transform: uppercase; letter-spacing: 0.5px; margin: 16px 0 8px; }
.row-between { display: flex; justify-content: space-between; align-items: center; }
.muted { color: var(--text-light); font-size: 13px; }
.error { color: var(--danger); font-size: 14px; }

/* ─── Buttons ──────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border: 2px solid transparent;
    border-radius: var(--radius);
    box-sizing: border-box;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
    text-decoration: none;
    font-family: inherit;
}
.btn:hover { opacity: 0.92; }
.btn:active { opacity: 0.7; }
.btn.primary,
.btn.accent,
.btn-primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}
.btn.danger,
.btn-danger {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}
.btn.outline,
.btn-outline {
    background: transparent;
    color: var(--primary);
    border-color: var(--primary);
}
.btn.sm,
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ─── Forms ────────────────────────────────────────────────── */
label { display: block; margin-bottom: 10px; font-size: 13px; font-weight: 600; color: var(--text-light); }
.form-group { margin-bottom: 10px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 3px; color: var(--text-light); }
input[type=text], input[type=password], input[type=email],
select, textarea {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    background: var(--input-bg);
    color: var(--text);
}
.form-control { width: 100%; }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(15,52,96,0.1);
}
input[type=file] { margin: 8px 0; font-size: 14px; }
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.form-row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
}
.check-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}
.check-grid label {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    user-select: none;
}
.check-grid label:hover {
    background: var(--bg);
    border-color: var(--primary);
}
.check-grid label:has(input:checked) {
    background: var(--selection-bg);
    border-color: var(--selection-border);
    color: var(--selection-fg);
}
.check-grid input[type="checkbox"],
.check-grid input[type="radio"] {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    accent-color: var(--primary);
}
.form-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}
.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}

/* ─── Tables ───────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; }
table th {
    background: var(--bg);
    text-align: left;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-light);
    padding: 8px;
    border-bottom: 2px solid var(--border);
}
table td { padding: 8px; border-bottom: 1px solid var(--border); font-size: 14px; }
table tr:last-child td { border-bottom: none; }
table tr:hover td { background: var(--hover-bg); }
table code { font-size: 11px; color: var(--text-light); background: var(--input-bg); padding: 2px 6px; border-radius: 3px; }

/* ─── Job status chips ─────────────────────────────────────── */
.status { display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px; }
.status-DRAFT { background: #e5e7eb; color: #4b5563; }
.status-READY { background: #dbeafe; color: #1e40af; }
.status-RUNNING { background: #fed7aa; color: #9a3412; }
.status-COMPLETED { background: #d1fae5; color: #065f46; }
.status-FAILED { background: #fee2e2; color: #991b1b; }

/* ─── KPI cards ────────────────────────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin-bottom: 20px; }
.kpi {
    background: var(--card); border-radius: var(--radius); padding: 14px 16px;
    box-shadow: var(--shadow); border-top: 3px solid var(--primary);
}
.kpi .l { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-light); margin-bottom: 4px; }
.kpi .v { font-size: 24px; font-weight: 700; color: var(--text); }
.kpi.success { border-top-color: var(--success); }
.kpi.warning { border-top-color: var(--warning); }
.kpi.danger { border-top-color: var(--danger); }
.kpi.info { border-top-color: var(--info); }

/* ─── Metadata list ────────────────────────────────────────── */
.meta-grid { display: grid; grid-template-columns: auto 1fr; gap: 6px 20px; font-size: 13px; margin-bottom: 16px; }
.meta-grid dt { color: var(--text-light); font-weight: 500; }
.meta-grid dd { color: var(--text); }

/* ─── Collapsible ──────────────────────────────────────────── */
.collapsible {
    border-top: 1px solid var(--border);
    padding-top: 12px;
    margin-top: 12px;
}
#resultSection .collapsible:first-child {
    border-top: none;
    padding-top: 0;
    margin-top: 0;
}
.collapsible-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 0 8px;
    cursor: pointer;
    user-select: none;
}
.collapsible-header h3 {
    margin: 0;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-light);
}
.collapsible-header h3::before {
    content: '▾ ';
    font-size: 16px;
    display: inline-block;
    width: 12px;
    transition: transform 0.2s;
}
.collapsible.collapsed .collapsible-header h3::before { transform: rotate(-90deg); display: inline-block; }
.collapsible-header .chevron { display: none; }
.collapsible-body { padding: 0 0 4px; }
.collapsible.collapsed .collapsible-body { display: none; }
.collapsible-header .actions { display: flex; gap: 8px; align-items: center; }

/* ─── Group palette (stable colours) ──────────────────────── */
.group-0 { --gc: #2563eb; }
.group-1 { --gc: #059669; }
.group-2 { --gc: #d97706; }
.group-3 { --gc: #7c3aed; }
.group-4 { --gc: #db2777; }
.group-5 { --gc: #0891b2; }
.group-badge {
    display: inline-block; padding: 2px 10px; border-radius: 12px;
    font-size: 11px; font-weight: 600; color: #fff; background: var(--gc);
}

/* ─── Gantt ────────────────────────────────────────────────── */
#ganttChart { border: 1px solid var(--border); border-radius: 6px; background: var(--card); overflow-x: auto; font-size: 11px; }
.gantt-row { display: flex; align-items: center; border-bottom: 1px dashed #e2e8f0; }
.gantt-row:last-child { border-bottom: none; }
.gantt-row.axis { border-bottom: 1px solid var(--border); background: var(--surface-2); }
.gantt-label { flex: 0 0 140px; padding: 6px 12px; font-weight: 600; font-size: 12px; color: var(--text); border-left: 3px solid var(--gc, transparent); display: flex; align-items: center; gap: 8px; }
.gantt-row.axis .gantt-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-light); border-left: none; font-weight: 500; }
.gantt-track { flex: 1; position: relative; height: 28px; min-width: 720px; }
.gantt-row.axis .gantt-track { height: 22px; }
.gantt-bar {
    position: absolute; top: 5px; height: 18px; border-radius: 3px;
    background: var(--gc); color: #fff; padding: 0 6px; line-height: 18px;
    font-size: 10px; font-weight: 500; overflow: hidden; white-space: nowrap; cursor: help;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}
.gantt-tick { position: absolute; top: 0; bottom: 0; border-left: 1px dotted #cbd5e0; font-size: 9px; color: var(--text-light); padding-left: 3px; }

/* ─── Summary chips (legacy, kept for compat) ─────────────── */
.summary-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip { background: var(--card); border: 1px solid var(--border); padding: 6px 12px; border-radius: 999px; font-size: 13px; color: var(--text); }
.chip strong { color: var(--primary); margin-left: 6px; }

/* ─── Markdown from AI ─────────────────────────────────────── */
.markdown h1, .markdown h2, .markdown h3 { margin: 16px 0 8px; color: var(--primary); }
.markdown h1 { font-size: 17px; } .markdown h2 { font-size: 14px; } .markdown h3 { font-size: 14px; }
.markdown p { margin: 8px 0; line-height: 1.6; }
.markdown ul, .markdown ol { margin: 8px 0 8px 24px; }
.markdown li { margin: 4px 0; }
.markdown code { background: var(--surface-2); padding: 1px 5px; border-radius: 3px; font-size: 13px; color: var(--primary); }
.markdown pre { background: #1a1a2e; color: #e2e8f0; padding: 12px 14px; border-radius: 4px; font-size: 13px; overflow-x: auto; }
.markdown pre code { background: transparent; color: inherit; padding: 0; }
.markdown strong { font-weight: 600; color: var(--text); }

/* ─── Code block (raw JSON etc.) ───────────────────────────── */
pre.codeblock {
    background: #1a1a2e; color: #e2e8f0; padding: 14px 16px;
    border-radius: 6px; overflow-x: auto; max-height: 400px;
    font-size: 13px; line-height: 1.5; font-family: ui-monospace, Menlo, Consolas, monospace;
}

/* ─── AI Setup page (form sections + provider cards) ──────── */
.page-desc {
    display: flex; gap: 12px; align-items: flex-start;
    padding: 12px 16px; margin-bottom: 16px;
    background: var(--card); border-radius: var(--radius);
    border-left: 3px solid var(--primary);
    font-size: 13px; line-height: 1.5; color: var(--text);
}
.page-desc-icon { font-size: 16px; flex-shrink: 0; margin-top: 1px; }
.page-desc b { color: var(--text); }

.form-section {
    border-top: 1px solid var(--border);
    padding-top: 12px;
    margin-top: 12px;
}
.form-header + .form-section {
    border-top: none;
    margin-top: 0;
}
.form-section-title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-light);
    margin-bottom: 8px;
}
.form-section-title.collapsible {
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 6px;
}
.form-section-title.collapsible::before {
    content: '▾';
    font-size: 16px;
    transition: transform 0.2s;
    display: inline-block;
    width: 12px;
}
.form-section-title.collapsible.collapsed::before { transform: rotate(-90deg); }
.form-section-title.collapsible.collapsed + .form-section-body { display: none; }
.form-section-body { padding: 0; }

.ai-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px;
    margin-bottom: 12px;
}
.ai-card:last-child { margin-bottom: 0; }
.ai-card-row1 {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 10px; flex-wrap: wrap; gap: 8px;
}
.ai-card-row2 {
    display: grid; grid-template-columns: 1fr auto auto;
    gap: 8px; align-items: end; font-size: 13px;
}
.ai-card-row3 {
    margin-top: 8px;
    display: grid; grid-template-columns: 1fr auto;
    gap: 8px; align-items: end;
}
.ai-card-key-fields {
    display: grid; grid-template-columns: auto 1fr;
    gap: 8px; align-items: end;
}
.ai-card-key-actions {
    display: flex; gap: 6px; align-items: end; padding-bottom: 1px;
}
.ai-field-label {
    font-size: 11px; color: var(--text-light);
    margin-bottom: 2px;
}
.ai-card select, .ai-card input[type=text], .ai-card input[type=password], .ai-card input[type=number] {
    font-family: inherit;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--input-bg);
    color: var(--text);
    margin-top: 0;
}

.ai-modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5); z-index: 1000;
    display: flex; align-items: center; justify-content: center;
}
.ai-modal {
    background: var(--card); border-radius: 12px; padding: 20px;
    max-width: 500px; width: 95%;
}

/* Generic modal overlay (shared with Terms consent modal, GDPR Art. 7) */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5); z-index: 9999;
    display: flex; align-items: center; justify-content: center;
    padding: 16px;
}
.modal-overlay.hidden { display: none; }
.modal-content {
    background: var(--card); border-radius: 8px; padding: 24px;
    width: 100%; box-shadow: 0 4px 24px rgba(0,0,0,0.2);
}

.about-card { max-width: 420px; color: var(--text); text-align: left; }
.about-card h2 { font-size: 20px; margin: 0 0 16px; color: var(--primary, #0f3460); }
.about-version-grid { display: grid; gap: 10px; margin-bottom: 20px; }
.about-version-row { display: grid; grid-template-columns: 92px 1fr; gap: 10px; font-size: 13px; line-height: 1.45; }
.about-version-row strong { color: var(--text-light); font-weight: 700; }
.about-version-row span { color: var(--text); overflow-wrap: anywhere; }
.about-card .btn { width: 100%; }

/* Terms & Privacy consent modal */
.terms-consent-card { max-width: 460px; color: var(--text); text-align: left; }
.terms-consent-eyebrow {
    font-size: 11px; letter-spacing: 2px; text-transform: uppercase;
    color: var(--text-light); margin: 0 0 6px; font-style: italic; font-weight: 500;
}
.terms-consent-title { font-size: 20px; margin: 0 0 8px; color: var(--primary, #0f3460); }
.terms-consent-version { font-size: 13px; color: var(--text-light); margin: 0 0 16px; }
.terms-consent-body { font-size: 14px; line-height: 1.6; margin: 0 0 20px; color: var(--text); }
.terms-consent-body a { color: var(--primary, #0f3460); font-weight: 500; }
.terms-consent-card button.primary { width: 100%; }

/* Chat log markdown tables (GFM) — keeps agent replies with tabular
   data legible instead of showing raw |---|---| separator rows. */
.chat-md-table {
    border-collapse: collapse;
    width: 100%;
    margin: 8px 0;
    font-size: 13px;
    background: var(--card);
}
.chat-md-table th,
.chat-md-table td {
    border: 1px solid var(--border, #dcdde1);
    padding: 6px 10px;
    text-align: left;
    vertical-align: top;
}
.chat-md-table th {
    background: var(--input-bg);
    font-weight: 600;
    color: var(--text, #2c3e50);
}

:root[data-theme="dark"] .card,
:root[data-theme="dark"] .check-grid label,
:root[data-theme="dark"] .chip,
:root[data-theme="dark"] .meta-grid,
:root[data-theme="dark"] .ai-card {
    background: var(--card);
    border-color: var(--border);
}
:root[data-theme="dark"] .check-grid label:has(input:checked) {
    background: var(--selection-bg);
    color: var(--selection-fg);
    border-color: var(--selection-border);
}
:root[data-theme="dark"] .menu-input {
    background: var(--input-bg);
    color: var(--text);
    border-color: var(--border);
}
:root[data-theme="dark"] .gantt-tick { border-left-color: #475569; }
:root[data-theme="dark"] .totp-qr-wrap { background: #fff; }

/* ─── Responsive ───────────────────────────────────────────── */
@media (max-width: 900px) {
    #content { padding: 16px; }
    .page-header h2 { font-size: 18px; }
    .kpi-grid { grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 8px; }
    .kpi .v { font-size: 20px; }
    .form-row,
    .form-row-3 { grid-template-columns: 1fr; }
    .check-grid { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
    #totpEnrollView .login-card { width: min(480px, calc(100vw - 24px)); max-width: 480px; }
    .totp-enroll-grid { grid-template-columns: 1fr; }
    .totp-codes { grid-template-columns: 1fr 1fr; }
    .totp-qr-wrap { margin-top: 10px; }
}

@media (max-width: 480px) {
    #totpEnrollView, #totpVerifyView { align-items: flex-start; padding: 10px; }
    #totpEnrollView .login-card, #totpVerifyView .login-card {
        width: 100%;
        max-height: calc(100vh - 20px);
        padding: 20px;
    }
    #totpEnrollView .login-card h1, #totpVerifyView .login-card h1 { white-space: normal; }
    .totp-secret { white-space: normal; overflow-wrap: anywhere; text-align: center; }
}

/* ─── Voice controls (push-to-talk mic + read-aloud toggle) ─── */
.voice-mic-btn, .voice-tts-btn {
    padding: 0 12px;
    font-size: 18px;
    min-width: 44px;
    line-height: 1;
}
.voice-mic-btn.voice-mic-active {
    background: #dc2626;
    color: #fff;
    animation: voice-mic-pulse 1s ease-in-out infinite;
}
.voice-tts-btn {
    opacity: 0.55;
    transition: opacity 0.2s, background 0.2s;
}
.voice-tts-btn[data-active="true"] {
    opacity: 1;
    background: var(--selection-bg);
    color: var(--selection-fg);
    border-color: var(--selection-border);
}
@keyframes voice-mic-pulse {
    50% { opacity: 0.6; }
}
