:root {
  --bg: #0f1113;
  --surface: #181b1e;
  --surface-2: #212529;
  --line: #2e3338;
  --text: #f1eee9;
  --muted: #a0a5aa;
  --flame: #ff7a1a;
  --flame-ink: #1a0d03;
  --good: #52c98a;
  --bad: #f0605a;
  --warn: #f2b84b;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

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

h1, h2, p { margin: 0; }
h2 { font-size: 1rem; font-weight: 650; }
.muted { color: var(--muted); }
.error { color: var(--bad); min-height: 1.5em; }

.brand { font-weight: 800; letter-spacing: .08em; }
.brand span { color: var(--flame); }

#app { max-width: 1100px; margin: 0 auto; padding: 0 16px 48px; }

.top { display: flex; justify-content: space-between; align-items: center; padding: 16px 0; }

.hero {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 20px;
  padding: 24px 0 28px; border-top: 1px solid var(--line);
}
.eyebrow { color: var(--muted); font-size: .85rem; }
h1 { font-size: clamp(1.8rem, 5vw, 2.6rem); line-height: 1.15; font-weight: 750; }
h1.on { color: var(--good); }
h1.off { color: var(--bad); }
h1.busy { color: var(--warn); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

.btn {
  min-height: 44px; padding: 0 18px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text); font: inherit; font-weight: 600;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; text-decoration: none;
}
.btn:hover:not(:disabled) { border-color: var(--muted); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn:focus-visible, .tab:focus-visible, input:focus-visible, .log:focus-visible { outline: 2px solid var(--flame); outline-offset: 2px; }
.btn.primary { background: var(--flame); border-color: var(--flame); color: var(--flame-ink); }
.btn.danger { background: transparent; border-color: var(--bad); color: var(--bad); }
.btn.ghost { background: transparent; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: .875rem; }

.banner { padding: 10px 14px; margin-bottom: 16px; border: 1px solid var(--bad); border-radius: 8px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 12px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px; }
.tile p { color: var(--muted); font-size: .875rem; }
.tile strong { display: block; font-size: 2rem; line-height: 1.25; font-variant-numeric: tabular-nums; }
.tile small { color: var(--muted); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 12px; min-width: 0; }
.panel-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; }
.columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
.columns .panel { margin-bottom: 0; }
.columns { margin-bottom: 12px; }

#chart { width: 100%; height: 180px; display: block; }
#chart .grid { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
#chart .line { fill: none; stroke: var(--flame); stroke-width: 2; vector-effect: non-scaling-stroke; }
#chart text { fill: var(--muted); font-size: 11px; }

.list { list-style: none; margin: 0; padding: 0; max-height: 320px; overflow: auto; }
.list li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.list li:last-child { border-bottom: 0; }
.list small { color: var(--muted); white-space: nowrap; }
.list .timeout { color: var(--warn); }
.list.mono li { font: 13px/1.5 ui-monospace, Consolas, monospace; color: var(--muted); }

.log-tools { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; }
.tab { min-height: 40px; padding: 0 12px; background: transparent; border: 1px solid transparent; border-radius: 6px; color: var(--muted); font: inherit; cursor: pointer; }
.tab.active { background: var(--surface-2); border-color: var(--line); color: var(--text); }
input {
  width: 100%; min-height: 44px; padding: 0 12px; margin-top: 4px; background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; font: inherit;
}
#logSearch { width: min(280px, 100%); margin: 0; }
.log {
  margin: 0; height: 380px; overflow: auto; padding: 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  font: 12px/1.6 ui-monospace, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere;
}

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); display: grid; gap: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 24px; }
.login-card .brand { font-size: 1.25rem; margin-bottom: 4px; }

dialog { background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 24px; width: min(420px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0, 0, 0, .65); }
dialog form { display: grid; gap: 14px; }
dialog h2 { font-size: 1.25rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }

.note { padding: 10px 14px; margin-bottom: 12px; border: 1px solid var(--warn); border-radius: 8px; font-size: .9rem; }
.file-tools { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.file-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.crumb { min-height: 36px; padding: 0 6px; background: none; border: 0; border-radius: 6px; color: var(--flame); font: inherit; cursor: pointer; }
.crumb:hover { background: var(--surface-2); }
.files { max-height: 460px; }
.files li { align-items: center; flex-wrap: wrap; }
.file-name { flex: 1 1 200px; min-width: 0; min-height: 36px; padding: 0; background: none; border: 0; color: var(--text); font: inherit; text-align: left; cursor: pointer; overflow-wrap: anywhere; }
.file-name:hover { color: var(--flame); }
.file-name.folder { font-weight: 650; }
.file-name.folder::before { content: "▸ "; color: var(--flame); }
.file-meta { color: var(--muted); font-size: .8rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
#editor { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
#editorText { display: block; width: 100%; height: 480px; resize: vertical; color: var(--text); white-space: pre; overflow-wrap: normal; }
.crumb:focus-visible, .file-name:focus-visible, textarea:focus-visible { outline: 2px solid var(--flame); outline-offset: 2px; }

@media (max-width: 520px) {
  .actions, .actions .btn { width: 100%; }
}
