:root {
  color-scheme: light dark;
  --paper: #f5f6f0;
  --white: #fff;
  --ink: #182c26;
  --muted: #50655b;
  --rule: #d9e1d8;
  --deep: #143b30;
  --mint: #d5e9dd;
  --active: #14694e;
  --blocked: #9d451d;
  --ready: #315381;
  --waiting: #64736a;
  font-family: "Instrument Sans","Avenir Next",system-ui,sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: default;
  opacity: .55;
}

button:focus-visible,
a:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 3px solid #087d64;
  outline-offset: 3px;
}

p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

h1,
h2,
h3 {
  margin: 0;
}

a {
  color: inherit;
}

button {
  min-height: 44px;
}

button[hidden],
[hidden] {
  display: none!important;
}

.top {
  background: var(--deep);
  color: #fff;
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px max(22px,calc((100vw - 1320px)/2));
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 21px;
  letter-spacing: -.04em;
  text-decoration: none;
  font-weight: 750;
  white-space: nowrap;
}

.brand small {
  font-size: 13px;
  font-weight: 550;
  color: #d4e7dc;
  letter-spacing: 0;
}

.brand-rule {
  height: 21px;
  width: 1px;
  background: #709087;
  margin: 0 4px;
}

.mark {
  display: flex;
  gap: 3px;
  align-items: center;
  transform: skew(-18deg);
  margin-right: 4px;
}

.mark i {
  height: 17px;
  width: 5px;
  background: #b9e2ad;
  border-radius: 1px;
}

.mark i:first-child {
  height: 10px;
}

.mark i:last-child {
  height: 23px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.demo-tag,
.eyebrow,
.map-scale,
.map-note {
  font-size: 11px;
  letter-spacing: .11em;
  font-weight: 800;
}

.demo-tag {
  padding: 6px 8px;
  border: 1px solid #79988c;
  border-radius: 5px;
  white-space: nowrap;
}

.quiet {
  background: transparent;
  border: 1px solid var(--rule);
  color: inherit;
  border-radius: 7px;
  padding: 7px 12px;
  font-weight: 650;
  font-size: 13px;
}

.quiet:hover {
  background: #dcece45c;
}

.top .quiet {
  border-color: #79988c;
}

main {
  max-width: 1364px;
  margin: auto;
  padding: 25px 22px 42px;
}

.intro {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 14px;
  margin-bottom: 19px;
}

.intro h1 {
  font-size: clamp(34px,5vw,49px);
  letter-spacing: -.065em;
  line-height: 1.06;
  margin: 5px 0;
}

.eyebrow {
  color: var(--active);
  display: flex;
  align-items: center;
  gap: 6px;
}

.eyebrow span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--active);
}

.mode {
  display: flex;
  border: 1px solid var(--rule);
  padding: 3px;
  border-radius: 8px;
  background: #e9ede5;
}

.mode button {
  border: 0;
  background: transparent;
  padding: 0 14px;
  border-radius: 5px;
  color: var(--muted);
  font-weight: 650;
}

.mode [aria-pressed=true] {
  background: var(--white);
  color: var(--deep);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4,1fr);
  border: 1px solid var(--rule);
  background: var(--white);
  border-radius: 10px;
  margin-bottom: 16px;
}

.metric {
  padding: 12px 17px;
  display: flex;
  align-items: baseline;
  gap: 10px;
  border-right: 1px solid var(--rule);
}

.metric:last-child {
  border: 0;
}

.metric strong {
  font-size: 29px;
  letter-spacing: -.055em;
  font-variant-numeric: tabular-nums;
}

.metric span {
  font-size: 13px;
  color: var(--muted);
  font-weight: 650;
}

.workspace,
.lower {
  display: grid;
  grid-template-columns: minmax(0,1.65fr) minmax(315px,1fr);
  gap: 16px;
  align-items: start;
}

.lower {
  margin-top: 16px;
}

.panel {
  background: var(--white);
  border: 1px solid var(--rule);
  border-radius: 11px;
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--rule);
}

.panel-head h2,
.detail h2 {
  font-size: 17px;
  letter-spacing: -.025em;
}

.panel-head p,
.detail p {
  font-size: 13px;
  margin-top: 3px;
}

.clock,
.count {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.clock {
  font-variant-numeric: tabular-nums;
}

.map {
  height: clamp(350px,31vw,400px);
  position: relative;
  overflow: hidden;
  background: #d9e6d4;
  isolation: isolate;
}

.map canvas {
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
  z-index: -1;
}

.map-note,
.map-scale {
  position: absolute;
  color: #344f42;
}

.map-note {
  top: 19px;
  left: 18px;
}

.map-scale {
  bottom: 14px;
  left: 18px;
}

.compass {
  position: absolute;
  right: 15px;
  top: 15px;
  display: grid;
  justify-items: center;
  background: #f8faf2;
  border: 1px solid #6e8975;
  border-radius: 50%;
  width: 45px;
  height: 45px;
  padding: 4px;
  font-size: 10px;
  font-weight: 800;
}

.compass span {
  font-size: 18px;
  line-height: 14px;
}

.marker {
  position: absolute;
  transform: translate(-50%,-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
  white-space: nowrap;
  border: 1px solid #708a78;
  background: #fffffa;
  border-radius: 7px;
  color: var(--ink);
  padding: 5px 9px;
  min-height: 44px;
}

.marker[aria-pressed=true] {
  border: 2px solid var(--deep);
  padding: 4px 8px;
  z-index: 2;
}

.marker span:last-child {
  display: grid;
  gap: 1px;
}

.marker strong {
  font-size: 13px;
}

.marker small {
  color: var(--muted);
  font-size: 11px;
}

.road {
  position: absolute;
  left: 44%;
  top: 50%;
  padding: 4px 7px;
  border: 1px solid #a25326;
  border-radius: 5px;
  color: #793414;
  background: #fff1de;
  font-size: 11px;
  font-weight: 750;
  transform: rotate(-8deg);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 17px;
  padding: 13px 16px;
  color: var(--muted);
  font-size: 12px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--waiting);
  flex: none;
}

.dot.active {
  background: var(--active);
}

.dot.blocked {
  background: var(--blocked);
}

.dot.ready {
  background: var(--ready);
}

.side {
  display: grid;
  gap: 12px;
}

.zone-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  border: 0;
  border-bottom: 1px solid var(--rule);
  background: var(--white);
  padding: 8px 15px;
  color: var(--ink);
  text-align: left;
  min-height: 50px;
}

.zone-row:last-child {
  border-bottom: 0;
}

.zone-row[aria-pressed=true] {
  background: #edf5ef;
  box-shadow: inset 3px 0 var(--active);
}

.zone-name {
  display: grid;
  flex: 1;
  gap: 2px;
}

.zone-name strong {
  font-size: 13px;
}

.zone-name small {
  color: var(--muted);
  font-size: 11px;
}

.badge {
  border-radius: 4px;
  font-size: 11px;
  white-space: nowrap;
  padding: 4px 6px;
  background: #e9eee8;
  color: #42544a;
  font-weight: 750;
}

.badge.active {
  background: #dceee5;
  color: #195c44;
}

.badge.blocked {
  background: #f9e5d6;
  color: #873a17;
}

.badge.ready {
  background: #e2eaf5;
  color: #2c4d78;
}

.detail {
  padding: 12px 15px;
}

.detail-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.detail dl {
  margin: 9px 0 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  font-size: 12px;
}

.detail dt {
  color: var(--muted);
}

.detail dd {
  margin: 0;
  font-weight: 650;
}

.detail form {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.detail label {
  display: grid;
  gap: 3px;
  font-size: 12px;
  font-weight: 650;
}

.detail input,
.detail select {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  border: 1px solid #a8b8af;
  border-radius: 5px;
  padding: 7px;
  background: var(--white);
  color: var(--ink);
}

.detail input[type=file] {
  font-size: 12px;
}

.detail img {
  display: block;
  width: 100%;
  max-height: 125px;
  object-fit: cover;
  border-radius: 5px;
  margin-top: 8px;
}

.detail .quiet {
  margin-top: 8px;
}

.guide-body {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.guide-body h3 {
  font-size: 15px;
  margin-bottom: 3px;
}

.guide-body p {
  font-size: 13px;
}

.primary {
  border: 1px solid var(--deep);
  border-radius: 6px;
  background: var(--deep);
  color: white;
  font-weight: 750;
  padding: 8px 13px;
  font-size: 13px;
  flex: none;
}

.primary:hover {
  background: #225c49;
}

.activity ol {
  list-style: none;
  margin: 0;
  padding: 0 15px;
  max-height: 200px;
  overflow: auto;
}

.activity li {
  display: flex;
  gap: 10px;
  border-bottom: 1px solid var(--rule);
  padding: 8px 0;
  font-size: 12px;
}

.activity li:last-child {
  border: 0;
}

.activity time {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.notice {
  position: fixed;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 30px);
  z-index: 5;
  padding: 9px 13px;
  border-radius: 6px;
  background: var(--deep);
  color: #fff;
  font-size: 13px;
}

.mesh-panel {
  margin-bottom: 12px;
  padding: 14px 16px;
}

.mesh-panel summary {
  cursor: pointer;
  font-weight: 750;
}

.mesh-panel p {
  margin: 8px 0;
  color: var(--muted);
  font-size: 13px;
}

.mesh-panel iframe {
  display: block;
  width: 100%;
  height: 650px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: #f5f6f0;
}

@media(max-width:880px) {
  .workspace,
  .lower {
    grid-template-columns: minmax(0,1fr) minmax(275px,.8fr);
  }
  .metric {
    display: grid;
    gap: 0;
  }
  .map {
    height: 400px;
  }
  .marker {
    gap: 5px;
    padding-inline: 6px;
  }
  .marker[aria-pressed=true] {
    padding-inline: 5px;
  }
}

@media(max-width:660px) {
  main {
    padding: 17px 12px 30px;
  }
  .top {
    padding-inline: 12px;
  }
  .brand small,
  .brand-rule {
    display: none;
  }
  .intro {
    align-items: start;
    flex-direction: column;
  }
  .workspace,
  .lower {
    grid-template-columns: 1fr;
  }
  .map {
    height: 330px;
  }
  .metrics {
    grid-template-columns: repeat(2,1fr);
  }
  .metric {
    padding: 8px 12px;
    display: flex;
    gap: 8px;
  }
  .metric:nth-child(2) {
    border-right: 0;
  }
  .metric:nth-child(-n+2) {
    border-bottom: 1px solid var(--rule);
  }
  .guide-body {
    flex-wrap: wrap;
  }
  .road {
    left: 38%;
    top: 51%;
  }
  .panel-head,
  .legend {
    padding-inline: 12px;
  }
}

/* ---- Added for the richer demo ---- */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Status is carried by shape as well as colour. */
.dot.blocked {
  border-radius: 2px;
  transform: rotate(45deg);
}

.dot.ready {
  border-radius: 2px;
}

.dot.waiting {
  background: transparent;
  border: 2px solid var(--waiting);
}

.stale {
  color: var(--blocked);
}

.sync-line {
  margin-top: 8px;
  font-weight: 650;
}

.detail form > label {
  margin-top: 0;
}

.detail details {
  margin-top: 10px;
}

.detail summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
  min-height: 32px;
}

.link.offline {
  border-color: var(--blocked);
  color: var(--blocked);
}

.activity li.queued time {
  color: var(--blocked);
}

.activity .badge {
  margin-left: 4px;
}

.auto {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 14px;
  padding: 12px 16px 14px;
  border-top: 1px solid var(--rule);
}

.auto h3 {
  font-size: 14px;
}

.auto p {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.auto-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.auto [aria-pressed=true] {
  background: var(--mint);
  border-color: var(--active);
}

#report-dialog {
  width: min(900px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 11px;
  background: #fff;
  color: #182c26;
}

#report-dialog::backdrop {
  background: #0b1a15a6;
}

.report-bar {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 16px;
  background: #f5f6f0;
  border-bottom: 1px solid #d9e1d8;
}

.report-bar h2 {
  font-size: 17px;
}

.report-bar div {
  display: flex;
  gap: 8px;
}

.report-bar .quiet {
  border-color: #a8b8af;
}

.report-bar .primary {
  background: #143b30;
  border-color: #143b30;
  color: #fff;
}

@media(max-width:660px) {
  .marker {
    min-height: 34px;
    padding: 3px 7px;
  }
  .marker[aria-pressed=true] {
    padding: 2px 6px;
  }
  .marker small {
    display: none;
  }
  .marker strong {
    font-size: 12px;
  }
  .road {
    left: 30%;
    top: 49%;
  }
  .report {
    padding: 18px;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #121a17;
    --white: #1a2520;
    --ink: #e6eee9;
    --muted: #a3b5ab;
    --rule: #2f3f37;
    --deep: #0e2a22;
    --mint: #1f4435;
    --active: #58c79b;
    --blocked: #f0966a;
    --ready: #8fb4ec;
    --waiting: #9aaba1;
  }
  .mode {
    background: #0f1714;
  }
  .mode [aria-pressed=true] {
    background: #2a3a33;
    color: var(--ink);
  }
  .map {
    background: #1d2a24;
  }
  .map-note,
  .map-scale {
    color: #b9cdbf;
  }
  .compass {
    background: #1a2520;
    border-color: #6f8f79;
  }
  .marker {
    background: #1a2520;
    border-color: #6f8f79;
  }
  .marker[aria-pressed=true] {
    border-color: #b9e2ad;
  }
  .road {
    background: #3b2414;
    border-color: #f0966a;
    color: #ffd2b8;
  }
  .zone-row[aria-pressed=true] {
    background: #20302a;
  }
  .badge {
    background: #2a3832;
    color: #c5d3cb;
  }
  .badge.active {
    background: #17392c;
    color: #8be0bb;
  }
  .badge.blocked {
    background: #43261a;
    color: #ffb692;
  }
  .badge.ready {
    background: #1f2f48;
    color: #b3cdf5;
  }
  .detail input,
  .detail select {
    border-color: #4b6156;
  }
  .primary {
    background: #2f7d62;
    border-color: #2f7d62;
    color: #fff;
  }
  .primary:hover {
    /* Darker, not lighter: white text must keep its contrast while hovered. */
    background: #276a53;
  }
  .quiet:hover {
    background: #2a3a335c;
  }
  .notice {
    background: #2f7d62;
  }
  button:focus-visible,
  a:focus-visible,
  select:focus-visible,
  input:focus-visible {
    outline-color: #7fe0bb;
  }
}

@media print {
  .top-actions,
  .mode,
  .guide,
  .live-panel,
  .legend,
  .detail form,
  .detail details,
  .detail [data-sign],
  #export,
  .notice,
  .mesh-panel {
    display: none !important;
  }
  .lower,
  .workspace {
    grid-template-columns: 1fr;
  }
  .activity ol {
    max-height: none;
  }
  .panel {
    break-inside: avoid;
  }
  html.print-report body > :not(#report-dialog) {
    display: none !important;
  }
  html.print-report #report-dialog {
    position: static;
    width: auto;
    max-height: none;
    /* The dialog scrolls on screen; on paper the whole report must flow from its first line. */
    overflow: visible;
    width: 100%;
    max-width: none;
    margin: 0;
    border: 0;
  }
  html.print-report,
  html.print-report body {
    background: #fff;
  }
  html.print-report #report-dialog::backdrop {
    background: none;
  }
  html.print-report .report-bar {
    display: none;
  }
}

.detail img {
  object-position: bottom;
}

@media(max-width:660px) {
  .top {
    flex-wrap: wrap;
  }
  .top-actions {
    flex-wrap: wrap;
    min-width: 0;
  }
  .demo-tag {
    white-space: normal;
    font-size: 9px;
  }
}

/* ---- Live mode (the page a pilot gateway serves at /app) ---- */

.live #reset,
.live .mode,
.live #guide,
.live #mesh-test-link,
.live #mesh-panel {
  display: none;
}

.signed-out main > :not(#sign-in):not(#notice) {
  display: none;
}

.sign-in {
  max-width: 460px;
  margin: 48px auto;
  padding: 24px;
}

.sign-in h1 {
  font-size: 22px;
  margin-bottom: 8px;
}

.sign-in form {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.sign-in label {
  font-size: 13px;
  font-weight: 650;
}

.sign-in input {
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--muted);
  border-radius: 6px;
  background: var(--white);
  color: var(--ink);
  font: inherit;
}

.sign-in .primary {
  justify-self: start;
  min-width: 120px;
}

.sign-in-error {
  margin-top: 12px;
  color: var(--blocked);
  font-weight: 650;
}

.sign-in .quiet {
  margin-top: 12px;
}

.live-panel .link {
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
}

.live-actions {
  display: flex;
  gap: 8px;
  flex: none;
}

#live-refused {
  list-style: none;
  margin: 0;
  padding: 0 16px;
}

#live-refused li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--rule);
  font-size: 13px;
}

.activity .late {
  color: var(--muted);
  white-space: nowrap;
}

.conflict {
  border-left: 3px solid var(--blocked);
  padding-left: 10px;
  font-weight: 400;
}

@media (max-width: 660px) {
  .live-panel .guide-body {
    flex-direction: column;
    align-items: flex-start;
  }
}

.log-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Alerts for the dispatcher in a live event. */
.alerts {
  margin-bottom: 16px;
}

.alerts ul {
  list-style: none;
  margin: 0;
  padding: 0 16px;
}

.alerts li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0 10px 10px;
  border-top: 1px solid var(--rule);
  border-left: 4px solid var(--blocked);
  font-size: 14px;
}

.alerts li.stale,
.alerts li.plant {
  border-left-color: var(--ready);
}

.alerts li small {
  color: var(--muted);
  white-space: nowrap;
}

.alert-sound {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  font-size: 13px;
  font-weight: 650;
}

.alert-sound input {
  width: 20px;
  height: 20px;
}

@media (max-width: 700px) {
  .alerts li {
    flex-direction: column;
    align-items: stretch;
  }
}

/* Recording acceptance in the handback dialog. Not printed. */
.acceptance {
  padding: 14px 16px;
  background: #f5f6f0;
  border-bottom: 1px solid #d9e1d8;
  color: #182c26;
}

.acceptance h3 {
  margin: 0 0 4px;
  font-size: 16px;
}

.acceptance p {
  margin: 0 0 10px;
  font-size: 13px;
  color: #50655b;
}

.acceptance form {
  display: grid;
  gap: 10px;
  max-width: 620px;
}

.acceptance label,
.acceptance #signature-label {
  display: grid;
  gap: 4px;
  font-size: 13px;
  font-weight: 650;
}

.acceptance input {
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid #50655b;
  border-radius: 6px;
  background: #fff;
  color: #182c26;
  font: inherit;
}

.acceptance canvas {
  display: block;
  width: 100%;
  max-width: 600px;
  aspect-ratio: 10 / 3;
  margin-top: 4px;
  border: 1px solid #50655b;
  border-radius: 6px;
  background: #fff;
  touch-action: none;
  cursor: crosshair;
}

.acceptance #acceptance-message {
  margin: 0;
  color: #873a17;
  font-weight: 650;
}

@media print {
  .acceptance {
    display: none !important;
  }
}
