/* Plain, fast, and legible on a laptop or a tablet over a slow link.
 *
 * System fonts only, nothing fetched from anywhere but this server, no
 * framework: the page renders the moment the HTML lands. Colours are the ones
 * signed off on the 24 Sep 2026 mockups.
 *
 * Red is reserved. It means an alert, a request for help, or an escalation,
 * and it is the Send alert button. Nothing else is allowed to use it, so that
 * red anywhere on the screen always means the same thing.
 */

:root {
  color-scheme: light;

  --page: #F6F6F9;
  --card: #FFFFFF;
  --line: #D8D8DE;
  --ink: #17171C;
  --muted: #5B5B66;

  --accent: #1257C7;
  --accent-soft: #EAF0FC;
  --red: #B3261E;
  --red-soft: #FBECEB;
  --green: #1E7F3C;
  --green-soft: #EAF5EE;
  --amber: #B26A00;
  --amber-soft: #FBF1E4;
  --grey: #8A8A94;

  /* The mockup's amber is 4.2:1 on white, under the 4.5:1 the same spec asks
     for, so amber WORDS are a shade darker while the dot, the bar and the
     border stay the signed-off colour. */
  --amber-ink: #8A5200;

  --radius: 14px;
  --sidebar: 232px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
}

a { color: var(--accent); }

.skip { position: absolute; left: -100vw; }
.skip:focus {
  position: static;
  display: inline-block;
  padding: 0.5rem;
  background: var(--card);
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* --- The shell: sidebar, top bar, page ---------------------------------- */

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

.sidebar {
  flex: 0 0 var(--sidebar);
  width: var(--sidebar);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem 0.75rem;
  background: var(--card);
  border-right: 1px solid var(--line);
}

.brand { padding: 0.25rem 0.5rem 0; }
.brand-name { display: block; font-size: 1.05rem; font-weight: 700; letter-spacing: -0.01em; }
.brand-org { display: block; color: var(--muted); font-size: 0.8125rem; }

.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a {
  display: block;
  padding: 0.45rem 0.6rem;
  border-radius: 9px;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.9375rem;
}
.sidebar nav a:hover { background: var(--page); }
.sidebar nav a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.sidebar-foot {
  margin-top: auto;
  padding: 0.75rem 0.6rem 0;
  border-top: 1px solid var(--line);
  font-size: 0.8125rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.sidebar-foot form { margin: 0.35rem 0 0; }

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

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: center;
  padding: 0.85rem 1.25rem;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.topbar-title { min-width: 0; margin-right: auto; }
.topbar-title h1 { font-size: 1.25rem; margin: 0; letter-spacing: -0.01em; }
.topbar-context { margin: 0.1rem 0 0; color: var(--muted); font-size: 0.875rem; }
.topbar-actions { display: flex; gap: 0.75rem; align-items: center; }

/* The posture switch. Both words are always on screen and the set one is
   filled in, so which way it is set never depends on remembering a colour.
   Each half is a link to the existing confirmation step, never a direct
   change. */
.posture-switch {
  display: inline-flex;
  padding: 2px;
  background: var(--page);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.posture-switch a, .posture-switch span {
  padding: 0.3rem 0.85rem;
  border-radius: 999px;
  font-size: 0.875rem;
  text-decoration: none;
  color: var(--muted);
  white-space: nowrap;
}
.posture-switch .is-set { background: var(--card); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(23, 23, 28, 0.12); }
.posture-switch .is-set.crisis { background: var(--red); color: #FFFFFF; box-shadow: none; }

.send-alert {
  display: inline-block;
  padding: 0.45rem 1rem;
  border-radius: 9px;
  background: var(--red);
  color: #FFFFFF;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.send-alert:hover { background: #99201A; }

main { padding: 1.25rem; min-width: 0; }

/* --- Cards -------------------------------------------------------------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  min-width: 0;
}
.card.scroll { overflow-x: auto; }
.card.narrow { max-width: 26rem; margin: 3rem auto; }
.card > :first-child { margin-top: 0; }

.card-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}
.card-head h2 { margin: 0; }

h1 { font-size: 1.25rem; margin: 0 0 0.75rem; }
h2 { font-size: 1.0625rem; margin: 0 0 0.5rem; }
h3 { font-size: 0.9375rem; margin: 0 0 0.35rem; }

.hint { display: block; color: var(--muted); font-size: 0.875rem; }
.muted { color: var(--muted); }

.error, .notice {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--card);
  margin: 0 0 1rem;
}
.error { border-left: 4px solid var(--red); }
.notice { border-left: 4px solid var(--green); }

/* --- Forms -------------------------------------------------------------- */

label { display: block; font-weight: 600; margin-bottom: 0.25rem; }
input, select, textarea {
  font: inherit;
  padding: 0.5rem;
  width: 100%;
  max-width: 22rem;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 9px;
}
textarea { max-width: 40rem; min-height: 4.5rem; resize: vertical; }

button {
  font: inherit;
  padding: 0.5rem 1rem;
  border: 1px solid transparent;
  border-radius: 9px;
  background: var(--accent);
  color: #FFFFFF;
  font-weight: 600;
  cursor: pointer;
}
button.quiet {
  background: var(--card);
  color: var(--accent);
  border-color: var(--line);
  font-weight: 500;
}
/* Red is reserved: this is the button that raises an alert or resends one. */
button.danger { background: var(--red); }
button.danger:hover { background: #99201A; }

form.inline { display: flex; gap: 0.5rem; align-items: center; margin: 0; flex-wrap: wrap; }
form.inline select, form.inline input { width: auto; min-width: 9rem; }

/* --- Tables ------------------------------------------------------------- */

table { border-collapse: collapse; width: 100%; }
caption { text-align: left; }
th, td {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
tbody tr:last-child th, tbody tr:last-child td { border-bottom: 0; }
thead th {
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 600;
}

/* --- Lamps -------------------------------------------------------------- */

.lamp-cell { white-space: nowrap; }
.lamp {
  display: inline-block;
  width: 0.7rem; height: 0.7rem;
  border-radius: 50%;
  margin-right: 0.4rem;
  flex: 0 0 auto;
}
.lamp-green { background: var(--green); }
.lamp-amber { background: var(--amber); }
.lamp-red   { background: var(--red); }
.lamp-grey  { background: var(--grey); }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  margin: 0.75rem 0 0;
  padding: 0.75rem 0 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.8125rem;
  list-style: none;
}
.legend li { display: flex; align-items: center; }

/* --- State words -------------------------------------------------------- */

.state { font-weight: 600; white-space: nowrap; }
.state-help, .state-escalated, .escalated { color: var(--red); }
.state-nocontact { color: var(--red); }
.state-read, .state-delivered { color: var(--amber-ink); }
.state-acked { color: var(--green); }

/* --- Overview ----------------------------------------------------------- */

.columns {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}
.columns > .card { margin-bottom: 0; }

/* The refreshing fragment takes no space of its own, so the cards inside it
   are columns of the grid around it rather than one column holding two. */
.swap-contents { display: contents; }

/* Anyone who has asked for help, above everything else on the page. */
.help-banner {
  grid-column: 1 / -1;
  border: 1px solid var(--red);
  border-left-width: 5px;
  background: var(--red-soft);
  border-radius: var(--radius);
  padding: 0.85rem 1.1rem;
  margin: 0 0 1rem;
}
.help-banner h2 { color: var(--red); margin: 0 0 0.25rem; }
.help-banner ul { margin: 0; padding-left: 1.1rem; }

/* Bars. The number is written out beside every bar: the bar is the glance,
   the words are the answer. */
.bars { margin: 0.75rem 0 0; }
.bar-row { margin-bottom: 0.7rem; }
.bar-label {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.875rem;
  margin-bottom: 0.2rem;
}
.bar-label .count { color: var(--muted); white-space: nowrap; }
.bar-track {
  height: 8px;
  border-radius: 999px;
  background: var(--page);
  border: 1px solid var(--line);
  overflow: hidden;
}
.bar-fill { display: block; height: 100%; background: var(--accent); }
.bar-delivered .bar-fill { background: var(--accent); }
.bar-read .bar-fill { background: var(--amber); }
.bar-acked .bar-fill { background: var(--green); }
.bar-help .bar-fill { background: var(--red); }
.bar-help .bar-label { color: var(--red); font-weight: 600; }

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: 0.5rem;
}
.tile {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  min-width: 0;
}
.tile .lamp { margin-top: 0.4rem; }
.tile-name { font-weight: 600; display: block; overflow-wrap: anywhere; }
.tile-state { display: block; font-size: 0.8125rem; }
.tile-bearer { display: block; font-size: 0.8125rem; color: var(--muted); }

/* --- Stat tiles (alert detail) ------------------------------------------ */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.75rem 0.9rem;
}
.stat-figure { display: block; font-size: 1.75rem; font-weight: 700; line-height: 1.1; }
.stat-label { display: block; color: var(--muted); font-size: 0.8125rem; }
.stat-help .stat-figure, .stat-escalated .stat-figure { color: var(--red); }
.stat-acked .stat-figure { color: var(--green); }

/* --- Chat --------------------------------------------------------------- */

/* The conversation list beside the thread. Two columns on a desktop, stacked
   on a tablet in portrait, which is a supported size. */
.chat-page {
  display: grid;
  grid-template-columns: minmax(0, 15rem) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}
.chat-page > .card { margin-bottom: 0; }

.conversations { list-style: none; margin: 0; padding: 0; }
.conversation { border-bottom: 1px solid var(--line); }
.conversation:last-child { border-bottom: 0; }
.conversation a {
  display: block;
  padding: 0.5rem 0.4rem;
  text-decoration: none;
  color: inherit;
  border-radius: var(--radius);
}
.conversation a:hover { background: var(--line); }
/* The open conversation is marked by weight and a rule, not by colour alone. */
.conversation-open a { font-weight: 600; box-shadow: inset 2px 0 0 currentColor; }
.conversation-name { display: block; overflow-wrap: anywhere; }
.conversation-kind, .conversation-last {
  display: block;
  color: var(--muted);
  font-size: 0.8125rem;
}

.chat-log { margin: 0; max-height: 22rem; overflow-y: auto; }
.chat-line { padding: 0.4rem 0; border-bottom: 1px solid var(--line); }
.chat-line:last-child { border-bottom: 0; }
.chat-who { font-weight: 600; font-size: 0.875rem; }
.chat-when { color: var(--muted); font-size: 0.8125rem; margin-left: 0.4rem; }
.chat-body { margin: 0.1rem 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-send { margin-top: 0.75rem; }
.chat-send textarea { max-width: none; min-height: 3.5rem; }
.chat-send button { margin-top: 0.5rem; }

/* --- Timeline ----------------------------------------------------------- */

.timeline { margin: 0; padding: 0; list-style: none; }
.timeline li {
  display: grid;
  grid-template-columns: max-content max-content 1fr;
  gap: 0.25rem 1rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--line);
}
.timeline li:last-child { border-bottom: 0; }
.timeline .when { color: var(--muted); font-size: 0.875rem; white-space: nowrap; }
.timeline .what { font-weight: 600; font-size: 0.875rem; white-space: nowrap; }
.timeline .detail { overflow-wrap: anywhere; }

/* --- Facts, codes, sign-in --------------------------------------------- */

.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.25rem 1rem; margin: 0 0 0.75rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

.alert-body { font-size: 1.1rem; margin: 0 0 0.75rem; white-space: pre-wrap; }
.status-line { margin: 0 0 0.75rem; }

.issued { border-left: 4px solid var(--green); }
.code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 2rem;
  letter-spacing: 0.1em;
  margin: 0.25rem 0;
}
.secret { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.qr { display: block; margin: 0 auto 0.5rem; background: #FFFFFF; padding: 8px; border-radius: 9px; }

/* --- The template picker on the send-alert form -------------------------
   Big targets, because the two taps this exists for are made on a phone by
   somebody who has just been told a depot is flooding. */

.picker { list-style: none; margin: 0 0 0.5rem; padding: 0; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.picker a {
  display: block;
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--page);
  font-weight: 600;
  text-decoration: none;
}
.picker a:hover { border-color: var(--accent); }
.picker a.is-set { background: var(--accent); border-color: var(--accent); color: #FFFFFF; }

/* The reorder buttons sit together in one cell. */
.reorder { display: flex; gap: 0.35rem; white-space: nowrap; }

/* The sign-in page has no shell around it. */
.signin { padding: 0 1rem; }

/* Sign in with Google, where an OAuth client is configured. A link wearing the
   quiet button's clothes: it leaves the page rather than posting the form, and
   it is the page's own palette rather than Google's badge, because nothing
   here may be fetched from another host. */
.alt-signin {
  display: block;
  padding: 0.5rem 1rem;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--card);
  color: var(--accent);
  font-weight: 600;
  text-align: center;
  text-decoration: none;
}
.alt-signin:hover { border-color: var(--accent); }
.signin-or {
  color: var(--muted);
  font-size: 0.875rem;
  text-align: center;
  margin: 0.75rem 0;
}

/* --- The public pages ---------------------------------------------------
   The privacy policy and the support page are prose rather than a form, so
   they get a wider measure than the sign-in card and stay one column on a
   phone, which is where a reviewer is most likely to open them. */

.card.reading {
  max-width: 40rem;
  margin: 2rem auto;
  padding: 1.25rem 1.5rem;
}
.card.reading h2 { margin: 1.75rem 0 0.5rem; }
.card.reading h3 { margin: 1.25rem 0 0.35rem; }
.card.reading ul { padding-left: 1.25rem; margin: 0.5rem 0; }
.card.reading li { margin-bottom: 0.4rem; }

/* The links at the foot of a public page, and under the sign-in card. */
.page-foot {
  margin-top: 1.75rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.875rem;
}
.signin-foot {
  max-width: 26rem;
  margin: -1.5rem auto 3rem;
  padding-top: 0;
  border-top: 0;
  text-align: center;
}

/* --- Narrower screens ---------------------------------------------------
   A tablet in portrait is a supported size, so the three columns stack and
   the sidebar becomes a strip across the top rather than disappearing behind
   a control somebody has to find. */

@media (max-width: 1100px) {
  .columns { grid-template-columns: 1fr; }
  .chat-page { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .sidebar {
    flex: 0 0 auto;
    width: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    gap: 0.5rem;
  }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar-foot { margin-top: 0; }
  main { padding: 1rem; }
}
