:root {
  --page: #e6f0fc;
  --shell: #1c1c1e;
  --panel: #ffffff;
  --ink: #101216;
  --muted: #7a8394;
  --line: #eceff4;
  --field: #f3f5f9;

  --blue: #e2edfc;
  --blue-line: #5da3f4;
  --lavender: #e7e1f6;
  --mint: #d8efe0;
  --cream: #f9f0cf;
  --sea: #d6e8f7;

  --up: #25905f;
  --down: #cf4a44;
  --amber: #b9780f;
  --amber-bg: #fbeccb;
  --dark: #232325;

  --radius: 22px;
  --font-head: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --font: "Figtree", "Segoe UI", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--ink);
  font: 400 14px/1.45 var(--font);
}

h1, h2, h3, p { margin: 0; }
h1, h2, h3, .big { font-family: var(--font-head); letter-spacing: -0.02em; }
h1 { font-size: 34px; line-height: 1.1; }
h2 { font-size: 20px; }
h3 { font-size: 17px; }

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

:focus-visible { outline: 2px solid var(--blue-line); outline-offset: 2px; }

[hidden] { display: none !important; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Shell ---------- */
.shell {
  width: 100%;
  min-height: 100vh;
  background: var(--shell);
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
}

.rail {
  display: flex; flex-direction: column; align-items: center;
  padding: 22px 0;
  gap: 24px; overflow-y: auto;
  color: #c9ccd3;
  position: sticky; top: 0; height: 100vh; align-self: start;
}
.logo {
  width: 46px; height: 46px; border-radius: 14px;
  background: #f9f0cf; color: #1c1c1e;
  display: grid; place-items: center;
}
.rail-nav { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.rail-btn {
  position: relative;
  width: 74px; padding: 9px 4px 8px; border-radius: 14px;
  border: 0; background: transparent; color: inherit;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.rail-label { font-size: 11.5px; font-weight: 500; line-height: 1.1; }
.rail-btn svg { width: 22px; height: 22px; }
.rail-btn:hover { background: #2b2b2e; color: #fff; }
.rail-btn:disabled { opacity: .45; cursor: default; }
.rail-btn[aria-current="page"] { color: #fff; background: #44444c; }
.rail-btn[aria-current="page"] .rail-label { font-weight: 600; }
.rail-btn[aria-current="page"]::before {
  content: ""; position: absolute; left: -9px; top: 12px; bottom: 12px;
  width: 3px; border-radius: 3px; background: #fff;
}

.panel {
  background: var(--panel);
  padding: 30px clamp(20px, 2.6vw, 48px) 28px;
  min-width: 0;
}

/* ---------- Header ---------- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 26px; }
.top-actions { display: flex; align-items: center; gap: 10px; }

.round {
  position: relative;
  width: 40px; height: 40px; border-radius: 50%;
  border: 0; background: var(--blue);
  display: grid; place-items: center;
}
.round svg { width: 18px; height: 18px; }
.round:hover { background: #d3e4fa; }
.dot {
  position: absolute; top: 8px; right: 9px;
  width: 8px; height: 8px; border-radius: 50%;
  background: #e5484d; box-shadow: 0 0 0 2px var(--blue);
}

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 18px; border-radius: 999px;
  border: 0; font-weight: 600; white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; stroke-width: 2.2; }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: #2a2d35; }
.btn-soft { background: #cfe4ff; color: #0f2a4a; }
.btn-soft:hover { background: #bdd9fb; }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--ink); }

.user {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 16px 4px 4px; border-radius: 999px; background: var(--blue);
  font-weight: 600;
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: #1c1c1e; color: #f9f0cf;
  display: grid; place-items: center; font: 700 14px var(--font-head);
}

/* ---------- Cards ---------- */
.card { border-radius: var(--radius); padding: 20px 22px; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; }
.block > h2, .block-head h2 { margin-bottom: 14px; }
.block-head h2 { margin-bottom: 14px; }

.link-btn {
  border: 0; background: none; padding: 0;
  color: var(--muted); text-decoration: underline; text-underline-offset: 3px;
  font-size: 13px;
}
.link-btn:hover { color: var(--ink); }

.sub { color: var(--muted); font-size: 13px; }

/* ---------- Row 1 ---------- */
.row-1 {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
  gap: 26px;
  margin-bottom: 30px;
}

.chart-card { position: relative; background: var(--blue); height: 196px; padding: 18px 22px 0; overflow: hidden; }
.chart-head { position: relative; z-index: 1; }
.big { font-size: 28px; font-weight: 700; line-height: 1.1; }
.chart { position: absolute; inset: 0; }
.chart svg { display: block; width: 100%; height: 100%; overflow: visible; stroke-width: 1.6; }
.tabs {
  position: absolute; z-index: 2; left: 22px; bottom: 12px;
  display: flex; gap: 4px;
}
.tabs button {
  border: 0; background: none; border-radius: 999px;
  padding: 3px 9px; font-size: 12px; font-weight: 500; color: #7b93b4;
}
.tabs button[aria-selected="true"] { background: var(--ink); color: #fff; font-weight: 600; }
.tip {
  position: absolute; z-index: 3; pointer-events: none;
  background: #17181b; color: #fff; border-radius: 12px;
  padding: 6px 12px; font: 600 13px var(--font-head); white-space: nowrap;
  transform: translate(-50%, -135%);
}
.tip small { display: block; font: 400 11px var(--font); color: #aab0bb; }

.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.kpi {
  display: flex; flex-direction: column; justify-content: space-between; gap: 16px;
  height: 196px; padding: 20px; text-align: left;
  border: 1.5px solid rgba(16, 18, 22, .07); border-radius: var(--radius);
  color: var(--ink);
}
button.kpi { cursor: pointer; transition: transform .15s ease, box-shadow .15s ease; }
button.kpi:hover { transform: translateY(-2px); box-shadow: 0 10px 22px -14px rgba(20, 30, 60, .5); }
.kpi.tone-mint { background: var(--mint); }
.kpi.tone-cream { background: var(--cream); }
.kpi.tone-lavender { background: var(--lavender); }
.kpi-icon {
  width: 52px; height: 52px; border-radius: 16px; background: #fff;
  display: grid; place-items: center;
  box-shadow: 0 0 0 1.5px rgba(16, 18, 22, .06);
}
.kpi-icon svg { width: 24px; height: 24px; }
.kpi-text { display: grid; gap: 2px; }
.kpi-num { font: 700 clamp(24px, 2.1vw, 32px)/1.1 var(--font-head); letter-spacing: -.02em; }
.kpi-label { font-weight: 600; }
.kpi-sub { font-size: 12.5px; color: #5c6473; }

/* ---------- Row 2 ---------- */
.row-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 290px;
  gap: 26px;
  align-items: start;
}

.table-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.table-head h2 { margin: 0; }
.pills { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.pill-select { position: relative; }
.pill-select select {
  appearance: none; -webkit-appearance: none;
  height: 36px; padding: 0 34px 0 16px; border-radius: 999px;
  border: 1.5px solid var(--line); background: #fff; font-weight: 500; cursor: pointer;
}
.pill-select::after {
  content: ""; position: absolute; right: 14px; top: 14px;
  width: 7px; height: 7px; border-right: 1.8px solid var(--ink); border-bottom: 1.8px solid var(--ink);
  transform: rotate(45deg); pointer-events: none;
}

.filters { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.search {
  position: relative; flex: 1 1 220px; min-width: 0;
}
.search svg { position: absolute; left: 14px; top: 11px; width: 16px; height: 16px; color: var(--muted); }
.search input {
  width: 100%; height: 38px; border-radius: 999px; border: 0;
  background: var(--field); padding: 0 16px 0 38px;
}
.search input::placeholder { color: #9aa2b1; }
.chip {
  height: 34px; padding: 0 14px; border-radius: 999px;
  border: 1.5px solid var(--line); background: #fff; font-weight: 500; font-size: 13px;
}
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }

.chip-sep { width: 1.5px; height: 20px; background: var(--line); margin: 0 2px; }
.setchips { display: flex; gap: 8px; flex-wrap: wrap; }

.matlist { list-style: none; margin: 0; padding: 0; max-height: 280px; overflow-y: auto; }
.matlist li { display: flex; align-items: center; gap: 12px; padding: 10px 2px; border-top: 1px solid var(--line); }
.matlist li:first-child { border-top: 0; }
.matlist .mi { flex: 1; min-width: 0; display: grid; }
.matlist .mi b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.matlist .mi span { font-size: 12px; color: var(--muted); }
.matlist .ma { font-weight: 600; font-variant-numeric: tabular-nums; }
.matform { display: grid; grid-template-columns: 1fr 120px auto; gap: 12px; align-items: end; margin-top: 14px; }
.matform label { display: grid; gap: 6px; font-size: 12.5px; font-weight: 500; color: var(--muted); min-width: 0; }
.matform input { height: 44px; width: 100%; min-width: 0; border: 1.5px solid var(--line); background: #fff; border-radius: 12px; padding: 0 14px; color: var(--ink); }

.table-wrap { overflow-x: auto; position: relative; }
table.inv { width: 100%; border-collapse: collapse; min-width: 640px; }
.inv th {
  text-align: left; font-weight: 500; font-size: 12.5px; color: var(--muted);
  padding: 10px 10px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.inv th button { border: 0; background: none; padding: 0; color: inherit; font-weight: inherit; font-size: inherit; }
.inv th button:hover { color: var(--ink); }
.inv th[aria-sort="ascending"] button::after { content: " ↑"; }
.inv th[aria-sort="descending"] button::after { content: " ↓"; }
.inv th.num, .inv td.num { text-align: right; font-variant-numeric: tabular-nums; }
.inv td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.inv tbody tr { cursor: pointer; transition: background .12s ease; }
.inv tbody tr:hover { background: #f7f9fc; }
.c-star { width: 34px; padding-right: 0 !important; }

.star { border: 0; background: none; width: 26px; height: 26px; padding: 0; color: #b8bfcc; border-radius: 8px; }
.star svg { width: 18px; height: 18px; }
.star:hover { color: var(--ink); }
.star[aria-pressed="true"] { color: #e2a21b; }
.star[aria-pressed="true"] svg { fill: currentColor; }

.cardcell { display: flex; align-items: center; gap: 12px; min-width: 0; }
.cardcell .meta { min-width: 0; }
.cardcell .nm { border: 0; background: none; padding: 0; text-align: left; cursor: pointer; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; display: block; }
.cardcell .cd { font-size: 12px; color: var(--muted); }

.thumb {
  --h: 220;
  flex: none; width: 34px; height: 46px; border-radius: 7px;
  background: linear-gradient(155deg, hsl(var(--h) 80% 86%), hsl(var(--h) 62% 62%));
  box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .55);
  display: grid; place-items: center;
  font: 700 9.5px var(--font-head); color: rgba(16, 18, 22, .72);
}
.thumb.lg { width: 84px; height: 116px; border-radius: 12px; font-size: 18px; }

.delta { font-weight: 600; }
.delta.good { color: var(--up); }
.delta.warn { color: var(--amber); }
.delta.flat { color: var(--muted); font-weight: 500; }

.days.old { background: var(--amber-bg); color: var(--amber); border-radius: 999px; padding: 2px 9px; font-weight: 600; }

.status {
  display: inline-block; border-radius: 999px; padding: 3px 11px;
  font-size: 12.5px; font-weight: 600; white-space: nowrap;
}
.s-listed { background: #dcf1e5; color: #1f7a50; }
.s-claimed { background: var(--amber-bg); color: var(--amber); }
.s-sold { background: #e3e7ee; color: #566073; }
.s-unlisted { background: #fff; color: var(--muted); box-shadow: inset 0 0 0 1.5px var(--line); }

.empty { text-align: center; padding: 40px 12px; color: var(--muted); }
.empty strong { color: var(--ink); }

.table-foot { display: flex; justify-content: space-between; gap: 12px; padding-top: 12px; color: var(--muted); font-size: 13px; }

/* ---------- Side column ---------- */
.side { display: grid; gap: 20px; }

.promo {
  position: relative; overflow: hidden;
  background: var(--dark); color: #fff;
  border-radius: var(--radius); padding: 26px 24px 24px;
  min-height: 236px;
}
.promo-copy { position: relative; z-index: 1; }
.promo h3 { font-size: 22px; line-height: 1.2; max-width: 14ch; }
.promo p { color: #b6bac3; font-size: 13px; margin: 12px 0 20px; max-width: 28ch; }
.promo-deco {
  position: absolute; right: -34px; bottom: -34px; width: 150px; height: 190px;
  border: 1.5px solid rgba(255, 255, 255, .28); border-radius: 16px; transform: rotate(14deg);
}
.promo-deco::after {
  content: ""; position: absolute; inset: 14px 8px 0 -34px;
  border: 1.5px solid rgba(255, 255, 255, .18); border-radius: 16px;
}

.sales { background: var(--mint); }
.sales-head { margin-bottom: 8px; }
.sales ul { list-style: none; margin: 0; padding: 0; }
.sales li {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 0; border-top: 1px solid rgba(16, 18, 22, .08);
}
.sales li:first-child { border-top: 0; }
.sales .who { min-width: 0; }
.sales .who b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sales .who span { font-size: 12px; color: #55705f; }
.sales .pl { font-weight: 600; font-variant-numeric: tabular-nums; color: #17794b; white-space: nowrap; }
.sales .pl.neg { color: var(--down); }

/* ---------- Dialogs ---------- */
dialog {
  border: 0; padding: 0; color: var(--ink);
  background: var(--panel); border-radius: 26px;
  max-width: calc(100vw - 24px);
  box-shadow: 0 40px 80px -30px rgba(10, 20, 40, .6);
}
dialog::backdrop { background: rgba(14, 18, 28, .5); }

#drawer {
  position: fixed; inset: 0; margin: auto;
  width: min(560px, calc(100vw - 24px));
  height: auto; max-height: min(780px, calc(100vh - 32px)); max-height: min(780px, calc(100dvh - 32px));
  border-radius: 26px; overflow: hidden;
  box-shadow: 0 40px 80px -30px rgba(10, 20, 40, .6);
}
#drawer[open] { display: flex; flex-direction: column; animation: pop-in .18s ease-out; }
@keyframes pop-in { from { transform: scale(.97); opacity: 0; } }

.drawer-inner { display: flex; flex-direction: column; flex: 1; min-height: 0; width: 100%; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; }
.d-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 24px; border-bottom: 1px solid var(--line); }
.d-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 24px; display: grid; gap: 22px; align-content: start; }
.d-foot { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 10px; padding: 16px 24px 20px; border-top: 1px solid var(--line); background: #fff; }
.d-foot .btn { justify-content: center; height: 46px; }

.d-top { display: flex; gap: 20px; align-items: flex-start; }
.d-title { min-width: 0; }
.d-title h2 { font-size: 24px; line-height: 1.15; overflow-wrap: anywhere; }
.d-title .cd { color: var(--muted); margin-top: 4px; }
.badges { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; }
.badge { background: var(--field); border-radius: 999px; padding: 3px 10px; font-size: 12.5px; font-weight: 500; }

.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.stat { background: var(--field); border-radius: 16px; padding: 12px 16px; }
.stat span { display: block; font-size: 12px; color: var(--muted); }
.stat b { font: 700 19px var(--font-head); font-variant-numeric: tabular-nums; }
.stat.tint-blue { background: var(--blue); }
.stat.tint-mint { background: var(--mint); }

.facts { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.facts div { background: var(--field); border-radius: 16px; padding: 12px 16px; }
.facts dt { font-size: 12px; color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; }

.field { display: grid; gap: 8px; }
.field > label { font-size: 12.5px; font-weight: 500; color: var(--muted); }
.field .inline { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px; }
.drawer-inner input, .add input, .add select, .add textarea {
  height: 44px; width: 100%; border: 1.5px solid var(--line); background: #fff; border-radius: 12px; padding: 0 14px; color: var(--ink);
}
.add label { display: grid; gap: 6px; font-size: 12.5px; font-weight: 500; color: var(--muted); }
.btn-sm { height: 36px; padding: 0 14px; font-size: 13px; }
.btn-line { background: #fff; box-shadow: inset 0 0 0 1.5px var(--line); }
.btn-line:hover { box-shadow: inset 0 0 0 1.5px var(--ink); }
.btn:disabled { opacity: .45; cursor: default; }
.danger { color: var(--down); justify-self: start; }

.add { padding: 24px 26px 22px; width: min(560px, 100vw - 24px); display: grid; gap: 16px; }
.add .hint { color: var(--muted); font-size: 13px; max-width: 52ch; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: #17181b; color: #fff; border-radius: 999px; padding: 11px 20px;
  font-weight: 500; box-shadow: 0 14px 30px -12px rgba(0, 0, 0, .5); z-index: 50;
}

/* ---------- Views and shared boxes ---------- */
.view[hidden] { display: none; }
.view > * + * { margin-top: 26px; }
.box { background: #fff; border: 1.5px solid var(--line); border-radius: var(--radius); padding: 20px 22px; min-width: 0; }
.box > h2, .box > h3 { margin-bottom: 12px; }
.box-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.box-head h2, .box-head h3 { margin: 0; }
.hint { color: var(--muted); font-size: 13px; max-width: 60ch; margin-bottom: 14px; }
.hint code { background: var(--field); padding: 1px 6px; border-radius: 6px; font-size: 12px; }
.row-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.row-actions.end { justify-content: flex-end; }
.file-btn { cursor: pointer; }
.file-btn:focus-within { outline: 2px solid var(--blue-line); outline-offset: 2px; }
textarea {
  width: 100%; border: 1.5px solid var(--line); border-radius: 14px; padding: 12px 14px;
  font: 500 13px/1.5 ui-monospace, "Cascadia Mono", Consolas, monospace; color: var(--ink); resize: vertical; background: #fff;
}
.empty.small { padding: 26px 8px; }
.s-bad { background: #fbe1df; color: var(--down); }
.nm2 { font-weight: 600; }

/* Summary tiles (4 across) */
.kpis.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpis.four .kpi { height: auto; flex-direction: row; align-items: center; justify-content: flex-start; gap: 16px; padding: 16px 18px; }
.kpis.four .kpi-icon { width: 48px; height: 48px; flex: none; }
.kpis.four .kpi-num { font-size: clamp(22px, 1.9vw, 28px); overflow-wrap: anywhere; }
.kpi.tone-blue { background: var(--sea); }
button.kpi { font: inherit; width: 100%; position: relative; }
.kpi-go {
  position: absolute; top: 14px; right: 14px; width: 28px; height: 28px; border-radius: 50%;
  background: rgba(255, 255, 255, .75); display: grid; place-items: center;
}
.kpi-go svg { width: 14px; height: 14px; stroke-width: 2.2; }
button.kpi:hover .kpi-go { background: #fff; }

/* Net profit chart */
.nets { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; }
.nbar { display: grid; grid-template-rows: 170px auto auto; gap: 6px; justify-items: center; min-width: 0; }
.nb-area { position: relative; width: 100%; height: 170px; }
.nb-area::before { content: ""; position: absolute; left: 0; right: 0; top: var(--z); border-top: 1px dashed #cfd6e2; }
.nb-area i { position: absolute; left: 22%; right: 22%; border-radius: 8px; background: #5da3f4; opacity: .5; }
.nb-area i.neg { background: #e08a3c; }
.nbar.now .nb-area i { opacity: 1; }
.nb-val { font-weight: 600; font-size: 13px; font-variant-numeric: tabular-nums; }
.nb-val.neg { color: var(--down); }
.nb-m { font-size: 12px; color: var(--muted); }
.nbar.now .nb-m { color: var(--ink); font-weight: 600; }
.flash { animation: flash 1.4s ease-out; }
@keyframes flash { 0% { box-shadow: 0 0 0 0 rgba(93, 163, 244, .75); } 100% { box-shadow: 0 0 0 16px rgba(93, 163, 244, 0); } }

/* Overview */
.ov-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.7fr) minmax(0, 1.1fr); gap: 20px; align-items: stretch; }
.donut-wrap { display: grid; justify-items: center; gap: 16px; padding-top: 6px; }
.donut { width: min(180px, 100%); height: auto; overflow: visible; }
.donut text { stroke: none; fill: var(--ink); }
.donut .d-num { font: 700 26px var(--font-head); }
.donut .d-lab { font-size: 11px; fill: var(--muted); }
.legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; width: 100%; }
.legend li { display: flex; align-items: center; gap: 10px; }
.legend li b { margin-left: auto; font-variant-numeric: tabular-nums; }
.legend i { width: 12px; height: 12px; border-radius: 4px; display: inline-block; margin-right: 6px; }
.legend li i { margin: 0; }
.legend.row { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-bottom: 8px; }
.legend.row b { margin-left: auto; }
.legend b.pos { color: var(--up); }
.legend b.neg { color: var(--down); }
.linechart { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0 10px; }
.linechart svg { width: 100%; height: 190px; display: block; overflow: visible; }
.linechart .grid { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.ylabels { display: flex; flex-direction: column; justify-content: space-between; font-size: 11.5px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.months { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); padding-top: 8px; }
.bars { display: grid; gap: 14px; }
.bar { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; align-items: center; gap: 10px; font-size: 13px; }
.bar span { color: var(--muted); font-weight: 500; }
.bar b { font-variant-numeric: tabular-nums; }
.track { height: 12px; border-radius: 6px; background: var(--field); overflow: hidden; }
.track i { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, #5da3f4, #86bdf8); }

/* Claims */
.claims-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 20px; align-items: start; }
.groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; align-items: start; margin-top: 14px; }
.groups > .empty { grid-column: 1 / -1; }
.group header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.group .total { font: 700 20px var(--font-head); }
.group ul { list-style: none; margin: 0; padding: 0; }
.group li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.group .gi { flex: 1; min-width: 0; display: grid; }
.group .gi b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.group .gi span { font-size: 12px; color: var(--muted); }
.group .gp { font-weight: 600; font-variant-numeric: tabular-nums; }
.group footer { display: flex; gap: 8px; margin-top: 12px; padding-top: 14px; border-top: 1px solid var(--line); }
.group footer .btn { flex: 1; justify-content: center; }

/* Price trends */
.trends { list-style: none; margin: 0; padding: 0; }
.trends li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.trends li:first-child { border-top: 0; }
.tcode { font: 700 14px var(--font-head); width: 44px; }
.tname { flex: 1; min-width: 0; color: var(--muted); font-size: 12.5px; }
.trend { font-weight: 600; font-variant-numeric: tabular-nums; }
.trend.up { color: var(--up); }
.trend.down { color: var(--down); }

/* Rail alert dot */
.rail-dot { position: absolute; top: 7px; right: 18px; width: 8px; height: 8px; border-radius: 50%; background: #ff6b6b; box-shadow: 0 0 0 2px var(--shell); }

/* ---------- Page title + description ---------- */
.title-block { min-width: 0; }
.page-sub { color: var(--muted); font-size: 14px; margin-top: 4px; max-width: 60ch; }

/* ---------- Segmented control ---------- */
.seg { display: inline-flex; background: #e3e7ee; border-radius: 999px; padding: 4px; gap: 3px; }
.seg button { border: 0; background: none; border-radius: 999px; padding: 7px 16px; font-weight: 500; color: #5b6577; }
.seg button:hover { color: var(--ink); }
/* The selected option is dark with white text and a check mark, so it is obvious which one is on */
.seg button[aria-selected="true"], .seg button[aria-checked="true"] { background: var(--ink); color: #fff; font-weight: 600; }
.seg button[aria-selected="true"]::before, .seg button[aria-checked="true"]::before { content: "✓"; margin-right: 6px; font-weight: 700; }
.chip[aria-pressed="true"]::before { content: "✓"; margin-right: 6px; font-weight: 700; }
.wording-pick { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* ---------- Claims import ---------- */
.steps { margin: 0 0 12px; padding-left: 20px; display: grid; gap: 4px; color: #3b4252; max-width: 70ch; }
.import-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 4px 0 14px; }
.inline-field { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin-left: auto; }
.inline-field input { height: 38px; border: 1.5px solid var(--line); border-radius: 12px; padding: 0 12px; width: 190px; color: var(--ink); }
.review-sum { margin-bottom: 12px; }
.warns { list-style: none; margin: 0 0 16px; padding: 12px 14px; background: #fdf3dc; border-radius: 14px; display: grid; gap: 8px; font-size: 13px; }
.warns li { display: flex; gap: 10px; align-items: flex-start; }
.warns svg { width: 16px; height: 16px; flex: none; margin-top: 2px; color: var(--amber); }
.posts { display: grid; gap: 14px; }
.post { border: 1.5px solid var(--line); border-radius: 18px; padding: 14px 16px; }
.post > header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 8px; }
.post h4 { margin: 0; font: 600 16px var(--font-head); overflow-wrap: anywhere; }
.claimrows { list-style: none; margin: 0; padding: 0; }
.crow { display: grid; grid-template-columns: auto minmax(120px, 1fr) minmax(180px, 1.4fr) auto; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.crow.late { grid-template-columns: minmax(0, 1fr) auto; color: var(--muted); }
.crow .who { display: grid; min-width: 0; }
.crow .who b { font-weight: 600; overflow-wrap: anywhere; }
.crow .who span { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crow select { height: 38px; width: 100%; border: 1.5px solid var(--line); border-radius: 12px; padding: 0 10px; background: #fff; min-width: 0; }
.crow .price { display: flex; align-items: center; gap: 4px; font-weight: 500; color: var(--muted); }
.crow .price input { width: 84px; height: 38px; border: 1.5px solid var(--line); border-radius: 12px; padding: 0 8px; color: var(--ink); }
.chk input, #costRows input[type="checkbox"], #costAll { width: 18px; height: 18px; accent-color: var(--ink); }

/* ---------- Costs tab ---------- */
.missing { color: var(--amber); font-weight: 600; }
.cost-field { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); }
.cost-in { width: 108px; height: 38px; border: 1.5px solid var(--line); border-radius: 12px; padding: 0 10px; text-align: right; color: var(--ink); background: #fff; font-variant-numeric: tabular-nums; }
.cost-in:placeholder-shown { border-color: #f0d9a0; background: #fffaf0; }
.bulkbar { display: flex; align-items: flex-end; gap: 10px 14px; flex-wrap: wrap; background: var(--blue); border-radius: 16px; padding: 12px 16px; margin: 4px 0 12px; }
.bulkbar b { align-self: center; }
.bulkbar label { display: grid; gap: 4px; font-size: 12px; color: #4a5a74; }
.bulkbar input { width: 120px; height: 36px; border: 1.5px solid #fff; border-radius: 10px; padding: 0 10px; color: var(--ink); }

/* ---------- Buyer message dialog ---------- */
.add.wide { width: min(780px, calc(100vw - 24px)); }
.bill-settings { display: grid; gap: 10px; }
.bill-settings label { display: grid; gap: 6px; font-size: 12.5px; font-weight: 500; color: var(--muted); }
.add textarea { height: auto; padding: 10px 14px; }
.bill-settings textarea, .bill-card textarea { font: 400 14px/1.5 var(--font); }
.bill-list { display: grid; gap: 14px; }
.bill-card { border: 1.5px solid var(--line); border-radius: 18px; padding: 14px 16px; }
.bill-actions { display: flex; gap: 8px; }
.bill-card textarea { width: 100%; resize: vertical; }
.bill-card .box-head { margin-bottom: 10px; }

/* ---------- Manage cards menu ---------- */
.menu-wrap { position: relative; }
.btn .chev { width: 14px; height: 14px; stroke-width: 2.4; margin-left: 2px; }
.btn[aria-expanded="true"] .chev { transform: rotate(180deg); }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 40; min-width: 300px;
  background: #fff; border: 1.5px solid var(--line); border-radius: 18px; padding: 6px;
  box-shadow: 0 24px 50px -22px rgba(20, 30, 60, .45);
}
.menu button { display: grid; width: 100%; text-align: left; border: 0; background: none; border-radius: 12px; padding: 9px 12px; gap: 1px; }
.menu button b { font-weight: 600; }
.menu button small { color: var(--muted); font-size: 12px; }
.menu button:hover:not(:disabled), .menu button:focus-visible { background: var(--field); outline: none; }
.menu button:disabled { opacity: .5; cursor: default; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 4px; }

/* ---------- Selection column + card images ---------- */
.c-sel { width: 34px; padding-right: 0 !important; }
.c-sel input { width: 18px; height: 18px; accent-color: var(--ink); vertical-align: middle; }
.thumb { overflow: hidden; position: relative; }
.thumb.has-img { width: 42px; height: 59px; background: var(--field); box-shadow: 0 0 0 1px rgba(16, 18, 22, .08); }
.thumb.has-img .rar { display: none; }
.thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.linkrow { display: flex; gap: 20px; }
.photo-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.photo-row .sub { flex: 1 1 220px; font-size: 12.5px; }
.notes { background: var(--field); border-radius: 14px; padding: 10px 14px; font-size: 13.5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.add textarea[name=notes] { font: 400 14px/1.4 var(--font); }
.thumb.lg.has-img { width: 112px; height: 156px; }
.pricelinks { display: flex; align-items: center; gap: 8px 14px; flex-wrap: wrap; font-size: 13px; }
.pricelinks a, .rlinks a { color: var(--ink); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.pricelinks a:hover, .rlinks a:hover { color: #2a6fd1; }
.rlinks { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12.5px; margin-top: 4px; }

/* ---------- Add / edit form ---------- */
.lookup-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.lookup-bar .hint { margin: 0; flex: 1 1 260px; }
.grid2 .span2 { grid-column: 1 / -1; }
.img-prev { display: flex; justify-content: center; }
.img-prev img { max-height: 200px; border-radius: 12px; box-shadow: 0 0 0 1px rgba(16, 18, 22, .1); }
.add select { background: #fff; }

/* ---------- Lookup dialog ---------- */
.lookup-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.lookup-form input { flex: 1 1 220px; width: auto; }
.lookup-form input { height: 44px; border: 1.5px solid var(--line); border-radius: 12px; padding: 0 14px; width: 100%; color: var(--ink); }
.lookup-status { min-height: 20px; }
.lookup-status.err { color: var(--down); font-weight: 500; }
.lookup-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 12px; }
.result { border: 1.5px solid var(--line); border-radius: 18px; padding: 10px; display: grid; gap: 3px; align-content: start; min-width: 0; }
.rimg { aspect-ratio: 5 / 7; border-radius: 12px; background: var(--field); display: grid; place-items: center; overflow: hidden; margin-bottom: 6px; }
.rimg img { width: 100%; height: 100%; object-fit: contain; }
.rname { font-family: var(--font-head); font-size: 15px; overflow-wrap: anywhere; }
.result .sub { font-size: 12px; }
.rprice { margin-top: 4px; font-size: 15px; }
.rprice small { color: var(--muted); font-size: 12px; font-weight: 400; }
.result .btn { margin-top: 8px; justify-content: center; width: 100%; }

/* ---------- Bulk stock lots ---------- */
.lotform { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr) auto auto; gap: 12px; align-items: end; margin-bottom: 14px; }
.lotform label { display: grid; gap: 6px; font-size: 12.5px; font-weight: 500; color: var(--muted); min-width: 0; }
.lotform input { height: 44px; width: 100%; min-width: 0; border: 1.5px solid var(--line); background: #fff; border-radius: 12px; padding: 0 14px; color: var(--ink); }
.lot-split { display: grid; gap: 6px; }
.lots { list-style: none; margin: 0; padding: 0; }
.lot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 0; border-top: 1px solid var(--line); }
.lot:first-child { border-top: 0; }
.lot-main { display: grid; min-width: 0; }
.lot-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.mini-select select { height: 36px; border: 1.5px solid var(--line); border-radius: 999px; padding: 0 12px; background: #fff; font-size: 13px; }
.tag { display: inline-block; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: var(--lavender); border-radius: 999px; padding: 2px 10px; font-size: 12.5px; font-weight: 500; vertical-align: middle; }

/* ---------- Drag and drop zone ---------- */
.dropzone { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; border: 2px dashed #b9c6da; border-radius: 18px; padding: 18px 20px; background: #f7f9fd; margin-bottom: 12px; transition: background .12s ease, border-color .12s ease; }
.dropzone svg { width: 30px; height: 30px; flex: none; color: #5da3f4; }
.dropzone .dz-text { display: grid; gap: 2px; flex: 1 1 260px; }
.dropzone.is-over { background: #e2edfc; border-color: #5da3f4; border-style: solid; }
body.dragging-files .dropzone { border-color: #5da3f4; }

/* ---------- Claims: extra sales and by-buyer review ---------- */
.plus { width: 34px; height: 34px; padding: 0; justify-content: center; font-size: 20px; line-height: 1; border-radius: 50%; }
.buyer-in { height: 34px; width: 100%; min-width: 120px; border: 1.5px solid var(--line); border-radius: 10px; padding: 0 10px; color: var(--ink); }
.crow.note { grid-template-columns: minmax(0, 1fr); color: var(--muted); padding: 7px 0; }
.crow.note .who span { white-space: normal; }
.post > header .plus-wrap { display: flex; align-items: center; gap: 8px; }
.bgroup { border: 1.5px solid var(--line); border-radius: 18px; padding: 12px 16px; }
.bgroup > header { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 4px; }
.bgroup h4 { margin: 0; font: 600 16px var(--font-head); }
.plus-row { display: flex; gap: 8px; align-items: center; padding: 8px 0 2px; flex-wrap: wrap; }
.plus-row input { flex: 1 1 180px; height: 38px; border: 1.5px solid var(--line); border-radius: 12px; padding: 0 12px; color: var(--ink); }
.hidden-note { color: var(--muted); font-size: 13px; margin-top: 10px; }

.cardhead { display: flex; align-items: center; gap: 12px; min-width: 0; }
.group footer .sub { align-self: center; }

/* ---------- Responsive ---------- */
@media (max-width: 1280px) {
  .kpis.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1120px) {
  .ov-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .ov-line { grid-column: 1 / -1; order: -1; }
  .claims-grid { grid-template-columns: minmax(0, 1fr); }
  .row-1 { grid-template-columns: minmax(0, 1fr); }
  .row-2 { grid-template-columns: minmax(0, 1fr); }
  .side { grid-template-columns: repeat(2, minmax(0, 1fr)); order: -1; }
  #view-prices .side { grid-template-columns: minmax(0, 1fr); order: 0; }
}

@media (max-width: 760px) {
  .shell { display: block; padding-bottom: 72px; }
  .rail {
    position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; top: auto;
    flex-direction: row; justify-content: center; gap: 0; padding: 8px 6px 6px; overflow: visible;
    background: var(--shell); height: auto; align-self: auto;
  }
  .rail .logo { display: none; }
  .rail-nav { display: flex; width: 100%; gap: 2px; }
  .rail-nav li { flex: 1; min-width: 0; }
  .rail-btn { width: 100%; padding: 6px 0 5px; gap: 2px; }
  .rail-btn svg { width: 20px; height: 20px; }
  .rail-label { font-size: 10px; }
  .rail-dot { right: 22%; }
  .crow { grid-template-columns: auto minmax(0, 1fr); }
  .crow select, .crow .price { grid-column: 2; }
  .inline-field { margin-left: 0; width: 100%; }
  .inline-field input { flex: 1; width: auto; }
  .seg button { padding: 7px 12px; }
  .lotform { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .lotform label:first-child, .lotform .btn { grid-column: 1 / -1; }
  .lookup-form { grid-template-columns: minmax(0, 1fr); }
  .chip-sep { display: none; }
  .menu { right: auto; left: 0; min-width: min(300px, calc(100vw - 32px)); }
  .rail-btn[aria-current="page"]::before { left: 18%; right: 18%; top: -6px; bottom: auto; width: auto; height: 3px; }
  .panel { padding: 20px 16px 24px; }
  .top { flex-wrap: wrap; }
  h1 { font-size: 28px; }
  .user-name { display: none; }
  .user { padding: 4px; }
  .kpis, .kpis.four { grid-template-columns: minmax(0, 1fr); }
  .ov-grid { grid-template-columns: minmax(0, 1fr); }
  .groups { grid-template-columns: minmax(0, 1fr); }
  .nets { gap: 4px; }
  .nb-val { font-size: 11px; }
  .kpi { height: auto; flex-direction: row; align-items: center; justify-content: flex-start; gap: 16px; }
  .side { grid-template-columns: minmax(0, 1fr); }
  #drawer { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); border-radius: 22px; }
  .grid2 { grid-template-columns: 1fr; }
  .matform { grid-template-columns: 1fr 100px; }
  .matform .btn { grid-column: 1 / -1; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
