/*
  Cadenza Rights: Music royalty analytics dashboard stylesheet.
  Warm analog mastering console and record-label ledger palette:
  walnut charcoal, warm cream typography, VU-meter terracotta orange, and studio teal.
*/

:root {
  /* Color tokens */
  --bg-console: #181512;
  --bg-deck: #201b17;
  --bg-well: #120f0d;
  --bg-hover: #29231e;
  --bg-active: #312922;

  --ink-primary: #f2eadc;
  --ink-secondary: #bfb4a4;
  --ink-muted: #9e9383;

  --accent-orange: #e07a38;
  --accent-orange-dim: rgba(224, 122, 56, 0.14);
  --accent-teal: #5ca4a9;
  --accent-teal-dim: rgba(92, 164, 169, 0.14);

  --border-hairline: rgba(242, 234, 220, 0.10);
  --border-strong: rgba(242, 234, 220, 0.20);
  --focus-ring: #e07a38;

  /* Typography */
  --font-display: "Bricolage Grotesque", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "DM Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Spacing scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;

  /* Radii */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-pill: 999px;

  /* Layout */
  --rail-width: 92px;
  --topbar-height: 68px;
  --drawer-width: 440px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
  scroll-behavior: smooth;
  background-color: var(--bg-console);
  color: var(--ink-primary);
  accent-color: var(--accent-orange);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-display);
  font-size: 15px;
  line-height: 1.5;
  background-color: var(--bg-console);
  color: var(--ink-primary);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}

::selection {
  background-color: var(--accent-orange);
  color: var(--bg-well);
}

/* Custom console scrollbar */
::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

::-webkit-scrollbar-track {
  background: var(--bg-well);
}

::-webkit-scrollbar-thumb {
  background: #3a3129;
  border-radius: var(--radius-pill);
  border: 2px solid var(--bg-well);
}

::-webkit-scrollbar-thumb:hover {
  background: #52463b;
}

:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: var(--space-3);
  z-index: 100;
  padding: var(--space-2) var(--space-4);
  background: var(--accent-orange);
  color: var(--bg-well);
  font-weight: 600;
  border-radius: var(--radius-sm);
  text-decoration: none;
}

.skip-link:focus {
  left: var(--space-3);
}

/* Shell Layout */
.console-shell {
  display: grid;
  grid-template-columns: var(--rail-width) minmax(0, 1fr);
  min-height: 100vh;
}

/* Slim Console Rail */
.console-rail {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-2);
  background: var(--bg-well);
  border-right: 1px solid var(--border-hairline);
  z-index: 30;
}

.brand-mark {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  color: var(--ink-primary);
  text-decoration: none;
  padding: var(--space-1);
  border-radius: var(--radius-md);
}

.rail-brand-text {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.rail-nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  width: 100%;
  align-items: center;
}

.rail-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 78px;
  min-height: 50px;
  padding: 6px 4px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--ink-secondary);
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 11px;
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease;
}

.rail-btn:hover {
  background: var(--bg-hover);
  color: var(--ink-primary);
}

.rail-btn.is-active {
  background: var(--bg-deck);
  color: var(--accent-orange);
  border-color: var(--border-strong);
}

.rail-label {
  line-height: 1;
}

.console-lamp {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: var(--space-2);
}

.lamp-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-teal);
  border: 1px solid var(--bg-deck);
}

.lamp-code {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-muted);
}

/* Main Console Area */
.console-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Top Filter Bar */
.console-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  min-height: var(--topbar-height);
  padding: var(--space-3) var(--space-6);
  background: rgba(24, 21, 18, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-hairline);
}

.topbar-identity {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.console-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.console-cycle {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-muted);
}

.topbar-controls {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

/* Period Segmented Switch */
.period-switch {
  display: inline-flex;
  padding: 3px;
  background: var(--bg-well);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-md);
}

.period-btn {
  min-height: 36px;
  padding: 0 var(--space-3);
  border: none;
  border-radius: 5px;
  background: transparent;
  color: var(--ink-secondary);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease;
}

.period-btn:hover {
  color: var(--ink-primary);
}

.period-btn.is-active {
  background: var(--accent-orange);
  color: var(--bg-well);
}

/* Select & Inputs */
.platform-select-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.platform-select-wrap.full-width {
  width: 100%;
}

.console-select {
  appearance: none;
  min-height: 42px;
  padding: 0 34px 0 var(--space-3);
  background: var(--bg-deck);
  color: var(--ink-primary);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: 12px;
  cursor: pointer;
  transition: border-color 140ms ease, background-color 140ms ease;
}

.console-select.full-width {
  width: 100%;
}

.console-select:hover {
  border-color: var(--border-strong);
  background: var(--bg-hover);
}

.select-chevron {
  position: absolute;
  right: 11px;
  pointer-events: none;
  color: var(--ink-muted);
}

/* Buttons */
.btn-primary,
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 42px;
  padding: 0 var(--space-4);
  border-radius: var(--radius-md);
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}

.btn-primary {
  background: var(--accent-orange);
  color: var(--bg-well);
  border: 1px solid var(--accent-orange);
}

.btn-primary:hover {
  background: #eb8947;
  border-color: #eb8947;
}

.btn-secondary {
  background: var(--bg-deck);
  color: var(--ink-primary);
  border: 1px solid var(--border-strong);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--ink-muted);
}

.text-action {
  background: transparent;
  border: none;
  color: var(--accent-orange);
  font-family: var(--font-mono);
  font-size: 12px;
  cursor: pointer;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
}

.text-action:hover {
  background: var(--accent-orange-dim);
}

/* Ledger Canvas */
.ledger-canvas {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  padding: var(--space-6);
  max-width: 1480px;
  width: 100%;
}

/* Anchor scroll offset below sticky topbar */
#overview,
#territories,
#catalog {
  scroll-margin-top: calc(var(--topbar-height) + var(--space-5));
}

/* Unified Console Meter Strip */
.meter-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--bg-deck);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.meter-cell {
  padding: var(--space-5);
  border-right: 1px solid var(--border-hairline);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.meter-cell:last-child {
  border-right: none;
}

.meter-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.meter-label {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.meter-delta {
  font-family: var(--font-mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-secondary);
}

.meter-delta.is-up {
  color: var(--accent-orange);
}

.meter-delta.is-teal {
  color: var(--accent-teal);
}

.meter-value {
  font-family: var(--font-mono);
  font-size: clamp(22px, 2.2vw, 28px);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  color: var(--ink-primary);
  line-height: 1.15;
}

.meter-sub {
  font-size: 12px;
  color: var(--ink-secondary);
}

/* Analog VU Bar */
.vu-bar {
  position: relative;
  height: 7px;
  width: 100%;
  margin-top: 4px;
  background: var(--bg-well);
  border-radius: var(--radius-pill);
  overflow: hidden;
  border: 1px solid var(--border-hairline);
}

.vu-fill {
  display: block;
  height: 100%;
  background: var(--accent-orange);
  border-radius: var(--radius-pill);
  transition: width 260ms ease;
}

.vu-fill.is-teal {
  background: var(--accent-teal);
}

/* Console Panels */
.console-panel {
  background: var(--bg-deck);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-bottom: var(--space-5);
}

.panel-title-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.panel-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--ink-primary);
}

.panel-note {
  margin: 0;
  font-size: 13px;
  color: var(--ink-secondary);
}

/* Series Toggles */
.series-toggles {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  background: var(--bg-well);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-md);
}

.series-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 var(--space-3);
  border: none;
  border-radius: 5px;
  background: transparent;
  color: var(--ink-secondary);
  font-family: var(--font-mono);
  font-size: 12px;
  cursor: pointer;
}

.series-btn.is-active {
  background: var(--bg-active);
  color: var(--ink-primary);
}

.swatch {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

.swatch-orange {
  background: var(--accent-orange);
}

.swatch-teal {
  background: var(--accent-teal);
}

.swatch-cream {
  background: var(--ink-secondary);
}

/* Live Scrub Readout Strip */
.scrub-readout {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(180px, 1.4fr);
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
  background: var(--bg-well);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-md);
}

.readout-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.readout-key {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.readout-val {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--ink-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.readout-val.is-orange {
  color: var(--accent-orange);
}

.readout-val.is-teal {
  color: var(--accent-teal);
}

/* Anchor SVG Chart */
.chart-stage {
  position: relative;
  width: 100%;
}

.revenue-svg {
  display: block;
  width: 100%;
  height: auto;
  cursor: crosshair;
  touch-action: pan-y;
}

.chart-grid line {
  stroke: rgba(242, 234, 220, 0.08);
  stroke-width: 1;
}

.chart-axis-text text {
  fill: var(--ink-muted);
  font-family: var(--font-mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.series-royalty-area,
.series-royalty-line,
.series-stream-line {
  transition: opacity 180ms ease;
}

.revenue-svg[data-series="royalties"] .series-stream-line,
.revenue-svg[data-series="royalties"] #scrub-dot-stream {
  opacity: 0.1;
}

.revenue-svg[data-series="streams"] .series-royalty-line,
.revenue-svg[data-series="streams"] .series-royalty-area,
.revenue-svg[data-series="streams"] #scrub-dot-royalty {
  opacity: 0.1;
}

/* Split Ledger Grid (Territories + Rights Mix) */
.ledger-split-grid {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  gap: var(--space-6);
}

.territory-ledger {
  display: flex;
  flex-direction: column;
}

.territory-row {
  display: grid;
  grid-template-columns: 44px minmax(110px, 145px) minmax(80px, 1fr) 96px 56px;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  min-height: 44px;
  padding: var(--space-2) var(--space-3);
  border: none;
  border-bottom: 1px solid var(--border-hairline);
  background: transparent;
  color: var(--ink-primary);
  text-align: left;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background-color 140ms ease;
}

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

.territory-row:hover {
  background: var(--bg-hover);
}

.territory-row.is-selected {
  background: var(--accent-orange-dim);
}

.territory-code {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-muted);
}

.territory-name {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.territory-bar-track {
  display: block;
  height: 8px;
  background: var(--bg-well);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.territory-bar-fill {
  display: block;
  height: 100%;
  background: var(--accent-orange);
  border-radius: var(--radius-pill);
  transition: width 260ms ease;
}

.territory-bar-fill.is-teal {
  background: var(--accent-teal);
}

.territory-amount,
.territory-share {
  font-family: var(--font-mono);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.territory-share {
  color: var(--ink-muted);
}

/* Rights Mix */
.rights-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.rights-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.rights-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-2);
}

.rights-name {
  font-size: 14px;
  font-weight: 500;
}

.rights-val {
  font-family: var(--font-mono);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-primary);
}

.rights-foot {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-muted);
}

.panel-footer-action {
  margin-top: var(--space-6);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-hairline);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.split-callout-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13px;
}

.split-callout-copy span {
  color: var(--ink-secondary);
}

/* Catalog Table */
.catalog-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-bottom: var(--space-5);
}

.catalog-controls {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.search-field {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 12px;
  color: var(--ink-muted);
  pointer-events: none;
}

.console-input {
  min-height: 42px;
  padding: 0 var(--space-3);
  background: var(--bg-well);
  color: var(--ink-primary);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-md);
  font-family: var(--font-display);
  font-size: 14px;
  transition: border-color 140ms ease;
}

.search-field .console-input {
  padding-left: 36px;
  width: 240px;
}

.console-input:hover {
  border-color: var(--border-strong);
}

.console-input:focus {
  border-color: var(--accent-orange);
  outline: none;
}

.mono-input {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  width: 100%;
}

.format-pills {
  display: inline-flex;
  gap: 4px;
}

.pill-btn {
  min-height: 38px;
  padding: 0 var(--space-3);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-md);
  background: var(--bg-well);
  color: var(--ink-secondary);
  font-family: var(--font-mono);
  font-size: 12px;
  cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease, border-color 140ms ease;
}

.pill-btn:hover {
  color: var(--ink-primary);
  border-color: var(--border-strong);
}

.pill-btn.is-active {
  background: var(--accent-orange-dim);
  color: var(--ink-primary);
  border-color: var(--accent-orange);
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.ledger-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
}

.ledger-table th {
  text-align: left;
  padding: 0 var(--space-2) var(--space-3) 0;
  border-bottom: 1px solid var(--border-strong);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
}

.ledger-table th:last-child,
.ledger-table td:last-child {
  padding-right: 0;
}

.ledger-table th.num-col,
.ledger-table td.num-col {
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.ledger-table th.action-col,
.ledger-table td.action-col {
  text-align: right;
  width: 110px;
}

.sort-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: transparent;
  border: none;
  padding: 6px 0;
  color: inherit;
  font: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  cursor: pointer;
}

.sort-btn:hover,
.sort-btn.is-sorted {
  color: var(--ink-primary);
}

.sort-btn.is-sorted::after {
  content: "";
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--accent-orange);
}

.sort-btn.is-sorted.is-asc::after {
  transform: rotate(180deg);
}

.ledger-table td {
  padding: var(--space-3) var(--space-2) var(--space-3) 0;
  border-bottom: 1px solid var(--border-hairline);
  vertical-align: middle;
  font-size: 14px;
}

.ledger-table tbody tr:hover {
  background: var(--bg-hover);
}

.ledger-table td.is-strong {
  color: var(--accent-orange);
  font-weight: 500;
}

.release-cell {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.cat-code {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-muted);
  padding: 3px 6px;
  background: var(--bg-well);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.release-title {
  font-weight: 600;
  color: var(--ink-primary);
}

.release-meta {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-muted);
}

.format-tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-well);
  color: var(--ink-secondary);
  border: 1px solid var(--border-hairline);
}

.row-action-btn {
  min-height: 36px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-well);
  color: var(--ink-primary);
  font-family: var(--font-mono);
  font-size: 12px;
  cursor: pointer;
  transition: border-color 140ms ease, color 140ms ease, background-color 140ms ease;
}

.row-action-btn:hover {
  border-color: var(--accent-orange);
  color: var(--ink-primary);
  background: var(--accent-orange-dim);
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: var(--space-2);
  padding: var(--space-8) var(--space-4);
  color: var(--ink-secondary);
}

.empty-state[hidden] {
  display: none;
}

.empty-title {
  margin: var(--space-2) 0 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--ink-primary);
}

.empty-copy {
  margin: 0 0 var(--space-3);
  font-size: 13px;
  color: var(--ink-muted);
}

/* Split Simulator Drawer */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(12, 10, 8, 0.72);
  backdrop-filter: blur(3px);
  z-index: 50;
}

.drawer-backdrop[hidden],
.split-drawer[hidden] {
  display: none;
}

.split-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(var(--drawer-width), 100vw);
  background: var(--bg-deck);
  border-left: 1px solid var(--border-strong);
  z-index: 60;
  display: flex;
  flex-direction: column;
  box-shadow: -16px 0 40px rgba(0, 0, 0, 0.45);
}

.drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border-hairline);
}

.icon-close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-hairline);
  background: var(--bg-well);
  color: var(--ink-secondary);
  cursor: pointer;
}

.icon-close-btn:hover {
  color: var(--ink-primary);
  border-color: var(--border-strong);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-5) var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
}

.field-label {
  font-family: var(--font-mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 13px;
  color: var(--ink-secondary);
  cursor: pointer;
}

.toggle-row input {
  width: 16px;
  height: 16px;
}

.preset-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.split-meter-block {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.split-bar {
  display: flex;
  height: 12px;
  border-radius: var(--radius-pill);
  overflow: hidden;
  background: var(--bg-well);
  border: 1px solid var(--border-hairline);
}

.split-seg {
  display: block;
  height: 100%;
  transition: width 160ms ease;
}

.seg-artist {
  background: var(--accent-orange);
}

.seg-producer {
  background: var(--accent-teal);
}

.seg-publisher {
  background: var(--ink-secondary);
}

.split-legend {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-2);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-secondary);
}

.split-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.split-legend strong {
  color: var(--ink-primary);
  font-variant-numeric: tabular-nums;
}

.slider-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.slider-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.slider-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}

.slider-pct {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--ink-primary);
}

.slider-item input[type="range"] {
  width: 100%;
  height: 6px;
  cursor: pointer;
}

.payout-ledger {
  background: var(--bg-well);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.payout-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-hairline);
}

.payout-row:last-child {
  padding-bottom: 0;
  border-bottom: none;
}

.payout-role {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-primary);
}

.payout-note {
  display: block;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-muted);
}

.payout-amount {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.payout-amount.is-orange {
  color: var(--accent-orange);
}

.payout-amount.is-teal {
  color: var(--accent-teal);
}

.payout-total .payout-amount {
  font-size: 16px;
  color: var(--ink-primary);
}

.drawer-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-hairline);
}

/* Toast Region */
.toast-region {
  position: fixed;
  right: var(--space-5);
  bottom: var(--space-5);
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-width: min(380px, calc(100vw - 32px));
}

.console-toast {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-well);
  color: var(--ink-primary);
  border: 1px solid var(--accent-orange);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
  font-size: 13px;
}

.toast-title {
  display: block;
  font-weight: 600;
  color: var(--accent-orange);
  margin-bottom: 2px;
}

.toast-detail {
  display: block;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-secondary);
}

.toast-dismiss {
  background: transparent;
  border: none;
  color: var(--ink-muted);
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.toast-dismiss:hover {
  color: var(--ink-primary);
}

/* Responsive Breakpoints */
@media (max-width: 1120px) {
  .meter-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .meter-cell:nth-child(2) {
    border-right: none;
  }

  .meter-cell:nth-child(1),
  .meter-cell:nth-child(2) {
    border-bottom: 1px solid var(--border-hairline);
  }

  .ledger-split-grid {
    grid-template-columns: 1fr;
  }

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

  .readout-track {
    grid-column: 1 / -1;
  }
}

@media (max-width: 768px) {
  .console-shell {
    grid-template-columns: 1fr;
    padding-bottom: 68px;
  }

  .console-rail {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    flex-direction: row;
    justify-content: center;
    padding: 4px var(--space-3);
    border-right: none;
    border-top: 1px solid var(--border-strong);
  }

  .rail-brand,
  .rail-footer {
    display: none;
  }

  .rail-nav {
    flex-direction: row;
    justify-content: space-around;
    width: 100%;
  }

  .rail-btn {
    width: auto;
    min-width: 64px;
    min-height: 48px;
    padding: 6px 10px;
  }

  #overview,
  #territories,
  #catalog {
    scroll-margin-top: var(--space-4);
  }

  .console-topbar {
    position: static;
    padding: var(--space-3) var(--space-4);
  }

  .topbar-controls {
    width: 100%;
  }

  .topbar-controls .btn-primary,
  .topbar-controls .btn-secondary {
    flex: 1;
  }

  .period-switch {
    flex: 1;
  }

  .period-btn {
    flex: 1;
    min-height: 44px;
  }

  .console-select,
  .btn-primary,
  .btn-secondary,
  .pill-btn,
  .row-action-btn {
    min-height: 44px;
  }

  .ledger-canvas {
    padding: var(--space-4);
    gap: var(--space-4);
  }

  .console-panel {
    padding: var(--space-4);
  }

  .scrub-readout {
    gap: var(--space-3);
    padding: var(--space-3);
  }

  .readout-key {
    font-size: 11px;
  }

  .readout-val {
    font-size: 13px;
  }

  .meter-strip {
    grid-template-columns: 1fr;
  }

  .meter-cell {
    border-right: none;
    border-bottom: 1px solid var(--border-hairline);
  }

  .meter-cell:last-child {
    border-bottom: none;
  }

  .territory-row {
    grid-template-columns: 32px minmax(0, 1fr) auto 44px;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-1);
  }

  .territory-name {
    font-size: 13px;
  }

  .territory-amount,
  .territory-share {
    font-size: 12px;
  }

  .territory-bar-track {
    display: none;
  }

  .search-field,
  .search-field .console-input {
    width: 100%;
  }

  .catalog-controls {
    width: 100%;
  }

  /* Responsive stacked catalog cards on mobile (zero horizontal clipping) */
  .table-wrap {
    overflow-x: visible;
  }

  .ledger-table {
    min-width: 0;
  }

  .ledger-table thead {
    display: none;
  }

  .ledger-table tbody {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
  }

  .ledger-table tr {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-2) var(--space-3);
    padding: var(--space-3);
    background: var(--bg-well);
    border: 1px solid var(--border-hairline);
    border-radius: var(--radius-md);
  }

  .ledger-table td {
    padding: 0;
    border-bottom: none;
  }

  .ledger-table td:nth-child(1) {
    grid-column: 1 / -1;
  }

  .ledger-table td:nth-child(2) {
    grid-column: 1 / 2;
    align-self: center;
  }

  .ledger-table td:nth-child(3),
  .ledger-table td:nth-child(4),
  .ledger-table td:nth-child(5) {
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 13px;
    padding-top: var(--space-2);
    border-top: 1px solid var(--border-hairline);
  }

  .ledger-table td:nth-child(3)::before,
  .ledger-table td:nth-child(4)::before,
  .ledger-table td:nth-child(5)::before {
    content: attr(data-label);
    font-family: var(--font-mono);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--ink-muted);
  }

  .ledger-table td:nth-child(6) {
    grid-column: 2 / -1;
    grid-row: 2;
    width: auto;
    text-align: right;
    align-self: center;
  }

  .ledger-table td:nth-child(6) .row-action-btn {
    min-height: 36px;
  }

  .toast-region {
    bottom: 76px;
    right: var(--space-3);
    left: var(--space-3);
    max-width: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
