/* ============================================================
   CLA AI Tax Automation — bespoke design system
   Self-contained (no external CSS framework) so a live demo
   never depends on a CDN staying up.
   ============================================================ */

:root {
  /* CLA-inspired palette: deep teal + warm ivory */
  --teal-900: #0b2e2b;
  --teal-800: #0f3d38;
  --teal-700: #135049;
  --teal-600: #1a6b60;
  --teal-500: #218a7c;
  --teal-400: #35b0a0;
  --teal-300: #6fd0c2;
  --gold-500: #c9a227;
  --gold-400: #e0bd47;

  --ink: #10201e;
  --paper: #f6f4ee;
  --paper-2: #ffffff;
  --line: #e3ded2;
  --muted: #5d6b68;

  --ok: #1f9d63;
  --warn: #c98a1e;
  --bad: #c0492f;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow-1: 0 1px 2px rgba(11, 46, 43, .06), 0 8px 24px rgba(11, 46, 43, .06);
  --shadow-2: 0 12px 40px rgba(11, 46, 43, .14);
  --font: "Inter var", "Segoe UI", system-ui, -apple-system, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Georgia, serif;

  --bg: var(--paper);
  --surface: var(--paper-2);
  --text: var(--ink);
  --text-soft: var(--muted);
  --border: var(--line);
  --brand: var(--teal-600);
  --brand-strong: var(--teal-700);
  --header-grad: linear-gradient(135deg, var(--teal-800), var(--teal-600));
}

:root[data-theme="dark"] {
  --bg: #0a1615;
  --surface: #10201e;
  --text: #eef3f1;
  --text-soft: #9db3ae;
  --border: #1e3330;
  --brand: var(--teal-400);
  --brand-strong: var(--teal-300);
  --shadow-1: 0 1px 2px rgba(0,0,0,.3), 0 10px 30px rgba(0,0,0,.35);
  --shadow-2: 0 16px 48px rgba(0,0,0,.5);
  --header-grad: linear-gradient(135deg, #0b2e2b, #135049);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
  transition: background .3s ease, color .3s ease;
}
a { color: var(--brand-strong); }
h1,h2,h3 { line-height: 1.15; letter-spacing: -0.01em; margin: 0; }
.hidden { display: none !important; }
.mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* ---------- App shell ---------- */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 24px;
  background: var(--header-grad);
  color: #eafaf6;
  box-shadow: var(--shadow-1);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; font-weight: 700; }
.brand .mark {
  width: 34px; height: 34px; border-radius: 9px;
  display: grid; place-items: center; font-weight: 800; color: var(--teal-900);
  background: linear-gradient(160deg, #ffffff, var(--teal-300));
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.5);
}
.brand small { display:block; font-weight: 500; opacity: .8; font-size: 12px; letter-spacing:.02em; }
.topbar .spacer { flex: 1; }
.topbar .pill {
  font-size: 12px; padding: 5px 11px; border-radius: 999px;
  background: rgba(255,255,255,.14); color: #eafaf6; border: 1px solid rgba(255,255,255,.18);
}
.topbar .pill.dot::before { content:"●"; color: var(--teal-300); margin-right:6px; font-size:10px; }
.icon-btn {
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.18);
  color: #eafaf6; border-radius: 9px; padding: 7px 10px; cursor: pointer; font-size: 14px;
}
.icon-btn:hover { background: rgba(255,255,255,.22); }

.wrap { max-width: 1180px; margin: 0 auto; padding: 28px 24px 80px; }

/* ---------- Buttons ---------- */
.btn {
  appearance:none; border:1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 11px 18px; border-radius: var(--radius-sm); font-weight: 600; font-size: 14px;
  cursor: pointer; transition: transform .06s ease, box-shadow .2s ease, background .2s;
  display:inline-flex; align-items:center; gap:8px;
}
.btn:hover { box-shadow: var(--shadow-1); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand); border-color: transparent; color: #fff; }
:root[data-theme="dark"] .btn.primary { color: #05100e; }
.btn.primary:hover { background: var(--brand-strong); }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-1);
}
.card.pad { padding: 22px; }
.grid { display: grid; gap: 18px; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-2 { grid-template-columns: 1.4fr 1fr; }
@media (max-width: 900px){ .grid.cols-3,.grid.cols-2 { grid-template-columns: 1fr; } }

.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: 11px; color: var(--brand); font-weight: 700; }
.muted { color: var(--text-soft); }
.h-hero { font-family: var(--serif); font-size: clamp(28px, 4vw, 44px); }
.stat { font-size: 30px; font-weight: 800; }

/* ---------- Login ---------- */
.login-stage {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(1200px 700px at 80% -10%, rgba(53,176,160,.20), transparent 60%),
    radial-gradient(900px 600px at -10% 110%, rgba(201,162,39,.14), transparent 55%),
    var(--bg);
}
.login-card { width: 100%; max-width: 430px; padding: 34px; }
.login-card .mark-lg {
  width: 54px; height:54px; border-radius: 14px; display:grid; place-items:center;
  font-weight:800; font-size:22px; color: var(--teal-900);
  background: linear-gradient(160deg, #fff, var(--teal-300)); margin-bottom: 18px;
}
.field { margin-top: 16px; }
.field label { display:block; font-size: 13px; font-weight:600; margin-bottom:7px; }
.input {
  width:100%; padding: 12px 14px; border-radius: 10px; border:1px solid var(--border);
  background: var(--bg); color: var(--text); font-size: 15px; outline: none;
}
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(53,176,160,.18); }
.err { color: var(--bad); font-size: 13px; margin-top: 10px; min-height: 18px; }

/* ---------- Upload / library ---------- */
.dropzone {
  border: 2px dashed var(--border); border-radius: var(--radius); padding: 40px;
  text-align:center; transition: border-color .2s, background .2s; cursor: pointer;
}
.dropzone.drag { border-color: var(--brand); background: rgba(53,176,160,.06); }
.dropzone .big { font-size: 40px; }
.lib-item {
  display:flex; align-items:center; gap:12px; padding: 12px 14px; border:1px solid var(--border);
  border-radius: 10px; cursor:pointer; background: var(--surface); transition: box-shadow .2s, border-color .2s;
}
.lib-item:hover { box-shadow: var(--shadow-1); border-color: var(--brand); }
.lib-item .doc { font-size: 20px; }

/* ---------- Pipeline ---------- */
.pipeline { display:flex; flex-direction:column; gap:2px; }
.step {
  display:flex; align-items:center; gap:14px; padding: 12px 16px; border-radius: 10px;
  color: var(--text-soft); transition: background .3s, color .3s;
}
.step .dot {
  width: 26px; height:26px; border-radius: 999px; border:2px solid var(--border);
  display:grid; place-items:center; font-size: 13px; flex: none; transition: all .3s;
}
.step.active { color: var(--text); background: rgba(53,176,160,.08); }
.step.active .dot { border-color: var(--brand); color: var(--brand); }
.step.done .dot { background: var(--brand); border-color: var(--brand); color:#fff; }
:root[data-theme=dark] .step.done .dot { color:#05100e; }
.step .label { font-weight: 600; flex:1; }
.spinner {
  width:16px;height:16px;border-radius:999px;border:2px solid rgba(53,176,160,.3);
  border-top-color: var(--brand); animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg);} }
.progress-track { height:6px; background: var(--border); border-radius:999px; overflow:hidden; margin-top:8px; }
.progress-fill { height:100%; background: linear-gradient(90deg, var(--brand), var(--teal-300)); width:0; transition: width .4s ease; }

/* ---------- Review split view ---------- */
.review { display:grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items:start; }
@media (max-width: 980px){ .review { grid-template-columns: 1fr; } }
.pdf-pane { position: sticky; top: 84px; }
.pdf-scroll { max-height: calc(100vh - 140px); overflow:auto; border-radius: 12px; background: #2b2b2b; padding: 10px; }
.pdf-scroll canvas { width:100%; margin-bottom: 10px; border-radius: 6px; box-shadow: 0 4px 14px rgba(0,0,0,.4); }
.pdf-fallback { padding: 30px; text-align:center; color: var(--text-soft); }

.summary-head { display:flex; flex-wrap:wrap; gap: 16px 26px; padding: 6px 2px 18px; }
.summary-head .kv .k { font-size: 11px; text-transform:uppercase; letter-spacing:.08em; color: var(--text-soft); }
.summary-head .kv .v { font-weight: 700; }

.field-row {
  border:1px solid var(--border); border-radius: 12px; padding: 14px 16px; margin-bottom: 12px;
  background: var(--surface); transition: border-color .2s;
}
.field-row.flagged { border-color: var(--warn); background: rgba(201,138,30,.06); }
.field-row .top { display:flex; align-items:center; gap:10px; }
.field-row .label { font-weight:600; flex:1; }
.chip {
  font-size:11px; padding: 3px 9px; border-radius:999px; border:1px solid var(--border);
  color: var(--text-soft); background: var(--bg); white-space: nowrap;
}
.field-row .val {
  margin-top: 10px; width:100%; padding:9px 12px; border:1px solid var(--border);
  border-radius:9px; background: var(--bg); color: var(--text); font-size:15px; font-weight:600;
}
.field-row .val:focus { outline:none; border-color: var(--brand); box-shadow:0 0 0 3px rgba(53,176,160,.16); }
.field-row .exp { margin-top:8px; font-size: 13px; color: var(--text-soft); }
.field-row .anom { margin-top:8px; font-size:13px; color: var(--warn); display:flex; gap:6px; }
.edited-tag { font-size:11px; color: var(--brand); font-weight:700; }

/* confidence meter */
.conf { display:flex; align-items:center; gap:8px; }
.conf .bar { width: 60px; height:6px; border-radius:999px; background: var(--border); overflow:hidden; }
.conf .bar span { display:block; height:100%; }
.conf .pct { font-size:11px; font-weight:700; }
.c-hi span { background: var(--ok);} .c-hi .pct{color:var(--ok);}
.c-mid span { background: var(--warn);} .c-mid .pct{color:var(--warn);}
.c-lo span { background: var(--bad);} .c-lo .pct{color:var(--bad);}

/* ---------- Timeline / audit ---------- */
.timeline { list-style:none; margin:0; padding:0; }
.timeline li { position: relative; padding: 0 0 18px 26px; border-left: 2px solid var(--border); }
.timeline li:last-child { border-color: transparent; }
.timeline li .node { position:absolute; left:-7px; top:2px; width:12px; height:12px; border-radius:999px; background: var(--brand); box-shadow: 0 0 0 3px var(--surface); }
.timeline .act { font-weight:600; text-transform: capitalize; }
.timeline .meta { font-size:12px; color: var(--text-soft); }

/* ---------- Tabs ---------- */
.tabs { display:flex; gap:6px; margin-bottom: 18px; flex-wrap: wrap; }
.tab { padding:9px 16px; border-radius: 999px; border:1px solid var(--border); background: var(--surface); cursor:pointer; font-weight:600; font-size:14px; }
.tab.active { background: var(--brand); color:#fff; border-color: transparent; }
:root[data-theme=dark] .tab.active { color:#05100e; }

/* ---------- Toast ---------- */
.toast-wrap { position: fixed; bottom: 22px; right: 22px; display:flex; flex-direction:column; gap:10px; z-index: 60; }
.toast { background: var(--surface); border:1px solid var(--border); border-left: 4px solid var(--brand); padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow-2); font-size: 14px; animation: rise .25s ease; }
@keyframes rise { from { transform: translateY(10px); opacity:0;} }

/* ---------- Footer ---------- */
.footer { text-align:center; color: var(--text-soft); font-size: 12px; padding: 30px 0 10px; }

/* fade utility */
.fade-in { animation: fade .4s ease; }
@keyframes fade { from { opacity:0; transform: translateY(6px);} }

/* appended: 10x upgrades below */

/* ---------- Overview / dashboard ---------- */
.hero {
  border-radius: 18px; padding: 30px 32px; color: #eafaf6; position: relative; overflow: hidden;
  background: var(--header-grad);
  box-shadow: var(--shadow-2);
}
.hero::after {
  content:""; position:absolute; inset:0;
  background: radial-gradient(700px 300px at 90% -30%, rgba(111,208,194,.35), transparent 60%);
  pointer-events:none;
}
.hero .eyebrow { color: var(--teal-300); }
.hero h1 { font-family: var(--serif); font-size: clamp(26px,3.6vw,40px); margin: 6px 0 8px; }
.hero p { max-width: 640px; opacity: .92; margin: 0; }
.hero .cta { margin-top: 18px; display:flex; gap:10px; flex-wrap:wrap; }
.hero .btn.on-hero { background: #fff; color: var(--teal-800); border:none; }
.hero .btn.on-hero.ghost { background: rgba(255,255,255,.12); color:#eafaf6; border:1px solid rgba(255,255,255,.3); }

.kpis { display:grid; grid-template-columns: repeat(4,1fr); gap:16px; margin-top:18px; }
@media (max-width: 900px){ .kpis { grid-template-columns: repeat(2,1fr);} }
.kpi { padding: 20px; }
.kpi .k { font-size:12px; text-transform:uppercase; letter-spacing:.08em; color: var(--text-soft); font-weight:700; }
.kpi .v { font-size: 34px; font-weight: 800; margin-top:6px; letter-spacing:-.02em; }
.kpi .sub { font-size:12px; color: var(--text-soft); margin-top:2px; }
.kpi .v .unit { font-size:16px; font-weight:700; color: var(--text-soft); margin-left:2px; }

.howto { display:grid; grid-template-columns: repeat(4,1fr); gap:14px; }
@media (max-width: 900px){ .howto { grid-template-columns: 1fr 1fr; } }
.howto .step-card { padding:18px; }
.howto .n { width:30px;height:30px;border-radius:999px;background:rgba(53,176,160,.14);color:var(--brand);
  display:grid;place-items:center;font-weight:800; margin-bottom:10px; }
.howto h3 { font-size:15px; margin-bottom:4px; }
.howto p { font-size:13px; color:var(--text-soft); margin:0; }

/* ---------- Confidence donut ---------- */
.donut-wrap { display:flex; align-items:center; gap:18px; }
.donut { width:104px; height:104px; flex:none; }
.donut .track { fill:none; stroke: var(--border); stroke-width:11; }
.donut .val { fill:none; stroke-width:11; stroke-linecap:round; transform: rotate(-90deg); transform-origin:center;
  transition: stroke-dashoffset 1s cubic-bezier(.2,.8,.2,1); }
.donut-center { font-size:22px; font-weight:800; }

/* ---------- Fed vs CA compare ---------- */
.compare { display:grid; grid-template-columns:1fr 1fr; gap:0; border:1px solid var(--border); border-radius:12px; overflow:hidden; }
@media (max-width:700px){ .compare { grid-template-columns:1fr; } }
.compare .col { padding: 4px 0; }
.compare .col + .col { border-left:1px solid var(--border); }
.compare .col h4 { font-size:12px; text-transform:uppercase; letter-spacing:.08em; padding:12px 16px; margin:0;
  background: rgba(53,176,160,.07); color: var(--brand); border-bottom:1px solid var(--border); }
.compare .col.ca h4 { background: rgba(201,162,39,.10); color: var(--gold-500); }
.crow { display:flex; justify-content:space-between; gap:10px; padding:9px 16px; font-size:13px; border-bottom:1px solid var(--border); }
.crow:last-child { border-bottom:none; }
.crow .cl { color: var(--text-soft); }
.crow .cv { font-weight:700; font-variant-numeric: tabular-nums; }

/* ---------- Sticky action bar ---------- */
.actionbar { position: sticky; bottom: 0; margin-top:16px; padding:14px; display:flex; gap:10px; flex-wrap:wrap;
  background: var(--surface); border:1px solid var(--border); border-radius:14px; box-shadow: var(--shadow-2); align-items:center; }
.actionbar .sum { flex:1; font-size:13px; color:var(--text-soft); }

/* ---------- Section header ---------- */
.sec-head { display:flex; align-items:center; justify-content:space-between; margin: 26px 0 12px; }
.sec-head h2 { font-size:20px; }

/* ---------- Skeleton ---------- */
.skel { background: linear-gradient(90deg, var(--border) 25%, rgba(53,176,160,.10) 37%, var(--border) 63%);
  background-size: 400% 100%; animation: shimmer 1.3s infinite; border-radius:8px; }
@keyframes shimmer { 0%{background-position:100% 0} 100%{background-position:0 0} }

/* ---------- Field group ---------- */
.group-label { font-size:12px; text-transform:uppercase; letter-spacing:.08em; color:var(--text-soft);
  font-weight:700; margin: 16px 0 8px; }
.count-up { font-variant-numeric: tabular-nums; }

/* ---------- Conjure card + preview modal ---------- */
.conjure { background:
  linear-gradient(120deg, rgba(53,176,160,.10), transparent 55%),
  var(--surface); border-color: color-mix(in srgb, var(--brand) 30%, var(--border)); }

.modal-backdrop { position: fixed; inset:0; z-index:80; background: rgba(6,16,14,.55);
  backdrop-filter: blur(3px); display:flex; align-items:center; justify-content:center; padding:24px; animation: fade .2s ease; }
.modal { width:min(960px, 96vw); max-height:92vh; display:flex; flex-direction:column; overflow:hidden; box-shadow: var(--shadow-2); }
.modal-head { display:flex; align-items:flex-start; justify-content:space-between; gap:12px; padding:18px 20px; border-bottom:1px solid var(--border); }
.modal-body { display:grid; grid-template-columns: 1.3fr 1fr; gap:0; min-height:0; flex:1; }
@media (max-width:760px){ .modal-body { grid-template-columns:1fr; } }
.modal-doc { padding:14px; overflow:auto; }
.modal-doc .pdf-scroll { max-height: 60vh; }
.modal-side { padding:20px; border-left:1px solid var(--border); display:flex; flex-direction:column; gap:8px; overflow:auto; }
@media (max-width:760px){ .modal-side { border-left:none; border-top:1px solid var(--border);} }
.modal-foot { display:flex; align-items:center; gap:10px; padding:14px 20px; border-top:1px solid var(--border); }
.xbtn { background:transparent; border:1px solid var(--border); color:var(--text-soft); border-radius:8px;
  width:34px; height:34px; cursor:pointer; font-size:15px; flex:none; }
.xbtn:hover { color:var(--text); border-color:var(--brand); }
.btn-loading { position:relative; color:transparent !important; }
.btn-loading::after { content:""; position:absolute; inset:0; margin:auto; width:16px; height:16px; border-radius:999px;
  border:2px solid rgba(255,255,255,.5); border-top-color:#fff; animation: spin .8s linear infinite; }

/* ---------- Logo ---------- */
.mark-img { width:36px; height:36px; border-radius:9px; display:block;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.35); }
.brand#brandHome { cursor:pointer; }
.brand#brandHome:hover { opacity:.92; }
.mark-lg-img { width:56px; height:56px; border-radius:14px; display:block; margin-bottom:18px;
  box-shadow: var(--shadow-1); }

/* ---------- ROI calculator ---------- */
.kpis.two { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 900px){ .kpis.two { grid-template-columns: 1fr; } }
.roi-grid { display:grid; grid-template-columns: 1fr 1.15fr; gap:22px; margin-top:16px; align-items:center; }
@media (max-width: 800px){ .roi-grid { grid-template-columns: 1fr; } }
.roi-inputs { display:flex; flex-direction:column; gap:12px; }
.roi-inputs label { display:flex; flex-direction:column; gap:6px; font-size:13px; font-weight:600; color:var(--text-soft); }
.roi-inputs input { padding:10px 12px; border-radius:9px; border:1px solid var(--border); background:var(--bg);
  color:var(--text); font-size:15px; font-weight:700; font-variant-numeric:tabular-nums; }
.roi-inputs input:focus { outline:none; border-color:var(--brand); box-shadow:0 0 0 3px rgba(53,176,160,.16); }
.roi-outputs { display:grid; grid-template-columns:1fr 1fr; gap:14px; }
.roi-out { background:var(--bg); border:1px solid var(--border); border-radius:12px; padding:16px; }
.roi-out .k { font-size:11px; text-transform:uppercase; letter-spacing:.07em; color:var(--text-soft); font-weight:700; }
.roi-out .v { font-size:26px; font-weight:800; margin-top:4px; font-variant-numeric:tabular-nums; letter-spacing:-.01em; }
.roi-out.hero { grid-column:1 / -1; background:linear-gradient(120deg, rgba(53,176,160,.14), transparent 70%);
  border-color: color-mix(in srgb, var(--brand) 35%, var(--border)); }
.roi-out.hero .v { font-size:36px; color:var(--brand-strong); }
