/* GovCapture AI - dashboard styles.
   No build step, no framework, no JavaScript, no external requests.
   Tokens come from brand.css (--gc-*); see docs/design/brand.md for the
   palette, the type scale and the contrast table. The old --bg/--surface/...
   names are kept below as aliases so inline styles and signup.html's <style>
   block keep working.

   landing.css loads after this file on the public pages and overrides every
   element-level rule here under body.public, so keep element selectors to
   the ones it already resets (body, a, h1-h3, p, :focus-visible, form
   controls, details/summary). */

@import url("/static/brand.css");

/* --- Tokens --------------------------------------------------------------- */

:root {
  /* Aliases onto the brand tokens. Dark mode flips inside brand.css, so
     nothing here needs its own media query. */
  --bg:          var(--gc-paper);
  --surface:     var(--gc-surface);
  --border:      var(--gc-line);
  --text:        var(--gc-ink);
  --muted:       var(--gc-muted);
  --accent:      var(--gc-accent);
  --accent-soft: var(--gc-accent-soft);
  --good:        var(--gc-verified);
  --good-soft:   var(--gc-verified-soft);
  --warn:        var(--gc-unverified);
  --warn-soft:   var(--gc-unverified-soft);
  --bad:         var(--gc-required);
  --bad-soft:    var(--gc-required-soft);
  --radius:      var(--gc-radius);
  --shadow:      var(--gc-shadow);
  --mono:        var(--gc-font-mono);

  /* Dashboard-only derived values. */
  --app-wrap:     1400px;
  --app-gutter:   var(--gc-gutter);
  --app-gap:      1.25rem;              /* space between cards */
  --card-pad-x:   1.25rem;
  --card-pad-y:   1.1rem;
  --row-tint:     var(--gc-paper);      /* zebra rows */
  --row-hover:    var(--gc-ink-soft);
  --ring:         3px solid var(--gc-accent);
  /* Text-input boundary. line-strong reads at ~2:1 against the paper fill,
     under the 3:1 non-text minimum, so inputs get a border derived from the
     tokens that clears it in both themes (light #838586, dark #76808C). */
  --field-border: var(--gc-muted);
}

@supports (color: color-mix(in srgb, red 50%, blue)) {
  :root { --field-border: color-mix(in srgb, var(--gc-muted) 55%, var(--gc-line-strong)); }
}

/* --- Base ------------------------------------------------------------------ */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--gc-font-sans);
  font-size: .9375rem;                  /* 15px: denser than the public 17px */
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: .16em;
  text-decoration-color: color-mix(in srgb, currentColor 45%, transparent);
}
a:hover { text-decoration-thickness: 2px; text-decoration-color: currentColor; }

/* Links that are the cell's whole content, and controls, do without the
   underline until hovered; the accent colour and position carry them. */
td > a, td > strong > a, th a, .brand, nav.main a, .btn, .skip-link { text-decoration: none; }
td > a:hover, td > strong > a:hover { text-decoration: underline; }

/* One focus ring everywhere. Never removed. */
:focus-visible {
  outline: var(--ring);
  outline-offset: 2px;
  border-radius: var(--gc-radius-sm);
}
main:focus { outline: none; }         /* skip-link target, not a control */

h1, h2, h3 { color: var(--text); text-wrap: balance; }
h1 {
  font-family: var(--gc-font-serif);
  font-weight: 500;
  font-size: clamp(1.55rem, 1.25rem + 1vw, 1.95rem);
  line-height: var(--gc-leading-tight);
  letter-spacing: -.012em;
  margin: 0 0 .3rem;
}
h2 {
  font-family: var(--gc-font-serif);
  font-weight: 500;
  font-size: 1.2rem;
  line-height: var(--gc-leading-snug);
  letter-spacing: -.008em;
  margin: 0 0 .75rem;
}
h3 {
  font-family: var(--gc-font-sans);
  font-weight: 600;
  font-size: .95rem;
  line-height: 1.35;
  letter-spacing: 0;
  text-transform: none;
  margin: 0 0 .5rem;
}

p { margin: 0 0 .75rem; }
p:last-child { margin-bottom: 0; }

strong { font-weight: 600; }
code {
  font-family: var(--mono);
  font-size: .86em;
  background: var(--gc-ink-soft);
  border-radius: var(--gc-radius-sm);
  padding: .08em .35em;
}
hr { border: 0; border-top: 1px solid var(--border); margin: var(--app-gap) 0; }

/* --- Top bar ----------------------------------------------------------------- */

header.topbar {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: var(--app-wrap);
  margin: 0 auto;
  padding: .5rem var(--app-gutter);
  min-height: 56px;
  display: flex;
  align-items: center;
  gap: .5rem 1.25rem;
  flex-wrap: wrap;
}

.brand {
  font-family: var(--gc-font-serif);
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -.01em;
  color: var(--text);
  white-space: nowrap;
  padding: .25rem 0;
}
.brand:hover { text-decoration: none; color: var(--text); }
.brand span { color: var(--accent); }

nav.main { display: flex; gap: .15rem; flex-wrap: wrap; flex: 1 1 auto; min-width: 0; }

nav.main a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: .35rem .6rem;
  border-radius: var(--gc-radius-sm);
  color: var(--muted);
  font-size: .85rem;
  font-weight: 500;
  white-space: nowrap;
  transition: background-color .12s ease, color .12s ease;
}
nav.main a:hover { background: var(--gc-ink-soft); color: var(--text); text-decoration: none; }
nav.main a.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  box-shadow: inset 0 -2px 0 var(--accent);
}

@media (max-width: 760px) {
  .topbar-inner { row-gap: .25rem; }
  nav.main { order: 3; flex-basis: 100%; gap: .1rem; padding-bottom: .25rem; }
  nav.main a { padding: .3rem .5rem; font-size: .82rem; min-height: 32px; }
}

/* --- Page layout --------------------------------------------------------------- */

main {
  max-width: var(--app-wrap);
  margin: 0 auto;
  padding: 1.5rem var(--app-gutter) 4rem;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: .75rem 1.5rem;
  flex-wrap: wrap;
  margin-bottom: var(--app-gap);
}
.page-head > div { min-width: 0; }
.subtitle {
  color: var(--muted);
  font-size: .9rem;
  line-height: 1.5;
  margin: 0;
  max-width: var(--gc-measure);
}

/* --- Cards & grids -------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--gc-radius-lg);
  padding: var(--card-pad-y) var(--card-pad-x);
  box-shadow: var(--shadow);
  margin-bottom: var(--app-gap);
  min-width: 0;
}
.card.tight { --card-pad-x: 1rem; --card-pad-y: .8rem; }
.card > :last-child { margin-bottom: 0; }

/* A card title reads like a document heading: hairline underneath. */
.card > h2 {
  padding-bottom: .55rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: .9rem;
}

.grid { display: grid; gap: var(--app-gap); margin-bottom: var(--app-gap); min-width: 0; }
.grid > .card { margin-bottom: 0; }
.grid > * { min-width: 0; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr)); }

/* Stat tiles on the home page. The number is set in the serif, like a price. */
.stat { text-align: left; }
.stat .value {
  font-family: var(--gc-font-serif);
  font-size: 2rem;
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  margin-top: .15rem;
}
.stat .sub { color: var(--muted); font-size: .8rem; margin-top: .25rem; }

/* Small uppercase label above a value (stat tiles, the scores in a page
   head). This is the "eyebrow" from the brand note. */
.label {
  color: var(--muted);
  font-size: .74rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  line-height: 1.3;
}

/* --- Tables ------------------------------------------------------------------------- */

/* Wide tables scroll inside the wrapper; the page itself never does. */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  min-width: 0;
}
/* Inside a card the table runs to the card's edges. */
.card > .table-wrap { margin-inline: calc(-1 * var(--card-pad-x)); }
.card > .table-wrap :is(th, td):first-child { padding-left: var(--card-pad-x); }
.card > .table-wrap :is(th, td):last-child  { padding-right: var(--card-pad-x); }

table {
  width: 100%;
  border-collapse: separate;            /* borders travel with sticky cells */
  border-spacing: 0;
  font-size: .875rem;
  line-height: 1.45;
}
th {
  text-align: left;
  padding: .55rem .6rem;
  color: var(--muted);
  background: var(--surface);
  font-size: .74rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  line-height: 1.3;
  border-bottom: 1px solid var(--gc-line-strong);
  white-space: nowrap;
  vertical-align: bottom;
}
td {
  padding: .5rem .6rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
tbody tr:last-child > td { border-bottom-color: transparent; }
tbody tr:nth-child(even) > td { background: var(--row-tint); }
tbody tr:hover > td { background: var(--row-hover); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.nowrap, th.nowrap { white-space: nowrap; }
td > strong { font-weight: 600; }

/* The header row stays put while the body scrolls. That needs the wrapper
   not to be a scroll container, so it only happens where every table fits
   without horizontal scrolling. The top bar is not sticky, so top: 0. */
@media (min-width: 1180px) {
  .table-wrap { overflow-x: visible; }
  thead th { position: sticky; top: 0; z-index: 2; }
}

.empty {
  color: var(--muted);
  padding: 1.5rem .75rem;
  text-align: center;
  font-size: .9rem;
}
td.empty { background: transparent; }
tbody tr:hover > td.empty { background: transparent; }

th .sort, th a.sort {
  color: inherit;
  display: inline-flex;
  gap: .3rem;
  align-items: center;
  border-radius: var(--gc-radius-sm);
}
th .sort:hover { color: var(--text); text-decoration: underline; }
th .sort[aria-sort] { color: var(--text); }   /* the column the table is sorted by */

/* --- Badges, scores, bars --------------------------------------------------------------- */

.badge {
  display: inline-block;
  padding: .14rem .5rem;
  border-radius: var(--gc-radius-sm);
  font-size: .74rem;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: .01em;
  white-space: nowrap;
  vertical-align: middle;
  border: 1px solid transparent;
}
.badge.neutral { background: var(--bg); color: var(--muted); border-color: var(--border); }
.badge.good { background: var(--good-soft); color: var(--good); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad  { background: var(--bad-soft);  color: var(--bad); }
.badge.info { background: var(--accent-soft); color: var(--accent); }

/* Scores scale with their context: table-cell size in a table, large in a
   page head where the template wraps them in a 2rem container. */
.score {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.5em;
  padding: .12em .45em;
  border-radius: var(--gc-radius-sm);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: max(.8rem, .8em);
  line-height: 1.4;
  border: 1px solid transparent;
}
.score.s-high { background: var(--good-soft); color: var(--good); }
.score.s-mid  { background: var(--warn-soft); color: var(--warn); }
.score.s-low  { background: var(--bg); color: var(--muted); border-color: var(--border); }

.bar {
  height: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-top: .3rem;
}
.bar > i { display: block; height: 100%; background: var(--accent); }

.tag-list { display: flex; gap: .35rem; flex-wrap: wrap; }

/* --- Evidence ------------------------------------------------------------------------------- */

.evidence {
  font-size: .78rem;
  line-height: 1.5;
  color: var(--muted);
  border-left: 2px solid var(--border);
  padding-left: .6rem;
  margin-top: .3rem;
}
.evidence a { overflow-wrap: anywhere; }

/* The two strings the product itself prints. Same chip treatment as the
   public pages' .tok: mono, bold, tinted. Never decorative. */
.unverified, .evidence-required {
  font-family: var(--mono);
  font-weight: 700;
  font-size: .76rem;
  letter-spacing: .02em;
  padding: .06em .35em;
  border-radius: var(--gc-radius-sm);
  white-space: nowrap;
}
.unverified        { color: var(--warn); background: var(--warn-soft); }
.evidence-required { color: var(--bad);  background: var(--bad-soft); }

.callout {
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  color: var(--text);
  padding: .7rem .95rem;
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: .88rem;
  line-height: 1.5;
  margin-bottom: 1rem;
}
.callout.good { border-left-color: var(--good); background: var(--good-soft); }
.callout.warn { border-left-color: var(--warn); background: var(--warn-soft); }
.callout.bad  { border-left-color: var(--bad);  background: var(--bad-soft); }
.callout > :last-child { margin-bottom: 0; }

/* --- Buttons ---------------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  min-height: 2.25rem;
  padding: .4rem .85rem;
  border: 1px solid var(--gc-line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: .85rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color .12s ease, border-color .12s ease, transform .12s ease;
}
.btn:hover { background: var(--gc-ink-soft); border-color: var(--text); color: var(--text); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--gc-accent-ink); }
.btn.primary:hover { filter: brightness(1.1); background: var(--accent); border-color: var(--accent); color: var(--gc-accent-ink); }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.danger:hover { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.btn.small { min-height: 1.85rem; padding: .25rem .6rem; font-size: .78rem; }
.btn:disabled, .btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; }
select.btn { padding-right: 1.6rem; }

.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.btn-row form { display: inline-flex; margin: 0; }

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  align-items: center;
  margin: .5rem 0 .35rem;
}

@media (prefers-reduced-motion: reduce) {
  .btn, nav.main a { transition: none; }
  .btn:active { transform: none; }
}

/* --- Forms -------------------------------------------------------------------------------------- */

.filters {
  display: flex;
  gap: .6rem .75rem;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 1rem;
}
.filters .field { flex: 1 1 10rem; min-width: 0; }
.filters .field input, .filters .field select { width: 100%; }
.filters .btn, .filters label.inline { flex: 0 0 auto; min-height: 2.25rem; }

.field { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.field label {
  font-size: .8rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}
.stack > * + * { margin-top: .85rem; }
.stack .field input:not([type=checkbox]):not([type=radio]),
.stack .field select,
.stack .field textarea { width: 100%; max-width: 40rem; }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=search], input[type=url], input[type=tel], input[type=date],
select, textarea {
  min-height: 2.25rem;
  padding: .4rem .65rem;
  border: 1px solid var(--field-border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: .9rem;
  line-height: 1.4;
  min-width: 0;
  max-width: 100%;
}
select { padding-right: .5rem; }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: var(--ring);
  outline-offset: 0;
  border-color: var(--accent);
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 1rem; height: 1rem; margin: 0; }
input[type=file] { font-size: .85rem; max-width: 100%; }
textarea { width: 100%; font-family: var(--mono); font-size: .82rem; line-height: 1.5; resize: vertical; }
label.inline {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-size: .85rem;
  color: var(--text);
  padding-block: .35rem;
}

/* An archive control that sits on one line inside a table cell. */
.inline-form {
  display: flex;
  gap: .4rem;
  align-items: center;
  margin-top: .35rem;
}
.inline-form input[type="text"] {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 1.85rem;
  font-size: .82rem;
  padding: .25rem .5rem;
}

/* --- Login ----------------------------------------------------------------------------------------- */

.login-wrap { max-width: 400px; margin: 10vh auto 4rem; padding: 0; }
.login-wrap .card { padding: 1.75rem; }
.login-wrap .field { margin-bottom: 1rem; }
.login-wrap input { width: 100%; }
.login-wrap .btn { width: 100%; min-height: 2.75rem; margin-top: .25rem; }

/* --- Misc ------------------------------------------------------------------------------------------- */

.muted { color: var(--muted); }
.small { font-size: .8rem; }
.mono { font-family: var(--mono); font-size: .82rem; }

.message-body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: var(--mono);
  font-size: .82rem;
  line-height: 1.6;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .9rem 1rem;
  max-height: 26rem;
  overflow-y: auto;
}

details summary {
  cursor: pointer;
  color: var(--accent);
  font-size: .85rem;
  font-weight: 600;
  padding: .3rem 0;
  border-radius: var(--gc-radius-sm);
}
details summary:hover { text-decoration: underline; }

footer.site {
  max-width: var(--app-wrap);
  margin: 0 auto;
  padding: 1rem var(--app-gutter) 2.5rem;
  color: var(--muted);
  font-size: .8rem;
  line-height: 1.55;
  border-top: 1px solid var(--border);
}

/* --- Paging, sorting and assistive affordances ------------------------------------------------ */

/* Visible only to assistive technology. Used where colour alone would
   otherwise carry meaning (score bands) or where a link needs more context. */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Keyboard users reach the table without walking the nav. */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  padding: .6rem 1rem;
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  border: 2px solid var(--accent);
  border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus { left: 0; outline-offset: 0; }

.pager {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem 1.25rem;
  align-items: center;
  justify-content: space-between;
  padding: .75rem var(--card-pad-x);
  border-top: 1px solid var(--border);
}
.card > .pager { margin-inline: calc(-1 * var(--card-pad-x)); }
.card > .pager:last-child { margin-bottom: calc(-1 * var(--card-pad-y)); }
.pager-count, .pager-links { margin: 0; color: var(--muted); font-size: .85rem; }
.pager-links { display: flex; gap: .5rem; flex-wrap: wrap; }

/* --- Narrow screens ----------------------------------------------------------------------------- */

@media (max-width: 640px) {
  main { padding-top: 1rem; padding-bottom: 3rem; }
  .card { --card-pad-x: 1rem; --card-pad-y: .9rem; border-radius: var(--gc-radius); }
  .stat .value { font-size: 1.6rem; }
  .page-head { align-items: flex-start; }
  .filters .btn { flex: 1 1 8rem; }
  .btn-row .btn, .row-actions .btn { max-width: 100%; white-space: normal; text-align: center; }
  .login-wrap { margin-top: 6vh; }
}

@media (max-width: 420px) {
  .brand { font-size: 1.1rem; }
  .topbar-inner { gap: .5rem .75rem; }
}

/* --- Print: the record is a document, so it prints like one ------------------------------------ */

@media print {
  @page { margin: 14mm; }
  body { background: #fff; color: #000; font-size: 10.5pt; }
  header.topbar, footer.site, .skip-link, .filters, .btn, .btn-row, .row-actions,
  .inline-form, .pager, form, details:not([open]) > :not(summary) { display: none !important; }
  main { max-width: none; padding: 0; }
  a { color: inherit; text-decoration: underline; }
  .evidence a[href^="http"]::after { content: " (" attr(href) ")"; font-size: .9em; word-break: break-all; }
  .card {
    box-shadow: none;
    border: 1px solid #999;
    border-radius: 0;
    padding: .6rem .8rem;
    margin-bottom: .8rem;
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .grid { display: block; }
  .grid > .card { margin-bottom: .8rem; }
  .table-wrap { overflow: visible; }
  .card > .table-wrap { margin-inline: 0; }
  .card > .table-wrap :is(th, td):first-child { padding-left: .4rem; }
  .card > .table-wrap :is(th, td):last-child  { padding-right: .4rem; }
  table { font-size: 9.5pt; }
  thead { display: table-header-group; }
  thead th { position: static; background: #fff; color: #000; border-bottom: 1px solid #000; }
  th, td { white-space: normal; padding: .3rem .4rem; border-bottom: 1px solid #bbb; }
  tbody tr:nth-child(even) > td, tbody tr:hover > td { background: transparent; }
  tr { break-inside: avoid; page-break-inside: avoid; }
  .message-body { max-height: none; overflow: visible; border-color: #999; background: #fff; }
  .badge, .score, .callout, .unverified, .evidence-required, .bar, .bar > i {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
  .badge, .score { border: 1px solid currentColor; }
  .callout { border: 1px solid #999; border-left-width: 3px; }
  h1, h2, h3 { break-after: avoid; page-break-after: avoid; }
}
