/* Supermarket back office: steel shelving, yellow shelf-edge price labels,
   a thermal receipt for integration events. One loud element (the labels),
   everything else quiet. */

:root {
  --steel: #e2e6e9;
  --steel-deep: #c4cbd1;
  --shelf-edge: #9aa4ad;
  --ink: #17263a;
  --ink-soft: #4b5a6d;
  --label: #ffd83d;
  --label-edge: #e6b800;
  --paper: #fffef8;
  --promo: #d6262e;
  --scan: #1e8e5a;
  --focus: #1f6feb;

  --condensed: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --body: 'Barlow', 'Segoe UI', sans-serif;
  --receipt: 'Courier Prime', 'Courier New', monospace;

  --s1: 0.25rem;
  --s2: 0.5rem;
  --s3: 0.75rem;
  --s4: 1rem;
  --s5: 1.5rem;
  --s6: 2.25rem;
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body {
  margin: 0;
  background: var(--steel);
  color: var(--ink);
  font: 400 1rem/1.5 var(--body);
}
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
a { color: var(--ink); }
h1, h2, h3, h4 { font-family: var(--condensed); line-height: 1.1; margin: 0; }
h3 { font-size: 1.35rem; font-weight: 700; margin-bottom: var(--s3); }
h4 { font-size: 1.05rem; font-weight: 600; margin-bottom: var(--s2); color: var(--ink-soft); }

/* ---------- buttons */
.btn {
  display: inline-flex; align-items: center; gap: var(--s2);
  font: 600 0.95rem/1 var(--body);
  padding: 0.7rem 1rem;
  border: 2px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: #fff; box-shadow: 0 2px 0 var(--ink); }
.btn--ink { background: var(--ink); color: var(--paper); }
.btn--ink:hover { background: #22364f; }
.btn--small { padding: 0.5rem 0.75rem; font-size: 0.88rem; }

/* ---------- top bar: the store's own signage */
.store-bar {
  display: flex; justify-content: space-between; align-items: flex-end; gap: var(--s5);
  padding: var(--s5) var(--s6) var(--s4);
  background: var(--ink); color: var(--paper);
}
.store-bar__brand { display: flex; gap: var(--s4); align-items: center; max-width: 60rem; }
.store-bar__logo {
  font: 800 1.5rem/1 var(--condensed);
  background: var(--label); color: var(--ink);
  padding: 0.6rem 0.7rem; border-radius: 4px; transform: rotate(-3deg);
}
.store-bar h1 { font-size: clamp(1.8rem, 3.4vw, 2.8rem); font-weight: 800; letter-spacing: 0.01em; }
.store-bar p { margin: var(--s1) 0 0; color: #c9d3df; max-width: 62ch; }
.store-bar__links { display: flex; gap: var(--s4); }
.store-bar__links a { color: var(--paper); font-weight: 600; }

/* ---------- controls */
.controls {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--s4);
  padding: var(--s4) var(--s6);
  background: var(--steel-deep);
  border-bottom: 6px solid var(--shelf-edge);
}
.role-switch { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.role-switch__label { font-weight: 600; margin-right: var(--s1); }
.role-switch button {
  font: 500 0.92rem/1 var(--body);
  padding: 0.55rem 0.85rem; border-radius: 999px;
  border: 2px solid var(--ink-soft); background: transparent; color: var(--ink); cursor: pointer;
}
.role-switch button[aria-checked='true'] { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.controls__actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3); }
.locale { display: flex; align-items: center; gap: var(--s2); font-weight: 600; }
.locale select { font: inherit; padding: 0.45rem; border: 2px solid var(--ink-soft); border-radius: 6px; background: var(--paper); }

/* ---------- layout: aisles | shelf | receipt */
.store {
  display: grid;
  grid-template-columns: 13rem minmax(0, 1fr) 19rem;
  gap: var(--s5);
  padding: var(--s5) var(--s6);
  align-items: start;
}

.aisles { position: sticky; top: var(--s4); }
.aisles__title { font-size: 1.2rem; margin-bottom: var(--s3); }
.aisles ul { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s1); }
.aisle {
  width: 100%; display: flex; align-items: center; gap: var(--s3);
  padding: 0.45rem 0.6rem; border: 0; border-radius: 4px;
  background: transparent; color: var(--ink); font: 500 1rem/1.2 var(--body); text-align: left; cursor: pointer;
}
.aisle:hover { background: var(--steel-deep); }
.aisle[aria-pressed='true'] { background: var(--ink); color: var(--paper); }
.aisle__num {
  display: inline-grid; place-items: center; width: 1.7rem; height: 1.7rem; flex: none;
  font: 700 1rem/1 var(--condensed); background: #2b6cb0; color: #fff; border-radius: 3px;
}
.search { margin-top: var(--s5); display: grid; gap: var(--s2); }
.search label { font-weight: 600; }
.search input { font: inherit; padding: 0.6rem; border: 2px solid var(--ink-soft); border-radius: 6px; background: var(--paper); }

/* ---------- the shelf */
.shelf__head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s4); margin-bottom: var(--s4); }
.shelf__head h2 { font-size: 2rem; font-weight: 700; }
.shelf__count { margin: 0; color: var(--ink-soft); }
.shelf__labels {
  list-style: none; margin: 0; padding: var(--s4) var(--s4) var(--s5);
  display: grid; grid-template-columns: repeat(auto-fill, minmax(13.5rem, 1fr)); gap: var(--s5) var(--s4);
  /* metal shelf edges every row */
  background:
    repeating-linear-gradient(to bottom, transparent 0, transparent calc(19.5rem - 10px), var(--shelf-edge) calc(19.5rem - 10px), var(--shelf-edge) 19.5rem),
    #edf0f2;
  border-radius: 4px;
}
.shelf__empty { grid-column: 1 / -1; padding: var(--s6); text-align: center; color: var(--ink-soft); }
.shelf__more { margin: var(--s5) auto 0; display: flex; }

/* the price label */
.tag-wrap { min-height: 18rem; }
.tag {
  position: relative; width: 100%; height: 100%;
  display: flex; flex-direction: column; text-align: left;
  padding: var(--s3) var(--s3) var(--s2);
  background: var(--label); color: var(--ink);
  border: 0; border-top: 6px solid var(--label-edge); border-radius: 2px;
  box-shadow: 0 6px 0 -2px #00000026;
  font-family: var(--body); cursor: pointer;
  transition: transform 160ms ease;
}
.tag:hover { transform: translateY(-3px) rotate(-0.4deg); }
.tag--draft, .tag--enrichment { background: #fff4b8; border-top-color: #efd76d; }
.tag--archived { filter: grayscale(1); opacity: 0.7; }
.tag__top { display: flex; justify-content: space-between; gap: var(--s2); font-size: 0.8rem; }
.tag__brand { font-weight: 600; }
.tag__state { padding: 0 0.35rem; border-radius: 3px; background: #17263a1a; white-space: nowrap; }
.tag__state--published { background: var(--scan); color: #fff; }
.tag__state--review, .tag__state--approved { background: var(--ink); color: var(--paper); }
.tag__name { margin: var(--s2) 0 0; font: 600 1.15rem/1.15 var(--condensed); min-height: 2.6rem; }
.tag__size { margin: 0; font-size: 0.85rem; color: var(--ink-soft); }
.tag__price { margin: var(--s2) 0 0; display: flex; align-items: flex-start; line-height: 0.9; }
.tag__currency { font: 700 1.4rem/1 var(--condensed); margin: 0.3rem 0.15rem 0 0; }
.tag__amount { font: 800 3.4rem/0.9 var(--condensed); letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.tag__unit { margin: var(--s1) 0 var(--s2); font-size: 0.8rem; }
.tag__foot { margin-top: auto; display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s2); }
.barcode { width: 7.2rem; height: auto; background: #fff; padding: 2px 0; }
.barcode rect { fill: #000; }
.barcode text { font: 7px var(--body); fill: #000; }
.tag__nogtin { font-size: 0.78rem; padding: 0.3rem; border: 1px dashed var(--ink-soft); }
.tag__stamps { display: grid; gap: 3px; justify-items: end; }
.stamp { font: 700 0.75rem/1 var(--condensed); padding: 0.2rem 0.35rem; border: 2px solid; border-radius: 3px; transform: rotate(-4deg); }
.stamp--ok { color: var(--scan); border-color: var(--scan); background: #ffffffb3; }
.stamp--no { color: var(--ink-soft); border-color: var(--ink-soft); border-style: dashed; }
.tag__ribbon {
  position: absolute; top: 6.2rem; right: -6px;
  background: var(--promo); color: #fff; font: 800 0.9rem/1 var(--condensed); padding: 0.35rem 0.5rem 0.5rem;
  clip-path: polygon(12% 0, 100% 0, 100% 100%, 12% 100%, 0 50%);
  padding: 0.35rem 0.55rem 0.35rem 0.9rem;
}
.tag__soldout {
  position: absolute; inset: 40% -2px auto -2px; text-align: center;
  background: var(--promo); color: #fff; font: 800 1.1rem/1.6 var(--condensed); transform: rotate(-7deg);
}

/* ---------- thermal receipt */
.receipt { position: sticky; top: var(--s4); }
.receipt__paper {
  background: var(--paper); padding: var(--s4) var(--s4) var(--s6);
  font-family: var(--receipt); font-size: 0.85rem;
  max-height: calc(100vh - 2rem); overflow: auto;
  /* torn bottom edge */
  mask: linear-gradient(#000 0 0) top / 100% calc(100% - 10px) no-repeat, conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) bottom / 16px 10px repeat-x;
}
.receipt__title { font: 700 1.05rem/1.2 var(--receipt); text-align: center; border-bottom: 2px dashed var(--ink); padding-bottom: var(--s2); }
.receipt__sub { text-align: center; margin: var(--s2) 0 var(--s3); color: var(--ink-soft); font-size: 0.78rem; }
.receipt__lines { list-style: none; margin: 0; padding: 0; }
.receipt__line { display: grid; grid-template-columns: auto 1fr; column-gap: var(--s2); padding: var(--s1) 0; border-bottom: 1px dotted #9aa4ad; }
.receipt__time { color: var(--ink-soft); }
.receipt__type { font-weight: 700; overflow-wrap: anywhere; }
.receipt__ok, .receipt__bad { grid-column: 2; font-size: 0.78rem; }
.receipt__ok { color: var(--scan); }
.receipt__bad { color: var(--promo); font-weight: 700; }
.receipt__empty { color: var(--ink-soft); }

/* ---------- dialogs */
.detail {
  width: min(58rem, 96vw); max-height: 92vh; padding: 0; border: 0; border-radius: 6px;
  background: var(--paper); color: var(--ink);
  box-shadow: 0 30px 60px -20px #17263a80;
}
.detail::backdrop { background: #17263a99; }
.detail[open] { animation: lift 180ms ease-out; }
@keyframes lift { from { transform: translateY(12px); opacity: 0; } }
.detail__inner { padding: var(--s5) var(--s6) var(--s6); display: grid; gap: var(--s5); }
.detail__head { display: flex; justify-content: space-between; gap: var(--s4); align-items: start; }
.detail__head h2 { font-size: 2rem; font-weight: 800; }
.detail__close { font: 600 0.95rem var(--body); background: none; border: 2px solid var(--ink); border-radius: 6px; padding: 0.4rem 0.8rem; cursor: pointer; }
.detail__sku { margin: calc(-1 * var(--s4)) 0 0; color: var(--ink-soft); }

.flow__steps { list-style: none; margin: 0 0 var(--s3); padding: 0; display: grid; grid-template-columns: repeat(5, 1fr); counter-reset: step; }
.flow__steps li { position: relative; padding: var(--s2) var(--s2) var(--s2) 0; border-top: 5px solid var(--steel-deep); font: 600 1rem/1.2 var(--condensed); color: var(--ink-soft); }
.flow__steps li.done { border-color: var(--scan); color: var(--ink); }
.flow__steps li.current { border-color: var(--ink); color: var(--ink); }
.flow__moves { display: flex; flex-wrap: wrap; gap: var(--s2); }
.hint { margin: var(--s3) 0 0; font-size: 0.88rem; color: var(--ink-soft); max-width: 70ch; }

.ready__row { display: grid; grid-template-columns: 15rem 1fr 3rem; align-items: center; gap: var(--s3); margin-top: var(--s2); }
.meter { height: 0.7rem; background: var(--steel); border-radius: 999px; overflow: hidden; }
.meter__fill { display: block; height: 100%; background: var(--ink-soft); }
.is-ready .meter__fill { background: var(--scan); }
.ready__score { font: 700 1.05rem var(--condensed); text-align: right; }


.values { display: grid; grid-template-columns: repeat(auto-fit, minmax(19rem, 1fr)); gap: var(--s4) var(--s5); }
.values > h3 { grid-column: 1 / -1; margin: 0; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: var(--s1) var(--s3); margin: 0; font-size: 0.9rem; }
.kv dt { color: var(--ink-soft); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.kv dd .inherited { color: var(--ink-soft); font-size: 0.8rem; }
.kv dd code { display: block; margin-top: 2px; font: 0.76rem/1.35 var(--receipt); color: var(--ink-soft); background: var(--steel); padding: 2px 4px; border-radius: 3px; }
.flow__note { margin: 0; font-weight: 600; }

.edit__form { display: grid; grid-template-columns: auto 8rem auto 8rem auto; gap: var(--s2) var(--s3); align-items: center; margin-bottom: var(--s3); }
.edit__form input { font: inherit; padding: 0.45rem; border: 2px solid var(--ink-soft); border-radius: 6px; }
.suggestion { margin-top: var(--s3); padding: var(--s3) var(--s4); background: #fff8d1; border-left: 5px solid var(--label-edge); max-width: 70ch; }
.suggestion__meta { font-size: 0.82rem; color: var(--ink-soft); margin-top: 0; }
.suggestion__bullets { font-weight: 600; }

.history__list { margin: 0; padding-left: var(--s5); font-size: 0.88rem; color: var(--ink-soft); display: grid; gap: var(--s1); }

.xml, .gql textarea {
  width: 100%; font: 0.85rem/1.45 var(--receipt); padding: var(--s3);
  border: 2px solid var(--ink-soft); border-radius: 6px; background: #fff; color: var(--ink); resize: vertical;
}
.erp__report { display: grid; gap: var(--s2); }
.erp__error { margin: 0; color: var(--promo); }

/* ---------- graphql */
.gql { margin: var(--s4) var(--s6) var(--s6); padding: var(--s5); background: var(--paper); border-radius: 6px; }
.gql h2 { font-size: 1.8rem; font-weight: 700; }
.gql > p { margin: var(--s2) 0 var(--s4); color: var(--ink-soft); max-width: 70ch; }
.gql__form { display: grid; gap: var(--s3); justify-items: start; }
.gql__out { margin: var(--s4) 0 0; max-height: 26rem; overflow: auto; background: var(--ink); color: #e6edf5; padding: var(--s4); border-radius: 6px; font: 0.82rem/1.45 var(--receipt); }
.gql__out:empty { display: none; }

.foot { padding: var(--s4) var(--s6) var(--s6); color: var(--ink-soft); font-size: 0.9rem; }

.toast {
  position: fixed; left: 50%; bottom: var(--s5); transform: translate(-50%, 150%);
  background: var(--ink); color: var(--paper); padding: 0.8rem 1.1rem; border-radius: 6px; max-width: min(40rem, 92vw);
  transition: transform 200ms ease, visibility 0s linear 200ms;
  visibility: hidden;
}
.toast[data-kind='error'] { background: var(--promo); }
.toast--on { transform: translate(-50%, 0); visibility: visible; transition: transform 200ms ease; }

/* ---------- responsive */
@media (max-width: 1100px) {
  .store { grid-template-columns: 11rem minmax(0, 1fr); }
  .receipt { grid-column: 1 / -1; position: static; }
}
@media (max-width: 720px) {
  .store-bar, .controls, .store { padding-left: var(--s4); padding-right: var(--s4); }
  .store-bar { flex-direction: column; align-items: flex-start; }
  .store { grid-template-columns: 1fr; }
  .aisles { position: static; }
  .aisles ul { grid-template-columns: repeat(2, 1fr); }
  .shelf__labels { background: #edf0f2; }
  .detail__inner { padding: var(--s4); }
  .ready__row { grid-template-columns: 1fr 3rem; }
  .ready__row .meter { grid-column: 1 / -1; grid-row: 2; }
  .edit__form { grid-template-columns: 1fr 1fr; }
  .gql { margin: var(--s4); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
.detail__inner > .btn { justify-self: start; }
.shelf__more[hidden] { display: none; }
.gql__presets { display: flex; flex-wrap: wrap; gap: var(--s2); margin-bottom: var(--s4); }
.gql__form label { font-weight: 600; }
.gql__summary { font: 600 1.15rem var(--condensed); margin: var(--s4) 0 var(--s2); }
.gql__scroll { overflow-x: auto; }
.gql__table table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
.gql__table th { text-align: left; font: 600 0.95rem var(--condensed); border-bottom: 2px solid var(--ink); padding: var(--s2); white-space: nowrap; }
.gql__table td { border-bottom: 1px solid var(--steel-deep); padding: var(--s2); vertical-align: top; }
.gql__missing { color: var(--ink-soft); max-width: 22rem; }
.gql__error { color: var(--promo); font-weight: 600; }
.gql__raw { margin-top: var(--s4); }
.gql__raw summary { cursor: pointer; font-weight: 600; }
.tour { margin: var(--s4) var(--s6) 0; padding: var(--s3) var(--s4); background: var(--paper); border-left: 6px solid var(--label); border-radius: 4px; }
.tour summary { cursor: pointer; font: 700 1.2rem var(--condensed); }
.tour ol { margin: var(--s2) 0 0; padding-left: var(--s5); display: grid; gap: var(--s1); max-width: 80ch; }
@media (max-width: 720px) { .tour { margin: var(--s3) var(--s4) 0; } }

.ready__gaps { margin: var(--s1) 0 var(--s2); padding-left: var(--s5); font-size: 0.9rem; color: var(--promo); display: grid; gap: 2px; }
.linklike { background: none; border: 0; padding: 0; font: 600 0.9rem var(--body); color: var(--ink); text-decoration: underline; cursor: pointer; }
.field-editor { display: grid; grid-template-columns: auto minmax(10rem, 18rem); gap: var(--s2) var(--s3); align-items: center; margin: var(--s4) 0; padding: var(--s3) var(--s4); background: var(--steel); border-radius: 6px; max-width: 40rem; }
.field-editor select, .field-editor input, .field-editor textarea { font: inherit; padding: 0.45rem; border: 2px solid var(--ink-soft); border-radius: 6px; background: #fff; width: 100%; }
.field-editor [hidden] { display: none; }
.field-editor .btn { grid-column: 2; justify-self: start; }
.field-editor__slot { min-width: 0; }
