/* PostWatchHQ / Fire (ADR-0029). The same layout as the PostWatchHQ / EMS and PostWatch/HQ sign-in and header; only
   the colours differ. Police is red and blue. EMS is blues, white and navy. Fire is red and black, with no blue.
   Night: black with red marks and near-white text. Day: white with black text and red marks.
   "Auto" follows the device; Day and Night are set by the switch.
   Red is the brand here, so it never means "something is wrong". A problem is shown in amber, with a mark and words,
   never by colour alone. Every text colour is at least 4.5:1 against its background. */

:root {
  color-scheme: light;
  --page: #f5f5f6;
  --card: #ffffff;
  --card-2: #f5f5f6;
  --line: #d4d4d8;
  --field-line: #7a7a83;
  --text: #111113;
  --muted: #55555c;
  --accent: #b3140f;
  --accent-solid: #b3140f;
  --on-accent: #ffffff;
  --button: #111113;
  --button-hover: #3a3a40;
  --on-button: #ffffff;
  --field: #ffffff;
  --focus: #b3140f;
  --warn-bg: #fff4d6;
  --warn-line: #7a4b00;
  --warn-text: #111113;
  --warn-mark: #7a4b00;
  --shadow: 0 14px 40px rgba(17, 17, 19, 0.12);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}

/* Night values: used when Night is chosen, or when the device is dark and nothing is chosen. */
:root[data-theme="night"] {
  color-scheme: dark;
  --page: #0b0b0d;
  --card: #17171a;
  --card-2: #101012;
  --line: #2e2e33;
  --field-line: #7a7a83;
  --text: #f4f4f5;
  --muted: #b8b8bf;
  --accent: #ff6a5c;
  --accent-solid: #c8201a;
  --on-accent: #ffffff;
  --button: #c8201a;
  --button-hover: #a81a15;
  --on-button: #ffffff;
  --field: #0b0b0d;
  --focus: #ffffff;
  --warn-bg: #17171a;
  --warn-line: #ffc53d;
  --warn-text: #f4f4f5;
  --warn-mark: #ffc53d;
  --shadow: none;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    color-scheme: dark;
    --page: #0b0b0d;
    --card: #17171a;
    --card-2: #101012;
    --line: #2e2e33;
    --field-line: #7a7a83;
    --text: #f4f4f5;
    --muted: #b8b8bf;
    --accent: #ff6a5c;
    --accent-solid: #c8201a;
    --on-accent: #ffffff;
    --button: #c8201a;
    --button-hover: #a81a15;
    --on-button: #ffffff;
    --field: #0b0b0d;
    --focus: #ffffff;
    --warn-bg: #17171a;
    --warn-line: #ffc53d;
    --warn-text: #f4f4f5;
    --warn-mark: #ffc53d;
    --shadow: none;
  }
}

/* Which colouring of the logo shows. */
html .for-night { display: none; }
:root[data-theme="night"] .for-day { display: none; }
:root[data-theme="night"] .for-night { display: block; }
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] .for-day { display: none; }
  :root[data-theme="auto"] .for-night { display: block; }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--page); color: var(--text); font: 16px/1.5 var(--font); }
h1, h2 { line-height: 1.2; margin: 0 0 .5em; }
p { margin: 0; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
button, input { font: inherit; }

/* ---------- sign-in and set-up: a card under the logo, as in PostWatch/HQ ---------- */
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: min(440px, 100%); padding: 32px;
  background: var(--card); border: 1px solid var(--line); border-top: 4px solid var(--accent-solid); border-radius: 0 0 12px 12px; box-shadow: var(--shadow);
}
.login-logo { display: block; width: 100%; max-width: 330px; height: auto; margin-bottom: 22px; }
.tenant {
  display: flex; flex-direction: column; gap: 1px; margin-bottom: 20px; padding: 10px 12px;
  background: var(--card-2); border: 1px solid var(--line); border-radius: 6px;
}
.tenant-kind { color: var(--accent); font-size: .74rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.tenant-name { font-weight: 600; }
.login-card h1 { font-size: 1.4rem; }
.step { margin: 0 0 6px; color: var(--accent); font-weight: 600; font-size: .9rem; }

.fields label { display: block; margin: 14px 0 5px; font-weight: 600; font-size: .92rem; }
.fields input:not([type="hidden"]) {
  width: 100%; padding: 9px 11px; min-height: 44px;
  background: var(--field); color: var(--text); border: 1px solid var(--field-line); border-radius: 6px;
}
.primary {
  width: 100%; margin-top: 22px; padding: 11px; min-height: 46px;
  border: 1px solid var(--button); border-radius: 6px; background: var(--button); color: var(--on-button);
  font-weight: 600; cursor: pointer;
}
.primary:hover { background: var(--button-hover); border-color: var(--button-hover); }
.login-error {
  display: flex; gap: 10px; align-items: flex-start; margin-top: 16px; padding: 9px 12px; color: var(--warn-text);
  background: var(--warn-bg); border: 2px solid var(--warn-line); border-radius: 6px;
}
.warn-mark { flex: none; width: 20px; height: 20px; margin-top: 2px; fill: none; stroke: var(--warn-mark); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.warn-word { font-weight: 700; }
.login-note { margin: 18px 0 0; color: var(--muted); font-size: .86rem; text-align: center; }
.hint { margin: 6px 0; color: var(--muted); font-size: .88rem; }
.setup-key {
  margin: 12px 0; padding: 12px; background: var(--card-2); border: 1px solid var(--line); border-radius: 6px;
  font: 600 1.02rem/1.5 Consolas, "SF Mono", Menlo, monospace; text-align: center; overflow-wrap: anywhere; user-select: all;
}

/* ---------- Day / Night / Auto ---------- */
.theme { display: flex; width: fit-content; margin: 16px auto 0; padding: 3px; border: 1px solid var(--line); border-radius: 999px; background: var(--card-2); }
.theme-btn {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  border-radius: 999px; padding: 5px 14px; min-height: 30px; font-size: .84rem; font-weight: 600;
}
.theme-btn[aria-pressed="true"] { background: var(--accent-solid); color: var(--on-accent); }

/* ---------- workspace header, as in PostWatch/HQ ---------- */
.top { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; padding: 10px 16px; background: var(--card); border-top: 4px solid var(--accent-solid); border-bottom: 1px solid var(--line); }
.top-logo { display: block; }
.top-logo-img { width: 212px; height: auto; }
.top-tenant { display: flex; flex-direction: column; line-height: 1.25; padding-left: 16px; border-left: 1px solid var(--line); }
.top-tenant-name { font-weight: 600; }
.top-tenant-kind { color: var(--muted); font-size: .8rem; }
.top-right { display: flex; align-items: center; gap: 14px; margin-left: auto; flex-wrap: wrap; }
.top-right .theme { margin: 0; }
.top-user { color: var(--muted); font-size: .92rem; }
.link-button { padding: 4px 6px; background: none; border: 0; color: var(--accent); cursor: pointer; text-decoration: underline; }
.link-button:hover { color: var(--text); }

/* ---------- the workspace ---------- */
.space-main { max-width: 960px; margin: 0 auto; padding: 36px 16px 48px; }
.space-head h1 { font-size: clamp(1.7rem, 4vw, 2.3rem); margin-bottom: .1em; }
.space-sub { color: var(--muted); }
.empty { margin-top: 26px; padding: 60px 24px; text-align: center; background: var(--card); border: 1px dashed var(--line); border-radius: 10px; }
.empty h2 { font-size: 1.2rem; margin: 14px 0 4px; }
.empty p { color: var(--muted); }
.space-note { margin-top: 18px; color: var(--muted); font-size: .86rem; }

/* ---------- pages inside the workspace ---------- */
.nav { display: flex; gap: 4px; padding: 0 16px; background: var(--card); border-bottom: 1px solid var(--line); }
.nav a { padding: 10px 12px; color: var(--muted); font-weight: 600; text-decoration: none; border-bottom: 3px solid transparent; }
.nav a:hover { color: var(--text); }
.nav a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent-solid); }

/* ---------- sharing ---------- */
.share-state { margin-top: 26px; padding: 18px 20px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
.share-state h2 { font-size: 1.2rem; }
.share-state p { color: var(--muted); }
.share-how { margin-top: 18px; padding: 18px 20px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
.share-how h2 { font-size: 1.05rem; }
.share-how ul { margin: 8px 0 0; padding-left: 20px; }
.share-how li { margin: 4px 0; }
.rules { width: 100%; margin-top: 12px; border-collapse: collapse; font-size: .94rem; }
.rules th, .rules td { padding: 8px 10px; text-align: left; vertical-align: top; border-top: 1px solid var(--line); }
.rules th { color: var(--muted); font-size: .8rem; letter-spacing: .06em; text-transform: uppercase; }
.rule-off { display: inline-block; padding: 1px 8px; border: 1px solid var(--field-line); border-radius: 999px; font-weight: 600; }

@media (max-width: 560px) {
  .top-right { width: 100%; margin-left: 0; justify-content: flex-end; }
  .top-user { display: none; }
  .login-card { padding: 22px; }
}
