/* FCPA training admin — light & dark (selected, not flipped) */
:root {
  color-scheme: light;
  --page: #f4f3f8;
  --surface: #fcfcfb;          /* chart/card surface (validated against) */
  --surface-2: #f2f1f6;
  --surface-3: #e9e7f0;
  --ink: #1d1930;
  --ink-2: #514e66;
  --muted: #858298;
  --line: #e4e2ec;
  --ring: rgba(29, 25, 48, .10);
  --accent: #6c4ef2;
  --accent-ink: #ffffff;
  --accent-soft: #ece8ff;
  --pink: #ff4f8b;
  --good: #0ca30c; --good-text: #006300; --good-soft: #e3f6e3;
  --warn: #fab219; --warn-soft: #fff4d6;
  --serious: #ec835a;
  --crit: #d03b3b; --crit-soft: #fde8e8;
  /* ordinal status ramp (not invited -> completed), validated --ordinal light */
  --st-1: #86b6ef; --st-2: #5598e7; --st-3: #2a78d6; --st-4: #184f95;
  --meter-fill: #2a78d6; --meter-track: #cde2fb;
  --shadow: 0 1px 2px rgba(20, 16, 40, .06), 0 8px 24px rgba(20, 16, 40, .06);
  --font: 'M PLUS Rounded 1c', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0f0e13; --surface: #1a1a19; --surface-2: #222128; --surface-3: #2c2b33;
    --ink: #f0efec; --ink-2: #c3c2b7; --muted: #898781; --line: #2c2c2a; --ring: rgba(255, 255, 255, .10);
    --accent: #8f7bff; --accent-ink: #120e26; --accent-soft: #2a2450;
    --good-text: #0ca30c; --good-soft: #14301a; --warn-soft: #3a2f10; --crit-soft: #3a1717;
    --st-1: #184f95; --st-2: #256abf; --st-3: #3987e5; --st-4: #86b6ef;
    --meter-fill: #3987e5; --meter-track: #0d366b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0f0e13; --surface: #1a1a19; --surface-2: #222128; --surface-3: #2c2b33;
  --ink: #f0efec; --ink-2: #c3c2b7; --muted: #898781; --line: #2c2c2a; --ring: rgba(255, 255, 255, .10);
  --accent: #8f7bff; --accent-ink: #120e26; --accent-soft: #2a2450;
  --good-text: #0ca30c; --good-soft: #14301a; --warn-soft: #3a2f10; --crit-soft: #3a1717;
  --st-1: #184f95; --st-2: #256abf; --st-3: #3987e5; --st-4: #86b6ef;
  --meter-fill: #3987e5; --meter-track: #0d366b;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--ink); font-family: var(--font); font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
.ico { width: 1.15em; height: 1.15em; flex: none; vertical-align: -0.2em; }
.muted { color: var(--muted); }
.ink2 { color: var(--ink-2); }
.num { font-variant-numeric: tabular-nums; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hidden { display: none !important; }

/* buttons */
.btn { display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-weight: 700; cursor: pointer; white-space: nowrap; text-decoration: none; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--crit); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn:focus-visible, .tab:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.icon-btn { width: 34px; height: 34px; display: inline-grid; place-items: center; border-radius: 9px; border: 1px solid transparent; background: transparent; cursor: pointer; color: var(--ink-2); }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: #120e26 radial-gradient(circle at 50% 0%, #2a1f5c 0%, #120e26 65%); }
.login-card { width: min(400px, 100%); background: var(--surface); border-radius: 20px; padding: 28px; box-shadow: 0 30px 80px rgba(0, 0, 0, .4); text-align: center; }
.login-card img { width: 96px; height: 93px; margin: -72px auto 4px; display: block; }
.login-card h1 { margin: 4px 0 2px; font-size: 22px; }
.login-card p { margin: 0 0 18px; color: var(--ink-2); }
.login-card input { width: 100%; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); padding: 0 14px; margin-bottom: 10px; }
.login-card .btn { width: 100%; justify-content: center; height: 44px; }
.login-err { color: var(--crit); font-weight: 700; min-height: 20px; margin-top: 8px; }

/* shell */
.top { position: sticky; top: 0; z-index: 30; background: color-mix(in srgb, var(--page) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.top-in { max-width: 1240px; margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 16px; white-space: nowrap; }
.brand img { width: 34px; height: 33px; }
.brand b { font-family: 'Bangers', Impact, sans-serif; font-weight: 400; font-size: 22px; letter-spacing: 1px; }
.brand b span { color: var(--pink); }
.brand small { color: var(--muted); font-weight: 700; font-size: 13px; }
.tabs { display: flex; gap: 2px; margin-left: 12px; }
.tab { height: 34px; padding: 0 14px; border-radius: 9px; border: 0; background: transparent; cursor: pointer; font-weight: 700; color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px; }
.tab:hover { background: var(--surface-2); color: var(--ink); }
.tab[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--line); }
.tab .count { font-size: 11px; padding: 1px 6px; border-radius: 99px; background: var(--surface-3); color: var(--ink-2); }
.top-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.campaign-select { height: 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); padding: 0 10px; font-weight: 700; max-width: 240px; }
main { max-width: 1240px; margin: 0 auto; padding: 18px 20px 60px; }
.banner { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-radius: 12px; margin-bottom: 12px; background: var(--surface); border: 1px solid var(--line); }
.banner.info { border-left: 4px solid var(--accent); }
.banner.demo { border-left: 4px solid var(--warn); }
.banner .grow { flex: 1; }
.banner b { font-weight: 800; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 6px 0 16px; }
.page-head h1 { margin: 0; font-size: 24px; letter-spacing: -.2px; }
.page-head .sub { color: var(--ink-2); margin-top: 3px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); font-weight: 700; font-size: 12px; color: var(--ink-2); }

/* cards & grid */
.grid { display: grid; gap: 14px; }
.grid.kpis { grid-template-columns: 1.3fr repeat(5, 1fr); margin-bottom: 14px; }
.grid.two { grid-template-columns: 1.4fr 1fr; align-items: start; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.card-h { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 14px 16px 0; }
.card-h h2 { margin: 0; font-size: 15px; }
.card-h .note { color: var(--muted); font-size: 12px; }
.card-b { padding: 12px 16px 16px; }

.kpi { padding: 14px 16px; }
.kpi .label { color: var(--ink-2); font-weight: 700; font-size: 13px; display: flex; align-items: center; gap: 6px; }
.kpi .value { font-size: 28px; font-weight: 800; margin-top: 4px; letter-spacing: -.5px; }
.kpi .foot { color: var(--muted); font-size: 12px; margin-top: 2px; }
.kpi.hero .value { font-size: 52px; line-height: 1.05; }
.kpi .dot { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.kpi.crit .value { color: var(--ink); }
.status-icon { width: 18px; height: 18px; border-radius: 50%; display: inline-grid; place-items: center; color: #fff; font-size: 11px; font-weight: 800; }
.status-icon.crit { background: var(--crit); }
.status-icon.good { background: var(--good); }

/* stacked status bar */
.stack { display: flex; gap: 2px; height: 22px; margin: 6px 0 14px; }
.stack .seg { height: 100%; min-width: 4px; cursor: default; transition: filter .15s; position: relative; }
.stack .seg:first-child { border-radius: 4px 0 0 4px; }
.stack .seg:last-child { border-radius: 0 4px 4px 0; }
.stack .seg:only-child { border-radius: 4px; }
.stack .seg:hover, .stack .seg:focus-visible { filter: brightness(1.12); outline: none; }
.legend { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.legend .li { display: flex; flex-direction: column; gap: 1px; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); cursor: pointer; border: 1px solid transparent; text-align: left; }
.legend .li:hover { border-color: var(--line); }
.legend .sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 6px; vertical-align: 0; }
.legend .lt { font-weight: 700; color: var(--ink-2); font-size: 12px; }
.legend .lv { font-weight: 800; font-size: 18px; }
.legend .lv small { font-weight: 700; color: var(--muted); font-size: 12px; margin-left: 4px; }

.meters { display: grid; gap: 10px; }
.meter-row { display: grid; grid-template-columns: minmax(110px, 160px) 1fr 74px; gap: 12px; align-items: center; }
.meter-row .name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meter { height: 12px; border-radius: 4px; background: var(--meter-track); position: relative; overflow: hidden; }
.meter i { position: absolute; inset: 0 auto 0 0; background: var(--meter-fill); border-radius: 0 4px 4px 0; }
.meter-row .val { text-align: right; font-weight: 800; }
.meter-row .val small { display: block; font-weight: 600; color: var(--muted); font-size: 11px; }
.mini-meter { width: 72px; height: 8px; border-radius: 3px; background: var(--meter-track); overflow: hidden; display: inline-block; vertical-align: middle; margin-right: 8px; }
.mini-meter i { display: block; height: 100%; background: var(--meter-fill); border-radius: 0 3px 3px 0; }

.tooltip { position: fixed; z-index: 100; pointer-events: none; background: var(--ink); color: var(--page); padding: 8px 10px; border-radius: 10px; font-size: 12px; box-shadow: 0 8px 24px rgba(0, 0, 0, .25); max-width: 260px; }
.tooltip b { font-size: 15px; display: block; }

.checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.checklist li { display: flex; gap: 10px; align-items: flex-start; }
.checklist .ci { flex: none; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; margin-top: 1px; }
.checklist .ok .ci { background: var(--good-soft); color: var(--good-text); }
.checklist .todo .ci { background: var(--warn-soft); color: #9a6a00; }
.checklist b { display: block; font-size: 13px; }
.checklist span { color: var(--muted); font-size: 12px; }

.feed { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; max-height: 360px; overflow: auto; }
.feed li { display: flex; gap: 10px; align-items: flex-start; }
.feed .fi { flex: none; width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-2); color: var(--ink-2); }
.feed b { font-weight: 800; }
.feed time { display: block; color: var(--muted); font-size: 12px; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; }
.kv dt { color: var(--muted); font-weight: 700; font-size: 12px; }
.kv dd { margin: 0; font-weight: 700; }

/* people */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filters input[type=search] { height: 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); padding: 0 12px; min-width: 240px; }
.filters select { height: 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); padding: 0 10px; font-weight: 700; }
.filters .spacer { flex: 1; }
.bulk { display: flex; gap: 8px; align-items: center; padding: 8px 12px; border-radius: 12px; background: var(--accent-soft); margin-bottom: 10px; font-weight: 700; flex-wrap: wrap; }
.table-wrap { overflow: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 800; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0; background: var(--surface); cursor: pointer; user-select: none; }
table.data th.nosort { cursor: default; }
table.data th .arrow { opacity: .6; font-size: 10px; }
table.data td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tbody tr { cursor: pointer; }
table.data tbody tr:hover td { background: var(--surface-2); }
table.data td.nowrap { white-space: nowrap; }
.person b { display: block; font-weight: 800; }
.person span { color: var(--muted); font-size: 12px; }
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 800; padding: 1px 7px; border-radius: 99px; background: var(--surface-3); color: var(--ink-2); margin-left: 4px; vertical-align: 1px; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 12px; padding: 3px 9px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); white-space: nowrap; }
.pill .pd { width: 8px; height: 8px; border-radius: 50%; }
.pill.overdue { border-color: color-mix(in srgb, var(--crit) 40%, var(--line)); background: var(--crit-soft); }
.empty { text-align: center; padding: 36px 16px; color: var(--ink-2); }
.empty img { width: 110px; height: 106px; }
.empty h3 { margin: 6px 0; color: var(--ink); }
.empty .actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }

/* drawer & modal */
.scrim { position: fixed; inset: 0; background: rgba(10, 8, 20, .45); z-index: 60; animation: fade .15s; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(620px, 100%); background: var(--surface); z-index: 61; box-shadow: -20px 0 60px rgba(0, 0, 0, .25); display: flex; flex-direction: column; animation: slideIn .2s ease; }
.drawer-h { display: flex; gap: 12px; align-items: flex-start; padding: 18px 20px 12px; border-bottom: 1px solid var(--line); }
.drawer-h h2 { margin: 0; font-size: 20px; }
.drawer-h .grow { flex: 1; min-width: 0; }
.drawer-b { padding: 16px 20px 40px; overflow: auto; display: grid; gap: 18px; }
.drawer section h3 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.drawer .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.linkbox { display: flex; gap: 6px; }
.linkbox input { flex: 1; height: 34px; border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; background: var(--surface-2); font-size: 12px; min-width: 0; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 4px; display: grid; gap: 8px; border-left: 2px solid var(--line); }
.timeline li { padding-left: 12px; position: relative; }
.timeline li::before { content: ''; position: absolute; left: -7px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--muted); }
.timeline li.good::before { border-color: var(--good); background: var(--good); }
.timeline li.bad::before { border-color: var(--crit); }
.timeline li.mail::before { border-color: var(--accent); }
.timeline time { color: var(--muted); font-size: 12px; margin-left: 6px; }
table.mini { width: 100%; border-collapse: collapse; font-size: 13px; }
table.mini th { text-align: left; color: var(--muted); font-size: 11px; font-weight: 800; padding: 6px 8px; border-bottom: 1px solid var(--line); }
table.mini td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.yes { color: var(--good-text); font-weight: 800; }
.no { color: var(--crit); font-weight: 800; }
.modal-wrap { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 20px; }
.modal { width: min(560px, 100%); max-height: 90vh; overflow: auto; background: var(--surface); border-radius: 18px; box-shadow: 0 30px 80px rgba(0, 0, 0, .35); padding: 20px; animation: pop .18s ease; position: relative; z-index: 71; }
.modal.wide { width: min(860px, 100%); }
.modal h2 { margin: 0 0 4px; font-size: 19px; }
.modal p.lead { margin: 0 0 14px; color: var(--ink-2); }
.form { display: grid; gap: 12px; }
.form .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: grid; gap: 5px; }
.field > span { font-weight: 800; font-size: 12px; color: var(--ink-2); }
.field small { color: var(--muted); font-size: 12px; }
.field input[type=text], .field input[type=email], .field input[type=number], .field input[type=date], .field select, .field textarea { height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); padding: 0 12px; width: 100%; }
.field textarea { height: 160px; padding: 10px 12px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; resize: vertical; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 700; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); margin-top: 1px; flex: none; }
.check small { display: block; font-weight: 600; color: var(--muted); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.form-err { color: var(--crit); font-weight: 700; min-height: 18px; }
.settings { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; align-items: start; }
.settings .card-b { display: grid; gap: 12px; }
.save-bar { position: sticky; bottom: 0; display: flex; gap: 10px; align-items: center; justify-content: flex-end; padding: 12px 0; margin-top: 8px; background: linear-gradient(transparent, var(--page) 30%); }

/* policies */
.policy .card-h { flex-wrap: wrap; align-items: center; }
.policy .card-h .note { flex: 1 1 100%; }
.policy .settings > section { display: grid; gap: 12px; align-content: start; }
.sub-h { margin: 2px 0 0; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.policy .save-bar { position: static; background: none; padding: 12px 16px; margin: 0; border-top: 1px solid var(--line); }
.policy input:disabled { opacity: .5; }
.next-line { color: var(--ink-2); }

/* emails */
.mail-layout { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.mail-list tr.sel td { background: var(--accent-soft) !important; }
.mail-list td.msg { max-width: 0; width: 100%; }
.mail-list td.msg b, .mail-list td.msg > span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-list td.msg > span { color: var(--muted); font-size: 12px; }
.preview { position: sticky; top: 76px; }
.preview iframe { width: 100%; height: 70vh; border: 0; border-radius: 0 0 16px 16px; background: #f3f1fb; display: block; }
.preview-h { padding: 12px 16px; border-bottom: 1px solid var(--line); }
.preview-h b { display: block; }
.kind { font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 99px; background: var(--surface-3); color: var(--ink-2); white-space: nowrap; }
.kind.reminder_overdue { background: var(--crit-soft); color: var(--crit); }
.kind.completion { background: var(--good-soft); color: var(--good-text); }
.kind.invite { background: var(--accent-soft); color: var(--accent); }
.status-txt.failed { color: var(--crit); font-weight: 800; }

/* toasts */
#toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 200; display: grid; gap: 8px; }
.toast { background: var(--ink); color: var(--page); padding: 10px 16px; border-radius: 12px; font-weight: 700; box-shadow: 0 10px 30px rgba(0, 0, 0, .3); animation: pop .2s ease; display: flex; gap: 8px; align-items: center; }
.toast.err { background: var(--crit); color: #fff; }

@keyframes fade { from { opacity: 0; } }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } }
@keyframes pop { from { transform: scale(.96); opacity: 0; } }

@media (max-width: 1100px) {
  .grid.kpis { grid-template-columns: repeat(3, 1fr); }
  .grid.kpis .hero { grid-column: span 3; }
  .grid.two, .settings, .mail-layout { grid-template-columns: 1fr; }
  .preview { position: static; }
}
@media (max-width: 640px) {
  .grid.kpis { grid-template-columns: 1fr 1fr; }
  .grid.kpis .hero { grid-column: span 2; }
  .legend { grid-template-columns: 1fr 1fr; }
  .tabs { margin-left: 0; order: 3; width: 100%; overflow-x: auto; }
  .form .row2 { grid-template-columns: 1fr; }
  .filters input[type=search] { min-width: 0; flex: 1; }
  .meter-row { grid-template-columns: 100px 1fr 60px; }
}
@media print {
  .top, .banner, .page-head .actions, .filters { display: none !important; }
  body { background: #fff; }
}
