/* StoreCount — ledger-paper design system
   Palette: warm paper, deep pine ink, mint accent.
   Numbers are always tabular. Rules are hairlines, not boxes. */

:root {
  --paper: #f5f4ee;
  --surface: #ffffff;
  --surface-2: #fbfaf5;
  --surface-3: #f1efe7;
  --ink: #111a15;
  --ink-2: #3b4a42;
  --muted: #6b7a71;
  --faint: #93a097;
  --line: #e3e0d5;
  --line-2: #d2cec0;
  --pine: #0e5a42;
  --pine-2: #14795a;
  --mint: #e7f2ec;
  --mint-2: #cfe6da;
  --amber: #8f5f13;
  --amber-bg: #fbf0da;
  --red: #a33a2b;
  --red-bg: #fae8e4;
  --slate: #2b4a5e;
  --slate-bg: #e8eff4;
  --violet: #5a4780;
  --violet-bg: #eeeaf7;
  --rail: #0d1512;
  --rail-2: #16211c;
  --rail-line: #24312a;
  --rail-ink: #cfdad3;
  --rail-muted: #7f9188;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 22px;

  --sans: "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont, "Inter", "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Mono", "SF Mono", "Roboto Mono", ui-monospace, Consolas, monospace;

  --shadow-1: 0 1px 2px rgba(17, 26, 21, .04), 0 1px 1px rgba(17, 26, 21, .03);
  --shadow-2: 0 8px 24px -12px rgba(17, 26, 21, .22), 0 2px 6px rgba(17, 26, 21, .05);
  --shadow-3: 0 24px 60px -24px rgba(17, 26, 21, .38), 0 8px 18px -12px rgba(17, 26, 21, .2);

  --rail-w: 232px;
  --top-h: 64px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* faint paper grain + vignette */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(1200px 600px at 78% -10%, rgba(14, 90, 66, .05), transparent 62%),
    radial-gradient(900px 500px at 12% 108%, rgba(143, 95, 19, .045), transparent 60%);
}

h1, h2, h3, h4, p, figure { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
svg { fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

.num, .tnum { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.skip {
  position: absolute; left: -999px; top: 8px; z-index: 999;
  background: var(--ink); color: #fff; padding: 8px 14px; border-radius: 8px;
}
.skip:focus { left: 8px; }

:focus-visible {
  outline: 2px solid var(--pine-2);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ---------- shell ---------- */
.shell {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

.rail {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background: var(--rail);
  color: var(--rail-ink);
  padding: 20px 14px 16px;
  border-right: 1px solid var(--rail-line);
}

.brand { display: flex; gap: 11px; align-items: center; padding: 6px 8px 22px; }

.brand-mark {
  width: 34px; height: 34px; flex: none;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px;
  padding: 7px; border-radius: 10px;
  background: linear-gradient(150deg, #1c3a2e, #132019);
  border: 1px solid #2c463a;
}
.brand-mark i { background: #4f8f74; border-radius: 1.5px; opacity: .55; }
.brand-mark i:nth-child(2), .brand-mark i:nth-child(4), .brand-mark i:nth-child(9) { opacity: 1; background: #8fe0be; }
.brand-mark i:nth-child(9) { background: #e8b04a; }

.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 15px; letter-spacing: -.01em; color: #f1f7f3; font-weight: 650; }
.brand-text small { font-size: 10.5px; color: var(--rail-muted); letter-spacing: .04em; text-transform: uppercase; }

.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 11px; border-radius: 9px;
  color: var(--rail-ink); font-size: 13.5px; font-weight: 500;
  position: relative; transition: background .16s ease, color .16s ease;
}
.nav a svg { width: 18px; height: 18px; opacity: .8; }
.nav a:hover { background: var(--rail-2); color: #fff; }
.nav a.is-active { background: #1a2a22; color: #fff; }
.nav a.is-active::before {
  content: ""; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 3px;
  background: #8fe0be; border-radius: 0 3px 3px 0;
}
.nav a.is-active svg { opacity: 1; color: #8fe0be; }

.rail-foot { margin-top: auto; padding: 14px 8px 2px; border-top: 1px solid var(--rail-line); }
.sync { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--rail-muted); }
.sync .dot { width: 6px; height: 6px; border-radius: 50%; background: #7fd1a6; box-shadow: 0 0 0 3px rgba(127, 209, 166, .12); }
.sync.is-warn .dot { background: #e8b04a; box-shadow: 0 0 0 3px rgba(232, 176, 74, .12); }
.rail-store { font-size: 11px; color: #6d7f76; margin-top: 7px; letter-spacing: .05em; text-transform: uppercase; }

/* ---------- main ---------- */
.main { min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--top-h);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 clamp(16px, 3vw, 34px);
  background: rgba(245, 244, 238, .86);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: 8px; }

.crumb {
  font-size: 12px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.period-pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 11px; border: 1px solid var(--line-2); border-radius: 999px;
  background: var(--surface); font-size: 12px; color: var(--ink-2);
  font-variant-numeric: tabular-nums; white-space: nowrap; cursor: pointer;
}
.period-pill svg { width: 14px; height: 14px; color: var(--muted); }
.period-pill:hover { border-color: var(--pine-2); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px; border-radius: 9px;
  border: 1px solid transparent; background: var(--surface); color: var(--ink);
  font-size: 13px; font-weight: 550; white-space: nowrap;
  transition: background .15s ease, border-color .15s ease, transform .06s ease, box-shadow .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--pine); color: #fff; box-shadow: 0 1px 0 rgba(0,0,0,.06); }
.btn-primary:hover { background: #0b4b37; }
.btn-ghost { background: transparent; border-color: var(--line-2); }
.btn-ghost:hover { background: var(--surface); border-color: var(--ink-2); }
.btn-soft { background: var(--mint); color: var(--pine); border-color: transparent; }
.btn-soft:hover { background: var(--mint-2); }
.btn-danger { background: var(--red-bg); color: var(--red); }
.btn-danger:hover { background: #f6d8d2; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; border-radius: 7px; }
.btn-lg { height: 46px; padding: 0 20px; font-size: 14.5px; border-radius: 11px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.icon-btn {
  width: 36px; height: 36px; display: inline-grid; place-items: center;
  border: 1px solid var(--line-2); background: var(--surface); border-radius: 9px;
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover { border-color: var(--ink-2); }

#view { padding: clamp(18px, 2.4vw, 30px) clamp(16px, 3vw, 34px) 40px; flex: 1; outline: none; }

.foot {
  display: flex; justify-content: space-between; gap: 14px;
  padding: 14px clamp(16px, 3vw, 34px) 18px;
  border-top: 1px solid var(--line);
  font-size: 11.5px; color: var(--faint);
}
.foot-meta { font-variant-numeric: tabular-nums; }

/* ---------- page header ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: clamp(24px, 3vw, 32px); font-weight: 620; letter-spacing: -.025em; line-height: 1.12; }
.page-head .sub { margin-top: 6px; color: var(--muted); font-size: 13px; max-width: 62ch; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.eyebrow {
  font-size: 10.5px; font-weight: 650; letter-spacing: .14em; text-transform: uppercase;
  color: var(--faint); margin-bottom: 8px; display: flex; align-items: center; gap: 8px;
}
.eyebrow::before { content: ""; width: 14px; height: 1px; background: var(--line-2); }

/* dashboard dispo filter tabs */
.dash-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  margin: 0 0 16px;
  padding-bottom: 2px;
  scrollbar-width: none;
}
.dash-tabs::-webkit-scrollbar { display: none; }
.dash-tab {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  padding: 8px 12px 7px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 8px 8px 0 0;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 550;
  white-space: nowrap;
}
.dash-tab small { font-size: 10.5px; color: var(--faint); font-weight: 500; font-variant-numeric: tabular-nums; }
.dash-tab:hover { background: var(--surface-2); color: var(--ink); }
.dash-tab.is-active { color: var(--pine); border-bottom-color: var(--pine); background: var(--mint); }
.dash-tab.is-active small { color: var(--pine-2); }

/* ---------- cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
}
.card-pad { padding: clamp(16px, 2vw, 22px); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.card-head h2 { font-size: 14px; font-weight: 620; letter-spacing: -.005em; }
.card-head .hint { font-size: 12px; color: var(--muted); }

.grid { display: grid; gap: 14px; }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 14px; align-items: start; }

/* KPI */
.kpi { position: relative; padding: 18px 18px 16px; overflow: hidden; }
.kpi-label { display: flex; align-items: center; gap: 7px; font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.kpi-label .glyph { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; background: var(--surface-3); color: var(--ink-2); }
.kpi-label .glyph svg { width: 13px; height: 13px; }
.kpi-value { margin-top: 12px; font-size: clamp(24px, 2.4vw, 31px); font-weight: 620; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1.05; }
.kpi-value small { font-size: 12px; font-weight: 550; color: var(--muted); letter-spacing: 0; margin-left: 5px; }
.kpi-foot { margin-top: 10px; display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.kpi-meter { margin-top: 13px; height: 4px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.kpi-meter i { display: block; height: 100%; border-radius: 99px; background: var(--pine-2); transition: width .5s cubic-bezier(.2,.7,.2,1); }
.kpi.is-warn .kpi-value { color: var(--amber); }
.kpi.is-bad .kpi-value { color: var(--red); }
.kpi.is-good .kpi-value { color: var(--pine); }

.delta { display: inline-flex; align-items: center; gap: 3px; font-size: 11.5px; font-weight: 600; padding: 1px 6px; border-radius: 5px; font-variant-numeric: tabular-nums; }
.delta.up { color: var(--pine); background: var(--mint); }
.delta.down { color: var(--red); background: var(--red-bg); }
.delta.flat { color: var(--muted); background: var(--surface-3); }

/* ---------- chips / status ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 8px; border-radius: 6px;
  font-size: 11px; font-weight: 600; letter-spacing: .01em; white-space: nowrap;
  background: var(--surface-3); color: var(--ink-2);
}
.chip .dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .85; }
.chip.good { background: var(--mint); color: var(--pine); }
.chip.bad { background: var(--red-bg); color: var(--red); }
.chip.warn { background: var(--amber-bg); color: var(--amber); }
.chip.info { background: var(--slate-bg); color: var(--slate); }
.chip.mute { background: var(--surface-3); color: var(--muted); }
.chip.violet { background: var(--violet-bg); color: var(--violet); }
.chip.sku { font-family: var(--mono); background: var(--surface-3); color: var(--ink); letter-spacing: .02em; }
.chip.lg { height: 26px; padding: 0 10px; font-size: 11.5px; }

/* ---------- tables ---------- */
.table-wrap { overflow: auto; border-radius: 0 0 var(--r-lg) var(--r-lg); }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface-2);
  text-align: left; font-size: 10.5px; font-weight: 650; letter-spacing: .09em; text-transform: uppercase;
  color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
thead th.r, td.r { text-align: right; }
tbody td { padding: 10px 12px; border-bottom: 1px solid #f0eee6; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fcfbf7; }
tbody tr.is-click { cursor: pointer; }
td .desc { font-weight: 550; color: var(--ink); }
td .sub { font-size: 11.5px; color: var(--faint); margin-top: 1px; }
td.num { font-variant-numeric: tabular-nums; }
.pos { color: var(--pine); }
.neg { color: var(--red); }

.table-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.pager { display: flex; gap: 6px; align-items: center; }

.table-compact th, .table-compact td { padding: 9px 8px; }
.table-compact th { font-size: 9.5px; letter-spacing: .07em; }
.table-compact td { font-size: 12.5px; }

/* bar inside table */
.tbar { display: flex; align-items: center; gap: 8px; min-width: 92px; }
.tbar .track { flex: 1; height: 4px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.tbar .fill { height: 100%; border-radius: 99px; background: var(--pine-2); }
.tbar .fill.warn { background: #c58a2c; }
.tbar .pct { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; width: 30px; text-align: right; }

/* ---------- toolbar / filters ---------- */
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.search {
  position: relative; flex: 1 1 240px; max-width: 380px;
}
.search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--faint); }
.search input {
  width: 100%; height: 36px; padding: 0 12px 0 32px;
  border: 1px solid var(--line-2); border-radius: 9px; background: var(--surface);
  font-size: 13px;
}
.search input::placeholder { color: var(--faint); }
.search input:focus { outline: none; border-color: var(--pine-2); box-shadow: 0 0 0 3px rgba(20, 121, 90, .1); }

.seg { display: inline-flex; background: var(--surface-3); border-radius: 9px; padding: 3px; gap: 2px; }
.seg button {
  border: 0; background: transparent; padding: 5px 11px; border-radius: 7px;
  font-size: 12px; font-weight: 550; color: var(--muted);
}
.seg button.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
.seg button .n { font-size: 10.5px; color: var(--faint); margin-left: 4px; font-variant-numeric: tabular-nums; }

.select {
  height: 36px; border: 1px solid var(--line-2); border-radius: 9px; background: var(--surface);
  padding: 0 30px 0 11px; font-size: 12.5px; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 20 20' fill='none' stroke='%236b7a71' stroke-width='1.8'%3E%3Cpath d='M5 8l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.dash-toolbar { margin: -2px 0 18px; }
.dash-toolbar .select { min-width: 260px; }

/* ---------- dispo cards ---------- */
.dispo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); gap: 14px; }
.dispo-card { padding: 17px 18px 15px; display: flex; flex-direction: column; gap: 12px; transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease; }
.dispo-card:hover { border-color: var(--line-2); box-shadow: var(--shadow-2); transform: translateY(-1px); }
.dispo-card .top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.dispo-card h3 { font-size: 15px; font-weight: 620; letter-spacing: -.01em; }
.dispo-card .meta { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.dispo-stats { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.dispo-stats div { display: flex; flex-direction: column; gap: 1px; }
.dispo-stats span { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
.dispo-stats strong { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.ring { position: relative; width: 44px; height: 44px; flex: none; }
.ring svg { width: 44px; height: 44px; transform: rotate(-90deg); }
.ring .bg { stroke: var(--surface-3); }
.ring .fg { stroke: var(--pine-2); stroke-linecap: round; transition: stroke-dashoffset .6s ease; }
.ring span { position: absolute; inset: 0; display: grid; place-items: center; font-size: 10.5px; font-weight: 650; font-variant-numeric: tabular-nums; }

/* ---------- list rows ---------- */
.rows { display: flex; flex-direction: column; }
.scroll-wrap { position: relative; min-width: 0; }
.sheet-scroll {
  max-height: 224px;
  overflow-y: scroll;
  overscroll-behavior: contain;
  scrollbar-width: none;
}
.sheet-scroll::-webkit-scrollbar { width: 0; height: 0; }
.sheet-scroll:focus-visible { outline: 2px solid var(--pine-2); outline-offset: -2px; }
.scroll-rail {
  position: absolute;
  top: 6px;
  bottom: 6px;
  right: 5px;
  width: 7px;
  border-radius: 99px;
  background: var(--surface-3);
  pointer-events: none;
  opacity: 0;
  transition: opacity .18s ease;
}
.scroll-rail.is-on { opacity: 1; }
.scroll-rail i {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 40px;
  border-radius: 99px;
  background: var(--line-2);
}
.row-item { display: flex; align-items: center; gap: 12px; padding: 11px 16px; border-bottom: 1px solid #f0eee6; }
.row-item:last-child { border-bottom: 0; }
.row-item:hover { background: var(--surface-2); }
.row-item .grow { flex: 1; min-width: 0; }
.row-item .t { font-size: 12.5px; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-item .s { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.row-item .v { font-variant-numeric: tabular-nums; font-size: 12.5px; text-align: right; white-space: nowrap; }

.empty { padding: 38px 22px; text-align: center; color: var(--muted); }
.empty .glyph { width: 44px; height: 44px; border-radius: 12px; background: var(--surface-3); display: grid; place-items: center; margin: 0 auto 12px; color: var(--faint); }
.empty h3 { font-size: 14px; color: var(--ink); font-weight: 600; margin-bottom: 4px; }
.empty p { font-size: 12.5px; max-width: 42ch; margin: 0 auto; }

/* ---------- count screen ---------- */
.count-wrap { max-width: 760px; margin: 0 auto; }
.count-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.count-head h1 { font-size: 22px; font-weight: 620; letter-spacing: -.02em; }
.count-progress { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); }
.count-progress .track { width: 120px; height: 5px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.count-progress .fill { height: 100%; background: var(--pine-2); border-radius: 99px; transition: width .4s ease; }

.scan-card { padding: 18px; }
.scan-field { display: flex; gap: 8px; }
.scan-field .btn { padding-left: 10px; padding-right: 10px; }
.scan-field .btn svg { flex: none; width: 20px; height: 20px; }
#scan-region { position: relative; }
#scan-region video { width: 100% !important; height: 100% !important; object-fit: cover; }
.scan-input {
  flex: 1; min-width: 0; height: 54px; border: 1.5px solid var(--line-2); border-radius: 12px;
  background: var(--surface); padding: 0 16px;
  font-family: var(--mono); font-size: 20px; letter-spacing: .06em;
}
.scan-input::placeholder { font-family: var(--sans); font-size: 14px; letter-spacing: 0; color: var(--faint); }
.scan-input:focus { outline: none; border-color: var(--pine); box-shadow: 0 0 0 4px rgba(20, 121, 90, .12); }

.item-card { margin-top: 14px; padding: 20px; }
.item-card .top { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.item-card h2 { font-size: clamp(18px, 2.4vw, 22px); font-weight: 620; letter-spacing: -.02em; line-height: 1.2; }
.item-card .sku-line { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; flex-wrap: wrap; }
.item-card .facts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 16px 0 4px; padding-top: 14px; border-top: 1px solid var(--line); }
.item-card .facts div { display: flex; flex-direction: column; gap: 2px; }
.item-card .facts span { font-size: 10px; letter-spacing: .09em; text-transform: uppercase; color: var(--faint); }
.item-card .facts strong { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }

.count-entry { margin-top: 18px; display: grid; grid-template-columns: minmax(0, 1fr) 252px; gap: 16px; align-items: start; }
.count-display {
  border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2);
  padding: 14px 18px 16px;
}
.count-display label { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.count-input {
  width: 100%; border: 0; background: transparent; padding: 4px 0 0;
  font-size: 52px; font-weight: 600; letter-spacing: -.03em; font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.count-input:focus { outline: none; }
.count-hint { margin-top: 6px; font-size: 12px; color: var(--muted); min-height: 18px; }
.count-hint b { color: var(--ink); font-variant-numeric: tabular-nums; }

.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.keypad button {
  height: 54px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
  font-size: 20px; font-weight: 550; font-variant-numeric: tabular-nums;
  transition: background .1s ease, transform .06s ease;
}
.keypad button:hover { background: var(--surface-2); }
.keypad button:active { transform: scale(.97); background: var(--mint); }
.keypad button.wide { grid-column: span 2; }
.keypad button.ghost { background: var(--surface-3); border-color: transparent; font-size: 13px; font-weight: 600; }

.count-actions { display: flex; gap: 8px; margin-top: 16px; }
.count-actions .btn { flex: 1; }

.recent { margin-top: 14px; }
.recent .row-item { padding: 9px 16px; }

.variance-live { margin-top: 12px; display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 10px; font-size: 12.5px; background: var(--surface-3); }
.variance-live.pos { background: var(--mint); color: var(--pine); }
.variance-live.neg { background: var(--red-bg); color: var(--red); }
.variance-live b { font-variant-numeric: tabular-nums; }

/* ---------- data page ---------- */
.drop {
  border: 1.5px dashed var(--line-2); border-radius: var(--r-lg); background: var(--surface-2);
  padding: 26px; text-align: center; transition: border-color .15s, background .15s;
}
.drop.is-over { border-color: var(--pine-2); background: var(--mint); }
.drop .glyph { width: 42px; height: 42px; border-radius: 11px; background: var(--surface); border: 1px solid var(--line); display: grid; place-items: center; margin: 0 auto 10px; color: var(--pine); }
.drop h3 { font-size: 14px; font-weight: 600; }
.drop p { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.drop .btn { margin-top: 12px; }

.source { display: grid; grid-template-columns: 34px minmax(0,1fr) auto; gap: 12px; align-items: center; padding: 14px 16px; border-bottom: 1px solid #f0eee6; }
.source:last-child { border-bottom: 0; }
.source .icon { width: 34px; height: 34px; border-radius: 9px; background: var(--surface-3); display: grid; place-items: center; color: var(--ink-2); }
.source .icon svg { width: 16px; height: 16px; }
.source .t { font-size: 13px; font-weight: 550; }
.source .s { font-size: 11.5px; color: var(--muted); margin-top: 1px; }

.export-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.export-card { padding: 16px; display: flex; flex-direction: column; gap: 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.export-card h4 { font-size: 13px; font-weight: 600; }
.export-card p { font-size: 11.5px; color: var(--muted); flex: 1; }
.export-card .meta { font-size: 11px; color: var(--faint); font-variant-numeric: tabular-nums; }

/* ---------- modal ---------- */
.scrim { position: fixed; inset: 0; background: rgba(11, 17, 14, .42); backdrop-filter: blur(3px); z-index: 80; }
.modal-root { position: fixed; inset: 0; z-index: 90; display: none; place-items: center; padding: 18px; overflow: auto; }
.modal-root.is-open { display: grid; }
.modal {
  width: min(620px, 100%); background: var(--surface); border-radius: var(--r-xl);
  box-shadow: var(--shadow-3); border: 1px solid var(--line);
  max-height: min(86vh, 900px); display: flex; flex-direction: column;
  animation: pop .18s cubic-bezier(.2,.8,.2,1);
}
.modal.wide { width: min(880px, 100%); }
.modal.narrow { width: min(440px, 100%); }
@keyframes pop { from { transform: translateY(8px) scale(.985); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 22px 14px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 17px; font-weight: 620; letter-spacing: -.015em; }
.modal-head p { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.modal-body { padding: 18px 22px; overflow: auto; }
.modal-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 14px 22px 18px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--r-xl) var(--r-xl); }
.modal-foot .left { margin-right: auto; font-size: 12px; color: var(--muted); }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field label { font-size: 11px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.field input, .field select, .field textarea {
  height: 38px; border: 1px solid var(--line-2); border-radius: 9px; background: var(--surface);
  padding: 0 11px; font-size: 13.5px;
}
.field textarea { height: auto; padding: 9px 11px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--pine-2); box-shadow: 0 0 0 3px rgba(20, 121, 90, .1); }
.field .help { font-size: 11.5px; color: var(--faint); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.check-list { display: flex; flex-direction: column; gap: 8px; }
.check-item { display: flex; gap: 9px; align-items: flex-start; font-size: 12.5px; }
.check-item .tick { color: var(--pine); flex: none; margin-top: 2px; }
.check-item .warn { color: var(--amber); }
.check-item .bad { color: var(--red); }

/* toast */
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 120; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; pointer-events: none; }
.toast {
  background: var(--ink); color: #f4f8f5; padding: 10px 14px; border-radius: 10px;
  font-size: 12.5px; box-shadow: var(--shadow-2); display: flex; align-items: center; gap: 9px;
  animation: toast-in .2s cubic-bezier(.2,.8,.2,1); max-width: 340px;
}
.toast .dot { width: 6px; height: 6px; border-radius: 50%; background: #7fd1a6; flex: none; }
.toast.warn .dot { background: #e8b04a; }
.toast.bad .dot { background: #ef8a78; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* misc */
.hr { height: 1px; background: var(--line); border: 0; margin: 16px 0; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flex { display: flex; align-items: center; gap: 8px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 4px; }
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 14px; } .mt-4 { margin-top: 22px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 14px; } .mb-4 { margin-bottom: 22px; }
.pill-note { font-size: 11.5px; color: var(--muted); background: var(--surface-2); border: 1px solid var(--line); padding: 8px 11px; border-radius: 8px; }
.kbd { font-family: var(--mono); font-size: 10.5px; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 5px; padding: 1px 5px; color: var(--muted); background: var(--surface); }

.only-mobile { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 900px) {
  :root { --rail-w: 0px; --top-h: 58px; }
  .shell { grid-template-columns: 1fr; }
  .rail {
    position: fixed; inset: 0 auto 0 0; width: 252px; z-index: 100;
    transform: translateX(-102%); transition: transform .22s cubic-bezier(.2,.8,.2,1);
    box-shadow: var(--shadow-3);
  }
  .rail.is-open { transform: none; }
  .only-mobile { display: inline-grid; }
  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    display: flex; justify-content: space-around;
    background: rgba(255,255,255,.94); backdrop-filter: blur(12px);
    border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10px; color: var(--muted); padding: 4px 10px; border-radius: 8px; }
  .tabbar a svg { width: 20px; height: 20px; }
  .tabbar a.is-active { color: var(--pine); }
  #view { padding-bottom: 92px; }
  .foot { padding-bottom: 78px; }
  .topbar { padding: 0 14px; }
  .topbar-right .btn span { display: none; }
  .period-pill { padding: 6px 9px; font-size: 11px; }
  .card-head { padding: 14px; }
  .kpi { padding: 15px; }
  .count-entry { grid-template-columns: 1fr; }
  .keypad button { height: 58px; }
  .item-card .facts { grid-template-columns: repeat(2, 1fr); gap: 12px 10px; }
}

@media (min-width: 901px) {
  .tabbar { display: none; }
}

@media (max-width: 560px) {
  .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-3, .g-2 { grid-template-columns: 1fr; }
  .crumb { display: none; }
  #count-btn { display: none; }
  .topbar { justify-content: space-between; }
  .kpi { padding: 13px 13px 12px; }
  .kpi-value { font-size: 23px; margin-top: 9px; }
  .kpi-label { font-size: 10px; letter-spacing: .06em; }
  .kpi-label .glyph { width: 18px; height: 18px; }
  .scan-field { display: grid; grid-template-columns: minmax(0, 1fr) 48px; gap: 8px; }
  .scan-field .btn-primary { grid-column: 1 / -1; }
  .scan-input { height: 48px; font-size: 18px; }
  .count-wrap.is-counting .scan-card { display: none; }
  .count-wrap.is-counting .count-head { display: none; }
  .count-wrap.is-counting .count-progress-card { padding: 8px 14px !important; margin-bottom: 10px; }
  .count-head .eyebrow { display: none; }
  .count-head h1 { font-size: 20px; }
  .count-head .tiny { display: none; }
  .count-head { margin-bottom: 10px; }
  .item-card { margin-top: 10px; padding: 14px; }
  .item-card h2 { font-size: 18px; }
  .item-card .facts { margin: 12px 0 2px; padding-top: 11px; gap: 10px; }
  .count-entry { margin-top: 12px; gap: 10px; }
  .count-display { padding: 12px 14px 13px; }
  .count-input { font-size: 38px; }
  .keypad { gap: 6px; }
  .keypad button { height: 48px; font-size: 18px; }
  .count-actions { margin-top: 12px; }
  .count-actions .btn-lg { height: 44px; }
  .hide-sm { display: none !important; }
  .dash-tabs { margin-bottom: 12px; }
  .dash-tab { padding: 7px 10px 6px; font-size: 12px; }
  .dash-toolbar { margin-bottom: 14px; }
  .dash-toolbar .select { flex: 1 1 100%; min-width: 0; }
  .page-head { margin-bottom: 16px; }
  .page-head .actions { width: 100%; }
  .page-head .actions .btn { flex: 1; }
  .dispo-grid { grid-template-columns: 1fr; }
  .topbar-right #import-btn { display: none; }
  .modal { max-height: 92vh; }
  .modal-foot { flex-wrap: wrap; }
  .modal-foot .btn { flex: 1; }
}

@media (max-width: 700px) {
  .hide-sm { display: none !important; }
  .tabbar a.is-active { background: var(--mint); }
}

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

@media print {
  .rail, .topbar, .tabbar, .foot, .toolbar, .page-head .actions { display: none !important; }
  .shell { grid-template-columns: 1fr; }
  body { background: #fff; }
  .card { box-shadow: none; }
}

/* ---------- auth screen ---------- */
.auth[hidden], .shell[hidden] { display: none !important; }
.auth {
  position: fixed; inset: 0; z-index: 120;
  display: grid; place-items: center;
  padding: 22px;
  overflow: auto;
  background:
    radial-gradient(900px 520px at 82% -12%, rgba(14, 90, 66, .10), transparent 62%),
    radial-gradient(700px 460px at 8% 110%, rgba(143, 95, 19, .08), transparent 60%),
    var(--paper);
}
.auth::before {
  content: ""; position: fixed; inset: 0; pointer-events: none;
  background-image: radial-gradient(rgba(17,26,21,.035) .6px, transparent .6px);
  background-size: 5px 5px;
}
.auth-card {
  position: relative; width: min(472px, 100%);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-xl); padding: 30px;
  box-shadow: 0 30px 80px -40px rgba(17,26,21,.45), 0 10px 24px -18px rgba(17,26,21,.25);
}
.auth-brand { display: flex; gap: 11px; align-items: center; margin-bottom: 22px; }
.auth-brand .brand-text strong { color: var(--ink); }
.auth-brand .brand-text small { color: var(--muted); }
.auth-kicker { font-size: 10.5px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--pine-2); }
.auth-title { margin-top: 8px; font-size: 25px; line-height: 1.15; letter-spacing: -.025em; font-weight: 650; }
.auth-sub { margin-top: 8px; font-size: 13px; line-height: 1.55; color: var(--muted); }
.auth-form { margin-top: 20px; display: grid; gap: 12px; }
.auth-field { display: grid; gap: 6px; }
.auth-field > span { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.auth-field input {
  width: 100%; height: 44px; border: 1px solid var(--line-2); border-radius: 10px;
  background: var(--surface-2); padding: 0 12px; font-size: 15px; outline: none;
}
.auth-field input:focus { border-color: var(--pine-2); background: #fff; box-shadow: 0 0 0 3px rgba(20,121,90,.10); }
.auth-roles { margin-top: 18px; display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 6px; padding: 4px; background: var(--surface-3); border-radius: 12px; }
.auth-role {
  border: 0; background: transparent; border-radius: 9px; padding: 9px 8px;
  font-size: 12px; font-weight: 600; color: var(--muted); line-height: 1.25;
}
.auth-role.is-active { background: var(--surface); color: var(--pine); box-shadow: var(--shadow-1); }
.auth-role.is-disabled { opacity: .45; cursor: not-allowed; }
.auth-actions { margin-top: 18px; display: flex; gap: 8px; }
.auth-actions .btn { flex: 1; }
.auth-note {
  margin-top: 16px; padding: 11px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--surface-2);
  font-size: 12px; line-height: 1.5; color: var(--muted);
}
.auth-note b { color: var(--ink-2); }
.auth-error {
  padding: 9px 11px; border-radius: 9px; background: var(--red-bg);
  color: var(--red); font-size: 12.5px; line-height: 1.4;
}
.auth-small { margin-top: 16px; font-size: 11px; line-height: 1.5; color: var(--faint); }
.auth-codes { margin-top: 18px; display: grid; gap: 10px; }
.code-box {
  display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 6px 12px;
  padding: 13px 14px; border: 1px solid var(--line-2); border-radius: 12px; background: var(--surface-2);
}
.code-label { grid-column: 1 / -1; font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.code-value { font-size: 25px; font-weight: 650; letter-spacing: .14em; color: var(--ink); }
.code-box .btn { grid-column: 2; grid-row: 2; }

/* ---------- role chrome ---------- */
.role-chip { background: var(--mint); color: var(--pine); border-color: transparent; max-width: 210px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.role-counter .rail, body.role-counter .tabbar { display: none !important; }
body.role-counter .shell { grid-template-columns: minmax(0, 1fr); }
body.role-counter .main { min-height: 100vh; }
body.role-counter #import-btn, body.role-counter #count-btn, body.role-counter #period-pill { display: none !important; }
body.role-counter .topbar { height: 56px; position: sticky; top: 0; z-index: 30; background: rgba(245,244,238,.94); backdrop-filter: blur(10px); }
body.role-counter .topbar-right { margin-left: auto; }
body.role-counter .crumb { font-size: 16px; font-weight: 650; letter-spacing: -.01em; }
body.role-counter .foot { display: none; }
body.role-counter #view { padding-top: 18px; }
body.role-counter [data-act="edit-current"], body.role-counter [data-act="set-counter"], body.role-counter [data-act="count-finish"] { display: none !important; }

body.role-area [data-act="export-count"],
body.role-area [data-act="export-store"],
body.role-area [data-act="export-workbook"],
body.role-area [data-act="export-json"],
body.role-area [data-act="export-barcodes"],
body.role-area [data-act="barcode-template"],
body.role-area [data-act="export-dispo"],
body.role-area [data-act="add-item"],
body.role-area [data-act="add-receipt"],
body.role-area [data-act="open-period"],
body.role-area [data-act="close-period"],
body.role-area [data-act="reset-seed"],
body.role-area [data-act="clear-all"],
body.role-area [data-act="sync-publish"],
body.role-area [data-edit-sku],
body.role-area [data-remove-receipt] { display: none !important; }
body.role-area #import-btn { display: none !important; }
body.role-area .rail a[data-view="data"], body.role-area .tabbar a[data-view="data"] { display: none !important; }
body.role-area #period-pill { pointer-events: none; }

/* ---------- count event + manager helpers ---------- */
.event-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 11px 14px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface-2); margin-bottom: 14px;
}
.event-bar .grow { min-width: 0; }
.event-bar .t { font-size: 12.5px; font-weight: 600; }
.event-bar .s { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.event-bar .chip { flex: none; }
.count-wrap.is-blind .facts { grid-template-columns: repeat(2, minmax(0,1fr)); }
.recount-note { color: var(--amber); }

/* ---------- phone QR ---------- */
.qr-wrap { display: grid; place-items: center; gap: 12px; padding: 8px 0 4px; }
.qr-box { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 12px; line-height: 0; }
.qr-box svg { width: min(260px, 68vw); height: auto; display: block; }
.qr-url { font-size: 15px; font-weight: 600; letter-spacing: .01em; }
.qr-steps { margin-top: 14px; display: grid; gap: 7px; font-size: 12.5px; color: var(--muted); }
.qr-steps b { color: var(--ink-2); }

/* ---------- team / access ---------- */
.team-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.team-row:last-child { border-bottom: 0; }
.team-row .t { font-size: 13px; font-weight: 600; }
.team-row .s { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.team-code { font-size: 21px; font-weight: 650; letter-spacing: .14em; }
.team-active { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

@media (max-width: 560px) {
  .auth { padding: 12px; align-items: start; padding-top: 26px; }
  .auth-card { padding: 22px 18px; border-radius: 18px; }
  .auth-title { font-size: 22px; }
  .auth-roles { grid-template-columns: 1fr; }
  .auth-role { text-align: left; padding: 9px 12px; }
  .role-chip { max-width: 120px; font-size: 10.5px; }
  body.role-counter .topbar { padding-left: 14px; padding-right: 14px; }
}

body.role-counter #menu-btn { display: none !important; }
body.role-area [data-act="import"] { display: none !important; }
.count-progress { flex-wrap: wrap; row-gap: 6px; }

/* ---------- period history ---------- */
.history-card .card-head h2 { font-size: 14px; }
.history-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.history-stats > div { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; min-width: 0; }
.history-stats span { display: block; font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.history-stats strong { display: block; margin-top: 4px; font-size: 15px; font-weight: 620; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 700px) { .history-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) {
  .tabbar a { padding-left: 6px; padding-right: 6px; font-size: 9.5px; }
  .tabbar a svg { width: 18px; height: 18px; }
}

.pill-note svg, .check-item svg, .event-bar svg { width: 16px; height: 16px; flex: none; vertical-align: -3px; }

.auth-link { border: 0; background: none; padding: 0; color: var(--pine-2); font-size: inherit; text-decoration: underline; cursor: pointer; }

/* ---------- count conflicts ---------- */
.conflict-box { border: 1px solid #e8c98f; background: var(--amber-bg); border-radius: 12px; padding: 12px 14px; margin-bottom: 14px; }
.conflict-title { font-size: 13px; font-weight: 650; color: var(--ink); }
.conflict-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; margin-bottom: 9px; }
.conflict-head td { background: rgba(255,255,255,.55); font-size: 12.5px; padding-top: 9px; padding-bottom: 7px; }
.conflict-box .table-wrap { background: var(--surface); }
