/* Legal InnovAI brand: orange for energy and highlights, white to breathe,
   near-black to ground. Orange is never a background or body-text color. */
:root {
  color-scheme: light;
  --bg: #f7f7f6;
  --surface: #ffffff;
  --surface-2: #f2f2f0;
  --border: #e4e4e1;
  --text: #1c1c1b;
  --text-2: #4d4d4a;
  --text-3: #7c7c77;
  --brand: #ea580c;        /* logo "AI", highlight bars, chart accent */
  --accent: #c2410c;       /* buttons and links: darker orange for contrast */
  --accent-hover: #9a3412;
  --accent-ink: #ffffff;
  --accent-soft: #fff1e6;
  --muted-mark: #cfcfca;
  --grid: #ececea;
  --high: #b42318;
  --high-bg: #fdecea;
  --medium: #8a6100;
  --medium-bg: #fbf3dc;
  --low: #4d4d4a;
  --low-bg: #efefed;
  --good: #1f7a3a;
  --good-bg: #e7f4ea;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.04);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211;
    --surface: #1a1a19;
    --surface-2: #242422;
    --border: #30302d;
    --text: #f0efec;
    --text-2: #c6c5bd;
    --text-3: #929089;
    --brand: #fb8a3c;
    --accent: #fb8a3c;
    --accent-hover: #fdba74;
    --accent-ink: #1a1a19;
    --accent-soft: #3a2414;
    --muted-mark: #4a4945;
    --grid: #2a2a27;
    --high: #f28b82;
    --high-bg: #3a1d1b;
    --medium: #e3b341;
    --medium-bg: #352b14;
    --low: #c6c5bd;
    --low-bg: #2a2a27;
    --good: #6cc486;
    --good-bg: #183223;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
h1 { font-size: 22px; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 15px; margin: 0; }
h3 { font-size: 14px; margin: 0; }
a { color: var(--accent); }
button, select, input, textarea { font: inherit; color: inherit; }
.hi { color: var(--brand); }

/* --- Top bar & nav --- */
.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 0 24px; height: 58px; background: var(--surface);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; flex-direction: column; text-decoration: none; color: var(--text); line-height: 1.1; }
.product { font-weight: 800; font-size: 17px; letter-spacing: -0.01em; }
.by { font-size: 11px; color: var(--text-3); font-weight: 600; }
.nav { display: flex; gap: 4px; height: 100%; }
.nav a {
  display: flex; align-items: center; padding: 0 12px; color: var(--text-2);
  text-decoration: none; font-weight: 600; border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.nav a:hover { color: var(--text); }
.nav a.active { color: var(--text); border-bottom-color: var(--brand); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.org { color: var(--text-3); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.ai-pill {
  font-size: 12px; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--border);
  color: var(--text-2); background: var(--surface-2); white-space: nowrap;
}
.ai-pill.on { color: var(--accent); border-color: color-mix(in srgb, var(--brand) 45%, transparent); background: var(--accent-soft); }

main { width: 100%; max-width: 1240px; margin: 0 auto; padding: 24px 24px 48px; display: grid; gap: 16px; flex: 1; align-content: start; }
main:focus { outline: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--text-2); }

.footer {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 14px 24px; border-top: 1px solid var(--border); color: var(--text-3); font-size: 12px; background: var(--surface);
}

@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 16px 0; gap: 8px 16px; }
  .nav { order: 3; width: 100%; overflow-x: auto; height: 42px; }
  .org { display: none; }
  main { padding: 16px; }
}

/* --- Buttons --- */
.btn {
  background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 8px;
  padding: 8px 14px; font-weight: 700; cursor: pointer; text-decoration: none; display: inline-block;
}
.btn:hover { background: var(--accent-hover); }
.btn[disabled] { opacity: 0.6; cursor: progress; }
.btn.secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); font-weight: 600; }
.btn.secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn.small, .mini {
  padding: 3px 9px; font-size: 12px; border-radius: 6px;
}
.mini { border: 1px solid var(--border); background: var(--surface-2); cursor: pointer; white-space: nowrap; font-weight: 600; }
.mini:hover { border-color: var(--accent); color: var(--accent); }
.mini.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.mini.primary:hover { background: var(--accent-hover); color: var(--accent-ink); }
.mini[disabled] { opacity: 0.6; cursor: progress; }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; font-size: 13px; font-weight: 600; }

/* --- Cards, KPIs --- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); min-width: 0;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.muted { color: var(--text-3); font-size: 12px; }
.eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-3); font-weight: 700; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.kpi .label { color: var(--text-2); font-size: 12px; }
.kpi .value { font-size: 26px; font-weight: 750; font-variant-numeric: tabular-nums; margin-top: 2px; }
.kpi .sub { color: var(--text-3); font-size: 12px; }
.kpi.alert .value { color: var(--high); }
.headline { border-left: 4px solid var(--brand); }
.headline-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.headline-text { font-size: 18px; font-weight: 700; margin: 4px 0 6px; }
.meta { color: var(--text-3); font-size: 12px; }
.meta .warn { color: var(--medium); }

.grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
@media (max-width: 900px) { .grid, .grid-2 { grid-template-columns: 1fr; } }

/* --- Badges --- */
.sev, .badge {
  font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap; display: inline-block;
}
.sev::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin-right: 5px; vertical-align: 1px; background: currentColor; }
.sev.high { color: var(--high); background: var(--high-bg); }
.sev.medium { color: var(--medium); background: var(--medium-bg); }
.sev.low { color: var(--low); background: var(--low-bg); }
.badge { background: var(--surface-2); color: var(--text-2); }
.badge.screening { color: var(--medium); background: var(--medium-bg); }
.badge.open { color: var(--accent); background: var(--accent-soft); }
.badge.closed { color: var(--good); background: var(--good-bg); }
.badge.referred, .badge.declined { color: var(--text-2); background: var(--low-bg); }
.badge.conf { color: var(--high); background: var(--high-bg); }

/* --- Insights & actions --- */
.insights, .actions { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.insight, .action { border: 1px solid var(--border); border-radius: 8px; padding: 12px; background: var(--surface); }
.row-top { display: flex; gap: 8px; align-items: baseline; }
.insight h3 { flex: 1; }
.insight p { margin: 6px 0 0; color: var(--text-2); }
.insight .why { color: var(--text); }
details.evidence { margin-top: 8px; }
details.evidence summary { cursor: pointer; color: var(--text-3); font-size: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip { font-size: 11.5px; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); color: var(--text-2); text-decoration: none; }
a.chip:hover { color: var(--accent); }
.action-title { font-weight: 700; }
.action-meta { color: var(--text-3); font-size: 12px; margin-top: 2px; }
.btn-row { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; align-items: center; }
.status-tag { font-size: 11px; color: var(--good); font-weight: 700; }
.empty { color: var(--text-3); padding: 12px 0; }

/* --- Deadlines --- */
.dl-group { margin-bottom: 12px; }
.dl-group h3 { font-size: 11px; color: var(--text-3); font-weight: 700; margin: 0 0 6px; text-transform: uppercase; letter-spacing: 0.05em; }
.dl { display: grid; grid-template-columns: 64px 1fr auto; gap: 10px; align-items: center; padding: 7px 0; border-top: 1px solid var(--grid); }
.dl:first-of-type { border-top: 0; }
.dl-date { font-variant-numeric: tabular-nums; color: var(--text-2); font-size: 12.5px; }
.dl-title { min-width: 0; }
.dl-title .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dl-title .o { color: var(--text-3); font-size: 12px; }
.dl.overdue .dl-date { color: var(--high); font-weight: 700; }
.dl.is-done .dl-date, .dl.is-done .t { color: var(--text-3); text-decoration: line-through; }
.kind { font-size: 11px; padding: 1px 6px; border-radius: 4px; background: var(--surface-2); color: var(--text-2); margin-right: 6px; }

/* --- Charts --- */
.chart-title { font-weight: 700; margin: 0 0 2px; }
.chart-sub { color: var(--text-3); font-size: 12px; margin: 0 0 8px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-2); margin-bottom: 4px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
svg text { fill: var(--text-2); font-size: 11px; }
.bar-track { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; position: relative; }
.bar-fill { height: 100%; background: var(--brand); border-radius: 4px; }
.bar-mark { position: absolute; top: -3px; width: 2px; height: 14px; background: var(--text-2); }

/* --- Tables --- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
table.data th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-3); font-weight: 700; padding: 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data td { padding: 8px; border-bottom: 1px solid var(--grid); vertical-align: middle; }
table.data tr.clickable { cursor: pointer; }
table.data tr.clickable:hover td { background: var(--surface-2); }
table.data .num { text-align: right; }

/* --- Forms --- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }
label.field { display: grid; gap: 4px; font-weight: 600; font-size: 13px; }
label.field .hint { font-weight: 400; color: var(--text-3); font-size: 12px; }
input[type="text"], input[type="number"], input[type="date"], input[type="search"], input[type="tel"], input[type="email"], input[type="password"], input[type="file"], select, textarea {
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; background: var(--surface); width: 100%;
}
.filters select, .filters input { width: auto; }
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 0; border-color: var(--brand); }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 600; font-size: 13px; }
.check input { margin-top: 3px; }
.errors { color: var(--high); background: var(--high-bg); border-radius: 8px; padding: 8px 12px; margin: 0; }
.callout { border-radius: 8px; padding: 10px 12px; background: var(--surface-2); }
.callout.good { background: var(--good-bg); }
.callout.warn { background: var(--medium-bg); }
.callout.bad { background: var(--high-bg); }
.callout h3 { margin-bottom: 4px; }
.callout ul { margin: 4px 0 0; padding-left: 18px; }

/* --- Detail pages --- */
.dl-list { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.dl-list dt { color: var(--text-3); font-size: 12.5px; }
.dl-list dd { margin: 0; }
.notes { list-style: none; padding: 0; margin: 0 0 10px; display: grid; gap: 8px; }
.notes li { border-left: 3px solid var(--border); padding: 2px 0 2px 10px; }
.notes .who { color: var(--text-3); font-size: 12px; }
.suggest { display: grid; gap: 6px; }
.suggest-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 0; border-top: 1px solid var(--grid); }
.suggest-row:first-child { border-top: 0; }
.back { font-size: 13px; text-decoration: none; font-weight: 600; }
.narrative { white-space: pre-wrap; min-height: 220px; line-height: 1.55; }
.skills { display: flex; gap: 4px; flex-wrap: wrap; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 8px 14px; border-radius: 8px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: opacity 0.2s; z-index: 10;
}
.toast.show { opacity: 1; }

/* --- Sign-in & account --- */
body.signed-out .app-only { display: none; }
.me { font-size: 12px; color: var(--text-2); white-space: nowrap; text-decoration: none; }
.me:hover { color: var(--accent); }
.auth-wrap { display: grid; place-items: center; padding: 32px 0; }
.auth-card { width: 100%; max-width: 420px; padding: 28px; }
.auth-card h1 { margin-bottom: 6px; }
.steps { padding-left: 20px; color: var(--text-2); }
.steps li { margin-bottom: 4px; }
.qr { display: grid; place-items: center; margin: 8px 0; }
.qr img { border-radius: 8px; background: #fff; padding: 6px; }
.codes {
  background: var(--surface-2); border-radius: 8px; padding: 12px 16px; font-size: 15px;
  columns: 2; font-variant-numeric: tabular-nums; letter-spacing: 0.04em;
}
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.callout.bad h3 { color: var(--high); }
@media (max-width: 900px) { .me { display: none; } }

/* --- Public apply form --- */
.apply-wrap { max-width: 760px; margin: 0 auto; width: 100%; display: grid; gap: 12px; }
.quick-exit {
  position: fixed; top: 12px; right: 12px; z-index: 20; background: var(--high); color: #fff; border: 0;
  border-radius: 999px; padding: 8px 14px; font-weight: 700; cursor: pointer; box-shadow: 0 2px 8px rgb(0 0 0 / 0.2);
}
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
