/* Al-Alwan identity (alwanasp.com): red #bd1e2d, charcoal, slate #253d4e for data. */
:root {
  --bg: #f6f6f7;
  --card: #ffffff;
  --ink: #232122;
  --ink-2: #5f5b5d;
  --muted: #6f6b6d;
  --faint: #8a8688;
  --line: #ebe9ea;
  --line-2: #e6e4e5;
  --hover: #f6f6f7;
  --side: #232122;
  --side-text: #c9c5c7;
  --side-faint: #8c8789;
  --red: #bd1e2d;
  --red-dark: #8f1520;
  --red-soft: #fbeced;
  --slate: #253d4e;
  --slate-2: #9cb6c8;
  --slate-soft: #e9eff3;
  --good: #157a48;
  --good-soft: #e5f4ec;
  --warn: #9a5a00;
  --warn-soft: #fdf1dc;
  --mark: #fff1b8;
  /* stock age, fresh to old */
  --age-1: #1f6f8b;
  --age-2: #6aa7bd;
  --age-3: #e3ac4f;
  --age-4: #c9761b;
  --age-5: #8a3c00;
  --radius: 16px;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --shadow-lift: 0 10px 28px rgb(35 33 34 / .08);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.6 'Cairo', system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; }
h1 { font-size: 28px; font-weight: 800; line-height: 1.35; }
h2 { font-size: 18px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 700; }
a { color: var(--red); text-decoration: none; transition: color .15s; }
a:hover { color: var(--red-dark); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 2px; }
.icon { width: 1.15em; height: 1.15em; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.num { text-align: end; white-space: nowrap; font-variant-numeric: tabular-nums; }
.sku { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--faint); direction: ltr; unicode-bidi: isolate; }
.muted { color: var(--muted); font-size: 13px; margin: 0; }
.unit { font-size: .55em; font-weight: 500; color: var(--faint); margin-inline-start: 4px; }

/* ---------------------------------------------------------------- controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 16px;
  border: 1px solid var(--line-2); border-radius: 12px; background: var(--card); color: var(--ink);
  font-size: 14px; font-weight: 600; white-space: nowrap; transition: border-color .15s, background .15s, transform .15s var(--ease);
}
.btn:hover { border-color: var(--ink); color: var(--ink); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary:hover { background: var(--red-dark); border-color: var(--red-dark); color: #fff; }
.btn.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--red); padding: 0 8px; }
.btn.icon-only { width: 44px; padding: 0; }
.btn:disabled { opacity: .45; cursor: default; }
.field, select.field { height: 44px; border: 1px solid var(--line-2); border-radius: 12px; padding: 0 14px; background: var(--card); min-width: 0; transition: border-color .15s, box-shadow .15s; }
.field:focus, select.field:focus { outline: 0; border-color: var(--ink); box-shadow: 0 0 0 3px rgb(35 33 34 / .08); }
.segmented { display: inline-flex; background: var(--card); border: 1px solid var(--line-2); border-radius: 12px; padding: 4px; gap: 2px; position: relative; }
.segmented button { border: 0; background: transparent; color: var(--muted); font-size: 13px; padding: 0 14px; height: 36px; border-radius: 8px; transition: background .2s var(--ease), color .2s; }
.segmented button:hover { color: var(--ink); }
.segmented button[aria-pressed=true] { background: var(--ink); color: #fff; font-weight: 700; }
.segmented.soft { background: #f3f2f3; border-color: transparent; }
.segmented.soft button[aria-pressed=true] { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / .08); }
.pill { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; padding: 2px 10px; border-radius: 999px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.pill.good, .pill.in { background: var(--good-soft); color: var(--good); }
.pill.warn, .pill.low { background: var(--warn-soft); color: var(--warn); }
.pill.bad, .pill.out { background: var(--red-soft); color: var(--red); }
.pill.plain { background: #f3f2f3; color: var(--ink-2); }
.pill.slate { background: var(--slate-soft); color: var(--slate); }
.tag { display: inline-block; font-size: 12px; font-weight: 700; color: var(--slate); background: var(--slate-soft); border-radius: 6px; padding: 1px 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 0; background: var(--red-soft); color: var(--red); font-size: 13px; font-weight: 600; border-radius: 999px; padding: 0 12px; height: 34px; transition: background .15s; }
.chip:hover { background: #f6d7da; }
.chip .icon { width: 14px; height: 14px; }
.note { display: flex; align-items: flex-start; gap: 10px; background: var(--slate-soft); color: var(--slate); border-radius: 12px; padding: 12px 16px; font-size: 13px; }
.note.warn { background: var(--warn-soft); color: var(--warn); }
.note.bad { background: var(--red-soft); color: var(--red); }
.note .icon { margin-top: 3px; }

/* ---------------------------------------------------------------- shell */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  flex: 0 0 248px; background: var(--side); color: var(--side-text); display: flex; flex-direction: column; gap: 24px;
  padding: 24px 16px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar .logo { height: 52px; width: auto; align-self: flex-start; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.nav-group { font-size: 11px; font-weight: 600; color: var(--side-faint); padding: 18px 12px 6px; }
.nav-group:first-child { padding-top: 0; }
.nav-link {
  position: relative; display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: 10px;
  color: var(--side-text); font-size: 14px; transition: background .2s var(--ease), color .2s;
}
.nav-link .icon { width: 20px; height: 20px; stroke-width: 1.8; }
.nav-link:hover { background: rgb(255 255 255 / .05); color: #fff; }
.nav-link.active { background: rgb(255 255 255 / .08); color: #fff; font-weight: 700; }
.nav-link.active::before { content: ''; position: absolute; inset-inline-start: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 3px; background: var(--red); animation: grow-y .35s var(--ease); }
.nav-badge { margin-inline-start: auto; background: var(--red); color: #fff; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 8px; }
.sync-card { margin-top: auto; background: rgb(255 255 255 / .06); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: #a9a4a6; }
.sync-card b { display: flex; align-items: center; gap: 8px; color: #fff; font-size: 13px; font-weight: 600; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #3ccf86; box-shadow: 0 0 0 0 rgb(60 207 134 / .6); animation: pulse 2.4s infinite; flex: none; }
.dot.bad { background: var(--red); animation: none; }
.dot.busy { background: #e3ac4f; }
.user { display: flex; align-items: center; gap: 10px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--red); color: #fff; display: grid; place-items: center; font-weight: 700; flex: none; }
.user b { display: block; color: #fff; font-size: 13px; font-weight: 600; line-height: 1.3; }
.user small { color: #a9a4a6; font-size: 12px; }
.user button { margin-inline-start: auto; width: 44px; height: 44px; border: 0; border-radius: 10px; background: transparent; color: #a9a4a6; display: grid; place-items: center; transition: background .15s, color .15s; }
.user button:hover { background: rgb(255 255 255 / .06); color: #fff; }

.main { flex: 1; min-width: 0; padding: 28px clamp(16px, 3vw, 40px) 48px; }
.view { display: flex; flex-direction: column; gap: 22px; max-width: 1480px; margin: 0 auto; }
.mobile-bar, .tabbar { display: none; }

/* ---------------------------------------------------------------- page */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; position: relative; z-index: 20; }
.page-head .lead { display: flex; flex-direction: column; gap: 4px; max-width: 680px; }
.page-head .lead > span { font-size: 14px; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.quick-search { display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--line-2); border-radius: 12px; padding: 0 14px; height: 44px; width: 320px; max-width: 100%; color: var(--faint); transition: border-color .15s, box-shadow .15s; }
.quick-search:focus-within { border-color: var(--ink); box-shadow: 0 0 0 3px rgb(35 33 34 / .08); }
.quick-search input { border: 0; outline: 0; flex: 1; min-width: 0; font-size: 14px; background: transparent; color: var(--ink); }
.kbd { font-size: 11px; border: 1px solid var(--line-2); border-radius: 6px; padding: 0 6px; direction: ltr; }
.bell { position: relative; }
.bell .badge-dot { position: absolute; top: 9px; inset-inline-end: 10px; width: 8px; height: 8px; background: var(--red); border-radius: 50%; border: 2px solid #fff; }
.popover-wrap { position: relative; }
.popover { position: absolute; top: calc(100% + 8px); inset-inline-end: 0; width: 340px; max-width: calc(100vw - 32px); background: var(--card); border: 1px solid var(--line-2); border-radius: 14px; box-shadow: 0 18px 40px rgb(35 33 34 / .14); padding: 10px; z-index: 30; animation: pop .2s var(--ease); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-head > div:not([class]) { display: flex; flex-direction: column; gap: 2px; }
.card.flush .card-head { padding: 18px 22px 0; }
.more { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 600; min-height: 32px; }
.more .icon { width: 16px; height: 16px; transition: transform .2s var(--ease); }
.more:hover .icon { transform: translateX(-3px); }
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }
.cols-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.row { display: flex; flex-wrap: wrap; gap: 16px; align-items: stretch; }
.row > .wide { flex: 2 1 560px; }
.row > .narrow { flex: 1 1 320px; }

/* ---------------------------------------------------------------- stats */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.kpis.five { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.mobile-only { display: none !important; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; gap: 12px; transition: transform .25s var(--ease), box-shadow .25s var(--ease), border-color .2s; min-width: 0; color: var(--ink); }
a.kpi:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); color: var(--ink); }
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kpi-label { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-2); font-weight: 600; }
.kpi-label .icon { width: 18px; height: 18px; color: var(--faint); }
.kpi-value { font-size: 30px; font-weight: 800; line-height: 1.2; letter-spacing: -.01em; white-space: nowrap; }
.kpi-foot { font-size: 12px; color: var(--faint); }
.kpi.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.kpi.dark .kpi-label, .kpi.dark .kpi-foot, .kpi.dark .unit, .kpi.dark .kpi-label .icon { color: #c9c5c7; }
.kpi.dark:hover { color: #fff; }
.kpi.warn .kpi-value { color: var(--warn); }
.kpi.bad .kpi-value { color: var(--red); }
.delta { font-size: 12px; font-weight: 700; padding: 2px 10px; border-radius: 999px; direction: ltr; white-space: nowrap; }
.delta.up { background: var(--good-soft); color: var(--good); }
.delta.down { background: var(--red-soft); color: var(--red); }
.delta.flat { background: #f1f0f1; color: var(--ink-2); }
.meter { height: 6px; background: #f0eff0; border-radius: 3px; overflow: hidden; }
.kpi.dark .meter { background: rgb(255 255 255 / .12); }
.meter > span { display: block; height: 100%; border-radius: 3px; background: var(--slate); transform-origin: right; animation: grow-x .9s var(--ease) both; }
.meter > span.amber { background: var(--age-3); }
.meter > span.bad { background: var(--red); }
.meter > span.warn { background: var(--warn); }

.spark { display: flex; align-items: flex-end; gap: 3px; height: 36px; direction: ltr; }
.spark span { flex: 1; border-radius: 3px 3px 0 0; background: #e3e1e2; transform-origin: bottom; animation: grow-y .7s var(--ease) both; }
.spark span.last { background: var(--slate); }
.spark span.last.amber { background: var(--age-4); }
.spark.empty { background: repeating-linear-gradient(90deg, #f0eff0 0 6px, transparent 6px 9px); border-radius: 4px; height: 6px; margin-top: 30px; }

/* ---------------------------------------------------------------- charts */
.cols { display: flex; gap: 12px; }
.cols-axis { display: flex; flex-direction: column; justify-content: space-between; font-size: 11px; color: var(--faint); height: var(--h); padding-bottom: 24px; direction: ltr; text-align: left; font-variant-numeric: tabular-nums; }
.cols-axis span { line-height: 0; }
.cols-plot { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.cols-bars {
  height: calc(var(--h) - 24px); display: flex; align-items: flex-end; gap: 6px; direction: ltr; border-bottom: 1px solid var(--line-2);
  background-image: linear-gradient(#efeeef 1px, transparent 1px); background-size: 100% calc(100% / var(--rows));
}
.cols-slot { flex: 1; height: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 2px; border-radius: 4px; transition: background .15s; }
.cols-slot:hover { background: rgb(37 61 78 / .06); }
.col { flex: 1; max-width: 22px; border-radius: 4px 4px 0 0; background: var(--slate); transform-origin: bottom; animation: grow-y .8s var(--ease) both; animation-delay: calc(var(--i) * 18ms); }
.cols.accent .cols-slot:last-child .col:first-child { background: var(--red); }
.col.soft { background: var(--slate-2); }
.cols-x { display: flex; gap: 6px; font-size: 11px; color: var(--faint); direction: ltr; }
.cols-x span { flex: 1; text-align: center; white-space: nowrap; }
.chart-empty { color: var(--faint); text-align: center; padding: 48px 16px; margin: 0; font-size: 14px; }
.legend { display: flex; gap: 18px; font-size: 13px; color: var(--ink-2); flex-wrap: wrap; }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; background: var(--slate); }
.legend i.soft { background: var(--slate-2); }
.chart-tip { position: fixed; z-index: 100; pointer-events: none; background: var(--ink); color: #fff; border-radius: 8px; padding: 6px 10px; font-size: 12px; line-height: 1.5; max-width: 260px; box-shadow: 0 8px 20px rgb(0 0 0 / .18); }

.hbars { display: flex; flex-direction: column; gap: 4px; }
.hbar { display: grid; grid-template-columns: minmax(90px, 150px) minmax(0, 1fr) minmax(70px, auto); align-items: center; gap: 12px; font-size: 13px; padding: 6px 8px; border-radius: 8px; color: var(--ink); transition: background .15s; }
.hbar.link:hover { background: var(--hover); color: var(--ink); }
.hbar-label { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-value { text-align: end; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.track { height: 12px; background: #f3f2f3; border-radius: 6px; overflow: hidden; }
.fill { display: block; height: 100%; background: var(--slate); border-radius: 6px; transform-origin: right; animation: grow-x .9s var(--ease) both; animation-delay: calc(var(--i, 0) * 60ms); }
.fill.amber { background: var(--age-4); }
.fill.none { background: #d9d7d8; }
.fill.age-1 { background: var(--age-1); } .fill.age-2 { background: var(--age-2); } .fill.age-3 { background: var(--age-3); } .fill.age-4 { background: var(--age-4); } .fill.age-5 { background: var(--age-5); }

.stack { display: flex; height: 16px; border-radius: 8px; overflow: hidden; gap: 2px; }
.stack span { transform-origin: right; animation: grow-x .9s var(--ease) both; }
.stack .age-1, .swatch .age-1 { background: var(--age-1); } .stack .age-2, .swatch .age-2 { background: var(--age-2); } .stack .age-3, .swatch .age-3 { background: var(--age-3); } .stack .age-4, .swatch .age-4 { background: var(--age-4); } .stack .age-5, .swatch .age-5 { background: var(--age-5); }
.swatches { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px 18px; margin-top: 16px; }
.swatch { display: flex; align-items: flex-start; gap: 8px; color: var(--ink); border-radius: 8px; padding: 4px; transition: background .15s; }
a.swatch:hover { background: var(--hover); color: var(--ink); }
.swatch i { width: 10px; height: 10px; border-radius: 3px; margin-top: 6px; flex: none; }
.swatch span { display: flex; flex-direction: column; font-size: 13px; color: var(--ink-2); }
.swatch b { font-size: 15px; color: var(--ink); }

/* ---------------------------------------------------------------- lists & tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: start; font-size: 12px; font-weight: 700; color: var(--muted); padding: 12px 8px; white-space: nowrap; background: #faf9fa; }
.table th:first-child, .table td:first-child { padding-inline-start: 22px; }
.table th:last-child, .table td:last-child { padding-inline-end: 22px; }
.table.plain th { background: transparent; padding-top: 4px; }
.table.plain th:first-child, .table.plain td:first-child { padding-inline-start: 0; }
.table.plain th:last-child, .table.plain td:last-child { padding-inline-end: 0; }
.table td { padding: 12px 8px; border-top: 1px solid #f0eff0; vertical-align: middle; }
.table tbody tr { transition: background .15s; animation: fade-in .4s var(--ease) both; animation-delay: calc(var(--i, 0) * 25ms); }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover { background: #faf9fa; }
.table tbody tr.selected { background: #fffdf5; }
.table th.num, .table td.num { text-align: end; }
.table input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--red); margin: 0; }
.prod { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; }
.prod b { font-weight: 700; color: var(--ink); }
.prod-rank { display: flex; align-items: center; gap: 12px; }
.rank { width: 28px; height: 28px; border-radius: 8px; background: #f3f2f3; display: grid; place-items: center; font-size: 12px; font-weight: 800; color: var(--ink-2); flex: none; }
.cover { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.cover .meter { width: 56px; }
.idle { display: flex; align-items: center; gap: 8px; min-width: 150px; }
.idle b { width: 64px; flex: none; }
.idle .meter { flex: 1; }
.trend { display: flex; align-items: flex-end; gap: 2px; height: 24px; width: 100px; direction: ltr; }
.trend span { flex: 1; background: var(--slate-2); border-radius: 2px 2px 0 0; transform-origin: bottom; animation: grow-y .7s var(--ease) both; }
.empty { text-align: center; color: var(--faint); padding: 32px 16px !important; }
.pager { display: flex; justify-content: center; align-items: center; gap: 6px; padding: 16px; flex-wrap: wrap; }
.pager button { min-width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--card); font-weight: 600; transition: background .15s, border-color .15s; }
.pager button:hover:not(:disabled) { border-color: var(--ink); }
.pager button:disabled { opacity: .4; cursor: default; }
.pager button[aria-current=page] { background: var(--ink); border-color: var(--ink); color: #fff; }
.pager span { color: var(--faint); padding: 0 4px; }

.action-list { display: flex; flex-direction: column; gap: 10px; }
.action { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 12px; background: #f3f2f3; color: var(--ink); min-height: 44px; transition: transform .2s var(--ease), box-shadow .2s; }
.action:hover { color: var(--ink); transform: translateX(-3px); box-shadow: 0 4px 14px rgb(35 33 34 / .06); }
.action .count { width: 42px; height: 42px; border-radius: 10px; background: #fff; display: grid; place-items: center; font-weight: 800; font-size: 13px; flex: none; }
.action .text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.action .text b { font-size: 14px; }
.action .text small { font-size: 12px; color: var(--ink-2); }
.action.bad { background: var(--red-soft); } .action.bad .count { color: var(--red); }
.action.warn { background: var(--warn-soft); } .action.warn .count { color: var(--warn); }
.action.slate { background: var(--slate-soft); } .action.slate .count { color: var(--slate); }
.action > .icon { color: var(--faint); }

.wh-list { display: flex; flex-direction: column; gap: 10px; }
.wh { display: flex; flex-direction: column; gap: 6px; color: var(--ink); border-radius: 10px; padding: 6px 8px; margin: 0 -8px; transition: background .15s; }
a.wh:hover { background: var(--hover); color: var(--ink); }
.wh-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 14px; font-weight: 700; }
.wh-meta { display: flex; gap: 16px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.wh-meta .amber { color: var(--warn); }
.wh .track { height: 8px; }

.ideas { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.idea { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: flex; gap: 14px; align-items: flex-start; color: var(--ink); transition: transform .25s var(--ease), box-shadow .25s var(--ease); }
.idea:hover { color: var(--ink); transform: translateY(-3px); box-shadow: var(--shadow-lift); }
.idea .badge { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.idea .badge .icon { width: 22px; height: 22px; }
.idea .badge.slate { background: var(--slate-soft); color: var(--slate); }
.idea .badge.warn { background: var(--warn-soft); color: var(--warn); }
.idea .badge.bad { background: var(--red-soft); color: var(--red); }
.idea .text { display: flex; flex-direction: column; gap: 4px; }
.idea b { font-size: 15px; }
.idea small { font-size: 13px; color: var(--ink-2); }
.idea .go { font-size: 13px; font-weight: 700; color: var(--red); margin-top: 4px; }

.reorder-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid #f0eff0; color: var(--ink); }
.reorder-item:hover { color: var(--ink); }
.reorder-item .text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.reorder-item b { font-size: 14px; }
.reorder-item small { font-size: 12px; color: var(--faint); }
.qty-badge { display: flex; flex-direction: column; align-items: center; background: var(--ink); color: #fff; border-radius: 10px; padding: 4px 12px; min-width: 56px; line-height: 1.3; }
.qty-badge b { font-size: 16px; }
.qty-badge small { font-size: 10px; color: #c9c5c7; }

/* ---------------------------------------------------------------- search */
.search-panel { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 16px; display: flex; flex-direction: column; gap: 12px; z-index: 5; }
.search-row { display: flex; gap: 10px; }
.search-input { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; border: 2px solid var(--line-2); border-radius: 14px; padding: 0 12px 0 16px; height: 56px; transition: border-color .2s, box-shadow .2s; }
.search-input:focus-within { border-color: var(--ink); box-shadow: 0 0 0 4px rgb(35 33 34 / .06); }
.search-input input { border: 0; outline: 0; flex: 1; min-width: 0; font-size: 17px; font-weight: 600; background: transparent; }
.search-input input::-webkit-search-cancel-button { display: none; }
.search-input .clear { width: 36px; height: 36px; border: 0; border-radius: 50%; background: #f3f2f3; color: var(--ink-2); display: grid; place-items: center; }
.mic { width: 56px; height: 56px; border: 0; border-radius: 14px; background: var(--red); color: #fff; display: grid; place-items: center; flex: none; transition: transform .15s var(--ease), background .15s; }
.mic:hover { background: var(--red-dark); }
.mic.listening { animation: listen 1.2s infinite; }
.capabilities { display: flex; flex-wrap: wrap; gap: 8px; }
.capabilities span { font-size: 12px; font-weight: 600; color: var(--slate); background: var(--slate-soft); border-radius: 999px; padding: 3px 12px; }
.synonym-note { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); animation: fade-in .3s var(--ease); }
.synonym-note .icon { color: var(--slate); }
.suggest { position: absolute; top: 80px; inset-inline: 16px 82px; background: var(--card); border: 1px solid var(--line-2); border-radius: 14px; box-shadow: 0 18px 40px rgb(35 33 34 / .14); padding: 8px; display: flex; flex-direction: column; animation: pop .18s var(--ease); z-index: 10; }
.suggest h4 { margin: 0; font-size: 11px; font-weight: 700; color: var(--faint); padding: 8px 10px 4px; }
.suggest button { display: flex; align-items: center; gap: 12px; width: 100%; border: 0; background: transparent; padding: 0 10px; min-height: 44px; border-radius: 10px; text-align: start; transition: background .12s; }
.suggest button:hover, .suggest button.active { background: var(--hover); }
.suggest .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.suggest .price { width: 84px; text-align: end; font-weight: 700; }
.search-layout { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.filters { flex: 1 1 260px; max-width: 300px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 20px; position: sticky; top: 16px; }
.filters-head { display: flex; justify-content: space-between; align-items: center; }
.filters-head h2 { font-size: 16px; display: flex; align-items: center; gap: 8px; }
.filters fieldset { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.filters legend { font-size: 13px; font-weight: 700; color: var(--ink-2); margin-bottom: 8px; padding: 0; }
.filters label.check { display: flex; align-items: center; gap: 10px; min-height: 40px; font-size: 14px; cursor: pointer; border-radius: 8px; padding: 0 4px; transition: background .12s; }
.filters label.check:hover { background: var(--hover); }
.filters label.check span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filters label.check small { font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
.filters input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--red); margin: 0; }
.stock-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.stock-grid button { border: 1px solid var(--line-2); background: #fff; border-radius: 10px; min-height: 44px; font-size: 13px; transition: all .15s; }
.stock-grid button small { color: var(--faint); }
.stock-grid button[aria-pressed=true] { background: var(--ink); border-color: var(--ink); color: #fff; font-weight: 700; }
.stock-grid button[aria-pressed=true] small { color: #c9c5c7; }
.price-range { display: flex; gap: 8px; }
.price-range label { flex: 1; display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.price-range input { height: 40px; width: 100%; }
.results { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.results-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.results-head > div:first-child { display: flex; flex-direction: column; }
.results-head b { font-size: 16px; }
.results-head small { font-size: 12px; color: var(--faint); }
.view-toggle { display: flex; border: 1px solid var(--line-2); border-radius: 12px; overflow: hidden; background: #fff; }
.view-toggle button { width: 44px; height: 42px; border: 0; background: #fff; color: var(--faint); display: grid; place-items: center; transition: background .15s, color .15s; }
.view-toggle button[aria-pressed=true] { background: #f3f2f3; color: var(--ink); }
.active-filters { display: flex; flex-wrap: wrap; gap: 8px; }
.active-filters:empty { display: none; }
.stock-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.stock-chip { font-size: 12px; border-radius: 8px; padding: 2px 8px; font-weight: 600; background: var(--good-soft); color: var(--good); white-space: nowrap; }
.stock-chip.low { background: var(--warn-soft); color: var(--warn); }
.result-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.result-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 10px; text-align: start; transition: transform .2s var(--ease), box-shadow .2s; animation: fade-in .35s var(--ease) both; animation-delay: calc(var(--i, 0) * 25ms); cursor: pointer; }
.result-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.result-card .top { display: flex; gap: 10px; align-items: flex-start; }
.result-card .name { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; font-size: 15px; font-weight: 700; line-height: 1.5; }
.result-card .price { display: flex; flex-direction: column; align-items: flex-end; }
.result-card .price b { font-size: 17px; }
.result-card .price small { font-size: 11px; color: var(--faint); white-space: nowrap; }

/* ---------------------------------------------------------------- drawer */
.drawer { position: fixed; inset: 0; z-index: 50; }
.drawer-backdrop { position: absolute; inset: 0; background: rgb(35 33 34 / .45); animation: fade .25s ease both; }
.drawer-panel { position: absolute; top: 0; bottom: 0; inset-inline-start: 0; width: min(640px, 100%); background: var(--card); box-shadow: -24px 0 60px rgb(0 0 0 / .18); display: flex; flex-direction: column; overflow-y: auto; animation: slide-in .38s var(--ease) both; }
.drawer.closing .drawer-panel { animation: slide-out .22s ease-in both; }
.drawer.closing .drawer-backdrop { animation: fade-out .22s ease both; }
.drawer-head { padding: 22px 28px 18px; border-bottom: 1px solid #f0eff0; display: flex; gap: 12px; align-items: flex-start; position: sticky; top: 0; background: var(--card); z-index: 1; }
.drawer-head .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.drawer-head h2 { font-size: 22px; font-weight: 800; line-height: 1.4; }
.drawer-head .tags { display: flex; flex-wrap: wrap; gap: 6px; }
.drawer-body { padding: 22px 28px 32px; display: flex; flex-direction: column; gap: 24px; }
.drawer-body section { display: flex; flex-direction: column; gap: 10px; }
.drawer-body section.facts { display: grid; }
.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.fact { background: var(--bg); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; animation: rise .4s var(--ease) both; animation-delay: calc(var(--i, 0) * 40ms + 120ms); }
.fact span { font-size: 12px; color: var(--muted); }
.fact b { font-size: 20px; font-weight: 800; }
.fact.dark { background: var(--ink); color: #fff; } .fact.dark span, .fact.dark .unit { color: #c9c5c7; }
.fact.bad { background: var(--red-soft); } .fact.bad b { color: var(--red); }
.fact.warn b { color: var(--warn); }
.stock-row { display: flex; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; }
.stock-row > .icon { color: var(--faint); width: 20px; height: 20px; }
.stock-row .grow { flex: 1; display: flex; flex-direction: column; }
.stock-row b { font-size: 14px; }
.stock-row small { font-size: 12px; color: var(--faint); }
.qty-bars { height: 120px; display: flex; align-items: flex-end; gap: 4px; direction: ltr; border-bottom: 1px solid var(--line-2); }
.qty-bars span { flex: 1; background: var(--slate-2); border-radius: 3px 3px 0 0; transform-origin: bottom; animation: grow-y .7s var(--ease) both; animation-delay: calc(var(--i) * 15ms + 200ms); }
.qty-bars span:last-child { background: var(--red); }
.timeline-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid #f0eff0; }
.delta-dot { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none; font-weight: 800; font-size: 13px; direction: ltr; }
.delta-dot.out { background: var(--red-soft); color: var(--red); }
.delta-dot.in { background: var(--good-soft); color: var(--good); }
.timeline-item .grow { flex: 1; display: flex; flex-direction: column; }
.timeline-item small { font-size: 12px; color: var(--faint); }
.drawer-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.drawer-actions .btn { flex: 1; min-width: 180px; height: 48px; }

/* ---------------------------------------------------------------- forms */
.form { display: flex; flex-direction: column; gap: 16px; max-width: 560px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; }
.form textarea { min-height: 160px; border: 1px solid var(--line-2); border-radius: 12px; padding: 12px 14px; line-height: 1.9; resize: vertical; }
.form textarea:focus { outline: 0; border-color: var(--ink); }
.saved { border-color: var(--good) !important; box-shadow: 0 0 0 3px var(--good-soft) !important; }
details summary { cursor: pointer; color: var(--red); font-size: 14px; font-weight: 600; }

/* ---------------------------------------------------------------- login */
.login { min-height: 100vh; display: flex; flex-wrap: wrap; background: #fff; }
.login-form { flex: 1 1 420px; display: flex; align-items: center; justify-content: center; padding: 48px 24px; }
.login-form form { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 20px; animation: rise .6s var(--ease) both; }
.login-form img { height: 72px; width: auto; align-self: flex-start; margin-inline-start: -12px; }
.login-form label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; }
.login-form .field { height: 52px; font-size: 15px; }
.login-form .btn { height: 52px; font-size: 16px; }
.password { display: flex; align-items: center; height: 52px; border: 1px solid var(--line-2); border-radius: 12px; transition: border-color .15s, box-shadow .15s; }
.password:focus-within { border-color: var(--ink); box-shadow: 0 0 0 3px rgb(35 33 34 / .08); }
.password input { flex: 1; min-width: 0; border: 0; outline: 0; height: 100%; padding: 0 14px; background: transparent; font-size: 15px; }
.password button { width: 44px; height: 44px; border: 0; background: transparent; color: var(--muted); display: grid; place-items: center; }
.login-error { color: var(--red); font-size: 14px; margin: 0; animation: shake .4s; }
.login-brand { flex: 1 1 520px; background: var(--side); color: #fff; display: flex; flex-direction: column; justify-content: space-between; padding: 56px; position: relative; overflow: hidden; min-height: 420px; }
.login-brand .shape { position: absolute; inset-inline-end: -120px; bottom: -140px; width: 520px; height: 520px; border: 64px solid rgb(189 30 45 / .22); border-radius: 48px; animation: drift 18s ease-in-out infinite alternate; }
.login-brand img { height: 56px; width: auto; align-self: flex-start; position: relative; }
.login-brand .copy { position: relative; display: flex; flex-direction: column; gap: 18px; max-width: 460px; animation: rise .8s .15s var(--ease) both; }
.login-brand h2 { font-size: 34px; font-weight: 800; line-height: 1.4; }
.login-brand p { margin: 0; font-size: 16px; color: #c9c5c7; line-height: 1.8; }
.login-brand .facts-row { display: flex; flex-wrap: wrap; gap: 28px; margin-top: 8px; }
.login-brand .facts-row b { display: block; font-size: 26px; font-weight: 800; }
.login-brand .facts-row small { font-size: 13px; color: #a9a4a6; }

/* ---------------------------------------------------------------- loading */
.skeleton { display: flex; flex-direction: column; gap: 16px; }
.skeleton div { border-radius: 16px; background: linear-gradient(90deg, #efeeef 25%, #f7f6f7 50%, #efeeef 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite linear; }
.loading { opacity: .55; transition: opacity .2s; pointer-events: none; }

/* ---------------------------------------------------------------- motion */
.view > * { animation: rise .5s var(--ease) both; animation-delay: calc(var(--i, 0) * 55ms); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes grow-x { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes grow-y { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes pop { from { opacity: 0; transform: translateY(-6px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes slide-in { from { transform: translateX(100%); } to { transform: none; } }
@keyframes slide-out { from { transform: none; } to { transform: translateX(100%); } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgb(60 207 134 / .55); } 70% { box-shadow: 0 0 0 8px rgb(60 207 134 / 0); } 100% { box-shadow: 0 0 0 0 rgb(60 207 134 / 0); } }
@keyframes listen { 0%, 100% { box-shadow: 0 0 0 0 rgb(189 30 45 / .5); } 50% { box-shadow: 0 0 0 10px rgb(189 30 45 / 0); } }
@keyframes shake { 0%, 100% { transform: none; } 25% { transform: translateX(6px); } 75% { transform: translateX(-6px); } }
@keyframes drift { from { transform: rotate(45deg); } to { transform: rotate(52deg) translate(-30px, 20px); } }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------------------------------------------------------------- phone */
@media (max-width: 900px) {
  .sidebar { display: none; }
  .shell { flex-direction: column; }
  .main { padding: 0 0 96px; }
  .view { padding: 18px 16px; gap: 18px; }
  .mobile-bar { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
  .mobile-bar img { height: 40px; width: auto; margin-inline-start: -8px; }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); position: fixed; bottom: 0; inset-inline: 0; z-index: 40;
    background: rgb(255 255 255 / .96); backdrop-filter: blur(10px); border-top: 1px solid var(--line); padding: 6px 4px calc(10px + env(safe-area-inset-bottom));
  }
  .tabbar a, .tabbar button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 52px; font-size: 11px; color: var(--muted); border: 0; background: transparent; transition: color .15s; }
  .tabbar .icon { width: 22px; height: 22px; transition: transform .2s var(--ease); }
  .tabbar .active { color: var(--red); font-weight: 700; }
  .tabbar .active .icon { transform: translateY(-2px); }
  .sheet { position: fixed; inset: 0; z-index: 60; }
  .sheet-panel { position: absolute; bottom: 0; inset-inline: 0; background: #fff; border-radius: 20px 20px 0 0; padding: 10px 16px calc(20px + env(safe-area-inset-bottom)); animation: sheet-up .3s var(--ease) both; }
  .sheet-panel::before { content: ''; display: block; width: 40px; height: 4px; border-radius: 2px; background: #dcdadb; margin: 0 auto 12px; }
  .sheet-panel a, .sheet-panel button.link-row { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 0 8px; color: var(--ink); font-size: 15px; border-radius: 10px; width: 100%; border: 0; background: transparent; }
  .sheet-panel .icon { color: var(--muted); }
  h1 { font-size: 24px; }
  .page-head { align-items: stretch; }
  .page-head .desktop-only { display: none; }
  .actions { width: 100%; }
  .actions .segmented { width: 100%; }
  .actions .segmented button { flex: 1; }
  .quick-search { width: 100%; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 14px; gap: 6px; }
  .kpi.hero { grid-column: 1 / -1; }
  .kpi-value { font-size: 22px; }
  .kpi.hero .kpi-value { font-size: 32px; }
  .kpi .spark, .kpi .kpi-top .delta { display: none; }
  .kpi.hero .kpi-top .delta { display: inline; }
  .card { padding: 16px; }
  .card.flush .card-head { padding: 16px 16px 0; }
  .table th:first-child, .table td:first-child { padding-inline-start: 16px; }
  .table th:last-child, .table td:last-child { padding-inline-end: 16px; }
  .filters { position: static; max-width: none; display: none; }
  .filters.open { display: flex; animation: pop .2s var(--ease); }
  .mobile-only { display: inline-flex !important; }
  .search-panel { padding: 12px; }
  .search-input { height: 50px; }
  .mic { width: 50px; height: 50px; }
  .suggest { top: 70px; inset-inline: 12px; }
  .view-toggle { display: none; }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .drawer-panel { width: 100%; }
  .drawer-head, .drawer-body { padding-inline: 18px; }
  .hbar { grid-template-columns: 90px minmax(0, 1fr) auto; }
  .login-brand { display: none; }
}
