/* DevOps panel — one stylesheet, grouped by what it styles.
   Dark only: this is an ops console that lives on a second monitor, and a
   theme switch is state nobody asked to manage. */

:root {
  --bg: #0f172a;
  --bg-soft: #0b1220;
  --card: #1e293b;
  --card-hi: #263449;
  --border: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --faint: #64748b;
  --accent: #38bdf8;
  --ok: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --crit: #fb7185;
  --debug: #818cf8;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.mono { font-family: var(--mono); font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.grow { flex: 1; }

/* ---------------------------------------------------------------- login */

#login-view {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 36px;
  width: 360px;
  text-align: center;
}
.login-card h1 { font-size: 18px; margin: 0 0 6px; }
.login-card p { color: var(--muted); margin: 0 0 20px; font-size: 13px; }
.login-card input { width: 100%; margin-bottom: 14px; }
#login-error { color: var(--bad); font-size: 13px; min-height: 18px; margin: 8px 0 0; }

/* ---------------------------------------------------------------- chrome */

header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
  position: sticky;
  top: 0;
  z-index: 20;
}
header h1 { font-size: 15px; margin: 0; font-weight: 600; }
header h1 span { color: var(--accent); }
header .meta { font-size: 12px; color: var(--faint); }

main { padding: 14px 20px 48px; max-width: 1560px; margin: 0 auto; }

/* ---------------------------------------------------------------- cards */

#cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 14px;
  min-width: 0;
}
.card .k {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.card .v { font-size: 20px; font-weight: 700; margin-top: 2px; }
.card .s {
  font-size: 11px;
  color: var(--faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.v.ok { color: var(--ok); }
.v.warn { color: var(--warn); }
.v.bad { color: var(--bad); }
.v.unknown { color: var(--faint); }

/* ---------------------------------------------------------------- tabs */

#tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
  flex-wrap: wrap;
}
#tabs button {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  padding: 8px 14px;
  font-size: 13.5px;
  cursor: pointer;
  border-radius: 0;
}
#tabs button.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}
#tabs button:hover { color: var(--text); }

/* ---------------------------------------------------------------- forms */

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  margin-bottom: 12px;
}
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; color: var(--muted); }

input, select, button, textarea {
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13.5px;
  font-family: inherit;
}
input:focus, select:focus { outline: 1px solid var(--accent); }
button { cursor: pointer; }
button.primary {
  background: var(--accent);
  color: #06263a;
  font-weight: 600;
  border: none;
  padding: 8px 18px;
}
button.primary:hover { filter: brightness(1.1); }
button.ghost { background: transparent; color: var(--muted); }
button.ghost:hover { color: var(--text); border-color: var(--faint); }
button.toggle.on { background: var(--card-hi); color: var(--accent); border-color: var(--accent); }
button:disabled { opacity: .45; cursor: not-allowed; }

.check { display: flex; align-items: center; gap: 6px; padding: 7px 0; font-size: 13px; }
.check input { width: auto; }

/* ---------------------------------------------------------------- tables */

.status-line { color: var(--muted); font-size: 12.5px; margin: 0 0 10px; min-height: 18px; }
.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: 70vh;
}
table { border-collapse: collapse; width: 100%; }
th, td {
  text-align: left;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
th {
  background: var(--card);
  font-size: 12px;
  color: var(--muted);
  position: sticky;
  top: 0;
  z-index: 1;
  font-weight: 600;
}
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(56, 189, 248, .04); }
td.ts { white-space: nowrap; color: var(--muted); font-family: var(--mono); font-size: 12px; }
td.detail { font-family: var(--mono); font-size: 12.5px; word-break: break-word; white-space: pre-wrap; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }

.tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.tag.ok, .tag.active { background: rgba(52, 211, 153, .15); color: var(--ok); }
.tag.bad, .tag.failed, .tag.inactive { background: rgba(248, 113, 113, .15); color: var(--bad); }
.tag.warn { background: rgba(251, 191, 36, .15); color: var(--warn); }
.tag.info { background: rgba(56, 189, 248, .13); color: var(--accent); }
.tag.neutral { background: rgba(148, 163, 184, .15); color: var(--muted); }

h3 { font-size: 13px; margin: 20px 0 8px; color: var(--muted); font-weight: 600; }
h3:first-child { margin-top: 0; }

pre.logbox {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px;
  font: 12px/1.5 var(--mono);
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  max-height: 320px;
}

.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 14px; }
.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.panel h4 { margin: 0 0 8px; font-size: 13px; color: var(--muted); font-weight: 600; }

.notice {
  border: 1px solid var(--border);
  border-left: 3px solid var(--warn);
  background: rgba(251, 191, 36, .06);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 12px;
}
.notice.bad { border-left-color: var(--bad); background: rgba(248, 113, 113, .06); }

/* ---------------------------------------------------------------- charts */

.chart-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px 6px;
  margin-bottom: 12px;
}
.chart-box .head { display: flex; justify-content: space-between; align-items: baseline; }
.chart-box h4 { margin: 0 0 4px; font-size: 13px; color: var(--muted); font-weight: 600; }
.chart-box .now { font-size: 12px; color: var(--text); font-family: var(--mono); }
.chart-box svg { width: 100%; height: 120px; display: block; }
.chart-box svg text { fill: var(--faint); font-size: 10px; font-family: var(--mono); }

.bar-row { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; font-size: 12.5px; }
.bar-row .label { flex: 0 0 auto; max-width: 46%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); }
.bar-row .track { flex: 1; height: 8px; background: var(--bg-soft); border-radius: 4px; overflow: hidden; }
.bar-row .fill { height: 100%; background: var(--accent); }
.bar-row .n { flex: 0 0 auto; color: var(--muted); font-variant-numeric: tabular-nums; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); margin-right: 6px; }
.dot.on { background: var(--ok); }
.dot.pending { background: var(--warn); }

/* ---------------------------------------------------------------- live log */

.live-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
/* Second-level tab bar for picking the log source. Same affordance as the
   main tabs on purpose: one at a time, and it looks like what it does. */
.subtabs {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}
.subtabs button {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  color: var(--muted);
  padding: 7px 13px;
  font-size: 13px;
  font-family: var(--mono);
  cursor: pointer;
}
.subtabs button:hover { color: var(--text); }
.subtabs button.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}
/* A stopped unit still has a journal worth reading, so it stays selectable —
   just dimmed, so "no output" is not mistaken for a broken stream. */
.subtabs button.dim { opacity: .55; }
.subtabs button .state { font-size: 10.5px; color: var(--faint); }

#log-stream {
  background: #060b16;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  height: 62vh;
  min-height: 320px;
  overflow-y: auto;
  overflow-x: auto;
  font: 12px/1.55 var(--mono);
  padding: 8px 0;
  scrollbar-color: var(--faint) #060b16;
}
#log-stream.wrap .line .msg { white-space: pre-wrap; word-break: break-word; }

.line {
  display: flex;
  gap: 10px;
  padding: 0 12px;
  border-left: 2px solid transparent;
}
.line:hover { background: rgba(56, 189, 248, .05); }
.line .lts { color: var(--faint); flex: 0 0 auto; }
.line .msg { white-space: pre; flex: 1; min-width: 0; }
.line.err { border-left-color: var(--bad); }
.line.err .msg { color: var(--bad); }
.line.crit { border-left-color: var(--crit); background: rgba(251, 113, 133, .07); }
.line.crit .msg { color: var(--crit); font-weight: 600; }
.line.warn { border-left-color: var(--warn); }
.line.warn .msg { color: var(--warn); }
.line.debug .msg { color: var(--debug); }
.line.meta { color: var(--faint); font-style: italic; }
.line mark { background: rgba(251, 191, 36, .35); color: inherit; border-radius: 2px; }

.stream-stats {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--faint);
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}
