/* Keep 1031 platform -- one stylesheet for the console and the portal.
 *
 * BRAND: navy and gold, ring mark. Operator ruling 2026-08-13.
 *
 * EVERY COLOUR BELOW COMES FROM assets/brand/keep1031-tokens.css, which is
 * byte-identical to keep1031-ops/assets/brand/keep1031-tokens.css. The pack is
 * the palette; this file maps it onto local names and does the layout.
 *
 * The suite enforces both halves: no hex may appear here that is not in the
 * pack, and the pack must match the ops repo's copy. That is the whole
 * mechanism by which campaign mail and the product cannot drift apart -- which
 * they already had, silently, before the ruling. A colour is not the kind of
 * thing that fails a test on its own.
 *
 * SO: to change a colour, change it in BOTH copies of the pack and then here.
 * Adding a new one here without adding it to the pack fails the suite, which
 * is the intended amount of friction: an invented colour is how a second
 * palette starts.
 *
 * Colours are defined once on :root and only re-bound under the dark blocks,
 * so a token can never be defined solely inside a media query.
 */

:root {
  --navy-900: #081426;
  --navy-800: #0d1f38;
  --navy-700: #14304f;
  --navy-600: #1d4470;
  --gold-500: #c9a227;
  --gold-400: #d9b64a;
  --on-navy: #cfdcec;
  --on-navy-muted: #9db0c8;
  --navy-line: #35506f;

  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --fg: #101826;
  --muted: #5a6675;
  --line: #d8dee6;

  --accent: var(--navy-800);
  --accent-fg: #ffffff;

  --ok: #14683f;
  --ok-bg: #e6f4ec;
  --warn: #8a5a00;
  --warn-bg: #fdf1da;
  --critical: #8f1d1d;
  --critical-bg: #fbe6e6;
  --passed: #4a2570;
  --passed-bg: #efe7f7;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(8, 20, 38, .08), 0 4px 14px rgba(8, 20, 38, .06);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a1220;
    --surface: #101c2e;
    --surface-2: #16253a;
    --fg: #e8edf4;
    --muted: #97a5b8;
    --line: #24354e;
    --accent: var(--gold-500);
    --accent-fg: #0a1220;
    --ok: #7fd0a0;      --ok-bg: #12301f;
    --warn: #e5b862;    --warn-bg: #33270d;
    --critical: #f09b9b; --critical-bg: #3a1616;
    --passed: #c9a6f0;  --passed-bg: #271a3a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }

/* The `hidden` attribute has to win.
 *
 * Both front ends hide their chrome with `hidden` until they know who is
 * signed in. The browser implements that with `[hidden] { display: none }` in
 * its own stylesheet -- which any author rule beats, and `header.top` below
 * sets `display: flex`. The result was a signed-out console showing its
 * header and a "Sign out" button. Found in a browser, because it is invisible
 * to anything checking HTTP responses.
 *
 * !important because the whole point is that it outranks whatever a component
 * rule says about display. This is the one place in the file it is warranted.
 */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--navy-600); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) a { color: var(--gold-400); } }

/* -- the shell ------------------------------------------------------------
 *
 * Persistent left navigation, ruled. The whole product is two clicks deep:
 * the nav is click one and it never goes away, so no screen is ever reached
 * by remembering where you came from.
 *
 * The sidebar is fixed on desktop and collapses to a horizontal strip under
 * 900px. It does not become a hamburger: a coordinator working a deadline
 * board on a tablet should be able to see where else they can go without
 * opening something first.
 */

.shell { display: flex; min-height: 100vh; align-items: stretch; }

.sidebar {
  flex: 0 0 208px;
  background: var(--navy-800);
  color: var(--on-navy);
  display: flex;
  flex-direction: column;
  padding: 14px 0 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 9px;
  padding: 0 16px 16px; margin-bottom: 4px;
}
.sidebar .brandname { font-weight: 600; font-size: 15px; color: #fff;
                      letter-spacing: .01em; }
.navgroup {
  font-size: 10px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--on-navy-muted); padding: 14px 16px 5px; font-weight: 600;
}
.navitem {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 16px; color: var(--on-navy); text-decoration: none;
  font-size: 13.5px; border-left: 3px solid transparent;
}
.navitem:hover { background: rgba(255, 255, 255, .05); color: #fff; }
.navitem.active {
  background: rgba(201, 162, 39, .12);
  border-left-color: var(--gold-500);
  color: #fff; font-weight: 600;
}
/* Grayed, not hidden: an operator who can see that Accounting is coming and
   is not here yet knows more than one who sees six items and wonders. */
.navitem.disabled { color: var(--on-navy-muted); opacity: .45; cursor: default; }
.navitem.disabled:hover { background: none; color: var(--on-navy-muted); }
.navicon { width: 16px; text-align: center; opacity: .85; font-size: 12px; }

.sidefoot {
  margin-top: auto; padding: 14px 16px; font-size: 12px;
  color: var(--on-navy-muted); border-top: 1px solid var(--navy-line);
}
.sidefoot button {
  background: transparent; border: 1px solid var(--navy-line);
  color: var(--on-navy); font-size: 12px; padding: 5px 10px; margin-top: 8px;
}
.sidefoot button:hover { border-color: var(--gold-500); color: var(--gold-400); }

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }

@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .sidebar {
    flex: none; height: auto; position: static;
    flex-direction: row; flex-wrap: wrap; align-items: center;
    padding: 8px 10px; gap: 2px;
  }
  .sidebar .brand { padding: 0 10px 0 4px; margin: 0; }
  .navgroup { display: none; }
  .navitem { border-left: 0; border-bottom: 3px solid transparent;
             padding: 6px 10px; }
  .navitem.active { border-left: 0; border-bottom-color: var(--gold-500); }
  .sidefoot { margin: 0 0 0 auto; border: 0; padding: 0 6px;
              display: flex; align-items: center; gap: 10px; }
  .sidefoot button { margin: 0; }
}

/* margin-inline:auto matters in both contexts and was dropped once in the
   shell refactor: inside .content it centres the column on a wide monitor,
   and outside the shell -- the signed-out screens render in a bare <main> --
   its absence left the sign-in card pinned to the left of the window. */
main { padding: 22px 26px; max-width: 1320px; margin-inline: auto; width: 100%; }

/* -- typographic rhythm ---------------------------------------------------
 * Section headings are small caps in muted ink so that the DATA is the
 * loudest thing on a board screen. A deadline chip has to win a glance
 * against everything around it; a heading competing with it costs the
 * half-second that made the board worth building.
 */
h1.page { font-size: 20px; margin: 0 0 2px; font-weight: 650;
          letter-spacing: -.01em; }
.pagesub { color: var(--muted); font-size: 13px; margin: 0 0 18px; }
h2 { font-size: 11px; text-transform: uppercase; letter-spacing: .09em;
     color: var(--muted); margin: 22px 0 8px; font-weight: 600; }
h2:first-child { margin-top: 0; }

/* Pipeline-by-stage cards. Counts read at a glance; the value underneath is
   the number a QI actually wants off this screen — "how much is committed and
   when does it land" rather than "how many prospects". */
.statrow { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.stat { flex: 1 1 130px; background: var(--surface); border: 1px solid var(--line);
        border-radius: var(--radius); padding: 11px 13px; box-shadow: var(--shadow); }
.statlabel { font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em;
             color: var(--muted); font-weight: 600; }
.statvalue { font-size: 22px; font-weight: 700; line-height: 1.15;
             font-variant-numeric: tabular-nums; }
.statsub { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

table.kv td { padding: 5px 8px 5px 0; border-bottom: 1px solid var(--line); }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
           margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }
.toolbar input[type="search"] { max-width: 280px; }

/* -- cards, tables ------------------------------------------------------ */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card + .card { margin-top: 14px; }
.card .pad { padding: 16px; }

.scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th {
  text-align: left; font-weight: 600; font-size: 10.5px; text-transform: uppercase;
  letter-spacing: .07em; color: var(--muted); padding: 9px 12px;
  border-bottom: 1px solid var(--line); white-space: nowrap;
  background: var(--surface-2);
}
/* Denser than Phase 1. A deadline board is read by scanning a column, and
   scanning gets worse as the eye has to travel further between rows. 8px is
   about the floor before rows stop reading as separate. */
td { padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
tbody tr.clickable { cursor: pointer; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.tight { white-space: nowrap; }
.mono { font-family: var(--mono); font-size: 12.5px; }

/* -- the countdown chip: the whole point of the board --------------------
 *
 * This is the one element on the console allowed to shout. Everything else
 * is deliberately quiet so that a red chip is visible from across a desk.
 *
 * The number and the caption are on one line rather than stacked: at a glance
 * "5d to day 45" reads as a fact, whereas a big number over small text reads
 * as a statistic and makes the eye stop to work out which deadline it is.
 * The left border is a second channel for the same information, so the board
 * still sorts visually for a colour-blind reader.
 */

.days {
  display: inline-flex; align-items: baseline; gap: 5px;
  padding: 3px 9px 3px 7px; border-radius: 5px; font-weight: 700;
  font-variant-numeric: tabular-nums; font-size: 13px; white-space: nowrap;
  border-left: 3px solid currentColor;
}
.days.ok       { background: var(--ok-bg);       color: var(--ok); }
.days.warn     { background: var(--warn-bg);     color: var(--warn); }
.days.critical { background: var(--critical-bg); color: var(--critical); }
.days.passed   { background: var(--passed-bg);   color: var(--passed); }
.days.none     { background: var(--surface-2);   color: var(--muted); }
.days small { font-weight: 500; font-size: 10.5px; opacity: .75;
              letter-spacing: .02em; }
/* Critical gets weight as well as colour — the only element in the product
   that is allowed both. */
.days.critical { box-shadow: inset 0 0 0 1px var(--critical); }

.chip {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; border: 1px solid transparent;
  margin: 1px 4px 1px 0; white-space: nowrap;
}
.chip.neutral  { background: var(--surface-2); color: var(--muted); }
.chip.warn     { background: var(--warn-bg); color: var(--warn); }
.chip.critical { background: var(--critical-bg); color: var(--critical);
                 border-color: var(--critical); }
.chip.ok       { background: var(--ok-bg); color: var(--ok); }

/* -- forms and buttons -------------------------------------------------- */

button, .btn {
  font: inherit; font-weight: 600; font-size: 14px;
  padding: 8px 14px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--fg);
}
button.primary {
  background: var(--accent); color: var(--accent-fg); border-color: var(--accent);
}
button.danger { border-color: var(--critical); color: var(--critical); }
button:disabled { opacity: .5; cursor: not-allowed; }

label { display: block; font-size: 12px; font-weight: 600; color: var(--muted);
        margin: 12px 0 4px; text-transform: uppercase; letter-spacing: .05em; }
input, select, textarea {
  font: inherit; width: 100%; padding: 9px 11px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--fg);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--gold-500); outline-offset: 1px; border-color: var(--gold-500);
}
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
         gap: 0 16px; }

.notice { padding: 12px 14px; border-radius: 8px; font-size: 14px; margin: 12px 0; }
.notice.critical { background: var(--critical-bg); color: var(--critical);
                   border: 1px solid var(--critical); }
.notice.warn { background: var(--warn-bg); color: var(--warn); }
.notice.info { background: var(--surface-2); color: var(--muted); }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.right { text-align: right; }

/* -- sign-in ------------------------------------------------------------ */

.signin { max-width: 400px; margin: 8vh auto; }
.signin .card .pad { padding: 26px; }
.signin .mark { display: block; margin: 0 auto 18px; }

/* -- milestone chain ---------------------------------------------------- */

.chain { list-style: none; margin: 0; padding: 0; }
.chain li { display: flex; gap: 12px; align-items: flex-start;
            padding: 9px 0; border-bottom: 1px solid var(--line); }
.chain li:last-child { border-bottom: 0; }
.chain .dot { flex: 0 0 auto; width: 18px; height: 18px; border-radius: 50%;
              border: 2px solid var(--line); margin-top: 2px; }
.chain li.complete .dot { background: var(--ok); border-color: var(--ok); }
.chain li.in_progress .dot { border-color: var(--gold-500); border-width: 4px; }
.chain li.na .dot { background: var(--surface-2); }
.chain .label { flex: 1; }
.chain li.complete .label { color: var(--muted); }

/* The portal's entity switcher: buttons rather than a <select>, because on a
   phone a select is a modal wheel and this is the control a person uses most.
   Renders only when there is more than one taxpayer to switch between. */
.switcher { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.switcher button { display: inline-flex; align-items: center; gap: 6px;
                   font-size: 13.5px; }

dialog {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 0;
  background: var(--surface); color: var(--fg); max-width: 640px; width: 92vw;
  box-shadow: 0 12px 48px rgba(8, 20, 38, .35);
}
dialog::backdrop { background: rgba(8, 20, 38, .55); }
dialog .pad { padding: 20px; }
dialog h3 { margin: 0 0 4px; font-size: 17px; }

footer.legal { color: var(--muted); font-size: 12px; padding: 30px 20px;
               text-align: center; }
