/* Hoyne order portal — hand-written, no build step, no CDN.
 *
 * Palette and type measured off hoynebrewing.ca (docs: portal/README.md).
 * The one rule to keep: GOLD IS A LIGHT COLOUR. Gold surfaces take ink text,
 * never white — white on #FFBF0D is ~1.8:1. Gold text only ever sits on
 * charcoal.
 *
 * Layout is phone-first; the media queries widen it. Sections in order:
 * tokens, fonts, reset, layout, header, buttons, fields, cards, tables,
 * dialogs, badges/banners, utilities.
 */

/* ------------------------------------------------------------- tokens --- */
:root {
  /* Hoyne brand */
  --charcoal: #1f1f1f;
  --ink: #171716;
  --gold: #ffbf0d;
  --gold-dim: #e0a800;
  --cream: #f2f0ea;
  --mist: #a3b6bf;
  --mist-dark: #8fa6b3;
  --grey: #e6e6e6;

  /* Semantic surfaces */
  --bg: #faf9f6;
  --surface: #ffffff;
  --surface-sunk: var(--cream);
  --border: #dcd9d0;
  --border-strong: #bdb9ad;

  /* Text. --muted is 4.6:1 on --surface; don't lighten it further. */
  --text: var(--ink);
  --muted: #6b6862;
  --text-on-dark: var(--cream);
  --muted-on-dark: #a8a49b;

  /* Status, warmed to sit with the cream */
  --danger: #a8321f;
  --danger-bg: #fdf0ed;
  --danger-border: #efc4bb;
  --warn: #8a5a08;
  --warn-bg: #fdf5e6;
  --warn-border: #eddcb4;
  --ok: #2e6b4f;
  --ok-bg: #eef6f1;
  --ok-border: #c2ddcd;

  --radius: 10px;
  --radius-lg: 16px;
  --radius-pill: 999px;
  --shadow: 0 1px 2px rgb(23 23 22 / 6%), 0 4px 12px rgb(23 23 22 / 6%);
  --shadow-lg: 0 8px 32px rgb(23 23 22 / 18%);

  --sans: Graphik, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: Roslindale, Georgia, "Times New Roman", serif;

  --tap: 44px;              /* minimum touch target */
  --gutter: 1rem;
}

/* -------------------------------------------------------------- fonts --- */
/* Licensed to Hoyne; self-hosted so there's no CDN dependency or FOUC.
 * swap keeps text visible while they load. */
@font-face { font-family: Graphik; font-weight: 300; font-style: normal;
  font-display: swap; src: url("/static/fonts/graphik-300.woff2") format("woff2"); }
@font-face { font-family: Graphik; font-weight: 400; font-style: normal;
  font-display: swap; src: url("/static/fonts/graphik-400.woff2") format("woff2"); }
@font-face { font-family: Graphik; font-weight: 400; font-style: italic;
  font-display: swap; src: url("/static/fonts/graphik-400-italic.woff2") format("woff2"); }
@font-face { font-family: Graphik; font-weight: 500; font-style: normal;
  font-display: swap; src: url("/static/fonts/graphik-500.woff2") format("woff2"); }
@font-face { font-family: Graphik; font-weight: 500; font-style: italic;
  font-display: swap; src: url("/static/fonts/graphik-500-italic.woff2") format("woff2"); }
@font-face { font-family: Graphik; font-weight: 700; font-style: normal;
  font-display: swap; src: url("/static/fonts/graphik-700.woff2") format("woff2"); }
@font-face { font-family: Roslindale; font-weight: 700; font-style: normal;
  font-display: swap; src: url("/static/fonts/roslindale-700.woff2") format("woff2"); }

/* -------------------------------------------------------------- reset --- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 700; line-height: 1.2; }
p { margin: 0 0 .5rem; }
a { color: inherit; }
:focus-visible {
  outline: 2px solid var(--gold-dim);
  outline-offset: 2px;
  border-radius: 4px;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ------------------------------------------------------------- layout --- */
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 var(--gutter); }
.page { padding: 1.25rem 0 5rem; }         /* bottom room for the sticky bar */
.stack > * + * { margin-top: 1rem; }
.row { display: flex; align-items: center; gap: .75rem; }
.row-wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.cols { display: grid; gap: 1rem; }
@media (min-width: 900px) {
  :root { --gutter: 1.5rem; }
  .cols { grid-template-columns: 2fr 1fr; align-items: start; }
}

/* ------------------------------------------------------------- header --- */
.masthead { background: var(--charcoal); color: var(--text-on-dark); }
.masthead .wrap { display: flex; align-items: center; gap: 1rem; min-height: 60px; }
.brand { display: flex; align-items: center; gap: .75rem; text-decoration: none;
         color: var(--text-on-dark); padding: .5rem 0; }
.brand svg { display: block; width: 92px; height: auto; }
.brand-sub {
  font-size: 11px; font-weight: 500; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted-on-dark); border-left: 1px solid #3a3a38; padding-left: .75rem;
}
.masthead-user { font-size: 13px; color: var(--muted-on-dark); }
.masthead a.linkish, .masthead button.linkish {
  color: var(--text-on-dark); background: none; border: 0; padding: .5rem;
  font: inherit; font-size: 13px; cursor: pointer; text-decoration: underline;
  text-underline-offset: 3px; min-height: var(--tap);
}
.masthead a.linkish:hover, .masthead button.linkish:hover { color: var(--gold); }
@media (max-width: 599px) { .brand-sub, .masthead-user { display: none; } }

/* Environment warning strip (fake Ekos / submit disabled). */
.envbar {
  display: flex; flex-wrap: wrap; justify-content: center; gap: .15rem 1.25rem;
  background: var(--gold); color: var(--ink);
  font-size: 12.5px; font-weight: 500; padding: .4rem var(--gutter);
}
.envbar strong { font-weight: 700; }
@media (max-width: 599px) { .envbar-long { display: none; } }

/* ------------------------------------------------------------ buttons --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: var(--tap); padding: .55rem 1.1rem;
  font: 500 14px/1 var(--sans); text-decoration: none; cursor: pointer;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  transition: background .12s ease, border-color .12s ease;
}
.btn:hover { border-color: var(--ink); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn-primary {           /* ink on gold — never white on gold */
  background: var(--gold); border-color: var(--gold); color: var(--ink); font-weight: 700;
}
.btn-primary:hover { background: var(--gold-dim); border-color: var(--gold-dim); }
.btn-dark { background: var(--charcoal); border-color: var(--charcoal); color: var(--cream); }
.btn-dark:hover { background: #000; }
.btn-quiet { background: transparent; border-color: transparent; color: var(--muted); }
.btn-quiet:hover { background: var(--grey); color: var(--text); border-color: transparent; }
.btn-danger { color: var(--danger); border-color: var(--danger-border); background: var(--danger-bg); }
.btn-sm { min-height: 34px; padding: .3rem .7rem; font-size: 13px; }
.btn-block { width: 100%; }

/* ------------------------------------------------------------- fields --- */
.field { display: grid; gap: .25rem; margin-bottom: .85rem; }
.field > label, .label {
  font-size: 12px; font-weight: 500; letter-spacing: .04em; text-transform: uppercase;
  color: var(--muted);
}
.req { color: var(--danger); margin-left: .15rem; }
/* Match by exclusion, not by listing types: `<input name="qty">` has no type
   attribute, so `input[type=text]` never matches it and it would silently keep
   the browser's ~200px default width and blow out any fixed-width column. */
input:not([type=checkbox]):not([type=radio]):not([type=submit]):not([type=button]):not([type=file]),
select, textarea {
  width: 100%; min-height: var(--tap); padding: .5rem .65rem;
  /* 16px keeps iOS from zooming the viewport when a field takes focus. */
  font: 400 16px/1.4 var(--sans); color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius); appearance: none;
}
textarea { min-height: 5.5rem; resize: vertical; }
select {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath fill='%236b6862' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .7rem center; padding-right: 2rem;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--ink); outline: 2px solid var(--gold-dim); outline-offset: -1px;
}
input[readonly], .readonly {
  background: var(--surface-sunk); color: var(--muted); border-style: dashed;
}
.static-value { padding: .5rem .65rem; font-size: 15px; }
.hint { font-size: 12px; color: var(--muted); }
.err { border-color: var(--danger) !important; background: var(--danger-bg); }
.warnf { border-color: var(--warn) !important; background: var(--warn-bg); }
.msg-err { font-size: 12px; color: var(--danger); }
.msg-warn { font-size: 12px; color: var(--warn); }
.check { display: flex; align-items: center; gap: .5rem; min-height: var(--tap); }
.check input { width: 20px; height: 20px; min-height: 0; accent-color: var(--charcoal); }

/* On a wide screen, mirror Ekos' label-left form. On a phone it stacks. */
@media (min-width: 700px) {
  .field-inline { grid-template-columns: 11rem 1fr; align-items: start; gap: .75rem; }
  .field-inline > label { text-align: right; padding-top: .7rem; }
}

/* -------------------------------------------------------------- cards --- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden;
}
.card + .card { margin-top: 1rem; }
.card-head {
  display: flex; align-items: center; gap: .6rem;
  padding: .7rem 1rem; border-bottom: 1px solid var(--border);
  font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
}
.card-body { padding: 1rem; }
.card-foot { padding: .75rem 1rem; border-top: 1px solid var(--border); background: var(--surface-sunk); }
.grid2 { display: grid; gap: 0 2rem; }
@media (min-width: 900px) { .grid2 { grid-template-columns: 1fr 1fr; } }

.sidecard { background: var(--surface); border: 1px solid var(--border);
            border-radius: var(--radius-lg); padding: 1rem; }
.sidecard + .sidecard { margin-top: 1rem; }
.sidecard h2 { font-size: 12px; letter-spacing: .08em; text-transform: uppercase;
               color: var(--muted); margin-bottom: .5rem; }

/* -------------------------------------------------------------- table --- */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; padding: .55rem 1rem; background: var(--surface-sunk);
  font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--muted); border-bottom: 1px solid var(--border);
}
.table td { padding: .6rem 1rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table a { text-decoration: none; }
.table a:hover { text-decoration: underline; }
.rowlink:hover { background: var(--surface-sunk); }
.row-bad { background: var(--danger-bg); }

/* The line-items grid. Fixed layout so the item name gets the slack instead of
   collapsing to one word per line when the numeric columns are wide. */
.table-lines { table-layout: fixed; }
.table-lines .c-item { width: auto; }
.table-lines .c-num { width: 5.5rem; }
.table-lines .c-amt { width: 6rem; }
.table-lines .c-del { width: 2.75rem; }
.table-lines td { padding: .6rem .5rem; }
.table-lines td:first-child { padding-left: 1rem; }
.table-lines input { padding: .4rem .45rem; font-size: 14px; min-height: 38px; }
.subline { font-size: 12px; color: var(--muted); margin-top: .15rem; }
.row-bad .subline { color: var(--muted); }
@media (max-width: 699px) {
  .table-lines { table-layout: auto; }
  .table-lines .c-num, .table-lines .c-amt, .table-lines .c-del { width: auto; }
  .table-lines input { max-width: 9rem; }
}

/* Under 700px every table becomes a card list: the header row is hidden and
   each cell carries its own label from data-label. */
@media (max-width: 699px) {
  .table.responsive thead { display: none; }
  .table.responsive, .table.responsive tbody, .table.responsive tr, .table.responsive td {
    display: block; width: 100%;
  }
  .table.responsive tr {
    border: 1px solid var(--border); border-radius: var(--radius);
    margin-bottom: .6rem; padding: .35rem .2rem; background: var(--surface);
  }
  .table.responsive td { border: 0; display: flex; gap: 1rem; align-items: center;
                         padding: .35rem .75rem; }
  .table.responsive td::before {
    content: attr(data-label); flex: 0 0 7.5rem;
    font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
    color: var(--muted);
  }
  .table.responsive td:empty { display: none; }
  .table.responsive .num { text-align: left; }
  /* The first cell is the card's title — a "CUSTOMER" label above the customer's
     name is just noise. */
  .table.responsive td.card-title { display: block; padding: .5rem .75rem .25rem; }
  .table.responsive td.card-title::before { content: none; }
  .table.responsive td.card-title a { font-size: 15px; }
}

/* ------------------------------------------------------------- queue ---- */
.tabs { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .25rem;
        scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: .4rem;
  min-height: 38px; padding: .35rem .85rem; border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong); background: var(--surface);
  font-size: 13px; font-weight: 500; text-decoration: none; text-transform: capitalize;
}
.tab[aria-current="page"] { background: var(--charcoal); border-color: var(--charcoal);
                            color: var(--cream); }
.tab .count { font-variant-numeric: tabular-nums; opacity: .65; }

.empty { padding: 3rem 1rem; text-align: center; color: var(--muted);
         border: 1px dashed var(--border-strong); border-radius: var(--radius-lg);
         background: var(--surface); }

/* ------------------------------------------------------------ badges ---- */
.badge {
  display: inline-flex; align-items: center; padding: .15rem .5rem;
  border-radius: var(--radius-pill); font-size: 11px; font-weight: 700;
  letter-spacing: .05em; text-transform: uppercase; white-space: nowrap;
}
.badge-pending   { background: var(--mist); color: var(--ink); }
.badge-submitted { background: var(--ok-bg); color: var(--ok); border: 1px solid var(--ok-border); }
.badge-rejected  { background: var(--grey); color: var(--muted); }
.badge-failed, .badge-expired { background: var(--warn-bg); color: var(--warn);
                                border: 1px solid var(--warn-border); }
.badge-edited { background: var(--gold); color: var(--ink); }
.badge-num { background: var(--ok-bg); color: var(--ok); }

.banner { border-radius: var(--radius); padding: .7rem .9rem; font-size: 14px;
          border: 1px solid; margin-bottom: 1rem; }
.banner ul { margin: .35rem 0 0; padding-left: 1.1rem; }
.banner-err  { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger); }
.banner-warn { background: var(--warn-bg);   border-color: var(--warn-border);   color: var(--warn); }
.banner-ok   { background: var(--ok-bg);     border-color: var(--ok-border);     color: var(--ok); }
.banner-info { background: var(--surface);   border-color: var(--border);        color: var(--muted); }

/* ------------------------------------------------------- sticky actions -- */
/* Inline at the end of the form on a desktop; pinned to the bottom of the
   viewport on a phone, where the form is far too long to scroll past. */
.actionbar { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap;
             margin-top: 1rem; }
@media (max-width: 899px) {
  /* The bar floats over the page while you scroll, so anything you can tap
     needs clearance beneath it — otherwise scrolling an element into view can
     park it underneath the bar. */
  .page { padding-bottom: 7rem; }
  button, input, select, textarea, a.btn, summary { scroll-margin-bottom: 6rem; }
  .actionbar {
    position: sticky; bottom: 0; z-index: 20;
    padding: .7rem var(--gutter);
    margin: 1rem calc(-1 * var(--gutter)) 0;
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    backdrop-filter: blur(8px);
    border-top: 1px solid var(--border);
    padding-bottom: max(.7rem, env(safe-area-inset-bottom));
  }
  .actionbar .btn, .actionbar form { flex: 1 1 auto; }
  .actionbar form .btn { width: 100%; }
}

/* ------------------------------------------------------------ dialogs --- */
dialog {
  width: min(960px, 100vw); max-width: 100vw; max-height: 92dvh; padding: 0;
  border: 0; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  background: var(--surface); color: var(--text);
}
dialog::backdrop { background: rgb(23 23 22 / 55%); }
.dialog-head {
  display: flex; align-items: center; gap: .75rem; padding: .75rem 1rem;
  border-bottom: 1px solid var(--border); position: sticky; top: 0;
  background: var(--surface); z-index: 1;
}
.dialog-head h2 { font-size: 15px; white-space: nowrap; }
.dialog-head input[type=search] { flex: 1 1 12rem; min-width: 0; }
.dialog-body { padding: 1rem; overflow-y: auto; max-height: calc(92dvh - 60px); }
.dialog-body.flush { padding: 0; }
/* Full-screen sheet on a phone. `inset: 0` + `margin: 0` beats the UA's
   `margin: auto`, which otherwise centres the sheet and lets the page peek out
   above it when 100dvh and the visual viewport disagree. */
@media (max-width: 699px) {
  dialog {
    position: fixed; inset: 0; margin: 0;
    width: 100%; max-width: 100%; height: 100%; max-height: 100%;
    border-radius: 0;
  }
  .dialog-head { flex-wrap: wrap; }
  .dialog-head h2 { flex: 1 1 auto; }
  .dialog-head input[type=search] { flex: 1 1 100%; order: 3; }
  .dialog-body { max-height: none; height: calc(100% - 108px); }
  .dialog-body.flush { height: calc(100% - 108px); }
}

/* -------------------------------------------------------------- picker -- */
.picker { display: grid; min-height: 26rem; }
.picker-pane { overflow-y: auto; max-height: 60vh; }
.picker-pane + .picker-pane { border-left: 1px solid var(--border); }
.picker-pane h3 {
  position: sticky; top: 0; background: var(--surface); z-index: 1;
  padding: .6rem .9rem; font-size: 11px; letter-spacing: .07em; text-transform: uppercase;
  color: var(--muted); border-bottom: 1px solid var(--border);
}
.picker-item {
  display: block; width: 100%; text-align: left; background: none; cursor: pointer;
  border: 0; border-bottom: 1px solid var(--border); padding: .6rem .9rem;
  font: inherit; min-height: var(--tap);
}
.picker-item:hover { background: var(--surface-sunk); }
.picker-item[aria-selected="true"] { background: var(--surface-sunk);
                                     box-shadow: inset 3px 0 0 var(--gold); }
.picker-item .title { display: flex; gap: .5rem; align-items: flex-start; font-size: 14px; }
.picker-meta { margin-left: 1rem; margin-top: .15rem; display: flex; flex-wrap: wrap;
               gap: .1rem .75rem; font-size: 12px; color: var(--muted);
               font-variant-numeric: tabular-nums; }
.dot { flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%; margin-top: .4rem; }
.dot-ok { background: var(--ok); }
.dot-out { background: var(--danger); }
.out-of-stock { color: var(--danger); font-weight: 500; }
.picker-back { display: none; }

@media (min-width: 800px) {
  .picker { grid-template-columns: 15rem 20rem 1fr; }
}
/* Phone: one pane at a time, with a back chevron — the same drill-down Ekos'
   own modal uses. `data-pane` is set by the template as you descend. */
@media (max-width: 799px) {
  .picker { grid-template-columns: 1fr; }
  .picker-pane { max-height: none; border-left: 0 !important; }
  .picker[data-pane="products"] .pane-variants,
  .picker[data-pane="products"] .pane-detail,
  .picker[data-pane="variants"] .pane-products,
  .picker[data-pane="variants"] .pane-detail,
  .picker[data-pane="detail"] .pane-products,
  .picker[data-pane="detail"] .pane-variants { display: none; }
  .picker-back { display: inline-flex; }
}

/* ------------------------------------------------------------- misc ----- */
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }
.display { font-family: var(--display); text-transform: uppercase; letter-spacing: .01em; }
details > summary { cursor: pointer; min-height: var(--tap); display: flex;
                    align-items: center; }
.trail { list-style: none; margin: 0; padding: 0; font-size: 12.5px; }
.trail li + li { margin-top: .6rem; padding-top: .6rem; border-top: 1px solid var(--border); }
.trail ul { margin: .25rem 0 0; padding-left: 1rem; color: var(--muted); }
.auth-card { max-width: 24rem; margin: 3rem auto; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
