/* monitor.css — GTA Update Monitor View */
/* Design tokens aligned with newsupdate.ca (news/assets/news.css) */

:root {
  /* Service colours */
  --fire-div:        #D9341C;
  --police-div:      #3346B5;
  --alarm-div:       #D90F1E;

  /* Masthead */
  --masthead-from:   #0B1F4B;
  --masthead-to:     #142B6E;
  --masthead-rule:   #D90F1E;

  /* Surface (news.css tokens) */
  --bg:              #EDF1F7;
  --surface:         #FFFFFF;
  --surface-2:       #F6F8FB;
  --divider:         #D6DCE7;
  --text:            #121826;
  --muted:           #4B5565;
  --signal:          #1F4FD8;
  --red:             #D90F1E;
  --yellow:          #FFC21A;
}

body.dark-mode {
  --bg:              #0A1226;
  --surface:         #111C38;
  --surface-2:       #0E1830;
  --divider:         #24325A;
  --text:            #E7ECF6;
  --muted:           #A6B2CB;
  --fire-div:        #D9341C;
  --police-div:      #1E2A80;
  --alarm-div:       #8B0000;
  --red:             #FF4B57;
}

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  font-family: 'Schibsted Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100%;
  overflow: hidden;
  display: flex; flex-direction: column;
}

#app {
  display: flex; flex-direction: column;
  height: 100vh;
  max-width: 1920px;
  margin: 0 auto; width: 100%;
}
@media (min-width: 1200px) { #app { width: 80%; } }

/* ===== Masthead ===== */
.masthead {
  background: linear-gradient(135deg, var(--masthead-from), var(--masthead-to));
  border-bottom: 3px solid var(--masthead-rule);
  padding: 8px 20px;
  display: flex; align-items: center; gap: 16px;
  flex-shrink: 0;
}
body.dark-mode .masthead { background: #08142F; }

.logo-tile {
  width: 36px; height: 36px;
  background: var(--red);
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 900; color: #fff;
  position: relative; flex-shrink: 0;
}
.logo-tile::after {
  content: '·';
  position: absolute; bottom: 1px; right: 4px;
  color: var(--yellow); font-size: 14px; line-height: 1;
}
.logo-text {
  color: #fff; font-size: 18px; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase; line-height: 1;
}
.logo-tagline {
  color: rgba(255,255,255,0.5); font-size: 9px;
  letter-spacing: 0.18em; text-transform: uppercase; margin-top: 3px;
}

.news-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-decoration: none; flex-shrink: 0;
  background: var(--red); color: #fff;
  padding: 7px 18px; border-radius: 8px;
  line-height: 1.2;
  transition: filter 0.15s;
}
.news-btn:hover { filter: brightness(1.15); }
.news-btn-top { font-size: 17px; font-weight: 700; letter-spacing: 0.03em; color: var(--yellow); }
.news-btn-sub { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.85; }

#fancyClock {
  font-size: 26px; font-weight: 400;
  font-variant-numeric: tabular-nums; letter-spacing: 0.02em;
  color: #fff; white-space: nowrap;
}

.masthead-middle {
  flex: 1; display: flex; align-items: center; justify-content: center;
  gap: 10px; flex-wrap: wrap;
}
.masthead-middle .toggle-label { color: rgba(255,255,255,0.9); }
.masthead-middle .toggle-label input[type=checkbox] { accent-color: var(--yellow); }
.masthead-right { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.masthead-right #weatherBar { color: rgba(255,255,255,0.7); }

/* ===== Controls bar ===== */
.controls {
  background: var(--surface);
  border-bottom: 1px solid var(--divider);
  padding: 5px 20px;
  display: flex; align-items: center; gap: 8px;
  flex-shrink: 0; flex-wrap: wrap;
}

.ctrl-sep { width: 1px; height: 22px; background: var(--divider); flex-shrink: 0; }

.filter-pills { display: flex; gap: 6px; }
.svc-btn {
  padding: 4px 14px; border-radius: 999px;
  font-size: 13px; font-weight: 600;
  border: 2px solid transparent; cursor: pointer;
  background: var(--surface-2); color: var(--text);
}
body.dark-mode .svc-btn { background: #1E2D4A; }
.svc-btn[data-service="all"].active    { background: #2E7D32; color: #fff; border-color: #2E7D32; }
.svc-btn[data-service="police"].active { background: var(--police-div); color: #fff; border-color: var(--police-div); }
.svc-btn[data-service="fire"].active   { background: var(--fire-div); color: #fff; border-color: var(--fire-div); }

#hourRange {
  padding: 3px 6px; font-size: 13px;
  border: 1px solid var(--divider); border-radius: 5px;
  background: var(--surface); color: var(--text);
}
#hourRangeLabel { font-size: 12px; color: var(--muted); white-space: nowrap; }

.controls-centre { flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; }
.ctrl-scroll-col { width: 100px; min-width: 100px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.scroll-btn {
  width: 72px; padding: 4px 0; border-radius: 7px;
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  border: 2px solid var(--divider); background: var(--surface-2); color: var(--muted);
  cursor: pointer; letter-spacing: 0.05em;
}
.scroll-btn:hover { border-color: var(--muted); }
.scroll-btn.scroll-active {
  background: var(--signal); color: #fff; border-color: var(--signal);
  box-shadow: 0 0 6px rgba(31,79,216,0.4);
}

#weatherBar {
  font-size: 13px; color: var(--muted);
  display: flex; align-items: center; gap: 4px;
}

.toggle-controls { display: flex; gap: 10px; align-items: center; }
.toggle-label {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 600; cursor: pointer;
  color: var(--text); white-space: nowrap;
}
.toggle-label input[type=checkbox] { width: 13px; height: 13px; cursor: pointer; }

.action-btn {
  padding: 5px 12px; border-radius: 6px;
  font-size: 13px; font-weight: 600; border: none; cursor: pointer;
}
.btn-feedback { background: var(--red); color: #fff; }
.btn-oldsite  { background: #b8860b; color: #fff; }

#viewSelect {
  padding: 3px 8px; font-size: 13px; font-weight: 700;
  border: 2px solid var(--red); border-radius: 5px;
  background: rgba(255,255,255,0.1); color: #fff; cursor: pointer;
}

/* Select dropdown option styling — light mode */
select option                { background: #fff; color: #121826; }
select option:checked        { background: #1F4FD8; color: #fff; }

/* Select dropdown option styling — dark mode */
body.dark-mode select        { color-scheme: dark; }
body.dark-mode select option { background: #111C38; color: #fff; }
body.dark-mode select option:checked { background: #1F4FD8; color: #fff; }

/* ===== App body: feed + sidebar ===== */
.app-body {
  flex: 1; overflow: hidden;
  display: flex; flex-direction: row;
}

#events-wrap {
  flex: 1; overflow-y: auto; overflow-x: hidden;
}

#events-body {
  display: flex; flex-direction: column;
  padding-bottom: 20px;
}

/* ===== Placeholder rows ===== */
.mon-placeholder {
  padding: 16px 20px; text-align: center;
  color: var(--muted); font-style: italic; font-size: 15px;
}

/* ===== Hour dividers ===== */
.hour-div {
  display: flex; align-items: center;
  padding: 4px 20px;
  background: var(--surface-2); color: var(--muted);
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase;
  border-top: 1px solid var(--divider);
  border-bottom: 1px solid var(--divider);
  margin: 2px 0;
}

/* ===== Monitor row ===== */
.mon-row {
  display: flex; align-items: stretch;
  border-bottom: 1px solid var(--divider);
  min-height: 54px;
  background: var(--surface);  /* white — no service tint */
}
/* Alarm rows only get a tint */
.mon-row.alarm-level {
  background: #FEF2F2 !important;
  border-left: 4px solid var(--alarm-div);
}
body.dark-mode .mon-row.alarm-level {
  background: #2D1010 !important;
  border-left-color: var(--red);
}

/* Flash: yellow highlight fading */
@keyframes monFlash {
  0%, 80% { background-color: #FEF9C3 !important; }
  100%     { background-color: var(--surface); }
}
.mon-row.row-flash { animation: monFlash 15s ease-out forwards; }
.mon-row.alarm-level.row-flash { animation: none; }

/* ===== Division badge ===== */
.mon-div {
  width: 100px; min-width: 100px;
  display: flex; align-items: center; justify-content: center;
  padding: 8px 10px;
  /* background is white — same as row */
}

.mon-badge {
  width: 72px; min-width: 72px;
  padding: 5px 6px;
  border-radius: 7px;
  text-align: center;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.20), 0 2px 4px rgba(0,0,0,0.25);
}
.mon-badge:hover { opacity: 0.85; }

.fire   .mon-badge { background: linear-gradient(to bottom, #E8461E, #C42A12); }
.police .mon-badge { background: linear-gradient(to bottom, #3D52C8, #2A3A9A); }
.alarm-level .mon-badge { background: linear-gradient(to bottom, #EF1525, #B50D1A) !important; }
body.dark-mode .fire   .mon-badge { background: linear-gradient(to bottom, #E8461E, #C42A12); }
body.dark-mode .police .mon-badge { background: linear-gradient(to bottom, #263590, #1A2670); }
body.dark-mode .alarm-level .mon-badge { background: linear-gradient(to bottom, #A00010, #700008) !important; }

.mon-badge-label {
  font-size: 12px; font-weight: 700;
  color: rgba(255,255,255,0.9);
  text-transform: uppercase; letter-spacing: 0.08em; line-height: 1.2;
}
.mon-badge-name {
  font-size: 15px; font-weight: 700;
  color: #fff; line-height: 1.2;
  word-break: break-word;
}

/* ===== Time column ===== */
.mon-time-col {
  width: 80px; min-width: 80px;
  display: flex; align-items: center; justify-content: flex-end;
  padding-right: 14px; flex-shrink: 0;
  overflow: hidden;
}

.mon-time {
  font-size: 20px; font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--muted); text-align: right; white-space: nowrap;
  line-height: 1.2;
}
.mon-sub-date { display: block; font-size: 11px; color: var(--muted); white-space: nowrap; }
.alarm-level .mon-time { color: #7F1D1D; }
body.dark-mode .alarm-level .mon-time { color: #FCA5A5; }

/* ===== Content ===== */
.mon-content {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; justify-content: center;
  padding: 7px 14px;
}

.mon-line1 {
  display: flex; align-items: baseline;
  gap: 10px; flex-wrap: wrap; min-width: 0;
}

.mon-phone-div { display: none; }  /* desktop: hidden */
.mon-phone-time { display: none; } /* desktop: hidden; shown on phone */

.mon-desc {
  font-size: 20px; font-weight: 700; color: var(--text);
  flex-shrink: 0;
}
.alarm-level .mon-desc { color: #7F1D1D; }
body.dark-mode .alarm-level .mon-desc { color: #FCA5A5; }

.mon-loc {
  font-size: 18px; font-weight: 400; color: var(--muted);
  flex: 1; min-width: 0;
}
.alarm-level .mon-loc { color: #9A3412; }
body.dark-mode .alarm-level .mon-loc { color: #FDBA74; }

.mon-line2 {
  font-size: 15px; color: var(--muted);
  margin-top: 3px; text-align: right;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ===== Badges ===== */
.alarm-badge {
  background: var(--red); color: #fff;
  padding: 1px 6px; border-radius: 4px;
  font-size: 12px; font-weight: 700; flex-shrink: 0;
}
body.dark-mode .alarm-badge { background: var(--red); color: #111; }
.alarm-level .alarm-badge { background: #FF0000 !important; color: #fff !important; border: 1px solid #fff; }

.update-badge {
  background: var(--yellow); color: #111;
  font-weight: 700; padding: 1px 5px; border-radius: 4px;
  font-size: 11px; cursor: pointer; flex-shrink: 0;
}
.update-badge:hover { opacity: 0.75; text-decoration: underline; }

/* ===== Big text ===== */
body.big-text .mon-row       { min-height: 68px; }
body.big-text .mon-div       { width: 116px; min-width: 116px; }
body.big-text .mon-badge     { width: 88px; min-width: 88px; }
body.big-text .mon-badge-name { font-size: 18px; }
body.big-text .mon-time-col  { width: 110px; min-width: 110px; }
body.big-text .mon-time      { font-size: 24px; }
body.big-text .mon-desc      { font-size: 26px; }
body.big-text .mon-loc       { font-size: 22px; }
body.big-text .mon-line2     { font-size: 18px; }
body.big-text .alarm-badge   { font-size: 14px; padding: 2px 8px; }
body.big-text .hour-div      { font-size: 13px; padding: 6px 20px; }

/* ===== Stats sidebar ===== */
#stats-panel {
  display: none;    /* hidden below 1600px */
  width: 380px; min-width: 380px;
  border-left: 1px solid var(--divider);
  border-top: 3px solid var(--red);
  overflow-y: auto;
  background: var(--surface);
  flex-direction: column;
  flex-shrink: 0;
}

.stats-section {
  padding: 14px 18px;
  border-bottom: 1px solid var(--divider);
}
.stats-section:last-child { border-bottom: none; flex: 1; }

.stats-h {
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--masthead-from);
  margin-bottom: 10px;
}
body.dark-mode .stats-h { color: var(--muted); }

/* 24h stat rows */
.stat-row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 5px 0; border-bottom: 1px solid var(--divider);
}
.stat-row:last-child { border-bottom: none; }
.stat-label { font-size: 14px; color: var(--muted); }
.stat-val   { font-size: 22px; font-weight: 700; color: var(--text); line-height: 1; }
.stat-pct   { font-size: 12px; font-weight: 400; color: var(--muted); margin-left: 5px; }
.stat-alarm { color: var(--red); }

/* Active fire rows */
.stat-fire-row {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
  padding: 3px 0; border-bottom: 1px solid var(--divider);
  font-size: 15px; line-height: 1.1;
}
.stat-fire-row:last-child { border-bottom: none; }
.stat-fire-time  { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; flex-shrink: 0; }
.stat-fire-desc  { color: var(--text); font-weight: 600; }
.stat-fire-loc   { color: var(--muted); font-size: 14px; }
.stat-alarm-chip {
  background: var(--red); color: #fff;
  border-radius: 4px; padding: 2px 7px;
  font-size: 13px; font-weight: 700; flex-shrink: 0;
}
.stat-none { font-size: 14px; color: var(--muted); font-style: italic; }

/* Calls-per-hour chart */
.chart-wrap {
  display: flex; flex-direction: column;
  height: 90px;
}
.chart-bars {
  flex: 1; display: flex; align-items: flex-end; gap: 2px;
}
.chart-col {
  flex: 1; display: flex; flex-direction: column;
  align-items: stretch; justify-content: flex-end; height: 100%;
  position: relative; cursor: default;
}
.chart-bar {
  background: var(--police-div);
  border-radius: 2px 2px 0 0;
  min-height: 2px;
  position: relative;
}
body.dark-mode .chart-bar { background: #2A3A8A; }
.chart-fire {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: var(--fire-div);
  border-radius: 2px 2px 0 0; min-height: 2px;
}
.chart-labels {
  display: flex; gap: 2px;
  margin-top: 3px;
}
.chart-lbl {
  flex: 1; text-align: center;
  font-size: 8px; color: var(--muted);
  overflow: hidden; white-space: nowrap;
}

/* ===== Detailed card view ===== */
.view-detailed #events-body {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 14px; padding: 14px;
}
.view-detailed .hour-div { grid-column: 1 / -1; margin: 0; }
.view-detailed #no-events, .view-detailed .mon-placeholder { grid-column: 1 / -1; }
/* Hide monitor rows in detailed view */
.view-detailed .mon-row { display: none; }
/* Hide cards in monitor view */
.det-card { display: none; }
.view-detailed .det-card { display: flex; }

.det-card {
  background: var(--surface);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08), 0 0 1px rgba(0,0,0,0.06);
  cursor: pointer;
  content-visibility: auto;
  contain-intrinsic-size: auto 260px;
  flex-direction: row;
  border: 1px solid var(--divider);
}
body.dark-mode .det-card { box-shadow: 0 1px 4px rgba(0,0,0,0.3); }
.det-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.15), 0 0 1px rgba(0,0,0,0.1); }
body.dark-mode .det-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.5); }

.det-stripe {
  width: 5px; min-width: 5px; flex-shrink: 0;
}
.det-card.fire   .det-stripe { background: var(--fire-div); }
.det-card.police .det-stripe { background: var(--police-div); }
.det-card.alarm-level .det-stripe { background: var(--red); }

.det-card.alarm-level {
  background: #FEF2F2;
  border-color: rgba(217,15,30,0.25);
}
body.dark-mode .det-card.alarm-level {
  background: #2D1010;
  border-color: rgba(255,75,87,0.3);
}

.det-inner {
  flex: 1; min-width: 0;
  padding: 12px 14px;
  display: flex; flex-direction: column; gap: 8px;
}

/* Card header: badge + time + status */
.det-header {
  display: flex; align-items: flex-start; gap: 10px;
}
.det-card .mon-badge { flex-shrink: 0; }

.det-time-block {
  display: flex; flex-direction: column;
  align-items: flex-end; justify-content: center;
  margin-left: auto;
}
.det-time-val {
  font-size: 18px; font-weight: 600;
  font-variant-numeric: tabular-nums; color: var(--text);
  line-height: 1.2;
}
.det-time-date {
  font-size: 11px; color: var(--muted);
}
.det-card.alarm-level .det-time-val { color: #7F1D1D; }
body.dark-mode .det-card.alarm-level .det-time-val { color: #FCA5A5; }

.det-status {
  display: flex; gap: 5px; flex-shrink: 0; align-items: flex-start;
}
.det-chip {
  padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.03em;
  white-space: nowrap;
}
.det-chip-active { background: #16a34a; color: #fff; }
.det-chip-closed { background: var(--surface-2); color: var(--muted); border: 1px solid var(--divider); }
.det-chip-alarm  { background: var(--red); color: #fff; }
.det-chip-updated {
  background: var(--yellow); color: #111;
  cursor: pointer;
  animation: detUpdFade 180s ease-out forwards;
}
@keyframes detUpdFade {
  0%, 95% { opacity: 1; }
  100%    { opacity: 0.4; }
}

/* Title */
.det-title {
  font-size: 18px; font-weight: 700; color: var(--text);
  line-height: 1.25;
}
.det-card.alarm-level .det-title { color: #7F1D1D; }
body.dark-mode .det-card.alarm-level .det-title { color: #FCA5A5; }

/* Location */
.det-location {
  display: flex; flex-wrap: wrap; align-items: baseline;
  gap: 6px; font-size: 14px; color: var(--muted);
}
.det-loc-text { font-weight: 500; }
.det-area { font-size: 12px; color: var(--muted); opacity: 0.7; }
.det-map-link {
  font-size: 11px; font-weight: 700; color: var(--signal);
  text-decoration: none; letter-spacing: 0.03em;
}
.det-map-link:hover { text-decoration: underline; }

/* Units chips */
.det-units {
  display: flex; flex-wrap: wrap; gap: 4px;
}
.det-unit-chip {
  padding: 2px 7px; border-radius: 5px;
  font-size: 12px; font-weight: 600;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--divider);
  font-variant-numeric: tabular-nums;
}

/* Duration */
.det-duration {
  font-size: 12px; font-weight: 600; color: #16a34a;
}
.det-duration-closed { color: var(--muted); }

/* Timeline */
.det-timeline {
  border-top: 1px solid var(--divider);
  padding-top: 6px;
}
.det-tl-label {
  font-size: 10px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.08em;
  margin-bottom: 4px;
}
.det-tl-entry {
  display: flex; gap: 8px; align-items: baseline;
  font-size: 12px; padding: 2px 0;
  border-bottom: 1px solid var(--divider);
}
.det-tl-entry:last-child { border-bottom: none; }
.det-tl-time {
  font-variant-numeric: tabular-nums; color: var(--muted);
  min-width: 36px; font-weight: 500;
}
.det-tl-alarm { font-weight: 700; color: var(--red); min-width: 24px; }
.det-tl-added   { color: #15803D; font-weight: 500; }
.det-tl-removed { color: #DC2626; font-weight: 500; }
.det-tl-nochange { color: var(--muted); font-style: italic; }
.det-tl-expand {
  background: none; border: none; cursor: pointer;
  font-size: 11px; font-weight: 600; color: var(--signal);
  padding: 3px 0; margin-bottom: 2px;
}
.det-tl-expand:hover { text-decoration: underline; }

/* Footer */
.det-footer {
  font-size: 11px; color: var(--muted); opacity: 0.6;
  font-variant-numeric: tabular-nums;
}

/* Big text adjustments for detailed */
body.big-text .det-title { font-size: 22px; }
body.big-text .det-time-val { font-size: 22px; }
body.big-text .det-location { font-size: 16px; }
body.big-text .det-unit-chip { font-size: 14px; }
body.big-text .det-tl-entry { font-size: 14px; }

/* Footer stats (shown at < 1600px) */
#footer-stats {
  font-size: 13px; color: var(--muted);
  margin-bottom: 4px;
}
#footer-stats strong { color: var(--text); }

/* ===== Footer ===== */
.mon-footer {
  padding: 7px 20px; text-align: center;
  font-size: 12px; color: var(--muted);
  border-top: 1px solid var(--divider); flex-shrink: 0;
}
.mon-footer a { color: var(--muted); }
.mon-footer a:hover { color: var(--text); }

/* ===== Wide screen: show sidebar, slim footer ===== */
@media (min-width: 1600px) {
  #stats-panel { display: flex; }
  #footer-stats { display: none; }
}
/* Detailed view: no sidebar, stats inline at bottom of feed */
.view-detailed #stats-panel { display: none !important; }
.view-detailed #footer-stats { display: none !important; }
#inline-stats { display: none; }
.view-detailed #inline-stats {
  display: block;
  grid-column: 1 / -1;
  padding: 14px 20px;
  font-size: 14px; color: var(--muted);
  border-top: 1px solid var(--divider);
  background: var(--surface-2);
  text-align: center;
  border-radius: 8px;
}
#inline-stats strong { color: var(--text); }

/* ===== Event detail dialog ===== */
#eventDialog {
  border: none; border-radius: 12px; padding: 0;
  max-width: 520px; width: 90vw;
  background: var(--surface); color: var(--text);
  box-shadow: 0 12px 40px rgba(0,0,0,0.35);
  overflow: visible; position: fixed;
  top: 50%; left: 50%; transform: translate(-50%, -50%);
}
#eventDialog::backdrop { background: rgba(0,0,0,0.5); }
body.dark-mode #eventDialog { border: 1px solid var(--divider); }
#eventDialog #eventDialogCard { padding: 0; }
#eventDialog #eventDialogCard .det-card {
  display: block !important; box-shadow: none; border-radius: 12px;
}
#eventDialog #eventDialogCard .det-inner { padding: 16px 20px; gap: 8px; }
#eventDialogClose {
  position: absolute; top: 8px; right: 12px;
  background: none; border: none; font-size: 24px;
  color: var(--muted); cursor: pointer; z-index: 1;
  line-height: 1; padding: 4px;
}
#eventDialogClose:hover { color: var(--text); }
#eventDialogCopy {
  position: absolute; bottom: -36px; left: 50%; transform: translateX(-50%);
  background: var(--surface); color: var(--muted); border: 1px solid var(--divider);
  border-radius: 6px; padding: 4px 12px; font-size: 12px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
}
#eventDialogCopy:hover { color: var(--text); }
/* Clickable rows */
.mon-row { cursor: pointer; }
.mon-row:hover { background: rgba(0,0,0,0.03); }
body.dark-mode .mon-row:hover { background: rgba(255,255,255,0.03); }
.mon-row.alarm-level:hover { filter: brightness(1.05); }
/* Phone: full-screen dialog */
@media (max-width: 768px) {
  #eventDialog {
    max-width: 100vw; width: 100vw; height: 100vh;
    border-radius: 0; top: 0; left: 0; transform: none;
    overflow-y: auto;
  }
  #eventDialogClose { top: 10px; right: 10px; font-size: 28px; }
  #eventDialogCopy {
    position: static; transform: none; display: block;
    margin: 8px 16px 16px; text-align: center;
  }
}

/* ===== Modals ===== */
#contactModal {
  display: none; position: fixed;
  top: 0; left: 0; width: 100vw; height: 100vh;
  background: rgba(0,0,0,0.6); z-index: 9999; overflow: auto;
}
#contactModal.show { display: block; }

.modal-content {
  background: var(--surface); color: var(--text);
  margin: 10vh auto; padding: 24px 30px;
  border-radius: 12px; width: 500px; max-width: 95vw;
  box-shadow: 0 8px 20px rgba(0,0,0,0.3);
  position: relative;
}
body.dark-mode .modal-content { border: 1px solid var(--divider); }
.modal-content h2 { margin-top: 0; font-size: 20px; text-align: center; }
.modal-content label { display: block; margin-top: 10px; font-weight: 600; font-size: 13px; }
.modal-content input, .modal-content textarea {
  width: 100%; padding: 8px; margin-top: 4px;
  border: 1px solid var(--divider); border-radius: 5px;
  font-size: 14px; box-sizing: border-box; resize: vertical;
  background: var(--bg); color: var(--text);
}
.modal-actions { display: flex; justify-content: space-between; margin-top: 16px; }
.modal-actions button { padding: 8px 18px; border: none; border-radius: 6px; font-size: 14px; font-weight: 700; cursor: pointer; }
#cancelBtn { background: #dc3545; color: #fff; }
#sendBtn   { background: var(--signal); color: #fff; }

.close-btn {
  position: absolute; top: 10px; right: 14px;
  font-size: 22px; color: var(--muted); cursor: pointer;
}
.close-btn:hover { color: var(--text); }

#historyModal, #divisionModal {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.55); z-index: 1000;
  align-items: center; justify-content: center;
}
#historyModalInner, #divisionModalInner {
  background: var(--surface); color: var(--text);
  border-radius: 7px; width: 520px; max-height: 70vh;
  display: flex; flex-direction: column;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
  border: 1px solid var(--divider);
}
#divisionModalInner { width: 620px; }
#historyModalHeader, #divisionModalHeader {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px; border-bottom: 1px solid var(--divider); font-weight: 700;
}
#historyModalClose, #divisionModalClose {
  cursor: pointer; font-size: 1.1em; color: var(--muted);
}
#historyModalClose:hover, #divisionModalClose:hover { color: var(--text); }
#historyModalBody, #divisionModalBody {
  overflow-y: auto; padding: 10px 16px;
  font-family: monospace; font-size: 1.2em;
}
.hist-row { display: flex; gap: 10px; padding: 3px 0; border-bottom: 1px solid var(--divider); }
.hist-time  { color: var(--muted); min-width: 40px; }
.hist-alarm { color: var(--text); min-width: 36px; font-weight: bold; }
.hist-units { flex: 1; }
.hist-added   { color: #15803D; }
.hist-removed { color: #DC2626; margin-left: 6px; }
.hist-nochange { color: var(--muted); font-style: italic; }

/* ===== Responsive — phone ===== */
@media (max-width: 768px) {
  html, body { overflow: auto; height: auto; }
  #app { height: auto; min-height: 100vh; }
  .app-body { flex-direction: column; overflow: visible; }
  #events-wrap { flex: none; height: auto; overflow: visible; }
  #stats-panel { display: none !important; }

  .masthead { padding: 6px 10px; gap: 8px; flex-wrap: wrap; }
  #fancyClock { font-size: 18px; }
  .logo-text  { font-size: 15px; }
  .logo-tagline { display: none; }
  .logo-tile  { width: 28px; height: 28px; font-size: 16px; }
  .news-btn { padding: 3px 8px; }
  .news-btn-top { font-size: 11px; }
  .news-btn-sub { font-size: 8px; }
  .btn-oldsite, #feedbackBtn { display: none !important; }
  .masthead-middle { order: 3; flex-basis: 100%; justify-content: flex-start; overflow-x: auto; flex-wrap: nowrap; gap: 8px; }
  .masthead-middle .toggle-label { font-size: 11px; }
  .masthead-middle #viewSelect { font-size: 12px; padding: 2px 5px; }
  .masthead-right { margin-left: auto; }
  #weatherBar { display: none; }

  .controls { padding: 4px 8px; gap: 5px; overflow-x: auto; flex-wrap: nowrap; }
  .ctrl-sep { display: none; }
  .controls-centre { justify-content: flex-start; }
  .ctrl-scroll-col { width: auto; min-width: auto; }
  .scroll-btn { width: 56px; font-size: 11px; }
  #hourRangeLabel { display: none; }
  .svc-btn    { font-size: 12px; padding: 3px 10px; }
  #hourRange  { font-size: 12px; }

  /* Phone rows: block, left border */
  .mon-row {
    display: block;
    padding: 8px 10px 8px 12px;
    border-left: 4px solid transparent;
  }
  .mon-row.fire          { border-left-color: var(--fire-div); }
  .mon-row.police        { border-left-color: var(--police-div); }
  .mon-row.alarm-level   { border-left-color: var(--alarm-div); border-left-width: 5px; }

  /* Hide desktop columns */
  .mon-div      { display: none; }
  .mon-time-col { display: none; }

  /* Show phone badge + phone time inline */
  .mon-phone-div {
    display: inline-block;
    font-size: 10px; font-weight: 700;
    padding: 1px 7px; border-radius: 999px;
    color: #fff; white-space: nowrap; flex-shrink: 0;
  }
  .fire   .mon-phone-div { background: var(--fire-div); }
  .police .mon-phone-div { background: var(--police-div); }
  .alarm-level .mon-phone-div { background: var(--alarm-div); }

  .mon-phone-time {
    display: inline;
    font-size: 12px; font-weight: 600;
    font-variant-numeric: tabular-nums; color: var(--muted); flex-shrink: 0;
  }

  .mon-content { padding: 0; }
  .mon-line1 { flex-wrap: nowrap; gap: 5px; align-items: center; overflow: hidden; }
  .mon-desc  { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }

  .mon-loc {
    display: block;
    max-width: 100%; white-space: normal; overflow: visible;
    font-size: 13px; margin-top: 2px;
  }
  .mon-line2 { font-size: 11px; white-space: normal; margin-top: 2px; }

  .hour-div { padding: 3px 10px; font-size: 10px; }

  #footer-stats { font-size: 12px; }
  .mon-footer { padding: 8px 10px; font-size: 11px; }

  /* Detailed cards: single column on phone */
  .view-detailed #events-body { grid-template-columns: 1fr; gap: 10px; padding: 10px; }
  .det-title { font-size: 16px; }
  .det-inner { padding: 10px 12px; gap: 6px; }
}

/* ===== Landscape mobile ===== */
@media (max-width: 926px) and (orientation: landscape) {
  #weatherBar { display: none !important; }
  #fancyClock { font-size: 18px; }
  .controls { flex-wrap: nowrap; overflow-x: auto; }
  #stats-panel { display: none !important; }
}
