:root {
  --bg: #0b0d14;
  --bg-2: #11141d;
  --card: rgba(22, 26, 38, 0.82);
  --card-solid: #161a26;
  --border: rgba(255, 255, 255, 0.07);
  --border-2: rgba(255, 255, 255, 0.12);
  --text: #e8eaf2;
  --muted: #8b91a7;
  --accent: #7c5cff;
  --accent-2: #22d3ee;
  --accent-soft: rgba(124, 92, 255, 0.14);
  --ok: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --win: #3b82f6;
  --lin: #f59e0b;
  --tool: #10b981;
  --other: #a78bfa;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f5fb;
    --bg-2: #eceef7;
    --card: rgba(255, 255, 255, 0.9);
    --card-solid: #ffffff;
    --border: rgba(15, 20, 40, 0.08);
    --border-2: rgba(15, 20, 40, 0.15);
    --text: #161a2b;
    --muted: #646b84;
    --accent-soft: rgba(124, 92, 255, 0.1);
    --shadow: 0 8px 24px rgba(20, 25, 60, 0.08);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(124, 92, 255, 0.16), transparent 60%),
    radial-gradient(900px 500px at 110% 10%, rgba(34, 211, 238, 0.10), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  min-height: 100vh;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
code { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 12px; background: var(--accent-soft); padding: 1px 6px; border-radius: 6px; }
h2 { font-size: 15px; margin: 0; font-weight: 600; letter-spacing: .2px; }
h3 { margin: 0; font-size: 16px; }

/* ---------- brand / topbar */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: .5px; font-size: 18px; }
.brand.big { font-size: 28px; justify-content: center; }
.logo {
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 20px rgba(124, 92, 255, .5);
  position: relative;
}
.logo::after { content: ""; position: absolute; inset: 8px 7px 11px; border: 2px solid #fff; border-radius: 3px; }
.logo::before { content: ""; position: absolute; left: 11px; right: 11px; bottom: 5px; height: 4px; background: #fff; border-radius: 1px; }
.brand.big .logo { width: 40px; height: 40px; }
.brand.big .logo::after { inset: 11px 10px 16px; }
.brand.big .logo::before { left: 16px; right: 16px; bottom: 7px; height: 6px; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px; padding: 12px 24px;
  background: color-mix(in srgb, var(--bg) 75%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.services { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; justify-content: center; }
.svc { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--card); border: 1px solid var(--border); font-size: 12px; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--bad); box-shadow: 0 0 8px var(--bad); }
.dot.on { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.top-actions { display: flex; gap: 6px; }

main { max-width: 1280px; margin: 0 auto; padding: 24px; display: flex; flex-direction: column; gap: 20px; }

/* ---------- cards */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); backdrop-filter: blur(8px);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1.2fr 1fr; gap: 20px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- stats */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
@media (max-width: 1000px) { .stats { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .stats { grid-template-columns: 1fr; } }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); min-width: 0; }
.stat .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .8px; }
.stat .value { font-size: 24px; font-weight: 700; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .sub { color: var(--muted); font-size: 12px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar { height: 6px; background: var(--border-2); border-radius: 999px; overflow: hidden; margin-top: 10px; }
.bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 999px; transition: width .4s; }
.bar.warn > span { background: linear-gradient(90deg, var(--warn), var(--bad)); }

/* ---------- buttons / inputs */
.btn {
  appearance: none; border: 1px solid var(--border-2); background: var(--card-solid); color: var(--text);
  padding: 8px 14px; border-radius: 10px; font: inherit; font-weight: 500; cursor: pointer;
  transition: transform .08s, background .15s, border-color .15s; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(135deg, var(--accent), #6246ea); border-color: transparent; color: #fff; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--accent-soft); }
.btn.danger { background: rgba(248, 113, 113, .12); border-color: rgba(248, 113, 113, .35); color: var(--bad); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn {
  appearance: none; border: 0; background: transparent; color: var(--muted); cursor: pointer;
  width: 32px; height: 32px; border-radius: 8px; display: inline-grid; place-items: center; font-size: 14px;
}
.icon-btn:hover { background: var(--accent-soft); color: var(--text); }
.icon-btn.bad:hover { background: rgba(248, 113, 113, .14); color: var(--bad); }
.icon-btn svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

input[type=text], input[type=url], input[type=password], input[type=search], input[type=number], select, textarea {
  font: inherit; color: var(--text); background: var(--bg-2); border: 1px solid var(--border-2);
  padding: 9px 12px; border-radius: 10px; outline: none; min-width: 0; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select { cursor: pointer; }

/* ---------- dropzone */
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  border: 2px dashed var(--border-2); border-radius: var(--radius); padding: 30px 16px; cursor: pointer;
  text-align: center; transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dz-icon { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; background: var(--accent-soft); }
.dz-icon svg { width: 26px; height: 26px; stroke: var(--accent); fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.dz-title { font-weight: 600; font-size: 15px; }
.url-form { display: flex; gap: 8px; margin-top: 14px; }
.url-form #url-input { flex: 2; }
.url-form #url-name { flex: 1; }
@media (max-width: 600px) { .url-form { flex-direction: column; } }

/* ---------- transfers */
.transfers { display: flex; flex-direction: column; gap: 10px; max-height: 260px; overflow: auto; }
.xfer { padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-2); }
.xfer-top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.xfer-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.xfer-meta { font-size: 12px; color: var(--muted); margin-top: 4px; display: flex; justify-content: space-between; }
.empty { color: var(--muted); text-align: center; padding: 26px 10px; font-size: 13px; }

/* ---------- library */
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar input[type=search] { width: 200px; }
.chips { display: flex; gap: 4px; background: var(--bg-2); padding: 3px; border-radius: 10px; border: 1px solid var(--border); }
.chip { border: 0; background: transparent; color: var(--muted); padding: 5px 10px; border-radius: 8px; cursor: pointer; font: inherit; font-size: 13px; }
.chip.active { background: var(--card-solid); color: var(--text); box-shadow: 0 1px 4px rgba(0, 0, 0, .2); }
.library { display: flex; flex-direction: column; gap: 6px; }
.group-title { font-size: 11px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--muted); margin: 12px 4px 4px; }
.group-title:first-child { margin-top: 0; }
.iso {
  display: grid; grid-template-columns: 42px minmax(0, 1fr) auto auto auto; gap: 14px; align-items: center;
  padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--bg-2);
  transition: border-color .15s, transform .15s;
}
.iso:hover { border-color: var(--border-2); }
.iso.disabled { opacity: .55; }
.iso-icon { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; font-weight: 800; font-size: 13px; color: #fff; }
.cat-windows { background: linear-gradient(135deg, #3b82f6, #1d4ed8); }
.cat-linux { background: linear-gradient(135deg, #f59e0b, #d97706); }
.cat-tools { background: linear-gradient(135deg, #10b981, #047857); }
.cat-other { background: linear-gradient(135deg, #a78bfa, #7c3aed); }
.iso-title { font-weight: 600; display: flex; align-items: center; gap: 8px; min-width: 0; }
.iso-title span.t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.iso-sub { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.iso-note { font-size: 12px; color: var(--warn); margin-top: 3px; }
.iso-note.bad { color: var(--bad); }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 600; white-space: nowrap; }
.pill { font-size: 12px; padding: 3px 10px; border-radius: 999px; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.pill.ready { background: rgba(52, 211, 153, .12); color: var(--ok); }
.pill.processing, .pill.queued { background: rgba(251, 191, 36, .12); color: var(--warn); }
.pill.error { background: rgba(248, 113, 113, .12); color: var(--bad); }
.spinner { width: 10px; height: 10px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.iso-method select { max-width: 230px; font-size: 12px; padding: 6px 8px; }
.iso-actions { display: flex; gap: 2px; align-items: center; }
@media (max-width: 860px) {
  .iso { grid-template-columns: 42px minmax(0, 1fr) auto; }
  .iso-method { grid-column: 2 / -1; }
  .iso-actions { grid-column: 2 / -1; justify-content: flex-end; }
}

/* switch */
.switch { position: relative; width: 38px; height: 22px; display: inline-block; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--border-2); border-radius: 999px; transition: .2s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(16px); }

/* ---------- events */
.events { display: flex; flex-direction: column; max-height: 300px; overflow: auto; }
.ev { display: grid; grid-template-columns: 90px 130px 150px 1fr; gap: 12px; padding: 8px 4px; border-bottom: 1px solid var(--border); font-size: 13px; }
.ev:last-child { border-bottom: 0; }
.ev .mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; color: var(--muted); }
@media (max-width: 700px) { .ev { grid-template-columns: 70px 1fr; } .ev .mac { display: none; } .ev .txt { grid-column: 1 / -1; } }

/* ---------- modal */
.modal { position: fixed; inset: 0; background: rgba(5, 6, 12, .6); backdrop-filter: blur(4px); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal-card { width: min(620px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--card-solid); border: 1px solid var(--border-2); border-radius: 18px; box-shadow: 0 30px 80px rgba(0, 0, 0, .5); animation: pop .15s ease-out; }
@keyframes pop { from { transform: scale(.97); opacity: 0; } }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--card-solid); }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 12px; color: var(--muted); font-weight: 500; }
.field .hint { font-size: 12px; color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > .field { flex: 1; min-width: 160px; }
.section-title { font-size: 11px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--muted); margin-top: 6px; padding-top: 14px; border-top: 1px solid var(--border); }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 12px; font-size: 13px; }
.kv > div:nth-child(odd) { color: var(--muted); }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; }
pre.log { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 10px; max-height: 260px; overflow: auto; font-size: 12px; white-space: pre-wrap; margin: 0; }
.help p { margin: 0 0 8px; }
.help ol, .help ul { margin: 0 0 8px; padding-left: 20px; }
.help li { margin-bottom: 4px; }

/* ---------- login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); background: var(--card); border: 1px solid var(--border); border-radius: 20px; padding: 32px; display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow); text-align: center; }
.login-card p { margin: -6px 0 6px; }
.login-err { color: var(--bad); min-height: 18px; font-size: 13px; }

/* ---------- toasts */
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--card-solid); border: 1px solid var(--border-2); border-left: 3px solid var(--accent); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow); max-width: 360px; animation: pop .15s ease-out; }
.toast.bad { border-left-color: var(--bad); }
.toast.ok { border-left-color: var(--ok); }

@media (max-width: 640px) {
  .topbar { padding: 10px 16px; flex-wrap: wrap; }
  .services { order: 3; flex-basis: 100%; justify-content: flex-start; }
  main { padding: 16px; }
  .toolbar input[type=search] { width: 100%; }
}
