/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 390px;
  padding: 34px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
}
.login-card .mark {
  width: 46px;
  height: 46px;
  border-radius: 13px;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 21px;
  margin-bottom: 20px;
}
.login-card h1 {
  margin: 0 0 6px;
  font-size: 22px;
  letter-spacing: -0.02em;
}
.login-card p {
  margin: 0 0 24px;
  color: var(--text-mute);
  font-size: 13.5px;
}

/* ---------- Shell ---------- */
.admin-shell {
  display: grid;
  grid-template-columns: 236px 1fr;
  min-height: 100vh;
}

.admin-side {
  border-right: 1px solid var(--border-soft);
  background: var(--bg-elev);
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.admin-side .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px 22px;
  font-weight: 750;
  letter-spacing: -0.02em;
}
.admin-side .brand .mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 14px;
}
.side-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 10px;
  border: none;
  background: none;
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 550;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: all 0.16s var(--ease);
}
.side-link:hover {
  background: var(--surface);
  color: var(--text);
}
.side-link.active {
  background: var(--surface-2);
  color: var(--text);
}
.side-link .dot {
  margin-left: auto;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--good);
  animation: blink 1.6s infinite;
}
@keyframes blink {
  50% {
    opacity: 0.25;
  }
}

.admin-main {
  padding: 30px 34px 70px;
  max-width: 1180px;
}
.admin-main > header {
  margin-bottom: 26px;
}
.admin-main > header h1 {
  margin: 0 0 5px;
  font-size: 25px;
  font-weight: 750;
  letter-spacing: -0.025em;
}
.admin-main > header p {
  margin: 0;
  color: var(--text-mute);
  font-size: 13.5px;
}

/* ---------- Panels ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 20px;
}
.panel > h3 {
  margin: 0 0 4px;
  font-size: 15.5px;
  font-weight: 680;
}
.panel > .desc {
  margin: 0 0 18px;
  color: var(--text-mute);
  font-size: 13px;
}
.panel-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}

/* ---------- Stats ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.stat {
  padding: 18px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border-soft);
}
.stat .k {
  font-size: 12px;
  color: var(--text-mute);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  font-weight: 600;
}
.stat .v {
  font-size: 27px;
  font-weight: 750;
  margin-top: 7px;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.stat .s {
  font-size: 12.5px;
  color: var(--text-mute);
  margin-top: 3px;
}

/* ---------- Dropzone ---------- */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 34px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.18s var(--ease);
  background: var(--bg-elev);
}
.dropzone:hover,
.dropzone.over {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--bg-elev));
}
.dropzone .big {
  font-size: 15px;
  font-weight: 620;
  margin-bottom: 5px;
}
.dropzone .small {
  font-size: 12.5px;
  color: var(--text-mute);
}
.dropzone svg {
  color: var(--accent);
  margin-bottom: 12px;
}
.file-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

/* ---------- Torrent rows ---------- */
.torrent {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 16px 18px;
  margin-bottom: 12px;
}
.torrent-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}
.torrent .name {
  font-weight: 620;
  font-size: 14px;
  word-break: break-word;
  line-height: 1.4;
}
.torrent .path {
  font-size: 12px;
  color: var(--text-mute);
  margin-top: 3px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  word-break: break-all;
}
.torrent .bar {
  height: 7px;
  border-radius: 99px;
  background: var(--surface-2);
  overflow: hidden;
  margin: 13px 0 9px;
}
.torrent .bar > i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.4s var(--ease);
}
.torrent .bar.done > i {
  background: var(--good);
}
.torrent .stats-line {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.torrent .stats-line b {
  color: var(--text);
  font-weight: 620;
}
.torrent-actions {
  display: flex;
  gap: 7px;
  flex: none;
}
.torrent-files {
  margin-top: 14px;
  border-top: 1px solid var(--border-soft);
  padding-top: 12px;
  display: grid;
  gap: 7px;
  max-height: 220px;
  overflow-y: auto;
}
.torrent-files .f {
  display: flex;
  gap: 12px;
  font-size: 12.5px;
  color: var(--text-dim);
}
.torrent-files .f span:first-child {
  flex: 1;
  word-break: break-all;
}

/* ---------- Library rows ---------- */
.lib-row {
  display: grid;
  grid-template-columns: 1.1fr 0.7fr 2fr auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

/* ---------- Log ---------- */
.log {
  background: #0a0c12;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.7;
  max-height: 300px;
  overflow-y: auto;
  color: #9fb3c8;
  white-space: pre-wrap;
}
.log .err {
  color: var(--bad);
}
[data-theme='light'] .log {
  background: #10131c;
}

/* ---------- Browse dialog ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1500;
  background: rgb(0 0 0 / 0.6);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  padding: 20px;
  animation: fade-in 0.15s var(--ease);
}
.modal {
  width: 100%;
  max-width: 560px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.modal header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-soft);
}
.modal header h3 {
  margin: 0 0 4px;
  font-size: 16px;
}
.modal header .cur {
  font-size: 12px;
  color: var(--text-mute);
  font-family: ui-monospace, Menlo, Consolas, monospace;
  word-break: break-all;
}
.modal .body {
  max-height: 46vh;
  overflow-y: auto;
  padding: 8px;
}
.modal footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}
.dir-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: none;
  border-radius: 9px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font-size: 13.5px;
}
.dir-item:hover {
  background: var(--surface);
}
.dir-item svg {
  color: var(--text-mute);
  flex: none;
}

@media (max-width: 860px) {
  .admin-shell {
    grid-template-columns: 1fr;
  }
  .admin-side {
    position: static;
    height: auto;
    flex-direction: row;
    overflow-x: auto;
    padding: 12px;
  }
  .admin-side .brand {
    display: none;
  }
  .side-link {
    width: auto;
    white-space: nowrap;
  }
  .admin-main {
    padding: 20px 16px 60px;
  }
  .lib-row {
    grid-template-columns: 1fr;
  }
}
