/* ===========================================================================
   Practice Tracker — the firm's visual language.

   The tokens are lifted verbatim from the marketing app's globals.css so the
   two feel like one firm rather than two vendors. Navy #0a2240 and gold
   #ffb347 are the authoritative brand values from brand/BRAND.md.

   Hand-authored rather than Tailwind-from-a-CDN, for three reasons that were
   all visible in the first version: the CDN build ignores the brand theme, so
   everything came out default slate; it blocks first paint while a megabyte of
   JavaScript compiles classes in the browser; and utility soup in the
   templates put the design in fifteen files at once, where it drifted.
   =========================================================================== */

:root {
  --navy: #0a2240;
  --navy-soft: #14345c;
  --navy-line: #1d3f68;
  --gold: #ffb347;
  --gold-deep: #d98b16;
  --paper: #faf8f4;
  --rule: #ece7dd;
  --ink: #16202e;
  --ink-muted: #6f6a5c;
  --surface: #ffffff;

  /* State. Held to three, so a row can only ever say one thing loudly. */
  --good: #1a7f4b;
  --good-bg: #e8f5ee;
  --warn: #b06a00;
  --warn-bg: #fdf1dd;
  --bad: #b42318;
  --bad-bg: #fdeceb;

  --radius: 0.5rem;
  --radius-sm: 0.3rem;
  --shadow-card: 0 1px 2px rgb(10 34 64 / 0.04), 0 1px 3px rgb(10 34 64 / 0.06);
  --shadow-pop: 0 4px 6px -1px rgb(10 34 64 / 0.1), 0 10px 24px -4px rgb(10 34 64 / 0.15);

  --sidebar-w: 216px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
  --font-num: ui-monospace, "SF Mono", "Cascadia Mono", "Segoe UI Mono",
              "Roboto Mono", monospace;
}

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

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

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p, figure, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ---------------------------------------------------------------------------
   Shell
   --------------------------------------------------------------------------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  background: var(--navy);
  color: #e8eef6;
  padding: 18px 12px 12px;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 18px;
}
.sidebar__brand img { width: 22px; height: auto; display: block; }
.sidebar__brand span { font-size: 13px; font-weight: 600; letter-spacing: -0.01em; }
.sidebar__brand small {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: #90a6c2;
  letter-spacing: 0;
}

.sidebar__section {
  padding: 14px 8px 6px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: #7f97b8;
}

.navlink {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  margin-bottom: 1px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  color: #cfdcec;
  transition: background 120ms, color 120ms;
}
.navlink:hover { background: var(--navy-soft); color: #fff; }
.navlink svg { width: 16px; height: 16px; flex: none; opacity: 0.85; }
.navlink[aria-current="page"] {
  background: var(--navy-soft);
  color: #fff;
  font-weight: 500;
  box-shadow: inset 2px 0 0 var(--gold);
}
.navlink[aria-current="page"] svg { opacity: 1; color: var(--gold); }
.navlink__count {
  margin-left: auto;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: #90a6c2;
}

.sidebar__foot {
  margin-top: auto;
  border-top: 1px solid var(--navy-line);
  padding-top: 10px;
  font-size: 12px;
  color: #90a6c2;
}
.sidebar__me { display: flex; align-items: center; gap: 8px; padding: 4px 8px 8px; }
.sidebar__me strong { font-weight: 500; color: #e8eef6; font-size: 12.5px; }
.sidebar__links { display: flex; gap: 10px; padding: 0 8px; font-size: 11.5px; }
.sidebar__links a:hover { color: #fff; text-decoration: underline; }

.main {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
}

.page { padding: 22px 28px 64px; max-width: 1500px; width: 100%; }

/* ---------------------------------------------------------------------------
   Page head
   --------------------------------------------------------------------------- */
.page-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.page-head h1 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.page-head .sub { font-size: 13px; color: var(--ink-muted); margin-top: 2px; }
.page-head .spacer { flex: 1; }
.page-head .actions { display: flex; align-items: center; gap: 8px; }

.breadcrumb {
  font-size: 12.5px;
  color: var(--ink-muted);
  margin-bottom: 6px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.breadcrumb:hover { color: var(--navy); }
.breadcrumb svg { width: 13px; height: 13px; }

/* ---------------------------------------------------------------------------
   Buttons
   --------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 120ms, border-color 120ms, box-shadow 120ms;
}
.btn:hover { background: var(--paper); border-color: #ddd7cc; }
.btn svg { width: 15px; height: 15px; }

.btn--primary {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}
.btn--primary:hover { background: var(--navy-soft); border-color: var(--navy-soft); }

.btn--ghost { background: transparent; border-color: transparent; color: var(--ink-muted); }
.btn--ghost:hover { background: var(--rule); color: var(--ink); }

.btn--sm { height: 27px; padding: 0 9px; font-size: 12.5px; }
.btn--danger { color: var(--bad); border-color: #f3d3d0; }
.btn--danger:hover { background: var(--bad-bg); }

/* Segmented control — the view switcher. */
.segmented {
  display: inline-flex;
  padding: 2px;
  gap: 2px;
  background: var(--rule);
  border-radius: var(--radius-sm);
}
.segmented a {
  padding: 4px 11px;
  border-radius: 4px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-muted);
}
.segmented a:hover { color: var(--ink); }
.segmented a[aria-current="true"] {
  background: var(--surface);
  color: var(--navy);
  box-shadow: var(--shadow-card);
}

/* ---------------------------------------------------------------------------
   Saved views — the row of chips that mirrors how the work is actually cut up
   --------------------------------------------------------------------------- */
.views {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding-bottom: 14px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--rule);
}
.view-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 29px;
  padding: 0 11px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-muted);
  background: transparent;
  transition: background 120ms, color 120ms, border-color 120ms;
}
.view-chip svg { width: 14px; height: 14px; flex: none; }
.view-chip:hover { background: var(--surface); border-color: var(--rule); color: var(--ink); }
.view-chip[aria-current="page"] {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}
.view-chip .n {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--rule);
  color: var(--ink-muted);
}
.view-chip[aria-current="page"] .n { background: var(--navy-line); color: #cfdcec; }
.view-chip--alert .n { background: var(--bad-bg); color: var(--bad); }
.view-chip--alert[aria-current="page"] .n { background: #7d1610; color: #ffd9d5; }

/* ---------------------------------------------------------------------------
   Cards
   --------------------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}
.card + .card { margin-top: 14px; }
.card__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--rule);
}
.card__head h2 { font-size: 13.5px; font-weight: 600; letter-spacing: -0.01em; }
.card__head .hint { font-size: 12px; color: var(--ink-muted); }
.card__head .spacer { flex: 1; }
.card__body { padding: 14px; }

.count-pill {
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--paper);
  border: 1px solid var(--rule);
  color: var(--ink-muted);
}

/* Summary tiles */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}
.tile {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow-card);
  display: block;
  transition: border-color 120ms, box-shadow 120ms;
}
a.tile:hover { border-color: #d8d0c2; box-shadow: var(--shadow-pop); }
.tile .k {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.tile .v {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  margin-top: 3px;
  line-height: 1.1;
}
.tile .foot { font-size: 12px; color: var(--ink-muted); margin-top: 2px; }
.tile--bad .v { color: var(--bad); }
.tile--warn .v { color: var(--warn); }
.tile--good .v { color: var(--good); }

/* ---------------------------------------------------------------------------
   The grid — the screen people actually work from
   --------------------------------------------------------------------------- */
.grid-wrap {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.grid-scroll { overflow-x: auto; }

table.grid {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

table.grid thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
  padding: 7px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-muted);
  white-space: nowrap;
}
table.grid thead th a { display: inline-flex; align-items: center; gap: 4px; }
table.grid thead th a:hover { color: var(--navy); }
table.grid thead th svg { width: 12px; height: 12px; }

table.grid td {
  padding: 0 12px;
  height: 38px;
  border-bottom: 1px solid #f4f1ec;
  vertical-align: middle;
}
table.grid tbody tr:last-child td { border-bottom: 0; }
table.grid tbody tr:hover td { background: #fcfbf9; }
table.grid tbody tr.is-overdue td:first-child { box-shadow: inset 3px 0 0 var(--bad); }
table.grid tbody tr.is-soon td:first-child { box-shadow: inset 3px 0 0 var(--warn); }

/* Group headings, the way the Airtable grid groups by client group. */
tr.group-row td {
  height: 30px;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
  border-top: 1px solid var(--rule);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink-muted);
}
tr.group-row .g-name { color: var(--ink); }
tr.group-row .g-count { font-weight: 500; }

.cell-client { font-weight: 500; }
.cell-client a:hover { text-decoration: underline; text-underline-offset: 2px; }
.cell-job { color: var(--ink-muted); }
.cell-period {
  font-family: var(--font-num);
  font-size: 11.5px;
  color: var(--ink-muted);
  white-space: nowrap;
}
.cell-date {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--ink-muted);
}
.cell-date.overdue { color: var(--bad); font-weight: 600; }
.cell-date.soon { color: var(--warn); font-weight: 500; }
.cell-date.none { color: #b9b2a4; font-style: italic; }
.col-num { text-align: right; font-variant-numeric: tabular-nums; }

.truncate { max-width: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------------------------------------------------------------------
   Pills
   --------------------------------------------------------------------------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 21px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
  border: 1px solid transparent;
}
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }

/* Stage colours. Deliberately the same hues as the Airtable base, so nobody
   has to relearn what a colour means on the day they switch. */
.stage-NOT_STARTED       { background: #f1efe9; color: #6b6559; border-color: #e4e0d6; }
.stage-IN_PREP           { background: #e7effa; color: #1f5fae; border-color: #d3e2f5; }
.stage-WAITING_ON_CLIENT { background: var(--warn-bg); color: #8a5300; border-color: #f6e2c2; }
.stage-IN_REVIEW         { background: #f0e9fb; color: #6b3fb5; border-color: #e2d6f6; }
.stage-READY             { background: #e2f4ec; color: #14724a; border-color: #cbe9db; }
.stage-DONE              { background: #eef0f2; color: #5b6673; border-color: #e0e4e8; }

.prio-URGENT { background: var(--bad-bg); color: var(--bad); border-color: #f6cfcb; }
.prio-HIGH   { background: var(--warn-bg); color: var(--warn); border-color: #f6e2c2; }
.prio-NORMAL { display: none; }
.prio-LOW    { display: none; }

.flag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  padding: 1px 7px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}
.flag--bad { background: var(--bad-bg); color: var(--bad); }
.flag--warn { background: var(--warn-bg); color: var(--warn); }
.flag--good { background: var(--good-bg); color: var(--good); }
.flag--mute { background: var(--paper); color: var(--ink-muted); border: 1px solid var(--rule); }
.flag svg { width: 12px; height: 12px; }

/* People */
.who { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.avatar {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--navy-soft);
  color: #fff;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.avatar--gold { background: var(--gold); color: var(--navy); }
.avatar--empty { background: var(--rule); color: #9a9284; }
.avatar--lg { width: 30px; height: 30px; font-size: 12px; }
.who--none { color: var(--warn); font-size: 12.5px; }

/* ---------------------------------------------------------------------------
   Inline editing. A stage or an owner changes in place; the row is swapped by
   the server. Nothing here navigates away, because a tracker you have to leave
   in order to update is a tracker nobody updates.
   --------------------------------------------------------------------------- */
.menu { position: relative; display: inline-block; }
.menu > summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  border-radius: 999px;
}
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary:hover .pill { filter: brightness(0.97); }
.menu[open] > summary .pill { box-shadow: 0 0 0 2px rgb(10 34 64 / 0.12); }

.menu__pop {
  position: absolute;
  z-index: 30;
  top: calc(100% + 5px);
  left: 0;
  min-width: 210px;
  padding: 5px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
}
.menu__pop--right { left: auto; right: 0; }
.menu__label {
  padding: 5px 8px 4px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.menu__item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.menu__item:hover { background: var(--paper); }
.menu__item[disabled] { opacity: 0.4; cursor: not-allowed; }
.menu__item[disabled]:hover { background: none; }
.menu__note {
  padding: 6px 8px 4px;
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--ink-muted);
  border-top: 1px solid var(--rule);
  margin-top: 4px;
}

.btn-quiet {
  border: 0;
  background: none;
  padding: 2px 5px;
  margin: -2px -5px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  font-size: 13px;
}
.btn-quiet:hover { background: var(--rule); }

/* ---------------------------------------------------------------------------
   Forms
   --------------------------------------------------------------------------- */
.field { display: block; margin-bottom: 12px; }
.field > .lbl {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-muted);
  margin-bottom: 4px;
}
.field .help { font-size: 11.5px; color: var(--ink-muted); margin-top: 4px; line-height: 1.45; }

.input, .select, .textarea {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid #ddd7cc;
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 13.5px;
}
.textarea { height: auto; padding: 8px 10px; resize: vertical; min-height: 68px; }
.select { appearance: none; padding-right: 28px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%236f6a5c' stroke-width='1.6'%3E%3Cpath d='M4 6.5 8 10.5l4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center; background-size: 15px; }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--navy-soft);
  box-shadow: 0 0 0 3px rgb(20 52 92 / 0.1);
}
.input::placeholder, .textarea::placeholder { color: #b3aca0; }

.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 820px) { .row-2, .row-3 { grid-template-columns: 1fr; } }

.check { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; cursor: pointer; }
.check input { width: 15px; height: 15px; accent-color: var(--navy); }

.search {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.search svg {
  position: absolute; left: 9px;
  width: 15px; height: 15px; color: var(--ink-muted); pointer-events: none;
}
.search input {
  height: 32px;
  width: 230px;
  padding: 0 10px 0 30px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 13px;
}
.search input:focus { outline: none; border-color: var(--navy-soft); box-shadow: 0 0 0 3px rgb(20 52 92 / 0.1); }

/* ---------------------------------------------------------------------------
   Messages
   --------------------------------------------------------------------------- */
.notice {
  display: flex;
  gap: 9px;
  padding: 10px 13px;
  border-radius: var(--radius);
  border: 1px solid;
  font-size: 13px;
  margin-bottom: 14px;
  line-height: 1.45;
}
.notice svg { width: 16px; height: 16px; flex: none; margin-top: 1px; }
.card__head svg, .empty svg, .tile svg { width: 15px; height: 15px; }
.flag svg, .pill svg { width: 12px; height: 12px; flex: none; }
.menu__item svg { width: 14px; height: 14px; margin-left: auto; color: var(--good); }
.search svg { width: 15px; height: 15px; }
.notice--bad { background: var(--bad-bg); border-color: #f3d3d0; color: #7d1610; }
.notice--warn { background: var(--warn-bg); border-color: #f6e2c2; color: #74450a; }
.notice--info { background: #eef3fa; border-color: #d8e4f3; color: #1c3f6e; }

.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--ink-muted);
  font-size: 13.5px;
}
.empty strong { display: block; color: var(--ink); font-weight: 600; margin-bottom: 3px; }

.muted { color: var(--ink-muted); }
.tiny { font-size: 11.5px; }
.nowrap { white-space: nowrap; }

/* Decree facts — Act 60 relationship context. */
.decree {
  border: 1px solid #e6dcc4;
  background: linear-gradient(0deg, #fffdf8, #fffaf0);
  border-radius: var(--radius);
  padding: 13px 15px;
  margin-bottom: 16px;
}
.decree h2 {
  font-size: 11px; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--gold-deep); margin-bottom: 8px;
}
.decree .who-line { font-weight: 500; font-size: 13px; }

/* Two-column detail layout */
.split { display: grid; grid-template-columns: minmax(0,1fr) 320px; gap: 16px; align-items: start; }
@media (max-width: 1080px) { .split { grid-template-columns: 1fr; } }

.deflist { display: grid; grid-template-columns: auto 1fr; gap: 7px 14px; font-size: 13px; }
.deflist dt { color: var(--ink-muted); white-space: nowrap; }
.deflist dd { margin: 0; }

.bar {
  height: 6px;
  border-radius: 999px;
  background: var(--rule);
  overflow: hidden;
}
.bar > span { display: block; height: 100%; background: var(--navy); border-radius: 999px; }
.bar > span.over { background: var(--bad); }
.bar > span.warn { background: var(--gold-deep); }

@media (max-width: 860px) {
  .sidebar {
    position: static;
    width: auto;
    flex-direction: row;
    align-items: center;
    gap: 4px;
    overflow-x: auto;
    padding: 8px 10px;
  }
  .sidebar__section, .sidebar__foot, .navlink__count { display: none; }
  .sidebar__brand { padding: 0 8px 0 0; }
  .shell { flex-direction: column; }
  .main { margin-left: 0; }
  .page { padding: 16px 14px 48px; }
}
