/* ============================================================
   ARDIS — comms-console design system
   High-contrast, daylight-readable, glove-friendly tap targets.
   Signature: the green / amber / red safety system.
   ============================================================ */

:root {
  --bg:        #eef1f4;
  --surface:   #ffffff;
  --surface-2: #f6f8fa;
  --ink:       #10151c;
  --muted:     #59636e;
  --line:      #d3d9e0;
  --line-2:    #e6eaef;

  --brand:     #0b6e99;
  --brand-ink: #064b69;
  --accent:    #0ea5d6;

  --green:     #1f9d55;
  --green-bg:  #e3f6ea;
  --amber:     #c2700a;
  --amber-bg:  #fdf0db;
  --red:       #d42a2a;
  --red-bg:    #fbe3e3;

  --radius:    14px;
  --radius-sm: 10px;
  --shadow:    0 1px 2px rgba(16,21,28,.06), 0 4px 16px rgba(16,21,28,.06);
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --tap: 48px;
  --maxw: 920px;
}

/* ARDIS is daylight-only by design (outdoor readability, consistent appearance). */

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}
.mono { font-family: var(--mono); }

/* ---------- App shell ---------- */
.app { max-width: var(--maxw); margin: 0 auto; padding-bottom: 84px; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  background: var(--brand);
  color: #fff;
  padding: 10px 14px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
}
.topbar .brand { font-weight: 800; letter-spacing: .5px; font-size: 18px; }
.topbar .brand small { font-weight: 600; opacity: .8; font-size: 11px; display:block; letter-spacing:.3px; }
.topbar .clock { margin-left: auto; font-family: var(--mono); font-size: 15px; opacity: .95; }
.topbar .iconbtn {
  background: rgba(255,255,255,.16); color:#fff; border:0; border-radius: 10px;
  width: 40px; height: 40px; font-size: 18px; cursor: pointer;
}

.eventbar {
  background: var(--surface); border-bottom: 1px solid var(--line);
  padding: 8px 14px; display:flex; align-items:center; gap:10px; flex-wrap: wrap;
}
.eventbar .ev-name { font-weight: 700; }
.eventbar .ev-meta { color: var(--muted); font-size: 13px; }
.pill {
  font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); border:1px solid var(--line);
  text-transform: uppercase; letter-spacing: .4px;
}
.pill.live { background: var(--green-bg); color: var(--green); border-color: transparent; }
.pill.setup { background: var(--amber-bg); color: var(--amber); border-color: transparent; }

/* counts strip */
.counts { display:flex; gap:8px; padding: 10px 14px; flex-wrap: wrap; }
.count {
  flex: 1 1 0; min-width: 70px; background: var(--surface); border:1px solid var(--line);
  border-radius: var(--radius-sm); padding: 8px 10px; text-align:center;
}
.count b { display:block; font-size: 22px; font-family: var(--mono); line-height: 1.1; }
.count span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing:.5px; }
.count.alert { background: var(--red-bg); border-color: transparent; }
.count.alert b, .count.alert span { color: var(--red); }

/* ---------- Tabs (bottom nav, mobile-first) ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  background: var(--surface); border-top: 1px solid var(--line);
  display: flex; max-width: var(--maxw); margin: 0 auto;
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  flex: 1; background: none; border: 0; color: var(--muted);
  padding: 8px 2px 10px; font-size: 11px; font-weight: 600; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.tabbar button .ic { font-size: 20px; line-height: 1; }
.tabbar button.active { color: var(--brand); }
.tabbar button.active .ic { transform: translateY(-1px); }

/* ---------- Sections / cards ---------- */
.view { padding: 12px 14px; }
.view[hidden] { display: none; }
.section-h { display:flex; align-items:center; gap:10px; margin: 4px 0 10px; }
.section-h h2 { font-size: 15px; margin: 0; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.section-h .sp { margin-left: auto; }

.card {
  background: var(--surface); border:1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 12px; margin-bottom: 10px;
}

/* Station card with safety status edge */
.station {
  position: relative; padding-left: 14px; overflow: hidden;
}
.station::before {
  content:""; position:absolute; left:0; top:0; bottom:0; width: 6px; background: var(--line);
}
.station.s-green::before { background: var(--green); }
.station.s-amber::before { background: var(--amber); }
.station.s-red::before   { background: var(--red); }
.station.s-red  { background: var(--red-bg); border-color: transparent; }
.station.s-amber{ background: var(--amber-bg); }
.station.s-out  { opacity: .72; }

.station .row1 { display:flex; align-items:baseline; gap:8px; }
.station .call { font-family: var(--mono); font-weight: 700; font-size: 19px; }
.station .assign { color: var(--muted); font-size: 14px; }
.station .stamp { margin-left:auto; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.station .loc { font-size: 13px; color: var(--muted); margin-top: 2px; }
.station .meta { font-size: 13px; margin-top: 4px; }
.station .meta a { color: var(--brand); font-weight: 600; text-decoration: none; }

.statetag {
  font-size: 11px; font-weight: 800; padding: 2px 7px; border-radius: 6px; letter-spacing:.4px;
  text-transform: uppercase;
}
.statetag.green { background: var(--green-bg); color: var(--green); }
.statetag.amber { background: var(--amber-bg); color: var(--amber); }
.statetag.red   { background: var(--red); color:#fff; }
.statetag.out   { background: var(--surface-2); color: var(--muted); border:1px solid var(--line); }
.statetag.standby { background: var(--amber-bg); color: var(--amber); }

/* action buttons inside station */
.actions { display:flex; gap:8px; margin-top: 10px; flex-wrap: wrap; }
.actions .btn { flex: 1 1 auto; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--tap); padding: 0 16px; border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 700; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); cursor: pointer;
  user-select: none; touch-action: manipulation;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand); border-color: var(--brand); color:#fff; }
.btn.heard   { background: var(--green); border-color: var(--green); color:#fff; }
.btn.safety  { background: var(--red); border-color: var(--red); color:#fff; }
.btn.ghost   { background: var(--surface); }
.btn.danger  { background: var(--red-bg); border-color: transparent; color: var(--red); }
.btn.sm { min-height: 38px; font-size: 13px; padding: 0 12px; }
.btn.block { width: 100%; }
.btn.big { min-height: 60px; font-size: 18px; }
.btn:disabled { opacity: .45; cursor: default; }

/* ---------- Bulletins ---------- */
.bull {
  border-left: 6px solid var(--line); cursor: pointer;
}
.bull.p-high { border-left-color: var(--amber); }
.bull.p-emergency { border-left-color: var(--red); background: var(--red-bg); }
.bull .b-head { display:flex; align-items:center; gap:8px; }
.bull .b-title { font-weight: 700; font-size: 16px; }
.bull .b-type { font-size: 12px; color: var(--muted); }
.bull .b-body { margin-top: 8px; font-size: 14px; white-space: pre-wrap; }
.bull .b-grid { margin-top: 8px; font-size: 13px; display:grid; grid-template-columns: auto 1fr; gap:2px 10px; }
.bull .b-grid dt { color: var(--muted); }
.badge { font-size:11px; font-weight:800; padding:2px 7px; border-radius:6px; text-transform:uppercase; letter-spacing:.3px;}
.badge.emergency { background: var(--red); color:#fff; }
.badge.high { background: var(--amber-bg); color: var(--amber); }
.badge.incident { background: var(--brand); color:#fff; }

/* emergency banner */
.banner {
  background: var(--red); color:#fff; padding: 10px 14px; font-weight: 700;
  display:flex; align-items:center; gap:8px; cursor:pointer;
}
.banner.high { background: var(--amber); }
.banner .lbl { background: rgba(255,255,255,.22); padding:1px 7px; border-radius:6px; font-size:11px; }

/* ---------- Info: frequency + contacts ---------- */
.freq { display:grid; grid-template-columns: 1fr auto; gap: 2px 12px; }
.freq .f-label { font-weight: 700; }
.freq .f-val { font-family: var(--mono); text-align: right; }
.freq .f-sub { grid-column: 1 / -1; color: var(--muted); font-size: 13px; border-bottom:1px solid var(--line-2); padding-bottom:8px; margin-bottom:8px; }
.contact { display:flex; align-items:center; gap:10px; padding: 8px 0; border-bottom:1px solid var(--line-2); }
.contact:last-child { border-bottom: 0; }
.contact .c-name { font-weight: 600; }
.contact .c-org { color: var(--muted); font-size: 13px; }
.contact .c-phone { font-family: var(--mono); font-size: 14px; margin-top: 1px; }
.contact .c-phone a { color: var(--brand); text-decoration: none; }
.contact .call-btn { margin-left:auto; }

/* Net tab: single column on phones, two columns (operators | notes) on wider screens */
.net-grid { display: block; }
.net-side { margin-top: 10px; }
@media (min-width: 760px) {
  .net-grid { display: grid; grid-template-columns: 1fr 300px; gap: 14px; align-items: start; }
  .net-side { margin-top: 0; position: sticky; top: 12px; }
}

/* ---------- Forms / modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 60; background: rgba(8,12,18,.55);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal[hidden] { display: none; }
.sheet {
  background: var(--surface); width: 100%; max-width: var(--maxw);
  border-radius: 18px 18px 0 0; padding: 16px 16px calc(20px + env(safe-area-inset-bottom));
  max-height: 92vh; overflow-y: auto;
}
@media (min-width: 640px) {
  .modal { align-items: center; }
  .sheet { border-radius: 18px; }
}
.sheet h3 { margin: 2px 0 14px; font-size: 18px; }
label.field { display:block; margin-bottom: 12px; }
label.field > span { display:block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
input, select, textarea {
  width: 100%; min-height: var(--tap); padding: 10px 12px; font-size: 16px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--ink); font-family: inherit;
}
textarea { min-height: 84px; resize: vertical; }
.row2 { display:grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sheet-actions { display:flex; gap:10px; margin-top: 6px; position: sticky; bottom: 0; background: var(--surface); padding-top: 8px;}
.sheet-actions .btn { flex:1; }
.muted { color: var(--muted); }
.empty { text-align:center; color: var(--muted); padding: 30px 10px; }
.empty .ic { font-size: 34px; display:block; margin-bottom: 8px; }

/* list rows for setup */
.lrow { display:flex; align-items:center; gap:10px; padding:10px 0; border-bottom:1px solid var(--line-2); }
.lrow:last-child{border-bottom:0;}
.lrow .l-main { min-width:0; }
.lrow .l-main .l-t { font-weight:600; }
.lrow .l-main .l-s { font-size:13px; color:var(--muted); word-break: break-all;}
.lrow .l-act { margin-left:auto; display:flex; gap:6px; }

/* login */
.login-wrap { max-width: 380px; margin: 8vh auto; padding: 0 18px; }
.login-logo { text-align:center; margin-bottom: 22px; }
.login-logo .mark { font-size: 40px; font-weight:800; color: var(--brand); letter-spacing:1px;}
.login-logo .sub { color: var(--muted); font-size:13px; }

/* toast */
#toast {
  position: fixed; left:50%; transform: translateX(-50%); bottom: 96px; z-index: 80;
  background: var(--ink); color: var(--surface); padding: 10px 16px; border-radius: 10px;
  font-size: 14px; font-weight:600; box-shadow: var(--shadow); opacity: 0; transition: opacity .2s;
  max-width: 90%; text-align:center;
}
#toast.show { opacity: 1; }
#toast.err { background: var(--red); color:#fff; }

/* map */
#map, .map-el { width: 100%; height: 60vh; min-height: 340px; border-radius: var(--radius); border:1px solid var(--line); }
.leaflet-popup-content { font-family: var(--sans); }
.map-cap { font-family: var(--mono); font-weight: 700; }

/* roll-call compact */
.rollrow {
  display:flex; align-items:center; gap:10px; padding:10px 12px; border-bottom:1px solid var(--line-2);
  background: var(--surface);
}
.rollrow .call { font-family: var(--mono); font-weight:700; }
.rollrow .sp { margin-left:auto; }

/* segmented control */
.seg { display:flex; background: var(--surface-2); border:1px solid var(--line); border-radius: 10px; overflow:hidden; }
.seg button { flex:1; border:0; background:none; padding:9px 4px; font-weight:700; font-size:13px; color:var(--muted); cursor:pointer; }
.seg button.on { background: var(--brand); color:#fff; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
