:root {
  --bg: #f6f7f9; --card: #fff; --fg: #1b1f27; --muted: #697386; --line: #dfe3ea;
  --accent: #2f6fed; --accent-fg: #fff; --ok: #1f9d57; --warn: #b7791f; --err: #d23f3f;
  color-scheme: light;
}
/* dark: follow the system unless the user picked light, or when explicitly chosen */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1218; --card: #181c24; --fg: #e8ebf1; --muted: #8f99ab; --line: #2a303b;
    --accent: #5b92ff; --ok: #3ccf82; --warn: #e0a84a; --err: #ff6b6b; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1218; --card: #181c24; --fg: #e8ebf1; --muted: #8f99ab; --line: #2a303b;
  --accent: #5b92ff; --ok: #3ccf82; --warn: #e0a84a; --err: #ff6b6b; color-scheme: dark;
}
#theme { position: fixed; top: 12px; right: 12px; z-index: 10; width: 38px; height: 38px; padding: 0; border-radius: 99px; font-size: 18px; line-height: 1; }
header { padding-right: 48px; }
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
main { max-width: 1040px; margin: 0 auto; padding: 24px 16px 48px; }
main.narrow { max-width: 440px; margin-top: 10vh; }
header, .between { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
h1 { font-size: 24px; margin: 0 0 16px; }
h2 { font-size: 16px; margin: 0 0 12px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
@media (max-width: 760px) { .grid { grid-template-columns: 1fr; } }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px; margin-bottom: 16px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: grid; grid-template-columns: 1fr 2fr; gap: 12px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--fg); font-size: 14px; }
input, select, textarea, button { font: inherit; }
input:not([type=checkbox]), select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--fg);
}
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 24px; }
@media (max-width: 760px) { .opts { grid-template-columns: 1fr; } }
button { padding: 9px 16px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--fg); cursor: pointer; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.link { border: 0; background: none; color: var(--accent); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 8px; }
.muted { color: var(--muted); font-size: 13px; }
.warn { color: var(--warn); }
.err { color: var(--err); min-height: 1.2em; margin: 6px 0 12px; }
details summary { cursor: pointer; color: var(--muted); font-size: 13px; margin-bottom: 8px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 600; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.dstname { padding: 4px 8px !important; font-size: 13px; }
.tag { font-size: 11px; background: var(--bg); border: 1px solid var(--line); border-radius: 99px; padding: 1px 8px; color: var(--muted); }
.bar { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; min-width: 120px; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
tr.done .bar i { background: var(--ok); }
tr.err .bar i { background: var(--err); }
tr.warn .bar i { background: var(--warn); }
.st { color: var(--muted); }
.stats { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
pre { margin: 0; max-height: 280px; overflow: auto; font: 12px/1.5 ui-monospace, Menlo, Consolas, monospace; white-space: pre-wrap; }
code { background: var(--bg); padding: 1px 5px; border-radius: 4px; }
footer { text-align: center; margin-top: 24px; }
@media (max-width: 760px) { #ftable th:nth-child(3), #ftable td:nth-child(3) { min-width: 140px; } .card { overflow-x: auto; } }
.row3 { display: grid; grid-template-columns: 1fr auto auto auto; gap: 8px; align-items: end; margin-bottom: 10px; }
@media (max-width: 760px) { .row3 { grid-template-columns: 1fr 1fr; } .row3 label { grid-column: 1 / -1; } }
#log-card > summary { cursor: pointer; font-weight: 600; font-size: 16px; }
#log-card[open] > summary { margin-bottom: 10px; }
.userbar { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
dialog { border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--fg); padding: 20px; width: min(420px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0,0,0,.45); }
