:root {
  font-family: "Manrope", "Segoe UI Variable", "Segoe UI", sans-serif;
  --bg: #040912;
  --bg-glow: #10203b;
  --surface: #0b1424;
  --card: #101d31;
  --field: #081120;
  --border: #233954;
  --text: #e2e8f0;
  --muted: #90a4bf;
  --accent: #38bdf8;
  --danger: #f43f5e;
  --button-bg: #0d1a2c;
  --button-bg-hover: #12243d;
  --tab-bg: #0b1321;
  --tab-active: #14253e;
  --toast-bg: #0f1f33;
  --toast-border: #2a4f78;
  --progress-track: #0b1628;
  --overlay: rgba(8, 13, 23, 0.85);
}

:root[data-theme="dark"] {
  color-scheme: dark;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #eef3fb;
  --bg-glow: #d7e5ff;
  --surface: #f7faff;
  --card: #ffffff;
  --field: #ffffff;
  --border: #c7d5ea;
  --text: #0f223d;
  --muted: #4e6482;
  --accent: #1168d9;
  --danger: #c0392b;
  --button-bg: #f3f7ff;
  --button-bg-hover: #e6efff;
  --tab-bg: #edf3ff;
  --tab-active: #dce8ff;
  --toast-bg: #ffffff;
  --toast-border: #a9c1e8;
  --progress-track: #dfe8f8;
  --overlay: rgba(229, 238, 252, 0.88);
}

* {
  box-sizing: border-box;
}

html,
body,
#root {
  margin: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 15% 10%, var(--bg-glow) 0, var(--surface) 45%, var(--bg) 100%);
  color: var(--text);
}

.app-shell {
  display: grid;
  grid-template-rows: auto auto auto 1fr auto;
  height: 100%;
  padding: 12px 14px 10px;
  gap: 8px;
}

/* ── Menu Bar ───────────────────────────────────────────────── */

.menu-bar {
  display: flex;
  align-items: center;
  gap: 0;
  user-select: none;
  font-size: 13px;
  font-weight: 600;
  margin: -8px -6px 0;
}

.menu-bar-item {
  position: relative;
}

.menu-bar-trigger {
  background: none;
  border: none;
  color: var(--text);
  padding: 5px 12px;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  border-radius: 6px;
  transition: background 0.1s;
}

.menu-bar-trigger:hover,
.menu-bar-trigger.open {
  background: var(--button-bg-hover);
}

.menu-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 1000;
  min-width: max-content;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 0;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  white-space: nowrap;
}

.menu-dropdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: none;
  color: var(--text);
  padding: 7px 16px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  transition: background 0.1s;
}

.menu-dropdown-item:hover {
  background: var(--button-bg-hover);
}

.menu-dropdown-item .shortcut {
  color: var(--muted);
  font-size: 12px;
  margin-left: 24px;
  white-space: nowrap;
}

.menu-separator {
  height: 1px;
  background: var(--border);
  margin: 4px 8px;
}

.menu-submenu {
  position: relative;
}

.menu-submenu-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: none;
  color: var(--text);
  padding: 7px 16px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  transition: background 0.1s;
}

.menu-submenu-trigger:hover {
  background: var(--button-bg-hover);
}

.menu-submenu-trigger::after {
  content: "\25B6";
  font-size: 8px;
  color: var(--muted);
  margin-left: 12px;
}

.menu-submenu-dropdown {
  position: absolute;
  top: -4px;
  left: 100%;
  z-index: 1001;
  min-width: max-content;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 0;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.menu-settings-grid {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  align-items: center;
  gap: 6px 8px;
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.menu-spinner {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  height: 28px;
}

.menu-spinner.disabled {
  opacity: 0.45;
  pointer-events: none;
}

.menu-spinner input[type="text"] {
  width: 38px;
  background: var(--field);
  color: var(--text);
  border: none;
  padding: 0 6px;
  font: inherit;
  font-size: 13px;
  text-align: center;
  outline: none;
}

.menu-spinner-arrows {
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border);
}

.menu-spinner-arrows button {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--button-bg);
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  width: 18px;
  flex: 1;
  font-size: 8px;
  line-height: 1;
  transition: background 0.1s;
}

.menu-spinner-arrows button:hover {
  background: var(--button-bg-hover);
  color: var(--text);
}

.menu-spinner-arrows button:first-child {
  border-bottom: 1px solid var(--border);
}

.menu-settings-grid input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

.menu-speed-unit {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}



.control-strip {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--surface) 92%, transparent), color-mix(in srgb, var(--bg) 92%, transparent));
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
}

.ctrl-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--button-bg);
  color: var(--muted);
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease, transform 0.12s ease;
}

.ctrl-icon-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: var(--accent);
  background: var(--button-bg-hover);
  color: var(--text);
}

.ctrl-icon-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.ctrl-icon-btn.ctrl-play:not(:disabled) {
  color: #4ade80;
}

.ctrl-icon-btn.ctrl-play:hover:not(:disabled) {
  border-color: #4ade80;
  background: rgba(74, 222, 128, 0.1);
}

.ctrl-icon-btn.ctrl-pause:not(:disabled):hover {
  border-color: #f59e0b;
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.1);
}

.ctrl-icon-btn.ctrl-pause.paused {
  border-color: #f59e0b;
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.15);
}

.ctrl-icon-btn.ctrl-stop:not(:disabled) {
  color: var(--danger);
}

.ctrl-icon-btn.ctrl-stop:hover:not(:disabled) {
  border-color: var(--danger);
  background: rgba(244, 63, 94, 0.1);
}

.ctrl-icon-btn.ctrl-speed.active {
  color: #f59e0b;
  border-color: rgba(245, 158, 11, 0.5);
  background: rgba(245, 158, 11, 0.1);
}

.ctrl-icon-btn.ctrl-speed:hover:not(:disabled) {
  border-color: #f59e0b;
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.1);
}

.ctrl-separator {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 2px;
}

.buttons,
.speed-config,
.link-actions,
.input-row,
.settings-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.buttons-right {
  margin-left: auto;
  justify-content: flex-end;
}

.btn {
  background: var(--button-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 6px 11px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: var(--accent);
  background: var(--button-bg-hover);
}

.btn.accent {
  background: linear-gradient(180deg, #56d6ff, #33b9f4);
  color: #07111c;
  border-color: #41c6f9;
}

.btn.danger {
  border-color: rgba(244, 63, 94, 0.7);
  color: #fda4af;
}

:root[data-theme="light"] .btn.danger {
  border-color: color-mix(in srgb, var(--danger) 60%, transparent);
  color: var(--danger);
}

.btn.btn-active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 45%, transparent);
}

.tabs {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tab-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.tab-action-btn {
  font-size: 12px;
  padding: 5px 10px;
}

.tab-action-btn:hover:not(:disabled) {
  transform: none;
}

.downloads-action-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
}

.search-input.tab-search {
  width: 330px;
  min-width: 330px;
  position: relative;
  z-index: 1;
}

.tab {
  background: var(--tab-bg);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 9px;
  padding: 7px 12px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
}

.tab.active {
  color: var(--text);
  background: var(--tab-active);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}

.tab-content {
  min-height: 0;
}

.grid-two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  height: 100%;
}

.card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--card) 96%, transparent), color-mix(in srgb, var(--surface) 96%, transparent));
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.card.wide {
  grid-column: span 2;
  min-height: 280px;
}

.card h3 {
  margin: 0;
  font-size: 15px;
  letter-spacing: 0.1px;
}

.card label,
.hint {
  color: var(--muted);
  font-size: 13px;
}

.card input,
.card select,
.speed-config input,
.speed-config select,
.speed-config button,
.card textarea {
  width: 100%;
  background: var(--field);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 7px 9px;
}

.card textarea {
  min-height: 220px;
  resize: vertical;
}

.password-list {
  min-height: 120px;
  resize: vertical;
}

.input-row input {
  flex: 1;
}

.speed-config input {
  width: 96px;
}

.speed-config select {
  width: 150px;
}

.downloads-view {
  height: 100%;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.downloads-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.downloads-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.downloads-toolbar .search-input {
  margin-left: auto;
}

.pkg-column-header {
  display: grid;
  grid-template-columns: 1fr 70px 160px 220px 180px 100px;
  gap: 8px;
  padding: 5px 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  user-select: none;
}

.pkg-column-header .sortable {
  cursor: pointer;
}

.pkg-column-header .sortable:hover {
  color: var(--text);
}

.pkg-column-header .sort-active {
  color: var(--accent);
}

.pkg-columns {
  display: grid;
  grid-template-columns: 1fr 70px 160px 220px 180px 100px;
  gap: 8px;
  align-items: center;
  min-width: 0;
  flex: 1;
}

.pkg-columns .pkg-col-name {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.pkg-columns .pkg-col-name h4 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pkg-columns .pkg-col-progress,
.pkg-columns .pkg-col-size,
.pkg-columns .pkg-col-hoster,
.pkg-columns .pkg-col-status,
.pkg-columns .pkg-col-speed {
  font-size: 13px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pkg-col-progress {
  font-variant-numeric: tabular-nums;
}

.progress-size {
  display: block;
  position: relative;
  width: 100%;
  height: 18px;
  background: var(--progress-track);
  border-radius: 4px;
  overflow: hidden;
}

.progress-size-bar {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: linear-gradient(90deg, #3bc9ff, #22d3ee);
  border-radius: 4px;
  transition: width 0.15s ease;
}

.progress-size-text {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  white-space: nowrap;
  z-index: 1;
}

.progress-size-text-filled {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #0a0f1a;
  white-space: nowrap;
  z-index: 2;
}

.progress-size-small {
  height: 14px;
}

.progress-size-small .progress-size-text,
.progress-size-small .progress-size-text-filled {
  font-size: 9px;
}

.progress-inline {
  display: block;
  position: relative;
  width: 100%;
  height: 18px;
  background: var(--progress-track);
  border-radius: 4px;
  overflow: hidden;
}

.progress-inline-bar {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: linear-gradient(90deg, #22c55e, #4ade80);
  border-radius: 4px;
  transition: width 0.15s ease;
}

.progress-inline-text {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  z-index: 1;
}

.progress-inline-text-filled {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #0a0f1a;
  white-space: nowrap;
  z-index: 2;
}

.progress-inline-small {
  height: 14px;
}

.progress-inline-small .progress-inline-text,
.progress-inline-small .progress-inline-text-filled {
  font-size: 10px;
}

.search-input {
  width: min(360px, 100%);
  background: var(--field);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 7px 9px;
}

.collector-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.collector-metrics {
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.collector-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.collector-tab {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 9px;
  overflow: hidden;
  background: var(--tab-bg);
}

.collector-tab > button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 6px 10px;
  cursor: pointer;
}

.collector-tab.active > button {
  color: var(--text);
}

.collector-tab .close-tab {
  border: 0;
  border-left: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  width: 26px;
  cursor: pointer;
}

.collector-tab .close-tab:hover {
  color: var(--danger);
}

.add-tab {
  min-width: 32px;
  padding-inline: 0;
}

.reconnect-badge {
  color: color-mix(in srgb, var(--danger) 70%, var(--text));
  font-weight: 600;
}

.reconnect-banner {
  border: 1px solid color-mix(in srgb, var(--danger) 45%, var(--border));
  background: color-mix(in srgb, var(--danger) 12%, var(--surface));
  color: var(--text);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 13px;
}

.status-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 5px 14px;
  margin: 0 -14px -10px;
}

.settings-shell {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 8px;
  height: 100%;
  min-height: 0;
}

.settings-toolbar {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.settings-toolbar-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.settings-toolbar-copy span {
  color: var(--muted);
  font-size: 12px;
}

.settings-toolbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.settings-toolbar-actions-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.update-popup {
  position: fixed;
  right: 20px;
  bottom: 56px;
  background: var(--toast-bg);
  border: 1px solid var(--toast-border);
  border-radius: 12px;
  padding: 10px 14px;
  min-width: 260px;
  max-width: 340px;
  box-shadow: 0 16px 30px rgba(0, 0, 0, 0.35);
  z-index: 30;
  font-variant-numeric: tabular-nums;
}

.update-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.update-popup-title {
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
}

.update-popup-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
}

.update-popup-close:hover {
  color: var(--text);
}

.update-popup-message {
  font-size: 12px;
  color: var(--muted);
}

.update-popup-downloading .update-popup-message,
.update-popup-verifying .update-popup-message,
.update-popup-launching .update-popup-message,
.update-popup-starting .update-popup-message {
  color: color-mix(in srgb, var(--accent) 75%, var(--text));
}

.update-popup-done .update-popup-message {
  color: color-mix(in srgb, var(--accent) 65%, var(--text));
}

.update-popup-error .update-popup-message {
  color: color-mix(in srgb, var(--danger) 65%, var(--text));
}

.update-popup-bar-track {
  margin-top: 6px;
  height: 4px;
  background: var(--progress-track);
  border-radius: 2px;
  overflow: hidden;
}

.update-popup-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.settings-body {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 0;
  min-height: 0;
  overflow: hidden;
}

.settings-sidebar {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 8px 4px 0;
  border-right: 1px solid var(--border);
  overflow-y: auto;
}

.settings-sidebar-tab {
  background: none;
  border: none;
  border-left: 3px solid transparent;
  color: var(--muted);
  padding: 8px 12px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  border-radius: 0 8px 8px 0;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.settings-sidebar-tab:hover {
  background: var(--button-bg-hover);
  color: var(--text);
}

.settings-sidebar-tab.active {
  border-left-color: var(--accent);
  color: var(--text);
  background: var(--tab-active);
}

.settings-content {
  overflow-y: auto;
  padding: 4px 0 4px 14px;
}

.settings-section {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.field-grid {
  display: grid;
  gap: 8px;
}

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

.field-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field-grid > div {
  min-width: 0;
}

.toggle-line {
  display: flex;
  align-items: center;
  gap: 7px;
}

.toggle-line input[type="checkbox"] {
  width: 15px;
  height: 15px;
}

.package-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--card) 96%, transparent), color-mix(in srgb, var(--surface) 96%, transparent));
  padding: 8px 12px;
}

.package-card[draggable="true"] {
  cursor: grab;
}

.package-card[draggable="true"]:active {
  cursor: grabbing;
}

.disabled-pkg {
  opacity: 0.72;
}

.pkg-selected {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 30%, transparent);
}

.item-selected {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.package-card header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.package-card h4 {
  margin: 0;
  font-size: 15px;
}

.package-card header span {
  color: var(--muted);
  font-size: 13px;
}

.package-card header .progress-inline-text-filled,
.package-card header .progress-size-text-filled {
  color: #0a0f1a;
}


.pkg-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--button-bg);
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.pkg-toggle:hover {
  border-color: var(--accent);
  color: var(--text);
  background: var(--button-bg-hover);
}

.pkg-name-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
}

.rename-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 1px solid var(--accent);
  border-radius: 4px;
  color: var(--text);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  padding: 1px 4px;
  margin: -2px 0;
  outline: none;
}

.pkg-speed {
  margin-left: 7px;
  color: color-mix(in srgb, var(--accent) 70%, var(--text));
}

.pkg-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.progress {
  margin-top: 8px;
  height: 7px;
  border-radius: 999px;
  background: var(--progress-track);
  overflow: hidden;
  display: flex;
}

.progress-dl {
  height: 100%;
  background: linear-gradient(90deg, #3bc9ff, #22d3ee);
}

.progress-ex {
  height: 100%;
  background: linear-gradient(90deg, #22c55e, #4ade80);
}

/* History Tab */
.history-view {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.history-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.history-card {
  cursor: default;
}

.history-details {
  padding: 10px 12px;
  border-top: 1px solid color-mix(in srgb, var(--border) 40%, transparent);
}

.history-detail-grid {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 4px 16px;
  font-size: 13px;
}

.history-label {
  color: var(--muted);
  font-weight: 600;
}

.history-path {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-actions {
  margin-top: 10px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  margin-top: 10px;
  font-size: 13px;
}

th,
td {
  border-bottom: 1px solid rgba(35, 57, 84, 0.7);
  padding: 7px 8px;
  text-align: left;
}

th {
  color: var(--muted);
  font-weight: 600;
}

td {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.num {
  font-variant-numeric: tabular-nums;
  font-family: "Consolas", "SFMono-Regular", "Menlo", monospace;
}

.item-row {
  display: grid;
  grid-template-columns: 1fr 70px 160px 220px 180px 100px;
  gap: 8px;
  align-items: center;
  margin: 0 -12px;
  padding: 4px 12px;
  font-size: 13px;
  border-top: 1px solid color-mix(in srgb, var(--border) 40%, transparent);
}

.item-row:hover {
  background: color-mix(in srgb, var(--accent) 5%, transparent);
}

.item-row .pkg-col {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 13px;
}

.item-row .pkg-col-name {
  color: var(--text);
  padding-left: 32px;
}

.item-remove {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  padding: 2px 4px;
  border-radius: 4px;
  opacity: 0.6;
}

.item-remove:hover {
  opacity: 1;
  background: rgba(244, 63, 94, 0.1);
}

.statistics-view {
  height: 100%;
  overflow: auto;
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  grid-template-rows: auto 1fr;
  gap: 10px;
  min-height: 0;
}

.stats-overview {
  grid-column: span 2;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 8px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  background: var(--field);
  border-radius: 10px;
  border: 1px solid var(--border);
}

.stat-label {
  color: var(--muted);
  font-size: 12px;
}

.stat-value {
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.stat-value.danger {
  color: var(--danger);
}

.stats-chart-card {
  min-height: 280px;
  display: flex;
  flex-direction: column;
}

.bandwidth-chart-container {
  flex: 1;
  min-height: 200px;
  position: relative;
  margin-top: 8px;
  background: var(--field);
  border-radius: 10px;
  border: 1px solid var(--border);
  overflow: hidden;
}

.bandwidth-chart-container canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.stats-provider-card {
  min-height: 280px;
  display: flex;
  flex-direction: column;
}

.provider-stats {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

.provider-stat-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  background: var(--field);
  border-radius: 10px;
  border: 1px solid var(--border);
}

.provider-name {
  font-weight: 600;
  font-size: 14px;
}

.provider-bars {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.provider-bar {
  height: 8px;
  background: var(--progress-track);
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.3s ease;
}

.bar-fill.completed {
  background: linear-gradient(90deg, #3bc9ff, #22d3ee);
}

.provider-detail {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.empty-provider {
  color: var(--muted);
  text-align: center;
  padding: 20px;
  font-size: 13px;
}

@media (max-width: 1100px) {
  .statistics-view {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
  }

  .stats-overview {
    grid-column: span 1;
  }

  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  }
}

.account-info {
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--field);
}

.account-info-success {
  color: #4ade80;
  border-color: rgba(74, 222, 128, 0.35);
}

.account-info-error {
  color: var(--danger);
  border-color: rgba(244, 63, 94, 0.35);
}

.account-table {
  table-layout: fixed;
  margin-top: 4px;
}

.account-table th:first-child,
.account-table td:first-child {
  width: 22%;
}

.account-col-hoster {
  font-weight: 600;
}

.account-status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
}

.account-status-ok {
  background: rgba(74, 222, 128, 0.15);
  color: #4ade80;
}

.account-status-configured {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
}

.account-status-error {
  background: rgba(244, 63, 94, 0.12);
  color: var(--danger);
}

.account-status-loading {
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  color: var(--accent);
}

.account-status-unknown {
  background: color-mix(in srgb, var(--muted) 15%, transparent);
  color: var(--muted);
}

.account-toolbar {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.account-actions-cell {
  display: flex;
  gap: 6px;
}

.account-actions-cell .btn {
  padding: 4px 8px;
  font-size: 12px;
}

.schedule-row {
  display: grid;
  grid-template-columns: 56px auto 56px auto 92px auto auto auto;
  align-items: center;
  gap: 6px;
}

.schedule-row input[type="number"] {
  text-align: center;
}

.schedule-row .btn {
  padding: 5px 8px;
}

.btn-icon {
  border: 1px solid var(--border);
  background: var(--button-bg);
  color: var(--text);
  border-radius: 7px;
  width: 28px;
  height: 28px;
  cursor: pointer;
}

.btn-icon.danger {
  color: var(--danger);
}

.col-actions {
  width: 8%;
}

.empty {
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 18px;
  background: var(--toast-bg);
  color: var(--text);
  border: 1px solid var(--toast-border);
  border-radius: 12px;
  padding: 10px 14px;
  box-shadow: 0 16px 30px rgba(0, 0, 0, 0.35);
}

.ctx-menu {
  position: fixed;
  z-index: 100;
  min-width: 200px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 0;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.ctx-menu-item {
  display: block;
  width: 100%;
  background: none;
  border: none;
  color: var(--text);
  padding: 7px 14px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  text-align: left;
  transition: background 0.1s;
}

.ctx-menu-item:hover {
  background: var(--button-bg-hover);
}

.ctx-menu-item.ctx-danger {
  color: var(--danger);
}

.ctx-menu-sep {
  height: 1px;
  background: var(--border);
  margin: 4px 8px;
}

.link-popup {
  width: min(720px, 90vw);
  max-height: 70vh;
  display: flex;
  flex-direction: column;
}

.link-popup-list {
  flex: 1;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--field);
  max-height: 50vh;
}

.link-popup-row {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 12px;
  padding: 6px 10px;
  font-size: 12px;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 40%, transparent);
}

.link-popup-row:last-child {
  border-bottom: none;
}

.link-popup-name,
.link-popup-url {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-popup-name {
  color: var(--text);
}

.link-popup-url {
  color: var(--muted);
}

.link-popup-click {
  cursor: pointer;
  border-radius: 4px;
  padding: 1px 3px;
  margin: -1px -3px;
  transition: background 0.1s;
}

.link-popup-click:hover {
  background: var(--button-bg-hover);
}

.drop-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--overlay);
  border: 2px dashed color-mix(in srgb, var(--accent) 72%, transparent);
  color: var(--text);
  font-size: 20px;
  font-weight: 600;
  pointer-events: none;
  backdrop-filter: blur(2px);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 9, 18, 0.68);
  display: grid;
  place-items: center;
  z-index: 20;
  padding: 20px;
}

.modal-card {
  width: min(560px, 100%);
  border: 1px solid var(--border);
  border-radius: 14px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--card) 98%, transparent), color-mix(in srgb, var(--surface) 98%, transparent));
  box-shadow: 0 20px 38px rgba(0, 0, 0, 0.35);
  padding: 16px;
  display: grid;
  gap: 10px;
}

.modal-card h3 {
  margin: 0;
}

.modal-card p {
  margin: 0;
  color: var(--muted);
}

.modal-path {
  font-size: 12px;
  word-break: break-all;
}

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

@media (max-width: 1100px) {
  .control-strip {
    flex-direction: column;
    align-items: flex-start;
  }

  .buttons-right {
    width: 100%;
    margin-left: 0;
    justify-content: flex-end;
  }

  .settings-toolbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .downloads-toolbar .search-input {
    width: 100%;
    margin-left: 0;
  }

  .settings-toolbar-actions {
    width: 100%;
  }

  .settings-toolbar-actions-wrap {
    width: 100%;
    align-items: flex-start;
  }

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

  .settings-body {
    grid-template-columns: 140px 1fr;
  }

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

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

  .schedule-row span {
    display: none;
  }

  .package-card header {
    flex-direction: column;
    align-items: flex-start;
  }

  .pkg-columns,
  .pkg-column-header {
    grid-template-columns: 1fr;
  }

  .pkg-column-header .pkg-col-progress,
  .pkg-column-header .pkg-col-size,
  .pkg-column-header .pkg-col-hoster,
  .pkg-column-header .pkg-col-status,
  .pkg-column-header .pkg-col-speed {
    display: none;
  }

  .pkg-columns .pkg-col-progress,
  .pkg-columns .pkg-col-size,
  .pkg-columns .pkg-col-hoster,
  .pkg-columns .pkg-col-status,
  .pkg-columns .pkg-col-speed {
    display: none;
  }

  .pkg-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .card.wide,
  .settings-actions {
    grid-column: span 1;
  }
}
