/* Visual tokens match the existing BLEAK Analytics dashboard. */
:root {
  color-scheme: dark;
  --bg: #0a0b0d;
  --panel: #141619;
  --panel-fill: linear-gradient(145deg, rgba(29,31,36,.94), rgba(20,22,25,.92));
  --border: rgba(255,255,255,.075);
  --muted: #9a9fa8;
  --text: #f7f7f8;
  --text-data: #c8cbd0;
  --orange: #ff7a12;
  --orange-bright: #ff942e;
  --orange-deep: #e34f00;
  --orange-soft: rgba(255,122,18,.12);
  --orange-border: rgba(255,122,18,.3);
  --orange-text: #ffe0c7;
  --money: #ffc99d;
  --green: #62dda2;
  --danger: #ff8589;
  --warning: #ffd18e;
  --radius: 20px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  letter-spacing: 0;
  color: var(--text);
  background: var(--bg);
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; line-height: 1.5; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
[hidden] { display: none !important; }
::selection { background: rgba(255,122,18,.28); color: var(--text); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 10px; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: 0; }
button, select { cursor: pointer; }
button, input, select, textarea { border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; min-height: 40px; }
button { background: rgba(255,255,255,.043); font-size: 13px; font-weight: 650; line-height: 1.35; transition: background 160ms ease, border-color 160ms ease, color 160ms ease; }
button:hover { background: rgba(255,255,255,.075); border-color: rgba(255,255,255,.14); }
button:disabled { opacity: .45; cursor: not-allowed; }
:where(button, input, select, textarea, a, [tabindex]):focus-visible { outline: 2px solid var(--orange); outline-offset: 3px; }
input, textarea, select { background: rgba(7,8,10,.6); max-width: 100%; min-width: 0; }
input::placeholder, textarea::placeholder { color: var(--muted); }
input:focus, textarea:focus, select:focus { border-color: var(--orange-border); }
input[type=checkbox] { min-height: auto; accent-color: var(--orange); }
textarea { resize: vertical; min-height: 72px; }
label { display: grid; gap: 8px; color: var(--text-data); }
form { display: grid; gap: 18px; }
a { color: inherit; text-decoration: none; }
h1 { font-size: 25px; font-weight: 700; line-height: 1.25; margin: 8px 0; }
h2 { font-size: 20px; font-weight: 700; margin: 26px 0 16px; line-height: 1.35; }
p { line-height: 1.5; }
.topbar { position: sticky; top: 0; z-index: 20; background: var(--bg); border-bottom: 1px solid var(--border); }
.topbar-inner { width: min(1380px, calc(100% - 48px)); min-height: 78px; margin: auto; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 14px 0; }
.brand { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.brand > span { display: flex; flex-direction: column; line-height: 1.15; }
.brand strong { font-size: 16px; font-weight: 800; }
.brand small { color: var(--muted); font-size: 9px; text-transform: uppercase; margin-top: 3px; }
.mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 13px; font-size: 18px; font-weight: 900; background: linear-gradient(160deg,var(--orange-bright),var(--orange-deep)); color: #15100c; flex: none; }
#identity { padding: 6px 12px; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); font-size: 12px; max-width: 240px; overflow-wrap: anywhere; }
main { width: min(1380px, calc(100% - 48px)); padding: 48px 0 64px; margin: auto; }
.login { width: min(440px, 100%); margin: 36px auto; padding: 30px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel-fill); }
.login h1 { margin-bottom: 28px; }
.actions, .toolbar, .heading, .dialog-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; min-width: 0; }
.actions { justify-content: flex-end; }
.heading { margin-bottom: 24px; }
.heading.compact { margin: 0 0 18px; }
.heading.compact h2 { margin: 0; }
.toolbar { margin: 16px 0; }
.inline { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.eyebrow { color: var(--orange); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.muted, footer, .sub { color: var(--muted); }
.sub { display: block; font-size: 12px; margin-top: 5px; line-height: 1.45; }
.primary { background: linear-gradient(135deg,var(--orange-bright),var(--orange)); border-color: transparent; color: #15100c; font-weight: 750; }
.primary:hover { background: var(--orange-bright); border-color: var(--orange-bright); }
.segmented { display: flex; flex-wrap: wrap; gap: 6px; }
.segmented button { background: transparent; border-color: transparent; color: var(--muted); padding: 9px 14px; font-weight: 600; }
.segmented button:hover { background: rgba(255,255,255,.04); color: var(--text); }
.segmented button[aria-pressed=true] { background: var(--orange-soft); border-color: var(--orange-border); color: var(--orange-text); }
#workspace > .toolbar { padding: 14px 0; border-block: 1px solid var(--border); }
#reportDate { font-size: 13px; margin: 18px 0; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin: 22px 0; }
.metric { border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; background: var(--panel-fill); min-width: 0; min-height: 138px; display: flex; flex-direction: column; justify-content: space-between; gap: 14px; }
.metric span { color: var(--muted); font-size: 13px; }
.metric strong { display: block; font-size: 30px; font-weight: 700; line-height: 1.2; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.metric.debt { border-color: var(--orange-border); background: linear-gradient(150deg, rgba(255,122,18,.16), var(--panel) 80%); }
.metric.debt span { color: var(--orange-text); }
.metric.debt strong { color: var(--money); }
.metric.good strong { color: var(--green); }
#shares { grid-template-columns: repeat(5,minmax(0,1fr)); }
#shares .metric { min-height: 130px; padding: 18px; border-radius: 13px; }
#shares .metric strong { color: var(--money); font-size: 26px; }
#shares .metric:nth-child(-n+2) { border-color: var(--orange-border); background: var(--orange-soft); }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; padding: 14px 0; margin-top: 28px; border-block: 1px solid var(--border); }
.tabs button { min-width: 90px; background: transparent; border-color: transparent; color: var(--muted); padding: 10px 18px; }
.tabs button[aria-current=page] { background: var(--orange-soft); border-color: var(--orange-border); color: var(--orange-text); }
#reportsView, #sellersView { padding-top: 24px; }
.table-scroll { overflow-x: auto; max-width: 100%; border-block: 1px solid var(--border); background: var(--panel); }
table { border-collapse: collapse; width: 100%; text-align: left; font-variant-numeric: tabular-nums; }
th { color: var(--muted); font-size: 10px; text-transform: uppercase; white-space: nowrap; font-weight: 700; background: #1a1c20; }
td, th { padding: 14px 12px; border-bottom: 1px solid var(--border); }
td:first-child, th:first-child { padding-left: 18px; }
td:first-child { min-width: 155px; max-width: 230px; overflow-wrap: anywhere; }
td:last-child, th:last-child { padding-right: 18px; }
td { font-size: 12px; color: var(--text-data); }
td strong { color: var(--text); font-weight: 600; }
tbody tr:hover { background: rgba(255,255,255,.025); }
tbody tr:last-child td { border-bottom: 0; }
.number { text-align: right; white-space: nowrap; }
tfoot { font-weight: 650; background: #1a1c20; border-top: 1px solid var(--border); }
#invoicesView table { min-width: 1160px; }
#reportsView table { min-width: 720px; }
#importDialog { width: min(1100px, calc(100% - 32px)); }
#importReview td { max-width: 260px; }
#importDialog .actions { margin-top: 22px; }
.matched { color: var(--green); }
.money { color: var(--money); font-weight: 650; }
.date { white-space: nowrap; }
.badge { display: inline-block; padding: 5px 10px; white-space: nowrap; color: var(--muted); font-size: 11px; border: 1px solid var(--border); border-radius: 999px; background: rgba(255,255,255,.028); }
.badge.paid { color: var(--green); border-color: rgba(98,221,162,.24); background: rgba(98,221,162,.08); }
.badge.partial { color: #8ccde0; border-color: rgba(140,205,224,.24); background: rgba(140,205,224,.08); }
.badge.deferred { color: var(--warning); border-color: rgba(255,183,77,.24); background: rgba(255,183,77,.08); }
.overdue { color: var(--danger); }
.empty { text-align: center; color: var(--muted); padding: 44px 20px; }
#message:empty { display: none; }
#message, .warning, .form-error { color: var(--warning); }
#message { padding: 12px 0; }
footer { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-top: 26px; font-size: 11px; }
dialog { width: min(760px, calc(100% - 32px)); max-height: 90dvh; border: 1px solid var(--border); border-radius: var(--radius); background: #191b1f; color: inherit; padding: 26px; }
dialog::backdrop { background: #000b; }
.dialog-header { align-items: flex-start; flex-wrap: nowrap; }
.dialog-header h2 { margin: 5px 0 20px; overflow-wrap: anywhere; }
.close { font-size: 24px; width: 40px; height: 40px; padding: 0; flex-shrink: 0; }
.detail-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 16px; padding-block: 18px; margin: 12px 0 24px; border-block: 1px solid var(--border); color: var(--muted); }
.detail-grid > div { min-width: 0; }
.detail-grid strong { display: block; margin-top: 8px; font-size: 24px; color: var(--money); overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.section-divider { border-top: 1px solid var(--border); margin-top: 26px; padding-top: 8px; }
.history-item { border-bottom: 1px solid var(--border); padding: 14px 0; display: flex; align-items: center; gap: 12px; justify-content: space-between; }
.history-item > div { min-width: 0; overflow-wrap: anywhere; }
.history-item.reversed { opacity: .6; }
.history-item.reversed strong { text-decoration: line-through; }
.form-error:empty { display: none; }
.check { display: flex; align-items: center; gap: 10px; }
@media(max-width: 1000px) { #shares { grid-template-columns: repeat(3,minmax(0,1fr)); } #identity { max-width: 170px; } }
@media(max-width: 700px) {
  main { width: calc(100% - 32px); padding: 28px 0 44px; }
  .topbar-inner { width: calc(100% - 32px); min-height: 68px; gap: 12px; flex-wrap: wrap; }
  .topbar .actions { gap: 6px; }
  .topbar button, .topbar select { padding-inline: 10px; }
  #identity { display: none; }
  .metrics, #shares { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .metric { min-height: 128px; padding: 18px; }
  .metric strong, #shares .metric strong { font-size: 26px; }
  .heading { gap: 18px; }
  .heading .actions { justify-content: flex-start; }
  .segmented { gap: 4px; }
  .segmented button { padding: 9px 11px; }
  #workspace > .toolbar { gap: 18px; }
  #workspace > .toolbar > .inline { justify-content: space-between; width: 100%; }
  #search { width: 100%; }
  input, textarea, select { font-size: 16px; }
  .login { margin: 16px auto; padding: 24px; }
  .tabs { gap: 4px; }
  .tabs button { flex: 1; min-width: 0; padding-inline: 10px; }
}
@media(max-width: 420px) {
  .topbar-inner { gap: 8px; }
  .brand { gap: 8px; }
  .brand strong { font-size: 14px; }
  .mark { width: 34px; height: 34px; border-radius: 11px; }
  .topbar button, .topbar select { font-size: 12px; padding-inline: 8px; }
  .form-row { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; gap: 12px; }
  .detail-grid > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
  .detail-grid strong { margin: 0; font-size: 22px; }
  .metric, #shares .metric { padding: 16px; }
  dialog { padding: 20px; }
  .history-item { align-items: flex-start; flex-wrap: wrap; }
}
@media(prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; } }
@media print {
  :root { color-scheme: light; --text: #111; --text-data: #111; --money: #111; --muted: #444; --panel: #fff; --border: #ddd; color: #111; background: #fff; }
  .topbar .actions,.toolbar,.tabs,.heading .actions,#invoicesView,#sellersView,#print,footer,#message { display: none !important; }
  .topbar { position: static; background: white; }
  .topbar-inner { width: 100%; }
  #reportsView { display: block !important; }
  .metric, #shares .metric:nth-child(-n+2) { background: white; border-color: #ddd; }
  .metric strong, .metric.good strong, .money { color: #111 !important; }
  .table-scroll { overflow: visible; }
  #reportsView table { min-width: 0; }
  th, tfoot { background: #eee; }
  main { width: 100%; padding: 20px 0; }
  .metrics { grid-template-columns: repeat(4,minmax(0,1fr)); }
  #shares { grid-template-columns: repeat(5,minmax(0,1fr)); }
  #shares .metric { padding: 10px; }
  #shares .metric strong { font-size: 20px; }
}
