/* Cellar Stock — design system */
:root {
  --bg: #f5efe6;
  --surface: #fffdf9;
  --surface-2: #f0e7da;
  --ink: #241a11;
  --muted: #7b6a58;
  --line: #e6dac8;
  --accent: #c46a17;
  --accent-soft: #f6e2cb;
  --accent-ink: #fff;
  --good: #23824e;
  --good-soft: #dcf0e3;
  --warn: #b86e00;
  --warn-soft: #fbead0;
  --bad: #c33b2a;
  --bad-soft: #f9dcd6;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 4px 16px rgba(60, 40, 20, .06);
  --shadow-lg: 0 10px 40px rgba(40, 25, 10, .22);
  --r: 16px;
  --r-sm: 11px;
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #110e0b; --surface: #1b1713; --surface-2: #26201a; --ink: #f4ebdf; --muted: #a8977f; --line: #342b22;
    --accent: #f2a046; --accent-soft: #3a2814; --accent-ink: #1a1007;
    --good: #5ccf8c; --good-soft: #15301f; --warn: #f3b24e; --warn-soft: #362611; --bad: #ff7b67; --bad-soft: #3b1913;
    --shadow: 0 1px 2px rgba(0,0,0,.3); --shadow-lg: 0 10px 40px rgba(0,0,0,.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #110e0b; --surface: #1b1713; --surface-2: #26201a; --ink: #f4ebdf; --muted: #a8977f; --line: #342b22;
  --accent: #f2a046; --accent-soft: #3a2814; --accent-ink: #1a1007;
  --good: #5ccf8c; --good-soft: #15301f; --warn: #f3b24e; --warn-soft: #362611; --bad: #ff7b67; --bad-soft: #3b1913;
  --shadow: 0 1px 2px rgba(0,0,0,.3); --shadow-lg: 0 10px 40px rgba(0,0,0,.6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font: 16px/1.45 ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  font-variant-numeric: tabular-nums;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- shell ---------- */
.app { min-height: 100dvh; padding-bottom: calc(var(--nav-h) + var(--safe-b) + 24px); }
.top {
  position: sticky; top: 0; z-index: 20; padding: calc(var(--safe-t) + 10px) 16px 10px;
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid transparent;
}
.top.scrolled { border-bottom-color: var(--line); }
.top-in { max-width: 760px; margin: 0 auto; display: flex; align-items: center; gap: 10px; }
.brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); flex: none; }
.brand h1 { font-size: 19px; letter-spacing: -.02em; margin: 0; line-height: 1.1; }
.brand small { display: block; font-size: 12px; color: var(--muted); font-weight: 500; }
.sync { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); padding: 5px 10px; border-radius: 99px; white-space: nowrap; }
.sync i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.sync.ok i { background: var(--good); }
.sync.busy i { background: var(--warn); animation: pulse 1s infinite; }
.sync.off i { background: var(--bad); }
@keyframes pulse { 50% { opacity: .3; } }

main { max-width: 760px; margin: 0 auto; padding: 8px 16px 0; }
.page-h { display: flex; align-items: flex-end; gap: 12px; margin: 10px 0 14px; }
.page-h h2 { font-size: 26px; letter-spacing: -.03em; margin: 0; flex: 1; line-height: 1.1; }
.page-h p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }

.nav {
  position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: color-mix(in srgb, var(--surface) 90%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line); display: flex; justify-content: center;
}
.nav-in { display: flex; width: 100%; max-width: 560px; }
.nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  text-decoration: none; color: var(--muted); font-size: 11px; font-weight: 600; position: relative;
}
.nav a svg { width: 23px; height: 23px; }
.nav a.on { color: var(--accent); }
.nav a .dot { position: absolute; top: 8px; left: calc(50% + 8px); min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--bad); color: #fff; font-size: 10px; display: grid; place-items: center; }

@media (min-width: 980px) {
  .app { padding-left: 96px; padding-bottom: 32px; }
  .nav { top: 0; right: auto; width: 96px; height: auto; border-top: 0; border-right: 1px solid var(--line); padding: 90px 0 0; }
  .nav-in { flex-direction: column; gap: 6px; }
  .nav a { flex: none; height: 70px; }
}

/* ---------- building blocks ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.pad { padding: 16px; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 10px; align-items: center; }
.row > .grow { flex: 1; min-width: 0; }
.wrap { flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.b { font-weight: 700; }
.good { color: var(--good); } .warn { color: var(--warn); } .bad { color: var(--bad); }
.section-t { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 22px 4px 8px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 18px;
  border-radius: 13px; border: 1px solid var(--line); background: var(--surface); font-weight: 650; white-space: nowrap;
  transition: transform .08s, background .15s;
}
.btn:active { transform: scale(.97); }
.btn svg { width: 19px; height: 19px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--bad); }
.btn.danger.armed { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.block { width: 100%; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; padding: 0; flex: none; }
.icon-btn svg { width: 20px; height: 20px; }
.btn-bar { display: flex; gap: 10px; }
.btn-bar > * { flex: 1; }

.field { display: block; }
.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 0 2px 6px; }
.field small { display: block; color: var(--muted); font-size: 12px; margin: 5px 2px 0; }
.input, select.input, textarea.input {
  width: 100%; min-height: 46px; padding: 11px 13px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.input { resize: vertical; line-height: 1.5; }
.input.err { border-color: var(--bad); }
.search { position: relative; }
.search svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); }
.search .input { padding-left: 40px; border-radius: 14px; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 12px 2px; margin: 0 -16px; padding-left: 16px; padding-right: 16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 7px 14px; font-size: 14px; font-weight: 600; color: var(--muted); }
.chip.on { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.chip .n { opacity: .6; margin-left: 4px; font-weight: 500; }

.seg { display: flex; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { flex: 1; border: 0; background: transparent; border-radius: 9px; padding: 8px 10px; font-weight: 600; font-size: 14px; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.good { background: var(--good-soft); color: var(--good); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }

.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty svg { width: 44px; height: 44px; opacity: .5; margin-bottom: 8px; }
.empty b { display: block; color: var(--ink); font-size: 17px; margin-bottom: 4px; }
.notice { padding: 12px 14px; border-radius: 12px; background: var(--accent-soft); font-size: 14px; }
.notice.bad { background: var(--bad-soft); color: var(--bad); }
.notice.good { background: var(--good-soft); color: var(--good); }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
@media (max-width: 520px) { .stats { grid-template-columns: 1fr 1fr; } }
.stat { text-align: left; padding: 12px 14px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.stat b { display: block; font-size: 21px; letter-spacing: -.02em; line-height: 1.2; }
.stat span { font-size: 12px; color: var(--muted); font-weight: 600; }
button.stat { cursor: pointer; }
.stat.alert b { color: var(--bad); }
.stat.on { border-color: var(--bad); box-shadow: 0 0 0 2px var(--bad-soft); }

/* ---------- stock list ---------- */
.items { display: grid; gap: 8px; }
.item { display: flex; gap: 12px; align-items: center; padding: 12px; cursor: pointer; transition: border-color .15s; }
.item:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.item.flag { border-left: 4px solid var(--bad); }
.thumb { width: 46px; height: 58px; border-radius: 10px; flex: none; overflow: hidden; background: var(--surface-2); display: grid; place-items: center; color: var(--muted); font-weight: 800; font-size: 17px; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.item .info { flex: 1; min-width: 0; }
.item .name { font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
.item .meta { font-size: 13px; color: var(--muted); margin-top: 2px; }
.item .tags { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 6px; }
.level { height: 4px; border-radius: 2px; background: var(--surface-2); margin-top: 8px; overflow: hidden; }
.level i { display: block; height: 100%; background: var(--good); border-radius: 2px; }
.level.low i { background: var(--bad); }

.stepper { display: flex; align-items: center; background: var(--surface-2); border-radius: 13px; flex: none; }
.stepper button { width: 40px; height: 42px; border: 0; background: transparent; font-size: 22px; line-height: 1; border-radius: 13px; color: var(--ink); }
.stepper button:active { background: var(--line); }
.stepper output { min-width: 42px; text-align: center; font-weight: 800; font-size: 17px; }

.fab {
  position: fixed; z-index: 25; right: max(16px, calc(50% - 364px)); bottom: calc(var(--nav-h) + var(--safe-b) + 16px);
  height: 56px; padding: 0 22px 0 18px; border-radius: 18px; border: 0; background: var(--accent); color: var(--accent-ink);
  font-weight: 750; display: flex; align-items: center; gap: 8px; box-shadow: var(--shadow-lg);
}
.fab svg { width: 22px; height: 22px; }
@media (min-width: 980px) { .fab { bottom: 28px; } }

/* ---------- lists / rows ---------- */
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; }
.li { padding: 13px 16px; border-top: 1px solid var(--line); }
.li:first-child { border-top: 0; }
.li.warn-row { background: color-mix(in srgb, var(--bad-soft) 55%, transparent); }
.li .t { font-weight: 700; overflow-wrap: anywhere; }
.li .s { font-size: 13px; color: var(--muted); margin-top: 2px; }
.li .input { min-height: 42px; padding: 8px 11px; }
.li .ctrl { margin-top: 9px; }
.big-n { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { text-align: left; padding: 16px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); text-decoration: none; color: inherit; display: block; }
.tile .ic { width: 42px; height: 42px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; margin-bottom: 12px; }
.tile .ic svg { width: 22px; height: 22px; }
.tile b { display: block; font-size: 16px; }
.tile span { font-size: 13px; color: var(--muted); }

/* ---------- sheet ---------- */
.sheet-bg { position: fixed; inset: 0; z-index: 50; background: rgba(15, 10, 5, .45); display: flex; align-items: flex-end; justify-content: center; animation: fade .18s; }
.sheet {
  width: 100%; max-width: 640px; max-height: 92dvh; overflow: auto; background: var(--bg); border-radius: 22px 22px 0 0;
  padding: 8px 16px calc(16px + var(--safe-b)); box-shadow: var(--shadow-lg); animation: up .22s cubic-bezier(.2,.8,.2,1);
  overscroll-behavior: contain;
}
@media (min-width: 700px) { .sheet-bg { align-items: center; } .sheet { border-radius: 22px; max-height: 88dvh; } }
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 10px; }
.sheet-h { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.sheet-h h3 { flex: 1; margin: 0; font-size: 21px; letter-spacing: -.02em; }
.sheet-foot { position: sticky; bottom: calc(-16px - var(--safe-b)); background: var(--bg); padding: 12px 0 calc(4px + var(--safe-b)); margin-top: 16px; border-top: 1px solid var(--line); }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

/* ---------- toast ---------- */
.toasts { position: fixed; z-index: 60; left: 0; right: 0; bottom: calc(var(--nav-h) + var(--safe-b) + 84px); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 14px; background: var(--ink); color: var(--bg); padding: 11px 12px 11px 16px; border-radius: 14px; box-shadow: var(--shadow-lg); max-width: 520px; font-size: 14px; animation: up .2s; }
.toast button { border: 0; background: transparent; color: var(--accent); font-weight: 800; padding: 4px 6px; }
@media (min-width: 980px) { .toasts { bottom: 28px; } }

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); }
table.t { border-collapse: collapse; width: 100%; font-size: 14px; }
table.t th, table.t td { padding: 10px 12px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
table.t th { font-size: 12px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; background: var(--surface-2); position: sticky; top: 0; cursor: pointer; user-select: none; }
table.t th:first-child, table.t td:first-child { text-align: left; white-space: normal; min-width: 150px; position: sticky; left: 0; background: var(--surface); }
table.t th:first-child { background: var(--surface-2); z-index: 1; }
table.t tr.neg td { color: var(--bad); }
table.t tfoot td { font-weight: 800; background: var(--surface-2); border-bottom: 0; }
.gp { display: inline-block; min-width: 50px; text-align: center; padding: 3px 8px; border-radius: 8px; font-weight: 800; }
.gp.good { background: var(--good-soft); } .gp.warn { background: var(--warn-soft); } .gp.bad { background: var(--bad-soft); }

/* ---------- cocktails ---------- */
.cx-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.cx-card { text-align: left; padding: 14px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); cursor: pointer; display: flex; flex-direction: column; gap: 6px; }
.cx-card b { font-size: 17px; letter-spacing: -.01em; }
.cx-card .foot { display: flex; justify-content: space-between; align-items: center; margin-top: auto; padding-top: 6px; }
.recipe ol, .recipe ul { margin: 6px 0 0; padding-left: 20px; }
.recipe li { margin: 5px 0; }
.kv { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.kv > div { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.kv span { display: block; font-size: 12px; color: var(--muted); font-weight: 600; }
.kv b { font-size: 18px; }
.ing-row { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.pick { display: flex; justify-content: space-between; gap: 8px; width: 100%; text-align: left; padding: 9px 12px; margin-top: 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); font-size: 14px; }
.picked { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 8px 12px; border-radius: 10px; background: var(--accent-soft); font-weight: 650; }

.photo-edit { display: flex; gap: 14px; align-items: center; }
.photo-edit .thumb { width: 72px; height: 92px; }

.lock { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.lock .card { width: 100%; max-width: 360px; text-align: center; }
.pin { font-size: 28px; letter-spacing: .4em; text-align: center; }

.spin { width: 18px; height: 18px; border: 2.5px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: rot .7s linear infinite; display: inline-block; }
@keyframes rot { to { transform: rotate(360deg); } }
.hide { display: none !important; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- small screens ---------- */
.sync { text-decoration: none; }
@media (max-width: 520px) {
  .stat { padding: 10px 12px; }
  .stat b { font-size: 19px; }
  .item { gap: 10px; padding: 10px; }
  .thumb { width: 40px; height: 52px; font-size: 15px; }
  .stepper button { width: 34px; }
  .stepper output { min-width: 36px; font-size: 16px; }
  .brand small { display: none; }
}
.sticky-bar { position: sticky; bottom: calc(var(--nav-h) + var(--safe-b) + 10px); margin-top: 12px; }
@media (min-width: 980px) { .sticky-bar { bottom: 16px; } }
