@import url('https://fonts.googleapis.com/css2?family=Overpass:wght@400;600;700&display=swap');

/* Palette taken from a CTC dispatcher panel: slate board, white rail, lamp colors. */
:root {
  --chrome: #1a252b;
  --panel: #24323a;
  --panel-raised: #2d3d45;
  --edge: #3d5059;
  --rail: #dce1da;
  --text: #e8ece6;
  --muted: #98a8ad;
  --lamp-off: #52636a;
  --stop: #e5483a;
  --clear: #4cc37e;
  --yellow: #f2c94c;
  --cyan: #5fd3e0;
  --orange: #f2994a;
  --focus: #f2c94c;
  --font: 'Overpass', 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--chrome);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
}
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- Sign-in ---------- */
.signin {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(var(--rail), var(--rail)) 0 58% / 100% 3px no-repeat,
    var(--panel);
}
.signin-card {
  width: min(360px, 100%);
  background: var(--chrome);
  border: 1px solid var(--edge);
  border-radius: 6px;
  padding: 28px 28px 24px;
  position: relative;
}
.signin-card h1 { margin: 0 0 4px; font-size: 26px; font-weight: 700; letter-spacing: -0.01em; }
.signin-card p { margin: 0 0 22px; color: var(--muted); }
.lamps { display: flex; gap: 8px; margin-bottom: 18px; }
.lamps span { width: 12px; height: 12px; border-radius: 50%; background: var(--lamp-off); }
.lamps span:nth-child(1) { background: var(--clear); }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.field input {
  width: 100%;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: 4px;
}
.field input:focus-visible { outline-offset: 0; }
.btn-primary {
  width: 100%;
  margin-top: 6px;
  padding: 11px 14px;
  background: var(--yellow);
  color: #1a1a14;
  border: 0;
  border-radius: 4px;
  font-weight: 700;
  cursor: pointer;
}
.btn-primary:disabled { opacity: 0.6; cursor: wait; }
.error { margin: 14px 0 0; color: #ff8a7e; min-height: 1.45em; }

/* ---------- App shell ---------- */
.app { height: 100%; display: grid; grid-template-rows: auto 1fr; }
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 14px;
  background: var(--chrome);
  border-bottom: 1px solid var(--edge);
  min-height: 52px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; white-space: nowrap; }
.brand svg { flex: none; }
.layout-pick {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 4px 6px;
  color: var(--muted);
  max-width: 220px;
}
.layout-pick:hover { border-color: var(--edge); }
.layout-pick option { background: var(--chrome); }
.find { position: relative; flex: 1 1 220px; max-width: 340px; }
.find input {
  width: 100%;
  padding: 7px 10px;
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: 4px;
}
.find input::placeholder { color: var(--muted); }
.feed { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; margin-left: auto; white-space: nowrap; }
.feed .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--lamp-off); }
.feed[data-state="live"] .dot { background: var(--clear); }
.feed[data-state="stale"] .dot { background: var(--yellow); }
.tools { display: flex; gap: 6px; }
.tool {
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: 4px;
  padding: 6px 10px;
  cursor: pointer;
  white-space: nowrap;
}
.tool:hover { background: var(--panel-raised); }
.user { color: var(--muted); font-size: 13px; }

.stage { position: relative; min-height: 0; display: grid; grid-template-columns: 1fr auto; }
.map {
  position: relative;
  overflow: hidden;
  background: var(--panel);
  touch-action: none;
  cursor: grab;
}
.map.dragging { cursor: grabbing; }
.map svg.layout { width: 100%; height: 100%; display: block; }
.map .loading, .map .empty {
  position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); padding: 24px; text-align: center;
}

/* ---------- Layout drawing ---------- */
.layout .panel { fill: var(--panel); }
.layout .grid-dot { fill: #34464e; }
.layout .track { stroke: var(--rail); stroke-width: 3.2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.layout .blockend { stroke: var(--rail); stroke-width: 2; }
.layout .sig-base, .layout .sig-stem { stroke: #9aa7aa; stroke-width: 2; stroke-linecap: round; }
.layout .sig-lamp { fill: var(--lamp-off); }
.layout .signal.stop .sig-lamp { fill: var(--stop); }
.layout .signal.clear .sig-lamp { fill: var(--clear); }
.layout .switch.normal .sw-reverse, .layout .switch.reverse .sw-normal { stroke: #5d6f75; }
.layout .label { font-family: var(--font); text-anchor: middle; dominant-baseline: central; fill: var(--text); pointer-events: none; }
.layout .label-yellow { fill: var(--yellow); font-weight: 600; }
.layout .label-cyan { fill: var(--cyan); }
.layout .label-orange { fill: var(--orange); }
.layout .portal { cursor: pointer; }
.layout .portal circle { fill: var(--panel); stroke: var(--cyan); stroke-width: 2; }
.layout .portal text { fill: var(--cyan); font-family: var(--font); font-weight: 700; text-anchor: middle; dominant-baseline: central; }
.layout .portal:hover circle, .layout .portal.flash circle { fill: #20505a; }
.layout .wiu { cursor: pointer; }
.layout .hit { fill: transparent; stroke: transparent; stroke-width: 2; }
.layout .wiu:hover .hit { fill: rgba(242, 201, 76, 0.06); stroke: rgba(242, 201, 76, 0.35); }
.layout .wiu.selected .hit { fill: rgba(242, 201, 76, 0.1); stroke: var(--yellow); }

/* ---------- Details drawer ---------- */
.details {
  width: 320px;
  background: var(--chrome);
  border-left: 1px solid var(--edge);
  padding: 18px 20px;
  overflow-y: auto;
}
.details[hidden] { display: none; }
.details-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.details h2 { margin: 0; font-size: 22px; line-height: 1.2; }
.details .sub { color: var(--muted); margin: 2px 0 16px; }
.close { background: none; border: 0; color: var(--muted); font-size: 22px; line-height: 1; padding: 2px 6px; cursor: pointer; border-radius: 4px; }
.close:hover { color: var(--text); }
.facts { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; }
.facts dt { color: var(--muted); font-size: 13px; padding-top: 2px; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.facts dd.mono { font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.copy { margin-left: 6px; font-size: 12px; padding: 1px 6px; background: var(--panel); border: 1px solid var(--edge); border-radius: 3px; cursor: pointer; color: var(--muted); }
.live-note { margin-top: 20px; padding: 12px 14px; background: var(--panel); border-radius: 4px; color: var(--muted); font-size: 14px; }

.hint { position: absolute; left: 12px; bottom: 10px; color: var(--muted); font-size: 12px; pointer-events: none; }

@media (max-width: 760px) {
  .topbar { gap: 8px 10px; padding: 8px 10px; }
  .find { order: 5; flex-basis: 100%; max-width: none; }
  .feed { margin-left: 0; }
  .user, .hint { display: none; }
  .stage { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .details { width: auto; max-height: 45vh; border-left: 0; border-top: 1px solid var(--edge); }
}
@media (prefers-reduced-motion: no-preference) {
  .layout .hit { transition: fill 120ms, stroke 120ms; }
}
