/* ============================================================
   HELM · ops console
   Dense, dark, tabular. Reads the same on a phone and a monitor.
   ============================================================ */

:root {
  --bg: #0a0c0f;
  --panel: #0e1116;
  --panel-2: #12161c;
  --panel-3: #171c23;
  --line: #1b2129;
  --line-2: #29323d;
  --text: #d8dde4;
  --dim: #8b949f;
  --faint: #5a636f;

  --accent: #4c9aff;
  --accent-soft: rgba(76, 154, 255, 0.13);
  --ok: #3fb27f;
  --ok-soft: rgba(63, 178, 127, 0.13);
  --warn: #d9a13c;
  --warn-soft: rgba(217, 161, 60, 0.13);
  --crit: #e2564c;
  --crit-soft: rgba(226, 86, 76, 0.13);
  --info: #7f8ea3;

  --ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, 'JetBrains Mono', 'SF Mono', Menlo, monospace;

  --rail-w: 208px;
  --top-h: 52px;
  --tab-h: 56px;
  --r: 4px;
  --pad: 16px;
  --row-y: 8px;
  --fs: 13px;

  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

/* Compact trades padding for rows on screen; it is a per-device preference so
   the phone can stay roomy while the monitor gets dense. */
html[data-density="compact"] { --pad: 11px; --row-y: 5px; --fs: 12px; }
html[data-density="roomy"]   { --pad: 22px; --row-y: 11px; --fs: 13.5px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--ui);
  font-size: var(--fs);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
  overscroll-behavior-y: none;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; background: none; border: none; }
button { cursor: pointer; }
svg { display: block; }
[hidden] { display: none !important; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #242c36; }
::-webkit-scrollbar-thumb:hover { background: #313b47; }

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.dim { color: var(--dim); }
.faint { color: var(--faint); }

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

.boot {
  position: fixed; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px;
  background: var(--bg); z-index: 90;
}
.boot-wheel { animation: wheel 3.4s linear infinite; }
@keyframes wheel { to { transform: rotate(360deg); } }
.boot-mark {
  font-family: var(--mono); font-size: 15px; letter-spacing: 0.4em;
  color: var(--faint); animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }

.login {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
  overflow-y: auto;
}
.login-card {
  width: 100%; max-width: 360px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 26px 22px;
}
.login-brand { display: flex; align-items: center; gap: 13px; margin-bottom: 22px; }
.login-mark { font-family: var(--mono); font-size: 19px; letter-spacing: 0.3em; line-height: 1.2; }
.login-tag { font-size: 11px; color: var(--faint); letter-spacing: 0.14em; text-transform: uppercase; margin-top: 2px; }
.login-sub { color: var(--dim); font-size: 12.5px; margin-bottom: 6px; line-height: 1.65; }
.login-form { display: grid; gap: 9px; }
.login-form label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--faint); margin-top: 6px; }
.login-form input {
  width: 100%;
  background: var(--panel-2); border: 1px solid var(--line-2);
  border-radius: var(--r); padding: 13px 14px;
  /* 16px keeps iOS from zooming the whole page when the field is focused. */
  font-size: 16px;
}
.login-form input:focus { outline: none; border-color: var(--accent); background: var(--panel-3); }
.btn-lg { padding: 13px 16px; font-size: 14px; width: 100%; margin-top: 4px; }

.code-wrap { position: relative; }
#login-code {
  font-family: var(--mono); letter-spacing: 0.5em; text-align: center;
  font-size: 24px; padding: 14px 10px 14px 20px; caret-color: var(--accent);
}
#login-code::placeholder { letter-spacing: 0.4em; color: var(--faint); }

.login-links { display: flex; justify-content: space-between; gap: 10px; margin-top: 12px; }
.link-btn { color: var(--dim); font-size: 12px; padding: 6px 2px; text-decoration: underline; text-underline-offset: 3px; }
.link-btn:hover { color: var(--text); }

.login-msg { margin-top: 14px; font-size: 12.5px; min-height: 18px; color: var(--dim); line-height: 1.55; }
.login-msg.err { color: #ff9d95; }
.login-msg.ok { color: #6bd6a4; }

.login-restore { margin-top: 16px; font-size: 12.5px; color: var(--dim); display: flex; align-items: center; gap: 9px; }
.spinner {
  width: 13px; height: 13px; border-radius: 50%; flex: none;
  border: 2px solid var(--line-2); border-top-color: var(--accent);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 420px) {
  .login { align-items: flex-start; padding-top: 8vh; }
  .login-card { padding: 22px 18px; border: none; background: transparent; }
}

/* ---------------- buttons ---------------- */

.btn {
  border: 1px solid var(--line-2); border-radius: var(--r);
  padding: 9px 14px; font-size: 12.5px; font-weight: 500;
  background: var(--panel-2); transition: border-color .12s, background .12s, opacity .12s;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:hover { border-color: #3a4551; background: var(--panel-3); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent-soft); border-color: rgba(76,154,255,.4); color: #a8ccff; }
.btn-primary:hover { background: rgba(76,154,255,.2); }
.btn-danger { background: var(--crit-soft); border-color: rgba(226,86,76,.4); color: #ffa79f; }
.btn-danger:hover { background: rgba(226,86,76,.2); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--dim); }
.btn-ghost:hover { color: var(--text); }
.btn-sm { padding: 6px 10px; font-size: 11.5px; }
.btn-xs { padding: 4px 8px; font-size: 11px; border-radius: 3px; }

.icon-btn {
  width: 32px; height: 32px; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: var(--r); color: var(--dim);
  background: var(--panel-2); position: relative;
}
.icon-btn:hover { color: var(--text); border-color: var(--line-2); }

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

.top {
  position: fixed; top: 0; left: 0; right: 0; height: var(--top-h);
  display: flex; align-items: center; gap: 12px; padding: 0 14px;
  background: rgba(10,12,15,.94); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); z-index: 40;
  padding-top: env(safe-area-inset-top);
  height: calc(var(--top-h) + env(safe-area-inset-top));
}
.brand {
  font-family: var(--mono); font-size: 13px; letter-spacing: 0.26em;
  display: inline-flex; align-items: center; gap: 8px; flex: none; color: var(--text);
}
.brand .wheel-sm { color: var(--accent); flex: none; }
.top-status { flex: 1; min-width: 0; display: flex; gap: 12px; align-items: center; font-size: 11.5px; color: var(--dim); overflow: hidden; }
.top-status .ts-item { white-space: nowrap; display: inline-flex; gap: 5px; align-items: center; }
.top-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.badge {
  position: absolute; top: -5px; right: -5px; min-width: 16px; height: 16px;
  padding: 0 4px; border-radius: 8px; background: var(--crit); color: #fff;
  font-size: 10px; font-weight: 700; display: grid; place-items: center;
  font-family: var(--mono);
}
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); transition: background .3s; }
.live-dot.on { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }

.rail {
  position: fixed; top: calc(var(--top-h) + env(safe-area-inset-top)); bottom: 0; left: 0; width: var(--rail-w);
  background: var(--panel); border-right: 1px solid var(--line);
  padding: 10px 8px; display: flex; flex-direction: column; gap: 1px; z-index: 35;
  overflow-y: auto;
}
.rail-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border-radius: var(--r); color: var(--dim); font-size: 12.5px;
}
.rail-item:hover { background: var(--panel-2); color: var(--text); }
.rail-item.active { background: var(--panel-3); color: var(--text); }
.rail-ico { width: 14px; text-align: center; opacity: .65; font-size: 12px; }
.rail-tag {
  margin-left: auto; font-family: var(--mono); font-size: 10px;
  padding: 1px 5px; border-radius: 3px; background: var(--panel-3); color: var(--faint);
}
.rail-tag.crit { background: var(--crit-soft); color: #ff9d95; }
.rail-tag.warn { background: var(--warn-soft); color: #f0c268; }
.rail-tag.ok { background: var(--ok-soft); color: #6bd6a4; }
.rail-group {
  font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.16em;
  color: #3f4854; padding: 12px 10px 5px;
}
.rail-group:first-child { padding-top: 2px; }
.rail-foot { margin-top: auto; padding-top: 12px; margin-top: 14px; border-top: 1px solid var(--line); display: grid; gap: 6px; }
.rail-scrim { display: none; }

/* The header is fixed, so the space for it is reserved here rather than as a
   margin on .main, whose top margin collapses out of the flow and lets the
   sticky banner sit on top of the page title. */
#app { padding-top: calc(var(--top-h) + env(safe-area-inset-top)); }

.main {
  overflow-x: hidden;
  margin-left: var(--rail-w);
  padding: var(--pad);
  /* No cap: a 2000px monitor is bought to be used. Columns are added as the
     window grows rather than leaving a river of empty space on the right. */
  max-width: none;
}

.tabbar { display: none; }

/* A dashboard that cannot reach your phone is decoration, so this sits above
   everything until it is fixed or explicitly dismissed. */
.push-banner {
  position: sticky; top: calc(var(--top-h) + env(safe-area-inset-top)); z-index: 30;
  margin-left: var(--rail-w);
  /* It lives inside #app's padded flow, so it needs no offset of its own. */
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 11px 16px;
  background: var(--warn-soft); border-bottom: 1px solid rgba(217,161,60,.3);
}
.push-banner-text { flex: 1; min-width: 190px; font-size: 12.5px; color: #f0c268; }
.push-banner-text strong { font-weight: 600; }
.push-banner-text span { color: var(--dim); display: block; margin-top: 2px; font-size: 11.5px; line-height: 1.5; }
.push-banner-actions { display: flex; gap: 6px; align-items: center; }
.push-banner.ok { background: var(--ok-soft); border-bottom-color: rgba(63,178,127,.3); }
.push-banner.ok .push-banner-text { color: #6bd6a4; }

/* ---------------- layout primitives ---------------- */

.view-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.view-title { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.view-sub { font-size: 12px; color: var(--faint); }
.view-actions { margin-left: auto; display: flex; gap: 6px; align-items: center; }

.grid { display: grid; gap: 10px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }

/* auto-fit rather than a fixed count: a row of four tiles spreads across the
   whole width instead of hugging the left and leaving half the monitor empty. */
@media (min-width: 1500px) {
  .grid-4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
  .grid-3 { grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); }
  .grid-2 { grid-template-columns: repeat(auto-fit, minmax(430px, 1fr)); }
}
/* Panels that must stay side by side no matter how wide the screen gets. */
.grid-pair { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 900px) { .grid-pair { grid-template-columns: 1fr; } }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r); padding: 13px;
  /* Grid children default to min-width:auto, so a wide table would push the
     whole page sideways instead of scrolling inside its own wrapper. */
  min-width: 0;
}
.grid > * { min-width: 0; }
.card-head {
  display: flex; align-items: center; gap: 8px; margin-bottom: 10px;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--faint);
}
.card-head .right { margin-left: auto; text-transform: none; letter-spacing: 0; }

.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 13px; }
.stat-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--faint); }
.stat-value { font-size: 22px; font-weight: 600; margin-top: 4px; font-family: var(--mono); letter-spacing: -0.02em; }
.stat-sub { font-size: 11px; color: var(--dim); margin-top: 2px; }
.stat.ok .stat-value { color: var(--ok); }
.stat.warn .stat-value { color: var(--warn); }
.stat.crit .stat-value { color: var(--crit); }
.stat.accent .stat-value { color: var(--accent); }

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

.tw { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -13px; padding: 0 13px; max-width: calc(100% + 26px); }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th {
  text-align: left; font-weight: 500; font-size: 10.5px; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--faint); padding: 6px 8px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
td { padding: var(--row-y) 8px; border-bottom: 1px solid rgba(27,33,41,.65); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--panel-2); }
td.num, th.num { text-align: right; font-family: var(--mono); }
td.nowrap { white-space: nowrap; }

.pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 7px;
  border-radius: 3px; font-size: 10.5px; font-weight: 500; white-space: nowrap;
  border: 1px solid transparent;
}
.pill.ok { background: var(--ok-soft); color: #6bd6a4; border-color: rgba(63,178,127,.25); }
.pill.warn { background: var(--warn-soft); color: #f0c268; border-color: rgba(217,161,60,.25); }
.pill.crit { background: var(--crit-soft); color: #ff9d95; border-color: rgba(226,86,76,.25); }
.pill.dim { background: var(--panel-3); color: var(--dim); border-color: var(--line); }
.pill.accent { background: var(--accent-soft); color: #a8ccff; border-color: rgba(76,154,255,.25); }

.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex: none; }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.crit { background: var(--crit); }
.dot.dim { background: var(--faint); }

/* ---------------- meters and charts ---------------- */

.meter { height: 4px; background: var(--panel-3); border-radius: 2px; overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--accent); border-radius: 2px; }
.meter.ok > i { background: var(--ok); }
.meter.warn > i { background: var(--warn); }
.meter.crit > i { background: var(--crit); }

canvas.chart { width: 100%; height: 120px; display: block; }
canvas.spark { width: 74px; height: 20px; display: block; }

.legend { display: flex; gap: 12px; font-size: 10.5px; color: var(--faint); margin-top: 6px; }
.legend i { width: 8px; height: 2px; display: inline-block; margin-right: 4px; vertical-align: middle; }

/* ---------------- alerts ---------------- */

.alert-row {
  display: flex; gap: 11px; padding: 11px; border: 1px solid var(--line);
  border-radius: var(--r); background: var(--panel); margin-bottom: 7px;
  border-left-width: 2px;
}
.alert-row.critical { border-left-color: var(--crit); }
.alert-row.warning { border-left-color: var(--warn); }
.alert-row.info { border-left-color: var(--info); }
.alert-row.acked { opacity: .55; }
.alert-body { flex: 1; min-width: 0; }
.alert-title { font-size: 13px; font-weight: 500; }
.alert-detail { font-size: 11.5px; color: var(--dim); margin-top: 2px; line-height: 1.5; }
.alert-meta { font-size: 10.5px; color: var(--faint); margin-top: 6px; display: flex; gap: 10px; flex-wrap: wrap; }
.alert-actions { display: flex; flex-direction: column; gap: 5px; flex: none; }
@media (max-width: 620px) {
  .alert-buttons .btn { flex: 1 1 auto; }
  .bulk-actions { width: 100%; }
}

.empty { padding: 30px 14px; text-align: center; color: var(--faint); font-size: 12.5px; }

/* ---------------- fleet strip ---------------- */

.fleet-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 6px; }
.chip-app {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 9px; border-radius: var(--r);
  border: 1px solid var(--line); background: var(--panel-2);
  font-size: 12px; min-width: 0;
}
.chip-app:hover { border-color: var(--line-2); background: var(--panel-3); }
.chip-app.crit { border-color: rgba(226,86,76,.35); background: var(--crit-soft); }
.chip-app.dim { opacity: .6; }
.chip-app-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-app-mem { margin-left: auto; font-family: var(--mono); font-size: 10.5px; color: var(--faint); }

/* ---------------- alert controls ---------------- */

.filter-bar { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.chip {
  padding: 6px 11px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--dim); font-size: 12px;
  display: inline-flex; align-items: center; gap: 6px;
}
.chip:hover { color: var(--text); border-color: var(--line-2); }
.chip.on { background: var(--accent-soft); border-color: rgba(76,154,255,.4); color: #a8ccff; }
.chip-n { font-family: var(--mono); font-size: 10.5px; opacity: .7; }

.quick-row { display: flex; gap: 6px; flex-wrap: wrap; }

.bulk-bar {
  display: none; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 9px 12px; margin-bottom: 8px;
  background: var(--accent-soft); border: 1px solid rgba(76,154,255,.3); border-radius: var(--r);
}
.bulk-bar.on { display: flex; }
.bulk-count { font-size: 12px; color: #a8ccff; }
.bulk-actions { margin-left: auto; display: flex; gap: 5px; flex-wrap: wrap; }

.alert-row.picked { border-color: rgba(76,154,255,.45); background: var(--accent-soft); }
.pick { flex: none; padding: 0; display: flex; align-items: flex-start; }
.pick-box {
  width: 17px; height: 17px; border-radius: 3px; border: 1px solid var(--line-2);
  display: grid; place-items: center; font-size: 11px; color: var(--accent);
  background: var(--panel-2);
}
.alert-buttons { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 9px; }

.duration-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px; }
.duration-grid .btn { width: 100%; }

.notif-log { max-height: 60vh; overflow-y: auto; }
.notif-row { display: flex; gap: 9px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid rgba(27,33,41,.6); }
.notif-row:last-child { border-bottom: none; }
.notif-row .dot { margin-top: 5px; }

.rule-row {
  display: flex; align-items: center; gap: 10px; padding: 9px 0;
  border-bottom: 1px solid rgba(27,33,41,.65);
}
.rule-row:last-child { border-bottom: none; }
.rule-name { font-size: 12.5px; }
.rule-help { font-size: 11px; color: var(--faint); margin-top: 2px; line-height: 1.45; }
.rule-input {
  width: 68px; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 3px; padding: 4px 6px; font-family: var(--mono); font-size: 11.5px; text-align: right;
}
.switch {
  width: 32px; height: 18px; border-radius: 9px; background: var(--panel-3);
  border: 1px solid var(--line-2); position: relative; flex: none; transition: background .15s;
}
.switch::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px;
  border-radius: 50%; background: var(--faint); transition: transform .15s, background .15s;
}
.switch.on { background: var(--ok-soft); border-color: rgba(63,178,127,.4); }
.switch.on::after { transform: translateX(14px); background: var(--ok); }

/* ---------------- console ---------------- */

.console {
  display: flex; flex-direction: column;
  height: min(74vh, calc(100vh - 250px));
  min-height: 320px;
  border: 1px solid var(--line); border-radius: var(--r); background: #07090c; overflow: hidden;
}
.console-out {
  flex: 1; overflow-y: auto; padding: 12px 14px;
  font-family: var(--mono); font-size: 12px; line-height: 1.55;
  white-space: pre-wrap; word-break: break-word; color: #b6c0cc;
}
.console-line.cmd { color: #a8ccff; }
.console-line.cmd::before { content: '$ '; color: var(--faint); }
.console-line.err { color: #ff9d95; }
.console-line.meta { color: var(--faint); font-size: 11px; }
.console-bar {
  display: flex; align-items: center; gap: 8px; padding: 9px 12px;
  border-top: 1px solid var(--line); background: var(--panel);
}
.console-cwd { font-family: var(--mono); font-size: 11px; color: var(--accent); white-space: nowrap; max-width: 34%; overflow: hidden; text-overflow: ellipsis; }
.console-input {
  flex: 1; font-family: var(--mono); font-size: 13px; background: transparent;
  border: none; outline: none; color: var(--text); min-width: 0;
}
.console-chips { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 9px; }

/* ---------------- command palette ---------------- */

.palette { position: fixed; inset: 0; background: rgba(4,6,9,.72); z-index: 88; display: flex; justify-content: center; padding: 12vh 16px 16px; }
.palette-card { width: 100%; max-width: 560px; background: var(--panel); border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.palette-input { width: 100%; padding: 15px 17px; font-size: 15px; background: transparent; border: none; outline: none; border-bottom: 1px solid var(--line); }
.palette-list { max-height: 52vh; overflow-y: auto; }
.palette-item { display: flex; align-items: center; gap: 11px; padding: 10px 17px; cursor: pointer; font-size: 13px; }
.palette-item.on { background: var(--panel-3); }
.palette-item .kind { margin-left: auto; font-size: 10px; color: var(--faint); text-transform: uppercase; letter-spacing: 0.1em; }
.palette-item .ico { width: 15px; text-align: center; color: var(--faint); }
.palette-hint { padding: 8px 17px; border-top: 1px solid var(--line); font-size: 10.5px; color: var(--faint); display: flex; gap: 14px; }

/* ---------------- explorer ---------------- */

.crumbs { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; font-family: var(--mono); font-size: 11.5px; margin-bottom: 9px; }
.crumbs button { color: var(--accent); }
.crumbs span { color: var(--faint); }
.bar-cell { display: flex; align-items: center; gap: 8px; }
.bar-cell .meter { flex: 1; min-width: 40px; }

.sql-box {
  width: 100%; min-height: 76px; resize: vertical;
  background: #07090c; border: 1px solid var(--line); border-radius: var(--r);
  padding: 11px 12px; font-family: var(--mono); font-size: 12.5px; color: #b6c0cc;
}
.sql-box:focus { outline: none; border-color: var(--line-2); }

/* ---------------- misc ---------------- */

.logbox {
  background: #07090c; border: 1px solid var(--line); border-radius: var(--r);
  padding: 10px; font-family: var(--mono); font-size: 11px; line-height: 1.55;
  max-height: 420px; overflow: auto; white-space: pre-wrap; word-break: break-word;
  color: #a9b3bf;
}
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; border-bottom: 1px solid rgba(27,33,41,.55); font-size: 12px; }
.kv:last-child { border-bottom: none; }
.kv span:first-child { color: var(--dim); }
.kv span:last-child { font-family: var(--mono); text-align: right; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--panel-3); border: 1px solid var(--line-2); border-radius: var(--r);
  padding: 10px 15px; font-size: 12.5px; z-index: 80; max-width: 90vw;
  box-shadow: 0 6px 24px rgba(0,0,0,.5);
}
.toast.err { border-color: rgba(226,86,76,.5); color: #ffa79f; }
.toast.ok { border-color: rgba(63,178,127,.5); color: #6bd6a4; }

.modal { position: fixed; inset: 0; background: rgba(4,6,9,.78); display: grid; place-items: center; z-index: 85; padding: 18px; }
.modal-card { background: var(--panel); border: 1px solid var(--line-2); border-radius: var(--r); padding: 18px; width: 100%; max-width: 380px; }
.modal-title { font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.modal-body { font-size: 12.5px; color: var(--dim); line-height: 1.6; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.seg button { padding: 5px 10px; font-size: 11.5px; color: var(--dim); background: var(--panel-2); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--panel-3); color: var(--text); }

.only-mobile { display: none; }

/* ---------------- phone ---------------- */

@media (max-width: 900px) {
  .only-mobile { display: inherit; }
  td.only-mobile, th.only-mobile { display: table-cell; }
  .rail {
    transform: translateX(-100%); transition: transform .18s ease;
    width: 244px; box-shadow: 0 0 40px rgba(0,0,0,.6);
    padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 14px);
    overscroll-behavior: contain;
  }
  /* Sixteen pages plus four labels plus the footer: a row that is already the
     full width of the drawer does not need eleven pixels of padding to be a
     comfortable target. */
  .rail-item { padding-top: 9px; padding-bottom: 9px; }
  .rail.open { transform: translateX(0); }
  .rail-scrim { display: block; position: fixed; inset: 0; background: rgba(4,6,9,.6); z-index: 34; opacity: 0; pointer-events: none; transition: opacity .18s; }
  .rail-scrim.on { opacity: 1; pointer-events: auto; }
  .main {
    margin-left: 0; padding: 12px 12px calc(var(--tab-h) + env(safe-area-inset-bottom) + 12px);
  }
  .console { height: calc(100vh - 300px); }
  .push-banner { margin-left: 0; padding: 10px 12px; }
  .push-banner-actions { width: 100%; justify-content: space-between; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .top-status { display: none; }

  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
    background: rgba(10,12,15,.96); backdrop-filter: blur(8px);
    border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
    height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  }
  .tab {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; font-size: 9.5px; color: var(--faint); position: relative;
  }
  .tab span { font-size: 15px; opacity: .8; }
  .tab.active { color: var(--accent); }
  .tab-dot { position: absolute; top: 8px; right: 50%; margin-right: -14px; width: 6px; height: 6px; border-radius: 50%; background: var(--crit); }

  .stat-value { font-size: 19px; }
  table { font-size: 12px; }
  th, td { padding: 7px 6px; }
}

@media (max-width: 460px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .view-title { font-size: 15px; }

  /* One more column than the phone can hold: CPU is a live number on the app's
     own page, memory is what actually gets watched in a list. */
  .hide-xs { display: none !important; }
  th, td { padding: 8px 7px; }
}


/* ---------------- filter bar ---------------- */

.filter-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding-bottom: 10px; margin-bottom: 2px; border-bottom: 1px solid var(--line);
}
.filter-input {
  flex: 1 1 160px; min-width: 0;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: var(--r); color: var(--text);
  font-family: var(--ui); font-size: 12.5px; padding: 7px 10px;
}
.filter-input:focus { outline: none; border-color: var(--accent); }
.filter-input::placeholder { color: var(--faint); }

/* ---------------- pull to refresh ---------------- */

.ptr {
  position: fixed; top: 0; left: 50%; z-index: 60;
  transform: translate(-50%, 0);
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--panel-2); border: 1px solid var(--line-2);
  display: grid; place-items: center;
  opacity: 0; pointer-events: none;
  transition: opacity .15s ease, transform .18s ease;
}
.ptr.on { opacity: 1; }
.ptr-ring {
  width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid var(--line-2); border-top-color: var(--faint);
}
.ptr.armed .ptr-ring { border-top-color: var(--accent); }
.ptr.spinning { transition: transform .2s ease; }
.ptr.spinning .ptr-ring { animation: spin .7s linear infinite; border-top-color: var(--accent); }

#wake-toggle.on { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }

/* ---------------- phone, second pass ---------------- */

@media (max-width: 900px) {
  /* Columns a 390px screen cannot fit without shrinking the type past reading
     size. Everything they held is still on the app's own page. */
  .hide-sm { display: none !important; }

  /* Anything tapped needs a finger-sized target, whatever the density is. */
  .icon-btn { width: 36px; height: 36px; }
  .btn { min-height: 34px; }
  .btn-xs { min-height: 30px; padding-left: 10px; padding-right: 10px; }
  .tab { min-height: 46px; }
  .switch { transform: scale(1.12); transform-origin: left center; }

  /* iOS zooms the whole page in on any input under 16px, and never zooms back
     out. Every field the phone can focus is therefore at least 16px. */
  input, select, textarea { font-size: 16px !important; }
  .filter-input, .rule-input { font-size: 16px !important; }

  /* A row of buttons in a card wraps instead of pushing the card sideways. */
  .view-actions, .card-head .right { flex-wrap: wrap; }
  .filter-bar { gap: 6px; }
  .seg button { padding: 7px 11px; }

  /* The palette is a sheet on a phone, not a floating box. */
  .palette-card { max-height: 72vh; }

  /* Sticky headers cost more than they give on a short screen. */
  .modal-card { max-height: 86vh; overflow-y: auto; }

  /* Nothing may push the page sideways: a stray wide child is the usual cause
     of a phone layout that scrolls horizontally by a few pixels. */
  html, body { overflow-x: hidden; }
  .card, .stat, .alert-row { max-width: 100%; }
}

/* Landscape on a phone is a 380px-tall window: the top bar and tab bar cannot
   both keep their full height and leave anything to read. */
@media (max-width: 900px) and (max-height: 460px) and (orientation: landscape) {
  :root { --top-h: 44px; --tab-h: 46px; }
  .tab { font-size: 9px; }
  .tab span { font-size: 13px; }
  .console { height: calc(100vh - 190px); }
}

/* Notched phones in landscape put the safe area on the sides. */
@media (max-width: 900px) {
  .main { padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
  .top { padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(14px, env(safe-area-inset-right)); }
}

/* Tap highlight and text selection belong to a web page, not to a console. */
@media (hover: none) {
  * { -webkit-tap-highlight-color: transparent; }
  .btn, .tab, .rail-item, .icon-btn, .seg button { -webkit-user-select: none; user-select: none; }
}

@media (prefers-reduced-motion: reduce) {
  .boot-wheel, .ptr .ptr-ring { animation: none !important; }
}

/* The row itself is the control on a phone, so it says so. */
.chev { color: var(--faint); text-align: right; font-size: 16px; width: 1px; padding-left: 0 !important; }
@media (max-width: 900px) {
  tr[data-app] { cursor: pointer; }
  tr[data-app]:active { background: var(--panel-3); }
}

/* A settings row is a sentence and a control side by side, which is one column
   too many on a phone: the help text shrinks to four words per line. */
@media (max-width: 620px) {
  .rule-row { flex-wrap: wrap; row-gap: 9px; }
  .rule-row > .seg,
  .rule-row > div:last-child:not([style*="flex:1"]) { width: 100%; }
  .rule-row .seg { display: flex; }
  .rule-row .seg button { flex: 1; }
}


/* ============================================================
   Second pass on layout: the console had eight tiles and six
   cards competing in one viewport. These are the pieces that
   give it a hierarchy - one headline, then groups, then detail.
   ============================================================ */

/* The single sentence that answers "is anything wrong". */
.hero {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 18px; margin-bottom: 16px;
  border: 1px solid var(--line); border-radius: 8px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border-left: 3px solid var(--ok);
}
.hero.warn { border-left-color: var(--warn); }
.hero.crit { border-left-color: var(--crit); }
.hero-mark {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: var(--ok-soft); color: var(--ok); font-size: 15px;
}
.hero.warn .hero-mark { background: var(--warn-soft); color: var(--warn); }
.hero.crit .hero-mark { background: var(--crit-soft); color: var(--crit); }
.hero-body { flex: 1; min-width: 0; }
.hero-line { font-size: 15px; font-weight: 550; color: var(--text); }
.hero-sub { font-size: 12px; color: var(--dim); margin-top: 3px; line-height: 1.6; }
.hero-actions { flex: none; display: flex; gap: 6px; }

/* A titled group. The label carries the grouping so the cards
   inside it do not each have to repeat the context. */
.section { margin-bottom: 20px; }
.section > .section-head {
  display: flex; align-items: baseline; gap: 10px;
  margin: 0 0 9px; padding: 0 2px;
}
.section-title {
  font-family: var(--mono); font-size: 10px; letter-spacing: 1.8px;
  text-transform: uppercase; color: var(--faint);
}
.section-note { font-size: 11.5px; color: var(--faint); margin-left: auto; }

/* Tabs inside a page, so Settings is four short screens and not
   one long scroll. */
.subnav {
  display: flex; gap: 2px; margin-bottom: 16px;
  border-bottom: 1px solid var(--line); overflow-x: auto;
  scrollbar-width: none;
}
.subnav::-webkit-scrollbar { display: none; }
.subnav button {
  flex: none; padding: 9px 14px; border: none; background: none;
  color: var(--dim); font-family: var(--ui); font-size: 12.5px;
  cursor: pointer; white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.subnav button:hover { color: var(--text); }
.subnav button.on { color: var(--accent); border-bottom-color: var(--accent); }

/* Resource meters as one card instead of four tiles. */
.gauges { display: grid; gap: 15px; }
.gauge-row { display: grid; grid-template-columns: 78px 1fr auto; align-items: center; gap: 12px; }
.gauge-name { font-size: 12.5px; color: var(--dim); }
.gauge-read { font-family: var(--mono); font-size: 12.5px; color: var(--text); white-space: nowrap; }
.gauge-read .faint { font-size: 11px; }

/* A row in a plain list: label left, value right, nothing else. */
.row {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 0; border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: none; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-size: 13px; color: var(--text); }
.row-sub { font-size: 11.5px; color: var(--faint); margin-top: 2px; line-height: 1.5; }
.row-side { flex: none; display: flex; align-items: center; gap: 7px; }

/* Add-a-person form. */
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 4px; }
.inline-form input {
  flex: 1 1 220px; min-width: 0;
  background: var(--panel-2); border: 1px solid var(--line-2);
  border-radius: var(--r); color: var(--text);
  font-family: var(--ui); font-size: 13px; padding: 9px 11px;
}
.inline-form input:focus { outline: none; border-color: var(--accent); }

.role-tag {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 1.2px;
  text-transform: uppercase; padding: 3px 7px; border-radius: 3px;
  border: 1px solid var(--line-2); color: var(--dim);
}
.role-tag.owner { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }

/* The destructive corner of Settings, fenced off on purpose. */
.danger {
  border: 1px solid rgba(226,86,76,.28); border-radius: 8px;
  background: rgba(226,86,76,.04); padding: var(--pad);
}
.danger .card-head { color: var(--crit); }

@media (max-width: 620px) {
  .hero { flex-wrap: wrap; }
  .hero-actions { width: 100%; }
  .hero-actions .btn { flex: 1; }
  .gauge-row { grid-template-columns: 64px 1fr auto; gap: 9px; }
  .inline-form input { flex: 1 1 100%; }
  .inline-form .btn { flex: 1; }
}

@media (max-width: 620px) {
  /* Nineteen apps at one per row is a scroll, not a glance. */
  .fleet-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; }
  .chip-app { padding: 8px; font-size: 11.5px; }
  .chip-app-mem { font-size: 10.5px; }

  /* When the headline wraps, a vertically centred mark drifts away from it. */
  .hero { align-items: flex-start; }
  .hero-mark { margin-top: 1px; }
}


/* ============================================================
   The phone title bar. It had five identical grey tiles in a
   row - two of them the same three-line icon - bunched into the
   left third of a 390px screen. Icons now, not tiles, and only
   the ones that belong in a title bar.
   ============================================================ */

.no-mobile { display: inherit; }

.brand .wheel-sm { color: var(--accent); flex: none; }
.brand-text { letter-spacing: 0.26em; }

/* A row of labelled controls at the foot of the menu, which is where the
   things that used to crowd the title bar actually belong. */
.rail-btn { display: flex; align-items: center; justify-content: space-between; gap: 10px; text-align: left; }
.rail-btn.on { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }

@media (max-width: 900px) {
  .no-mobile { display: none !important; }

  .top { gap: 10px; padding-left: max(10px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }

  /* No box until it is touched: the bar reads as three things, not five tiles. */
  .top .icon-btn {
    width: 40px; height: 40px;
    background: none; border-color: transparent;
    color: var(--dim);
  }
  .top .icon-btn:active { background: var(--panel-2); color: var(--text); }
  .top #nav-toggle { margin-left: -8px; }
  .top #alert-bell { margin-right: -4px; color: var(--text); }

  .brand { gap: 9px; font-size: 12.5px; }
  .brand-text { display: inline; }

  /* The live dot was a 7px speck wedged against the bell. Give it its own
     space and let it sit on the baseline of the wordmark instead. */
  .live-dot { width: 6px; height: 6px; margin-left: 6px; }
}

@media (max-width: 360px) {
  .brand-text { display: none; }
}
