/* =====================================================================
   sparehash design system, shared by the website (apps/web) and the node app (apps/node).
   Flat: solid surfaces, 1px borders, no glow, blur, gradients or animation.
   Light by default; dark when [data-theme="dark"] (the toggle on the site, Settings in the app).
   ===================================================================== */

@font-face {
  font-family: "BubbledotICG-FinePos";
  src: url("fonts/BubbledotICG-FinePos-400.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Geist Pixel Circle";
  src: url("fonts/GeistPixelCircle-400.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("fonts/Inter-var.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}

/* ---------- Tokens ---------- */
:root {
  color-scheme: light;
  --bg: #f6f6f7;
  --surface: #ffffff;
  --surface-2: #f2f2f4;
  --surface-3: #e9e9ec;
  --line: #e2e2e6;
  --line-strong: #cfcfd5;
  --text: #111114;
  --soft: #3b3b42;
  --muted: #6c6c75;
  --accent: #f28238;
  --accent-ink: #1a0b02;
  --accent-text: #c2530f;
  --accent-bg: rgba(242, 130, 56, 0.14);
  --green: #1f9d55;
  --green-bg: rgba(31, 157, 85, 0.1);
  --amber: #a87b06;
  --amber-bg: rgba(217, 169, 37, 0.12);
  --red: #c93a32;
  --red-bg: rgba(229, 83, 75, 0.12);
  --blue: #2563eb;
  --primary-bg: #111114;
  --primary-ink: #ffffff;
  --primary-hover: #2a2a30;
  /* code (GitHub light palette) */
  --code-kw: #cf222e;
  --code-str: #0a3069;
  --code-com: #6e7781;
  --code-fn: #8250df;
  --code-num: #0550ae;
  --code-prop: #953800;
  --font-sans: "Inter", "Segoe UI", system-ui, sans-serif;
  --font-display: "BubbledotICG-FinePos", "Geist Pixel Circle", ui-monospace, monospace;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --radius: 14px;
  --radius-sm: 10px;
  --gutter: clamp(16px, 3vw, 40px);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0c0c0e;
  --surface: #141417;
  --surface-2: #1b1b1f;
  --surface-3: #232328;
  --line: #2a2a30;
  --line-strong: #3a3a42;
  --text: #f3f3f5;
  --soft: #c8c8cf;
  --muted: #8d8d97;
  --accent-text: #f5a36c;
  --accent-bg: rgba(242, 130, 56, 0.12);
  --green: #3fbf6f;
  --green-bg: rgba(63, 191, 111, 0.12);
  --amber: #d9a925;
  --amber-bg: rgba(217, 169, 37, 0.12);
  --red: #e5534b;
  --red-bg: rgba(229, 83, 75, 0.12);
  --blue: #4c8df6;
  --primary-bg: #f3f3f5;
  --primary-ink: #0c0c0e;
  --primary-hover: #ffffff;
  /* code (GitHub dark palette) */
  --code-kw: #ff7b72;
  --code-str: #a5d6ff;
  --code-com: #8b949e;
  --code-fn: #d2a8ff;
  --code-num: #79c0ff;
  --code-prop: #ffa657;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
img, svg, canvas, video { display: block; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
button:disabled, .btn[aria-disabled="true"] { cursor: not-allowed; opacity: 0.45; }
input, select, textarea { font: inherit; color: inherit; }
code, kbd, pre { font-family: var(--font-mono); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.display { font-family: var(--font-display); font-weight: 400; letter-spacing: -0.03em; line-height: 1.08; }
.muted { color: var(--muted); }
.soft { color: var(--soft); }
.small { font-size: 13px; }
.mono { font-family: var(--font-mono); font-size: 0.92em; }
.green { color: var(--green); }
.amber { color: var(--amber); }
.red { color: var(--red); }
.accent { color: var(--accent-text); }
.num, .tabular { font-variant-numeric: tabular-nums; }

.inline-link {
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 3px;
}
.inline-link:hover { color: var(--accent-text); }

/* ---------- Brand ---------- */
.brand { display: inline-flex; align-items: center; gap: 10px; font-family: var(--font-display); font-size: 21px; letter-spacing: -0.03em; }
.brand__mark { display: inline-grid; place-items: center; flex-shrink: 0; width: 26px; height: 26px; border-radius: 7px; background: var(--accent); }
.brand__mark::before { content: "#"; font-family: var(--font-display); font-size: 15px; color: var(--accent-ink); }

/* ---------- Buttons ---------- */
.btn, .btn-primary, .btn-glass, .btn-secondary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 18px; border-radius: 999px;
  font-weight: 600; font-size: 14px; white-space: nowrap;
  border: 1px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn-primary { background: var(--primary-bg); color: var(--primary-ink); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-glass, .btn-secondary { background: var(--surface-2); border-color: var(--line); color: var(--text); }
.btn-glass:hover:not(:disabled), .btn-secondary:hover:not(:disabled) { background: var(--surface-3); border-color: var(--line-strong); }
.btn-accent { background: var(--accent); color: var(--accent-ink); }
.btn-danger:hover:not(:disabled) { background: var(--red-bg); border-color: var(--red); color: var(--red); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-lg { height: 48px; padding: 0 24px; font-size: 15px; }

/* ---------- Surfaces ---------- */
.panel { padding: 20px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); min-width: 0; }
.panel h3 { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.panel p { color: var(--soft); line-height: 1.6; }
.panel p + p { margin-top: 10px; }
.panel__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin-bottom: 14px; }
.panel__head h3 { margin: 0; }
.panel__hint { font-size: 13px; color: var(--muted); }

.notice, .banner { padding: 14px 16px; border-radius: var(--radius-sm); border: 1px solid var(--accent); background: var(--accent-bg); color: var(--text); line-height: 1.55; }
.notice strong { font-weight: 600; }
.banner.bad { border-color: var(--red); background: var(--red-bg); }
.banner.good { border-color: var(--green); background: var(--green-bg); }

.code { padding: 14px 16px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface-2); overflow-x: auto; }
.code code, .code pre { font-size: 13px; line-height: 1.6; color: var(--text); white-space: pre; }
.code .t-k { color: var(--code-kw); }
.code .t-s { color: var(--code-str); }
.code .t-c { color: var(--code-com); font-style: italic; }
.code .t-f { color: var(--code-fn); }
.code .t-n { color: var(--code-num); }
.code .t-p { color: var(--code-prop); }
.code__label { display: block; margin-bottom: 8px; font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
code.chip, .chip { display: inline-flex; align-items: center; gap: 8px; max-width: 100%; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); font-size: 13px; }
.chip code { font-size: 12.5px; word-break: break-all; }

/* ---------- Tags, dots, pills ---------- */
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); color: var(--soft); font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.tag--accent, .tag.orange { border-color: transparent; background: var(--accent-bg); color: var(--accent-text); }
.tag--green, .tag.green { border-color: transparent; background: var(--green-bg); color: var(--green); }
.tag--amber { border-color: transparent; background: var(--amber-bg); color: var(--amber); }
.tag--red, .tag.red { border-color: transparent; background: var(--red-bg); color: var(--red); }
.tag--soft { color: var(--muted); }

.dot { display: inline-flex; align-items: center; gap: 7px; }
.dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex-shrink: 0; }
.dot--online::before, .dot--ok::before, .dot--good::before { background: var(--green); }
.dot--paused::before, .dot--warn::before { background: var(--amber); }
.dot--quarantined::before, .dot--partial::before, .dot--error::before, .dot--bad::before { background: var(--red); }

.pill { display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: 13px; font-weight: 500; white-space: nowrap; }
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.pill.ok::before { background: var(--green); }
.pill.warn::before { background: var(--amber); }
.pill.bad::before { background: var(--red); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.table th, .table td { padding: 11px 14px; text-align: left; white-space: nowrap; border-top: 1px solid var(--line); vertical-align: middle; }
.table thead th { border-top: 0; background: var(--surface-2); font-size: 11.5px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.table td { color: var(--soft); }
.table td strong { color: var(--text); font-weight: 600; }
.table .num, .table th.num { text-align: right; }
.table tbody tr:hover td { background: var(--surface-2); }
.empty { padding: 22px 16px; text-align: center; color: var(--muted); font-size: 14px; white-space: normal !important; }

/* ---------- Stat tiles ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.stat { padding: 16px 18px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); }
.stat__label, .stat .label { font-size: 11.5px; font-weight: 600; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted); }
.stat__value, .stat .value { margin-top: 8px; font-family: var(--font-display); font-size: 28px; letter-spacing: -0.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat__sub, .stat .sub { margin-top: 6px; font-size: 12.5px; color: var(--muted); }
.stat--flame .stat__value, .stat.accent .value { color: var(--accent-text); }

.kv { display: grid; gap: 1px; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--line); }
.kv > div { display: flex; justify-content: space-between; gap: 16px; padding: 10px 14px; background: var(--surface-2); }
.kv dt { color: var(--muted); }
.kv dd { text-align: right; font-weight: 500; min-width: 0; overflow-wrap: anywhere; }

/* ---------- Form controls ---------- */
.input, select.input {
  height: 40px; min-width: 0; padding: 0 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text); outline: 0;
  transition: border-color 0.15s ease;
}
.input:focus { border-color: var(--accent); }
.input::placeholder { color: var(--muted); }
.input.num, .input.num-sm { width: 96px; font-variant-numeric: tabular-nums; }
.input.time { width: 128px; }
.input.wide { width: 100%; }
select.input option { background: var(--surface); color: var(--text); }
input[type="number"] { -moz-appearance: textfield; }
input[type="number"]::-webkit-outer-spin-button, input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 18px; background: transparent; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 999px; background: linear-gradient(to right, var(--accent) var(--fill, 0%), var(--surface-3) var(--fill, 0%)); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; margin-top: -6px; width: 16px; height: 16px; border-radius: 50%; background: var(--text); border: 0; }
input[type="range"]::-moz-range-track { height: 4px; border-radius: 999px; background: var(--surface-3); }
input[type="range"]::-moz-range-progress { height: 4px; border-radius: 999px; background: var(--accent); }
input[type="range"]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--text); border: 0; }
input[type="range"]:focus-visible { outline: 0; }
input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px var(--accent-bg), 0 0 0 1px var(--accent); }

.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; color: var(--soft); user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch i { position: relative; width: 36px; height: 20px; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--line-strong); }
.switch i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--text); transition: transform 0.15s ease; }
.switch input:checked + i { background: var(--green); border-color: var(--green); }
.switch input:checked + i::after { transform: translateX(16px); background: #fff; }
.switch input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }

.field { display: grid; gap: 6px; min-width: 0; }
.field > span:first-child { font-size: 11.5px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.form-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px; }

.seg { display: inline-flex; padding: 3px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface-2); }
.seg button { padding: 5px 12px; border-radius: 7px; font-size: 13px; font-weight: 600; color: var(--muted); }
.seg button.on, .seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--line); }

.progress { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { padding: 12px 14px; margin-bottom: -1px; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 600; font-size: 14px; white-space: nowrap; }
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.tabs button span { margin-left: 6px; color: var(--muted); font-weight: 500; }

/* ---------- Theme toggle ---------- */
.theme-toggle { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); color: var(--soft); }
.theme-toggle:hover { color: var(--text); border-color: var(--line-strong); }
.theme-toggle svg { width: 16px; height: 16px; }
