@font-face {
  font-family: "JetBrains Mono";
  src: url("/static/fonts/JetBrainsMono-Regular.woff2") format("woff2");
  font-weight: 400 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("/static/fonts/JetBrainsMono-Bold.woff2") format("woff2");
  font-weight: 600 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #06090e;
  --panel: #0b1017;
  --panel-elev: #0f1620;
  --border: #1c2a3a;
  --border-strong: #2b3f57;
  --text: #e2e8f0;
  --muted: #7c8da6;
  --dim: #4c5b70;
  --ok: #00e5a0;
  --info: #38bdf8;
  --warn: #f59e0b;
  --crit: #ff3b5c;
  --idle: #64748b;
  --offline: #ef4444;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

.noc-root {
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 4px 5px;
  gap: 4px;
  transition: transform 0.6s ease;
}

/* Top Bar */
.topbar {
  height: 28px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 8px;
  background: var(--panel);
  border: 1px solid var(--border);
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
}

.brand-mark {
  color: var(--ok);
  font-size: 13px;
}

.brand-title {
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.08em;
}

.brand-sep {
  color: var(--dim);
}

.brand-sub {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.1em;
}

.topbar-pills {
  display: flex;
  align-items: center;
  gap: 5px;
  overflow: hidden;
  flex: 1;
  min-width: 0;
  justify-content: center;
}

.svc-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 6px;
  border: 1px solid var(--border);
  background: var(--panel-elev);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  white-space: nowrap;
  cursor: pointer;
}

.svc-pill.active-focus {
  border-color: var(--info);
}

.svc-pill .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.badge {
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.07em;
  border: 1px solid currentColor;
  white-space: nowrap;
}

.badge-ok { color: var(--ok); background: rgba(0, 229, 160, 0.09); }
.badge-info { color: var(--info); background: rgba(56, 189, 248, 0.09); }
.badge-warn { color: var(--warn); background: rgba(245, 158, 11, 0.11); }
.badge-crit { color: var(--crit); background: rgba(255, 59, 92, 0.14); }
.badge-idle { color: var(--idle); background: rgba(100, 116, 139, 0.12); }
.badge-offline { color: var(--offline); background: rgba(239, 68, 68, 0.12); }

.layout-pill {
  background: var(--panel-elev);
  border: 1px solid var(--border-strong);
  color: var(--info);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  cursor: pointer;
}

.ws-indicator {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 700;
}

.ws-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.ws-on { color: var(--ok); }
.ws-on .ws-dot { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.ws-off { color: var(--crit); }
.ws-off .ws-dot { background: var(--crit); }

.clock {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: var(--text);
}

/* Sticky Banner */
.sticky-banner {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sticky-banner.hidden {
  display: none;
}

.sticky-item {
  flex: 1 1 320px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 700;
  border: 1px solid var(--crit);
  background: rgba(255, 59, 92, 0.13);
  color: #ffdce3;
}

.sticky-item.level-warn {
  border-color: var(--warn);
  background: rgba(245, 158, 11, 0.12);
  color: #fef3c7;
}

.sticky-svc {
  text-transform: uppercase;
  padding: 1px 6px;
  border: 1px solid currentColor;
  font-size: 11px;
}

/* Main Grid */
.grid {
  flex: 1;
  min-height: 0;
  display: grid;
  gap: 5px;
}

.grid.layout-0,
.grid.layout-1 {
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
}

.grid.layout-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: 1fr;
}

.grid.layout-3 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
}

.grid.layout-3 .tile:nth-child(3) {
  grid-column: span 2;
}

.grid.layout-4 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
}

.grid.layout-5,
.grid.layout-6 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
}

.grid.layout-many {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
}

/* Service Tile (Neo-TUI Frame) */
.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  min-height: 0;
  padding: 4px 7px;
  background: var(--panel);
  border: 1px solid var(--border);
  overflow: hidden;
}

/* Neo-TUI corner accents */
.tile::before,
.tile::after {
  content: "";
  position: absolute;
  width: 8px;
  height: 8px;
  pointer-events: none;
}

.tile::before {
  top: -1px;
  left: -1px;
  border-top: 2px solid var(--border-strong);
  border-left: 2px solid var(--border-strong);
}

.tile::after {
  bottom: -1px;
  right: -1px;
  border-bottom: 2px solid var(--border-strong);
  border-right: 2px solid var(--border-strong);
}

.tile.status-ok::before,
.tile.status-ok::after { border-color: var(--ok); }

.tile.status-warn {
  border-color: rgba(245, 158, 11, 0.55);
}
.tile.status-warn::before,
.tile.status-warn::after { border-color: var(--warn); }

.tile.status-crit {
  border-color: var(--crit);
  box-shadow: inset 0 0 24px rgba(255, 59, 92, 0.12);
  animation: crit-pulse 2.2s infinite ease-in-out;
}
.tile.status-crit::before,
.tile.status-crit::after { border-color: var(--crit); }

.tile.status-offline {
  border-style: dashed;
  border-color: rgba(239, 68, 68, 0.45);
  opacity: 0.78;
}

@keyframes crit-pulse {
  0%, 100% { box-shadow: inset 0 0 18px rgba(255, 59, 92, 0.1); }
  50% { box-shadow: inset 0 0 32px rgba(255, 59, 92, 0.24); }
}

body.kiosk-tv .tile.status-crit {
  animation: none;
  box-shadow: none;
}

.tile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding-bottom: 3px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.tile.status-crit .tile-header {
  background: rgba(255, 59, 92, 0.08);
  margin: -5px -8px 0;
  padding: 5px 8px 3px;
}

.tile-title-wrap {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.tile-idx {
  color: var(--dim);
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.tile-name {
  font-size: clamp(14px, 1.15vw, 17px);
  font-weight: 800;
  letter-spacing: 0.05em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tile-group {
  font-size: 9.5px;
  font-weight: 700;
  color: var(--muted);
  border: 1px solid var(--border-strong);
  padding: 0 4px;
  text-transform: uppercase;
  white-space: nowrap;
  flex-shrink: 0;
}

.tile-demo {
  font-size: 9.5px;
  font-weight: 700;
  color: var(--warn);
  border: 1px dashed var(--warn);
  padding: 0 4px;
  white-space: nowrap;
  flex-shrink: 0;
}

.tile-status-wrap {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.tile-age {
  font-size: 10.5px;
  color: var(--muted);
}

.tile-summary {
  font-size: 10.5px;
  line-height: 1.2;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
}

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  gap: 4px;
  flex-shrink: 0;
}

.kpi-card {
  background: var(--panel-elev);
  border: 1px solid var(--border);
  padding: 3px 6px;
  min-width: 0;
}

.kpi-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px;
}

.kpi-label {
  font-size: 9.5px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi-value {
  font-size: clamp(19px, 1.65vw, 24px);
  font-weight: 800;
  line-height: 1.12;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi-delta {
  font-size: 9.5px;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
  max-width: 52%;
}

.tone-ok { color: var(--ok); }
.tone-info { color: var(--info); }
.tone-warn { color: var(--warn); }
.tone-crit { color: var(--crit); }
.tone-muted { color: var(--muted); }

/* Gauges & Sparkline row */
.mid-band {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 4px;
  flex-shrink: 0;
}

.mid-band.no-spark {
  grid-template-columns: 1fr;
}

.mid-band.no-gauges {
  grid-template-columns: 1fr;
}

.gauges-box, .spark-box {
  background: var(--panel-elev);
  border: 1px solid var(--border);
  padding: 3px 6px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
}

.gauge-row {
  display: grid;
  grid-template-columns: 68px 1fr auto;
  align-items: center;
  gap: 5px;
  font-size: 10.5px;
}

.gauge-label {
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gauge-bar {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 2px;
  height: 8px;
}

.gauge-seg {
  background: #16202d;
}

.gauge-seg.filled.tone-ok { background: var(--ok); }
.gauge-seg.filled.tone-info { background: var(--info); }
.gauge-seg.filled.tone-warn { background: var(--warn); }
.gauge-seg.filled.tone-crit { background: var(--crit); }
.gauge-seg.filled.tone-muted { background: var(--idle); }

.gauge-num {
  font-weight: 700;
  font-size: 10.5px;
  white-space: nowrap;
}

.spark-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 10px;
  color: var(--muted);
}

.spark-val {
  font-weight: 800;
  font-size: 12px;
}

.spark-canvas,
.spark-wrap {
  position: relative;
  width: 100%;
  height: clamp(22px, 3.8vh, 38px);
  display: block;
  overflow: hidden;
}

.spark-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.spark-dot {
  position: absolute;
  right: 0;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  transform: translate(-1px, -50%);
  pointer-events: none;
}

/* Rows + Logs bottom area */
.tile-lower {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.38fr);
  gap: 4px;
}

.tile-lower.only-one {
  grid-template-columns: 1fr;
}

/* Layout DSL v2 Widgets */
.tile.has-accent::before,
.tile.has-accent::after {
  border-color: var(--tile-accent);
}

.tile-body-v2 {
  flex: 1;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow: hidden;
}

.dsl-split {
  display: grid;
  gap: 3px;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.dsl-stack {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.dsl-hero {
  background: var(--panel-elev);
  border: 1px solid var(--border);
  border-left-width: 3px;
  padding: 4px 7px;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 2px;
  overflow: hidden;
}

.dsl-hero-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
}

.dsl-hero-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dsl-hero-delta {
  font-size: 10.5px;
  font-weight: 800;
  white-space: nowrap;
}

.dsl-hero-main {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.dsl-hero-val {
  font-size: clamp(20px, 1.85vw, 26px);
  font-weight: 800;
  line-height: 1.02;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dsl-hero-sub {
  font-size: 10.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dsl-hero-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 2px;
  border-top: 1px solid var(--border);
  overflow: hidden;
}

.dsl-hero-stat {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  font-size: 10.5px;
  white-space: nowrap;
}

.dsl-hero-stat-lbl {
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 700;
}

.dsl-hero-stat-val {
  font-weight: 800;
}

.dsl-hero-spark {
  height: 22px;
  margin-top: 2px;
}

.dsl-kpi-sm .kpi-value { font-size: clamp(15px, 1.3vw, 19px); }
.dsl-kpi-lg .kpi-value { font-size: clamp(21px, 1.85vw, 27px); }

.dsl-pills {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  overflow: hidden;
}

.dsl-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--panel-elev);
  border: 1px solid var(--border);
  padding: 1px 5px;
  font-size: 9.5px;
  font-weight: 700;
  white-space: nowrap;
}

.dsl-pill .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.dsl-pill-lbl {
  color: var(--muted);
}

.dsl-pill-val {
  font-weight: 800;
}

.dsl-section-title {
  font-size: 9.5px;
  font-weight: 800;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding-bottom: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2px;
  flex-shrink: 0;
}

.dsl-table-box {
  background: #080c12;
  border: 1px solid var(--border);
  padding: 3px 6px;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.dsl-table-head {
  display: grid;
  gap: 6px;
  font-size: 9.5px;
  font-weight: 800;
  color: var(--dim);
  letter-spacing: 0.05em;
  padding-bottom: 2px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.dsl-table-body {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-height: 0;
  overflow: hidden;
}

.dsl-table-row {
  display: grid;
  gap: 6px;
  font-size: 10.5px;
  line-height: 1.2;
}

.dsl-table-cell {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
}

.dsl-banner {
  background: var(--panel-elev);
  border: 1px solid var(--border);
  border-left-width: 3px;
  padding: 3px 7px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
}

.tone-border-ok { border-color: rgba(0, 229, 160, 0.45); border-left-color: var(--ok); }
.tone-border-info { border-color: rgba(56, 189, 248, 0.45); border-left-color: var(--info); }
.tone-border-warn { border-color: rgba(245, 158, 11, 0.5); border-left-color: var(--warn); }
.tone-border-crit { border-color: rgba(255, 59, 92, 0.6); border-left-color: var(--crit); }
.tone-border-muted { border-color: var(--border); }

.rows-box, .logs-box {
  background: #080c12;
  border: 1px solid var(--border);
  padding: 4px 6px;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.kv-row {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  font-size: 10.5px;
  line-height: 1.22;
}

.kv-key {
  color: var(--muted);
  white-space: nowrap;
}

.kv-val {
  font-weight: 700;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.log-line {
  display: flex;
  gap: 5px;
  font-size: 10.5px;
  line-height: 1.22;
  white-space: nowrap;
  overflow: hidden;
}

.log-ts {
  color: var(--dim);
  flex-shrink: 0;
}

.log-lvl {
  font-weight: 800;
  flex-shrink: 0;
  width: 30px;
}

.log-text {
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Bottom Event Ticker */
.bottombar {
  height: 26px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 7px;
  background: var(--panel);
  border: 1px solid var(--border);
  overflow: hidden;
}

.ticker-tag {
  background: var(--panel-elev);
  border: 1px solid var(--border-strong);
  color: var(--info);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 1px 6px;
  flex-shrink: 0;
}

.ticker-list {
  display: flex;
  align-items: center;
  gap: 14px;
  overflow: hidden;
  white-space: nowrap;
  flex: 1;
}

.ticker-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
}

.ticker-time { color: var(--dim); }
.ticker-svc { font-weight: 800; text-transform: uppercase; }
.ticker-msg { color: var(--text); }
.ticker-empty { color: var(--dim); font-size: 12px; }

/* Toasts */
.toast-stack {
  position: fixed;
  top: 56px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 420px;
  max-width: calc(100vw - 32px);
  z-index: 40;
  pointer-events: none;
}

.toast {
  background: #0d141e;
  border: 1px solid var(--border-strong);
  border-left-width: 4px;
  padding: 10px 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.65);
  animation: toast-in 0.2s ease-out;
}

.toast.level-ok { border-left-color: var(--ok); }
.toast.level-info { border-left-color: var(--info); }
.toast.level-warn { border-left-color: var(--warn); }
.toast.level-crit { border-left-color: var(--crit); background: #1a0b10; }

.toast-head {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 3px;
}

.toast-body {
  font-size: 13px;
  color: var(--text);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(16px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Empty & Auth */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--border-strong);
  background: var(--panel);
  gap: 10px;
  text-align: center;
  padding: 24px;
}

.empty-state h2 {
  font-size: 20px;
  letter-spacing: 0.08em;
}

.empty-state p {
  font-size: 13px;
  color: var(--muted);
}

.auth-modal {
  position: fixed;
  inset: 0;
  background: rgba(6, 9, 14, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
}

.auth-modal.hidden { display: none; }

.auth-box {
  width: 440px;
  max-width: calc(100vw - 32px);
  background: var(--panel);
  border: 1px solid var(--border-strong);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--ok);
  letter-spacing: 0.08em;
}

.auth-desc {
  font-size: 13px;
  color: var(--muted);
}

.auth-form {
  display: flex;
  gap: 8px;
}

.auth-form input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 14px;
  padding: 8px 10px;
}

.auth-form button {
  background: var(--ok);
  color: #04120c;
  border: none;
  font-family: var(--font-mono);
  font-weight: 800;
  padding: 8px 14px;
  cursor: pointer;
}

.auth-error {
  font-size: 12px;
  color: var(--crit);
  min-height: 16px;
}
