:root {
  --ground: #f6f6f4;
  --surface: #ffffff;
  --ink: #1b1b1a;
  --muted: #64645f;
  --line: #e6e5e1;
  --line-strong: #d4d3ce;
  --hue: #0b7a69;
  --hue-soft: #e3f2ef;
  --gpu: #8a8a84;
  --ok: #1f8a4c;
  --off: #9a9a94;
  --danger: #b42318;
  --danger-soft: #fdf0ee;
  --warn-ink: #7a2e0e;
  --btn: #f0efeb;
  --btn-ink: #1b1b1a;
  --primary: #1b1b1a;
  --primary-ink: #ffffff;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ground: #121212;
    --surface: #1a1a1a;
    --ink: #ececea;
    --muted: #a3a39d;
    --line: #2a2a2a;
    --line-strong: #3a3a3a;
    --hue: #3cc4ad;
    --hue-soft: #12302b;
    --gpu: #8e8e88;
    --ok: #4cc27f;
    --off: #6f6f6a;
    --danger: #ff7a6b;
    --danger-soft: #2c1714;
    --warn-ink: #ffb4a6;
    --btn: #242424;
    --btn-ink: #ececea;
    --primary: #ececea;
    --primary-ink: #121212;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-variant-numeric: tabular-nums;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
[hidden] { display: none !important; }
h1, h2 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 22px; line-height: 1.2; }
h2 { font-size: 15px; }
p { margin: 0; }

.bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: calc(52px + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) 16px 0;
  background: var(--ground);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.mark { width: 24px; height: 24px; fill: none; stroke: var(--hue); stroke-width: 1.8; stroke-linecap: round; }
.mark circle { fill: var(--hue); stroke: none; }

.wrap { max-width: 720px; margin: 0 auto; padding: 16px; display: grid; gap: 12px; }

/* login */
.login { max-width: 400px; padding-top: 40px; gap: 16px; }
.login form { display: grid; gap: 14px; }
label { display: grid; gap: 6px; font-size: 14px; color: var(--muted); }
input {
  font: inherit;
  font-size: 17px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 12px 14px;
  min-height: 48px;
}
input:focus-visible, button:focus-visible, summary:focus-visible { outline: 2px solid var(--hue); outline-offset: 2px; }
.msg { color: var(--danger); min-height: 1.4em; font-size: 14px; }

/* botões */
button { font: inherit; cursor: pointer; }
.primary, .secondary, .danger, .act {
  min-height: 48px;
  border-radius: 10px;
  border: 1px solid transparent;
  padding: 10px 14px;
  font-weight: 600;
}
.primary { background: var(--primary); color: var(--primary-ink); }
.secondary { background: var(--btn); color: var(--btn-ink); }
.danger { background: var(--danger); color: #fff; }
.link { background: none; border: 0; color: var(--muted); padding: 10px 4px; min-height: 44px; text-decoration: underline; text-underline-offset: 3px; }

/* status */
.status { padding: 4px 2px 0; display: grid; gap: 6px; }
.status-line { display: flex; align-items: center; gap: 10px; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--off); flex: none; }
.dot.on { background: var(--ok); }
.sub { color: var(--muted); font-size: 14px; }
.pill {
  justify-self: start;
  font-size: 13px;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--hue-soft);
  color: var(--ink);
}
.banner { font-size: 14px; color: var(--warn-ink); background: var(--danger-soft); border-radius: 10px; padding: 8px 12px; }

/* saúde: divided 2x2 */
.health {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.metric { padding: 12px 14px; display: grid; gap: 2px; min-width: 0; }
.metric:nth-child(odd) { border-right: 1px solid var(--line); }
.metric:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
.label { font-size: 13px; color: var(--muted); }
.value { font-size: 26px; font-weight: 600; line-height: 1.15; letter-spacing: -0.01em; }
.meta { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.value.hot { color: var(--danger); }
.offline .health, .offline .chart, .offline #procs { opacity: 0.55; }

/* painéis */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: grid; gap: 10px; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.legend { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.k { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-left: 6px; }
.k-cpu { background: var(--hue); }
.k-gpu { background: var(--gpu); }
.chart { width: 100%; height: 170px; display: block; }
.chart .grid { stroke: var(--line); stroke-dasharray: 3 4; stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart .tick { fill: var(--muted); font-size: 11px; }
.chart .l-cpu { fill: none; stroke: var(--hue); stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.chart .a-cpu { fill: var(--hue-soft); stroke: none; }
.chart .l-gpu { fill: none; stroke: var(--gpu); stroke-width: 1.6; stroke-dasharray: 5 4; vector-effect: non-scaling-stroke; }
.chart .empty { fill: var(--muted); font-size: 13px; }
.axis { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: -4px; }

/* ações */
.group { display: grid; gap: 8px; }
.group + .group { margin-top: 10px; padding-top: 12px; border-top: 1px solid var(--line); }
.group h2 { font-size: 14px; color: var(--muted); font-weight: 600; }
.buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.act { background: var(--btn); color: var(--btn-ink); text-align: left; display: grid; gap: 2px; }
.act.wide { grid-column: 1 / -1; }
.act.destructive { color: var(--danger); }
.act small { font-weight: 400; font-size: 12px; color: var(--muted); line-height: 1.3; }
.act[disabled] { cursor: not-allowed; opacity: 0.45; }
.act.busy { opacity: 0.7; }
.act.busy span::after { content: " …"; }
.hint { font-size: 13px; color: var(--muted); }
.note { font-size: 14px; color: var(--muted); }
.toast { font-size: 14px; min-height: 1.4em; color: var(--muted); }
.toast.err { color: var(--danger); }
.toast.ok { color: var(--ok); }

/* listas */
.rows { list-style: none; margin: 0; padding: 0; }
.rows li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.rows li:last-child { border-bottom: 0; }
.rows .name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rows .num { color: var(--muted); white-space: nowrap; text-align: right; }
.rows .two { display: grid; gap: 1px; min-width: 0; }
.rows .two small { color: var(--muted); font-size: 12px; }
.rows .bad { color: var(--danger); }
summary { cursor: pointer; font-weight: 600; min-height: 28px; }
.foot { font-size: 12px; color: var(--muted); text-align: center; padding: 4px 0 20px; }

/* diálogo */
dialog {
  border: 0;
  border-radius: 14px;
  padding: 0;
  width: min(420px, calc(100vw - 32px));
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
.dlg { padding: 18px; display: grid; gap: 12px; }
.warning {
  background: var(--danger-soft);
  color: var(--warn-ink);
  border-left: 4px solid var(--danger);
  border-radius: 8px;
  padding: 10px 12px;
  font-weight: 600;
}
.dlg-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

@media (min-width: 720px) {
  .health { grid-template-columns: repeat(4, 1fr); }
  .metric:nth-child(odd) { border-right: 0; }
  .metric:nth-child(-n+2) { border-bottom: 0; }
  .metric + .metric { border-left: 1px solid var(--line); }
  .buttons { grid-template-columns: repeat(4, 1fr); }
  .act.wide { grid-column: span 2; }
}
