/* «Призма»: PrismaPro 3 layout language (title-barred panels, flat data grids, square buttons) in Profi System colours. */
:root {
  --blue: #0D4C9C;
  --blue-ink: #0A3B7A;
  --blue-soft: #E3ECF7;
  --graphite: #12161C;
  --text: #12161C;
  --muted: #59616E;
  --line: #D5DAE1;
  --head: #EEF1F5;
  --bg: #F2F4F7;
  --card: #FFFFFF;
  --warn-bg: #FFF4DB;
  --warn: #7A5000;
  --flag-bg: #FFF0E8;
  --flag: #B3261E;
  --ok-bg: #E4F4EA;
  --ok: #1D6B3A;
  --r: 4px;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}
p { margin: .2rem 0; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.pad { padding: 0 14px 12px; }
.mono, .num, td, dd { font-variant-numeric: tabular-nums; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

.bar {
  position: sticky; top: 0; z-index: 3; display: flex; align-items: center; gap: 12px;
  padding: 10px max(16px, env(safe-area-inset-left)); background: var(--graphite); color: #fff;
}
.brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.15rem; letter-spacing: .02em; }
.brand::before { content: ""; display: inline-block; width: 10px; height: 18px; margin-right: 8px; vertical-align: -3px;
  background: linear-gradient(135deg, var(--blue) 50%, #fff 50%); }
.release { font-size: .8rem; color: #B8C0CC; margin-left: auto; }
.bar .link { color: #fff; }

main { max-width: 1320px; margin: 0 auto; padding: 12px 12px 48px; }
.layout { display: grid; gap: 12px; align-items: start; }
@media (min-width: 1024px) {
  .layout { grid-template-columns: 440px minmax(0, 1fr); }
  .left { position: sticky; top: 120px; max-height: calc(100vh - 132px); overflow: auto; }
}
/* step breadcrumb: Колір › Каталог › Продукт › Фасовка, sticky under the header */
.crumbs { position: sticky; top: 64px; z-index: 2; display: flex; align-items: center; gap: 8px; padding: 2px 12px;
  background: #fff; border-bottom: 1px solid var(--line); box-shadow: 0 2px 6px rgba(18, 22, 28, .06); }
.crumbs .tchip { flex: 0 0 auto; margin: 0; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .2); }
.crumbs ol { display: flex; gap: 0 2px; margin: 0; padding: 0; list-style: none; min-width: 0; overflow-x: auto;
  scrollbar-width: none; }
.crumbs li { display: flex; align-items: center; flex: 0 0 auto; }
.crumbs li + li::before { content: "›"; color: var(--muted); padding: 0 4px; }
.crumbs li:first-child { position: sticky; left: 0; z-index: 1; background: #fff; box-shadow: 8px 0 8px -6px rgba(18, 22, 28, .25); }  /* the code never scrolls away */
.crumb { position: relative; min-height: 44px; padding: 4px 6px; border: 0; background: none; color: var(--muted); font-size: .8rem; text-align: left;
  border-radius: var(--r); line-height: 1.2; }
.crumb b { display: block; color: var(--text); font-size: .95rem; font-weight: 600; max-width: 30ch; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.crumb b:empty::after { content: "—"; color: var(--muted); font-weight: 400; }
.crumb[aria-current="step"] { background: var(--blue-soft); color: var(--blue-ink); }
@media (max-width: 1023px) {
  .crumb { padding: 4px; }   /* phone: values only, one line; labels stay for screen readers */
  .crumb .lbl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .crumb b { font-size: .9rem; max-width: 14ch; }
  .crumb[aria-current="step"] b:empty::after { content: "оберіть"; color: var(--blue-ink); }
}
@media (hover: hover) and (pointer: fine) { .crumb:hover { background: var(--head); } }

/* PrismaPro-style panel: coloured title bar, white body */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 12px; overflow: clip; }
.panel .title { margin: 0; padding: 9px 14px; background: var(--blue); color: #fff; font-size: 1rem; font-weight: 600; }
/* PrismaPro: once a colour / catalogue is picked its list folds to the chosen row; «Змінити» unfolds it */
.panel { position: relative; }
.change { display: none; position: absolute; top: 0; right: 4px; min-height: 40px; padding: 0 10px; border: 0;
  background: none; color: #fff; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.picked .change { display: block; }
.picked tbody tr:not([aria-current="true"]), .picked .hint { display: none; }
@media (max-width: 1023px) { #step-colour.picked #search-form, #step-deck.picked .hero { display: none; } }
.panel .body { padding: 12px 14px; }
.narrow { max-width: 380px; margin: 10vh auto 0; }

label { display: block; font-size: .875rem; font-weight: 600; margin: 0 0 4px; }
.body label + input, .body input + label { margin-top: 0; }
#login-form label { margin-top: 10px; }
input, select, button { font: inherit; }
input, select {
  width: 100%; min-height: 44px; padding: 9px 12px; border: 1px solid #BFC6D1; border-radius: var(--r);
  background: #fff; color: var(--text);
}
input:focus-visible, select:focus-visible, button:focus-visible, tr[tabindex]:focus-visible {
  outline: 3px solid var(--blue); outline-offset: 1px;
}
/* full-bleed rows/options sit inside clipped panels: draw the ring inside so it is never cut */
tr[tabindex]:focus-visible, .opt:focus-visible, .crumb:focus-visible { outline-offset: -3px; }
#q { font-size: 1.1rem; }

button { cursor: pointer; transition: transform 140ms var(--ease-out), background-color 160ms ease; }
button:active { transform: scale(0.97); }
.btn { min-height: 44px; padding: 9px 18px; border: 0; border-radius: var(--r); font-weight: 600; background: var(--blue); color: #fff; }
.btn.wide { width: 100%; margin-top: 14px; }
.btn.secondary { background: var(--blue-soft); color: var(--blue-ink); }
.btn.danger { background: var(--flag); color: #fff; }
@media (hover: hover) and (pointer: fine) {
  .btn:hover { background: var(--blue-ink); }
  .btn.secondary:hover { background: #D2E0F2; }
  .btn.danger:hover { background: #8F1E18; }
  .grid tbody tr[tabindex]:hover { background: #F4F7FB; }
  .opt:hover, .chip:hover { border-color: var(--blue); }
}
.link { background: none; border: 0; color: var(--blue); padding: 8px 0; min-height: 44px; }
.error { color: var(--flag); min-height: 1.4em; font-size: .875rem; }
.hint { color: var(--muted); font-size: .875rem; padding: 10px 14px; margin: 0; }

/* Data grid (PrismaPro tables) */
.grid { width: 100%; border-collapse: collapse; }
.grid th { background: var(--head); color: var(--muted); font-size: .8rem; font-weight: 600; text-align: left;
  padding: 7px 10px; border-bottom: 1px solid var(--line); }
.grid td { padding: 9px 10px; border-bottom: 1px solid var(--line); height: 48px; overflow-wrap: anywhere; }
.grid tbody tr[tabindex] { cursor: pointer; }
.grid tbody tr[aria-current="true"] { background: var(--blue-soft); box-shadow: inset 3px 0 0 var(--blue); }
.grid .chipcol { width: 52px; }
.grid td b { font-weight: 600; }
.grid .num { text-align: right; white-space: nowrap; }
.chipcell { width: 52px; }
.chipcell span { display: block; width: 32px; height: 32px; border-radius: 3px; border: 1px solid rgba(0, 0, 0, .12); }

.swatch { background: #ddd; border: 1px solid rgba(0, 0, 0, .1); border-radius: var(--r); }
.none { background: repeating-linear-gradient(45deg, #e8e8e8 0 6px, #f6f6f6 6px 12px) !important; }
.hero { display: flex; gap: 14px; align-items: center; }
.swatch.big { flex: 0 0 96px; height: 96px; }
.code { font-size: 1.6rem; font-weight: 700; line-height: 1.15; letter-spacing: -0.01em; }

/* Product list (radio rows) and can chips */
.list { display: grid; grid-template-columns: 1fr; }
@media (min-width: 1024px) { .list { grid-template-columns: 1fr 1fr; } .list .opt:nth-child(odd) { border-right: 1px solid var(--line); } }
.opt { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 48px; padding: 8px 14px; text-align: left;
  border: 0; border-bottom: 1px solid var(--line); background: #fff; color: inherit; border-left: 3px solid transparent; }
.opt[aria-checked="true"] { background: var(--blue-soft); border-left-color: var(--blue); font-weight: 600; }
.opt .name { flex: 1; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: flex; align-items: center; gap: 8px; min-height: 56px; min-width: 120px; padding: 4px 12px 4px 6px;
  border-radius: var(--r); border: 1px solid #BFC6D1; background: #fff; color: inherit; text-align: left; line-height: 1.25; }
.chip img { width: 36px; height: 44px; object-fit: contain; }
.photo { flex: 0 0 auto; width: 96px; height: 112px; object-fit: contain; }
.r-head { display: flex; gap: 12px; align-items: center; }
@media (min-width: 1024px) { .photo { width: 120px; height: 140px; } }
details.similar summary { cursor: pointer; list-style: none; background: var(--graphite); min-height: 44px; }
details.similar summary::-webkit-details-marker { display: none; }
details.similar summary::after { content: " ▸"; }
details.similar[open] summary::after { content: " ▾"; }
.chip small { display: block; color: var(--muted); }
.chip[aria-checked="true"] { border-color: var(--blue); background: var(--blue-soft); box-shadow: inset 0 0 0 1px var(--blue); }
.badge { display: inline-block; font-size: .72rem; font-weight: 700; padding: 2px 7px; border-radius: 3px;
  background: var(--head); color: var(--blue-ink); white-space: nowrap; }
.badge.uv { background: var(--ok-bg); color: var(--ok); }
.custom { margin-top: 14px; }
.note { background: var(--blue-soft); color: var(--blue-ink); padding: 6px 10px; border-radius: var(--r); margin: 0 0 10px;
  font-size: .9rem; font-weight: 600; }
.row { display: flex; gap: 8px; }
.row input { flex: 1; }

/* Dispense */
#recipe { opacity: 1; transform: none; transition: opacity 180ms ease, transform 220ms var(--ease-out); }
.panel { scroll-margin-top: 120px; }
@starting-style { #recipe { opacity: 0; transform: translateY(6px); } }
.flag { margin: 12px 14px 0; padding: 12px 14px; background: var(--flag-bg); border: 1px solid #F3C2B6;
  border-left: 5px solid var(--flag); border-radius: var(--r); color: #6E1712; }
.flag p { font-weight: 600; margin: 0 0 8px; }
.flag p:last-child { margin: 0; }
.strong { font-weight: 600; font-size: 1.05rem; }
.tchip { display: inline-block; width: 18px; height: 18px; margin-right: 8px; vertical-align: -3px; border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .7); }
.warn { background: var(--warn-bg); color: var(--warn); padding: 8px 14px; margin: 0 14px 10px; border-radius: var(--r); font-size: .9rem; }
.dispense td:first-child { white-space: nowrap; }
.dispense td { height: 60px; font-size: 1.25rem; }
.dispense td.num b { font-size: 2rem; letter-spacing: -0.01em; }
.dispense td:last-child { font-size: 1rem; color: var(--muted); }
.dispense .lowtag { display: inline-block; margin-left: 6px; font-size: .75rem; font-weight: 700; color: #fff;
  background: var(--flag); padding: 1px 6px; border-radius: 3px; vertical-align: 3px; }
.dispense tr.low td { background: var(--flag-bg); }
.dispense tr.low td.num b { color: var(--flag); }
.dispense tfoot th { background: #fff; color: var(--text); font-size: .9rem; border-bottom: 0; }
.dot { display: inline-block; width: 14px; height: 14px; border-radius: 2px; margin-right: 8px; vertical-align: -2px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .25); }
.totals { display: grid; grid-template-columns: 1fr auto; gap: 4px 0; margin: 0; border-top: 1px solid var(--line); }
.totals dt { color: var(--muted); }
.totals dd { margin: 0; text-align: right; }
.totals .total { font-size: 1.35rem; font-weight: 700; color: var(--text); }
.totals.pay { border-top: 0; padding-top: 4px; }

/* busy: keep the old content in place (no layout jump), dimmed and not clickable until fresh data arrives */
[aria-busy="true"] { opacity: .4; pointer-events: none; transition: opacity 120ms ease; }
/* phone: what to pay stays in view while scrolling the recipe */
@media (max-width: 1023px) {
  #r-pay { position: sticky; bottom: 0; z-index: 1; background: #fff; box-shadow: 0 -4px 12px rgba(18, 22, 28, .08);
    padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0ms !important; }
  button:active { transform: none; }
}
