:root {
  --bg: #0a111e;
  --bg-elevated: #0d1626;
  --panel: #111c2e;
  --panel-soft: #0e1828;
  --panel-hover: #152238;
  --field: #0a1322;
  --text: #e8eef8;
  --text-strong: #f7f9fc;
  --muted: #8ea0b8;
  --muted-strong: #aebdd0;
  --line: #27364b;
  --line-soft: rgba(87, 107, 137, 0.34);
  --accent: #65a3ff;
  --accent-strong: #3f7fe3;
  --accent-soft: rgba(101, 163, 255, 0.11);
  --accent-border: rgba(101, 163, 255, 0.34);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.1);
  --danger-border: rgba(248, 113, 113, 0.35);
  --ok: #4ade80;
  --ok-soft: rgba(74, 222, 128, 0.09);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.09);
  --radius-xs: 6px;
  --radius-sm: 9px;
  --radius: 12px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
  --shadow-lg: 0 24px 70px rgba(0, 0, 0, 0.42);
}

* { box-sizing: border-box; }
html { color-scheme: dark; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
html, body { width: 100%; min-height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 13.5px;
  line-height: 1.5;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { color: var(--text-strong); line-height: 1.25; }
p { color: var(--muted); }
small { color: var(--muted); }
::selection { background: rgba(101, 163, 255, 0.25); }

/* Base controls */
button {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-soft);
  color: var(--text);
  font-weight: 650;
  font-size: 12.5px;
  white-space: nowrap;
  transition: border-color .14s ease, background-color .14s ease, color .14s ease, transform .14s ease;
}
button:hover { border-color: #425875; background: var(--panel-hover); }
button:active { transform: translateY(1px); }
button:focus-visible { outline: 3px solid var(--accent-soft); outline-offset: 2px; }
button:disabled { opacity: .46; cursor: not-allowed; transform: none; }
button.primary {
  border-color: transparent;
  background: var(--accent-strong);
  color: #fff;
}
button.primary:hover { background: #4f8df1; }
button.danger { border-color: var(--danger-border); background: var(--danger-soft); color: #fecaca; }
button.danger:hover { border-color: rgba(248, 113, 113, .58); background: rgba(248, 113, 113, .15); }
button.small { min-height: 30px; padding: 5px 9px; font-size: 11.5px; }
button.secondary-action { background: transparent; }

label {
  min-width: 0;
  display: grid;
  gap: 6px;
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 650;
}
input, textarea, select {
  width: 100%;
  min-width: 0;
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  outline: none;
  background: var(--field);
  color: var(--text);
  transition: border-color .14s ease, box-shadow .14s ease, background-color .14s ease;
}
textarea { min-height: 74px; resize: vertical; line-height: 1.45; }
input::placeholder, textarea::placeholder { color: #64758d; }
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: #0c1728;
}
input[type="checkbox"] {
  width: 16px;
  min-width: 16px;
  height: 16px;
  min-height: 16px;
  padding: 0;
  margin: 0;
  accent-color: var(--accent-strong);
}
.check-row {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  min-height: 36px;
  padding-top: 20px;
  color: var(--text);
  cursor: pointer;
}
.check-row span { font-size: 12.5px; font-weight: 550; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 12px; }
.hint { margin: 10px 0 0; color: var(--muted); font-size: 11.5px; }
.eyebrow, .page-kicker {
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .09em;
  text-transform: uppercase;
}

/* Application shell */
.app-page {
  min-height: 100vh;
  overflow-x: hidden;
  background:
    linear-gradient(180deg, rgba(101, 163, 255, .025), transparent 260px),
    var(--bg);
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: 64px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(10, 17, 30, .94);
  backdrop-filter: blur(16px);
}
.topbar-inner {
  width: min(100% - 32px, 1660px);
  height: 100%;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}
.brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 11px;
}
.brand-mark {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: grid;
  place-items: center;
  border-radius: 11px;
}
.brand-mark img { width: 38px; height: 38px; display: block; }
.brand-copy { min-width: 0; }
.title-line { display: flex; align-items: center; gap: 8px; }
.title-line h1 {
  margin: 0;
  overflow: hidden;
  font-size: 14px;
  font-weight: 720;
  letter-spacing: -.012em;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.brand-copy p { margin: 1px 0 0; font-size: 10.5px; }
.version-badge, .badge, .status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--muted-strong);
  font-size: 10.5px;
  font-weight: 750;
  white-space: nowrap;
}
.version-badge { min-height: 20px; padding: 2px 6px; color: #9fc4ff; border-color: var(--accent-border); }
.status-pill::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 3px currentColor;
  opacity: .78;
}
.status-pill.ok, .badge.ok { color: #86efac; border-color: rgba(74, 222, 128, .30); background: var(--ok-soft); }
.status-pill.warn, .badge.warn { color: #fde68a; border-color: rgba(251, 191, 36, .30); background: var(--warn-soft); }
.status-pill.danger, .badge.danger { color: #fecaca; border-color: var(--danger-border); background: var(--danger-soft); }
.badge.info { color: #b9d5ff; border-color: var(--accent-border); background: var(--accent-soft); }
.topbar-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.user-chip {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 4px 9px 4px 5px;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: rgba(17, 28, 46, .8);
}
.user-avatar {
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 28px;
  border-radius: 50%;
  background: #263b59;
  color: #dcecff;
  font-size: 11px;
  font-weight: 800;
}
.user-copy { min-width: 0; display: grid; line-height: 1.15; }
.user-copy small { font-size: 8.5px; text-transform: uppercase; letter-spacing: .06em; }
.user-name {
  max-width: 130px;
  overflow: hidden;
  color: var(--text);
  font-size: 10.5px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.icon-button { min-width: 36px; padding: 7px 9px; background: transparent; }
.icon-button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-button span { display: none; }

.workspace {
  width: min(100% - 32px, 1660px);
  margin: 0 auto;
  padding: 18px 0 34px;
  display: grid;
  grid-template-columns: 214px minmax(0, 1fr);
  gap: 18px;
}
.sidebar {
  position: sticky;
  top: 82px;
  align-self: start;
  min-width: 0;
  max-height: calc(100vh - 100px);
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 9px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: rgba(14, 24, 40, .86);
  box-shadow: var(--shadow);
}
.nav-group { display: grid; gap: 3px; }
.nav-label {
  padding: 6px 9px 4px;
  color: #64758d;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.nav-button {
  width: 100%;
  min-height: 38px;
  justify-content: flex-start;
  gap: 9px;
  padding: 8px 10px;
  border-color: transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-align: left;
}
.nav-button svg { width: 17px; height: 17px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
.nav-button:hover { border-color: transparent; background: rgba(255, 255, 255, .035); color: var(--text); }
.nav-button.active { background: var(--accent-soft); color: #bcd7ff; }
.nav-button.active::before {
  content: '';
  width: 2px;
  height: 18px;
  margin-left: -10px;
  border-radius: 999px;
  background: var(--accent);
}
.nav-button.active svg { margin-left: -1px; }
.nav-count {
  min-width: 22px;
  margin-left: auto;
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted-strong);
  font-size: 9.5px;
  text-align: center;
}
.sidebar-footer {
  margin-top: auto;
  padding: 10px;
  border-top: 1px solid var(--line-soft);
}
.sidebar-status-line { display: flex; align-items: center; gap: 7px; margin-bottom: 4px; }
.sidebar-status-line strong { font-size: 10.5px; }
.sidebar-status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.sidebar-footer small { display: block; font-size: 9.5px; line-height: 1.4; }

.content { min-width: 0; }
.view-panel { display: none; min-width: 0; animation: view-enter .16s ease; }
.view-panel.active { display: block; }
@keyframes view-enter { from { opacity: .65; transform: translateY(3px); } to { opacity: 1; transform: none; } }
.page-header {
  min-height: 57px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}
.page-header h2 { margin: 2px 0 3px; font-size: 20px; letter-spacing: -.025em; }
.page-header p { margin: 0; font-size: 12px; }
.header-actions { display: flex; align-items: center; gap: 8px; }

/* Cards and status */
.card {
  min-width: 0;
  padding: 17px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}
.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.section-heading h3 { margin: 0 0 2px; font-size: 13px; }
.section-heading p { margin: 0; font-size: 11.5px; }
.metrics { display: grid; gap: 8px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.metrics-wide { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.metrics > div {
  min-width: 0;
  min-height: 68px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 11px 12px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: var(--panel-soft);
}
.metrics span {
  color: #74869e;
  font-size: 9.5px;
  font-weight: 750;
  letter-spacing: .065em;
  text-transform: uppercase;
}
.metrics strong { margin-top: 8px; overflow-wrap: anywhere; font-size: 13px; font-weight: 680; }
.current-download {
  margin-top: 12px;
  padding: 14px;
  border: 1px solid var(--accent-border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  background: rgba(101, 163, 255, .055);
}
.current-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.current-head strong, .current-head small { display: block; }
.current-head strong { margin: 3px 0; font-size: 14px; }
.progress-details { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; color: var(--muted); font-size: 10.5px; }

.summary-accordion {
  margin-top: 12px;
  overflow: hidden;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: var(--panel-soft);
}
.summary-accordion > summary {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 12px;
  cursor: pointer;
  list-style: none;
}
.summary-accordion > summary::-webkit-details-marker { display: none; }
.summary-accordion > summary span:first-child { display: grid; gap: 1px; }
.summary-accordion > summary strong { font-size: 11.5px; }
.summary-accordion > summary small { font-size: 10px; }
.summary-accordion[open] > summary { border-bottom: 1px solid var(--line-soft); }
.summary, .logs {
  margin: 0;
  padding: 13px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: #08111e;
  color: #b9c8da;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  line-height: 1.55;
}
.summary { max-height: 250px; }
.summary:empty { display: none; }
.logs { min-height: 360px; max-height: calc(100vh - 190px); border-radius: var(--radius-sm); }

/* Queue */
.queue-card { overflow: visible; }
.queue-summary-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 12px; }
.queue-summary-grid > div { min-height: 72px; }
.queue-accordion, .settings-accordion, .library-accordion {
  overflow: hidden;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: var(--panel-soft);
}
.queue-accordion > summary,
.settings-accordion > summary,
.library-accordion > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: background-color .14s ease, border-color .14s ease;
}
.queue-accordion > summary::-webkit-details-marker,
.settings-accordion > summary::-webkit-details-marker,
.library-accordion > summary::-webkit-details-marker { display: none; }
.queue-accordion > summary { min-height: 58px; padding: 11px 13px; }
.queue-accordion > summary:hover,
.settings-accordion > summary:hover,
.library-accordion > summary:hover { background: rgba(255, 255, 255, .025); }
.queue-accordion[open] > summary,
.settings-accordion[open] > summary,
.library-accordion[open] > summary { border-bottom: 1px solid var(--line-soft); background: rgba(101, 163, 255, .035); }
.accordion-copy { min-width: 0; display: grid; gap: 2px; }
.accordion-title { color: var(--text); font-size: 12px; font-weight: 700; }
.accordion-state { display: inline-flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.accordion-chevron {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-right: 1.6px solid #91a9c4;
  border-bottom: 1.6px solid #91a9c4;
  transform: rotate(45deg) translateY(-2px);
  transition: transform .18s ease;
}
.queue-accordion[open] > summary .accordion-chevron,
.settings-accordion[open] > summary .accordion-chevron,
.library-accordion[open] > summary .accordion-chevron,
.summary-accordion[open] > summary .accordion-chevron { transform: rotate(225deg) translate(-2px, -2px); }
.queue-accordion-content { padding: 13px; }
.queue-toolbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 11px; }
.inline-actions, .queue-filters, .section-actions, .form-actions-inline, .library-actions { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.queue-filters { justify-content: flex-start; }
.compact-label { gap: 4px; color: var(--muted); font-size: 9.5px; font-weight: 750; letter-spacing: .05em; text-transform: uppercase; }
.compact-label select { min-width: 150px; color: var(--text); font-size: 11.5px; letter-spacing: normal; text-transform: none; }
.pagination-actions { display: flex; justify-content: center; padding-top: 12px; }
.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--line-soft); border-radius: var(--radius-sm); }
.download-table { width: 100%; min-width: 980px; border-collapse: collapse; background: var(--panel-soft); }
.download-table th, .download-table td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.download-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #111d30;
  color: #8295ad;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .07em;
  text-transform: uppercase;
}
.download-table tbody tr:last-child td { border-bottom: 0; }
.download-table tbody tr:hover { background: rgba(255, 255, 255, .018); }
.download-title { max-width: 350px; }
.download-title strong, .download-title small { display: block; overflow-wrap: anywhere; }
.download-title strong { font-size: 11.5px; }
.download-title small { margin-top: 3px; font-size: 9.5px; }
.row-actions { min-width: 190px; display: flex; flex-wrap: wrap; gap: 5px; }
.error-text { max-width: 340px; margin-top: 5px; color: #fecaca; white-space: pre-wrap; font-size: 9.5px; line-height: 1.35; }
.empty-state { padding: 24px; text-align: center; color: var(--muted); }

/* Settings */
.settings-stack { display: grid; gap: 8px; }
.settings-accordion > summary { min-height: 62px; padding: 11px 13px; }
.settings-index {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  flex: 0 0 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0b1525;
  color: #7990aa;
  font-size: 9px;
  font-weight: 800;
}
.settings-summary-copy { min-width: 0; flex: 1; display: grid; gap: 1px; }
.settings-summary-copy strong { color: var(--text); font-size: 12px; }
.settings-summary-copy small { font-size: 10px; }
.settings-panel { padding: 14px; }
.form-grid { display: grid; gap: 11px 12px; align-items: start; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.wide { grid-column: 1 / -1; }
.form-actions-inline { min-height: 56px; align-items: flex-end; }

/* Libraries */
.libraries-card { padding: 12px; }
.playlist-list { display: grid; gap: 8px; }
.library-accordion { background: var(--panel-soft); }
.library-accordion > summary { min-height: 78px; padding: 12px 13px; }
.library-summary-main { min-width: 0; display: flex; align-items: flex-start; gap: 11px; }
.library-index {
  width: 31px;
  height: 31px;
  display: grid;
  place-items: center;
  flex: 0 0 31px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #0a1423;
  color: #7e93ad;
  font-size: 10px;
  font-weight: 800;
}
.playlist-title { min-width: 0; }
.playlist-title h3 { margin: 0 0 2px; font-size: 12.5px; }
.playlist-title p { margin: 0; font-size: 10.5px; }
.library-stats { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.library-summary-state { display: inline-flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.library-body { padding: 14px; }
.library-actions-panel { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line-soft); display: grid; gap: 10px; }
.library-action-group { display: grid; gap: 6px; }
.library-action-group-title { color: #70839b; font-size: 9px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.library-actions .spacer { flex: 1; }
.library-danger-actions { padding-top: 9px; border-top: 1px solid var(--line-soft); }
.section-actions { justify-content: flex-end; margin-top: 12px; padding: 4px 2px 0; }

/* Dialog and feedback */
.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 80;
  max-width: min(390px, calc(100vw - 32px));
  padding: 11px 13px;
  border: 1px solid var(--accent-border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  background: #101c2e;
  color: var(--text);
  box-shadow: var(--shadow-lg);
  white-space: pre-wrap;
  font-size: 11.5px;
}
.toast.error { border-color: var(--danger-border); border-left-color: var(--danger); color: #fecaca; }
dialog {
  width: min(540px, calc(100vw - 28px));
  margin: auto;
  padding: 0;
  color: var(--text);
  border: 1px solid #3a506d;
  border-radius: 14px;
  background: #101b2d;
  box-shadow: var(--shadow-lg);
}
dialog::backdrop { background: rgba(2, 6, 15, .78); backdrop-filter: blur(5px); }
.modal-card { padding: 21px; }
.modal-card h2 { margin: 4px 0 6px; font-size: 19px; }
.modal-card p { margin-bottom: 0; }
.modal-copy { margin-bottom: 16px; }
.modal-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  float: right;
  margin-left: 14px;
  border: 1px solid var(--danger-border);
  border-radius: 10px;
  background: var(--danger-soft);
  color: #fecaca;
  font-size: 18px;
  font-weight: 900;
}
.modal-warning {
  margin: 13px 0;
  padding: 11px 12px;
  border: 1px solid rgba(251, 191, 36, .26);
  border-radius: 9px;
  background: var(--warn-soft);
  color: #fde68a;
  font-size: 11px;
  line-height: 1.5;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 17px; }
.modal-check { padding-top: 10px; }

/* Native progress */
progress.progress-track,
progress.mini-progress {
  display: block;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #070f1b;
  color: var(--accent);
  appearance: none;
  -webkit-appearance: none;
}
progress.progress-track { width: 100%; height: 8px; margin: 13px 0 8px; }
progress.mini-progress { width: 115px; height: 6px; margin: 5px 0; }
progress.progress-track::-webkit-progress-bar,
progress.mini-progress::-webkit-progress-bar { background: #070f1b; }
progress.progress-track::-webkit-progress-value,
progress.mini-progress::-webkit-progress-value { background: var(--accent); }
progress.progress-track::-moz-progress-bar,
progress.mini-progress::-moz-progress-bar { background: var(--accent); }

/* Dashboard responsive */
@media (max-width: 1220px) {
  .topbar-actions .user-chip { display: none; }
  .queue-summary-grid, .metrics-wide { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 980px) {
  .topbar { height: auto; min-height: 64px; }
  .topbar-inner { padding: 10px 0; align-items: flex-start; }
  .topbar-actions { flex-wrap: wrap; }
  .workspace { grid-template-columns: 1fr; padding-top: 10px; }
  .sidebar {
    position: static;
    max-height: none;
    flex-direction: row;
    align-items: center;
    gap: 4px;
    overflow-x: auto;
    padding: 7px;
  }
  .nav-group { display: flex; gap: 3px; }
  .nav-label, .sidebar-footer { display: none; }
  .nav-button { width: auto; flex: 0 0 auto; }
  .nav-button.active::before { display: none; }
  .nav-button.active svg { margin-left: 0; }
  .form-grid.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .topbar-inner { width: min(100% - 20px, 1660px); flex-direction: column; }
  .brand-copy p { display: none; }
  .topbar-actions { width: 100%; justify-content: flex-start; }
  .status-pill { margin-right: auto; }
  .workspace { width: min(100% - 20px, 1660px); }
  .page-header { align-items: stretch; flex-direction: column; }
  .header-actions { width: 100%; }
  .header-actions button { flex: 1; }
  .metrics, .metrics-wide, .queue-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid.two, .form-grid.three { grid-template-columns: 1fr; }
  .wide { grid-column: auto; }
  .check-row { padding-top: 5px; }
  .form-actions-inline { min-height: 0; }
  .queue-toolbar { align-items: stretch; flex-direction: column; }
  .queue-filters { align-items: stretch; }
  .compact-label { flex: 1 1 160px; }
  .compact-label select { width: 100%; }
  .library-accordion > summary { align-items: flex-start; }
  .library-summary-state { align-items: flex-end; flex-direction: column-reverse; }
}
@media (max-width: 520px) {
  .title-line h1 { max-width: 230px; }
  .topbar-actions button { flex: 1 1 auto; }
  .topbar-actions .status-pill { width: 100%; justify-content: center; margin: 0; }
  .icon-button span { display: inline; }
  .metrics, .metrics-wide, .queue-summary-grid { grid-template-columns: 1fr; }
  .card { padding: 13px; }
  .current-head { flex-direction: column; }
  .settings-accordion > summary { align-items: flex-start; }
  .settings-summary-copy small { display: none; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions button { width: 100%; }
}
/* --------------------------------------------------------------------------
   Tela de login
   -------------------------------------------------------------------------- */

.login-page {
  min-height: 100vh;
  overflow-x: hidden;
  background: #030713;
}

.login-page::selection { background: rgba(53, 184, 255, 0.32); }

.login-ambient {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.login-ambient::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 20%, rgba(14, 165, 233, 0.18), transparent 31%),
    radial-gradient(circle at 88% 78%, rgba(59, 130, 246, 0.13), transparent 30%),
    linear-gradient(128deg, #020617 0%, #061425 52%, #050a15 100%);
}

.orb {
  position: absolute;
  display: block;
  border-radius: 50%;
  filter: blur(2px);
  opacity: 0.72;
  animation: orb-drift 14s ease-in-out infinite alternate;
}
.orb-one {
  top: -9rem;
  left: -7rem;
  width: 31rem;
  height: 31rem;
  background: radial-gradient(circle at 34% 34%, rgba(125, 211, 252, 0.27), rgba(14, 165, 233, 0.035) 67%, transparent 70%);
}
.orb-two {
  right: -12rem;
  bottom: -13rem;
  width: 38rem;
  height: 38rem;
  background: radial-gradient(circle at 45% 42%, rgba(37, 99, 235, 0.23), rgba(37, 99, 235, 0.025) 66%, transparent 70%);
  animation-delay: -4s;
}
.orb-three {
  top: 43%;
  left: 43%;
  width: 15rem;
  height: 15rem;
  background: radial-gradient(circle, rgba(34, 211, 238, 0.11), transparent 70%);
  animation-delay: -8s;
}

.grid-glow {
  position: absolute;
  inset: 0;
  opacity: 0.09;
  background-image:
    linear-gradient(rgba(125, 211, 252, 0.25) 1px, transparent 1px),
    linear-gradient(90deg, rgba(125, 211, 252, 0.25) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(circle at center, black 0%, transparent 72%);
}

@keyframes orb-drift {
  from { transform: translate3d(-1.5%, -1.5%, 0) scale(0.98); }
  to { transform: translate3d(3%, 2%, 0) scale(1.05); }
}

.login-shell {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100% - 44px));
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(390px, 0.78fr);
  align-items: center;
  gap: clamp(44px, 8vw, 110px);
  padding: 54px 0;
}

.login-visual { min-width: 0; padding: 22px 0; }
.login-brand-row { display: flex; align-items: flex-start; gap: 19px; }
.login-logo {
  width: 66px;
  height: 66px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid rgba(125, 211, 252, 0.38);
  border-radius: 21px;
  background: linear-gradient(145deg, rgba(56, 189, 248, 0.96), rgba(14, 116, 184, 0.96));
  color: #00101c;
  font-size: 21px;
  font-weight: 950;
  letter-spacing: -0.06em;
  box-shadow: 0 20px 50px rgba(14, 165, 233, 0.3), inset 0 1px rgba(255, 255, 255, 0.45);
}

.login-visual h1 {
  max-width: 720px;
  margin: 8px 0 0;
  font-size: clamp(38px, 5vw, 68px);
  line-height: 0.99;
  letter-spacing: -0.06em;
  text-wrap: balance;
  background: linear-gradient(100deg, #f8fbff 12%, #bfe9ff 62%, #6dcafa 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.login-lead {
  max-width: 650px;
  margin: 29px 0 0;
  color: #a9bdd5;
  font-size: clamp(15px, 1.7vw, 18px);
  line-height: 1.65;
}

.login-feature-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 34px;
}

.login-feature-grid > div {
  min-height: 150px;
  display: flex;
  flex-direction: column;
  padding: 17px;
  border: 1px solid rgba(84, 117, 153, 0.34);
  border-radius: 17px;
  background: linear-gradient(145deg, rgba(17, 34, 57, 0.62), rgba(6, 15, 28, 0.5));
  backdrop-filter: blur(11px);
}

.feature-icon {
  align-self: flex-start;
  margin-bottom: 23px;
  color: #61c6fa;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.12em;
}
.login-feature-grid strong { margin-bottom: 7px; color: #e7f4ff; font-size: 13px; }
.login-feature-grid small { line-height: 1.45; }
.login-signal {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin-top: 26px;
  color: #83a0bc;
  font-size: 12px;
}
.signal-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 5px rgba(34, 197, 94, 0.1), 0 0 18px rgba(34, 197, 94, 0.54);
}

.login-panel { min-width: 0; }
.login-card {
  position: relative;
  overflow: hidden;
  padding: clamp(25px, 3.5vw, 39px);
  border: 1px solid rgba(108, 160, 199, 0.4);
  border-radius: 26px;
  background:
    linear-gradient(150deg, rgba(17, 35, 58, 0.94), rgba(6, 15, 28, 0.92));
  box-shadow: 0 34px 100px rgba(0, 0, 0, 0.52), inset 0 1px rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(22px);
}

.login-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 12%;
  right: 12%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(125, 211, 252, 0.78), transparent);
}

.login-card-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 29px; }
.login-card-mark {
  width: 39px;
  height: 39px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid rgba(53, 184, 255, 0.32);
  border-radius: 12px;
  background: rgba(53, 184, 255, 0.1);
  color: #80d6ff;
  font-size: 13px;
}
.login-card h2 { margin: 5px 0 6px; font-size: 27px; letter-spacing: -0.035em; }
.login-card-head p { font-size: 13px; }

.login-card form > label {
  display: block;
  margin: 16px 0 8px;
  color: #dbeafe;
  font-size: 12px;
  font-weight: 760;
}

.login-field {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 53px;
  border: 1px solid #2b4260;
  border-radius: 14px;
  background: rgba(2, 8, 18, 0.78);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.login-field:focus-within {
  border-color: var(--accent);
  background: rgba(3, 13, 27, 0.93);
  box-shadow: 0 0 0 4px rgba(53, 184, 255, 0.11), 0 10px 34px rgba(0, 0, 0, 0.2);
}
.login-field input {
  height: 51px;
  padding: 10px 74px 10px 43px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  box-shadow: none;
}
.login-field input:focus { border: 0; box-shadow: none; }
.field-symbol {
  position: absolute;
  left: 15px;
  z-index: 1;
  color: #7291ae;
  font-size: 13px;
  font-weight: 900;
}
.password-toggle {
  position: absolute;
  right: 7px;
  z-index: 2;
  min-height: 36px;
  padding: 6px 9px;
  border: 0;
  background: transparent;
  color: #7dd3fc;
  font-size: 11px;
}
.password-toggle:hover { border: 0; background: rgba(53, 184, 255, 0.08); }

.login-submit {
  width: 100%;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 25px;
  border-radius: 14px;
  font-size: 14px;
  box-shadow: 0 15px 36px rgba(12, 139, 216, 0.24);
}
.button-arrow { font-size: 18px; transition: transform 0.15s ease; }
.login-submit:hover .button-arrow { transform: translateX(4px); }
.login-submit.loading .button-arrow { animation: login-pulse 0.9s ease-in-out infinite alternate; }
@keyframes login-pulse { to { opacity: 0.25; transform: translateX(5px); } }

.login-message,
.setup-required,
.transport-notice,
.caps-warning {
  margin-top: 15px;
  padding: 12px 13px;
  border-radius: 12px;
  font-size: 12px;
  line-height: 1.5;
}
.login-message { border: 1px solid rgba(249, 115, 22, 0.38); background: rgba(249, 115, 22, 0.1); color: #fed7aa; }
.login-message.success { border-color: rgba(34, 197, 94, 0.38); background: rgba(34, 197, 94, 0.09); color: #bbf7d0; }
.caps-warning { margin-top: 8px; padding: 7px 10px; border: 1px solid rgba(245, 158, 11, 0.28); background: rgba(245, 158, 11, 0.08); color: #fde68a; }
.transport-notice { border: 1px solid rgba(245, 158, 11, 0.3); background: rgba(245, 158, 11, 0.075); color: #fde68a; }
.setup-required { border: 1px solid rgba(53, 184, 255, 0.33); background: rgba(53, 184, 255, 0.075); color: #d9f2ff; }
.setup-required strong, .setup-required p, .setup-required small { display: block; }
.setup-required p { margin: 7px 0; }
.setup-required code {
  display: block;
  overflow-x: auto;
  margin: 10px 0;
  padding: 11px;
  border-radius: 9px;
  background: #020711;
  color: #8ad9ff;
  white-space: nowrap;
}
.login-security-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 23px;
  padding-top: 17px;
  border-top: 1px solid rgba(88, 111, 140, 0.28);
  color: #6f89a5;
  font-size: 10px;
  line-height: 1.4;
}


.login-logo img { width: 54px; height: 54px; display: block; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
@media (max-width: 980px) {
  .login-shell { grid-template-columns: 1fr; max-width: 680px; gap: 32px; padding: 38px 0; }
  .login-visual h1 { max-width: 620px; }
  .login-lead { margin-top: 22px; }
  .login-feature-grid { margin-top: 24px; }
}
@media (max-width: 620px) {
  .login-shell { width: min(100% - 24px, 680px); padding: 22px 0; }
  .login-visual { padding: 6px 0; }
  .login-brand-row { gap: 13px; }
  .login-logo { width: 52px; height: 52px; border-radius: 16px; }
  .login-logo img { width: 52px; height: 52px; }
  .login-visual h1 { font-size: clamp(33px, 11vw, 48px); }
  .login-feature-grid { grid-template-columns: 1fr; }
  .login-feature-grid > div { min-height: auto; }
  .feature-icon { margin-bottom: 13px; }
  .login-card { padding: 23px 18px; border-radius: 21px; }
  .login-security-row { flex-direction: column; }
}

/* Final visual refinements */
.sidebar-status-dot.warn { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.sidebar-status-dot.danger { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.login-logo { border: 0; background: transparent; box-shadow: none; }
