* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 13px;
  line-height: 1.4;
  background: #fff;
  color: #000;
}

a { color: inherit; }

.cell {
  border: 1px solid #000;
  padding: 5px 7px;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.module .cell {
  border: 0;
  border-radius: 0;
  padding: 5px 7px;
}

.module > .panel-head {
  border-bottom: 1px solid #eee;
  padding-bottom: 6px;
}

.module > .meta {
  border-top: 1px solid #eee;
  padding-top: 6px;
}

header.cell {
  margin: 8px 8px 0;
  padding: 8px 10px;
}

.header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.header-main {
  flex: 1 1 auto;
  min-width: 0;
}

.header-clock {
  flex: 0 0 auto;
  display: block;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  text-align: left;
  line-height: 1.2;
}

.header-clock:hover .doom-clock--header,
.header-clock:focus-visible .doom-clock--header {
  background: #fafafa;
  outline: 2px solid #000;
  outline-offset: 1px;
}

.doom-clock {
  display: flex;
  align-items: center;
  gap: 10px;
}

.doom-clock--header {
  gap: 8px;
  padding: 4px 8px;
  border: 1px solid #000;
  background: #fff;
}

.doom-clock--large {
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 16px 12px 12px;
  border: 1px solid #000;
  background: #fafafa;
  margin-bottom: 8px;
}

.doom-analog { flex: 0 0 auto; line-height: 0; }

.doom-analog-face {
  display: block;
  width: 52px;
  height: 52px;
}

.doom-clock--large .doom-analog-face {
  width: min(168px, 52vw);
  height: min(168px, 52vw);
}

.doom-digital {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-family: ui-monospace, "SF Mono", "Roboto Mono", "Cascadia Mono", monospace;
  font-variant-numeric: tabular-nums;
}

.doom-digital--compact { min-width: 0; }

.doom-digital-wall {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1.1;
}

.doom-digital-count {
  font-size: 15px;
  font-weight: 700;
  color: #c1121f;
  letter-spacing: 0.06em;
  line-height: 1;
}

.doom-digital-label {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 7px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.55;
}

.doom-digital--large { align-items: center; text-align: center; }

.doom-lcd {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 14px;
  border: 2px solid #111;
  background: #0a0a0a;
  min-width: min(280px, 88vw);
}

.doom-lcd-row {
  display: block;
  color: #ff3b3b;
  text-shadow: 0 0 8px rgba(255, 60, 60, 0.45);
  letter-spacing: 0.08em;
  line-height: 1;
}

.doom-lcd-row--wall {
  font-size: clamp(28px, 8vw, 40px);
  font-weight: 600;
  opacity: 0.92;
}

.doom-lcd-row--count {
  font-size: clamp(36px, 10vw, 52px);
  font-weight: 700;
}

.doom-digital-meta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.doom-digital-sec {
  font-size: 14px;
  font-weight: 700;
  color: #c1121f;
  letter-spacing: 0.12em;
}

.doom-digital-sec small {
  font-size: 10px;
  opacity: 0.7;
  letter-spacing: 0.14em;
}

.doom-digital--large .doom-digital-label {
  font-size: 10px;
}

@media (max-width: 520px) {
  .header-row { flex-wrap: wrap; }
  .header-clock { margin-left: auto; }
  .doom-analog-face { width: 44px; height: 44px; }
  .doom-digital-wall { font-size: 10px; }
  .doom-digital-count { font-size: 13px; }
}

h1 {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-bottom: 6px;
  font-size: 12px;
}

nav button {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  font-size: 11px;
  opacity: 0.7;
}

#layout-hint { font-style: italic; opacity: 0.85; }

#summary { font-weight: 600; opacity: 0.9; }

.filter-wrap { display: inline-flex; align-items: center; }

.filter-wrap input {
  width: 7.5rem;
  max-width: 40vw;
  padding: 2px 6px;
  border: 1px solid #000;
  background: #fff;
  font: inherit;
  font-size: 11px;
}

:root {
  --desk-gap: 12px;
  --desk-cell: 220px;
  --desk-row: 200px;
}

#btn-alerts[aria-pressed="true"],
#btn-urgent[aria-pressed="true"] { font-weight: 600; }

.desk {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--desk-cell)), 1fr));
  grid-auto-rows: minmax(var(--desk-row), auto);
  grid-auto-flow: dense;
  gap: var(--desk-gap);
  padding: var(--desk-gap);
  margin: 0;
  align-items: stretch;
}

.module--xl {
  grid-column: span 2;
  grid-row: span 2;
}

.module--lg {
  grid-column: span 2;
}

.module--sm {
  grid-row: span 1;
}

@media (max-width: 720px) {
  .module--xl {
    grid-column: span 2;
    grid-row: span 1;
  }
  .module--lg { grid-column: span 2; }
}

@media (max-width: 480px) {
  .desk { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .module--xl,
  .module--lg { grid-column: span 2; }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.module--loading .metric .big { opacity: 0.35; }

.module--loading .viz::after {
  content: "";
  display: block;
  height: 56px;
  background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite linear;
}

@media (min-width: 1024px) {
  .module--loading .viz::after { height: 72px; }
}

.module--map.module--loading .viz::after { height: 72px; }

@media (min-width: 1024px) {
  .module--map.module--loading .viz::after { height: 100%; min-height: 96px; }
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.module[hidden] { display: none !important; }

.module {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
  min-height: 0;
  border: 1px solid #000;
  background: #fff;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
}

.module > .viz {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.module--xl .metric .big { font-size: clamp(28px, 3vw, 40px); }
.module--lg .metric .big { font-size: clamp(24px, 2.6vw, 34px); }
.module--sm .metric .big { font-size: clamp(18px, 2vw, 24px); }

.module--xl .panel-head h2,
.module--lg .panel-head h2 { font-size: 11px; }

.module--map .viz-map {
  flex: 1 1 auto;
  width: 100%;
  min-height: 120px;
  aspect-ratio: auto;
  max-height: none;
  position: relative;
  padding: 0;
  overflow: hidden;
}

.module--xl.module--map .viz-map { min-height: 180px; }
.module--lg.module--map .viz-map { min-height: 140px; }

.module--sm .viz-chart { min-height: 36px; max-height: 44px; }
.module--sm .sub { -webkit-line-clamp: 2; }

.glance {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 2px 7px 4px;
  min-height: 0;
}

.glance:empty { display: none; padding: 0; }

.glance-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  padding: 3px 7px;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  font-size: 10px;
  line-height: 1.2;
  background: #fafafa;
}

.glance-k {
  opacity: 0.6;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 9px;
}

.glance-v {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.glance-chip--bad { border-color: #fecaca; background: #fef2f2; color: #991b1b; }
.glance-chip--warn { border-color: #fed7aa; background: #fff7ed; color: #9a3412; }
.glance-chip--ok { border-color: #bbf7d0; background: #f0fdf4; color: #166534; }
.glance-chip--neutral { border-color: #e5e7eb; background: #f9fafb; color: #374151; }

.module .viz-chart {
  width: 100%;
  flex: 1 1 auto;
  min-height: 72px;
  max-height: none;
  aspect-ratio: 320 / 96;
  display: block;
  overflow: visible;
}

.module .viz-chart--medium {
  min-height: 88px;
  aspect-ratio: 320 / 96;
}

.module .viz-chart--short {
  min-height: 52px;
  aspect-ratio: 320 / 48;
}

.module--compact .sub {
  -webkit-line-clamp: 2;
}

.module--compact .list {
  max-height: 4.2em;
  font-size: 10px;
}

.module--compact .tier-bars {
  margin-bottom: 2px;
}

.module--compact .tier-bars .bar.cell {
  padding: 3px 5px;
}

.module--compact .tier-bars .bar .track {
  height: 6px;
}

.value-bars + .list,
.tier-bars + .list {
  margin-top: 4px;
  border-top: 1px solid #eee;
  padding-top: 2px;
}

.module--xl .viz-chart,
.module--lg .viz-chart {
  min-height: 72px;
  aspect-ratio: 320 / 88;
}

.module .list {
  flex: 1 1 auto;
  font-size: 11px;
  max-height: none;
  overflow: auto;
}

.module--xl .list,
.module--lg .list { font-size: 12px; }

.module .viz-spiral {
  width: 100%;
  flex: 1 1 auto;
  min-height: 100px;
  max-height: none;
  display: block;
}

.module--xl .viz-spiral { min-height: 160px; }

.module .viz-gauge-wrap { flex: 1 1 auto; display: flex; align-items: center; justify-content: center; }
.module .viz-gauge { max-width: min(180px, 100%); }

.module:hover,
.module:focus-visible {
  background: #fafafa;
  outline: 2px solid #000;
  outline-offset: -2px;
}

.module:active { background: #f0f0f0; }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-wrap: nowrap;
}

.panel-head h2 {
  margin: 0;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.55;
  flex: 0 0 auto;
  max-width: 42%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 2px 5px;
  border-radius: 3px;
  background: #f3f4f6;
  color: #4b5563;
}

@media (min-width: 1024px) {
  .desk .module .status {
    font-size: 10px;
    max-width: 48%;
    padding: 3px 7px;
  }
}

.status.strong { opacity: 1; font-weight: 700; }

.status--critical {
  background: #fee2e2;
  color: #991b1b;
}

.status--high {
  background: #ffedd5;
  color: #9a3412;
}

.status--elevated {
  background: #fef3c7;
  color: #92400e;
}

.status--calm {
  background: #ecfdf5;
  color: #166534;
}

.module--sev-high {
  border-left: 4px solid #dc2626;
  background: linear-gradient(90deg, #fef2f2 0%, #fff 28%);
}

.module--sev-med {
  border-left: 4px solid #f97316;
  background: linear-gradient(90deg, #fff7ed 0%, #fff 28%);
}

.module--sev-low {
  border-left: 4px solid #eab308;
  background: linear-gradient(90deg, #fefce8 0%, #fff 24%);
}

.module--sev-calm {
  border-left: 4px solid #d1d5db;
}

.module--sev-high .panel-head h2::before,
.module--sev-med .panel-head h2::before,
.module--sev-low .panel-head h2::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: middle;
  transform: translateY(-1px);
}

.module--sev-high .panel-head h2::before { background: #dc2626; box-shadow: 0 0 0 2px #fecaca; }
.module--sev-med .panel-head h2::before { background: #f97316; box-shadow: 0 0 0 2px #fed7aa; }
.module--sev-low .panel-head h2::before { background: #eab308; box-shadow: 0 0 0 2px #fef08a; }

.module--slot-hidden {
  display: none !important;
}

.metric {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 6px;
}

.metric .big {
  font-size: clamp(17px, 2.4vw, 22px);
  font-weight: 600;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.metric .unit {
  font-size: 11px;
  opacity: 0.65;
  min-width: 0;
  overflow-wrap: anywhere;
  line-height: 1.2;
}

.metric--center { justify-content: center; text-align: center; }

.sub {
  font-size: 11px;
  opacity: 0.65;
  overflow-wrap: anywhere;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.module--xl .sub,
.module--lg .sub { font-size: 12px; -webkit-line-clamp: 4; }

.meta {
  font-size: 10px;
  opacity: 0.5;
  display: flex;
  justify-content: space-between;
  gap: 6px;
  flex-wrap: nowrap;
}

.meta .src {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meta span:last-child { flex-shrink: 0; }

.viz { padding: 0; display: flex; flex-direction: column; min-height: 0; }

.viz-chart {
  width: 100%;
  aspect-ratio: 320 / 96;
  min-height: 72px;
  max-height: 110px;
  display: block;
  overflow: visible;
}

.viz-chart--short {
  aspect-ratio: 320 / 56;
  min-height: 48px;
  max-height: 64px;
}

.viz-chart--medium {
  aspect-ratio: 320 / 96;
  min-height: 84px;
  max-height: 120px;
}

.chart-axis-tick { fill: #666; font-family: inherit; }
.chart-axis-title { fill: #444; font-weight: 600; font-family: inherit; }

.chart-block { display: flex; flex-direction: column; gap: 4px; min-width: 0; }

.chart-timeframe {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 0 2px 2px;
}

.chart-timeframe .chart-range {
  border: 1px solid #ccc;
  background: #f5f5f5;
  color: #333;
  font: inherit;
  font-size: 10px;
  line-height: 1.2;
  padding: 2px 7px;
  border-radius: 999px;
  cursor: pointer;
}

.chart-timeframe .chart-range.active {
  background: #111;
  border-color: #111;
  color: #fff;
}

.bars-axis-label {
  font-size: 10px;
  color: #666;
  padding: 0 4px 2px;
}

.viz-gauge-wrap { display: flex; justify-content: center; padding: 3px 4px; }
.viz-gauge {
  width: 100%;
  max-width: 140px;
  height: auto;
  aspect-ratio: 200 / 112;
  display: block;
}

.viz-clock { display: flex; justify-content: center; padding: 4px; }

.doom-clock--large { width: 100%; }

.viz-spiral {
  width: 100%;
  max-height: 72px;
  display: block;
}
.viz-spiral--large {
  max-height: none;
  width: min(320px, 100%);
  margin: 0 auto;
}

.viz-map {
  width: 100%;
  aspect-ratio: 16 / 10;
  min-height: 72px;
  max-height: 88px;
  position: relative;
  padding: 0;
  overflow: hidden;
}

.viz-map > .map { position: absolute; inset: 0; width: 100%; height: 100%; }

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  font-size: 9px;
  opacity: 0.75;
  padding: 0 2px 2px;
}

.map-legend span { display: inline-flex; align-items: center; gap: 3px; }
.map-legend i { width: 6px; height: 6px; border-radius: 50%; border: 1px solid rgba(0,0,0,.3); display: inline-block; }
.map-legend--heat { gap: 6px; }
.map-legend--heat .heat-gradient-bar {
  flex: 1;
  width: 72px;
  height: 7px;
  border-radius: 4px;
  border: 1px solid rgba(0,0,0,.35);
  background: linear-gradient(90deg, #fef08a 0%, #eab308 28%, #f97316 52%, #dc2626 76%, #7f1d1d 100%);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08);
}

.leaflet-container { background: #e8e8e8; font-size: 8px; }
.leaflet-control-zoom { display: none; }
.leaflet-control-attribution { font-size: 7px; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.leaflet-popup-content { margin: 6px 8px; font-size: 11px; line-height: 1.35; }
.leaflet-popup-content .meta-line { opacity: 0.65; font-size: 10px; margin-top: 2px; }

.bars { display: flex; flex-direction: column; gap: 4px; font-size: 11px; }
.bar.cell {
  display: grid;
  grid-template-columns: minmax(42px, 54px) minmax(0, 1fr) auto;
  align-items: center;
  gap: 5px;
  padding: 4px 5px;
  border: 1px solid #eee;
}
.bar .name { opacity: 0.65; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; }
.bar .track { height: 5px; background: #e8e8e8; overflow: hidden; }
.bar .fill { height: 100%; transition: width 0.5s ease; }
.bar .val { font-variant-numeric: tabular-nums; text-align: right; min-width: 20px; font-size: 10px; }

.list { font-size: 10px; max-height: 72px; overflow: auto; }
.list .row {
  display: flex;
  justify-content: space-between;
  gap: 5px;
  padding: 3px 0;
  border-top: 1px solid #eee;
}
.list .row:first-child { border-top: 0; }
.list .row .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .row .v { flex-shrink: 0; opacity: 0.7; font-variant-numeric: tabular-nums; }

.nodata { opacity: 0.45; font-size: 10px; padding: 6px; border: 1px solid #000; }
.err { font-size: 10px; opacity: 0.75; overflow-wrap: anywhere; }

footer.cell {
  margin: 0 8px 8px;
  font-size: 10px;
  opacity: 0.7;
  line-height: 1.5;
}

/* Detail modal */
.detail-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.detail-overlay[hidden] { display: none; }

.detail-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(2px);
}

.detail-dialog {
  position: relative;
  width: min(920px, 100%);
  max-height: min(92vh, 900px);
  background: #fff;
  border: 1px solid #000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
}

.detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}

.detail-head-main {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}

.detail-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: none;
}

.detail-close {
  border: 1px solid #000;
  background: #fff;
  width: 32px;
  height: 32px;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}

.detail-close:hover { background: #f5f5f5; }

.detail-body {
  overflow: auto;
  padding: 0 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.detail-metric {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 10px 12px;
  border: 1px solid #000;
}

.detail-metric .big {
  font-size: clamp(28px, 5vw, 42px);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.detail-metric .unit { font-size: 14px; opacity: 0.65; }

.detail-section {
  border: 1px solid #000;
  padding: 10px 12px;
}

.detail-section h3 {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.detail-facts {
  margin: 0;
  padding-left: 18px;
  font-size: 13px;
  line-height: 1.55;
}

.detail-facts li + li { margin-top: 6px; }

.detail-note {
  font-size: 12px;
  opacity: 0.7;
  line-height: 1.5;
}

.detail-meta {
  font-size: 11px;
  opacity: 0.55;
  padding-top: 4px;
}

.detail-chart {
  width: 100%;
  aspect-ratio: 640 / 168;
  min-height: 140px;
  max-height: 240px;
  display: block;
  overflow: visible;
}

.detail-chart--tall {
  aspect-ratio: 640 / 228;
  max-height: 280px;
}

.detail-map {
  width: 100%;
  aspect-ratio: 16 / 10;
  min-height: 220px;
  max-height: 360px;
  position: relative;
  border: 1px solid #000;
}

.detail-map > .map { position: absolute; inset: 0; width: 100%; height: 100%; }

.detail-overlay .leaflet-control-zoom { display: block; }

.detail-list { font-size: 12px; max-height: 280px; overflow: auto; }
.detail-list .row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 0;
  border-top: 1px solid #eee;
}
.detail-list .row:first-child { border-top: 0; }

.detail-loading { padding: 24px; opacity: 0.6; font-size: 13px; }

.ad-slot {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 50px;
  margin: 0;
  overflow: hidden;
}

.ad-slot--leader {
  border-bottom: 1px solid #000;
  min-height: 60px;
  background: #fafafa;
}

.ad-slot--footer {
  min-height: 90px;
  margin-bottom: 8px;
}

.ad-slot--detail {
  min-height: 50px;
  border-bottom: 1px solid #eee;
  background: #fafafa;
}

.ad-slot ins.adsbygoogle {
  display: block;
  width: 100%;
  max-width: 100%;
}

.detail-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 640px) {
  .detail-grid-2 { grid-template-columns: 1fr; }
  .detail-overlay { padding: 8px; }
}
