/* =====================================================================
   Order Intentions — design system.

   Tokens and component styles follow ui-reference.html. Two additions the
   reference does not need:

   1. A [data-theme] block mirroring the dark media query, so the header
      toggle can override the system preference in both directions.
   2. Components the reference does not show — flash messages, the site
      header, the development sign-in panel.

   The dark greys are cool — a blue hue, around 220 degrees. They were warm
   (a yellow hue, which reads as brown) and that was rejected. If you adjust
   them, keep bg, card, card-2 and the three text greys on the same hue, or
   whichever one drifts will show as a tint against the rest.

   Every colour works in both modes. Tinted panels use tinted TEXT, never
   grey text on a wash: grey on amber is unreadable in dark mode.
   ===================================================================== */

:root{
  --bg:#F7F7F5;  --card:#FFFFFF;  --card-2:#FAFAF9;
  --text:#1A1A18; --text-2:#5C5C57; --text-3:#8A8A83;
  --line:rgba(0,0,0,.09); --line-2:rgba(0,0,0,.16);
  --green:#1D9E75; --green-text:#0F6E56; --green-wash:rgba(29,158,117,.11);
  --amber:#EF9F27; --amber-text:#8C5A0B; --amber-wash:rgba(239,159,39,.13);
  --red:#D14343;   --red-text:#9B2C2C;  --red-wash:rgba(209,67,67,.11);
  --track:rgba(0,0,0,.08);
  --radius:8px; --card-radius:12px;
}

/* System preference, unless the reader has explicitly chosen light. */
@media (prefers-color-scheme:dark){
  :root:not([data-theme="light"]){
    --bg:#16181C; --card:#1F2228; --card-2:#1A1D22;
    --text:#ECEEF2; --text-2:#A0A7B2; --text-3:#737A85;
    --line:rgba(255,255,255,.11); --line-2:rgba(255,255,255,.2);
    --green-text:#5DCAA5; --green-wash:rgba(29,158,117,.17);
    --amber-text:#EFB765; --amber-wash:rgba(239,159,39,.15);
    --red-text:#F09595;  --red-wash:rgba(209,67,67,.16);
    --track:rgba(255,255,255,.1);
  }
}

/* Explicit choice from the toggle wins over the system preference. */
:root[data-theme="dark"]{
  --bg:#16181C; --card:#1F2228; --card-2:#1A1D22;
  --text:#ECEEF2; --text-2:#A0A7B2; --text-3:#737A85;
  --line:rgba(255,255,255,.11); --line-2:rgba(255,255,255,.2);
  --green-text:#5DCAA5; --green-wash:rgba(29,158,117,.17);
  --amber-text:#EFB765; --amber-wash:rgba(239,159,39,.15);
  --red-text:#F09595;  --red-wash:rgba(209,67,67,.16);
  --track:rgba(255,255,255,.1);
}

*{box-sizing:border-box}

body{margin:0;background:var(--bg);color:var(--text);
  font:400 15px/1.6 Inter,system-ui,-apple-system,"Segoe UI",Helvetica,Arial,sans-serif;
  -webkit-font-smoothing:antialiased}

.wrap{max-width:940px;margin:0 auto;padding:28px 20px 72px}
.wrap.wide{max-width:1180px}

a{color:var(--text);text-decoration:underline;text-underline-offset:2px;
  text-decoration-color:var(--line-2)}
a:hover{text-decoration-color:var(--text-2)}

/* ---------- site header ---------- */
.site-header{border-bottom:0.5px solid var(--line);background:var(--card)}
.site-header .inner{max-width:1180px;margin:0 auto;padding:14px 20px;
  display:flex;align-items:center;gap:20px;flex-wrap:wrap}
.brand{font-weight:500;font-size:15px;text-decoration:none;color:var(--text);
  letter-spacing:-.01em}
/* flex:1 so the nav fills the bar and .spacer can push the account controls
   to the right edge; without it the nav sizes to its links and everything
   huddles beside the brand. */
.site-nav{flex:1;display:flex;align-items:center;gap:18px;flex-wrap:wrap;font-size:14px}
.site-nav a{color:var(--text-2);text-decoration:none}
.site-nav a:hover,.site-nav a[aria-current="page"]{color:var(--text)}
.site-nav .spacer{flex:1}

/* Narrow screens: rather than let the spacer open ragged gaps between wrapped
   links, make it a full-width break so the account controls take their own
   line under the navigation. */
@media (max-width:720px){
  .site-nav .spacer{flex-basis:100%;height:0}
}
.who{font-size:12px;color:var(--text-3)}

.count{display:inline-block;margin-left:6px;padding:1px 7px;border-radius:999px;
  background:var(--amber-wash);color:var(--amber-text);font-size:11px;font-weight:500}

/* ---------- cards and structure ---------- */
.card{background:var(--card);border:0.5px solid var(--line);
  border-radius:var(--card-radius);padding:20px 22px;margin-bottom:10px}
.card.flush{padding:0}
.head{display:flex;justify-content:space-between;align-items:baseline;gap:14px}
.tag{font-size:12px;letter-spacing:.06em;text-transform:uppercase;
  color:var(--text-3);padding:30px 0 10px;margin:0}
.tag b{color:var(--text-2);font-weight:500}

h1{font:500 20px/1.3 inherit;margin:0;letter-spacing:-.01em}
h2{font:500 17px/1.3 inherit;margin:0}
h3{font:500 15px/1.4 inherit;margin:0}
.sub{font-size:13px;color:var(--text-2);margin:2px 0 0}
.meta{font-size:13px;color:var(--text-2);white-space:nowrap}
.hint{font-size:13px;color:var(--text-3);margin:6px 0 0}
.sep{border-top:0.5px solid var(--line);margin:0;padding-top:16px}
.line{padding:16px 0 14px;border-top:0.5px solid var(--line)}
.line:first-of-type{border-top:0}
.line.first{border-top:0.5px solid var(--line);margin-top:14px}

/* ---------- the confirmed / pending split bar ---------- */
.bar{display:flex;height:8px;border-radius:4px;overflow:hidden;
  background:var(--track);margin:10px 0 9px}
.bar .c{background:var(--green)}
.bar .p{background:var(--amber)}
.legend{display:flex;gap:20px;font-size:13px;flex-wrap:wrap}
.ok{color:var(--green-text)}
.wait{color:var(--amber-text)}
.stop-text{color:var(--red-text)}

/* ---------- notices ---------- */
.notice{background:var(--amber-wash);color:var(--amber-text);
  border-radius:var(--radius);padding:9px 13px;font-size:13px;margin-top:11px}
.notice.info{background:var(--track);color:var(--text-2)}
.notice.good{background:var(--green-wash);color:var(--green-text)}
.notice.bad{background:var(--red-wash);color:var(--red-text)}
.notice b{font-weight:500}
.notice p{margin:.4em 0 0}
.notice p:first-child{margin-top:0}

/* ---------- chips ---------- */
.chip{display:inline-block;font-size:12px;font-weight:500;padding:4px 10px;
  border-radius:var(--radius);white-space:nowrap}
.chip.ok{background:var(--green-wash);color:var(--green-text)}
.chip.wait{background:var(--amber-wash);color:var(--amber-text)}
.chip.draft{background:var(--track);color:var(--text-2)}
.chip.stop{background:var(--red-wash);color:var(--red-text)}

/* ---------- metrics ---------- */
.metrics{display:grid;grid-template-columns:repeat(auto-fit,minmax(120px,1fr));gap:10px}
.metric{background:var(--card-2);border-radius:var(--radius);padding:14px 16px}
.metric .k{font-size:12px;color:var(--text-3);margin-bottom:5px}
.metric .v{font-size:24px;font-weight:500;letter-spacing:-.01em}

/* ---------- tables ---------- */
.scroll{overflow-x:auto;margin:0 -2px}
table{width:100%;border-collapse:collapse;font-size:13px}
th{font-size:12px;font-weight:500;color:var(--text-3);text-align:left;
  padding:0 8px 10px;border-bottom:0.5px solid var(--line-2);white-space:nowrap}
th a{color:var(--text-3);text-decoration:none}
th a:hover{color:var(--text)}
td{padding:12px 8px;border-bottom:0.5px solid var(--line);vertical-align:middle}
tr:last-child td{border-bottom:0}
th.r,td.r{text-align:right}
.n{font-variant-numeric:tabular-nums}
.dim{color:var(--text-3)}
.empty{color:var(--text-3)}
code{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:.92em}

/* ---------- controls ---------- */
label{display:block;font-size:12px;color:var(--text-3);margin-bottom:6px}
input,select,textarea{width:100%;height:38px;padding:0 11px;
  border:0.5px solid var(--line-2);border-radius:var(--radius);
  background:var(--card);color:var(--text);font:400 15px inherit}
textarea{height:auto;padding:9px 11px;line-height:1.5}
input:focus,select:focus,textarea:focus,button:focus-visible{
  outline:2px solid var(--text-2);outline-offset:1px}
input.qty{width:64px;text-align:right;font-variant-numeric:tabular-nums}

/* No stepper arrows. They are small targets, they invite clicking a quantity
   up one at a time, and on a case of 24 that is absurd — typing the number is
   faster. The field stays type=number so it still validates and still brings
   up a numeric keypad on a phone. */
input[type=number]{-moz-appearance:textfield;appearance:textfield}
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}
input.short{width:140px}
.field{margin-bottom:14px}

.btn{height:38px;padding:0 18px;border-radius:var(--radius);
  border:0.5px solid var(--line-2);background:transparent;color:var(--text);
  font:500 14px inherit;cursor:pointer;white-space:nowrap}
.btn:hover{border-color:var(--text-3)}
.btn.solid{background:var(--text);color:var(--card);border-color:var(--text)}
.btn.solid:hover{opacity:.88}
.btn.sm{height:32px;padding:0 13px;font-size:13px}
.btn.full{width:100%}
.btn[disabled]{opacity:.45;cursor:not-allowed}
.btn.danger{color:var(--red-text);border-color:var(--red-wash)}

.linkbtn{background:none;border:0;padding:0;height:auto;
  color:var(--text-2);font:inherit;font-size:14px;cursor:pointer;text-decoration:none}
.linkbtn:hover{color:var(--text)}
.linkbtn.danger{color:var(--red-text)}
.linkbtn.danger:hover{color:var(--red)}

/* ---------- light/dark switch ---------- */
.theme-switch{display:inline-flex;align-items:center;gap:8px;
  background:none;border:0;padding:0;cursor:pointer;font:inherit;font-size:14px;
  color:var(--text-2)}
.theme-switch:hover{color:var(--text)}
.theme-track{position:relative;width:38px;height:21px;border-radius:999px;
  background:var(--track);border:0.5px solid var(--line-2);
  transition:background .18s ease,border-color .18s ease}
.theme-knob{position:absolute;top:2px;left:2px;width:15px;height:15px;
  border-radius:50%;background:var(--card);border:0.5px solid var(--line-2);
  transition:transform .18s ease}
.theme-switch[aria-checked="true"] .theme-track{background:var(--text);
  border-color:var(--text)}
.theme-switch[aria-checked="true"] .theme-knob{transform:translateX(17px);
  background:var(--card);border-color:transparent}
.theme-switch:focus-visible{outline:2px solid var(--text-3);outline-offset:3px;
  border-radius:var(--radius)}

@media (prefers-reduced-motion:reduce){
  .theme-track,.theme-knob{transition:none}
}

.row{display:flex;align-items:center;justify-content:space-between;gap:14px}
.row.tight{gap:8px}
.row.start{justify-content:flex-start}
.row.end{justify-content:flex-end}
.grid2{display:grid;grid-template-columns:1fr 1fr;gap:16px;align-items:start}
.grid2.sidebar{grid-template-columns:1fr 300px}
/* The catalogue beside the order itself: the order needs room for its split
   bars, per-case legends and quantity controls, so it gets nearly half. */
.grid2.orderpane{grid-template-columns:1fr 400px}
@media(max-width:1000px){.grid2.orderpane{grid-template-columns:1fr}}
.grid4{display:grid;grid-template-columns:repeat(auto-fit,minmax(110px,1fr));gap:12px}
@media(max-width:720px){
  .grid2,.grid2.sidebar{grid-template-columns:1fr}
}

form.inline{display:inline}
.stack > * + *{margin-top:10px}

/* ---------- order cards in the sidebar ---------- */
.order-card{border:0.5px solid var(--line);border-radius:var(--radius);
  padding:12px;margin-bottom:10px}
.order-card .ref{font-size:14px;font-weight:500}

/* ---------- flash messages ---------- */
.flash{border-radius:var(--radius);padding:10px 14px;font-size:13px;margin-bottom:10px}
.flash-success{background:var(--green-wash);color:var(--green-text)}
.flash-error{background:var(--red-wash);color:var(--red-text)}
.flash-info{background:var(--track);color:var(--text-2)}

/* ---------- development sign-in ---------- */
.dev{border:0.5px dashed var(--line-2);border-radius:var(--card-radius);
  padding:14px 16px;margin-bottom:16px;background:var(--card-2)}
.dev summary{cursor:pointer;font-size:13px;color:var(--text-3);list-style:none}
.dev summary::-webkit-details-marker{display:none}
.dev summary b{color:var(--text-2);font-weight:500}
.dev-accounts{display:grid;grid-template-columns:repeat(auto-fill,minmax(200px,1fr));
  gap:8px;margin-top:12px}
.dev-account{display:block;width:100%;height:auto;padding:9px 11px;text-align:left;
  border:0.5px solid var(--line);border-radius:var(--radius);
  background:var(--card);color:var(--text);font:inherit;cursor:pointer;line-height:1.4}
.dev-account:hover:not([disabled]){border-color:var(--text-3)}
.dev-account[disabled]{opacity:.45;cursor:not-allowed}
.dev-account .r1{display:block;font-size:11px;text-transform:uppercase;
  letter-spacing:.05em;color:var(--text-3)}
.dev-account .r2{display:block;font-size:13px;font-weight:500}
.dev-account .r3{display:block;font-size:12px;color:var(--text-3)}

.footer{max-width:940px;margin:0 auto;padding:0 20px 40px;
  font-size:12px;color:var(--text-3)}

/* ---------------------------------------------------------------------
   Product tiles, cart lines, and the product dialog.
   --------------------------------------------------------------------- */

/* Tiles are portrait and large: these are trading-card products, and the
   picture is what a buyer recognises. Name and price sit under the art. */
.tiles{display:grid;grid-template-columns:repeat(auto-fill,minmax(128px,1fr));gap:12px}

.tile{
  position:relative;display:flex;flex-direction:column;gap:0;
  height:auto;padding:10px;text-align:left;
  background:var(--card);border:0.5px solid var(--line-2);
  border-radius:var(--radius);color:var(--text);font:inherit;cursor:pointer
}
.tile:hover{border-color:var(--text-3)}
.tile-art{
  aspect-ratio:3/4;border-radius:6px;background:var(--card-2);
  border:0.5px solid var(--line);
  display:flex;align-items:center;justify-content:center;
  color:var(--text-3);font-size:11px;letter-spacing:.04em;text-transform:uppercase
}
.tile-name{margin-top:9px;font-size:13px;font-weight:500;line-height:1.3}
.tile-sku{font-size:11px;color:var(--text-3)}
.tile-foot{margin-top:6px;display:flex;justify-content:space-between;align-items:baseline;gap:6px}
.tile-price{font-size:14px;font-weight:500;font-variant-numeric:tabular-nums}
.tile-case{font-size:11px;color:var(--text-2)}
.tile-badge{position:absolute;top:16px;right:16px;font-size:11px;padding:2px 7px}

/* Cart lines: ordered on the right, then the split with the figures
   highlighted. The numbers are what the eye should land on. */
.cart-line{
  border:0.5px solid var(--line-2);border-radius:var(--radius);
  padding:12px 14px;margin-bottom:8px
}
.cart-head{display:flex;justify-content:space-between;align-items:baseline;gap:12px}
.cart-name{font-size:14px;font-weight:500}
.cart-ordered{font-size:13px;color:var(--text-2);white-space:nowrap}
.cart-split{display:flex;gap:20px;margin-top:8px;font-size:13px;color:var(--text-2);flex-wrap:wrap}
.num{display:inline-block;padding:1px 7px;border-radius:5px;font-weight:500;
  font-variant-numeric:tabular-nums;color:var(--text)}
.num-ok{background:var(--green-wash);color:var(--green-text)}
.num-wait{background:var(--amber-wash);color:var(--amber-text)}
.num-zero{background:var(--track);color:var(--text-3)}
.cart-cases{margin-top:8px;font-size:12px;color:var(--text-3)}
.cart-cases div + div{margin-top:2px}
.cart-actions{margin-top:8px;display:flex;justify-content:flex-end;gap:8px;align-items:center}

.product-dialog{
  width:min(560px,calc(100vw - 32px));padding:22px;
  background:var(--card);color:var(--text);
  border:0.5px solid var(--line-2);border-radius:var(--card-radius)
}
.product-dialog::backdrop{background:rgba(0,0,0,.45)}
.product-dialog h2{margin:0}
.product-dialog form{margin:0}

/* ---------------------------------------------------------------------
   Inline (i) explanation. Shows on hover and on keyboard focus, and taps
   open it on touch because the element is focusable.
   --------------------------------------------------------------------- */
.infotip{
  position:relative;display:inline-flex;align-items:center;justify-content:center;
  width:15px;height:15px;margin-left:4px;vertical-align:middle;
  background:var(--amber-wash);border:0.5px solid transparent;border-radius:50%;
  font-size:10px;font-style:italic;font-weight:600;line-height:1;
  color:var(--amber-text);cursor:help;user-select:none
}
.infotip:hover,.infotip:focus-visible{border-color:var(--amber);outline:none}

.infotip-bubble{
  position:absolute;bottom:calc(100% + 8px);left:50%;transform:translateX(-50%);
  width:250px;padding:10px 12px;z-index:20;
  background:var(--card);color:var(--text-2);
  border:0.5px solid var(--line-2);border-radius:var(--radius);
  box-shadow:0 6px 20px rgba(0,0,0,.18);
  font-size:12px;font-style:normal;font-weight:400;line-height:1.5;text-align:left;
  opacity:0;visibility:hidden;transition:opacity .12s ease
}
.infotip:hover .infotip-bubble,.infotip:focus .infotip-bubble,.infotip:focus-within .infotip-bubble{
  opacity:1;visibility:visible
}

/* Near the right edge of a narrow pane the bubble would overflow, so the
   last column's bubble anchors to its right instead of centring. */
.cart-split > span:last-child .infotip-bubble{left:auto;right:-6px;transform:none}

/* ---------------------------------------------------------------------
   The "start a new order" card, shown where the current order sits once
   there is no open draft.
   --------------------------------------------------------------------- */
.start-card{display:flex;flex-direction:column;justify-content:center;
  min-height:200px;margin-bottom:10px}
.start-new{
  display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;
  width:100%;height:auto;padding:26px 16px;
  background:transparent;color:var(--text-2);
  border:1px dashed var(--line-2);border-radius:var(--radius);
  font:inherit;cursor:pointer
}
.start-new:hover{border-color:var(--text-3);color:var(--text);background:var(--card-2)}
.start-plus{font-size:34px;font-weight:300;line-height:1}
.start-label{font-size:14px;font-weight:500}

/* Product pictures ---------------------------------------------------- */
.tile-art{overflow:hidden;padding:0}
.tile-art img{width:100%;height:100%;object-fit:cover;display:block}
.tile-art-empty{
  display:flex;align-items:center;justify-content:center;width:100%;height:100%;
  color:var(--text-3);font-size:11px;letter-spacing:.04em;text-transform:uppercase
}

.pd-body{display:flex;gap:16px;margin-top:12px}
.pd-body #pd-image{
  width:160px;flex:0 0 160px;border-radius:6px;border:0.5px solid var(--line);
  background:var(--card-2)
}
.pd-facts{flex:1;min-width:0}
@media(max-width:520px){
  .pd-body{flex-direction:column}
  .pd-body #pd-image{width:120px;flex:none;align-self:center}
}
