/* ============================================
   Ledger — design tokens
   ============================================ */
:root {
  /* Surfaces */
  --bg: oklch(0.965 0.008 80);        /* warm cream */
  --bg-sunk: oklch(0.945 0.010 80);   /* deeper crème for panels */
  --surface: #ffffff;
  --surface-2: oklch(0.985 0.006 80);

  /* Text */
  --ink: oklch(0.20 0.012 60);        /* warm near-black */
  --ink-2: oklch(0.42 0.010 60);      /* secondary */
  --ink-3: oklch(0.58 0.008 60);      /* tertiary / labels */
  --ink-4: oklch(0.72 0.006 60);      /* placeholder */

  /* Borders */
  --line: oklch(0.88 0.006 70);
  --line-2: oklch(0.92 0.006 70);
  --line-strong: oklch(0.78 0.008 70);

  /* Accent — Prussian ink */
  --accent: oklch(0.36 0.085 250);
  --accent-2: oklch(0.46 0.085 250);
  --accent-tint: oklch(0.94 0.025 250);
  --accent-tint-strong: oklch(0.88 0.04 250);

  /* Semantic */
  --pos: oklch(0.50 0.10 150);
  --pos-tint: oklch(0.94 0.04 150);
  --neg: oklch(0.52 0.16 25);
  --neg-tint: oklch(0.94 0.04 25);
  --warn: oklch(0.62 0.12 65);
  --warn-tint: oklch(0.94 0.05 65);

  /* Series colors (used for stock chips, not pokemon-themed) */
  --tag-bg: oklch(0.96 0.012 60);
  --tag-fg: oklch(0.32 0.010 60);

  /* Type */
  --font-ui: "Inter Tight", "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  /* Radii */
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;

  --shadow-soft: 0 1px 0 oklch(0.88 0.006 70 / 0.5);
  --shadow-pop: 0 8px 28px -12px oklch(0.20 0.012 60 / 0.18), 0 2px 6px -2px oklch(0.20 0.012 60 / 0.08);
}

:root { color-scheme: light; }
[data-theme="dark"] {
  color-scheme: dark;
  --bg: oklch(0.17 0.018 255);
  --bg-sunk: oklch(0.14 0.018 255);
  --surface: oklch(0.215 0.018 255);
  --surface-2: oklch(0.255 0.018 255);
  --ink: oklch(0.96 0.005 250);
  --ink-2: oklch(0.80 0.010 250);
  --ink-3: oklch(0.64 0.012 250);
  --ink-4: oklch(0.50 0.012 250);
  --line: oklch(0.32 0.015 250);
  --line-2: oklch(0.27 0.015 250);
  --line-strong: oklch(0.42 0.018 250);
  --accent: oklch(0.66 0.11 250);
  --accent-2: oklch(0.75 0.11 250);
  --accent-tint: oklch(0.32 0.06 250);
  --accent-tint-strong: oklch(0.40 0.08 250);
  --pos: oklch(0.75 0.14 150);
  --pos-tint: oklch(0.32 0.07 150);
  --neg: oklch(0.70 0.17 25);
  --neg-tint: oklch(0.34 0.09 25);
  --warn: oklch(0.80 0.13 75);
  --warn-tint: oklch(0.36 0.07 65);
  --tag-bg: oklch(0.27 0.015 250);
  --tag-fg: oklch(0.82 0.012 250);
  --shadow-soft: 0 1px 0 oklch(0 0 0 / 0.45);
  --shadow-pop: 0 8px 28px -12px oklch(0 0 0 / 0.65), 0 2px 6px -2px oklch(0 0 0 / 0.5);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-ui);
  font-feature-settings: "ss01", "cv11";
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.005em;
}

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
a { color: inherit; }

.mono { font-family: var(--font-mono); font-feature-settings: "tnum", "zero"; letter-spacing: -0.01em; }
.tnum { font-variant-numeric: tabular-nums; }

/* ============================================
   App shell
   ============================================ */
.app {
  display: grid;
  grid-template-columns: 232px 1fr;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
  border-right: 1px solid var(--line);
  background: var(--surface-2);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 18px;
}
.brand-mark {
  width: 26px; height: 26px;
  border-radius: 6px;
  background: transparent;
  display: grid; place-items: center;
  color: var(--bg);
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 13px;
}
.brand-name {
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.01em;
}
.brand-name small {
  display: block;
  font-weight: 400;
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  margin-top: 1px;
}

.nav-section {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--ink-3);
  padding: 16px 10px 6px;
  font-weight: 500;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--r-sm);
  color: var(--ink-2);
  text-decoration: none;
  font-size: 13.5px;
  cursor: pointer;
  border: none;
  background: none;
  text-align: left;
  width: 100%;
  transition: background 0.12s;
}
.nav-item:hover { background: oklch(0.92 0.008 70); color: var(--ink); }
.nav-item.active {
  background: var(--ink);
  color: var(--bg);
}
.nav-item.active .nav-count { color: oklch(0.85 0.008 70); }
.nav-icon { width: 14px; height: 14px; display: inline-block; flex-shrink: 0; }
.nav-count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
}

.sidebar-foot {
  margin-top: auto;
  padding: 10px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--ink-3);
}

/* ---- Topbar ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 28px;
  height: 56px;
  background: oklch(0.965 0.008 80 / 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.crumbs {
  display: flex; align-items: baseline; gap: 8px;
  font-size: 13px;
}
.crumbs .sep { color: var(--ink-4); }
.crumbs .now { font-weight: 600; }
.topbar-spacer { flex: 1; }

.rate-pill {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 5px 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.rate-pill .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--pos); }
.rate-pill .val { font-weight: 600; }
.rate-pill .lab { color: var(--ink-3); }

.kbd {
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink-3);
}

/* ---- Page chrome ---- */
.page {
  padding: 24px 28px 64px;
  max-width: 1480px;
  margin: 0 auto;
}
.page-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 22px;
  gap: 24px;
}
.page-title {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.018em;
  margin: 0;
}
.page-sub {
  color: var(--ink-3);
  font-size: 13px;
  margin-top: 4px;
}
.page-actions { display: flex; gap: 8px; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.12s;
}
.btn:hover { background: var(--surface-2); border-color: var(--ink-3); }
.btn-primary {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}
.btn-primary:hover { background: oklch(0.30 0.012 60); border-color: oklch(0.30 0.012 60); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: oklch(0.92 0.008 70); }
.btn-danger { color: var(--neg); }
.btn-danger:hover { background: var(--neg-tint); border-color: var(--neg); }
.btn-sm { padding: 4px 9px; font-size: 12px; }
.btn-icon { padding: 6px; }

/* ---- Cards & panels ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.card-pad { padding: 18px 20px; }
.card-head {
  padding: 14px 20px;
  border-bottom: 1px solid var(--line-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.005em;
}
.card-sub {
  font-size: 11.5px;
  color: var(--ink-3);
}

/* ---- KPI ---- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  overflow: hidden;
}
.kpi {
  padding: 18px 22px;
  border-right: 1px solid var(--line-2);
}
.kpi:last-child { border-right: none; }
.kpi-clickable { cursor: pointer; transition: background 0.12s ease; }
.kpi-clickable:hover { background: var(--surface-2); }
.kpi-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-3);
  font-weight: 500;
}
.kpi-value {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin-top: 6px;
  display: flex;
  align-items: baseline;
  gap: 4px;
}
.kpi-value .unit {
  font-size: 13px;
  font-weight: 400;
  color: var(--ink-3);
  letter-spacing: 0;
}
.kpi-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--ink-3);
}
.delta { font-family: var(--font-mono); font-weight: 500; }
.delta.pos { color: var(--pos); }
.delta.neg { color: var(--neg); }

/* ---- Tables ---- */
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.tbl th {
  text-align: left;
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-3);
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  white-space: nowrap;
}
.tbl td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line-2);
  vertical-align: middle;
}
.tbl tr:last-child td { border-bottom: none; }
.tbl tr.clickable { cursor: pointer; }
.tbl tr.clickable:hover { background: var(--surface-2); }
.tbl .right { text-align: right; }
.tbl .num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.tbl .muted { color: var(--ink-3); }

/* ---- Badges & chips ---- */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--tag-bg);
  color: var(--tag-fg);
  border: 1px solid var(--line-2);
  font-weight: 500;
  white-space: nowrap;
}
.tag.tag-accent { background: var(--accent-tint); color: var(--accent); border-color: var(--accent-tint-strong); }
.tag.tag-pos { background: var(--pos-tint); color: var(--pos); border-color: oklch(0.85 0.04 150); }
.tag.tag-neg { background: var(--neg-tint); color: var(--neg); border-color: oklch(0.85 0.04 25); }
.tag.tag-warn { background: var(--warn-tint); color: var(--warn); border-color: oklch(0.85 0.05 65); }
.tag.tag-ghost { background: transparent; }

.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  display: inline-block;
}
.status-dot.delivered { background: var(--pos); }
.status-dot.in_transit { background: var(--warn); }
.status-dot.created { background: var(--ink-4); }
.status-dot.ordered { background: var(--accent); }
.status-dot.sold { background: var(--accent); }

/* ---- Currency display ---- */
.money {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  display: inline-flex;
  align-items: baseline;
  gap: 1px;
}
.money .cur { font-size: 0.78em; color: var(--ink-3); margin-right: 2px; font-weight: 400; }
.money.neg .amt { color: var(--neg); }
.money.pos .amt { color: var(--pos); }
.money-pair {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
}
.money-pair .jpy {
  font-family: var(--font-mono);
  color: var(--ink-3);
  font-size: 0.85em;
}

/* ---- Forms ---- */
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.field label {
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.input, .select, .textarea {
  width: 100%;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  color: var(--ink);
  font-size: 13px;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px oklch(0.36 0.085 250 / 0.12);
}
.input.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.input-suffix-wrap {
  position: relative;
  display: flex;
  align-items: stretch;
}
.input-suffix-wrap .input { padding-right: 36px; }
.input-suffix {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-3);
  font-size: 12px;
  font-family: var(--font-mono);
}

/* ---- Filter bar ---- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  margin-bottom: 14px;
}
.toolbar .toolbar-spacer { flex: 1; }
.search {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 4px 10px;
  width: 260px;
}
.search input {
  border: none; outline: none; background: none;
  flex: 1; font-size: 13px;
}
.tabs {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 2px;
  gap: 2px;
}
.tabs button {
  padding: 4px 12px;
  font-size: 12.5px;
  border: none;
  background: none;
  color: var(--ink-2);
  border-radius: 4px;
  font-weight: 500;
}
.tabs button.active { background: var(--ink); color: var(--bg); }
.tabs button:hover:not(.active) { background: var(--surface-2); }

/* ---- Drawer ---- */
.drawer-backdrop {
  position: fixed; inset: 0;
  background: oklch(0.20 0.012 60 / 0.32);
  z-index: 100;
  animation: fadeIn 0.15s ease;
}
.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(640px, 92vw);
  background: var(--surface);
  z-index: 101;
  border-left: 1px solid var(--line);
  box-shadow: -16px 0 40px -20px oklch(0.20 0.012 60 / 0.25);
  display: flex;
  flex-direction: column;
  animation: slideIn 0.22s cubic-bezier(.2,.7,.2,1);
}
.drawer.wide { width: min(820px, 96vw); }
.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
}
.drawer-title { font-size: 15px; font-weight: 600; }
.drawer-sub { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 22px; }
.drawer-foot {
  padding: 14px 22px;
  border-top: 1px solid var(--line);
  display: flex; gap: 8px; justify-content: flex-end;
  background: var(--surface-2);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ---- Dashboard specific ---- */
.dash-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  margin-top: 16px;
}
.dash-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}

/* Pipeline viz */
.pipeline {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  position: relative;
}
.pipeline-step {
  padding: 18px 18px 20px;
  border-right: 1px solid var(--line-2);
  position: relative;
}
.pipeline-step:last-child { border-right: none; }
.pipeline-step .ps-num {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-4);
  letter-spacing: 0.06em;
}
.pipeline-step .ps-title {
  font-size: 12.5px;
  font-weight: 600;
  margin-top: 2px;
}
.pipeline-step .ps-val {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 500;
  margin-top: 14px;
  letter-spacing: -0.01em;
}
.pipeline-step .ps-meta {
  font-size: 11px;
  color: var(--ink-3);
  margin-top: 4px;
  font-family: var(--font-mono);
}
.pipeline-arrow {
  position: absolute;
  right: -7px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px; height: 14px;
  background: var(--surface);
  border-top: 1px solid var(--line-2);
  border-right: 1px solid var(--line-2);
  transform: translateY(-50%) rotate(45deg);
  z-index: 2;
}
.pipeline-step:last-child .pipeline-arrow { display: none; }
.pipeline-step.highlight { background: var(--accent-tint); }

/* ---- Chart ---- */
.chart-wrap {
  padding: 14px 20px 18px;
  position: relative;
}
.chart-axis-y {
  font-family: var(--font-mono);
  font-size: 10px;
  fill: var(--ink-3);
}
.chart-axis-x {
  font-family: var(--font-mono);
  font-size: 10px;
  fill: var(--ink-3);
}
.chart-grid {
  stroke: var(--line-2);
  stroke-width: 1;
  stroke-dasharray: 2 3;
}
.chart-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.5;
}
.chart-line-cum {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.5;
}
.chart-area {
  fill: var(--accent);
  opacity: 0.06;
}
.chart-dot {
  fill: var(--surface);
  stroke: var(--accent);
  stroke-width: 1.5;
  cursor: pointer;
  transition: r 0.12s;
}
.chart-dot:hover, .chart-dot.active { fill: var(--accent); r: 4.5; }
.chart-tip {
  position: absolute;
  background: var(--ink);
  color: var(--bg);
  padding: 8px 12px;
  border-radius: var(--r-sm);
  font-size: 12px;
  pointer-events: none;
  white-space: nowrap;
  z-index: 4;
  box-shadow: var(--shadow-pop);
}
.chart-tip .tip-title { font-weight: 500; margin-bottom: 2px; }
.chart-tip .tip-meta { font-family: var(--font-mono); color: oklch(0.75 0.008 80); font-size: 11px; }

/* ---- Stock grid ---- */
.stock-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.series-card {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  padding: 14px 16px;
  transition: border-color 0.12s, transform 0.15s;
}
.series-card:hover { border-color: var(--line-strong); }
.series-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.series-name { font-weight: 600; font-size: 14px; }
.series-total {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.02em;
}
.series-bar {
  height: 6px;
  background: var(--line-2);
  border-radius: 3px;
  margin-top: 12px;
  display: flex;
  overflow: hidden;
}
.series-bar-seg { height: 100%; }
.series-bar-seg.np { background: var(--ink-4); }
.series-bar-seg.nh { background: var(--accent-2); }
.series-bar-seg.h  { background: var(--pos); }
.series-legend {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
  margin-top: 10px;
  font-size: 11.5px;
}
.series-legend .lg {
  display: flex; flex-direction: column;
}
.series-legend .lg-dot {
  display: inline-flex; align-items: center; gap: 5px;
  color: var(--ink-3);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.series-legend .lg-dot::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
}
.series-legend .lg.np .lg-dot::before { background: var(--ink-4); }
.series-legend .lg.nh .lg-dot::before { background: var(--accent-2); }
.series-legend .lg.h  .lg-dot::before { background: var(--pos); }
.series-legend .lg-val { font-family: var(--font-mono); font-weight: 500; margin-top: 1px; }

.series-meta-row {
  display: flex; justify-content: space-between;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  font-size: 11.5px;
  color: var(--ink-3);
}
.series-meta-row .mono { color: var(--ink-2); }

/* ---- Sale composer ---- */
.composer-grid {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 18px;
  height: 100%;
}
.basket-line {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  margin-bottom: 6px;
}
.basket-line .desc { font-size: 13px; }
.basket-line .cost { font-family: var(--font-mono); font-size: 12px; color: var(--ink-3); }
.basket-line .qty {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.basket-line .qty button {
  width: 22px; height: 22px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 4px;
  display: grid; place-items: center;
}
.basket-line .qty input {
  width: 38px; text-align: center;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px;
  font-family: var(--font-mono);
}

.stock-picker-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 10px;
  align-items: center;
  padding: 7px 10px;
  border-bottom: 1px solid var(--line-2);
  font-size: 13px;
}
.stock-picker-row:hover { background: var(--surface-2); }
.stock-picker-row .add {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 11.5px;
}
.stock-picker-row .add:hover { background: var(--ink); color: var(--bg); }
.stock-picker-row .avail { font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-3); width: 50px; text-align: right; }
.stock-picker-row .lab-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--bg-sunk);
  color: var(--ink-3);
  border: 1px solid var(--line-2);
}

/* Section subdiv */
.subhead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 22px 0 10px;
}
.subhead h3 {
  font-size: 14px;
  font-weight: 600;
  margin: 0;
}

/* Empty states */
.empty {
  text-align: center;
  padding: 36px 20px;
  color: var(--ink-3);
  font-size: 13px;
}

/* Detail key-value */
.kv {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 6px 16px;
  font-size: 13px;
}
.kv dt { color: var(--ink-3); font-weight: 500; }
.kv dd { margin: 0; font-family: var(--font-mono); }

/* Misc */
.divider { height: 1px; background: var(--line); margin: 18px 0; }
.flex-row { display: flex; align-items: center; gap: 10px; }
.flex-col { display: flex; flex-direction: column; gap: 8px; }
.space-between { justify-content: space-between; }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: var(--r-sm);
  font-size: 13px;
  box-shadow: var(--shadow-pop);
  z-index: 200;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  animation: toastIn 0.22s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* Overlay blur + spinner pendant action async (reste sur la page courante) */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.18);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  animation: fadeIn 0.15s ease;
}
.loading-spinner {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.25);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}
.loading-msg {
  color: #fff;
  font-size: 13px;
  letter-spacing: 0.04em;
  font-weight: 500;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Tiny sparkline */
.sparkline { width: 100%; height: 38px; }
.sparkline path { fill: none; stroke: var(--accent); stroke-width: 1.5; }
.sparkline .area { fill: var(--accent); opacity: 0.08; stroke: none; }

/* Receive workflow */
.receive-row {
  display: grid;
  grid-template-columns: 1.5fr 90px 1fr 110px;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line-2);
}
.receive-row:last-child { border: none; }
.receive-row .what { font-size: 13px; }
.receive-row .what small { display: block; color: var(--ink-3); font-size: 11px; margin-top: 1px; }
.receive-row .arrow { color: var(--ink-3); text-align: center; font-family: var(--font-mono); }
.receive-target {
  display: flex; gap: 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 3px;
  background: var(--surface);
}
.receive-target button {
  flex: 1;
  padding: 4px 8px;
  font-size: 11.5px;
  border: none;
  background: none;
  border-radius: 4px;
  color: var(--ink-3);
}
.receive-target button.active { background: var(--ink); color: var(--bg); }

/* v2 — wider, 4 targets */
.receive-row-v2 {
  display: grid;
  grid-template-columns: 1.6fr 1.4fr 70px;
  gap: 16px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--line-2);
}
.receive-row-v2 .what { align-self: stretch; display: flex; flex-direction: column; justify-content: center; }
.receive-row-v2 .receive-target-v2 { align-self: center; }
.receive-row-v2:last-child { border: none; }
.receive-row-v2 .what { font-size: 13px; font-weight: 500; }
.receive-row-v2 .what small { display: block; color: var(--ink-3); font-size: 11px; margin-top: 2px; font-weight: 400; }
.receive-target-v2 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  background: var(--bg-sunk);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 3px;
}
.receive-target-v2 button {
  border: none;
  background: none;
  border-radius: 5px;
  padding: 6px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  color: var(--ink-2);
  cursor: pointer;
  transition: all 0.12s;
}
.receive-target-v2 button:hover { background: var(--surface); }
.receive-target-v2 button.active { background: var(--ink); color: var(--bg); box-shadow: 0 1px 2px oklch(0.20 0.012 60 / 0.15); }
.receive-target-v2 .rtl-label { font-size: 12px; font-weight: 600; }
.receive-target-v2 .rtl-sub { font-size: 10px; opacity: 0.7; }

/* Subscription of width */
@media (max-width: 1100px) {
  .app { grid-template-columns: 64px 1fr; }
  .sidebar { padding: 14px 8px; }
  .brand-name, .nav-section, .nav-item span:not(.nav-icon), .nav-count, .sidebar-foot { display: none; }
  .nav-item { justify-content: center; padding: 8px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-grid { grid-template-columns: 1fr; }
  .pipeline { grid-template-columns: 1fr 1fr; }
}

/* Overlay blur + spinner pendant action async (reste sur la page courante) */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.18);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  animation: fadeIn 0.15s ease;
}
.loading-spinner {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.25);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}
.loading-msg {
  color: #fff;
  font-size: 13px;
  letter-spacing: 0.04em;
  font-weight: 500;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================
   Kebab menu / popover
   ============================================ */
.kebab-wrap {
  position: relative;
  display: inline-block;
}
.kebab-wrap .btn.is-active {
  background: var(--bg-sunk);
  border-color: var(--line-strong);
}
.menu-pop {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 30;
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-pop);
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  animation: menuPopIn 0.12s ease;
}
.menu-pop.up {
  top: auto;
  bottom: calc(100% + 4px);
  transform-origin: bottom right;
}
@keyframes menuPopIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  background: transparent;
  border: none;
  border-radius: var(--r-sm);
  color: var(--ink);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background 0.1s;
}
.menu-item:hover:not(:disabled) {
  background: var(--bg-sunk);
}
.menu-item:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.menu-item.danger {
  color: var(--neg);
}
.menu-item.danger:hover:not(:disabled) {
  background: var(--neg-tint);
}
.menu-icon {
  display: inline-flex;
  width: 16px;
  color: var(--ink-3);
}
.menu-item.danger .menu-icon { color: var(--neg); }

/* ============================================
   Adjust stock drawer
   ============================================ */
.adjust-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
}
.adjust-row-meta {
  min-width: 0;
}
.adjust-row-input {
  display: flex;
  align-items: center;
  gap: 6px;
}
.adjust-delta {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 500;
  min-width: 34px;
  text-align: right;
  margin-left: 4px;
}

/* Reason chip grid */
.reason-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.reason-chip {
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 8px 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: border-color 0.1s, background 0.1s;
}
.reason-chip:hover {
  border-color: var(--line-strong);
}
.reason-chip.is-active {
  border-color: var(--accent);
  background: var(--accent-tint);
}
.reason-chip.is-active .reason-label { color: var(--accent); }
.reason-label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink);
}
.reason-help {
  font-size: 10.5px;
  color: var(--ink-3);
  line-height: 1.3;
}

/* ============================================
   Form sections (multi-section drawers)
   ============================================ */
.form-section {
  border-top: 1px dashed var(--line);
  padding-top: 18px;
  margin-top: 18px;
}
.form-section:first-child {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
}
.form-section-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}
.form-section-num {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent-tint);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  display: grid;
  place-items: center;
}
.form-section-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
}
.form-section-sub {
  font-size: 11.5px;
  color: var(--ink-3);
  margin-top: 1px;
}

/* Currency segmented toggle */
.cur-toggle {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 3px;
  background: var(--bg-sunk);
  gap: 2px;
}
.cur-toggle button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: transparent;
  border: none;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}
.cur-toggle button:hover { color: var(--ink); }
.cur-toggle button.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px oklch(0.20 0.012 60 / 0.08);
}
.cur-toggle .cur-sym {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--accent);
}

/* Item line editor */
.item-editor {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.item-editor-head,
.item-editor-row {
  display: grid;
  grid-template-columns: 1.7fr 1.3fr 70px 140px 30px;
  gap: 8px;
  align-items: center;
}
.item-editor-head {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-3);
  font-weight: 500;
  padding: 0 2px 4px;
}
.item-editor-head .right { text-align: right; }
.item-editor-row .input.right,
.item-editor-row .input.mono.right { text-align: right; }
.item-editor-row .line-total {
  text-align: right;
  font-size: 13px;
  color: var(--ink-2);
  padding: 0 4px;
}
.item-editor-add {
  align-self: flex-start;
  margin-top: 8px;
  color: var(--accent);
  border-color: var(--accent-tint-strong);
  background: var(--accent-tint);
}
.item-editor-add:hover {
  background: var(--accent-tint-strong);
}

/* Recap card */
.recap-card {
  margin-top: 24px;
  padding: 14px 16px;
  background: var(--bg-sunk);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.recap-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13px;
  padding: 4px 0;
  color: var(--ink-2);
}
.recap-row .recap-eur {
  color: var(--ink-3);
  font-size: 11.5px;
  margin-left: 6px;
}
.recap-row .recap-cur {
  color: var(--ink-3);
  font-size: 11.5px;
  margin-right: 10px;
}
.recap-row-total {
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 14px;
  color: var(--ink);
  font-weight: 500;
}
.recap-row-total b {
  font-size: 16px;
  font-weight: 600;
}

/* Form overlay (creating...) */
.form-overlay {
  position: absolute;
  inset: 0;
  background: oklch(0.965 0.008 80 / 0.78);
  backdrop-filter: blur(3px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 100;
  color: var(--ink-2);
  font-size: 13.5px;
  font-weight: 500;
  animation: overlayIn 0.18s ease;
}
.form-overlay.light {
  background: oklch(0.985 0.006 80 / 0.85);
}
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }

/* Spinner */
.spinner, .spinner-lg {
  display: inline-block;
  border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-right-color: currentColor;
  animation: spinnerRotate 0.7s linear infinite;
}
.spinner { width: 12px; height: 12px; border-width: 1.5px; }
.spinner-lg {
  width: 28px;
  height: 28px;
  color: var(--accent);
}
@keyframes spinnerRotate { to { transform: rotate(360deg); } }

/* Drawer body needs to be relative for overlay */
.drawer-body { position: relative; }

/* ============================================
   Import Mercari drawer specifics
   ============================================ */
.import-explainer {
  margin-top: 20px;
  padding: 14px 16px;
  background: var(--bg-sunk);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-md);
  font-size: 12.5px;
  color: var(--ink-2);
}
.import-explainer-head {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 8px;
}
.import-explainer ul {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.import-explainer-foot {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  color: var(--ink-3);
  font-size: 11.5px;
}
.scraped-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  background: var(--pos-tint);
  color: var(--pos);
  border-radius: var(--r-sm);
  font-size: 12.5px;
  margin-bottom: 16px;
}
.scraped-preview {
  display: flex;
  gap: 14px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.scraped-thumb {
  width: 80px;
  height: 80px;
  flex-shrink: 0;
  border-radius: var(--r-sm);
  background: repeating-linear-gradient(45deg, var(--surface-2), var(--surface-2) 6px, var(--bg-sunk) 6px, var(--bg-sunk) 12px);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  color: var(--ink-4);
  font-family: var(--font-mono);
  font-size: 10.5px;
}
.scraped-meta {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
}
.scraped-jp {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink);
}
.scraped-fr {
  font-size: 12px;
  color: var(--ink-3);
  font-style: italic;
}
.scraped-seller {
  display: flex;
  gap: 8px;
  font-size: 11.5px;
  margin-top: 4px;
}

/* --- Splash PokeBank --- */
.pb-splash{position:fixed;inset:0;z-index:9999;display:flex;align-items:center;justify-content:center;background:radial-gradient(120% 120% at 50% 30%, var(--surface) 0%, var(--bg) 72%);}
.pb-splash-inner{display:flex;flex-direction:column;align-items:center;gap:18px;}
.pb-ball{transform-origin:50% 50%;animation:pbBob 1.6s ease-in-out infinite;filter:drop-shadow(0 10px 22px rgba(20,20,35,.22));}
[data-theme="dark"] .pb-ball{filter:drop-shadow(0 0 26px rgba(255,255,255,.12)) drop-shadow(0 10px 22px rgba(0,0,0,.55));}
@keyframes pbBob{0%,100%{transform:translateY(0) rotate(-7deg)}50%{transform:translateY(-12px) rotate(7deg)}}
.pb-wordmark{font-family:'Inter Tight',system-ui,sans-serif;font-weight:800;font-size:30px;letter-spacing:-0.5px;color:var(--ink);}
.pb-wordmark span{color:var(--ink);}
.pb-sub{font-family:'Inter Tight',system-ui,sans-serif;font-size:12px;letter-spacing:1.5px;text-transform:uppercase;color:var(--ink-3);animation:pbPulse 1.6s ease-in-out infinite;}
@keyframes pbPulse{0%,100%{opacity:.4}50%{opacity:.9}}
