: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-move:not(:disabled) {
  color: var(--accent);
}

.ctrl-icon-btn.ctrl-move:hover:not(:disabled) {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.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);
}

.schedule-ctrl {
  position: relative;
  display: flex;
  align-items: center;
}
.schedule-btn.active {
  color: var(--accent);
}
.schedule-active {
  display: flex;
  align-items: center;
  gap: 4px;
}
.schedule-badge {
  font-size: 11px;
  color: var(--accent);
  white-space: nowrap;
  padding: 2px 6px;
  background: rgba(99, 179, 237, 0.12);
  border-radius: 6px;
  cursor: default;
}
.schedule-cancel {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 11px;
  padding: 2px 4px;
  border-radius: 4px;
  line-height: 1;
}
.schedule-cancel:hover { color: var(--danger, #e05555); }
.schedule-picker {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}
.schedule-picker-label {
  font-size: 12px;
  color: var(--muted);
}
.schedule-time-input {
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 3px 6px;
  font-size: 13px;
  width: 90px;
}
.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;
}

.btn.success {
  border-color: rgba(74, 222, 128, 0.7);
  color: #86efac;
}

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

:root[data-theme="light"] .btn.success {
  border-color: color-mix(in srgb, #16a34a 60%, transparent);
  color: #15803d;
}

.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: 0;
}

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

.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 set via inline style from columnOrder */
  gap: 8px;
  padding: 4px 10px;
  background: color-mix(in srgb, var(--card) 58%, transparent);
  border: 0;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 62%, transparent);
  border-radius: 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  user-select: none;
  margin-bottom: 1px;
}

.pkg-column-header .pkg-col-progress,
.pkg-column-header .pkg-col-size,
.pkg-column-header .pkg-col-hoster,
.pkg-column-header .pkg-col-account,
.pkg-column-header .pkg-col-prio,
.pkg-column-header .pkg-col-status,
.pkg-column-header .pkg-col-speed,
.pkg-column-header .pkg-col-added {
  text-align: center;
}

.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 set via inline style from columnOrder */
  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-account,
.pkg-columns .pkg-col-prio,
.pkg-columns .pkg-col-status,
.pkg-columns .pkg-col-speed,
.pkg-columns .pkg-col-added {
  font-size: 13px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
}

.pkg-col-progress {
  font-variant-numeric: tabular-nums;
  padding-right: 12px;
}

.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: 8px 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;
}

.footer-spacer {
  flex: 1;
}

.footer-btn {
  font-size: 11px;
  padding: 2px 8px;
  min-height: 0;
}

.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;
}

.account-settings-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.account-board {
  gap: 12px;
}

.account-board-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

.account-board-summary {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.account-display-toggle {
  width: fit-content;
}

.account-inline-stat {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--border) 85%, transparent);
  background: color-mix(in srgb, var(--button-bg) 86%, transparent);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.account-empty-state {
  display: grid;
  gap: 4px;
  padding: 14px;
  border: 1px dashed color-mix(in srgb, var(--border) 80%, transparent);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
}

.account-empty-state.compact {
  padding: 12px;
}

.account-empty-state strong {
  font-size: 14px;
}

.account-empty-state span {
  color: var(--muted);
  font-size: 13px;
}

.account-table {
  display: grid;
  gap: 8px;
  --account-col-service: 220px;
  --account-col-mode: 96px;
  --account-col-status: 300px;
  --account-col-info: 220px;
  --account-col-secret: 180px;
  --account-col-actions: 560px;
  width: 100%;
}

.account-table-head,
.account-row {
  display: grid;
  grid-template-columns:
    minmax(130px, var(--account-col-service))
    minmax(72px, var(--account-col-mode))
    minmax(140px, var(--account-col-status))
    minmax(160px, var(--account-col-info))
    minmax(180px, var(--account-col-secret))
    minmax(420px, var(--account-col-actions));
  gap: 10px;
  align-items: center;
  width: 100%;
}

.account-table-head {
  padding: 6px 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  align-items: center;
}

.account-table-head > *:nth-child(n+2) {
  border-left: 2px solid color-mix(in srgb, var(--border) 60%, transparent);
  padding-left: 10px;
  padding-right: 10px;
  box-sizing: border-box;
}

.account-header-cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  width: 100%;
}

.account-header-cell > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-resize-handle {
  position: absolute;
  top: -6px;
  right: -7px;
  width: 14px;
  height: calc(100% + 12px);
  border: none;
  background: transparent;
  cursor: col-resize;
  padding: 0;
  z-index: 2;
}

.account-resize-handle:hover::after,
.account-resize-handle:focus-visible::after {
  content: "";
  position: absolute;
  top: 6px;
  bottom: 6px;
  left: 50%;
  width: 2px;
  transform: translateX(-50%);
  border-radius: 999px;
  background: var(--accent);
}

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

.account-cell {
  min-width: 0;
  overflow-wrap: anywhere;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}

.account-row > .account-cell:nth-child(n+2) {
  border-left: 2px solid color-mix(in srgb, var(--border) 60%, transparent);
  padding-left: 10px;
  padding-right: 10px;
  box-sizing: border-box;
}

.account-row > .account-cell.account-row-actions {
  justify-content: center;
}

.account-service-cell {
  display: grid;
  gap: 3px;
  justify-items: center;
  align-content: center;
}

.account-status-cell {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px 8px;
}

.account-info-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

.account-usage-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 0;
}

.account-service-cell strong {
  font-size: 14px;
}

.account-service-cell span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.account-note {
  display: block;
  width: 100%;
  color: var(--muted);
  font-size: 11px;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
}

.account-usage-stats {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.account-usage-stats span + span::before {
  content: "·";
  margin-right: 4px;
}

.account-usage-stats.warning {
  color: color-mix(in srgb, #f59e0b 78%, white 8%);
}

.account-usage-total {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.account-mode-pill,
.account-status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid color-mix(in srgb, var(--border) 85%, transparent);
}

.account-mode-pill {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--text);
}

.account-status-pill {
  width: fit-content;
  background: color-mix(in srgb, #4ade80 14%, transparent);
  border-color: rgba(74, 222, 128, 0.25);
  color: var(--text);
}

.account-status-pill.account-status-disabled {
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  border-color: color-mix(in srgb, var(--danger) 40%, transparent);
  color: color-mix(in srgb, var(--danger) 75%, var(--text));
}

.account-status-pill.account-status-down {
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  border-color: color-mix(in srgb, var(--danger) 40%, transparent);
}

.account-status-pill.account-status-not_tracked,
.account-status-pill.account-status-unknown {
  background: color-mix(in srgb, #f59e0b 12%, transparent);
  border-color: rgba(245, 158, 11, 0.3);
}

.account-secret {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 12px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--field) 96%, transparent), color-mix(in srgb, var(--surface) 92%, transparent));
  border: 1px solid color-mix(in srgb, var(--border) 88%, transparent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  box-sizing: border-box;
  font-family: "JetBrains Mono", "Consolas", monospace;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-row-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  align-content: center;
  text-align: center;
  padding-left: 10px;
  padding-right: 10px;
  min-width: 0;
  overflow: hidden;
}

.account-row-actions .btn {
  padding: 5px 8px;
  font-size: 11px;
  white-space: nowrap;
  min-width: 82px;
  justify-content: center;
}

.account-row-disabled {
  opacity: 0.65;
}

.account-row-disabled .account-row-actions {
  opacity: 1;
}

.account-display-actions {
  display: flex;
  justify-content: flex-end;
  margin: -2px 0 10px;
}


.key-stats-popup {
  width: min(1360px, calc(100vw - 20px));
  max-width: min(1360px, calc(100vw - 20px));
  max-height: calc(100vh - 24px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-card.key-stats-popup {
  width: min(1360px, calc(100vw - 20px));
  max-width: min(1360px, calc(100vw - 20px));
}

.key-stats-popup-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.key-stats-popup-header h3 {
  margin: 0;
  font-size: 14px;
}

.key-stats-summary {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.key-stats-warn {
  color: #f59e0b;
}

.key-stats-popup .account-subkey-table {
  overflow-y: auto;
  max-height: calc(100vh - 140px);
}

.account-subkey-table {
  margin-top: 6px;
  border: 1px solid color-mix(in srgb, var(--border) 72%, transparent);
  border-radius: 8px;
  overflow: hidden;
  font-size: 11px;
}

.account-subkey-table-head,
.account-subkey-table-row {
  display: grid;
  grid-template-columns: 24px minmax(340px, 1fr) 72px 96px 180px 110px 168px;
  align-items: center;
  padding: 3px 8px;
  gap: 10px;
}

.account-subkey-table-head {
  background: color-mix(in srgb, var(--field) 90%, transparent);
  color: var(--muted);
  font-weight: 600;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
  padding: 4px 8px;
}

.account-subkey-table-head .col-usage,
.account-subkey-table-head .col-limit,
.account-subkey-table-head .col-traffic,
.account-subkey-table-head .col-links,
.account-subkey-table-row .col-usage,
.account-subkey-table-row .col-limit,
.account-subkey-table-row .col-traffic,
.account-subkey-table-row .col-links {
  text-align: right;
  justify-self: center;
}

.account-subkey-table-row {
  border-bottom: 1px solid color-mix(in srgb, var(--border) 30%, transparent);
}

.account-subkey-table-row:last-child {
  border-bottom: none;
}

.account-subkey-table-row.warning {
  background: color-mix(in srgb, #f59e0b 8%, transparent);
}

.account-subkey-table-row.disabled {
  background: color-mix(in srgb, var(--field) 45%, transparent);
}

.account-subkey-table-row .col-key {
  font-weight: 600;
  color: var(--muted);
}

.account-subkey-table-row .col-masked {
  font-family: "JetBrains Mono", "Consolas", monospace;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.account-subkey-table-row .col-masked.link-popup-click {
  display: block;
}

.account-subkey-table-row .col-usage {
  text-align: center;
}

.account-subkey-table-row .col-limit {
  text-align: center;
  color: var(--muted);
}

.account-subkey-table-row .col-traffic,
.account-subkey-table-row .col-links {
  text-align: center;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-subkey-table-row .col-action {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.account-subkey-table-row .col-action .btn {
  padding: 1px 6px;
  font-size: 10px;
}

.btn-sm {
  padding: 3px 8px;
  font-size: 11px;
}

.hoster-routing-table {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 10px;
}

.hoster-routing-header {
  display: grid;
  grid-template-columns: 1fr 1fr 40px;
  gap: 10px;
  padding: 8px 12px;
  background: color-mix(in srgb, var(--card) 80%, var(--surface));
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.hoster-routing-row {
  display: grid;
  grid-template-columns: 1fr 1fr 40px;
  gap: 10px;
  padding: 6px 12px;
  align-items: center;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 40%, transparent);
}

.hoster-routing-row:last-child {
  border-bottom: none;
}

.hoster-routing-label {
  font-weight: 500;
  font-size: 0.88rem;
}

.hoster-routing-row select {
  padding: 4px 8px;
  font-size: 0.84rem;
}

.hoster-routing-row .btn-sm {
  padding: 2px 8px;
  font-size: 0.9rem;
  min-width: 28px;
  line-height: 1.4;
  border-radius: 6px;
}

.hoster-routing-add {
  margin-top: 8px;
}

.hoster-routing-add select {
  max-width: 260px;
}

.provider-order-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}

.provider-order-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  cursor: grab;
  transition: border-color 0.12s ease, background 0.12s ease, transform 0.12s ease;
}

.provider-order-row.dragging {
  opacity: 0.6;
  cursor: grabbing;
}

.provider-order-row.drag-target {
  border-color: color-mix(in srgb, var(--accent) 65%, var(--border));
  background: color-mix(in srgb, var(--accent) 10%, rgba(255, 255, 255, 0.04));
  transform: translateY(-1px);
}

.provider-order-num {
  font-size: 0.8rem;
  color: var(--muted);
  min-width: 18px;
  text-align: right;
}

.provider-order-label {
  flex: 1;
  font-size: 0.9rem;
  font-weight: 500;
}

.provider-order-actions {
  display: flex;
  gap: 4px;
}

.provider-order-actions .btn-sm {
  padding: 2px 8px;
  font-size: 0.9rem;
  line-height: 1.4;
}

.account-modal {
  width: min(960px, calc(100vw - 36px));
  max-height: calc(100vh - 36px);
  overflow: hidden;
  gap: 14px;
}

.account-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

.account-modal-header > div:first-child {
  flex: 1;
  min-width: min(320px, 100%);
}

.account-modal-header p {
  margin: 4px 0 0;
  color: var(--muted);
}

.account-dialog-step {
  display: grid;
  gap: 12px;
  align-content: start;
}

.account-dialog-step-label {
  font-size: 14px;
  font-weight: 700;
}

.account-modal-body {
  display: grid;
  gap: 16px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}

.account-picker-search {
  width: 100%;
}

.account-modal label {
  display: block;
  margin-bottom: 6px;
  color: color-mix(in srgb, var(--text) 92%, var(--muted));
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.account-picker-search,
.account-modal input:not([type="checkbox"]):not([type="radio"]),
.account-modal select,
.account-modal textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--border) 90%, transparent);
  background: linear-gradient(180deg, color-mix(in srgb, var(--field) 97%, transparent), color-mix(in srgb, var(--surface) 94%, transparent));
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  font: inherit;
  box-sizing: border-box;
  appearance: none;
  transition: border-color 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.account-picker-search::placeholder,
.account-modal input::placeholder,
.account-modal textarea::placeholder {
  color: color-mix(in srgb, var(--muted) 88%, transparent);
}

.account-picker-search:hover,
.account-modal input:not([type="checkbox"]):not([type="radio"]):hover,
.account-modal select:hover,
.account-modal textarea:hover {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
}

.account-picker-search:focus-visible,
.account-modal input:not([type="checkbox"]):not([type="radio"]):focus-visible,
.account-modal select:focus-visible,
.account-modal textarea:focus-visible {
  outline: none;
  border-color: color-mix(in srgb, var(--accent) 68%, transparent);
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--accent) 28%, transparent),
    0 0 0 4px color-mix(in srgb, var(--accent) 12%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.account-modal input[type="password"] {
  letter-spacing: 0.02em;
}

.account-modal textarea {
  white-space: nowrap;
  overflow-x: auto;
}

.account-picker-table {
  display: grid;
  border: 1px solid color-mix(in srgb, var(--border) 84%, transparent);
  border-radius: 14px;
  overflow: auto;
  max-height: min(330px, 40vh);
  background: linear-gradient(180deg, color-mix(in srgb, var(--card) 96%, transparent), color-mix(in srgb, var(--surface) 94%, transparent));
}

.account-picker-head,
.account-picker-row {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(220px, 0.95fr);
  gap: 14px;
  align-items: start;
}

.account-picker-head {
  padding: 10px 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  position: sticky;
  top: 0;
  z-index: 1;
  background: color-mix(in srgb, var(--card) 98%, transparent);
}

.account-picker-row {
  display: grid;
  width: 100%;
  padding: 12px 14px;
  text-align: left;
  border: none;
  border-top: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.12s ease, transform 0.12s ease, background 0.12s ease;
}

.account-dialog-step + .account-dialog-step {
  padding-top: 4px;
  border-top: 1px solid color-mix(in srgb, var(--border) 75%, transparent);
}

.account-picker-row:hover {
  background: color-mix(in srgb, var(--button-bg-hover) 90%, transparent);
}

.account-picker-row.active {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent);
}

.account-picker-row > div {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.account-picker-row strong {
  font-size: 13px;
}

.account-picker-row span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.account-form-summary {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--border) 82%, transparent);
  background: color-mix(in srgb, var(--field) 84%, transparent);
}

.account-form-summary span {
  color: var(--muted);
  font-size: 13px;
}

.account-modal-fields {
  display: grid;
  gap: 12px;
}

.account-modal-note {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--accent) 26%, transparent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
}

.account-dl-key-limit-list {
  display: grid;
  gap: 8px;
}

.account-dl-key-limit-row {
  display: grid;
  grid-template-columns: minmax(160px, 220px) minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--border) 82%, transparent);
  background: color-mix(in srgb, var(--field) 84%, transparent);
}

.account-dl-key-meta {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.account-dl-key-meta strong {
  font-size: 13px;
}

.account-dl-key-meta span {
  color: var(--muted);
  font-size: 12px;
  font-family: "JetBrains Mono", "Consolas", monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-secret.account-secret-multiline {
  display: grid;
  align-items: start;
  gap: 4px;
  padding: 10px 12px;
  white-space: normal;
}

.account-secret.account-secret-multiline span {
  display: block;
  line-height: 1.35;
}

.account-status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.account-status-grid > div {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--border) 82%, transparent);
  background: color-mix(in srgb, var(--field) 84%, transparent);
}

.account-status-grid strong {
  font-size: 14px;
}

.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: 11px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--card) 96%, transparent), color-mix(in srgb, var(--surface) 96%, transparent));
  padding: 6px 10px;
}

.queue-package-card {
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0;
  box-shadow: none;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 54%, transparent);
}

.queue-package-card.pkg-stripe-a {
  background: color-mix(in srgb, var(--surface) 18%, transparent);
}

.queue-package-card.pkg-stripe-b {
  background: color-mix(in srgb, var(--card) 24%, transparent);
}

.queue-package-card:hover {
  background: color-mix(in srgb, var(--accent) 3%, transparent);
}

.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);
}

.queue-package-card.pkg-selected {
  border-color: transparent;
  box-shadow: inset 2px 0 0 0 var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

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

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

.queue-package-card header {
  min-height: 28px;
  padding: 3px 10px;
}

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

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

.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;
}

.queue-package-card .pkg-toggle {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  font-size: 12px;
  background: transparent;
  border-color: color-mix(in srgb, var(--border) 42%, transparent);
}

.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: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--progress-track);
  overflow: hidden;
  display: flex;
}

.queue-package-card .progress {
  margin-top: 0;
  height: 2px;
  border-radius: 0;
  background: color-mix(in srgb, var(--progress-track) 80%, transparent);
}

.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 set via inline style from columnOrder */
  gap: 8px;
  align-items: center;
  margin: 0 -10px;
  padding: 3px 10px;
  font-size: 12px;
  border-top: 1px solid color-mix(in srgb, var(--border) 40%, transparent);
}

.queue-package-card .item-row {
  margin: 0;
  padding: 2px 10px 2px 10px;
  border-top: 0;
}

.queue-package-card .item-row + .item-row {
  border-top: 1px solid color-mix(in srgb, var(--border) 24%, 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: 12px;
  text-align: center;
}

.item-row .pkg-col-name {
  text-align: left;
}

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

.link-status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  flex-shrink: 0;
  vertical-align: middle;
}
.link-status-dot.online {
  background: #22c55e;
  box-shadow: 0 0 4px #22c55e80;
}
.link-status-dot.offline {
  background: #ef4444;
  box-shadow: 0 0 4px #ef444480;
}
.link-status-dot.checking {
  background: #f59e0b;
  box-shadow: 0 0 4px #f59e0b80;
}

.prio-high {
  color: #f59e0b !important;
  font-weight: 700;
}

.prio-low {
  color: #64748b !important;
}

.pkg-col-dragging {
  opacity: 0.4;
}

.pkg-col-drop-target {
  box-shadow: -2px 0 0 0 var(--accent);
}

.pkg-column-header .pkg-col {
  cursor: grab;
}

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

.ctx-menu-sub {
  position: relative;
}

.ctx-menu-sub > .ctx-menu-item::after {
  content: "";
}

.ctx-menu-sub-items {
  display: none;
  position: absolute;
  left: 100%;
  top: 0;
  min-width: 120px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 0;
  box-shadow: 0 4px 12px rgba(0,0,0,.3);
  z-index: 1001;
}

.ctx-menu-sub:hover .ctx-menu-sub-items {
  display: block;
}

.ctx-menu-active {
  color: var(--accent) !important;
}

.ctx-menu-disabled {
  opacity: 0.4;
  cursor: not-allowed !important;
  pointer-events: none;
}

.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-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

.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-item.stat-item-clickable {
  cursor: pointer;
  transition: border-color 0.15s;
}
.stat-item.stat-item-clickable:hover {
  border-color: var(--danger, #e05555);
}

.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));
  }
}

.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);
  z-index: 50;
}

.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);
  z-index: 200;
}

.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%);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  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-details {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0;
}
.modal-details summary {
  padding: 6px 10px;
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
  user-select: none;
}
.modal-details summary:hover {
  color: var(--text);
}
.modal-details pre {
  margin: 0;
  padding: 8px 10px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 260px;
  overflow-y: auto;
  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;
  }

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

  .account-table-head {
    display: none;
  }

  .account-row {
    grid-template-columns: 1fr;
    min-width: 0;
  }

  .account-row-actions {
    justify-content: flex-start;
  }

  .account-subkey-table-head,
  .account-subkey-table-row {
    grid-template-columns: 24px minmax(0, 1fr) 64px 56px 44px;
    font-size: 10px;
    padding: 2px 6px;
  }

  .account-dl-key-limit-row {
    grid-template-columns: 1fr;
  }

  .account-subkey-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }

  .account-picker-list {
    grid-template-columns: 1fr;
  }

  .account-picker-head,
  .account-picker-row {
    grid-template-columns: 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,
  .item-row {
    grid-template-columns: 1fr !important;
  }

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

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

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

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