*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0a0b0f;
  --surface: #14151b;
  --surface-2: #1a1c24;
  --surface-3: #23252f;
  --border: #23242d;
  --border-2: #2d2f3a;
  --acc: #6366f1;
  --acc2: #818cf8;
  --acc-soft: rgba(99,102,241,0.13);
  --green: #34d399;
  --green-soft: rgba(52,211,153,0.13);
  --amber: #fbbf24;
  --amber-soft: rgba(251,191,36,0.13);
  --red: #f87171;
  --red-soft: rgba(248,113,113,0.12);
  --t1: #f2f3f7;
  --t2: #969aab;
  --t3: #5b5f70;
  --font: 'Hanken Grotesk', system-ui, sans-serif;
  --mono: 'JetBrains Mono', 'Courier New', monospace;
  --rail-w: 64px;
  --detail-w: 384px;
}

html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--t1);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
  height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ════ APP SHELL ════ */
.app { display: flex; height: 100vh; overflow: hidden; }

/* ════ FLOATING NAV RAIL ════ */
.rail {
  position: fixed; left: 14px; top: 14px; bottom: 14px;
  width: var(--rail-w);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  display: flex; flex-direction: column; align-items: center;
  padding: 14px 0; gap: 6px; z-index: 40;
}
.rail-logo {
  width: 42px; height: 42px; border-radius: 14px;
  background: linear-gradient(140deg, var(--acc), #7c3aed);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; margin-bottom: 8px;
  box-shadow: 0 6px 18px rgba(99,102,241,0.35);
}
.rail-btn {
  width: 44px; height: 44px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  color: var(--t3); cursor: pointer; transition: all 0.16s ease;
  position: relative; flex-shrink: 0;
}
.rail-btn:hover { background: var(--surface-2); color: var(--t1); }
.rail-btn.on { background: var(--acc); color: #fff; }
.rail-btn.on:hover { background: var(--acc); }
.rail-btn svg { width: 20px; height: 20px; }
.rail-sp { flex: 1; }
.rail-mini { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; }
.rail-mini-v { font-family: var(--mono); font-size: 9px; }
.rail-mini-v.dl { color: var(--acc2); }
.rail-mini-v.ul { color: var(--green); }

/* tooltip */
.rail-btn[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute; left: 52px; top: 50%; transform: translateY(-50%);
  background: var(--surface-3); color: var(--t1);
  font-size: 11px; font-weight: 500; padding: 5px 9px; border-radius: 8px;
  white-space: nowrap; border: 1px solid var(--border-2); z-index: 50;
  pointer-events: none;
}

/* ════ CONTENT ════ */
.content {
  flex: 1; margin-left: calc(var(--rail-w) + 28px);
  display: flex; flex-direction: column; overflow: hidden; height: 100vh;
  padding: 18px 22px 0;
  transition: margin-right 0.34s cubic-bezier(.22,.61,.36,1);
}
.content.detail-open { margin-right: calc(var(--detail-w) + 22px); }
@media (max-width: 1180px) { .content.detail-open { margin-right: 0; } }

/* ── top utility bar ── */
.topbar { display: flex; align-items: center; gap: 12px; flex-shrink: 0; margin-bottom: 16px; position: relative; z-index: 30; }
.pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 13px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface);
  font-size: 12px; color: var(--t2); white-space: nowrap;
}
.pill svg { width: 13px; height: 13px; }
.pill-ic-dl { color: var(--acc2); }
.pill-ic-ul { color: var(--green); }
.pill-ic-n { color: var(--t3); }
.pill b { color: var(--t1); font-family: var(--mono); font-weight: 500; }
.tb-gap { flex: 1; }

.search {
  position: relative; width: 240px;
}
.search-ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--t3); pointer-events: none; }
.search input {
  width: 100%; background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 8px 14px 8px 34px;
  color: var(--t1); font-size: 13px; font-family: var(--font); outline: none;
  transition: border-color 0.15s;
}
.search input:focus { border-color: var(--acc); }
.search input::placeholder { color: var(--t3); }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px; border-radius: 12px; border: 1px solid transparent;
  cursor: pointer; font-family: var(--font); font-size: 13px; font-weight: 500;
  transition: all 0.16s ease; white-space: nowrap; user-select: none;
}
.btn svg { width: 15px; height: 15px; }
.btn-p { background: var(--acc); color: #fff; }
.btn-p:hover { background: var(--acc2); }
.btn-g { background: var(--surface); color: var(--t2); border-color: var(--border); }
.btn-g:hover { background: var(--surface-2); color: var(--t1); }
.btn-d { background: var(--red-soft); color: var(--red); }
.btn-d:hover { background: rgba(248,113,113,0.2); }
.btn-full { width: 100%; justify-content: center; padding: 11px; font-size: 14px; }

/* ── title bar ── */
.title-bar { display: flex; align-items: flex-end; justify-content: space-between; flex-shrink: 0; margin-bottom: 14px; }
.title-h { font-size: 25px; font-weight: 600; letter-spacing: -0.4px; }
.title-sub { font-size: 13px; color: var(--t3); margin-top: 2px; }
.title-right { display: flex; align-items: center; gap: 12px; }
.conn {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border);
  font-size: 12px; color: var(--t2); white-space: nowrap;
}
.conn-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.conn-dot::after {
  content:''; position: absolute; width: 7px; height: 7px; border-radius: 50%;
  background: inherit; animation: ping 1.8s ease-out infinite;
}
.conn-dot { position: relative; }
@keyframes ping { 0% { opacity:0.7; transform:scale(1); } 100% { opacity:0; transform:scale(2.6); } }

.toggle-wrap { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--t2); }
.toggle { width: 38px; height: 22px; border-radius: 999px; background: var(--surface-3); position: relative; cursor: pointer; transition: background 0.2s; flex-shrink: 0; }
.toggle.on { background: var(--green); }
.toggle::after { content:''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform 0.2s; }
.toggle.on::after { transform: translateX(16px); }

/* ── card base ── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; }

/* ── chart card ── */
.chart-card { flex-shrink: 0; margin-bottom: 14px; padding: 14px 18px; display: flex; flex-direction: column; }
.chart-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.chart-title { font-size: 13px; font-weight: 600; color: var(--t1); }
.chart-now { display: flex; gap: 22px; }
.chart-now-i { display: flex; flex-direction: column; }
.chart-now-l { font-size: 10px; color: var(--t3); text-transform: uppercase; letter-spacing: 0.5px; display: flex; align-items: center; gap: 5px; }
.chart-now-v { font-family: var(--mono); font-size: 19px; font-weight: 500; line-height: 1.2; }
.chart-now-v.dl { color: var(--acc2); }
.chart-now-v.ul { color: var(--green); }
.chart-legend { display: flex; gap: 14px; }
.leg { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--t3); }
.leg-dot { width: 9px; height: 9px; border-radius: 3px; }
.chart-canvas-wrap { height: 140px; position: relative; }
.chart-ranges { display: flex; gap: 4px; }
.crange { padding: 4px 11px; border-radius: 8px; font-size: 11.5px; font-weight: 500; color: var(--t2); background: var(--surface-2); border: 1px solid var(--border); cursor: pointer; transition: all 0.14s; }
.crange:hover { color: var(--t1); border-color: var(--border-2); }
.crange.on { background: var(--acc); color: #fff; border-color: var(--acc); }

/* ── dashboard page ── */
.dash { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 16px; overflow-y: auto; padding-bottom: 16px; }
.dash .chart-card { margin-bottom: 0; }
.dash-tops { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; flex: 1; min-height: 220px; }
.top-card { display: flex; flex-direction: column; overflow: hidden; min-height: 0; }
.top-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.top-ic { width: 30px; height: 30px; border-radius: 9px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.top-title { font-size: 13px; font-weight: 600; white-space: nowrap; }
.top-count { margin-left: auto; font-size: 11px; font-family: var(--mono); color: var(--t3); background: var(--surface-3); padding: 2px 9px; border-radius: 999px; }
.top-body { padding: 6px; flex: 1; min-height: 0; overflow-y: auto; }
.top-body::-webkit-scrollbar { width: 6px; }
.top-body::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 3px; }
.top-row { display: flex; align-items: center; gap: 11px; padding: 11px 10px; border-radius: 12px; cursor: pointer; transition: background 0.14s; }
.top-row:hover { background: var(--surface-2); }
.top-row-ic { width: 30px; height: 30px; border-radius: 9px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.top-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 7px; }
.top-row-name { font-size: 12.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-bar { height: 3px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.top-fill { height: 100%; border-radius: 999px; }
.top-row-spd { font-size: 12px; white-space: nowrap; flex-shrink: 0; }
.top-empty { padding: 28px 16px; text-align: center; font-size: 12.5px; color: var(--t3); }
.console { font-family: var(--mono); }

/* ── dashboard metric cards ── */
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(185px, 1fr)); gap: 14px; flex-shrink: 0; }
.metric { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 15px 16px; display: flex; flex-direction: column; gap: 14px; }
.metric-top { display: flex; align-items: center; gap: 9px; }
.metric-ic { width: 30px; height: 30px; border-radius: 9px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.metric-label { font-size: 12px; color: var(--t2); }
.metric-val { font-size: 25px; font-weight: 500; letter-spacing: -0.5px; line-height: 1; }
.metric-sub { font-size: 11px; color: var(--t3); margin-top: 7px; }

/* ── public IP / VPN status ── */
.vpn { position: relative; display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border-2); background: var(--surface-2); font-size: 12.5px; font-weight: 500; }
.vpn-ok { border-color: rgba(52,211,153,0.35); color: var(--green); }
.vpn-warn { border-color: rgba(251,191,36,0.35); color: var(--amber); }
.vpn-load { color: var(--t2); }
.vpn-txt { white-space: nowrap; }
.vpn-ip { color: var(--t2); }
.vpn-ok .vpn-ip, .vpn-warn .vpn-ip { color: var(--t1); }
.vpn-bubble { position: absolute; top: calc(100% + 9px); left: 0; width: 300px; max-width: 78vw; background: var(--surface); border: 1px solid var(--border-2); border-radius: 16px; padding: 15px; z-index: 60; box-shadow: 0 18px 44px rgba(0,0,0,0.55); opacity: 0; transform: translateY(-6px); pointer-events: none; transition: opacity 0.16s, transform 0.16s; }
.vpn:hover .vpn-bubble { opacity: 1; transform: translateY(0); pointer-events: auto; }
.vpn-b-head { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--t1); margin-bottom: 12px; }
.vpn-ok .vpn-b-head { color: var(--green); }
.vpn-warn .vpn-b-head { color: var(--amber); }
.vpn-b-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 5px 0; font-size: 12px; color: var(--t3); }
.vpn-b-row b { color: var(--t1); font-weight: 500; max-width: 175px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vpn-b-msg { margin-top: 11px; padding-top: 11px; border-top: 1px solid var(--border); font-size: 11.5px; line-height: 1.6; color: var(--t2); }

/* ── filter bar ── */
.filter-bar { display: flex; align-items: center; gap: 10px; flex-shrink: 0; margin-bottom: 14px; }
.fb-gap { flex: 1; }
.search-lg { width: 360px; max-width: 44%; }
.filter-bar .search input { padding: 10px 14px 10px 38px; font-size: 13.5px; }
.fpills { display: flex; gap: 6px; flex-wrap: wrap; }
.fpill {
  display: flex; align-items: center; gap: 7px;
  padding: 6px 13px; border-radius: 999px; cursor: pointer;
  font-size: 12.5px; color: var(--t2); background: var(--surface);
  border: 1px solid var(--border); transition: all 0.15s;
}
.fpill:hover { color: var(--t1); border-color: var(--border-2); }
.fpill.on { background: var(--t1); color: var(--bg); border-color: var(--t1); font-weight: 600; }
.fpill-dot { width: 7px; height: 7px; border-radius: 50%; }
.fpill-n {
  font-size: 10px; font-family: var(--mono); padding: 0 6px; border-radius: 999px;
  background: var(--surface-3); color: var(--t2);
}
.fpill.on .fpill-n { background: rgba(0,0,0,0.12); color: var(--bg); }

/* ── list card ── */
.list-card { flex: 1; min-height: 160px; display: flex; flex-direction: column; overflow: hidden; margin-bottom: 14px; }
.list-head {
  display: grid; grid-template-columns: minmax(0,1fr) 100px 72px 126px 50px 46px 70px;
  gap: 12px; padding: 12px 20px; flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}
.lh { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.6px; color: var(--t3); }
.lh-sort { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; user-select: none; transition: color 0.14s; }
.lh-sort:hover { color: var(--t2); }
.lh.on { color: var(--t1); }
.lh-arr { font-size: 8px; line-height: 1; }
.tlist { flex: 1; overflow-y: auto; }
.tlist::-webkit-scrollbar { width: 6px; }
.tlist::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 3px; }

/* ── torrent row ── */
.trow {
  display: grid; grid-template-columns: minmax(0,1fr) 100px 72px 126px 50px 46px 70px;
  gap: 12px; align-items: center; padding: 15px 20px;
  border-bottom: 1px solid var(--border); cursor: pointer;
  transition: background 0.14s; position: relative;
  /* skip layout/paint of off-screen rows → smooth scroll + smooth detail reflow on huge lists */
  content-visibility: auto; contain-intrinsic-size: 0 63px;
}
.trow:last-child { border-bottom: none; }
.trow:hover { background: var(--surface-2); }
.trow.sel { background: var(--acc-soft); }
.trow.sel::before {
  content:''; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px;
  background: var(--acc); border-radius: 0 3px 3px 0;
}

.tn { display: flex; flex-direction: row; align-items: center; gap: 10px; min-width: 0; }
.tn-icon {
  width: 32px; height: 32px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.tn-icon svg { width: 15px; height: 15px; }
.tn-title { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 60px; flex-shrink: 1; }
.tprog { display: flex; align-items: center; gap: 8px; }
.tn-bar { height: 3px; flex: 1; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.tn-fill { height: 100%; border-radius: 999px; transition: width 0.6s ease; }
.tspeed { display: flex; gap: 10px; }

.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 10.5px; font-weight: 600; flex-shrink: 0; white-space: nowrap; }
.chip-dl { background: var(--acc-soft); color: var(--acc2); }
.chip-seed { background: var(--green-soft); color: var(--green); }
.chip-pause { background: var(--surface-3); color: var(--t3); }
.chip-stall { background: var(--amber-soft); color: var(--amber); }
.chip-err { background: var(--red-soft); color: var(--red); }
.chip-done { background: var(--green-soft); color: var(--green); }
.chip-chk { background: rgba(167,139,250,0.13); color: #a78bfa; }
.chip-cat { background: var(--surface-3); color: var(--t2); }

.tcell { font-family: var(--mono); font-size: 12px; color: var(--t2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tcell.dim { color: var(--t3); }
.tcell.two { display: flex; flex-direction: column; gap: 2px; }
.tcell .dl { color: var(--acc2); }
.tcell .ul { color: var(--green); }
.pct { font-family: var(--mono); font-size: 10.5px; color: var(--t3); }
.tprog .pct { min-width: 28px; text-align: right; flex-shrink: 0; }

.tacts { display: flex; gap: 6px; justify-content: flex-end; }
.abtn {
  width: 32px; height: 32px; border-radius: 9px; border: none;
  background: var(--surface-3); color: var(--t2); cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: all 0.14s;
}
.abtn:hover { background: var(--acc); color: #fff; }
.abtn.del:hover { background: var(--red); color: #fff; }
.abtn svg { width: 13px; height: 13px; }

/* empty */
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px 24px; color: var(--t3); gap: 12px; text-align: center; }
.empty svg { width: 38px; height: 38px; opacity: 0.3; }
.empty p { font-size: 13px; }

/* ── logs ── */
.logs-card { flex: 1; display: flex; flex-direction: column; overflow: hidden; margin-bottom: 14px; }
.logs-head { padding: 14px 18px; border-bottom: 1px solid var(--border); flex-shrink: 0; display: flex; align-items: center; gap: 9px; }
.logs-head svg { color: var(--acc2); }
.logs-head span { font-size: 13px; font-weight: 600; }
.log-row { display: flex; align-items: flex-start; gap: 12px; padding: 9px 18px; border-bottom: 1px solid var(--border); font-size: 12.5px; }
.log-row:last-child { border-bottom: none; }
.log-time { font-family: var(--mono); font-size: 10.5px; color: var(--t3); white-space: nowrap; padding-top: 1px; }
.log-msg { flex: 1; color: var(--t2); line-height: 1.5; }
.log-2 { color: var(--acc2); }
.log-4 { color: var(--red); }
.log-8 { color: var(--amber); }

/* ════ DETAIL PANEL (fixed slide-in) ════ */
.detail {
  position: fixed; top: 14px; bottom: 14px; right: 14px;
  width: var(--detail-w);
  background: var(--surface); border: 1px solid var(--border-2);
  border-radius: 22px; z-index: 45;
  display: flex; flex-direction: column; overflow: hidden;
  transform: translateX(calc(100% + 24px)); opacity: 0;
  transition: transform 0.34s cubic-bezier(.22,.61,.36,1), opacity 0.25s;
  box-shadow: 0 24px 60px rgba(0,0,0,0.5);
  will-change: transform;
}
.detail.open { transform: translateX(0); opacity: 1; }
.det-hdr { padding: 16px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.det-top { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 11px; }
.det-icon { width: 36px; height: 36px; border-radius: 11px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.det-icon svg { width: 18px; height: 18px; }
.det-name { font-size: 13.5px; font-weight: 600; line-height: 1.4; flex: 1; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.det-close { background: var(--surface-3); border: none; border-radius: 9px; padding: 6px; cursor: pointer; color: var(--t2); flex-shrink: 0; display: flex; transition: all 0.14s; }
.det-close:hover { background: var(--red); color: #fff; }
.det-pbar { height: 5px; background: var(--surface-3); border-radius: 999px; overflow: hidden; margin-bottom: 9px; }
.det-fill { height: 100%; border-radius: 999px; }
.det-meta { display: flex; align-items: center; gap: 8px; }

.det-tabs { display: flex; gap: 4px; padding: 10px 12px; flex-shrink: 0; }
.det-tab { flex: 1; padding: 8px; text-align: center; font-size: 12px; font-weight: 500; color: var(--t2); cursor: pointer; border-radius: 10px; transition: all 0.14s; }
.det-tab:hover { background: var(--surface-2); color: var(--t1); }
.det-tab.on { background: var(--acc); color: #fff; }
.det-body { flex: 1; overflow-y: auto; padding: 6px 12px 14px; }
.det-body::-webkit-scrollbar { width: 5px; }
.det-body::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 3px; }

.ig-sec { margin-bottom: 14px; }
.ig-sec:last-child { margin-bottom: 0; }
.ig-sec-h { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.7px; color: var(--t3); padding: 4px 10px 8px; }
.ig-row { display: grid; grid-template-columns: 110px 1fr; gap: 10px; padding: 8px 10px; border-radius: 10px; align-items: baseline; }
.ig-sec .ig-row:nth-child(even) { background: var(--surface-2); }
.ig-k { font-size: 11px; color: var(--t3); }
.ig-v { font-size: 11.5px; color: var(--t2); font-family: var(--mono); word-break: break-all; text-align: right; }

.f-row { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 10px; transition: background 0.14s; }
.f-row:hover { background: var(--surface-2); }
.f-ic { color: var(--t3); flex-shrink: 0; }
.f-name { flex: 1; font-size: 11.5px; color: var(--t2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.f-sz { font-family: var(--mono); font-size: 10.5px; color: var(--t3); white-space: nowrap; }
.f-pb { width: 42px; height: 4px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.f-pb-f { height: 100%; background: var(--acc); border-radius: 999px; }

.tk-row { padding: 9px 10px; border-radius: 10px; margin-bottom: 4px; background: var(--surface-2); }
.tk-url { font-size: 11px; color: var(--t2); word-break: break-all; margin-bottom: 5px; }
.tk-stats { display: flex; gap: 10px; font-family: var(--mono); font-size: 10px; }
.tk-ok { color: var(--green); }
.tk-err { color: var(--red); }
.tk-dim { color: var(--t3); }

.pr-row { padding: 9px 10px; border-radius: 10px; margin-bottom: 4px; background: var(--surface-2); }
.pr-top { display: flex; justify-content: space-between; margin-bottom: 4px; }
.pr-ip { font-family: var(--mono); font-size: 11.5px; color: var(--t1); display: inline-flex; align-items: center; }
.pr-flag { width: 19px; height: 14px; margin-right: 7px; border-radius: 2px; object-fit: cover; flex-shrink: 0; box-shadow: 0 0 0 1px rgba(255,255,255,0.06); }
.pr-cli { font-size: 10px; color: var(--t3); }
.pr-sp { display: flex; gap: 12px; font-family: var(--mono); font-size: 10px; }
.pr-dl { color: var(--acc2); }
.pr-ul { color: var(--green); }

/* ════ LOGIN ════ */
.login-bg { display: flex; align-items: center; justify-content: center; height: 100vh; }
.login-card { width: 440px; padding: 38px; background: var(--surface); border: 1px solid var(--border); border-radius: 26px; }
.l-logo { display: flex; align-items: center; gap: 14px; margin-bottom: 28px; }
.l-logo-ic { width: 50px; height: 50px; border-radius: 16px; background: linear-gradient(140deg, var(--acc), #7c3aed); display: flex; align-items: center; justify-content: center; font-size: 25px; box-shadow: 0 8px 24px rgba(99,102,241,0.4); }
.l-title { font-size: 24px; font-weight: 700; letter-spacing: -0.5px; }
.l-sub { font-size: 13px; color: var(--t3); margin-top: 2px; }
.fg { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.fg-label { font-size: 12px; font-weight: 500; color: var(--t2); }
.fg-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.finput {
  width: 100%; background: var(--bg); border: 1px solid var(--border-2); border-radius: 12px;
  padding: 11px 14px; color: var(--t1); font-size: 13.5px; font-family: var(--font); outline: none;
  transition: border-color 0.15s;
}
.finput:focus { border-color: var(--acc); }
.finput::placeholder { color: var(--t3); }
.l-err { background: var(--red-soft); border: 1px solid rgba(248,113,113,0.25); border-radius: 12px; padding: 10px 13px; font-size: 12.5px; color: var(--red); margin-bottom: 12px; }
.l-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 18px; }
.cors-tip { margin-top: 16px; border-radius: 14px; background: var(--amber-soft); border: 1px solid rgba(251,191,36,0.2); overflow: hidden; }
.cors-hdr { display: flex; align-items: center; justify-content: space-between; padding: 11px 14px; cursor: pointer; font-size: 12px; color: var(--amber); }
.cors-body { padding: 0 14px 13px; }
.cors-step { font-size: 11.5px; color: var(--t3); line-height: 1.9; }
.cors-step b { color: var(--t2); }
.cors-step code { background: var(--surface-3); padding: 1px 6px; border-radius: 5px; font-family: var(--mono); color: var(--t2); font-size: 10.5px; }

/* ════ MODALS ════ */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; animation: ovIn 0.2s ease; }
.modal { background: var(--surface); border: 1px solid var(--border-2); border-radius: 22px; padding: 24px; width: 480px; max-width: 100%; animation: modalIn 0.28s cubic-bezier(.22,.61,.36,1); }
@keyframes ovIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(14px) scale(0.97); } to { opacity: 1; transform: none; } }
.modal-h { display: flex; align-items: center; gap: 11px; margin-bottom: 18px; }
.modal-h svg { color: var(--acc2); }
.modal-title { font-size: 16px; font-weight: 600; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.mtabs { display: flex; gap: 4px; margin-bottom: 16px; background: var(--bg); padding: 4px; border-radius: 12px; }
.mtab { flex: 1; padding: 7px; text-align: center; font-size: 12.5px; color: var(--t2); cursor: pointer; border-radius: 9px; transition: all 0.14s; }
.mtab.on { background: var(--surface-3); color: var(--t1); }
.dropzone { border: 2px dashed var(--border-2); border-radius: 14px; padding: 28px; text-align: center; color: var(--t3); cursor: pointer; transition: all 0.15s; margin-bottom: 12px; }
.dropzone:hover, .dropzone.drag { border-color: var(--acc); color: var(--t2); background: var(--acc-soft); }
.dropzone svg { width: 28px; height: 28px; margin: 0 auto 9px; display: block; }
.dropzone p { font-size: 12.5px; }
.spd-row { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 14px; margin-bottom: 12px; }
.spd-label { font-size: 13px; color: var(--t2); display: flex; align-items: center; gap: 8px; }
.spd-unit { font-size: 11.5px; color: var(--t3); }
.del-msg { font-size: 13px; color: var(--t2); line-height: 1.6; }
.del-name { color: var(--t1); font-weight: 500; }
.chk-row { display: flex; align-items: center; gap: 9px; margin-top: 13px; cursor: pointer; }
.chk-row input { accent-color: var(--acc); width: 15px; height: 15px; }
.chk-row span { font-size: 12.5px; color: var(--t2); }

/* ════ TOAST ════ */
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); padding: 12px 20px; border-radius: 14px; font-size: 13px; font-weight: 500; z-index: 300; display: flex; align-items: center; gap: 9px; animation: tIn 0.25s ease; }
.toast svg { width: 16px; height: 16px; }
.toast-o { background: var(--surface); border: 1px solid var(--green); color: var(--green); }
.toast-e { background: var(--surface); border: 1px solid var(--red); color: var(--red); }
@keyframes tIn { from { transform: translate(-50%, 16px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

/* scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-2); }

/* ════ ENTRANCE ANIMATIONS ════ */
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* dashboard */
.metric { animation: fadeUp 0.42s cubic-bezier(.22,.61,.36,1) both; }
.metric:nth-child(1) { animation-delay: 0s; }
.metric:nth-child(2) { animation-delay: 0.04s; }
.metric:nth-child(3) { animation-delay: 0.08s; }
.metric:nth-child(4) { animation-delay: 0.12s; }
.metric:nth-child(5) { animation-delay: 0.16s; }
.metric:nth-child(6) { animation-delay: 0.20s; }
.dash .chart-card { animation: fadeUp 0.45s cubic-bezier(.22,.61,.36,1) both; animation-delay: 0.10s; }
.dash-tops { animation: fadeUp 0.45s cubic-bezier(.22,.61,.36,1) both; animation-delay: 0.18s; }

/* torrents + logs */
.filter-bar { animation: fadeUp 0.4s cubic-bezier(.22,.61,.36,1) both; }
.list-card { animation: fadeUp 0.42s cubic-bezier(.22,.61,.36,1) both; animation-delay: 0.06s; }
.logs-card { animation: fadeUp 0.42s cubic-bezier(.22,.61,.36,1) both; }

/* topbar pieces */
.metrics, .title-bar { animation: fadeIn 0.5s ease both; }
.rail { animation: fadeIn 0.5s ease both; }

/* interactive press feedback */
.rail-btn:active { transform: scale(0.9); }
.btn:active { transform: scale(0.96); }
.fpill:active, .det-tab:active, .top-row:active { transform: scale(0.98); }
.abtn:active { transform: scale(0.88); }
.metric, .top-card, .card { transition: border-color 0.2s ease, transform 0.2s ease; }
.top-row { transition: background 0.14s, transform 0.12s; }

/* honour reduced-motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-delay: 0s !important; }
}

/* ── reannounce last-sync time ── */
.reann-time { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--t3); white-space: nowrap; }
.reann-time svg { width: 12px; height: 12px; opacity: 0.7; }

/* ════════════════════════════════════════════════════════════════════
   MOBILE  (≤ 720px) — rail→bottom bar, full-screen detail, stacked rows
   ════════════════════════════════════════════════════════════════════ */
@media (max-width: 720px) {
  html, body, .app, .content { height: 100dvh; }

  /* nav rail → floating bottom bar */
  .rail {
    left: 8px; right: 8px; bottom: 8px; top: auto;
    width: auto; height: 58px;
    flex-direction: row; justify-content: space-around; align-items: center;
    border-radius: 20px; padding: 0 8px; gap: 2px;
  }
  .rail-logo, .rail-sp { display: none; }
  .rail-btn { width: 46px; height: 46px; }
  .rail-btn[data-tip]:hover::after { display: none; } /* no hover tooltips on touch */

  /* content: full width, clear the bottom bar */
  .content { margin-left: 0; padding: 12px 12px 80px; }
  .content.detail-open { margin-right: 0; }

  /* top utility bar wraps */
  .topbar { flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
  .tb-gap { display: none; }
  .reann-time { order: 9; }
  .btn { padding: 9px 13px; }

  /* title bar wraps */
  .title-bar { flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
  .title-h { font-size: 21px; }
  .title-sub { font-size: 12px; }
  .title-right { width: 100%; justify-content: space-between; }

  /* metric cards: 2 per row */
  .metrics { grid-template-columns: 1fr 1fr; gap: 10px; }
  .metric { padding: 12px 13px; gap: 10px; }
  .metric-val { font-size: 21px; }
  .metric-sub { font-size: 10.5px; }

  /* chart header wraps; ranges full width */
  .chart-head { flex-wrap: wrap; gap: 10px; }
  .chart-ranges { width: 100%; }
  .crange { flex: 1; text-align: center; }
  .chart-now { gap: 18px; }
  .chart-canvas-wrap { height: 120px; }

  /* dashboard top lists stack */
  .dash-tops { grid-template-columns: 1fr; min-height: 0; }
  .top-card { min-height: 180px; }

  /* VPN bubble spans the screen */
  .vpn-bubble { left: 0; right: auto; width: 86vw; max-width: 320px; }

  /* filters + search */
  .filter-bar { flex-wrap: wrap; gap: 8px; }
  .fb-gap { display: none; }
  .search-lg { width: 100%; max-width: none; }

  /* ── torrent list: hide header, reflow each row into 3 lines ── */
  .list-head { display: none; }
  .trow {
    grid-template-columns: repeat(3, 1fr) auto;
    gap: 7px 10px; padding: 13px 14px;
    contain-intrinsic-size: 0 86px;
  }
  .trow > *:nth-child(1) { grid-column: 1 / 4; grid-row: 1; }        /* name + chips */
  .trow > *:nth-child(7) { grid-column: 4; grid-row: 1; justify-self: end; } /* actions */
  .trow > *:nth-child(2) { grid-column: 1 / -1; grid-row: 2; }       /* progress */
  .trow > *:nth-child(3) { grid-column: 1; grid-row: 3; }            /* size */
  .trow > *:nth-child(4) { grid-column: 2 / 4; grid-row: 3; }        /* speed */
  .trow > *:nth-child(6) { grid-column: 4; grid-row: 3; justify-self: end; } /* ratio */
  .trow > *:nth-child(5) { display: none; }                          /* peers (hidden) */
  .tn-title { min-width: 0; }

  /* ── detail panel: full screen, slides up from bottom ── */
  .detail {
    left: 8px; right: 8px; top: 8px; bottom: 74px; width: auto;
    transform: translateY(calc(100% + 90px));
  }
  .detail.open { transform: translateY(0); }
  .ig-row { grid-template-columns: 96px 1fr; }

  /* modals + login fit the screen */
  .overlay { padding: 12px; }
  .modal { width: 100%; padding: 18px; }
  .login-card { width: 100%; padding: 26px 20px; }
  .l-title { font-size: 21px; }

  /* toast above the bottom bar */
  .toast { bottom: 82px; }
}

/* extra-small phones */
@media (max-width: 380px) {
  .metrics { grid-template-columns: 1fr; }
  .pill, .vpn { font-size: 11.5px; }
}
