@font-face { font-family: "EB Garamond"; font-weight: 500; font-display: swap; src: url(fonts/eb-garamond-latin-500-normal.woff2) format("woff2"); }
@font-face { font-family: "EB Garamond"; font-weight: 600; font-display: swap; src: url(fonts/eb-garamond-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: "EB Garamond"; font-weight: 400; font-style: italic; font-display: swap; src: url(fonts/eb-garamond-latin-400-italic.woff2) format("woff2"); }

:root {
  --paper: #FAF6EF; --card: #FFFDF8; --ink: #2B1E1B; --muted: #7C6B63; --rule: #E7DCCE;
  --wine: #6E1F30; --wine-soft: #F3E4E2; --ok: #3F6B45; --warn: #9A5B12;
  --serif: "EB Garamond", Garamond, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  --top: env(safe-area-inset-top, 0px);
  --bottom: max(8px, calc(env(safe-area-inset-bottom, 0px) - var(--dead, 0px)));
  --side: max(16px, env(safe-area-inset-left, 0px));
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.4 var(--sans); -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; margin: 0; letter-spacing: .005em; }

/* Sign in */
.signin { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: calc(var(--top) + 24px) 28px 40px; text-align: center; }
.signin img { border-radius: 22px; }
.signin h1 { font-size: 30px; }
.signin form { width: 100%; max-width: 320px; display: grid; gap: 12px; }
.error { color: #A3261C; min-height: 1.4em; margin: 0; font-size: 14px; }

/* Frame */
.top { position: sticky; top: 0; z-index: 5; background: rgba(250, 246, 239, .94); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  padding: calc(var(--top) + 10px) var(--side) 10px; border-bottom: 1px solid var(--rule); display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.top h1 { font-size: 30px; line-height: 1.1; }
.totals { margin: 0; color: var(--muted); font-size: 14px; text-align: right; font-variant-numeric: tabular-nums; }
main { padding: 4px var(--side) calc(84px + var(--bottom)); outline: none; }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(255, 253, 248, .96); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); border-top: 1px solid var(--rule);
  padding: 6px max(6px, env(safe-area-inset-left, 0px)) var(--bottom); }
.tabs button { border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0; color: var(--muted); font-size: 11px; }
.tabs svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.tabs button[aria-current="page"] { color: var(--wine); }

/* Shelves and lists */
.shelf { margin-top: 18px; }
.shelf-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 6px 0 6px; border-bottom: 1.5px solid var(--wine); }
.shelf-head h2 { font-size: 22px; color: var(--wine); }
.shelf-head h2 .num { font-variant-numeric: oldstyle-nums; margin-right: .35em; color: var(--ink); opacity: .55; }
.shelf-head .meta { color: var(--muted); font-size: 13px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.rows { list-style: none; margin: 0; padding: 0; }
.row { display: flex; gap: 12px; justify-content: space-between; align-items: flex-start; padding: 11px 0; border-bottom: 1px solid var(--rule); cursor: pointer; }
.row:active { background: var(--wine-soft); }
.row .name { font-family: var(--serif); font-size: 19px; line-height: 1.2; font-weight: 500; }
.row .name .v { color: var(--muted); }
.row .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.row .right { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.row .qty { font-size: 15px; }
.row .price { color: var(--muted); font-size: 13px; }
.chip { display: inline-block; font-size: 11.5px; padding: 1px 7px; border-radius: 99px; background: var(--wine-soft); color: var(--wine); margin-left: 6px; vertical-align: 2px; font-family: var(--sans); font-weight: 500; }
.chip.wait { background: #EEF0E6; color: #4D5A2E; }
.empty { color: var(--muted); padding: 18px 0; }
.lead { color: var(--muted); font-size: 14px; margin: 12px 0 0; }

/* Search */
.search { padding: 12px 0 8px; }
input[type="search"], input[type="text"], input[type="number"], input[type="password"], select, textarea {
  width: 100%; font-size: 16px; padding: 10px 12px; border: 1px solid #D8CBBB; border-radius: 10px; background: var(--card); -webkit-appearance: none; appearance: none; }
select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 55%, calc(100% - 12px) 55%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 28px; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(110, 31, 48, .35); outline-offset: 0; border-color: var(--wine); }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.filters label { display: grid; gap: 3px; font-size: 12px; color: var(--muted); }
.filters select { padding: 8px 28px 8px 10px; font-size: 15px; }
.result-line { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; font-weight: 600; font-variant-numeric: tabular-nums; }
.linkbtn { border: 0; background: none; color: var(--wine); font-weight: 500; padding: 4px 0; }

/* Summary */
.big { display: flex; gap: 28px; margin: 18px 0 6px; }
.big div { display: grid; }
.big b { font-family: var(--serif); font-size: 40px; font-weight: 600; line-height: 1; font-variant-numeric: lining-nums tabular-nums; }
.big span { color: var(--muted); font-size: 13px; }
.bars { list-style: none; padding: 0; margin: 14px 0 0; }
.bars li { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 8px 0; border-bottom: 1px solid var(--rule); font-size: 15px; cursor: pointer; }
.bars .bar { grid-column: 1 / -1; height: 6px; background: var(--wine-soft); border-radius: 3px; overflow: hidden; }
.bars .bar i { display: block; height: 100%; background: var(--wine); border-radius: 3px; }
.bars .n { color: var(--muted); font-variant-numeric: tabular-nums; }
h2.section { font-size: 23px; margin-top: 26px; }
.log { list-style: none; padding: 0; margin: 8px 0 0; font-size: 14px; }
.log li { padding: 8px 0; border-bottom: 1px solid var(--rule); display: grid; grid-template-columns: 62px 1fr; gap: 8px; }
.log .d { color: var(--muted); font-variant-numeric: tabular-nums; }
.tools { display: flex; gap: 10px; flex-wrap: wrap; margin: 18px 0; }

/* Buttons */
.btn { border: 1px solid #D8CBBB; background: var(--card); border-radius: 12px; padding: 11px 14px; font-weight: 500; font-size: 16px; }
.btn.primary { background: var(--wine); border-color: var(--wine); color: #FBF3EA; }
.btn:disabled { opacity: .5; }
.actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 16px 0 6px; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { border: 1px solid #D8CBBB; background: var(--card); border-radius: 99px; padding: 7px 12px; font-size: 14px; }
.seg button[aria-pressed="true"] { background: var(--wine); color: #FBF3EA; border-color: var(--wine); }
.stepper { display: inline-flex; align-items: center; border: 1px solid #D8CBBB; border-radius: 12px; overflow: hidden; background: var(--card); }
.stepper button { border: 0; background: none; width: 44px; height: 42px; font-size: 22px; color: var(--wine); }
.stepper output { min-width: 34px; text-align: center; font-variant-numeric: tabular-nums; font-size: 17px; }

/* Wine sheet */
.sheet { position: fixed; inset: 0; z-index: 20; background: var(--paper); overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: calc(var(--top) + 6px) var(--side) calc(28px + var(--bottom)); animation: up .22s ease-out; }
@keyframes up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet .back { border: 0; background: none; color: var(--wine); font-size: 17px; padding: 8px 0; display: inline-flex; align-items: center; gap: 4px; }
.sheet h2 { font-size: 30px; line-height: 1.1; margin-top: 6px; }
.sheet .producer { font-family: var(--serif); font-size: 19px; color: var(--muted); margin-top: 8px; }
.facts { margin: 16px 0 0; display: grid; grid-template-columns: 96px 1fr; gap: 7px 12px; font-size: 15px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.notes { font-family: var(--serif); font-size: 18px; line-height: 1.45; margin: 16px 0 0; padding-top: 14px; border-top: 1px solid var(--rule); white-space: pre-wrap; }
.panel { background: var(--card); border: 1px solid var(--rule); border-radius: 14px; padding: 14px; margin: 10px 0; display: grid; gap: 12px; }
.panel .label { font-size: 13px; color: var(--muted); margin-bottom: -6px; }
.panel .row2 { display: flex; gap: 10px; align-items: center; justify-content: space-between; }

/* Add / edit form */
.form { display: grid; gap: 12px; margin-top: 14px; }
.form label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.form label b { color: var(--wine); font-weight: 500; }
.form .two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form textarea { min-height: 96px; resize: vertical; }
.form details { border-top: 1px solid var(--rule); padding-top: 10px; }
.form summary { color: var(--wine); font-weight: 500; padding: 4px 0; }
.form details[open] { display: grid; gap: 12px; }
.match { background: var(--wine-soft); color: var(--wine); border-radius: 10px; padding: 10px 12px; font-size: 14px; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(76px + var(--bottom)); z-index: 30; background: #2B1E1B; color: #FBF3EA;
  padding: 10px 16px; border-radius: 12px; font-size: 14px; max-width: calc(100% - 32px); box-shadow: 0 6px 20px rgba(0,0,0,.18); }
