/* The look the sign-in pages and the admin explorer share with the workspace's app: its "Precise workbench" tokens,
   copied from web/src/ui/tokens.css (change them there first, then here), its element defaults (web/src/ui/base.css),
   the top bar and breadcrumbs of its shell (web/src/app/Shell.module.css), buttons, the sign-in card and the dialog.
   admin.css builds on it. Dark follows the system unless data-theme on <html> says otherwise; the pages set it from
   the same stored choice as the app's ThemeSwitch. */

:root {
  color-scheme: light dark;

  /* Colour: surfaces. A grey with a faint green cast, like the panels of bench instruments. */
  --bg: light-dark(#f3f4f1, #121412); /* the bench: page background */
  --surface: light-dark(#fbfbfa, #1a1d1a); /* a raised work surface: inputs, the supporting panel, the sheet */
  --surface-sunken: light-dark(#e8eae5, #0c0e0c); /* wells: table heads, bar tracks */
  --surface-hover: light-dark(#eceee9, #202420);

  /* Colour: text. */
  --ink: light-dark(#151815, #e7e9e4); /* primary text, figures */
  --ink-2: light-dark(#3d423c, #c2c7be); /* secondary text */
  --muted: light-dark(#5f655e, #959b91); /* labels, meta */
  --faint: light-dark(#8e948c, #676d64); /* placeholders, disabled, inactive marks */

  /* Colour: rules. Hairlines between rows; a strong rule over each section. */
  --rule: light-dark(#d6d9d3, #2a2e2a);
  --rule-strong: light-dark(#151815, #8a9086);

  /* Colour: the one accent. Ultramarine, only for what waits on the person: the Needs-you tick, the primary
     button, the selected option, the current step, focus. Never for links or decoration. */
  --accent: light-dark(#2438c8, #8e9cff);
  --accent-ink: light-dark(#ffffff, #0a0e2c); /* text on an accent fill */
  --accent-soft: light-dark(#e5e8f8, #1c2150); /* a selected option's wash */
  --focus: var(--accent);

  /* Colour: states. Each is shown with a word or a glyph, never by colour alone. */
  --positive: light-dark(#1d6f44, #6cc993); /* met, confirmed */
  --positive-soft: light-dark(#e0efe6, #142a1d);
  --negative: light-dark(#b02c22, #ff8a7c); /* overdue, breached, stopped */
  --negative-soft: light-dark(#f6e3e0, #3a1714);
  --warning: light-dark(#8a5700, #e9b14c); /* unconfirmed, email not sent, unassigned */
  --warning-soft: light-dark(#f4ebd9, #2f2410);

  /* Colour: the preliminary label on everything a solo run produces (C59). A violet no state uses, drawn as a
     hatched stamp, the way a drawing is stamped "preliminary, not for construction". */
  --preliminary: light-dark(#86307a, #e391d6);
  --preliminary-hatch: light-dark(rgb(134 48 122 / 0.14), rgb(227 145 214 / 0.16));

  /* Colour: charts. Quiet marks: this year as a mid-grey bar, last year as an ink tick across it. */
  --chart-bar: light-dark(#8d9389, #727a6f);
  --chart-mark: light-dark(#151815, #f1f3ee);
  --chart-track: var(--surface-sunken);

  /* Type: one grotesque, Instrument Sans, with its width axis. Normal width for sentences; condensed caps for
     labels and readouts. Every number is set with tabular figures (--numeric). */
  --font: 'Instrument Sans Variable', 'Instrument Sans', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  --numeric: tabular-nums;
  --width-normal: 100%;
  --width-condensed: 78%;

  /* Type scale: a 1.2 ratio, in rem off a 16px root. */
  --text-label: 0.6875rem; /* 11: condensed caps labels, chips */
  --text-meta: 0.75rem; /* 12: meta lines, table notes */
  --text-cell: 0.8125rem; /* 13: table cells, dense lists */
  --text-ui: 0.875rem; /* 14: controls, option reasons */
  --text-body: 1rem; /* 16: sentences on the Desk */
  --text-lead: 1.1875rem; /* 19: option labels, panel titles */
  --text-title: 1.4375rem; /* 23: page titles */
  --text-question: 1.75rem; /* 28: the question */
  --text-figure: 2.125rem; /* 34: a threshold being set */

  --weight-regular: 400;
  --weight-medium: 530;
  --weight-semibold: 630;

  --leading-tight: 1.15;
  --leading-snug: 1.3;
  --leading-text: 1.45;
  --tracking-caps: 0.07em;
  --tracking-display: -0.014em;

  /* Spacing: a 4px base. */
  --space-1: 2px;
  --space-2: 4px;
  --space-3: 8px;
  --space-4: 12px;
  --space-5: 16px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 48px;
  --space-9: 64px;

  /* Layout: a 12-column grid; the Desk keeps a margin column for its zone labels, like a ledger. */
  --page-max: 78rem;
  --page-max-wide: 96rem; /* the bench: a question beside its supporting panel */
  --gutter: var(--space-6);
  --margin-col: 12.5rem;
  --measure: 42rem;
  --tap: 32px; /* the smallest control; 44px on a coarse pointer */

  /* Radii: small. */
  --radius-1: 2px; /* chips, cells, inputs */
  --radius-2: 3px; /* buttons, option cards */
  --radius-3: 6px; /* the sheet's top corners */

  /* Rules. */
  --hairline: 1px;
  --tick: 2px; /* the accent tick on what needs the person */

  /* Elevation: only the phone's sheet and the sticky context bar float. Light casts a shadow; dark lifts the
     surface and draws a lighter top edge instead. */
  --shadow-sheet: 0 -1px 0 light-dark(#d6d9d3, #3a3f39), 0 -16px 40px light-dark(rgb(21 24 21 / 0.14), rgb(0 0 0 / 0.55));
  --shadow-bar: 0 1px 0 var(--rule), 0 6px 16px light-dark(rgb(21 24 21 / 0.06), rgb(0 0 0 / 0.35));

  /* Motion. */
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --duration-1: 120ms;
  --duration-2: 220ms;
}

:root[data-theme='light'] {
  color-scheme: light;
}

:root[data-theme='dark'] {
  color-scheme: dark;
}

@media (pointer: coarse) {
  :root {
    --tap: 44px;
  }
}

@media (max-width: 47.99rem) {
  :root {
    --gutter: var(--space-5);
    --text-question: 1.4375rem;
    --text-figure: 1.75rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --duration-1: 0ms;
    --duration-2: 0ms;
  }
}

:root {
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ---------------------------------------------------------------- element defaults */

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--text-ui);
  font-weight: var(--weight-regular);
  line-height: var(--leading-text);
  font-variant-numeric: var(--numeric);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
*,
*::before,
*::after {
  box-sizing: border-box;
}
h1,
h2,
h3,
h4,
p {
  margin: 0;
}
h1,
h2,
h3,
h4 {
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-display);
  line-height: var(--leading-tight);
}
h1 {
  font-size: var(--text-title);
}
h2 {
  font-size: var(--text-lead);
}
h3 {
  font-size: var(--text-body);
}
small {
  font-size: var(--text-meta);
}
button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
}
button {
  border: 0;
  background: none;
  cursor: pointer;
}
button:disabled {
  cursor: not-allowed;
}
a {
  color: inherit;
  text-decoration: none;
}
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--radius-1);
}
::selection {
  background: var(--accent-soft);
  color: var(--ink);
}
[hidden] {
  display: none !important;
}
svg.icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sub {
  color: var(--ink-2);
}
.eyebrow {
  color: var(--muted);
  font-size: var(--text-label);
  font-stretch: var(--width-condensed);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-caps);
  line-height: 1.2;
  text-transform: uppercase;
}
.skip-link {
  position: absolute;
  top: var(--space-3);
  left: var(--space-3);
  z-index: 200;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-2);
  background: var(--ink);
  color: var(--bg);
  font-size: var(--text-ui);
  transform: translateY(-200%);
}
.skip-link:focus {
  transform: none;
}

/* ---------------------------------------------------------------- the bar */

.bar {
  position: relative;
  z-index: 30;
  border-bottom: var(--hairline) solid var(--rule);
  background: var(--bg);
}
.bar-inner {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-6);
  max-width: var(--page-max);
  min-height: 48px;
  margin: 0 auto;
  padding: 0 var(--gutter);
}
.wordmark {
  flex: none;
  color: var(--ink);
  font-size: var(--text-meta);
  font-stretch: var(--width-condensed);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
}
/* What this surface is, beside the product: a chip in the strong tone. */
.bar-tag {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  margin-left: calc(-1 * var(--space-4));
  padding: 1px var(--space-3) 0;
  border: var(--hairline) solid var(--rule-strong);
  border-radius: var(--radius-1);
  color: var(--ink);
  font-size: var(--text-label);
  font-stretch: var(--width-condensed);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-caps);
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
}
.nav {
  display: flex;
  align-self: stretch;
  gap: var(--space-5);
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav::-webkit-scrollbar {
  display: none;
}
.nav-link {
  display: inline-flex;
  align-items: center;
  margin-bottom: -1px;
  border-bottom: var(--tick) solid transparent;
  color: var(--muted);
  font-size: var(--text-ui);
  white-space: nowrap;
}
.nav-link:hover {
  color: var(--ink);
}
.nav-link.active {
  border-bottom-color: var(--ink);
  color: var(--ink);
  font-weight: var(--weight-medium);
}
.bar-end {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  margin-left: auto;
  min-width: 0;
}
.search-trigger {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 9rem;
  min-height: var(--tap);
  padding: 0 var(--space-3) 0 var(--space-4);
  border: var(--hairline) solid var(--rule);
  border-radius: var(--radius-2);
  background: var(--surface);
  color: var(--muted);
  font-size: var(--text-ui);
  transition: border-color var(--duration-1) var(--ease);
}
.search-trigger:hover {
  border-color: var(--rule-strong);
  color: var(--ink);
}
.search-label {
  flex: 1;
  text-align: left;
}
kbd {
  padding: 2px var(--space-2) 1px;
  border: var(--hairline) solid var(--rule);
  border-radius: var(--radius-1);
  color: var(--muted);
  font-family: inherit;
  font-size: var(--text-label);
  font-stretch: var(--width-condensed);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-caps);
  white-space: nowrap;
}
.tools {
  position: static;
}
.menu-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-width: var(--tap);
  min-height: var(--tap);
  padding: 0 var(--space-3);
  border: var(--hairline) solid var(--rule);
  border-radius: var(--radius-2);
  color: var(--ink-2);
}
.menu-button:hover,
.menu-button[aria-expanded='true'] {
  border-color: var(--rule-strong);
  color: var(--ink);
}
/* The admin has more views than the workspace, so the person, the store and the theme always fold behind one
   button and open as a small panel under the bar. */
.tools-panel {
  display: none;
  position: absolute;
  top: calc(48px + var(--space-2));
  right: var(--gutter);
  z-index: 40;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-4);
  padding: var(--space-5);
  border: var(--hairline) solid var(--rule-strong);
  border-radius: var(--radius-3);
  background: var(--surface);
  box-shadow: var(--shadow-bar);
}
.tools-panel[data-open='true'] {
  display: flex;
}
/* A person, by the workspace's glyph: a small disc. */
.glyph-person {
  display: inline-block;
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}
.person {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--ink);
  font-size: var(--text-ui);
  white-space: nowrap;
}
.person .glyph-person {
  color: var(--ink-2);
}
.sign-out {
  padding: 0;
  color: var(--ink-2);
  font-size: var(--text-ui);
  white-space: nowrap;
}
.sign-out:hover {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}
/* Whether the store could be read: a readout with a state mark, in words. */
.store-status {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--muted);
  font-size: var(--text-label);
  font-stretch: var(--width-condensed);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  white-space: nowrap;
}
.store-status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--positive);
}
.store-status.offline::before {
  background: none;
  border: 1.5px solid var(--warning);
}
/* Auto, Light or Dark, as joined buttons (the app's Segmented). */
.theme-switch {
  display: inline-flex;
  border: var(--hairline) solid var(--rule);
  border-radius: var(--radius-2);
}
.theme-switch button {
  min-height: 26px;
  padding: 0 var(--space-3);
  color: var(--muted);
  font-size: var(--text-meta);
}
.theme-switch button + button {
  border-left: var(--hairline) solid var(--rule);
}
.theme-switch button:hover {
  color: var(--ink);
}
.theme-switch button[aria-pressed='true'] {
  background: var(--surface-sunken);
  color: var(--ink);
  font-weight: var(--weight-medium);
}

/* ---------------------------------------------------------------- breadcrumbs */

.crumbs {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: var(--space-4) var(--gutter) 0;
}
.crumbs:empty {
  display: none;
}
.trail ol {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  row-gap: var(--space-1);
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: var(--text-meta);
  line-height: var(--leading-snug);
}
.trail li {
  display: inline-flex;
  align-items: baseline;
  min-width: 0;
  max-width: 100%;
}
.trail li + li::before {
  content: '›';
  flex: none;
  padding: 0 var(--space-3);
  color: var(--faint);
}
.trail li > * {
  overflow: hidden;
  max-width: 36ch;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.trail a {
  color: var(--muted);
}
.trail a:hover {
  color: var(--ink);
  text-decoration: underline;
}
.trail .current > * {
  color: var(--ink);
  font-weight: var(--weight-medium);
}

/* ---------------------------------------------------------------- the page */

.content {
  display: block;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: var(--space-7) var(--gutter) var(--space-9);
  outline: none;
}
.icon-button {
  display: inline-grid;
  place-items: center;
  min-width: var(--tap);
  min-height: var(--tap);
  border: var(--hairline) solid transparent;
  border-radius: var(--radius-2);
  color: var(--muted);
}
.icon-button:hover {
  border-color: var(--rule);
  color: var(--ink);
}

/* ---------------------------------------------------------------- buttons */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  min-height: var(--tap);
  padding: 0 var(--space-4);
  border: var(--hairline) solid transparent;
  border-radius: var(--radius-2);
  font-size: var(--text-ui);
  font-weight: var(--weight-medium);
  line-height: 1.2;
  white-space: nowrap;
  transition:
    background-color var(--duration-1) var(--ease),
    border-color var(--duration-1) var(--ease),
    color var(--duration-1) var(--ease);
}
.button .icon {
  width: 14px;
  height: 14px;
}
.button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.button.primary:hover:not(:disabled) {
  background: color-mix(in oklab, var(--accent) 86%, var(--ink));
}
.button.primary:disabled {
  background: var(--surface-sunken);
  border-color: var(--surface-sunken);
  color: var(--faint);
}
.button.secondary {
  border-color: var(--rule-strong);
  color: var(--ink);
}
.button.secondary:hover:not(:disabled) {
  background: var(--surface-hover);
}

/* ---------------------------------------------------------------- empty, loading */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-7) 0;
}
.empty-state h2,
.empty-state h3 {
  font-size: var(--text-lead);
}
.empty-state p {
  max-width: var(--measure);
  color: var(--muted);
}
.skeleton {
  border-radius: var(--radius-1);
  background: var(--surface-sunken);
  animation: pulse 1.6s var(--ease) infinite;
}
.sk-heading {
  width: 45%;
  height: 40px;
  margin-bottom: var(--space-7);
}
.sk-hero {
  height: 180px;
  margin-bottom: var(--space-7);
}
.sk-cards {
  height: 140px;
}
@keyframes pulse {
  50% {
    opacity: 0.55;
  }
}
@keyframes appear {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ---------------------------------------------------------------- dialogs */

.dialog {
  width: min(640px, calc(100vw - 2 * var(--gutter)));
  max-height: 85dvh;
  padding: 0;
  border: var(--hairline) solid var(--rule-strong);
  border-radius: var(--radius-3);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 16px 40px light-dark(rgb(21 24 21 / 0.14), rgb(0 0 0 / 0.55));
}
.dialog::backdrop {
  background: light-dark(rgb(21 24 21 / 0.28), rgb(0 0 0 / 0.6));
}
.dialog[open] {
  animation: appear var(--duration-2) var(--ease);
}
.dialog-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-5);
  padding: var(--space-5) var(--space-6);
  border-bottom: var(--hairline) solid var(--rule);
  background: var(--surface);
}
.dialog-header h2 {
  max-width: 90%;
  font-size: var(--text-lead);
  overflow-wrap: anywhere;
}
.dialog-header .eyebrow {
  margin-bottom: var(--space-2);
}
.dialog-body {
  padding: var(--space-6);
  overflow-wrap: anywhere;
}
.dialog-body > p {
  color: var(--ink-2);
}

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

.signin {
  display: grid;
  place-content: center;
  justify-items: start;
  min-height: 100dvh;
  padding: var(--space-7) var(--gutter);
}
.signin .brand {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}
.signin .brand .bar-tag {
  margin-left: 0;
}
.signin-card {
  display: flex;
  flex-direction: column;
  width: min(380px, calc(100vw - 2 * var(--gutter)));
  padding-top: var(--space-5);
  border-top: var(--hairline) solid var(--rule-strong);
}
.signin-card h1 {
  font-size: var(--text-title);
  text-wrap: balance;
}
.signin-card h1 em {
  display: block;
  color: var(--muted);
  font-style: normal;
  font-weight: var(--weight-regular);
}
.signin-card > p {
  margin: var(--space-3) 0 var(--space-3);
  color: var(--ink-2);
}
.signin-card label {
  margin: var(--space-5) 0 var(--space-2);
  color: var(--muted);
  font-size: var(--text-label);
  font-stretch: var(--width-condensed);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
}
.signin-card input {
  min-height: 40px;
  padding: 0 var(--space-4);
  border: var(--hairline) solid var(--rule);
  border-radius: var(--radius-1);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--text-body);
}
.signin-card input:hover {
  border-color: var(--rule-strong);
}
.signin-card input:focus-visible {
  outline-offset: 0;
  border-color: var(--accent);
}
.signin-card .signin-error {
  margin: var(--space-4) 0 0;
  color: var(--negative);
}
.signin-card .button {
  align-self: flex-start;
  margin-top: var(--space-6);
  min-height: 40px;
  padding: 0 var(--space-6);
}

/* ---------------------------------------------------------------- phone width */

/* The product and the views stay; the views scroll in a row of their own under the bar; Search becomes an icon; the
   person, the store and the theme stay behind their button. */
@media (max-width: 63.99rem) {
  .bar-inner {
    flex-wrap: wrap;
    gap: 0 var(--space-4);
    padding-top: var(--space-2);
  }
  .bar-tag {
    margin-left: 0;
  }
  .nav {
    order: 3;
    flex: 1 0 100%;
    min-height: 40px;
  }
  .search-trigger {
    min-width: var(--tap);
    justify-content: center;
    padding: 0 var(--space-3);
  }
  .search-label,
  .search-trigger kbd {
    display: none;
  }
  .bar-end {
    gap: var(--space-3);
  }
}
@media (max-width: 47.99rem) {
  .content {
    padding-top: var(--space-6);
  }
  .trail li {
    display: none;
  }
  .trail li.parent {
    display: inline-flex;
  }
  .trail li.parent::before {
    content: '‹';
    padding: 0 var(--space-3) 0 0;
    color: var(--muted);
  }
  .dialog {
    width: calc(100vw - 24px);
    max-height: 90dvh;
  }
  .dialog-header,
  .dialog-body {
    padding: var(--space-5);
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
