:root {
  --bg: #f4f6f9; --card: #fff; --fg: #1d2330; --muted: #6b7484; --line: #e3e7ee;
  --accent: #2563eb; --accent-soft: #e6eefe; --ok: #15803d; --ok-soft: #e3f5e9;
  --warn: #b45309; --warn-soft: #fdf1e1; --err: #b91c1c; --err-soft: #fde8e8;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b; --card: #1b2029; --fg: #e5e9f0; --muted: #8b94a5; --line: #2b323e;
    --accent: #5b8def; --accent-soft: #1f2c46; --ok: #4ade80; --ok-soft: #173023;
    --warn: #f59e0b; --warn-soft: #34270f; --err: #f87171; --err-soft: #3a1a1a;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--fg); }
h1 { margin: 0 0 4px; font-size: 24px; }
h2 { margin: 0 0 12px; font-size: 16px; }
code { font: 12px ui-monospace, Menlo, Consolas, monospace; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--err); }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 12px; }

.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 20px; background: var(--card); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 17px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs button { border: 0; background: none; color: var(--muted); padding: 8px 12px; border-radius: 6px; cursor: pointer; font: inherit; }
.tabs button:hover { background: var(--bg); }
.tabs button.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.right { margin-left: auto; display: flex; gap: 10px; align-items: center; }

main { max-width: 1280px; margin: 0 auto; padding: 20px 16px 40px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 18px; margin-bottom: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.card-head h2 { margin: 0; }
.narrow { max-width: 440px; display: flex; flex-direction: column; gap: 12px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 16px; }
.grid2 .card { margin: 0; display: flex; flex-direction: column; gap: 12px; }
.span2 { grid-column: 1 / -1; }
.actions { flex-direction: row !important; align-items: center; }
@media (max-width: 500px) { .grid2 { grid-template-columns: 1fr; } }

.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; align-items: flex-end; }
.row.wrap > label { flex: 1 1 150px; }
.grow { flex: 1 1 260px; }
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); }
input, select, textarea { font: inherit; color: var(--fg); background: var(--bg); border: 1px solid var(--line);
  border-radius: 6px; padding: 7px 9px; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea { resize: vertical; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }

.btn { font: inherit; border: 1px solid var(--line); background: var(--card); color: var(--fg); padding: 7px 14px;
  border-radius: 6px; cursor: pointer; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--err); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.link { border: 0; background: none; color: var(--accent); padding: 2px 6px; }
.btn.link.danger { color: var(--err); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.err { background: var(--err-soft); color: var(--err); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.run { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }

.ports-strip { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.port-pill { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; }
.port-pill b { font: 600 15px ui-monospace, Menlo, Consolas, monospace; }
.port-pill span { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.stat .v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 12px; color: var(--muted); }

.active-list { display: flex; flex-direction: column; gap: 10px; }
.empty { color: var(--muted); padding: 12px 0; text-align: center; }
.xfer { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.xfer-top { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.xfer-top .f { font-weight: 600; word-break: break-all; }
.xfer-meta { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.bar { height: 8px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); transition: width .4s linear; }
.bar.indet > i { width: 30% !important; animation: slide 1.2s infinite ease-in-out; }
@keyframes slide { 0% { margin-left: -30%; } 100% { margin-left: 100%; } }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 12px; color: var(--muted); font-weight: 600; }
td.wrapcell { white-space: normal; word-break: break-all; }
tr.new { animation: flash 1.5s ease-out; }
@keyframes flash { from { background: var(--accent-soft); } to { background: transparent; } }
.hash { font: 11px ui-monospace, Menlo, Consolas, monospace; color: var(--muted); cursor: pointer; }
.folder-row td { background: var(--bg); font-weight: 600; }

.dropzone { margin-top: 12px; border: 2px dashed var(--line); border-radius: 10px; padding: 28px; text-align: center; cursor: pointer; }
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone p { margin: 4px 0; }
.upitem { margin-top: 10px; border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; }
.upitem .xfer-top { margin-bottom: 4px; }

.help { margin-top: 12px; font-size: 13px; }
.help pre { background: var(--bg); padding: 10px; border-radius: 6px; overflow-x: auto; font-size: 12px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--fg); color: var(--bg);
  padding: 10px 16px; border-radius: 8px; z-index: 20; max-width: 90vw; }
.toast.err { background: var(--err); color: #fff; }
