/* LegalScapes Quality Scorer. Brand tokens from brand/DESIGN.md (LegalScapes).
   --warn and --alert are functional status colors for report severity, not brand colors. */
@font-face {
  font-family: "Plus Jakarta Sans";
  src: url("/brand/PlusJakartaSans-latin.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("/brand/Inter-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --ink: #0f172a;          /* ink: headings, dark surfaces */
  --ink-muted: #334155;    /* body text on light */
  --green: #76a240;        /* primary */
  --green-dark: #5d8030;   /* primary-dark: hover, links on white */
  --green-light: #8fbf4d;  /* primary-light: accents on dark */
  --bg: #f1f5f9;           /* surface-alt */
  --surface: #ffffff;
  --line: #e2e8f0;         /* border */
  --muted: #64748b;
  --green-tint: #eef5e6;   /* 12% tint of primary */
  --warn: #ffb703;
  --alert: #fb8500;
  --warn-tint: #fff6dd;
  --alert-tint: #fff0e0;
  --on-dark: #cbd5e1;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink-muted);
  background: var(--bg);
  line-height: 1.55;
  font-size: 16px;
}
a { color: var(--green-dark); }
a:hover { color: var(--ink); }
h1, h2, h3, h4, .stat b, .gauge-card .g-label { font-family: "Plus Jakarta Sans", system-ui, sans-serif; color: var(--ink); }
:focus-visible { outline: 3px solid var(--green); outline-offset: 2px; border-radius: 4px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 10; }
.skip:focus { left: 8px; }
.mono { font-variant-numeric: tabular-nums; }
.small { font-size: 0.875rem; color: var(--muted); }

/* ---------- layout ---------- */
.topbar {
  background: var(--ink);
  color: #fff;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.topbar img { height: 32px; width: auto; display: block; }
.topbar a { color: #fff; text-decoration: none; font-weight: 600; font-size: 0.95rem; white-space: nowrap; }
.topbar a:hover { color: var(--green-light); }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 24px; }
.shell { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: calc(100vh - 58px); }
.side {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  overflow-y: auto;
  padding: 28px 18px;
  border-right: 1px solid var(--line);
  background: var(--surface);
}
.side h2 { font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 18px 10px 6px; }
.side a { display: block; padding: 7px 10px; border-radius: 8px; text-decoration: none; color: var(--ink); font-size: 0.93rem; }
.side a:hover, .side a.active { background: var(--green-tint); }
.side .foot { margin: 24px 10px 0; font-size: 0.8rem; color: var(--muted); }
.main { padding: 36px 40px 80px; max-width: 1000px; }

/* ---------- type ---------- */
h1 { font-size: clamp(1.9rem, 3.6vw, 2.8rem); line-height: 1.15; margin: 0 0 14px; letter-spacing: -0.02em; }
h1 em, h2 em { font-style: normal; color: var(--green); }
h2.headline { font-size: 1.6rem; line-height: 1.2; margin: 0 0 16px; letter-spacing: -0.01em; }
h3.sub { font-size: 1.05rem; margin: 28px 0 10px; }
h4 { margin: 0 0 8px; font-size: 1.02rem; }
.lead { font-size: 1.1rem; color: var(--muted); margin: 0 0 22px; max-width: 70ch; }
.eyebrow {
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--green-dark);
  margin: 0 0 10px;
}
.eyebrow .idx { color: var(--green); margin-right: 10px; }
section { margin: 0 0 56px; scroll-margin-top: 20px; }

/* ---------- hero (home) ---------- */
.hero-band { background: var(--ink); color: #fff; padding: 56px 0 64px; }
.hero-band .lead { color: var(--on-dark); }
.hero-band h1, .gate h2 { color: #fff; }
.hero-band h1 em { color: var(--green-light); }
.hero-band .eyebrow { color: var(--green-light); }
.rate-card {
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: var(--shadow);
  max-width: 720px;
}
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 0.95rem; }
.field input {
  width: 100%;
  font: inherit;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
}
.field input:focus { border-color: var(--green); outline: none; box-shadow: 0 0 0 3px rgba(118, 162, 64, 0.25); }
.help { font-size: 0.85rem; color: var(--muted); margin-top: 6px; }
.btn-row { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.btn {
  font: inherit;
  font-weight: 700;
  border: 0;
  border-radius: 10px;
  padding: 12px 22px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-dark); color: #fff; }
.btn-primary:disabled { opacity: 0.6; cursor: progress; }
.btn-secondary { background: var(--green-tint); color: var(--ink); }
.btn-secondary:hover { background: var(--green-light); }
.status { font-size: 0.92rem; color: var(--muted); }
.notice { border-radius: 10px; padding: 12px 16px; margin-top: 16px; }
.notice.error { background: var(--alert-tint); border: 1px solid var(--alert); }
.notice.info { background: var(--warn-tint); border: 1px solid var(--warn); }

/* ---------- cards and grids ---------- */
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card p { margin: 0; color: var(--muted); }
.card .eyebrow { margin-bottom: 6px; }
.dd { border-radius: var(--radius); padding: 18px 20px; border: 1px solid var(--line); background: var(--surface); }
.dd ul { margin: 0; padding-left: 20px; }
.dd li { margin: 4px 0; }
.dd.dont { border-left: 5px solid var(--alert); }
.dd.do { border-left: 5px solid var(--green); }
.dd.note { border-left: 5px solid var(--warn); background: var(--warn-tint); }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.kv div { font-size: 0.82rem; color: var(--muted); }
.kv b { display: block; font-size: 0.98rem; color: var(--ink); }

/* ---------- report head and gauges ---------- */
.report-top { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 28px; align-items: center; margin-bottom: 36px; }
.report-top h1 { font-size: clamp(1.5rem, 2.6vw, 2.1rem); }
.report-top .lead { font-size: 0.95rem; overflow-wrap: anywhere; }
.gauges { display: flex; gap: 16px; flex-wrap: wrap; }
.gauge-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px 10px; text-align: center; box-shadow: var(--shadow); width: 220px; }
.gauge-card svg { width: 100%; height: auto; display: block; }
.gauge-card .seg { fill: none; stroke: var(--line); stroke-width: 16; }
.gauge-card .seg.done { stroke: var(--green-light); }
.gauge-card .seg.on { stroke: var(--green); }
.gauge-card .seg.on.bad { stroke: var(--alert); }
.gauge-card .seg.done.bad { stroke: #fdd3a6; }
.gauge-card .g-label { font-size: 22px; font-weight: 800; fill: var(--ink); }
.gauge-card .g-title { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; fill: var(--muted); text-transform: uppercase; }
.gauge-card .g-end { font-size: 10px; fill: var(--muted); }

/* ---------- fixes ---------- */
.fixes { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.fixes li { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: start; }
.fixes .sev { font-size: 0.72rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; padding: 4px 8px; border-radius: 6px; white-space: nowrap; }
.sev.critical { background: var(--alert); color: var(--ink); }
.sev.important { background: var(--warn); color: var(--ink); }
.sev.opportunity { background: var(--green-tint); color: var(--ink); }
.fixes b { display: block; }

/* ---------- judgments ---------- */
.judgments { display: grid; gap: 12px; }
.jrow { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; }
.jrow.na { opacity: 0.6; }
.jhead { display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; }
.jhead .name { font-weight: 700; }
.jhead .right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.badge { font-size: 0.78rem; font-weight: 700; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.badge-good { background: var(--green); color: #fff; }
.badge-neutral { background: var(--green-tint); color: var(--ink); }
.badge-warn { background: var(--warn); color: var(--ink); }
.badge-bad { background: var(--alert); color: var(--ink); }
.badge-outline { border: 1px solid var(--line); color: var(--muted); }
.conf { font-size: 0.78rem; color: var(--muted); }
.dist { display: grid; gap: 3px; margin: 12px 0 4px; position: relative; height: 16px; }
.dist .seg { background: var(--green); border-radius: 3px; }
.dist .marker { position: absolute; top: -4px; width: 3px; height: 24px; background: var(--alert); border-radius: 2px; transform: translateX(-50%); }
.dist-labels, .bar-labels { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--muted); }
.bar { height: 10px; background: var(--green-tint); border-radius: 999px; overflow: hidden; margin: 12px 0 4px; }
.bar .fill { height: 100%; background: var(--green); }
.bar.problem .fill { background: var(--alert); }
.alts { font-size: 0.8rem; color: var(--muted); margin: 8px 0 0; }
.verdict-text { margin: 10px 0 0; }
.looks, .guide { font-size: 0.88rem; color: var(--muted); margin: 6px 0 0; }
.fix-quote { margin: 10px 0 0; padding: 8px 12px; border-left: 3px solid var(--line); background: var(--bg, #f8fafc); font-size: 0.92rem; }
.fix-quote .k, .suggestion .k { display: block; font-size: 0.7rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin-bottom: 2px; }
.suggestion { margin-top: 10px; padding: 10px 12px; border: 1px solid var(--green, #76a240); border-radius: 10px; background: rgba(118, 162, 64, 0.06); }
.suggestion p { margin: 4px 0 0; }
.suggestion .s-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.suggestion .copy { font: inherit; font-size: 0.78rem; font-weight: 700; padding: 3px 10px; border-radius: 6px; border: 1px solid var(--line); background: #fff; cursor: pointer; }
.adreview { list-style: none; padding: 0; margin: 0 0 8px; display: grid; gap: 12px; }
.adreview > li { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: start; }
.adreview b { display: block; }
.adreview .quotes { margin: 8px 0 0; padding-left: 18px; font-size: 0.9rem; font-style: italic; }
.adreview .sev { font-size: 0.72rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; padding: 4px 8px; border-radius: 6px; white-space: nowrap; }
.sev.ok { background: rgba(118, 162, 64, 0.14); color: var(--green-dark, #4d7a1f); }
.evidence { margin: 8px 0 0; padding-left: 18px; font-size: 0.88rem; color: var(--muted); }

/* ---------- manual checks ---------- */
.rules { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.rules > li { display: grid; grid-template-columns: 44px 1fr; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.rules .n { font-weight: 800; color: var(--green-dark); font-size: 1.2rem; }
.rules .t b { display: block; margin-bottom: 2px; }
.rules .t ul { margin: 8px 0 0; padding-left: 18px; color: var(--muted); font-size: 0.92rem; }

/* ---------- tables ---------- */
.dtable { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; font-size: 0.92rem; }
.dtable th, .dtable td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.dtable th { background: var(--green-tint); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; }
.dtable td.k { font-weight: 600; width: 34%; }
.dtable .num { text-align: right; white-space: nowrap; }
.dtable tr.doubted td { background: var(--alert-tint); }
details.markdown { margin-top: 10px; }
details.markdown summary { cursor: pointer; font-weight: 600; }
details.markdown pre { white-space: pre-wrap; word-break: break-word; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; max-height: 520px; overflow: auto; font-size: 0.82rem; }
details.howto { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 18px; }
details.howto summary { cursor: pointer; font-weight: 700; }

/* ---------- gate ---------- */
.gate { background: var(--ink); color: #fff; border-radius: var(--radius); padding: 28px; display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
.gate h2 { margin: 0 0 10px; }
.gate p { color: var(--on-dark); }
.gate ul { color: var(--on-dark); padding-left: 20px; }
.gate .field label { color: #fff; }
.gate .help { color: var(--on-dark); }

/* ---------- dashboard ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 28px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.stat b { display: block; font-size: 1.5rem; }
.stat span { font-size: 0.82rem; color: var(--muted); }
.tabs { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.tabs button { font: inherit; font-weight: 600; border: 1px solid var(--line); background: var(--surface); padding: 8px 16px; border-radius: 999px; cursor: pointer; color: var(--ink); }
.tabs button[aria-selected="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
textarea { width: 100%; font: inherit; font-size: 0.9rem; padding: 12px; border: 1.5px solid var(--line); border-radius: 10px; min-height: 140px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar select { font: inherit; padding: 9px 12px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); }
.toolbar input { font: inherit; padding: 9px 12px; border: 1.5px solid var(--line); border-radius: 10px; min-width: 260px; }

/* ---------- responsive and print ---------- */
@media (max-width: 480px) {
  .topbar img { height: 24px; }
  .topbar a { font-size: 0.85rem; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .main { padding: 24px 18px 60px; }
  .grid-3, .grid-2, .gate, .report-top { grid-template-columns: 1fr; }
}
@media print {
  .topbar, .side, .no-print, .gate { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; max-width: none; }
  body { background: #fff; }
  .jrow, .card, .dd, .fixes li { box-shadow: none; break-inside: avoid; }
  details.markdown { display: none; }
}
