/* PostWatchHQ / EMS (ADR-0028). The same layout as the PostWatch/HQ sign-in and header; only the colours differ.
   Police is red and blue. EMS is blues, white and navy, with no red.
   Night: PostWatch's navy with softer text, so a screen in a dark ambulance doesn't glare.
   Day: whites and light blues. "Auto" follows the device; Day and Night are set by the switch. */

:root {
  color-scheme: light;
  --page: #eaf2fb;
  --card: #ffffff;
  --card-2: #f4f8fd;
  --line: #c9daee;
  --text: #0b1f3f;
  --muted: #4d6482;
  --blue: #1f6fd6;
  --blue-solid: #1f6fd6;
  --blue-hover: #1859ad;
  --on-blue: #ffffff;
  --field: #ffffff;
  --focus: #0b3d91;
  --error-bg: #fdecea;
  --error-line: #b3261e;
  --error-text: #8c1d18;
  --pulse: #1f6fd6;
  --shadow: 0 14px 40px rgba(31, 79, 140, 0.14);
  --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: #0b1626;
  --card: #132238;
  --card-2: #0f1b2d;
  --line: #2a4060;
  --text: #d3deec;
  --muted: #94a6bd;
  --blue: #7fb1f7;
  --blue-solid: #2f66c4;
  --blue-hover: #3b78e7;
  --on-blue: #e8f0fb;
  --field: #0b1626;
  --focus: #9cc4ff;
  --error-bg: rgba(127, 177, 247, 0.12);
  --error-line: #7fb1f7;
  --error-text: #d3deec;
  --pulse: #4fa3ff;
  --shadow: none;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    color-scheme: dark;
    --page: #0b1626;
    --card: #132238;
    --card-2: #0f1b2d;
    --line: #2a4060;
    --text: #d3deec;
    --muted: #94a6bd;
    --blue: #7fb1f7;
    --blue-solid: #2f66c4;
    --blue-hover: #3b78e7;
    --on-blue: #e8f0fb;
    --field: #0b1626;
    --focus: #9cc4ff;
    --error-bg: rgba(127, 177, 247, 0.12);
    --error-line: #7fb1f7;
    --error-text: #d3deec;
    --pulse: #4fa3ff;
    --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(--blue); }
: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-radius: 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-left: 4px solid var(--blue-solid); border-radius: 6px;
}
.tenant-kind { color: var(--blue); 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(--blue); 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(--line); border-radius: 6px;
}
.primary {
  width: 100%; margin-top: 22px; padding: 11px; min-height: 46px;
  border: 1px solid var(--blue-solid); border-radius: 6px; background: var(--blue-solid); color: var(--on-blue);
  font-weight: 600; cursor: pointer;
}
.primary:hover { background: var(--blue-hover); border-color: var(--blue-hover); }
.login-error {
  margin-top: 16px; padding: 9px 12px; color: var(--error-text);
  background: var(--error-bg); border: 1px solid var(--error-line); border-radius: 6px;
}
.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(--blue-solid); color: var(--on-blue); }

/* ---------- 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-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(--blue); 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-pulse { width: min(320px, 80%); height: 60px; }
.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; }

.pulse-line {
  fill: none; stroke: var(--pulse); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 460; stroke-dashoffset: 460;
  animation: pulse-draw 3.6s ease-in-out infinite;
}
@keyframes pulse-draw {
  0% { stroke-dashoffset: 460; opacity: 1; }
  55% { stroke-dashoffset: 0; opacity: 1; }
  85% { stroke-dashoffset: 0; opacity: 1; }
  100% { stroke-dashoffset: 0; opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .pulse-line { animation: none; stroke-dashoffset: 0; }
}

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