:root {
  --bg: #0d1117; --panel: #151b23; --panel2: #1b2330; --line: #263040; --text: #e6edf3; --muted: #8b98a9;
  --blue: #4c8dff; --green: #34d399; --yellow: #fbbf24; --red: #f87171; --purple: #a78bfa;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--blue); }
header { position: sticky; top: 0; z-index: 5; background: rgba(13,17,23,.94); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.bar { max-width: 1320px; margin: 0 auto; padding: 10px 20px 0; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.brand small { color: var(--muted); font-weight: 400; }
.spacer { flex: 1; }
.refresh { color: var(--muted); font-size: 12px; display: flex; gap: 10px; align-items: center; }
nav.tabs { max-width: 1320px; margin: 0 auto; padding: 8px 20px 0; display: flex; gap: 2px; overflow-x: auto; }
nav.tabs a { color: var(--muted); text-decoration: none; padding: 8px 14px; border-bottom: 2px solid transparent; white-space: nowrap; }
nav.tabs a:hover { color: var(--text); }
nav.tabs a.on { color: var(--text); border-bottom-color: var(--blue); font-weight: 600; }
nav.tabs a .dot { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 5px; border-radius: 9px; background: var(--red); color: #111; font-size: 11px; font-weight: 700; text-align: center; }
button, .btn { background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px; cursor: pointer; font: inherit; font-size: 13px; text-decoration: none; display: inline-flex; align-items: center; gap: 5px; }
button:hover, .btn:hover { border-color: var(--blue); }
button.primary { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 600; }
button.danger:hover { border-color: var(--red); color: var(--red); }
button.sm { padding: 2px 8px; font-size: 12px; }
button:disabled { opacity: .5; cursor: default; }
main { max-width: 1320px; margin: 0 auto; padding: 20px; }
.view { display: none; } .view.on { display: block; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.stat .k { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.stat .v { font-size: 22px; font-weight: 650; margin-top: 2px; }
.stat .s { color: var(--muted); font-size: 12px; }
.meter { height: 5px; background: var(--panel2); border-radius: 3px; margin-top: 8px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--blue); }
section { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 18px; overflow: hidden; }
section > h2 { margin: 0; padding: 12px 16px; font-size: 15px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
section > h2 .count { color: var(--muted); font-weight: 400; font-size: 13px; }
section > h2 .hint { margin-left: auto; color: var(--muted); font-weight: 400; font-size: 12px; }
section > .body { padding: 14px 16px; }
.wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12px; padding: 8px 14px; background: var(--panel2); white-space: nowrap; }
td { padding: 9px 14px; border-top: 1px solid var(--line); vertical-align: top; }
tr:hover td { background: #18202b; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.muted { color: var(--muted); } .small { font-size: 12px; }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 99px; font-size: 12px; font-weight: 550; white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.ok { color: var(--green); background: rgba(52,211,153,.12); }
.warn { color: var(--yellow); background: rgba(251,191,36,.12); }
.bad { color: var(--red); background: rgba(248,113,113,.12); }
.info { color: var(--blue); background: rgba(76,141,255,.12); }
.off { color: var(--muted); background: rgba(139,152,169,.12); }
.tag { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 4px; background: var(--panel2); border: 1px solid var(--line); color: var(--muted); margin-right: 4px; }
.tag.pm2 { color: #6ee7b7; } .tag.docker { color: #60a5fa; } .tag.systemd { color: var(--purple); }
.actions { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.warnings { list-style: none; margin: 0; padding: 6px 0; }
.warnings li { padding: 8px 16px; display: flex; gap: 10px; align-items: flex-start; }
.allgood { padding: 14px 16px; color: var(--green); }
a.dom { color: var(--text); text-decoration: none; font-weight: 600; }
a.dom:hover { color: var(--blue); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fill, minmax(400px, 1fr)); gap: 18px; }
@media (max-width: 500px) { .grid3 { grid-template-columns: 1fr; } }
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } }
.grid2 section, .grid3 section { margin-bottom: 0; }
.filter { background: var(--panel2); border: 1px solid var(--line); color: var(--text); border-radius: 6px; padding: 5px 10px; font: inherit; width: 220px; }
.legend { padding: 10px 16px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--line); display: flex; gap: 16px; flex-wrap: wrap; }
.empty { padding: 18px 16px; color: var(--muted); }
.note { padding: 12px 16px; background: rgba(76,141,255,.08); border: 1px solid rgba(76,141,255,.25); border-radius: 10px; margin-bottom: 18px; color: #c9d7f2; }

/* uptime strip: 30 days */
.ustrip { display: flex; gap: 2px; align-items: flex-end; height: 18px; }
.ustrip i { width: 5px; height: 100%; border-radius: 2px; background: var(--line); }
.ustrip i.g { background: var(--green); } .ustrip i.y { background: var(--yellow); } .ustrip i.r { background: var(--red); }

/* small bar chart (single series, one hue) */
.chart { position: relative; display: flex; align-items: flex-end; gap: 2px; height: 90px; padding-top: 6px; border-bottom: 1px solid var(--line); }
.chart .col { flex: 1; height: 100%; display: flex; align-items: flex-end; cursor: default; }
.chart .col i { display: block; width: 100%; min-height: 1px; background: var(--blue); border-radius: 4px 4px 0 0; }
.chart .col:hover i { background: #7aa9ff; }
.chart .col.today i { background: #7aa9ff; }
.axis { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; margin-top: 4px; }
.tip { position: fixed; z-index: 50; pointer-events: none; background: #0b0f14; border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; font-size: 12px; display: none; white-space: nowrap; }
.kv { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
.kv div b { display: block; font-size: 20px; }
.kv div span { color: var(--muted); font-size: 12px; white-space: nowrap; }
.toplist { list-style: none; margin: 0; padding: 0; }
.toplist li { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; border-top: 1px solid var(--line); font-size: 13px; }
.toplist li:first-child { border-top: none; }
.toplist li span:first-child { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toplist li span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; }
.cols3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 14px; }
.cols3 > div { min-width: 0; }
.cols3 h4 { margin: 0 0 6px; font-size: 12px; color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
@media (max-width: 700px) { .cols3, .kv { grid-template-columns: 1fr 1fr; } }

/* files */
.crumbs { display: flex; flex-wrap: wrap; gap: 2px; align-items: center; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
.crumbs a { color: var(--text); text-decoration: none; padding: 2px 5px; border-radius: 4px; cursor: pointer; }
.crumbs a:hover { background: var(--panel2); color: var(--blue); }
.quick { display: flex; flex-wrap: wrap; gap: 6px; }
tr.click { cursor: pointer; }
.fname { display: flex; align-items: center; gap: 8px; }
.sizebar { height: 4px; border-radius: 2px; background: var(--blue); opacity: .6; margin-top: 4px; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 20; display: none; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; }
.modal-bg.on { display: flex; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; width: 100%; max-width: 640px; }
.modal.wide { max-width: 1100px; }
.modal h3 { margin: 0; padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; font-size: 15px; }
.modal h3 .x { margin-left: auto; }
.modal .mbody { padding: 16px; }
pre.log { margin: 0; background: #0a0d12; border: 1px solid var(--line); border-radius: 8px; padding: 12px; max-height: 65vh; overflow: auto; font-size: 12px; line-height: 1.5; white-space: pre-wrap; word-break: break-all; }
form.f label { display: block; margin-bottom: 12px; color: var(--muted); font-size: 12px; }
form.f input, form.f textarea, form.f select { display: block; width: 100%; margin-top: 4px; background: var(--panel2); border: 1px solid var(--line); color: var(--text); border-radius: 6px; padding: 7px 10px; font: inherit; }
form.f .row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
form.f .check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 14px; }
form.f .check input { width: auto; margin: 0; }
.err { color: var(--red); margin-top: 8px; }
.client-card .sites { list-style: none; margin: 0; padding: 0; }
.client-card .sites li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.client-card .sites li:first-child { border-top: none; }
.client-card .meta { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.steps { margin: 6px 0 0; padding-left: 20px; color: var(--muted); }
.steps li { margin: 4px 0; }
.toggle { display: flex; align-items: center; gap: 8px; }

/* header buttons */
.refresh .btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 600; }

/* new site wizard */
.wizard .step { display: flex; gap: 14px; padding-bottom: 18px; position: relative; }
.wizard .step::before { content: ""; position: absolute; left: 13px; top: 30px; bottom: 0; width: 2px; background: var(--line); }
.wizard .step.last::before { display: none; }
.wizard .num { flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--panel2); border: 1px solid var(--line); display: grid; place-items: center; font-weight: 700; font-size: 13px; color: var(--blue); }
.wizard .sbody { flex: 1; min-width: 0; padding-top: 3px; }
.wizard h4 { margin: 0 0 10px; font-size: 14px; }
.choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.choice { border: 1px solid var(--line); border-radius: 10px; padding: 12px; cursor: pointer; background: var(--panel2); margin: 0 !important; color: var(--text) !important; font-size: 14px !important; }
.choice input { display: none !important; }
.choice b { display: block; margin-bottom: 4px; }
.choice span { color: var(--muted); font-size: 12px; }
.choice:has(input:checked) { border-color: var(--blue); background: rgba(76,141,255,.1); }
.keybox { background: #0a0d12; border: 1px solid var(--line); border-radius: 8px; padding: 10px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; word-break: break-all; margin: 8px 0; }
.dnsrow { display: flex; gap: 8px; align-items: center; margin-top: 8px; font-size: 13px; flex-wrap: wrap; }

/* phone */
@media (max-width: 700px) {
  .bar { padding: 8px 12px 0; gap: 8px; }
  .brand small, #updated, .filter { display: none; }
  nav.tabs { padding: 4px 8px 0; }
  nav.tabs a { padding: 8px 10px; }
  main { padding: 12px; }
  .stats { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat .v { font-size: 18px; }
  .choices { grid-template-columns: 1fr; }
  form.f .row { grid-template-columns: 1fr; }
  .grid2 { gap: 12px; }
  td, th { padding: 8px 10px; }
  #v-overview th:nth-child(4), #v-overview td:nth-child(4), #v-overview th:nth-child(6), #v-overview td:nth-child(6) { display: none; }
  .modal-bg { padding: 0; }
  .modal { border-radius: 0; min-height: 100vh; }
  body { padding-bottom: env(safe-area-inset-bottom); }
  header { padding-top: env(safe-area-inset-top); }
}
@media (max-width: 700px) {
  .bar { flex-wrap: nowrap; }
  .brand { font-size: 15px; white-space: nowrap; }
  .spacer { display: none; }
  .refresh { gap: 6px; margin-left: auto; }
  .refresh button, .refresh .btn { padding: 5px 8px; }
  .hide-sm { display: none; }
}
