/* ==========================================================================
   PantryStock — design tokens
   ========================================================================== */
:root {
  --brand-50:  #ecfdf3;
  --brand-100: #d3f7e0;
  --brand-300: #77dba7;
  --brand-500: #16a34a;
  --brand-600: #128843;
  --brand-700: #0d6b36;

  --amber:  #d97706;
  --amber-bg: #fef3c7;
  --red:    #dc2626;
  --red-bg: #fee2e2;
  --blue:   #2563eb;
  --blue-bg:#dbeafe;
  --violet: #7c3aed;

  --bg:        #f4f6f3;
  --surface:   #ffffff;
  --surface-2: #eef1ed;
  --surface-3: #e4e8e2;
  --text:      #131a16;
  --text-2:    #5d6b63;
  --text-3:    #8a978f;
  --line:      #dde3dd;
  --line-2:    #c9d2ca;
  --accent:    var(--brand-500);
  --on-accent: #ffffff;
  --shadow-1:  0 1px 2px rgba(16,32,24,.06), 0 1px 3px rgba(16,32,24,.05);
  --shadow-2:  0 4px 12px rgba(16,32,24,.09), 0 2px 4px rgba(16,32,24,.05);
  --shadow-3:  0 -8px 32px rgba(16,32,24,.16);

  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 22px; --r-full: 999px;
  --sp: 16px;
  --tap: 44px;
  --topbar-h: 56px;
  --tabbar-h: 62px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --ease: cubic-bezier(.2,.7,.3,1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:        #0e120f;
    --surface:   #171d19;
    --surface-2: #1f2621;
    --surface-3: #29322b;
    --text:      #e9efea;
    --text-2:    #a3b1a8;
    --text-3:    #7a8880;
    --line:      #28312b;
    --line-2:    #35403a;
    --brand-500: #2fbe6a;
    --brand-600: #26a95c;
    --brand-50:  #12241a;
    --brand-100: #16311f;
    --amber-bg:  #3a2b09;
    --red-bg:    #3a1414;
    --blue-bg:   #12233f;
    --amber:     #f0a83c;
    --red:       #f36a6a;
    --blue:      #6ea8fe;
    --on-accent: #06170e;
    --shadow-1:  0 1px 2px rgba(0,0,0,.4);
    --shadow-2:  0 4px 14px rgba(0,0,0,.45);
    --shadow-3:  0 -8px 32px rgba(0,0,0,.6);
  }
}
:root[data-theme="dark"] {
  --bg: #0e120f; --surface: #171d19; --surface-2: #1f2621; --surface-3: #29322b;
  --text: #e9efea; --text-2: #a3b1a8; --text-3: #7a8880;
  --line: #28312b; --line-2: #35403a;
  --brand-500: #2fbe6a; --brand-600: #26a95c; --brand-50: #12241a; --brand-100: #16311f;
  --amber-bg: #3a2b09; --red-bg: #3a1414; --blue-bg: #12233f;
  --amber: #f0a83c; --red: #f36a6a; --blue: #6ea8fe; --on-accent: #06170e;
  --shadow-1: 0 1px 2px rgba(0,0,0,.4); --shadow-2: 0 4px 14px rgba(0,0,0,.45); --shadow-3: 0 -8px 32px rgba(0,0,0,.6);
}

/* ========================= reset ========================= */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 16px; line-height: 1.45;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
h1,h2,h3,h4,p,figure { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
svg { fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
svg.fill { fill: currentColor; stroke: none; }
[hidden] { display: none !important; }
::selection { background: var(--brand-300); color: #06170e; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ========================= splash ========================= */
.splash {
  position: fixed; inset: 0; z-index: 100; display: grid; place-content: center;
  justify-items: center; gap: 14px; background: var(--bg);
  transition: opacity .35s var(--ease);
}
.splash.gone { opacity: 0; pointer-events: none; }
.splash-mark { color: var(--brand-500); animation: pop .5s var(--ease) both; }
.splash-mark svg { stroke-width: 1.4; }
.splash-name { font-weight: 700; font-size: 20px; letter-spacing: -.02em; }
.spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2.5px solid var(--line-2); border-top-color: var(--brand-500);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pop { from { transform: scale(.7); opacity: 0 } to { transform: none; opacity: 1 } }

/* ========================= layout ========================= */
.app { display: flex; flex-direction: column; min-height: 100dvh; }
.view {
  flex: 1; padding: 12px var(--sp) calc(28px + var(--tabbar-h) + var(--safe-b));
  max-width: 720px; width: 100%; margin: 0 auto; outline: none;
  animation: fade .22s var(--ease);
}
@keyframes fade { from { opacity: 0; transform: translateY(6px) } to { opacity: 1; transform: none } }
.app.no-tabs .view { padding-bottom: calc(28px + var(--safe-b)); }
.app.no-tabs .tabbar { display: none; }

/* topbar */
.topbar {
  position: sticky; top: 0; z-index: 30;
  padding-top: var(--safe-t);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s;
}
.topbar.scrolled { border-bottom-color: var(--line); }
.topbar-inner {
  height: var(--topbar-h); max-width: 720px; margin: 0 auto;
  padding: 0 8px; display: flex; align-items: center; gap: 4px;
}
.topbar-title { font-weight: 650; font-size: 17px; letter-spacing: -.01em; flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-inline: 6px; }
.topbar-title.lead { font-size: 22px; font-weight: 750; }
.iconbtn {
  width: var(--tap); height: var(--tap); border-radius: var(--r-full);
  display: grid; place-items: center; color: var(--text-2); flex: none;
  transition: background .15s, color .15s;
}
.iconbtn:hover { background: var(--surface-2); color: var(--text); }
.iconbtn:active { transform: scale(.93); }
.iconbtn svg { width: 22px; height: 22px; }
.iconbtn .badge {
  position: absolute; margin: -20px 0 0 20px; min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 9px; background: var(--red); color: #fff; font-size: 10.5px; font-weight: 700;
  display: grid; place-items: center; border: 2px solid var(--bg);
}

/* tabbar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  padding-bottom: var(--safe-b);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.8) blur(18px);
  border-top: 1px solid var(--line);
  display: flex; justify-content: center;
}
.tabbar-inner { display: flex; width: 100%; max-width: 720px; height: var(--tabbar-h); align-items: stretch; }
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; color: var(--text-3); font-size: 10.5px; font-weight: 600; letter-spacing: .01em;
  transition: color .18s; position: relative;
}
.tab svg { width: 23px; height: 23px; transition: transform .2s var(--ease); }
.tab[aria-current="page"] { color: var(--accent); }
.tab[aria-current="page"] svg { transform: translateY(-1px) scale(1.06); }
.tab:active svg { transform: scale(.9); }
.tab-fab { flex: 0 0 76px; justify-content: flex-start; }
.tab-fab .fab {
  width: 52px; height: 52px; margin-top: -16px; border-radius: 18px;
  background: linear-gradient(160deg, var(--brand-500), var(--brand-600));
  color: var(--on-accent); display: grid; place-items: center;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--brand-500) 40%, transparent);
  transition: transform .18s var(--ease);
}
.tab-fab .fab svg { width: 26px; height: 26px; stroke-width: 2.4; }
.tab-fab:active .fab { transform: scale(.92); }

/* ad slot */
.adslot {
  position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h) + var(--safe-b)); z-index: 35;
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  background: var(--surface-2); border-top: 1px solid var(--line); font-size: 12px; color: var(--text-2);
}
.adslot .ad-tag { font-size: 9px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-3); border: 1px solid var(--line-2); border-radius: 4px; padding: 1px 4px; flex: none; }
.adslot .ad-body { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.adslot .ad-cta { flex: none; font-weight: 700; color: var(--accent); font-size: 12px; }
.app.has-ad .view { padding-bottom: calc(70px + var(--tabbar-h) + var(--safe-b)); }

/* ========================= type ========================= */
.h1 { font-size: 27px; font-weight: 760; letter-spacing: -.025em; line-height: 1.15; }
.h2 { font-size: 19px; font-weight: 700; letter-spacing: -.015em; }
.h3 { font-size: 15.5px; font-weight: 650; letter-spacing: -.01em; }
.sub { color: var(--text-2); font-size: 14px; }
.muted { color: var(--text-3); }
.tiny { font-size: 12.5px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.section-label {
  font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-3); margin: 22px 4px 9px; display: flex; align-items: center; gap: 8px;
}
.section-label .spacer { flex: 1 }
.section-label a, .section-label button { font-size: 12px; font-weight: 700; color: var(--accent); text-transform: none; letter-spacing: 0; }
/* Grid items default to min-width:auto, so a horizontally scrollable child
   (chip rows) would otherwise stretch the whole column past the viewport. */
.stack { display: grid; gap: 10px; }
.stack-lg { display: grid; gap: 18px; }
.stack > *, .stack-lg > * { min-width: 0; }
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.wrap { flex-wrap: wrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.center { text-align: center; }

/* ========================= cards ========================= */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 14px; box-shadow: var(--shadow-1);
}
.card.flush { padding: 0; overflow: hidden; }
.card.tint { background: var(--brand-50); border-color: color-mix(in srgb, var(--brand-500) 22%, transparent); }
.card-hd { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.card-hd .h3 { flex: 1 }

.list { display: grid; }
.list > * + * { border-top: 1px solid var(--line); }
.li {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; width: 100%;
  text-align: left; color: inherit; min-height: 56px; transition: background .12s;
}
button.li:active, a.li:active { background: var(--surface-2); }
.li-title { font-weight: 560; font-size: 15px; }
.li-sub { font-size: 12.5px; color: var(--text-2); }
/* Not scoped to .li — a sized-less inline SVG falls back to 300×150. */
.chev { width: 18px; height: 18px; color: var(--text-3); flex: none; }
.li-icon {
  width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; flex: none;
  background: var(--surface-2); color: var(--text-2); font-size: 18px;
}
.li-icon svg { width: 19px; height: 19px; }
.li-icon.brand { background: var(--brand-50); color: var(--brand-500); }
.li-icon.amber { background: var(--amber-bg); color: var(--amber); }
.li-icon.red   { background: var(--red-bg); color: var(--red); }
.li-icon.blue  { background: var(--blue-bg); color: var(--blue); }

/* ========================= buttons ========================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 18px; border-radius: var(--r-md);
  font-weight: 650; font-size: 15px; letter-spacing: -.01em;
  background: var(--surface-2); color: var(--text); border: 1px solid transparent;
  transition: transform .12s var(--ease), background .15s, opacity .15s;
  user-select: none;
}
.btn:active { transform: scale(.975); }
.btn svg { width: 19px; height: 19px; flex: none; }
.btn-primary { background: var(--brand-500); color: var(--on-accent); box-shadow: 0 2px 10px color-mix(in srgb, var(--brand-500) 28%, transparent); }
.btn-primary:hover { background: var(--brand-600); }
.btn-outline { background: transparent; border-color: var(--line-2); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-danger { background: var(--red-bg); color: var(--red); }
.btn-block { display: flex; width: 100%; }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 13.5px; border-radius: var(--r-sm); }
.btn-lg { min-height: 52px; font-size: 16.5px; border-radius: var(--r-lg); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn-row { display: flex; gap: 10px; }
.btn-row > * { flex: 1 }

.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 13px;
  border-radius: var(--r-full); background: var(--surface-2); color: var(--text-2);
  font-size: 13.5px; font-weight: 600; border: 1px solid transparent; white-space: nowrap;
  transition: all .15s;
}
.chip svg { width: 15px; height: 15px; }
.chip[aria-pressed="true"], .chip.on { background: var(--brand-500); color: var(--on-accent); }
.chip-scroll { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px 16px; margin: 0 -16px; }
.chip-scroll::-webkit-scrollbar { display: none; }

.pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: var(--r-full);
  font-size: 11.5px; font-weight: 700; letter-spacing: .01em; background: var(--surface-2); color: var(--text-2);
}
.pill svg { width: 12px; height: 12px; stroke-width: 2.4; }
.pill.ok    { background: var(--brand-50); color: var(--brand-500); }
.pill.low   { background: var(--amber-bg); color: var(--amber); }
.pill.out   { background: var(--red-bg); color: var(--red); }
.pill.info  { background: var(--blue-bg); color: var(--blue); }
.pill.plan  { background: linear-gradient(120deg, var(--violet), var(--blue)); color: #fff; }

/* ========================= forms ========================= */
.field { display: grid; gap: 6px; }
.label { font-size: 13px; font-weight: 650; color: var(--text-2); padding-inline: 3px; }
.input, .select, .textarea {
  width: 100%; min-height: 48px; padding: 11px 14px; border-radius: var(--r-md);
  background: var(--surface); border: 1.5px solid var(--line); color: var(--text);
  transition: border-color .15s, box-shadow .15s; -webkit-appearance: none; appearance: none;
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--brand-500);
  box-shadow: 0 0 0 3.5px color-mix(in srgb, var(--brand-500) 18%, transparent);
}
.textarea { min-height: 84px; resize: vertical; line-height: 1.45; }
.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a978f' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 18px; padding-right: 40px;
}
.input-icon { position: relative; }
.input-icon > svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 19px; height: 19px; color: var(--text-3); pointer-events: none; }
.input-icon .input { padding-left: 40px; }
.hint { font-size: 12.5px; color: var(--text-3); padding-inline: 3px; }
.err { font-size: 12.5px; color: var(--red); padding-inline: 3px; font-weight: 600; }
.input.invalid { border-color: var(--red); }

.seg { display: flex; background: var(--surface-2); border-radius: var(--r-md); padding: 3px; gap: 3px; }
.seg button {
  flex: 1; min-height: 38px; border-radius: 9px; font-size: 14px; font-weight: 650; color: var(--text-2);
  transition: all .18s var(--ease);
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }

.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 2; }
.switch .track {
  position: absolute; inset: 0; border-radius: var(--r-full); background: var(--line-2);
  transition: background .22s var(--ease);
}
.switch .track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.28); transition: transform .22s var(--ease);
}
.switch input:checked + .track { background: var(--brand-500); }
.switch input:checked + .track::after { transform: translateX(20px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-500) 30%, transparent); }

/* range slider */
.slider { width: 100%; height: 34px; background: none; -webkit-appearance: none; appearance: none; margin: 0; }
.slider::-webkit-slider-runnable-track {
  height: 10px; border-radius: var(--r-full);
  background: linear-gradient(90deg, var(--fill-color, var(--brand-500)) var(--fill, 50%), var(--surface-3) var(--fill, 50%));
}
.slider::-moz-range-track { height: 10px; border-radius: var(--r-full); background: var(--surface-3); }
.slider::-moz-range-progress { height: 10px; border-radius: var(--r-full); background: var(--fill-color, var(--brand-500)); }
.slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 26px; height: 26px; margin-top: -8px; border-radius: 50%;
  background: #fff; border: 2px solid var(--fill-color, var(--brand-500));
  box-shadow: 0 2px 6px rgba(0,0,0,.22); cursor: grab;
}
.slider::-moz-range-thumb {
  width: 24px; height: 24px; border-radius: 50%; background: #fff;
  border: 2px solid var(--fill-color, var(--brand-500)); box-shadow: 0 2px 6px rgba(0,0,0,.22);
}
.slider:active::-webkit-slider-thumb { cursor: grabbing; transform: scale(1.08); }
.slider-marks { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-3); padding: 0 2px; }

/* stepper */
.stepper { display: flex; align-items: center; gap: 4px; background: var(--surface-2); border-radius: var(--r-md); padding: 4px; }
.stepper button { width: 38px; height: 38px; border-radius: 9px; display: grid; place-items: center; color: var(--text); background: var(--surface); box-shadow: var(--shadow-1); }
.stepper button:active { transform: scale(.9); }
.stepper button svg { width: 18px; height: 18px; stroke-width: 2.6; }
.stepper .val { min-width: 62px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; font-size: 16px; }

/* ========================= level bar / ring ========================= */
.level { height: 8px; border-radius: var(--r-full); background: var(--surface-3); overflow: hidden; }
.level > i { display: block; height: 100%; border-radius: var(--r-full); background: var(--brand-500); transition: width .35s var(--ease), background .3s; }
.level.s-low > i  { background: var(--amber); }
.level.s-out > i  { background: var(--red); }
.level.s-out { background: var(--red-bg); }

.ring { position: relative; width: 132px; height: 132px; margin: 0 auto; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); stroke-linecap: round; }
.ring .bg { stroke: var(--surface-3); }
.ring .fg { stroke: var(--brand-500); transition: stroke-dashoffset .5s var(--ease), stroke .3s; }
.ring.s-low .fg { stroke: var(--amber); }
.ring.s-out .fg { stroke: var(--red); }
.ring .ring-val { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring .ring-num { font-size: 30px; font-weight: 760; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.ring .ring-cap { font-size: 11.5px; color: var(--text-2); font-weight: 600; }

/* ========================= item rows / tiles ========================= */
.item-row { display: flex; align-items: center; gap: 12px; padding: 11px 14px; width: 100%; text-align: left; color: inherit; }
.item-thumb {
  width: 44px; height: 44px; border-radius: 12px; flex: none; display: grid; place-items: center;
  background: var(--surface-2); font-size: 21px; overflow: hidden;
}
.item-thumb img { width: 100%; height: 100%; object-fit: cover; }
.item-main { flex: 1; min-width: 0; display: grid; gap: 5px; }
.item-main > * { min-width: 0; }
.item-name { font-weight: 600; font-size: 15px; letter-spacing: -.01em; }
.item-meta { display: flex; align-items: center; gap: 7px 6px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); }
.item-meta:empty { display: none; }
.item-qty { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 13.5px; color: var(--text-2); flex: none; text-align: right; }

.quick-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.quick-tile {
  display: flex; flex-direction: column; gap: 9px; padding: 12px; border-radius: var(--r-lg);
  background: var(--surface); border: 1px solid var(--line); text-align: left; box-shadow: var(--shadow-1);
  transition: transform .12s var(--ease);
}
.quick-tile:active { transform: scale(.97); }
.quick-tile .qt-top { display: flex; align-items: center; gap: 9px; min-width: 0; color: inherit; }
.quick-tile .item-thumb { width: 34px; height: 34px; border-radius: 10px; font-size: 17px; }
.quick-tile .qt-name { font-weight: 620; font-size: 14px; letter-spacing: -.01em; }
.quick-tile .qt-actions { display: flex; gap: 6px; }
.quick-tile .qt-btn {
  flex: 1; height: 34px; border-radius: 9px; background: var(--surface-2); display: grid; place-items: center;
  color: var(--text-2); font-weight: 700; font-size: 13px;
}
.quick-tile .qt-btn svg { width: 16px; height: 16px; stroke-width: 2.6; }
.quick-tile .qt-btn.use { background: var(--brand-50); color: var(--brand-500); }
.quick-tile .qt-btn:active { transform: scale(.94); }

.cat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.cat-tile {
  position: relative; padding: 14px; border-radius: var(--r-lg); background: var(--surface);
  border: 1px solid var(--line); text-align: left; display: grid; gap: 8px; box-shadow: var(--shadow-1);
  transition: transform .12s var(--ease);
}
.cat-tile:active { transform: scale(.97); }
.cat-emoji { font-size: 24px; line-height: 1; }
.cat-name { font-weight: 650; font-size: 15px; letter-spacing: -.01em; }
.cat-count { font-size: 12.5px; color: var(--text-2); }

/* stats */
.stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 480px) { .stat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.stat { display: grid; gap: 2px; padding: 12px 14px; color: inherit; transition: transform .12s var(--ease); }
.stat:active { transform: scale(.97); }
.stat .n { font-size: 23px; font-weight: 770; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat .k { font-size: 12.5px; color: var(--text-2); font-weight: 550; }

/* ========================= alerts ========================= */
.alert {
  display: flex; gap: 11px; padding: 12px 13px; border-radius: var(--r-md); align-items: flex-start;
  background: var(--surface-2); border: 1px solid transparent;
}
.alert > svg { width: 20px; height: 20px; flex: none; margin-top: 1px; }
.alert .a-body { flex: 1; min-width: 0; }
.alert .a-title { font-weight: 650; font-size: 14.5px; }
.alert .a-text { font-size: 13px; color: var(--text-2); }
.alert.warn { background: var(--amber-bg); color: var(--amber); border-color: color-mix(in srgb, var(--amber) 25%, transparent); }
.alert.warn .a-text, .alert.danger .a-text, .alert.info .a-text { color: inherit; opacity: .82; }
.alert.danger { background: var(--red-bg); color: var(--red); border-color: color-mix(in srgb, var(--red) 25%, transparent); }
.alert.info { background: var(--blue-bg); color: var(--blue); border-color: color-mix(in srgb, var(--blue) 25%, transparent); }
.alert.ok { background: var(--brand-50); color: var(--brand-600); }

/* setup checklist */
.setup-dot {
  width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line-2); flex: none;
  display: grid; place-items: center; color: transparent;
}
.setup-dot svg { width: 14px; height: 14px; stroke-width: 3; }
.li.done .setup-dot { background: var(--brand-500); border-color: var(--brand-500); color: var(--on-accent); }
.li.done .li-title { color: var(--text-3); text-decoration: line-through; }
.progress-bar { height: 6px; border-radius: var(--r-full); background: var(--surface-3); overflow: hidden; }
.progress-bar > i { display: block; height: 100%; background: var(--brand-500); transition: width .4s var(--ease); }

/* ========================= sheet / modal ========================= */
.sheet-root { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(8,14,10,.5); backdrop-filter: blur(2px); animation: fadein .2s; }
@keyframes fadein { from { opacity: 0 } }
.sheet {
  position: relative; width: 100%; max-width: 560px; max-height: 92dvh; overflow-y: auto;
  background: var(--surface); border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: var(--shadow-3); padding: 8px var(--sp) calc(var(--sp) + var(--safe-b));
  animation: slideup .3s var(--ease); overscroll-behavior: contain;
}
@keyframes slideup { from { transform: translateY(100%) } }
.sheet.closing { animation: slidedown .22s var(--ease) forwards; }
@keyframes slidedown { to { transform: translateY(100%) } }
.sheet-grab { width: 38px; height: 4px; border-radius: 2px; background: var(--line-2); margin: 4px auto 12px; }
.sheet-hd { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.sheet-hd .h2 { flex: 1 }
@media (min-width: 640px) {
  .sheet-root { align-items: center; }
  .sheet { border-radius: var(--r-xl); max-height: 86dvh; animation: pop .24s var(--ease); }
}

/* toast */
.toast-root {
  position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h) + var(--safe-b) + 12px);
  z-index: 80; display: grid; gap: 8px; justify-items: center; pointer-events: none; padding: 0 16px;
}
.toast {
  display: flex; align-items: center; gap: 10px; max-width: 480px;
  padding: 11px 16px; border-radius: var(--r-full); background: #1c231e; color: #f0f4f1;
  box-shadow: var(--shadow-2); font-size: 14px; font-weight: 550; animation: toastin .28s var(--ease);
  pointer-events: auto;
}
.toast svg { width: 17px; height: 17px; flex: none; }
.toast.ok svg { color: var(--brand-300); }
.toast.err svg { color: #f36a6a; }
.toast button { color: var(--brand-300); font-weight: 700; font-size: 13.5px; }
.toast.out { animation: toastout .22s var(--ease) forwards; }
@keyframes toastin { from { opacity: 0; transform: translateY(14px) scale(.96) } }
@keyframes toastout { to { opacity: 0; transform: translateY(8px) scale(.97) } }

/* ========================= scanner ========================= */
.scanner { position: fixed; inset: 0; z-index: 70; background: #000; display: flex; flex-direction: column; }
.scanner video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scanner-ui { position: relative; flex: 1; display: flex; flex-direction: column; color: #fff; }
.scanner-top { display: flex; align-items: center; gap: 8px; padding: calc(var(--safe-t) + 8px) 8px 8px;
  background: linear-gradient(#000c, transparent); }
.scanner-top .iconbtn { color: #fff; }
.scanner-top .title { flex: 1; font-weight: 650; text-align: center; padding-right: 44px; }
.scanner-mid { flex: 1; display: grid; place-items: center; }
.reticle {
  width: min(74vw, 300px); aspect-ratio: 1.5; border-radius: 18px; position: relative;
  box-shadow: 0 0 0 100vmax rgba(0,0,0,.45);
}
.reticle::before, .reticle::after,
.reticle > i::before, .reticle > i::after {
  content: ""; position: absolute; width: 30px; height: 30px; border: 3.5px solid #fff; border-radius: 4px;
}
.reticle::before { top: -2px; left: -2px; border-right: 0; border-bottom: 0; border-top-left-radius: 16px; }
.reticle::after { top: -2px; right: -2px; border-left: 0; border-bottom: 0; border-top-right-radius: 16px; }
.reticle > i::before { bottom: -2px; left: -2px; border-right: 0; border-top: 0; border-bottom-left-radius: 16px; }
.reticle > i::after { bottom: -2px; right: -2px; border-left: 0; border-top: 0; border-bottom-right-radius: 16px; }
.scan-laser {
  position: absolute; left: 8%; right: 8%; height: 2px; background: var(--brand-300);
  box-shadow: 0 0 12px var(--brand-300); animation: laser 2.1s ease-in-out infinite; border-radius: 2px;
}
@keyframes laser { 0%,100% { top: 12% } 50% { top: 86% } }
.scanner-bot { padding: 18px 16px calc(24px + var(--safe-b)); display: grid; gap: 12px; justify-items: center;
  background: linear-gradient(transparent, #000c 40%); }
.scanner-hint { font-size: 14px; opacity: .85; text-align: center; }
.scanner-bot .btn { background: rgba(255,255,255,.16); color: #fff; backdrop-filter: blur(6px); }
.scanner-bot .btn-primary { background: var(--brand-500); color: var(--on-accent); }
.scan-flash { position: absolute; inset: 0; background: #fff; animation: flash .35s ease-out forwards; pointer-events: none; }
@keyframes flash { from { opacity: .85 } to { opacity: 0 } }

/* ========================= misc ========================= */
.empty { display: grid; gap: 10px; justify-items: center; text-align: center; padding: 44px 20px; }
.empty-art { width: 62px; height: 62px; border-radius: 20px; background: var(--surface-2); display: grid; place-items: center; color: var(--text-3); }
.empty-art svg { width: 30px; height: 30px; stroke-width: 1.6; }
.empty .h3 { font-size: 16.5px; }

.plan-card { position: relative; padding: 16px; border-radius: var(--r-lg); border: 2px solid var(--line); background: var(--surface); display: grid; gap: 10px; text-align: left; width: 100%; }
.plan-card.sel { border-color: var(--brand-500); background: var(--brand-50); }
.plan-card .price { font-size: 24px; font-weight: 780; letter-spacing: -.03em; }
.plan-card .price small { font-size: 13px; font-weight: 600; color: var(--text-2); letter-spacing: 0; }
.plan-card .feats { display: grid; gap: 6px; font-size: 13.5px; color: var(--text-2); }
.plan-card .feats div { display: flex; gap: 7px; align-items: flex-start; }
.plan-card .feats svg { width: 15px; height: 15px; color: var(--brand-500); flex: none; margin-top: 3px; stroke-width: 2.6; }
.plan-card .ribbon {
  position: absolute; top: -10px; right: 14px; padding: 3px 10px; border-radius: var(--r-full);
  background: linear-gradient(120deg, var(--violet), var(--blue)); color: #fff; font-size: 11px; font-weight: 700;
}

.avatar {
  width: 38px; height: 38px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--brand-100); color: var(--brand-600); font-weight: 750; font-size: 14.5px;
}
.avatar.lg { width: 60px; height: 60px; font-size: 22px; }
.avatar.c1 { background: #dbeafe; color: #1d4ed8 } .avatar.c2 { background: #fce7f3; color: #be185d }
.avatar.c3 { background: #fef3c7; color: #b45309 } .avatar.c4 { background: #e9d5ff; color: #7c3aed }
.avatar.c5 { background: #ccfbf1; color: #0f766e }

.code-box {
  display: flex; align-items: center; justify-content: center; gap: 10px; padding: 14px;
  border: 2px dashed var(--line-2); border-radius: var(--r-md); background: var(--surface-2);
  font-size: 23px; font-weight: 750; letter-spacing: .16em; font-family: ui-monospace, Menlo, Consolas, monospace;
}

.check-box {
  width: 24px; height: 24px; border-radius: 7px; border: 2px solid var(--line-2); flex: none;
  display: grid; place-items: center; color: transparent; transition: all .16s;
}
.check-box svg { width: 15px; height: 15px; stroke-width: 3; }
.li.checked .check-box { background: var(--brand-500); border-color: var(--brand-500); color: var(--on-accent); }
.li.checked .item-name, .li.checked .li-title { color: var(--text-3); text-decoration: line-through; }

details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary::after { content: "＋"; float: right; color: var(--text-3); font-weight: 500; }
details[open] > summary::after { content: "－"; }

.divider { height: 1px; background: var(--line); margin: 4px 0; }
.spacer-lg { height: 24px; }
hr.or { border: 0; border-top: 1px solid var(--line); text-align: center; overflow: visible; margin: 20px 0; }
hr.or::after { content: attr(data-label); position: relative; top: -11px; background: var(--bg); padding: 0 12px; color: var(--text-3); font-size: 12.5px; font-weight: 600; }

.skel { background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
  background-size: 400% 100%; animation: shimmer 1.3s infinite linear; border-radius: var(--r-sm); }
@keyframes shimmer { from { background-position: 100% 0 } to { background-position: -100% 0 } }

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