/* Corner Cellar store app — brand tokens shared with the website (brand/README.md). System fonts: no third-party requests. */
:root {
  --wine: #6d1a36; --wine-deep: #3a0d1d; --cream: #f7f1e6; --paper: #fbf8f2; --gold-text: #8a5b17; --gold-light: #e9c98f;
  --ink: #1f2430; --muted: #555d6b; --line: #e6dccb; --ok: #1f6b3a; --bad: #a3142b; --warn-bg: #fff4d6; --warn-ink: #6b4a00;
  --radius: 14px; --serif: Georgia, 'Times New Roman', serif;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.5 var(--sans); }
h1, h2, h3 { font-family: var(--serif); color: var(--wine-deep); line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.9rem; } h2 { font-size: 1.3rem; } h3 { font-size: 1.1rem; }
a { color: var(--wine); }
a:focus-visible, button:focus-visible, input:focus-visible { outline: 3px solid var(--gold-text); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); } .small { font-size: .875rem; }
[hidden] { display: none !important; }

.demo-bar { background: var(--warn-bg); color: var(--warn-ink); font-size: .8rem; font-weight: 700; text-align: center; padding: 6px 12px; letter-spacing: .02em; }
.top { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 10px 16px; background: var(--wine-deep); color: #fff; }
.top .brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-family: var(--serif); font-weight: 700; font-size: 1.1rem; }
.top .brand small { font-family: var(--sans); font-weight: 400; color: var(--gold-light); font-size: .8rem; margin-left: 4px; }
.top nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.top nav a { color: #f3e7ea; text-decoration: none; padding: 8px 12px; border-radius: 999px; font-weight: 600; }
.top nav a[aria-current="page"], .top nav a:hover { background: rgba(255,255,255,.14); color: #fff; }
.top form { margin: 0; } .top .link { color: #f3e7ea; }

main { max-width: 760px; margin: 0 auto; padding: 20px 16px 48px; }
main.wide { max-width: 1180px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.card.narrow { max-width: 560px; margin-left: auto; margin-right: auto; }
.alert { background: #fde8ec; color: var(--bad); border-radius: 10px; padding: 10px 12px; font-weight: 600; }

label { display: block; font-weight: 600; margin: 0 0 6px; }
input[type=text], input[type=search], input[type=password], input[type=number] {
  width: 100%; font: inherit; padding: 11px 12px; border: 1.5px solid #c9bda9; border-radius: 10px; background: #fff; color: var(--ink); min-height: 46px;
}
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.row input { flex: 1 1 200px; width: auto; }
.row label { margin: 0; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: 700 1rem var(--sans); color: #fff; background: var(--wine);
  border: 2px solid var(--wine); border-radius: 999px; padding: 10px 20px; min-height: 46px; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--wine-deep); border-color: var(--wine-deep); }
.btn.ghost { background: #fff; color: var(--wine); }
.btn.ghost:hover { background: var(--cream); }
.btn.big { width: 100%; font-size: 1.1rem; min-height: 56px; margin-top: 8px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--wine); text-decoration: underline; cursor: pointer; }
form .btn { margin-top: 12px; }
.row .btn { margin-top: 0; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin: 20px 0; }
.tile { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 20px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  text-decoration: none; color: var(--ink); min-height: 130px; }
.tile:hover { border-color: var(--wine); box-shadow: 0 4px 14px rgba(58,13,29,.08); }
.tile-k { font-family: var(--serif); font-size: 1.4rem; font-weight: 700; color: var(--wine); }
.badge { align-self: flex-start; background: var(--warn-bg); color: var(--warn-ink); font-weight: 700; font-size: .8rem; padding: 3px 10px; border-radius: 999px; }

/* register */
.register { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 900px) { .register { grid-template-columns: 1.1fr .9fr; align-items: start; } .register > .card:last-child { position: sticky; top: 12px; } }
.results, .cart { list-style: none; margin: 0; padding: 0; }
.results li { border-top: 1px solid var(--line); }
.results li:first-child { border-top: 0; }
.pick { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 4px; background: none; border: 0; font: inherit; color: inherit; text-align: left; cursor: pointer; min-height: 56px; }
.pick:hover:not(:disabled) { background: var(--cream); }
.pick:disabled { opacity: .5; cursor: not-allowed; }
.pick img, .pick .ph { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: var(--cream); flex: none; }
.ln { flex: 1; display: flex; flex-direction: column; }
.cart li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.cart .empty { border: 0; }
.qty { display: inline-flex; align-items: center; gap: 8px; }
.q { width: 36px; height: 36px; border-radius: 50%; border: 1.5px solid var(--wine); background: #fff; color: var(--wine); font: 700 1.1rem var(--sans); cursor: pointer; }
.amt { min-width: 72px; text-align: right; font-weight: 700; }
.total { display: flex; justify-content: space-between; font-size: 1.2rem; margin: 12px 0; }
.member { background: var(--cream); border-radius: 10px; padding: 12px; margin-bottom: 8px; }
.member p { margin: 6px 0 0; }
.scanner { margin: 8px 0 12px; }
.scanner video { width: 100%; max-height: 300px; background: #000; border-radius: 10px; object-fit: cover; display: block; margin-bottom: 8px; }
dialog { border: 0; border-radius: var(--radius); padding: 24px; max-width: 440px; width: calc(100% - 32px); }
dialog::backdrop { background: rgba(27,20,24,.55); }
.big-total { font-family: var(--serif); font-size: 2.2rem; color: var(--wine); margin: 0; }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-weight: 600; max-width: calc(100% - 32px); z-index: 10; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.toast.bad { background: var(--bad); }

/* stock */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs a { padding: 8px 14px; border-radius: 999px; border: 1.5px solid var(--line); background: #fff; text-decoration: none; font-weight: 600; color: var(--wine-deep); }
.tabs a[aria-current="page"] { background: var(--wine); border-color: var(--wine); color: #fff; }
.item { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 12px; }
.item-head { display: flex; gap: 12px; align-items: center; }
.item-head img { border-radius: 10px; object-fit: cover; }
.item-head h3 { margin: 0; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
thead th { background: var(--cream); color: var(--wine-deep); font-size: .85rem; white-space: nowrap; }
tfoot th, tfoot td { border-bottom: 0; }
tr.out td:first-child { border-left: 4px solid var(--bad); }
tr.low td:first-child { border-left: 4px solid var(--gold-text); }
.pill { display: inline-block; font-size: .75rem; font-weight: 700; padding: 1px 8px; border-radius: 999px; }
.pill.out { background: #fde8ec; color: var(--bad); }
.po-buttons { display: flex; gap: 8px; flex-wrap: wrap; }

/* dashboard */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin: 16px 0; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; }
.kpi-k { font-size: .85rem; color: var(--muted); font-weight: 600; }
.kpi strong { font-family: var(--serif); font-size: 1.6rem; color: var(--wine-deep); }
.chart { margin: 0; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .bar { fill: #c9a4b0; } .chart .bar.wkd { fill: var(--wine); }
.chart .axis { stroke: var(--line); stroke-width: 1; }
.chart .tick { font: 11px var(--sans); fill: var(--muted); }
.key { display: inline-block; width: 12px; height: 12px; border-radius: 3px; background: #c9a4b0; vertical-align: -1px; margin: 0 4px 0 10px; }
.key.wkd { background: var(--wine); margin-left: 0; }
.two { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 900px) { .two { grid-template-columns: 1fr 1fr; } }
.mix { list-style: none; padding: 0; margin: 0; }
.mix li { display: grid; grid-template-columns: 9.5rem 1fr 3rem; align-items: center; gap: 10px; padding: 8px 0; }
.mix-bar { width: 100%; height: 12px; display: block; }
.mix-bar rect { fill: var(--wine); } .mix-bar rect.track { fill: var(--cream); }
.mix strong { text-align: right; }

/* labels + print */
.labels { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.label { margin: 0; background: #fff; border: 1px dashed #c9bda9; border-radius: 10px; padding: 12px; text-align: center; break-inside: avoid; }
.label svg { max-width: 100%; height: auto; }
.print-demo { font-weight: 700; color: var(--bad); letter-spacing: .05em; }
@media print {
  .demo-bar, .top, .no-print, .toast { display: none !important; }
  body { background: #fff; } main { max-width: none; padding: 0; } .card { border: 0; padding: 0; }
}
@media (max-width: 620px) {
  .top { gap: 8px 12px; } .top form { margin-left: auto; }
  .top nav { order: 3; flex-basis: 100%; justify-content: space-between; }
  .top nav a { flex: 1; text-align: center; padding: 8px 6px; }
}
@media (max-width: 520px) {
  h1 { font-size: 1.5rem; } .mix li { grid-template-columns: 7.5rem 1fr 2.6rem; }
}
.table-wrap:focus-visible { outline: 3px solid var(--gold-text); outline-offset: 2px; border-radius: 6px; }

/* phones: stacked table rows (cards) */
@media (max-width: 620px) {
  table.stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.stack, table.stack tbody, table.stack tfoot, table.stack tr { display: block; }
  table.stack tr { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px; padding: 6px 10px; }
  table.stack td, table.stack tfoot th { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 4px 0; text-align: right; }
  table.stack td::before { content: attr(data-label); font-weight: 600; color: var(--muted); text-align: left; }
  table.stack td:first-child { display: block; text-align: left; font-weight: 700; border-left: 0 !important; padding-bottom: 6px; }
  table.stack td:first-child::before { content: none; }
  table.stack tr.out { border-left: 5px solid var(--bad); } table.stack tr.low { border-left: 5px solid var(--gold-text); }
  table.stack tfoot th[colspan] { display: none; }
}
