:root {
  color-scheme: light;
  --ink: #172026;
  --muted: #65727d;
  --line: #d8e0e6;
  --panel: #ffffff;
  --bg: #f4f7f8;
  --brand: #143642;
  --brand-2: #0f766e;
  --good: #166534;
  --warn: #92400e;
  --bad: #991b1b;
  --soft-good: #dcfce7;
  --soft-warn: #fef3c7;
  --soft-bad: #fee2e2;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, Segoe UI, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

body.login-page {
  min-height: 100vh;
  min-height: 100dvh;
  color: #ffffff;
  background: #071010;
}

button, input, select {
  font: inherit;
}

.login-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(100%, 420px);
  border: 1px solid #253940;
  background: #0d1718;
  padding: 28px;
}

.login-logo {
  width: 132px;
  height: 48px;
  object-fit: contain;
  object-position: left center;
  display: block;
  margin-bottom: 18px;
}

.login-card h1 {
  margin: 4px 0 22px;
  font-size: 32px;
  line-height: 1.1;
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-form .primary-button {
  width: 100%;
  min-height: 46px;
}

.login-message {
  min-height: 22px;
  margin: 16px 0 0;
  color: #fecaca;
}

.app-shell {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  overflow: hidden;
}

.sidebar {
  background: #102b34;
  color: #ffffff;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 0;
  overflow: auto;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-logo {
  width: 112px;
  height: 42px;
  object-fit: contain;
  object-position: left center;
  display: block;
}

.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  background: #e7f7f4;
  color: #102b34;
  font-weight: 800;
}

.brand h1, .brand p, .topbar h2, .topbar p, h3, p {
  margin: 0;
}

.brand h1 {
  font-size: 18px;
}

.brand p, .helper-text, .eyebrow {
  color: var(--muted);
  font-size: 13px;
}

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

.sidebar .brand p, .sidebar .side-panel p {
  color: #c4d4da;
}

.nav {
  display: none;
  gap: 8px;
}

.sidebar.menu-open .nav {
  display: grid;
}

.nav-toggle {
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 8px;
  min-height: 42px;
  padding: 9px 12px;
  cursor: pointer;
  background: transparent;
  color: #d9e7eb;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
}

.nav-toggle-label {
  font-weight: 700;
}

.nav-toggle-icon,
.nav-toggle-icon::before,
.nav-toggle-icon::after {
  width: 20px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  display: block;
}

.nav-toggle-icon {
  position: relative;
  flex: 0 0 auto;
}

.nav-toggle-icon::before,
.nav-toggle-icon::after {
  content: "";
  position: absolute;
  left: 0;
}

.nav-toggle-icon::before {
  top: -6px;
}

.nav-toggle-icon::after {
  top: 6px;
}

.nav-button, .secondary-button, .primary-button, .danger-button {
  border: 1px solid transparent;
  min-height: 38px;
  padding: 8px 12px;
  cursor: pointer;
  background: #ffffff;
  color: var(--ink);
}

.nav-button {
  background: transparent;
  color: #d9e7eb;
  text-align: left;
  border-color: rgba(255,255,255,.14);
}

.nav-button.active, .nav-button:hover {
  background: #e7f7f4;
  color: #102b34;
}

.nav-toggle:hover,
.sidebar.menu-open .nav-toggle {
  background: #111818;
  color: #ffffff;
  border-color: #3a484e;
}

.primary-button {
  background: var(--brand-2);
  color: white;
}

.danger-button {
  background: #b42318;
  color: white;
}

.secondary-button {
  border-color: var(--line);
}

.compact-button {
  min-height: 34px;
  padding: 0 12px;
  white-space: nowrap;
}

button:disabled {
  opacity: .55;
  cursor: not-allowed;
}

.side-panel {
  border: 1px solid rgba(255,255,255,.14);
  padding: 14px;
  display: grid;
  gap: 12px;
}

.side-panel h2 {
  margin: 0;
  font-size: 14px;
}

.mini-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 0;
}

.mini-stats div {
  background: rgba(255,255,255,.08);
  padding: 10px;
}

.mini-stats dt {
  color: #bdd0d7;
  font-size: 12px;
}

.mini-stats dd {
  margin: 4px 0 0;
  font-size: 22px;
  font-weight: 700;
}

.main {
  height: 100vh;
  height: 100dvh;
  min-width: 0;
  min-height: 0;
  padding: 24px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar, .section-header, .card-header, .decision-row, .learn-row, .topbar-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.section-header.compact {
  align-items: center;
}

.section-header.compact h4 {
  margin: 0;
  font-size: 14px;
}

.topbar {
  margin-bottom: 16px;
  flex-wrap: wrap;
  flex: 0 0 auto;
}

.topbar h2 {
  font-size: 28px;
}

.view {
  display: none;
  min-width: 0;
  min-height: 0;
}

.view.active {
  display: block;
}

.view.active:is(#nucleoArtistsView, #whitelistView, #blacklistView, #labelWhitelistView, #playlistsView) {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
}

.view.active:is(#nucleoArtistsView, #whitelistView, #blacklistView, #labelWhitelistView, #playlistsView) .section-header,
.view.active:is(#nucleoArtistsView, #whitelistView, #blacklistView, #labelWhitelistView, #playlistsView) .table-save-note {
  flex: 0 0 auto;
}

.notice {
  position: fixed;
  top: 16px;
  right: 24px;
  left: 324px;
  z-index: 50;
  min-height: 38px;
  margin: 0;
  padding: 10px 12px;
  background: #e8f2f3;
  border-left: 4px solid var(--brand-2);
  color: #173a42;
  box-shadow: 0 14px 44px rgba(0, 0, 0, .28);
  pointer-events: none;
}

.notice:empty {
  display: none;
}

.confirm-dialog {
  width: min(420px, calc(100vw - 32px));
  border: 0;
  padding: 0;
  background: transparent;
}

.confirm-dialog::backdrop {
  background: rgba(8, 18, 22, .56);
}

.confirm-card {
  display: grid;
  gap: 14px;
  padding: 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .28);
}

.confirm-card h3 {
  font-size: 22px;
}

.confirm-card button {
  justify-self: end;
  min-width: 110px;
}

.review-layout {
  display: grid;
  grid-template-columns: minmax(320px, 430px) minmax(0, 1fr);
  gap: 16px;
}

.current-card, .queue-panel, .table-wrap, .audit-grid > article, .log-panel {
  background: var(--panel);
  border: 1px solid var(--line);
}

.current-card, .queue-panel {
  padding: 18px;
}

.current-card {
  display: grid;
  gap: 16px;
  align-content: start;
}

.current-card h3 {
  font-size: 26px;
}

.current-card .decision-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.current-card .learn-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.current-card .decision-row button,
.current-card .learn-row button {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 10px;
  text-align: center;
  white-space: normal;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  background: #e8f2f3;
  color: #143642;
  font-weight: 700;
  font-size: 12px;
}

.artist-meta {
  display: grid;
  gap: 8px;
  margin: 0;
}

.artist-meta div {
  display: grid;
  grid-template-columns: 88px 1fr;
}

.artist-meta dt {
  color: var(--muted);
}

.artist-meta dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.review-classifier {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  background: #f8fbfb;
}

.profile-link {
  color: #0563c1;
  overflow-wrap: anywhere;
}

.track-picker {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  background: #f8fbfb;
}

.track-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.selected-track {
  min-height: 34px;
  padding: 8px 10px;
  border: 1px solid #cfe2dc;
  background: #ffffff;
  color: var(--muted);
}

.track-results {
  display: grid;
  gap: 6px;
  max-height: 220px;
  overflow: auto;
}

.track-result {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid #e0e7eb;
  background: #ffffff;
}

.track-result strong,
.track-result span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.track-result span {
  color: var(--muted);
  font-size: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

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

input, select {
  min-height: 38px;
  border: 1px solid var(--line);
  padding: 8px 10px;
  background: #fff;
}

.queue-panel {
  min-height: 540px;
}

.virtual-list {
  margin-top: 12px;
  max-height: 600px;
  overflow: auto;
  border-top: 1px solid var(--line);
}

.queue-item {
  display: grid;
  grid-template-columns: minmax(120px, .9fr) minmax(160px, 1.2fr) minmax(120px, .9fr) minmax(120px, .9fr);
  gap: 10px;
  padding: 10px 8px;
  border-bottom: 1px solid #edf1f4;
  cursor: pointer;
  width: 100%;
  border-left: 0;
  border-right: 0;
  border-top: 0;
  text-align: left;
  background: transparent;
  color: inherit;
}

.queue-item:hover,
.queue-item.active {
  background: #f7fbfb;
}

.queue-item.active {
  box-shadow: inset 3px 0 0 var(--accent);
}

.queue-item.active strong,
.queue-item.active span {
  color: #ffffff;
}

.queue-item strong, .queue-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-wrap {
  overflow: auto;
  max-width: 100%;
  max-height: calc(100vh - 170px);
}

.view.active:not(#reviewView) .table-wrap {
  flex: 1 1 auto;
  height: 100%;
  min-height: 0;
  max-height: calc(100dvh - 170px);
  scrollbar-gutter: stable;
}

#labelWhitelistView.view.active .table-wrap {
  max-height: calc(100dvh - 150px);
}

.view.active:not(#reviewView) .table-wrap table {
  min-height: 100%;
}

.table-save-note {
  margin: -4px 0 10px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 920px;
  table-layout: fixed;
}

.view:not(#playlistsView) table th:nth-child(1),
.view:not(#playlistsView) table td:nth-child(1) {
  width: 23%;
}

.view:not(#playlistsView) table th:nth-child(2),
.view:not(#playlistsView) table td:nth-child(2) {
  width: 13%;
}

.view:not(#playlistsView) table th:nth-child(3),
.view:not(#playlistsView) table td:nth-child(3) {
  width: 13%;
}

.view:not(#playlistsView) table th:nth-child(4),
.view:not(#playlistsView) table td:nth-child(4) {
  width: 14%;
}

.view:not(#playlistsView) table th:nth-child(5),
.view:not(#playlistsView) table td:nth-child(5) {
  width: 13%;
}

.view:not(#playlistsView) table th:nth-child(6),
.view:not(#playlistsView) table td:nth-child(6) {
  width: 14%;
}

.view:not(#playlistsView) table th:nth-child(7),
.view:not(#playlistsView) table td:nth-child(7) {
  width: 10%;
}

#playlistsView table {
  min-width: 0;
  table-layout: fixed;
}

#playlistsView th,
#playlistsView td {
  padding: 7px 8px;
}

#playlistsView th:nth-child(1),
#playlistsView td:nth-child(1) {
  width: 22%;
}

#playlistsView th:nth-child(2),
#playlistsView td:nth-child(2) {
  width: 18%;
}

#playlistsView th:nth-child(3),
#playlistsView td:nth-child(3) {
  width: 42%;
}

#playlistsView th:nth-child(4),
#playlistsView td:nth-child(4) {
  width: 18%;
}

#playlistsView .table-wrap {
  overflow-x: hidden;
}

.playlist-genre-cell,
.playlist-block-cell {
  line-height: 1.2;
}

.playlist-map-select {
  min-width: 0;
}

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

th, td {
  padding: 9px 10px;
  border-bottom: 1px solid #e9eef2;
  text-align: left;
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
}

th {
  position: sticky;
  top: 0;
  background: var(--brand);
  color: #fff;
  z-index: 1;
}

td a {
  color: #0563c1;
  overflow-wrap: normal;
}

td select {
  width: 100%;
}

.table-name-cell {
  font-weight: 800;
  white-space: nowrap;
}

.table-meta-cell,
.table-id-cell,
.table-link-cell,
.table-status-cell,
.table-actions-cell {
  white-space: nowrap;
}

.table-id-cell {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.table-link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  max-width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--line);
  color: #7aa7ff;
  text-decoration: none;
  font-weight: 800;
}

.table-link-button:hover {
  border-color: #7aa7ff;
}

.table-actions-cell .compact-button {
  min-width: 92px;
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  text-align: center;
}

.table-name-cell {
  max-width: 260px;
  overflow-wrap: anywhere;
  word-break: normal;
}

.audit-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.audit-grid article {
  padding: 14px;
}

.audit-grid h4 {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
}

.audit-grid strong {
  font-size: 28px;
}

.log-panel {
  min-height: 320px;
  max-height: 480px;
  overflow: auto;
  padding: 14px;
  white-space: pre-wrap;
}

dialog {
  border: none;
  padding: 0;
}

.dialog-card {
  width: min(520px, 92vw);
  background: #fff;
  border: 1px solid var(--line);
  padding: 18px;
  display: grid;
  gap: 12px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 0;
  margin: 6px 0 0;
}

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .review-layout, .audit-grid {
    grid-template-columns: 1fr;
  }

  .topbar, .section-header, .topbar-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .notice {
    left: 16px;
    right: 16px;
    top: 16px;
  }
}

/* Dark operational theme aligned with the previous Nucleo interface. */
:root {
  color-scheme: dark;
  --ink: #f5f7f8;
  --muted: #93a1aa;
  --line: #243036;
  --panel: #0d1111;
  --bg: #050707;
  --brand: #0a0d0d;
  --brand-2: #6ee7c8;
  --soft-good: #123626;
  --soft-warn: #3b2b12;
  --soft-bad: #3a1518;
}

body,
.sidebar {
  background: var(--bg);
}

.brand-mark,
.primary-button {
  background: var(--brand-2);
  color: #06100d;
}

.nav-button,
.secondary-button,
.danger-button,
input,
select {
  border-color: var(--line);
  border-radius: 8px;
  background: #070a0a;
  color: var(--ink);
}

.nav-button {
  color: #d9e7eb;
}

.nav-button.active,
.nav-button:hover {
  background: #111818;
  color: #ffffff;
  border-color: #3a484e;
}

.danger-button {
  background: #ff6b6b;
  color: #ffffff;
}

.side-panel,
.current-card,
.queue-panel,
.table-wrap,
.audit-grid > article,
.log-panel,
.track-picker,
.review-classifier,
.dialog-card {
  background: var(--panel);
  border-color: var(--line);
}

.notice {
  background: #0d1514;
  color: #d8fff4;
}

.mini-stats div,
.track-result,
.selected-track {
  background: #070a0a;
}

.status-pill {
  background: #111818;
  color: var(--brand-2);
  border: 1px solid #2b403b;
}

th {
  background: #0a0d0d;
}

td,
th {
  border-bottom-color: #1b2428;
}

.queue-item {
  border-bottom-color: #1b2428;
}

.queue-item:hover {
  background: #101616;
}

.queue-item.active,
.queue-item.active:hover {
  background: #1c3434;
  color: #ffffff;
  box-shadow: inset 4px 0 0 #7aa7ff;
}

td a,
.profile-link {
  color: #7aa7ff;
}

.weekly-report {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
}

.weekly-report h4 {
  margin: 0;
}

.weekly-report ul {
  margin: 0;
  padding-left: 18px;
}

/* Desktop keeps the fixed sidebar, but the work area must scroll. */
@media (min-width: 921px) {
  .main {
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-gutter: stable;
  }

  #reviewView.view.active {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
  }

  .review-layout {
    align-items: stretch;
    flex: 1 1 auto;
    width: 100%;
    min-height: 0;
    padding-bottom: 0;
  }

  .current-card {
    align-self: start;
  }

  .queue-panel {
    align-self: stretch;
    display: flex;
    flex-direction: column;
    min-height: 0;
    max-height: none;
    overflow: hidden;
  }

  .queue-panel .section-header {
    flex: 0 0 auto;
  }

  .virtual-list {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
  }
}

/* Mobile layout only: keep the operational logic intact and prevent lateral overflow. */
@media (max-width: 920px) {
  html,
  body {
    width: 100%;
    min-height: 100%;
    overflow-x: hidden;
  }

  .app-shell {
    display: block;
    width: 100%;
    min-height: 100dvh;
    height: auto;
    overflow: visible;
  }

  .sidebar {
    width: 100%;
    min-height: 0;
    padding: 16px;
    overflow: visible;
  }

  .brand {
    justify-content: center;
    text-align: center;
  }

  .brand-logo {
    width: 76px;
    height: 38px;
    object-position: center;
  }

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

  .nav-button {
    text-align: center;
    min-width: 0;
  }

  .side-panel {
    display: none;
  }

  .main {
    width: 100%;
    min-height: 0;
    height: auto;
    padding: 16px;
    overflow: visible;
  }

  .topbar,
  .section-header {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    align-items: stretch;
  }

  .topbar-actions,
  .playlist-actions,
  .form-row {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
    gap: 10px;
  }

  .topbar-actions button,
  .playlist-actions button,
  .form-row button,
  .form-row input,
  .form-row select {
    width: 100%;
    min-width: 0;
  }

  .notice {
    left: 12px;
    right: 12px;
    top: 12px;
    width: auto;
  }

  #reviewView.view.active {
    display: block;
  }

  .review-layout {
    grid-template-columns: 1fr;
    gap: 16px;
    width: 100%;
    min-height: 0;
    height: auto;
    overflow: visible;
  }

  .current-card,
  .queue-panel,
  .track-picker,
  .review-classifier {
    width: 100%;
    min-width: 0;
    overflow: hidden;
  }

  .current-card {
    padding: 16px;
  }

  .current-card h3 {
    font-size: clamp(28px, 8vw, 40px);
    line-height: 1.08;
    overflow-wrap: anywhere;
  }

  .artist-meta div {
    grid-template-columns: 108px minmax(0, 1fr);
    gap: 8px;
  }

  .review-classifier,
  .track-picker {
    padding: 12px;
  }

  .review-classifier select,
  .review-classifier input,
  .track-picker select,
  .track-picker input {
    width: 100%;
    min-width: 0;
  }

  .track-search,
  .track-result,
  .current-card .decision-row,
  .current-card .learn-row {
    grid-template-columns: 1fr;
  }

  .current-card .decision-row button,
  .current-card .learn-row button {
    min-height: 48px;
  }

  .queue-panel {
    min-height: 0;
  }

  .virtual-list {
    max-height: 56dvh;
    overflow: auto;
  }

  .queue-item {
    grid-template-columns: 1fr;
    gap: 4px;
    padding: 12px 10px;
  }

  .queue-item strong,
  .queue-item span,
  .track-result strong,
  .track-result span {
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .view.active:not(#reviewView) .table-wrap,
  #labelWhitelistView.view.active .table-wrap,
  .table-wrap {
    width: 100%;
    max-height: none;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  table {
    min-width: 880px;
  }
}

@media (max-width: 560px) {
  .sidebar,
  .main {
    padding-left: 14px;
    padding-right: 14px;
  }

  .brand {
    gap: 10px;
  }

  .brand h1 {
    font-size: 18px;
  }

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

  .topbar h2 {
    font-size: clamp(34px, 10vw, 44px);
    line-height: 1;
  }

  .artist-meta div {
    grid-template-columns: 92px minmax(0, 1fr);
  }

  .confirm-card {
    padding: 18px;
  }
}
