/* Layout and components. Colours and fonts come from tokens.css. */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html { background: var(--paper); }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 16px/1.4 var(--font); -webkit-tap-highlight-color: transparent; }
.wrap { max-width: 560px; margin: 0 auto; padding: 0 16px calc(96px + env(safe-area-inset-bottom)); }
a { color: var(--ink); text-decoration-color: color-mix(in srgb, var(--ink) 35%, transparent); text-underline-offset: 3px; }
p { margin: 0 0 10px; }
b { font-weight: 650; }

/* Header: a band with fine horizontal print layers */
.top { margin: 0 -16px 14px; padding: calc(20px + env(safe-area-inset-top)) 16px 13px; border-bottom: 1px solid var(--line);
  background: repeating-linear-gradient(to bottom, transparent 0 3px, var(--layer) 3px 4px); }
.top h1 { margin: 0; font-size: 30px; line-height: 1.05; font-weight: 700; letter-spacing: -.02em; font-variation-settings: "SHRP" 100; text-wrap: balance; }
.sync { margin: 9px 0 0; font-size: 13.5px; color: var(--ink-soft); display: flex; align-items: center; gap: 7px; }
.sync::before { content: ""; flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--brand); }
.sync.bad::before { background: var(--alarm); }
.lead { font-size: 15px; color: var(--ink-soft); margin: -4px 0 14px; }

h2 { font-size: 17px; font-weight: 650; margin: 28px 0 8px; font-variation-settings: "SHRP" 100; }
.soft { color: var(--ink-soft); } .small { font-size: 13px; }
.warn { color: var(--alarm); font-weight: 600; }
.flash { background: var(--brand-soft); border-radius: var(--r-panel); padding: 12px 14px; margin: 0 0 14px; font-size: 15px; }

/* Panels and forms */
.card { background: var(--surface); border-radius: var(--r-panel); padding: 14px; margin: 12px 0; }
.card > :last-child { margin-bottom: 0; }
.card h2 { margin: 6px 0 0; }
.stack { display: grid; gap: 12px; }
.stack label { display: grid; gap: 5px; font-size: 13.5px; color: var(--ink-soft); }
.stack label.pair { grid-template-columns: 1fr auto; align-items: center; gap: 12px; font-size: 15px; color: var(--ink); }
.inline { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.inline label { display: grid; gap: 5px; font-size: 13.5px; color: var(--ink-soft); }
.inline label.grow { flex: 1; min-width: 150px; }
.with-pot { display: flex; align-items: center; gap: 10px; }
.with-pot .pot { --d: 34px; }
input, select { font: inherit; font-size: 16px; min-height: 44px; padding: 9px 12px; border: 1.5px solid var(--line); border-radius: var(--r-field);
  background: var(--paper); color: var(--ink); width: 100%; }
input:focus, select:focus { outline: none; border-color: var(--brand); }
select { appearance: none; padding-right: 34px;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-soft) 50%), linear-gradient(135deg, var(--ink-soft) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.qtyin { width: 4.4em; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; padding-left: 6px; padding-right: 6px; }

/* Buttons */
.btn { font: inherit; font-weight: 650; font-size: 15px; line-height: 1.2; border-radius: 999px; padding: 11px 18px; min-height: 44px; border: 0;
  background: var(--brand); color: var(--brand-ink); cursor: pointer; }
.btn:active { transform: scale(.97); }
a.btn { display: inline-flex; align-items: center; text-decoration: none; }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--ink) 20%, transparent); }
.btn.small { padding: 9px 15px; font-size: 14px; min-height: 40px; }
.btn.full { display: block; width: 100%; padding: 15px; font-size: 16px; margin-top: 12px; }
.btn:disabled { opacity: .6; }
.link { background: none; border: 0; padding: 6px 0; color: var(--ink-soft); text-decoration: underline; text-underline-offset: 3px; font: inherit; font-size: 14px; cursor: pointer; }
.acts { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.acts form { margin: 0; }

/* Something that waits for a decision: a request from Diana, an Ozon mismatch */
.req { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 13px 14px; margin: 0 0 10px; font-size: 15px; }
.req p { margin: 0; }
.req .btn { padding: 9px 15px; font-size: 14px; min-height: 40px; } .req .note { display: block; color: var(--ink-soft); margin-top: 2px; }

/* Lists of pots */
.rows { list-style: none; padding: 0; margin: 0; }
.row { display: flex; align-items: center; gap: 12px; min-height: 66px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.row > form { margin: 0; }
.row.wrapline { flex-wrap: wrap; }
.row > .pot { --d: 56px; --gap: 6px; }
.row .info { flex: 1; min-width: 0; display: grid; gap: 1px; text-decoration: none; color: inherit; }
a.info:active .name { text-decoration: underline; }
.name { font-weight: 600; font-size: 16px; }
.why { font-size: 13.5px; color: var(--ink-soft); } .why.alarm { color: var(--alarm); font-weight: 600; }
.qty { font-weight: 700; font-size: 19px; min-width: 36px; text-align: right; font-variant-numeric: tabular-nums; }
.qty.zero { color: var(--ink-soft); font-weight: 500; font-size: 16px; }
/* Quiet row action: «+4 / в очередь», «Напечатал». Says what it does, does not shout. */
.qbtn { font: inherit; display: grid; justify-items: center; gap: 1px; min-width: 72px; min-height: 44px; padding: 6px 10px; border: 0; border-radius: 12px;
  background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); font-size: 14px; font-weight: 650; cursor: pointer; }
.qbtn b { font-size: 17px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.qbtn small { font-size: 11px; font-weight: 500; color: var(--ink-soft); }
.qbtn:active { transform: scale(.97); }
.qbtn[aria-expanded=true] { box-shadow: inset 0 0 0 1.5px var(--brand); }
.section { font-size: 17px; margin: 26px 0 2px; display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.section:first-of-type { margin-top: 6px; }
.section .count { font-size: 13px; font-weight: 400; color: var(--ink-soft); }
.hint { margin: 0 0 4px; font-size: 13px; color: var(--ink-soft); }
.empty-note { margin: 6px 0 0; font-size: 14px; color: var(--ink-soft); }
.row .printed { display: none; flex-basis: 100%; padding-left: 68px; }
.row.open .printed { display: block; }
.row .printed .done { padding-left: 0; }
.row .printed .link { margin-top: 2px; }
.fold { margin-top: 22px; border: 1px dashed var(--line); border-radius: var(--r-panel); }
.fold > summary { list-style: none; cursor: pointer; padding: 14px; display: flex; justify-content: space-between; align-items: center; color: var(--ink-soft); font-size: 15px; }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::after { content: ""; width: 7px; height: 7px; border: solid var(--ink-soft); border-width: 0 2px 2px 0; transform: rotate(45deg); margin: -4px 4px 0; }
.fold[open] > summary::after { transform: rotate(-135deg); margin-top: 4px; }
.fold > .rows { padding: 0 12px 4px; }
.rows .empty { padding: 14px 0; color: var(--ink-soft); }
.foot { margin: 14px 0 0; }
.group { font-size: 14px; font-weight: 600; color: var(--ink-soft); margin: 28px 0 0; }

/* Queue: «done» form on its own line under the name */
.row .done { flex-basis: 100%; display: flex; gap: 8px; align-items: end; padding-left: 64px; }
.done label { display: grid; gap: 3px; font-size: 12px; color: var(--ink-soft); }
.done .btn { margin-left: auto; }
.row .addq { display: flex; gap: 6px; align-items: center; }

/* Batch acceptance */
.edit { flex-basis: 100%; padding-left: 56px; }
.edit summary { display: inline-block; list-style: none; font-size: 14px; color: var(--ink-soft); padding: 4px 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.edit summary::-webkit-details-marker { display: none; }
.edit summary::before { content: ""; display: inline-block; width: 9px; height: 5px; margin: 0 8px 3px 1px; border: solid var(--brand); border-width: 0 0 2px 2px; transform: rotate(-45deg); }
.edit[open] summary::before { display: none; }
.edit[open] summary { color: var(--ink); text-decoration: none; font-weight: 600; }
.edit .fields { display: grid; grid-template-columns: auto auto 1fr; gap: 8px; margin-top: 6px; }
.edit .fields label:last-child { grid-column: 1 / -1; }
.edit label { display: grid; gap: 3px; font-size: 12px; color: var(--ink-soft); }
.after { background: var(--surface); border-radius: var(--r-panel); padding: 14px; margin: 16px 0 0; font-size: 14px; color: var(--ink-soft); }
.after ul { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 4px; }
.after li { display: flex; justify-content: space-between; color: var(--ink); font-variant-numeric: tabular-nums; }
.after .warn { margin: 10px 0 0; }

/* Shelf: pots stand on a board, label under each */
.shelf { margin: 0; }
.shelf .group { margin: 24px 0 10px; }
.shelfgrid { display: grid; grid-template-columns: repeat(4, 1fr); align-items: end; }
.cell { display: flex; flex-direction: column; align-items: center; padding: 0 0 4px; text-decoration: none; color: inherit; border-radius: 6px; }
.cell .pot { --d: 70px; --gap: 7px; margin-bottom: 8px; }
.cell .n { align-self: stretch; text-align: center;
  font-size: 22px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.cell .n.zero { color: var(--alarm); }
.cell .c { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.history { font-size: 14px; color: var(--ink-soft); margin-top: 30px; }
.history b { color: var(--ink); }

/* Product page */
.hero { display: flex; align-items: center; gap: 20px; margin: 4px 0 14px; }
.stock .cnt { margin: 0; font-size: 16px; color: var(--ink-soft); }
.stock .cnt b { font-size: 40px; line-height: 1; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; margin-right: 2px; }
.stock .cnt.out { font-size: 22px; font-weight: 700; color: var(--alarm); }
.stock .why { margin: 4px 0 0; font-size: 14.5px; color: var(--ink-soft); }
.balances { display: flex; gap: 8px 22px; flex-wrap: wrap; margin: 0 0 18px; font-size: 14px; color: var(--ink-soft); }
.balances span { display: grid; }
.balances b { font-size: 26px; line-height: 1.1; color: var(--ink); font-variant-numeric: tabular-nums; }

/* Timelines */
.hist { list-style: none; padding: 0; margin: 0; font-size: 14.5px; }
.hist li { display: grid; grid-template-columns: 88px 1fr; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.hist li.empty { display: block; color: var(--ink-soft); }
.hist .t { color: var(--ink-soft); font-variant-numeric: tabular-nums; font-size: 13px; padding-top: 1px; }
.hist form { display: block; margin: 2px 0 0; }
.hist .link { padding: 2px 0; font-size: 13px; }

/* «Ещё» */
.links { display: grid; margin: 0 0 6px; }
.links a { display: flex; justify-content: space-between; align-items: center; padding: 14px 2px; border-bottom: 1px solid var(--line); text-decoration: none; font-weight: 600; }
.links a::after { content: ""; width: 7px; height: 7px; border: solid var(--ink-soft); border-width: 2px 2px 0 0; transform: rotate(45deg); margin-right: 4px; }

/* Login */
.brandmark { display: flex; align-items: center; justify-content: space-around; margin: 22px 0 14px; padding: 0 8px; }
.brandmark .pot { --d: 64px; }
.brandmark + .lead { margin-bottom: 18px; }

/* Bottom tabs: icon + label, tall enough to hit with a thumb */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; justify-content: center;
  background: color-mix(in srgb, var(--surface) 92%, transparent); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-top: 1px solid var(--line); padding: 0 6px env(safe-area-inset-bottom); }
.tabs a { flex: 1; max-width: 120px; min-height: 62px; display: grid; justify-items: center; align-content: center; gap: 3px;
  text-decoration: none; color: var(--ink-soft); font-size: 12px; -webkit-tap-highlight-color: transparent; }
.tabs svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tabs svg circle { fill: currentColor; stroke: none; }
.tabs a.on { color: var(--ink); font-weight: 650; }
.tabs a.on svg { color: var(--brand); }
.tabs a:active { background: color-mix(in srgb, var(--ink) 8%, transparent); border-radius: 14px; }

/* Tap feedback: the moment a link or form is used, a thin bar runs along the top until the next page arrives */
body.busy::after { content: ""; position: fixed; z-index: 9; left: 0; top: env(safe-area-inset-top); height: 3px; width: 40%;
  background: var(--brand); border-radius: 0 3px 3px 0; animation: busy 1s ease-in-out infinite; }
@keyframes busy { from { transform: translateX(-100%); } to { transform: translateX(260%); } }

/* Page changes cross-fade quickly and the tab bar stays put (Safari 18.2+, Chrome 126+) */
@view-transition { navigation: auto; }
.tabs { view-transition-name: tabs; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .14s; }
@media (prefers-reduced-motion: reduce) { body.busy::after { animation: none; width: 100%; } ::view-transition-group(*) { animation: none; } }

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
.btn:focus-visible { border-radius: 999px; }
@media (prefers-reduced-motion: reduce) { .btn:active { transform: none; } }

/* Pot: round photo of the real pot (pot macro in base.html). With a level, a ring around it shows stock against
   the norm: fills clockwise from the top, brand colour, orange at a third or less; out of stock fades the photo. */
.pot { --d: 44px; --gap: calc(var(--d) * .15); position: relative; display: inline-block; flex: none; width: var(--d); height: var(--d); }
.pot img { display: block; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; background: #8d8b88; }
.pot.ring img { position: absolute; left: var(--gap); top: var(--gap); width: calc(100% - 2 * var(--gap)); height: calc(100% - 2 * var(--gap)); }
.pot svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.pot circle { fill: none; stroke-width: 7; }
.pot .trk { stroke: color-mix(in srgb, var(--ink) 13%, transparent); }
.pot .lv { stroke: var(--brand); stroke-linecap: round; }
.pot.low .lv { stroke: var(--alarm); }
.pot.out img { filter: saturate(.5) contrast(.9); opacity: .75; }
.pot.big { --d: 168px; --gap: 14px; }
.pot.big circle { stroke-width: 4; }

/* Drawn pot: fallback for codes without a photo (SVG sprite in base.html). Width follows volume, fill = stock level. */
.pot.drawn { --sw: var(--gr); --s: 1; --w: 27px; width: calc(var(--w) * var(--s)); height: calc(var(--w) * 1.2 * var(--s)); overflow: visible; }
.pot.drawn.v100 { --w: 22px; } .pot.drawn.v200 { --w: 27px; } .pot.drawn.v300 { --w: 30px; } .pot.drawn.v400 { --w: 33px; }
.pot.drawn .ghost { fill: color-mix(in srgb, var(--sw) 22%, var(--paper)); }
.pot.drawn .fill { fill: var(--sw); }
.pot.drawn .edge { fill: none; stroke: color-mix(in srgb, var(--sw) 55%, var(--ink)); stroke-opacity: .55; stroke-width: .9; }
.pot.drawn .rim { fill: color-mix(in srgb, var(--sw) 82%, var(--ink)); }
.sw-gr { --sw: var(--gr); } .sw-bg { --sw: var(--bg); } .sw-pn { --sw: var(--pn); } .sw-yl { --sw: var(--yl); }
