/* Design tokens.

   Colour means status and nothing else. Everything structural is a neutral,
   and the four status tones are the only saturated things on the page. If the
   chrome is coloured, nothing reads as urgent. */

:root {
  --ink:        #14161a;
  --ink-2:      #4a5058;
  --ink-3:      #767d86;

  --paper:      #ffffff;
  --paper-2:    #f7f7f5;
  --paper-3:    #eeeeeb;

  --line:       #e0e0dc;
  --line-2:     #c9c9c4;

  /* Status. Muted on purpose: a board of twenty-two units should not look
     like a fruit machine. */
  --good:       #1a6b3c;
  --good-bg:    #e8f2ec;
  --warn:       #8a5a00;
  --warn-bg:    #fbf1de;
  --bad:        #a8322a;
  --bad-bg:     #fbeae8;
  --info:       #1f4f7a;
  --info-bg:    #e9f0f6;

  --accent:     #14161a;

  /* A 1.2 scale from 13px. Small, because this is a dense operations tool
     read forty times a day, not a landing page. */
  --t-xs:   11px;
  --t-sm:   13px;
  --t-base: 14px;
  --t-md:   16px;
  --t-lg:   19px;
  --t-xl:   23px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  --radius: 3px;
  --nav-height: 52px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto,
          "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

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

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

body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--t-base);
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper-2);
  /* Tabular figures so deadline and duration columns align down the page. */
  font-variant-numeric: tabular-nums;
}

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: var(--t-xl); }
h2 { font-size: var(--t-lg); }
h3 { font-size: var(--t-md); }

a { color: var(--ink); text-decoration-color: var(--line-2); text-underline-offset: 2px; }
a:hover { text-decoration-color: var(--ink); }

/* --- Shell --- */

.masthead {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  height: var(--nav-height);
  padding: 0 var(--space-5);
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.masthead__mark {
  font-weight: 600;
  font-size: var(--t-md);
  letter-spacing: -0.02em;
  text-decoration: none;
}

.masthead__org {
  font-size: var(--t-sm);
  color: var(--ink-2);
  padding-left: var(--space-4);
  border-left: 1px solid var(--line);
}

.masthead__spacer { flex: 1; }

.nav { display: flex; gap: var(--space-1); }

.nav a {
  padding: var(--space-2) var(--space-3);
  font-size: var(--t-sm);
  color: var(--ink-2);
  text-decoration: none;
  border-radius: var(--radius);
}

.nav a:hover { background: var(--paper-3); color: var(--ink); }

/* A weight change and a rule, rather than a filled pill. */
.nav a[aria-current="page"] {
  color: var(--ink);
  font-weight: 550;
  box-shadow: inset 0 -2px 0 var(--ink);
  border-radius: 0;
}

.shell { max-width: 1400px; margin: 0 auto; padding: var(--space-5); }

.page-head {
  display: flex;
  align-items: baseline;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.page-head p { margin: 0; color: var(--ink-3); font-size: var(--t-sm); }

/* --- Surfaces ---
   A border and a background shift group things. No shadow, no gradient. */

.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--line);
}

.panel__head h2 { font-size: var(--t-sm); font-weight: 600; color: var(--ink-2); }
.panel__body { padding: var(--space-4); }

/* --- Tables --- */

table { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }

th {
  text-align: left;
  font-weight: 500;
  font-size: var(--t-xs);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

td { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--paper-3); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--paper-2); }

.num { text-align: right; font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
.mono { font-family: var(--mono); font-size: var(--t-xs); }

/* --- Status --- */

.status {
  display: inline-block;
  padding: 1px var(--space-2);
  font-size: var(--t-xs);
  font-weight: 500;
  border-radius: 2px;
  text-transform: capitalize;
  white-space: nowrap;
}

.status--good    { color: var(--good); background: var(--good-bg); }
.status--warn    { color: var(--warn); background: var(--warn-bg); }
.status--bad     { color: var(--bad);  background: var(--bad-bg); }
.status--info    { color: var(--info); background: var(--info-bg); }
.status--neutral { color: var(--ink-2); background: var(--paper-3); }

/* --- Controls --- */

.button {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  font: inherit;
  font-size: var(--t-sm);
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
}

.button:hover { background: var(--paper-2); border-color: var(--ink-3); }

.button--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--paper);
}

.button--primary:hover { background: #2a2e35; border-color: #2a2e35; }
.button--quiet { border-color: transparent; background: transparent; color: var(--ink-2); }
.button--quiet:hover { background: var(--paper-3); }
.button:disabled { opacity: 0.45; cursor: not-allowed; }

label { display: block; font-size: var(--t-sm); font-weight: 500; margin-bottom: var(--space-1); }

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], input[type="time"],
select, textarea {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  font: inherit;
  font-size: var(--t-base);
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
}

input:focus-visible, select:focus-visible, textarea:focus-visible,
.button:focus-visible, a:focus-visible {
  outline: 2px solid var(--info);
  outline-offset: 1px;
}

.field { margin-bottom: var(--space-4); }
.field__error { margin-top: var(--space-1); font-size: var(--t-sm); color: var(--bad); }
.field__hint { margin-top: var(--space-1); font-size: var(--t-sm); color: var(--ink-3); }

/* --- Auth --- */

.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--space-5);
  background: var(--paper-2);
}

.auth__card { width: 100%; max-width: 360px; }
.auth__mark { font-size: var(--t-lg); font-weight: 600; letter-spacing: -0.02em; margin-bottom: var(--space-1); }
.auth__lede { color: var(--ink-3); font-size: var(--t-sm); margin: 0 0 var(--space-5); }
.auth__form { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-5); }
.auth__errors { margin-bottom: var(--space-4); padding: var(--space-3); font-size: var(--t-sm); color: var(--bad); background: var(--bad-bg); border-radius: var(--radius); }

/* --- Empty states ---
   Every one teaches. "No open work orders" is useless on its own. */

.empty { padding: var(--space-7) var(--space-5); text-align: center; }
.empty h3 { font-size: var(--t-base); font-weight: 600; margin-bottom: var(--space-2); }
.empty p { margin: 0 auto; max-width: 46ch; color: var(--ink-3); font-size: var(--t-sm); }
.empty .button { margin-top: var(--space-4); }

/* --- Summary strip --- */

.tallies { display: flex; gap: var(--space-6); padding: var(--space-4); }
.tally__value { font-size: var(--t-xl); font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; }
.tally__label { font-size: var(--t-xs); text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-3); }
.tally--bad .tally__value { color: var(--bad); }
.tally--warn .tally__value { color: var(--warn); }

/* --- Motion ---
   Only where it explains a change. A row updating in place fades; nothing
   slides in for effect. */

@media (prefers-reduced-motion: no-preference) {
  .htmx-swapping { opacity: 0.5; transition: opacity 80ms ease-out; }
}

/* --- Narrow screens ---
   Managers check the board standing in a corridor, so the board and the work
   list have to work one-handed. */

@media (max-width: 720px) {
  .shell { padding: var(--space-3); }
  .masthead { padding: 0 var(--space-3); gap: var(--space-3); overflow-x: auto; }
  .masthead__org { display: none; }
  .tallies { gap: var(--space-4); overflow-x: auto; }
  th, td { padding: var(--space-2) var(--space-3); }
  .hide-narrow { display: none; }
}
