/* ═══════════════════════════════════════════════════════════════════════════
   DASHBOARD — the status page
   ═══════════════════════════════════════════════════════════════════════════

   Replaces the nine-tab sidebar shell (compup-dashboard.html plus compup-style's
   sidebar rules), which was a workbench: My Properties, Protests, Search,
   Reports, Payments, Notifications, Profile, Help — each a place to go and do
   something. The product does not work that way. A homeowner buys one report,
   is walked through filing once, and after that the only question they have is
   "where is my protest?" — a question they should mostly be answered by email
   before they think to come here.

   So this surface answers exactly that question and stops. Three sections:
   Status (the whole product), Reports (past years, without digging), Account.

   Two structural decisions worth keeping:

   1. **No sidebar, no app shell.** The page extends modern-layout, so the site
      header is the navigation. The old dashboard was a separate-looking
      application bolted to a marketing site, and the seam was visible the
      moment you signed in. The case record is the only chrome this surface
      earns.

   2. **The stage rail is the page.** Not a stat grid. The canonical stages in
      protest_status.py are the real state machine, the events behind them are
      dated, and the rail draws that directly — segments for the glance, a
      dated docket underneath for the reader who wants the record.

   Colour follows the house rules: green appears on savings figures and nowhere
   else, navy carries state and action, amber is for a clock the owner has to
   care about. Everything else is warm neutral.
═══════════════════════════════════════════════════════════════════════════ */

/* ── Page frame ─────────────────────────────────────────────────────────── */

.dash {
  --dash-measure: 880px;      /* the report body is 900px; this matches it */
  max-width: var(--dash-measure);
  margin: 0 auto;
  padding: 2.5rem 1.25rem 5rem;
}

@media (max-width: 640px) {
  .dash { padding: 1.5rem 1rem 4rem; }
}

.dash-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.dash-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.75rem;
  letter-spacing: -0.01em;
  line-height: 1.2;
  color: var(--text-strong);
  margin: 0;
}

.dash-sub {
  margin: 0.3rem 0 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

/* ── Section switch ─────────────────────────────────────────────────────── */
/* Three destinations do not want a sidebar or a row of oversized tabs. This is
   a segmented control: small, quiet, and the same pill shape the product
   already uses for filters. */

.dash-nav {
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.25rem;
  background: var(--surface-sunken);
  border: 1px solid var(--border-hairline);
  border-radius: 999px;
  margin-bottom: 2rem;
}

.dash-nav__btn {
  appearance: none;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  /* warm-600, not --text-muted. Muted measures 4.24:1 against the sunken pill
     this control sits on, which is under AA for 14px text — and these are the
     page's primary navigation, not a caption. warm-600 measures 7.1:1 and
     still sits clearly behind the selected tab's navy. */
  color: var(--warm-600);
  padding: 0.45rem 1.1rem;
  border-radius: 999px;
  cursor: pointer;
  transition: color 160ms ease, background-color 160ms ease;
}

.dash-nav__btn:hover { color: var(--text-strong); }

.dash-nav__btn[aria-selected="true"] {
  background: var(--surface-raised);
  color: var(--brand);
  box-shadow: 0 1px 2px rgba(26, 23, 20, 0.06);
}

.dash-nav__btn:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.dash-panel[hidden] { display: none; }

/* ── Case record ────────────────────────────────────────────────────────── */
/* One protest, one record. Deliberately not a grid of equal cards: there is
   normally exactly one of these, and it is the content, not a tile. */

.case {
  background: var(--surface-raised);
  border: 1px solid var(--border-hairline);
  border-radius: 14px;
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}

@media (max-width: 640px) {
  .case { padding: 1.15rem; border-radius: 12px; }
}

.case__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.case__ident { min-width: 0; }

.case__address {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.3rem;
  letter-spacing: -0.01em;
  line-height: 1.25;
  color: var(--text-strong);
  margin: 0;
  text-wrap: balance;
}

/* Focus lands here when "show more" reveals records, so the reader is not
   dropped back at the top. Same rule as the flow's step heading: a heading is
   not a control and must not paint a focus ring. */
.case__address:focus { outline: none; }

.case__meta {
  margin: 0.35rem 0 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* State pill. Sits beside the address rather than above it — a status word
   floating over a heading reads as an eyebrow, and the address is the thing
   the owner came to find. */
.case__state {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: var(--brand-subtle);
  color: var(--brand);
  border: 1px solid var(--navy-100);
  white-space: nowrap;
}

.case__state--waiting {
  background: var(--amber-50);
  color: var(--amber-600);
  border-color: var(--amber-100);
}

.case__state--done {
  background: var(--money-subtle);
  color: var(--money-700);
  border-color: var(--money-100);
}

.case__state-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

/* The live stage gets a slow pulse — the one authored motion on this page. It
   says "this is still moving" on a screen whose entire job is to answer that,
   and it is the only thing here that animates on its own. */
.case__state--live .case__state-dot {
  animation: case-pulse 2.4s cubic-bezier(0.22, 1, 0.36, 1) infinite;
}

@keyframes case-pulse {
  0%, 70%, 100% { opacity: 1; transform: scale(1); }
  35%           { opacity: 0.35; transform: scale(1.45); }
}

/* ── Stage rail ─────────────────────────────────────────────────────────── */
/* Segments, not dots-with-labels. Ten stages cannot carry ten legible labels
   at 360px, and a rail that only works on desktop is not a status page. The
   segments read as progress at any width; the stage is named once underneath,
   in words, and the full dated record is one disclosure away. */

.rail { margin: 1.35rem 0 0; }

.rail__track {
  display: flex;
  /* The gap between the two groups is the point: the owner's steps and the
     county's are different kinds of thing, and running them together is what
     made a finished filing look like unfinished work. */
  gap: 0.85rem;
  margin-bottom: 0.7rem;
}

.rail__phase {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  flex: var(--rail-weight, 1) 1 0;
  min-width: 0;
}

.rail__group {
  display: flex;
  gap: 3px;
}

/* Whose steps these are. The caption is the whole point of the split: an
   unlabelled dashed run reads as the owner's backlog, and a labelled one
   reads as somewhere the record has still to travel. */
.rail__phase-label {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* The county's half is not the owner's to finish, so it never reads as
   foreground. Even when it does advance, it stays quieter than their own. */
.rail__phase--county { opacity: 0.75; }

.rail__seg {
  height: 6px;
  flex: 1 1 0;
  border-radius: 999px;
  background: var(--warm-200);
  transition: background-color 260ms cubic-bezier(0.22, 1, 0.36, 1);
}

.rail__seg--done,
.rail__seg--current { background: var(--brand); }

/* A stage that cannot advance on its own — the county-side ones, in a county
   where we have no tracking feed. Drawn as a dashed remainder so the rail does
   not imply a clock that is not running. */
.rail__seg--unreachable {
  background: repeating-linear-gradient(
    90deg,
    var(--warm-300) 0 3px,
    transparent 3px 7px
  );
}

.rail__now {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.rail__count {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ── The now-line ───────────────────────────────────────────────────────── */
/* One sentence, in the owner's language, saying what is true and whether
   anything is wanted from them. This is the line most visits exist to read. */

.case__now {
  margin: 0.85rem 0 0;
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--text-body);
  max-width: 62ch;
}

.case__now strong { color: var(--text-strong); font-weight: 600; }

/* ── Savings line ───────────────────────────────────────────────────────── */
/* A sentence, not a stat tile. The figure is the only saturated thing on the
   record, per the money-green rule, and the wording stays conditional because
   the review board has not agreed to anything yet. */

.case__savings {
  margin: 1.15rem 0 0;
  padding-top: 1.15rem;
  border-top: 1px solid var(--border-hairline);
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--text-body);
  max-width: 62ch;
}

.case__figure {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.4rem;
  color: var(--money);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

/* ── Actions ────────────────────────────────────────────────────────────── */

.case__actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 1.15rem;
}

.btn {
  appearance: none;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: 10px;
  padding: 0.65rem 1.15rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  text-decoration: none;
  border: 1px solid transparent;
  transition: background-color 160ms ease, border-color 160ms ease,
              color 160ms ease, transform 160ms ease;
}

.btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.btn--primary {
  background: var(--brand);
  color: #ffffff;
  border-color: var(--brand);
}
.btn--primary:hover:not(:disabled) { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn--primary:active:not(:disabled) { transform: translateY(1px); }

.btn--quiet {
  background: var(--surface-raised);
  color: var(--text-body);
  border-color: var(--border-strong);
}
.btn--quiet:hover:not(:disabled) { color: var(--text-strong); border-color: var(--warm-400); }
.btn--quiet:active:not(:disabled) { transform: translateY(1px); }

.btn--bare {
  background: transparent;
  color: var(--brand);
  border-color: transparent;
  padding-inline: 0.35rem;
}
.btn--bare:hover:not(:disabled) { text-decoration: underline; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn.is-busy { position: relative; color: transparent; pointer-events: none; }
.btn.is-busy::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 15px;
  height: 15px;
  border: 2px solid #ffffff;
  border-top-color: transparent;
  border-radius: 50%;
  animation: btn-spin 700ms linear infinite;
}
.btn--quiet.is-busy::after,
.btn--bare.is-busy::after { border-color: var(--brand); border-top-color: transparent; }

@keyframes btn-spin { to { transform: rotate(360deg); } }

/* ── The dated record ───────────────────────────────────────────────────── */
/* Disclosed, not default. Complete when opened: every event, dated, in the
   order it happened, plus the stages still ahead. */

.docket { margin-top: 1.15rem; }

.docket__toggle {
  appearance: none;
  background: none;
  border: 0;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--brand);
  cursor: pointer;
  padding: 0.25rem 0;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.docket__toggle:hover { text-decoration: underline; }
.docket__toggle:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.docket__chevron { transition: transform 180ms cubic-bezier(0.22, 1, 0.36, 1); }
.docket__toggle[aria-expanded="true"] .docket__chevron { transform: rotate(90deg); }

.docket__list {
  list-style: none;
  margin: 0.9rem 0 0;
  padding: 0 0 0 1.35rem;
  border-left: 1px solid var(--border-hairline);
}

.docket__item {
  position: relative;
  padding-bottom: 1.05rem;
}
.docket__item:last-child { padding-bottom: 0; }

.docket__item::before {
  content: '';
  position: absolute;
  left: calc(-1.35rem - 4.5px);
  top: 0.35rem;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 3px var(--surface-raised);
}

.docket__item--ahead::before {
  background: var(--surface-raised);
  border: 1.5px solid var(--border-strong);
}

.docket__what {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-strong);
  line-height: 1.4;
}
.docket__item--ahead .docket__what { color: var(--text-muted); font-weight: 500; }

.docket__when {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  margin-top: 0.15rem;
}

.docket__note {
  font-size: 0.8125rem;
  color: var(--text-body);
  margin-top: 0.25rem;
  line-height: 1.45;
  max-width: 60ch;
}

/* ── Flags ──────────────────────────────────────────────────────────────── */

.flag {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  margin: 1.15rem 0 0;
  padding: 0.75rem 0.9rem;
  border-radius: 10px;
  background: var(--amber-50);
  border: 1px solid var(--amber-100);
  color: var(--amber-600);
  font-size: 0.875rem;
  line-height: 1.5;
}

.flag--error {
  background: var(--red-50);
  border-color: var(--red-100);
  color: var(--red-600);
}

.flag i { margin-top: 0.15rem; flex: none; }

/* ── Tables (Reports) ───────────────────────────────────────────────────── */

.dash-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border-hairline);
  border-radius: 12px;
  background: var(--surface-raised);
}

.dash-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  min-width: 34rem;
}

.dash-table th {
  text-align: left;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--surface-sunken);
  padding: 0.7rem 1rem;
  white-space: nowrap;
}

.dash-table td {
  padding: 0.85rem 1rem;
  border-top: 1px solid var(--border-hairline);
  color: var(--text-body);
  vertical-align: middle;
}

.dash-table td:first-child { color: var(--text-strong); font-weight: 500; }
.dash-table .num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.dash-table .row-actions { display: flex; gap: 0.35rem; white-space: nowrap; }

/* ── Account ────────────────────────────────────────────────────────────── */

.panel {
  background: var(--surface-raised);
  border: 1px solid var(--border-hairline);
  border-radius: 14px;
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}

@media (max-width: 640px) {
  .panel { padding: 1.15rem; border-radius: 12px; }
}

.panel__title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-strong);
  margin: 0 0 0.35rem;
}

.panel__hint {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin: 0 0 1.25rem;
  line-height: 1.5;
  max-width: 60ch;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

@media (max-width: 560px) {
  .field-grid { grid-template-columns: 1fr; }
}

.field { display: flex; flex-direction: column; gap: 0.35rem; min-width: 0; }
.field--wide { grid-column: 1 / -1; }

.field label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-body);
  letter-spacing: 0.01em;
}

.field input,
.field select {
  font: inherit;
  font-size: 0.9375rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface-raised);
  color: var(--text-strong);
  transition: border-color 160ms ease, box-shadow 160ms ease;
  min-width: 0;
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-ring);
}

.field input:disabled { background: var(--surface-sunken); color: var(--text-muted); }

.field input[aria-invalid="true"] { border-color: var(--state-error); }

.field__error {
  font-size: 0.75rem;
  color: var(--state-error);
  min-height: 1em;
  line-height: 1.3;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.75rem 0;
  border-top: 1px solid var(--border-hairline);
}
.check:first-of-type { border-top: 0; padding-top: 0; }

.check input { margin-top: 0.15rem; width: 1rem; height: 1rem; accent-color: var(--brand); flex: none; }
.check__label { font-size: 0.875rem; color: var(--text-strong); font-weight: 500; display: block; }
.check__hint { font-size: 0.8125rem; color: var(--text-muted); margin-top: 0.15rem; line-height: 1.45; }

/* ── Empty and loading states ───────────────────────────────────────────── */

.empty {
  text-align: center;
  padding: 3.5rem 1.5rem;
  background: var(--surface-raised);
  border: 1px solid var(--border-hairline);
  border-radius: 14px;
}

.empty__title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.25rem;
  color: var(--text-strong);
  margin: 0 0 0.5rem;
  letter-spacing: -0.01em;
}

.empty__body {
  font-size: 0.9375rem;
  color: var(--text-body);
  line-height: 1.6;
  margin: 0 auto 1.5rem;
  max-width: 46ch;
}

/* Skeletons rather than a spinner: the shape of the answer arrives before the
   answer does, so the page does not jump when it lands. */
.sk {
  display: block;
  background: linear-gradient(
    90deg,
    var(--warm-100) 0%,
    var(--warm-200) 50%,
    var(--warm-100) 100%
  );
  background-size: 200% 100%;
  border-radius: 8px;
  animation: sk-sweep 1.4s ease-in-out infinite;
}

@keyframes sk-sweep {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

/* ── Toast ──────────────────────────────────────────────────────────────── */

.dash-toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%) translateY(0.5rem);
  z-index: 9000;
  background: var(--warm-900);
  color: var(--warm-50);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.75rem 1.15rem;
  border-radius: 10px;
  box-shadow: 0 12px 24px -6px rgba(26, 23, 20, 0.24);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease, transform 200ms cubic-bezier(0.22, 1, 0.36, 1);
  max-width: min(90vw, 30rem);
}

.dash-toast.is-shown { opacity: 1; transform: translateX(-50%) translateY(0); }
.dash-toast--error { background: var(--red-600); }

@media (prefers-reduced-motion: reduce) {
  .sk { animation: none; }
  .case__state--live .case__state-dot { animation: none; }
  .btn.is-busy::after { animation-duration: 2s; }
  .rail__seg,
  .docket__chevron,
  .dash-toast,
  .btn { transition-duration: 0.01ms; }
}
