:root {
  --bg: #07111f;
  --bg-soft: rgba(9, 18, 32, 0.74);
  --panel: rgba(12, 23, 41, 0.9);
  --panel-2: rgba(20, 35, 59, 0.95);
  --line: rgba(146, 168, 196, 0.18);
  --line-strong: rgba(146, 168, 196, 0.34);
  --text: #eef4ff;
  --muted: #9fb2cc;
  --green: #33d17a;
  --yellow: #ffb84d;
  --red: #ff6b7a;
  --cyan: #67e8f9;
  --blue: #7aa2ff;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(122, 162, 255, 0.2), transparent 28%),
    radial-gradient(circle at right 20%, rgba(103, 232, 249, 0.12), transparent 24%),
    linear-gradient(180deg, #08111f 0%, #03070d 100%);
  color: var(--text);
  font-family: "IBM Plex Sans", sans-serif;
}

button,
input,
textarea,
select {
  font: inherit;
}

select option {
  background: #0f1828;
  color: #eef4ff;
}

.field-hint {
  color: var(--muted);
  font-size: 12px;
}

.drop-zone {
  position: relative;
  border: 1px dashed var(--line-strong);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.03);
  min-height: 110px;
  overflow: hidden;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--cyan);
  background: rgba(103, 232, 249, 0.08);
  transform: translateY(-1px);
}

.drop-zone.disabled {
  opacity: 0.72;
}

.drop-zone.disabled input[type="file"] {
  pointer-events: none;
}

.drop-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.torrent-clear-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(244, 63, 94, 0.4);
  background: rgba(190, 24, 93, 0.28);
  color: #ffe4e6;
  font-weight: 700;
  z-index: 2;
  cursor: pointer;
}

.torrent-clear-btn:hover {
  background: rgba(225, 29, 72, 0.42);
}

.drop-zone-copy {
  min-height: 110px;
  display: grid;
  place-items: center;
  text-align: center;
  gap: 6px;
  padding: 16px;
}

.drop-zone-copy strong {
  font-size: 15px;
}

.drop-zone-copy span,
.drop-zone-copy small {
  color: var(--muted);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 28px 28px;
  pointer-events: none;
  opacity: 0.55;
}

body.modal-open {
  overflow: hidden;
}

.hidden {
  display: none !important;
}

.stack,
.stack-lg {
  display: grid;
  gap: 14px;
}

.stack-lg {
  gap: 20px;
}

.app-shell {
  position: relative;
  min-height: 100vh;
  padding: 28px;
}

.login-view {
  min-height: calc(100vh - 56px);
  display: grid;
  place-items: center;
}

.login-panel,
.panel,
.hero {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(16px);
}

.login-panel {
  width: min(460px, 100%);
  padding: 28px;
  border-radius: 28px;
}

.dashboard {
  display: grid;
  gap: 22px;
}

.hero {
  border-radius: 30px;
  padding: 28px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
  position: relative;
}

.session-badge,
.pill,
.metric {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
}

.session-badge {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 999px;
  color: var(--cyan);
  font-weight: 600;
  font: inherit;
  text-align: left;
  cursor: default;
}

.session-badge-toggle {
  border: 1px solid var(--line);
}

.hero-menu {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(320px, 0.95fr);
  gap: 22px;
  align-items: start;
}

.column {
  min-width: 0;
}

.panel {
  border-radius: 26px;
  padding: 22px;
}

.spotlight {
  background:
    linear-gradient(135deg, rgba(103, 232, 249, 0.06), transparent 38%),
    linear-gradient(180deg, rgba(20, 35, 59, 0.98), rgba(9, 18, 32, 0.96));
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 18px;
}

.panel-head.compact {
  margin-bottom: 12px;
}

.eyebrow,
.label {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 11px;
  color: var(--cyan);
}

.hero-title {
  margin: 0;
  font-size: 2rem;
  letter-spacing: 0.12em;
  font-weight: 700;
  color: var(--cyan);
}

h1,
h2 {
  font-family: "Space Grotesk", sans-serif;
  margin: 0;
  line-height: 1;
}

h1 {
  font-size: clamp(34px, 5vw, 58px);
}

h2 {
  font-size: 24px;
}

.muted,
.hint {
  color: var(--muted);
}

.hint {
  margin: 0;
  min-height: 18px;
  font-size: 13px;
}

.hint-error {
  color: var(--red);
}

.hint-success {
  color: var(--green);
}

.grid.two {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.settings-form {
  display: grid;
  gap: 14px 16px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: end;
}

.settings-form .full-width {
  grid-column: 1 / -1;
}

.settings-checkbox {
  min-height: 50px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
}

.settings-checkbox span {
  color: var(--text);
}

.series-options-row {
  grid-column: 1 / -1;
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr) minmax(120px, 180px);
  align-items: end;
}

label {
  display: grid;
  gap: 4px;
}

label span {
  font-size: 13px;
  color: var(--muted);
}

input,
textarea,
select {
  width: 100%;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  padding: 12px 14px;
  outline: none;
}

input:disabled,
textarea:disabled,
select:disabled {
  opacity: 0.58;
  cursor: not-allowed;
}

select {
  color-scheme: dark;
}

select option,
select optgroup {
  background: #101829;
  color: #eef4ff;
  border: 1px solid rgba(146, 168, 196, 0.16);
}

select option:checked,
select option:hover,
select option:focus {
  background: linear-gradient(0deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.035)), #101829;
  color: #ffffff;
}

select.placeholder {
  color: var(--muted);
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(122, 162, 255, 0.12);
}

textarea {
  resize: vertical;
}

label.invalid span {
  color: var(--red);
}

label.invalid input,
label.invalid textarea,
label.invalid select {
  border-color: rgba(255, 107, 122, 0.52);
  box-shadow:
    0 0 0 4px rgba(255, 107, 122, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.03),
    inset 0 -1px 0 rgba(0, 0, 0, 0.12);
}


.checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
}

.checkbox input {
  width: 18px;
  height: 18px;
  margin: 0;
}

.checkbox span {
  color: var(--text);
}

.compact-checkbox {
  gap: 8px;
}

.compact-checkbox span {
  color: var(--muted);
  font-size: 13px;
}

.primary-btn,
.ghost-btn,
.action-btn {
  border: 0;
  border-radius: 16px;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

.primary-btn:hover,
.ghost-btn:hover,
.action-btn:hover {
  transform: translateY(-1px);
}

.primary-btn {
  background: linear-gradient(135deg, #7aa2ff 0%, #4ef0c3 100%);
  color: #04111f;
  padding: 13px 18px;
  font-weight: 700;
  box-shadow: 0 16px 32px rgba(84, 203, 220, 0.2);
}

.ghost-btn,
.action-btn {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border: 1px solid var(--line);
  padding: 10px 14px;
}

.ghost-btn.small,
.action-btn {
  padding: 8px 10px;
  border-radius: 12px;
  font-size: 13px;
}

.logout-btn {
  background: rgba(190, 24, 93, 0.24);
  border-color: rgba(244, 63, 94, 0.45);
  color: #ffe4e6;
}

.logout-btn:hover {
  background: rgba(225, 29, 72, 0.4);
}

.danger-btn {
  background: linear-gradient(135deg, #ff8a8a 0%, #ff5d73 100%);
  color: #23040a;
  box-shadow: 0 16px 32px rgba(255, 107, 122, 0.24);
}

.danger-btn:hover {
  background: linear-gradient(135deg, #ff9a9a 0%, #ff6b7a 100%);
}

.snackbar-stack {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 1200;
  display: grid;
  gap: 12px;
  width: min(380px, calc(100vw - 36px));
  pointer-events: none;
}

.snackbar {
  --snackbar-accent: rgba(146, 168, 196, 0.28);
  --snackbar-fill: rgba(146, 168, 196, 0.16);
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid var(--snackbar-accent);
  background: var(--snackbar-fill);
  color: var(--text);
  box-shadow: 0 22px 44px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(16px);
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.snackbar.visible {
  opacity: 1;
  transform: translateY(0);
}

.snackbar-info {
  --snackbar-accent: rgba(122, 162, 255, 0.32);
  --snackbar-fill: rgba(122, 162, 255, 0.16);
}

.snackbar-success {
  --snackbar-accent: rgba(51, 209, 122, 0.34);
  --snackbar-fill: rgba(51, 209, 122, 0.16);
}

.snackbar-error {
  --snackbar-accent: rgba(255, 107, 122, 0.36);
  --snackbar-fill: rgba(255, 107, 122, 0.16);
}

.snackbar-message {
  flex: 1;
  line-height: 1.4;
}

.snackbar-close {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  cursor: pointer;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1300;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(2, 7, 13, 0.72);
  backdrop-filter: blur(10px);
}

.modal-card {
  width: min(540px, 100%);
  border: 1px solid var(--line-strong);
  border-radius: 26px;
  background:
    linear-gradient(180deg, rgba(20, 35, 59, 0.98), rgba(9, 18, 32, 0.98));
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.42);
  padding: 22px;
}

.modal-card[data-tone="danger"] {
  border-color: rgba(255, 107, 122, 0.42);
}

.modal-card[data-tone="danger"] .modal-head h3 {
  color: #ffd8de;
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.modal-head h3 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: 24px;
  line-height: 1.05;
}

.modal-close-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  cursor: pointer;
}

.modal-message {
  margin: 0 0 16px;
  color: var(--muted);
  line-height: 1.5;
  white-space: pre-wrap;
}

.modal-fields {
  gap: 12px;
}

.modal-error {
  min-height: 0;
  margin: 0;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.modal-actions .primary-btn,
.modal-actions .ghost-btn {
  min-width: 120px;
}

.inline-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.advanced-box {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.02);
}

.advanced-box summary {
  cursor: pointer;
  font-weight: 600;
}

.advanced-box[open] summary {
  margin-bottom: 14px;
}

.downloads-grid {
  display: grid;
  gap: 14px;
}

.torrent-files-list {
  display: grid;
  gap: 8px;
  max-height: 320px;
  overflow: auto;
}

.torrent-files-title-invalid {
  color: var(--red);
}

.torrent-file-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.025);
}

.torrent-file-row label {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.torrent-file-row input {
  width: 18px;
  height: 18px;
  margin: 0;
}

.torrent-file-name {
  overflow-wrap: anywhere;
}

.torrent-file-size {
  color: var(--muted);
  white-space: nowrap;
  font-size: 13px;
}

.download-card,
.admin-item,
.summary-item {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--bg-soft);
}

.download-card {
  padding: 18px;
  display: grid;
  gap: 14px;
}

.download-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.download-status-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.download-title {
  font-weight: 700;
  overflow-wrap: anywhere;
}

.download-subtitle {
  font-size: 13px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.download-status-note {
  color: var(--yellow);
  font-size: 13px;
  font-weight: 600;
}

.chevron-btn {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.history-delete-btn {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid rgba(244, 63, 94, 0.45);
  background: rgba(190, 24, 93, 0.24);
  color: #ffe4e6;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: 700;
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.history-delete-btn:hover {
  background: rgba(225, 29, 72, 0.4);
  border-color: rgba(251, 113, 133, 0.58);
}

.user-delete-btn {
  background: rgba(190, 24, 93, 0.24);
  border-color: rgba(244, 63, 94, 0.45);
  color: #ffe4e6;
}

.user-delete-btn:hover {
  background: rgba(225, 29, 72, 0.4);
  border-color: rgba(251, 113, 133, 0.58);
}

.chevron-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--line-strong);
}

.chevron-icon {
  width: 10px;
  height: 10px;
  border-right: 2px solid var(--text);
  border-bottom: 2px solid var(--text);
  transform: rotate(45deg) translateY(-1px);
  transition: transform 0.18s ease;
}

.chevron-btn.expanded .chevron-icon {
  transform: rotate(225deg) translateY(-1px);
}

.download-details {
  display: none;
}

.download-details.expanded {
  display: block;
}

.download-logs {
  display: grid;
  gap: 6px;
}

.download-actions {
  margin-top: -2px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  padding: 7px 11px;
  color: var(--text);
  font-size: 12px;
}

.progress-bar {
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #7aa2ff 0%, #4ef0c3 100%);
}

.download-stats,
.download-actions,
.capability-pills,
.status-metrics {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.metric {
  border-radius: 16px;
  padding: 9px 12px;
  min-width: 90px;
}

.metric-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted);
}

.metric strong {
  font-family: "Space Grotesk", sans-serif;
  font-size: 19px;
}

.summary-list,
.admin-list {
  display: grid;
  gap: 12px;
}

.summary-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.summary-item,
.admin-item {
  padding: 14px;
}

.summary-item strong,
.admin-item strong {
  display: block;
  margin-bottom: 6px;
}

.category-admin-item {
  display: grid;
  gap: 8px;
}

.category-admin-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.category-admin-head strong {
  margin-bottom: 0;
}

.category-admin-actions {
  margin-left: auto;
  justify-content: flex-end;
  flex-shrink: 0;
}

.side-column {
  position: sticky;
  top: 18px;
  align-self: start;
}

.mini-panel {
  background:
    linear-gradient(180deg, rgba(103, 232, 249, 0.05), transparent 46%),
    var(--panel);
}

.admin-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.tab-btn {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  border-radius: 999px;
  padding: 9px 12px;
  cursor: pointer;
}

.tab-btn.active {
  color: var(--text);
  border-color: var(--line-strong);
  background: rgba(122, 162, 255, 0.18);
}

.tab-content {
  display: none;
  gap: 14px;
}

.tab-content.active {
  display: grid;
}

.logs-box {
  min-height: 320px;
  max-height: 420px;
  overflow: auto;
  margin: 0;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: #02060d;
  color: #c8f1ff;
  white-space: pre-wrap;
  word-break: break-word;
}

.status-queued {
  color: var(--yellow);
}

.status-waiting {
  color: var(--yellow);
}

.status-downloading,
.status-completed {
  color: var(--green);
}

.status-paused {
  color: var(--blue);
}

.status-failed,
.status-cancelled,
.status-completed_with_warnings {
  color: var(--red);
}

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .side-column {
    position: static;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 16px;
  }

  .hero-actions {
    width: 100%;
  }

  .hero {
    padding: 22px;
    flex-direction: column;
  }

  .downloads-panel .panel-head {
    flex-direction: column;
    align-items: stretch;
  }

  .downloads-panel .status-metrics {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .downloads-panel .metric {
    width: 100%;
    min-width: 0;
  }

  .grid.two {
    grid-template-columns: 1fr;
  }

  .settings-form {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 570px) {
  .snackbar-stack {
    top: 16px;
    left: 16px;
    right: 16px;
    width: auto;
  }

  .modal-backdrop {
    padding: 16px;
  }

  .modal-card {
    padding: 18px;
  }

  .modal-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .modal-actions .primary-btn,
  .modal-actions .ghost-btn {
    width: 100%;
  }

  .hero {
    z-index: 1;
  }

  .hero-actions {
    width: auto;
    align-self: flex-end;
    flex-direction: column;
    align-items: stretch;
  }

  .session-badge {
    width: 100%;
    justify-content: space-between;
    cursor: pointer;
  }

  .session-badge::after {
    content: "▾";
    font-size: 12px;
    line-height: 1;
    color: var(--muted);
    transition: transform 0.18s ease;
  }

  .hero-actions.mobile-open .session-badge::after {
    transform: rotate(180deg);
  }

  .hero-menu {
    display: none;
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    z-index: 20;
    min-width: min(260px, calc(100vw - 32px));
    padding: 10px;
    border: 1px solid var(--line-strong);
    border-radius: 18px;
    background: rgba(12, 23, 41, 0.98);
    box-shadow: 0 22px 44px rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(16px);
    flex-direction: column;
    align-items: stretch;
  }

  .hero-actions.mobile-open .hero-menu {
    display: flex;
  }

  .hero-menu .ghost-btn {
    width: 100%;
    display: flex;
    justify-content: flex-start;
  }
}

@media (max-width: 500px) {
  .category-admin-head {
    flex-direction: column;
    align-items: stretch;
  }

  .category-admin-actions {
    margin-left: 0;
    justify-content: flex-start;
  }
}
