:root {
  --bg: #0b1220;
  --panel: #121b2e;
  --panel-2: #182338;
  --border: #233044;
  --text: #e2e8f0;
  --dim: #7d8ba1;
  --green: #22c55e;
  --amber: #f59e0b;
  --red: #ef4444;
  --blue: #60a5fa;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 20px clamp(14px, 3vw, 36px) 40px;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

h1 { font-size: 19px; margin: 0; }
h2 { font-size: 15px; margin: 0; color: var(--dim); text-transform: uppercase; letter-spacing: 0.06em; }
.dim { color: var(--dim); font-size: 12.5px; }

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}
.head-left .server-info { display: flex; gap: 10px; align-items: baseline; }
#server-name { font-weight: 600; }
.head-right { display: flex; align-items: center; gap: 14px; }

.pill {
  padding: 5px 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.pill.ok       { background: rgba(34,197,94,.15);  color: var(--green); box-shadow: 0 0 0 1px rgba(34,197,94,.4); }
.pill.warning  { background: rgba(245,158,11,.15); color: var(--amber); box-shadow: 0 0 0 1px rgba(245,158,11,.4); }
.pill.critical { background: rgba(239,68,68,.18);  color: var(--red);   box-shadow: 0 0 0 1px rgba(239,68,68,.5); animation: blink 1.2s infinite; }
.pill.unknown  { background: rgba(125,139,161,.15); color: var(--dim); }
@keyframes blink { 50% { opacity: .55; } }

button {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 13px;
}
button:hover { border-color: var(--blue); }

#active-alerts { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.alert-banner {
  border-radius: 10px;
  padding: 10px 16px;
  font-weight: 600;
  border: 1px solid;
}
.alert-banner.warning  { background: rgba(245,158,11,.1); border-color: rgba(245,158,11,.45); color: #fcd34d; }
.alert-banner.critical { background: rgba(239,68,68,.12); border-color: rgba(239,68,68,.5);  color: #fca5a5; }
.alert-banner .since { float: right; font-weight: 400; font-size: 12px; opacity: .8; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 26px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
}
.card .label { color: var(--dim); font-size: 12px; }
.card .value { font-size: 24px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.card .sub   { color: var(--dim); font-size: 11.5px; margin-top: 2px; min-height: 14px; }
.card.warn { border-color: rgba(245,158,11,.55); }
.card.warn .value { color: var(--amber); }
.card.crit { border-color: rgba(239,68,68,.6); }
.card.crit .value { color: var(--red); }

.tab-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 22px;
}
.tab-nav button {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 10px 16px;
  margin-bottom: -1px;
  color: var(--dim);
  font-size: 13.5px;
  font-weight: 600;
}
.tab-nav button:hover { color: var(--text); border-bottom-color: var(--border); }
.tab-nav button.active { color: var(--blue); border-bottom-color: var(--blue); }
.tab-count {
  color: var(--dim);
  font-weight: 400;
  font-size: 12px;
  margin-left: 2px;
}
.tab-nav button.active .tab-count { color: var(--blue); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.charts-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.ranges { display: flex; gap: 6px; }
.ranges button.active { border-color: var(--blue); color: var(--blue); }

.charts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr));
  gap: 14px;
  margin-bottom: 30px;
}
@media (max-width: 480px) { .charts { grid-template-columns: 1fr; } }
.chart-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px 8px;
}
.chart-box h3 { margin: 0; font-size: 13px; color: var(--dim); font-weight: 600; }
.chart-box .canvas-wrap { position: relative; height: 190px; }
.chart-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.chart-tools { display: flex; gap: 4px; flex-shrink: 0; }
.chart-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--dim);
  font-size: 12px;
  line-height: 1;
  padding: 3px 7px;
  cursor: pointer;
  text-decoration: none;
}
.chart-btn:hover { border-color: var(--blue); color: var(--blue); }
.help-btn.active { color: var(--blue); border-color: var(--blue); }
.chart-help {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 12px;
  line-height: 1.45;
  padding: 8px 10px;
  margin-bottom: 8px;
}

.alerts-section { margin-bottom: 30px; }
.alerts-section h2 { margin-bottom: 10px; }
table { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: 12px; overflow: hidden; }
th, td { text-align: left; padding: 8px 14px; border-bottom: 1px solid var(--border); font-size: 13px; }
th { color: var(--dim); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
tr:last-child td { border-bottom: none; }
tr.active-row td { background: rgba(239,68,68,.05); }

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}
.badge.warning  { background: rgba(245,158,11,.15); color: var(--amber); }
.badge.critical { background: rgba(239,68,68,.18); color: var(--red); }
.badge.resolved { background: rgba(34,197,94,.15); color: var(--green); }

.queries-section { margin-bottom: 30px; }
.queries-section h2 { margin-bottom: 10px; }
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.section-head h2 { margin-bottom: 0; }
.export-btn {
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 8px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}
.export-btn:hover { border-color: var(--blue); color: var(--blue); }
.head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.clear-btn { font-size: 12px; padding: 5px 12px; }
.clear-btn:hover { border-color: var(--red); color: var(--red); }
#pause-btn { font-size: 12px; padding: 5px 12px; }
#pause-btn.paused { border-color: var(--amber); color: var(--amber); }
#live-section.paused #running-table { opacity: .6; }
.count { color: var(--dim); font-size: 12px; font-weight: 400; }
code, .query-text {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: #cbd5e1;
  white-space: pre-wrap;
  word-break: break-word;
}
.query-text {
  display: block;
  max-height: 200px;
  overflow-y: auto;
}
.query-cell { max-width: 640px; }
td.runtime { font-variant-numeric: tabular-nums; white-space: nowrap; }
td.runtime.long { color: var(--amber); font-weight: 600; }
td.runtime.verylong { color: var(--red); font-weight: 700; }
.lvl { font-weight: 700; text-transform: uppercase; font-size: 11px; }
.lvl.error, .lvl.fatal { color: var(--red); }
.lvl.warning { color: var(--amber); }
.lvl.info { color: var(--blue); }
.copy-row { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.copy-btn {
  font-size: 11px;
  line-height: 1;
  padding: 3px 7px;
  border-radius: 6px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--dim);
  cursor: pointer;
  white-space: nowrap;
}
.copy-btn:hover { border-color: var(--blue); color: var(--blue); }
.copy-btn.copied { border-color: var(--green); color: var(--green); }
.snap-q .copy-row { margin: 4px 0; }

.snap-btn {
  font-size: 11px;
  padding: 2px 8px;
  margin-left: 8px;
  border-radius: 6px;
  background: rgba(96,165,250,.12);
  border: 1px solid rgba(96,165,250,.4);
  color: var(--blue);
  cursor: pointer;
}
.snap-row td { background: rgba(96,165,250,.04); padding: 0; }
.snap-inner { padding: 10px 14px; }
.snap-inner .snap-q { border-left: 2px solid var(--border); padding: 4px 0 4px 10px; margin: 6px 0; }
.snap-inner .snap-meta { color: var(--dim); font-size: 11px; }
.bind-vars {
  color: #94a3b8;
  font-size: 11px;
  margin-top: 3px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  word-break: break-word;
  max-height: 200px;
  overflow-y: auto;
}

footer { text-align: center; margin-top: 10px; }

/* ---------- kiosk mode (?kiosk) — wall displays ---------- */
body.kiosk { padding-top: 28px; }
body.kiosk #test-alert-btn,
body.kiosk .chart-tools,
body.kiosk .chart-help,
body.kiosk .ranges,
body.kiosk .tab-nav,
body.kiosk .alerts-section,
body.kiosk .queries-section,
body.kiosk footer { display: none; }
/* Kiosk shows only the charts; force the history panel visible regardless of tab state. */
body.kiosk .tab-panel[data-panel="history"] { display: block; }
body.kiosk h1 { font-size: 26px; }
body.kiosk #server-name { font-size: 18px; }
body.kiosk .pill { font-size: 18px; padding: 8px 22px; }
body.kiosk #last-poll { font-size: 15px; }
body.kiosk .cards { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
body.kiosk .card .label { font-size: 15px; }
body.kiosk .card .value { font-size: 40px; }
body.kiosk .card .sub { font-size: 14px; }
body.kiosk .alert-banner { font-size: 18px; padding: 14px 20px; }
body.kiosk .chart-box h3 { font-size: 15px; }
body.kiosk .chart-box .canvas-wrap { height: 230px; }
body.kiosk .charts-head h2 { font-size: 17px; }

/* ---------- Debbie (TK-2212): brand, server rows, notifications, sign-in ---------- */
:root { --dim: #94a3b8; --pink: #f472b6; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
button { min-height: 32px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { display: block; }
.brand h1 { font-size: 22px; letter-spacing: .01em; }

.servers { margin: 0 0 18px; }
.servers h2 { margin-bottom: 8px; }
#sandbox-note:empty { display: none; }
.server-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 8px; }
.server-row {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  text-align: left; padding: 10px 12px; border-radius: 10px; background: var(--panel); border: 1px solid var(--border);
}
.server-row.here { border-color: var(--pink); box-shadow: 0 0 0 1px var(--pink) inset; }
.sr-main { display: flex; flex-direction: column; min-width: 0; }
.sr-name { font-weight: 600; }
.sr-sub { color: var(--dim); font-size: 12.5px; overflow-wrap: anywhere; }
.chip { flex: none; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; border: 1px solid currentColor; }
.chip.ok { color: #4ade80; }
.chip.warning { color: #fbbf24; }
.chip.critical { color: #f87171; }
.chip.unknown { color: var(--dim); }

.bell-dot { margin-left: 4px; padding: 0 6px; border-radius: 999px; background: rgba(74,222,128,.15); color: #4ade80; font-size: 11px; font-weight: 700; }
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 12px; padding: 16px; width: min(520px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0,0,0,.6); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.h3 { font-size: 13px; color: var(--dim); margin: 16px 0 6px; text-transform: uppercase; letter-spacing: .06em; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; padding: 10px 12px; }
.switch .knob { width: 40px; height: 22px; border-radius: 999px; background: var(--border); position: relative; flex: none; }
.switch .knob::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--text); transition: left .15s; }
.switch[aria-checked="true"] .knob { background: #16a34a; }
.switch[aria-checked="true"] .knob::after { left: 21px; }
.why { color: #fbbf24; }
.push-log { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 13px; max-height: 40vh; overflow: auto; }

body.signin { display: grid; place-items: center; min-height: 100vh; min-height: 100dvh; padding: 16px; }
.signin-card { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 24px; text-align: center; }
.signin-mark { width: 160px; height: auto; }
.signin-card h1 { font-size: 26px; margin: 8px 0 4px; }
.signin-lede { color: var(--dim); margin: 0 0 18px; }
.signin-card form { display: grid; gap: 8px; text-align: left; }
.signin-card input { font: inherit; color: var(--text); background: var(--bg); border: 1px solid #64748b; border-radius: 8px; padding: 10px 12px; min-height: 44px; }
.signin-error { color: #f87171; margin: 0; min-height: 1.5em; }
button.primary { background: #db2777; border-color: #db2777; color: #fff; font-weight: 700; min-height: 44px; }
button.primary:hover { background: #be185d; }

@media (max-width: 600px) {
  header { align-items: flex-start; }
  .head-right { flex-wrap: wrap; gap: 8px; }
}

/* 320 px reflow: grid items may shrink below their content, and the chart canvas follows */
.chart-box { min-width: 0; }
