:root {
  --ground: #F4F5F7; --surface: #FFFFFF; --line: #E3E6EB; --line-soft: #EEF0F3; --input: #C5CAD3;
  --ink: #14171F; --ink-2: #2B303B; --ink-3: #3B4357; --muted: #5B6270; --faint: #8A909C;
  --brand: #1F2A6B; --brand-soft: #E9ECF8; --link: #1F3FAE;
  --down: #1D4ED8; --up: #A1460A;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--ground); color: var(--ink); font-family: 'IBM Plex Sans', system-ui, sans-serif;
  font-size: 14px; font-variant-numeric: tabular-nums; }
a { color: var(--link); }
a:hover { color: #16307F; }
h1 { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -0.01em; }
h2 { margin: 0; font-size: 16px; font-weight: 600; }
.sub { margin: 6px 0 0; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Layout */
.shell { min-height: 100vh; display: flex; flex-wrap: wrap; align-items: stretch; }
.side { flex: 1 1 220px; padding: 20px 14px; background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 24px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px; text-decoration: none; color: var(--ink); }
.brand b { display: block; font-size: 15px; }
.brand span { font-size: 12px; color: var(--muted); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 10px 12px; border-radius: 8px;
  text-decoration: none; font-weight: 500; color: var(--ink-2); }
.nav a:hover { background: #F2F4FA; color: var(--ink); }
.nav a[aria-current="page"] { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav svg, .icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
.content { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 32px; background: var(--surface); border-bottom: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.topbar strong { color: var(--ink); font-weight: 600; }
.user { display: flex; align-items: center; gap: 8px; min-height: 44px; text-decoration: none; color: var(--ink); font-weight: 500; }
.avatar { width: 32px; height: 32px; border-radius: 999px; background: var(--brand); color: #fff; display: flex;
  align-items: center; justify-content: center; font-size: 12px; font-weight: 600; text-transform: uppercase; }
main { width: 100%; max-width: 1240px; padding: 28px 32px 48px; display: flex; flex-direction: column; gap: 20px; }
main.narrow { max-width: 900px; }
.row { display: flex; flex-wrap: wrap; gap: 16px; }
.head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 20px; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.card.flush .card-head { margin: 0; padding: 14px 16px; border-bottom: 1px solid var(--line-soft); }
.card-foot { padding: 12px 16px; border-top: 1px solid var(--line-soft); color: var(--muted); font-size: 13px;
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; }
.kpi { flex: 1 1 220px; padding: 18px 20px; }
.kpi .label { font-size: 13px; color: var(--muted); font-weight: 500; }
.kpi .value { font-size: 30px; font-weight: 700; margin-top: 6px; }
.kpi .note { font-size: 13px; color: var(--muted); margin-top: 4px; }
.grow2 { flex: 2 1 560px; min-width: 0; }
.grow1 { flex: 1 1 280px; min-width: 0; }
.banner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px; border-radius: 12px; background: #EEF2FF; border: 1px solid #C9D3F5; color: var(--ink-3); }
.banner b { color: var(--brand); display: block; font-size: 15px; }
.banner code, code.cmd { font-size: 13px; padding: 8px 12px; border-radius: 8px; background: #fff; border: 1px solid #C9D3F5; color: var(--brand); }
.notice { padding: 12px 16px; border-radius: 8px; background: #E8F1FF; color: #1E40AF; font-weight: 500; }
.error { padding: 12px 16px; border-radius: 8px; background: #FDECEA; color: #8F1D14; font-weight: 500; }
.empty { padding: 32px 16px; text-align: center; color: var(--muted); }

/* Tables */
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em;
  font-weight: 600; padding: 10px 8px; background: #FAFBFC; white-space: nowrap; }
td { padding: 10px 8px; border-top: 1px solid var(--line-soft); vertical-align: middle; }
th:first-child, td:first-child { padding-left: 16px; }
th:last-child, td:last-child { padding-right: 16px; }
.plain th { background: none; padding-left: 0; }
.plain td:first-child, .plain th:first-child { padding-left: 0; }
.plain td:last-child, .plain th:last-child { padding-right: 0; }
.num { text-align: right; white-space: nowrap; }
.strong { font-weight: 600; }
.title-link { color: var(--ink); text-decoration: none; font-weight: 500; }
.title-link:hover { color: var(--link); text-decoration: underline; }
.down { color: var(--down); font-weight: 600; }
.up { color: var(--up); font-weight: 600; }
.was { color: var(--muted); text-decoration: line-through; }

/* Pills */
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.pill-in, .pill-ok { background: #E8F1FF; color: #1E40AF; }
.pill-order, .pill-suspect { background: #FFF4E5; color: #8A4206; }
.pill-pre { background: #F1ECFF; color: #5B21B6; }
.pill-out { background: #EEF0F3; color: #4B5563; }
.pill-failed { background: #FDECEA; color: #8F1D14; }
.pill-running { background: #F1ECFF; color: #5B21B6; }
.pill-sample { background: #FFF4E5; color: #8A4206; }
.kind { display: inline-block; min-width: 120px; text-align: center; font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 6px; }
.k-price_down { background: #E8F1FF; color: #1E40AF; }
.k-price_up { background: #FFF1E6; color: #9A3412; }
.k-promo { background: #EEF2FF; color: #3730A3; }
.k-out_of_stock { background: #EEF0F3; color: #374151; }
.k-back_in_stock { background: #E6F4F1; color: #115E59; }
.k-new_listing { background: #F1ECFF; color: #5B21B6; }
.k-removed { background: #F3F4F6; color: #4B5563; }

/* Forms */
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 600; color: var(--ink-3); }
input[type=text], input[type=search], input[type=password], input[type=number], select {
  height: 44px; padding: 0 12px; border: 1px solid var(--input); border-radius: 8px; font: inherit; font-size: 14px;
  background: #fff; color: var(--ink); width: 100%; }
input:focus, select:focus, button:focus-visible, a:focus-visible { outline: 3px solid #A9B8EE; outline-offset: 1px; }
.check { display: flex; align-items: center; gap: 8px; min-height: 40px; font-size: 13px; font-weight: 500; color: var(--ink); }
.check input { width: 18px; height: 18px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px;
  border-radius: 8px; border: 1px solid var(--input); background: #fff; color: var(--ink); font: inherit; font-size: 14px;
  font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { background: #F7F8FA; color: var(--ink); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #18225A; color: #fff; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 13px; }
.link-btn { border: 0; background: none; padding: 10px 0; font: inherit; font-size: 13px; color: var(--link); cursor: pointer; }
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; padding: 16px; }
.filters > .field { flex: 1 1 160px; }
.filters > .field.wide { flex: 3 1 260px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 8px; min-height: 38px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--input); background: #fff; color: var(--ink-2); font-size: 13px; font-weight: 600; text-decoration: none; }
.chip:hover { color: var(--ink); background: #F7F8FA; }
.chip[aria-current="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip .count { font-size: 12px; padding: 1px 7px; border-radius: 999px; background: #EEF0F3; color: var(--ink-3); }
.chip[aria-current="true"] .count { background: #3A4785; color: #fff; }
.star { width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; border: 0;
  background: none; cursor: pointer; color: var(--faint); padding: 0; border-radius: 8px; }
.star:hover { background: #F7F8FA; }
.star.on { color: #B45309; }
.star.on svg { fill: #F5B544; }
.pager { display: flex; gap: 8px; }

/* Charts */
.bars { display: flex; align-items: flex-end; gap: 4px; height: 170px; padding-top: 8px; border-bottom: 1px solid #D5D9E0; }
.bars span { flex: 1 1 0; background: #9AA8DB; border-radius: 3px 3px 0 0; min-height: 2px; }
.bars span.today { background: var(--brand); }
.axis { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 6px; }
.chart { width: 100%; height: auto; font-family: 'IBM Plex Sans', system-ui, sans-serif; }
.chart .tick { font-size: 12px; fill: var(--muted); }
.chart .end-label { font-size: 13px; font-weight: 600; }
.strip { display: flex; gap: 2px; }
.strip span { flex: 1 1 0; height: 20px; border-radius: 2px; background: #F2F3F6; }
.s-in_stock, .s-ok { background: #3558D6 !important; }
.s-on_order, .s-preorder, .s-suspect { background: #F0B35A !important; }
.s-out_of_stock { background: #C9CED6 !important; }
.s-failed { background: #8F1D14 !important; }
.s-running { background: #A78BFA !important; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--ink-3); }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }

/* Compare cells */
.cell { display: inline-block; min-width: 96px; padding: 6px 10px; border-radius: 8px; text-align: right; font-weight: 600; }
.cell small { display: block; font-size: 11px; font-weight: 500; color: var(--muted); }
.cell.best { background: var(--brand); color: #fff; font-weight: 700; }
.cell.best small { color: #D7DCF5; }
.cell.dim { background: #F2F3F6; color: var(--muted); }
.cell.none { color: var(--faint); font-weight: 400; }
.mine { background: #F7F8FA; }

/* Auth pages */
.auth { min-height: 100vh; padding: 48px 16px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px; }
.auth .card { width: 100%; max-width: 420px; padding: 32px; display: flex; flex-direction: column; gap: 18px; }
.auth .card.wide { max-width: 640px; }
.auth h1 { font-size: 22px; }
.code-input { height: 52px !important; font-size: 24px !important; letter-spacing: 0.3em; text-align: center; }
.qr { width: 200px; height: 200px; flex: 0 0 auto; }
.qr svg { width: 100%; height: 100%; }
.codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 16px; background: #F7F8FA;
  border: 1px solid var(--line); border-radius: 10px; font-family: 'IBM Plex Mono', ui-monospace, monospace; font-size: 16px; }
.secret { font-family: 'IBM Plex Mono', ui-monospace, monospace; font-size: 15px; letter-spacing: 0.06em; color: var(--ink); word-break: break-all; }

@media (max-width: 720px) {
  main { padding: 20px 16px 40px; }
  .topbar { padding: 10px 16px; }
  .side { border-right: 0; border-bottom: 1px solid var(--line); gap: 12px; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav a { flex: 1 1 140px; }
}
@media print {
  .side, .topbar, .filters, .star, .pager { display: none !important; }
}
