/* app.css — CUSTOM STRUCTURES (components & layout shell).
   Colors come from theme.css variables; spacing/alignment helpers live in
   utils.css. Load order: theme.css -> app.css -> utils.css. */

/* ---- Order count badges (customer list) -------------------------------- */
.order-badge {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 24px; height: 24px; border-radius: 12px;
    font-size: 12px; font-weight: 700; padding: 0 7px;
    cursor: default; user-select: none;
}
.badge-blue  { background: var(--blue-100,  #dbeafe); color: var(--blue-700,  #1d4ed8); }
.badge-amber { background: var(--amber-100, #fef3c7); color: var(--amber-700, #b45309); }
.badge-green { background: var(--green-100, #dcfce7); color: var(--green-700, #15803d); }

/* ---- Tooltip popup ----------------------------------------------------- */
.tip-popup {
    display: none; position: absolute; z-index: 9999;
    background: #1e293b; color: #f8fafc;
    border-radius: 8px; padding: 8px 12px;
    font-size: 12px; line-height: 1.5;
    box-shadow: 0 4px 16px rgba(0,0,0,.25);
    pointer-events: none; white-space: nowrap;
}
.tip-popup::after {
    content: ''; position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
    border: 5px solid transparent; border-top-color: #1e293b;
}
.tip-row { display: flex; align-items: center; gap: 8px; padding: 2px 0; }
.tip-label { color: #cbd5e1; }
.tip-pill {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 20px; height: 18px; border-radius: 9px;
    font-size: 11px; font-weight: 700; padding: 0 6px;
}
.tip-pill.pill-blue  { background: #1d4ed8; color: #fff; }
.tip-pill.pill-amber { background: #b45309; color: #fff; }
.tip-pill.pill-green { background: #15803d; color: #fff; }

/* Reset & base typography */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
.icon { width: 20px; height: 20px; flex: 0 0 auto; }
.icon-sm { width: 16px; height: 16px; flex: 0 0 auto; }

/* App shell */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 240px; flex: 0 0 240px; background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--line-soft); }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: var(--primary); color: var(--white); display: grid; place-items: center; }
.brand-mark .icon { width: 18px; height: 18px; }
.brand-name { font-weight: 600; font-size: 15px; color: var(--ink); }
.brand-sub { font-size: 11px; color: var(--faint); }
.nav { flex: 1; overflow-y: auto; padding: 12px; }
.nav-group { margin-bottom: 12px; }
.nav-group-label { padding: 6px 10px; font-size: 10px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 9px; color: var(--slate-600); font-weight: 500; margin-bottom: 2px; }
.nav-item .icon { color: var(--faint); }
.nav-item:hover { background: var(--hover); color: var(--ink); }
.nav-item:hover .icon { color: var(--slate-600); }
.nav-item.active { background: var(--primary-soft); color: var(--primary-strong); }
.nav-item.active .icon { color: var(--primary); }
.nav-foot { padding: 12px; border-top: 1px solid var(--line-soft); }
.nav-foot form { margin: 0; }
.nav-button { width: 100%; border: 0; background: transparent; text-align: left; cursor: pointer; }

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 14px; height: 64px; padding: 0 28px; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar h1 { font-size: 18px; font-weight: 600; margin: 0; color: var(--ink); }
.searchbox { display: flex; align-items: center; gap: 8px; background: var(--slate-100); border: 1px solid var(--line); border-radius: 9px; padding: 8px 12px; color: var(--faint); min-width: 240px; }
.searchbox input { border: 0; background: transparent; outline: 0; font-size: 14px; color: var(--text); width: 100%; }
.iconbtn { position: relative; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 9px; color: var(--slate-600); background: transparent; border: 0; cursor: pointer; }
.iconbtn:hover { background: var(--slate-100); }
.dot { position: absolute; top: 8px; right: 9px; width: 7px; height: 7px; border-radius: 50%; background: var(--red-500); border: 2px solid var(--white); }
.userchip { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 9px; }
.userchip:hover { background: var(--slate-100); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--ink); color: var(--white); display: grid; place-items: center; font-size: 12px; font-weight: 600; }
.main { padding: 28px; flex: 1; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-card); }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line-soft); }
.card-title { font-size: 15px; font-weight: 600; color: var(--ink); }
.link { color: var(--primary); font-size: 13px; font-weight: 600; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid transparent; border-radius: 10px; padding: 9px 14px; font-size: 14px; font-weight: 600; cursor: pointer; transition: background .15s, border-color .15s; }
.btn .icon { width: 18px; height: 18px; }
.btn-primary { background: var(--primary); color: var(--white); }
.btn-primary:hover { background: var(--primary-strong); }
.btn-dark { background: var(--ink); color: var(--white); }
.btn-dark:hover { background: var(--slate-800); }
.btn-outline { background: var(--surface); border-color: var(--line); color: var(--slate-700); }
.btn-outline:hover { background: var(--hover); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--slate-100); }
.btn-sm { padding: 6px 10px; font-size: 13px; }

/* Pills */
.pill { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-green { background: var(--primary-soft); color: var(--primary-strong); }
.pill-blue { background: var(--blue-50); color: var(--blue-700); }
.pill-amber { background: var(--amber-50); color: var(--amber-700); }
.pill-slate { background: var(--slate-100); color: var(--slate-600); }
.pill-red { background: var(--red-50); color: var(--red-600); }

/* Stat tiles */
.stats { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 24px; }
.stat { flex: 1 1 200px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; box-shadow: var(--shadow-card); }
.stat-top { display: flex; align-items: center; justify-content: space-between; }
.stat-ico { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; }
.stat-ico.green { background: var(--primary-soft); color: var(--primary); }
.stat-ico.blue { background: var(--blue-50); color: var(--blue-600); }
.stat-ico.amber { background: var(--amber-50); color: var(--amber-600); }
.stat-ico.slate { background: var(--slate-100); color: var(--slate-600); }
.stat-value { font-size: 26px; font-weight: 700; margin-top: 12px; color: var(--ink); }
.stat-label { font-size: 13px; color: var(--muted); margin-top: 2px; }

/* Table */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--faint); padding: 12px 20px; border-bottom: 1px solid var(--line-soft); }
.table td { padding: 14px 20px; border-bottom: 1px solid var(--line-soft); font-size: 14px; color: var(--slate-700); }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--hover); }
.table tbody tr.product-row { cursor: pointer; }
.table .right { text-align: right; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; color: var(--slate-600); }

.product-list-image {
  position: relative;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 9px;
  overflow: hidden;
  background: var(--slate-50);
  cursor: pointer;
}
.product-list-image-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--surface);
}
.product-list-image-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.product-list-image-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, .66);
  color: var(--white);
  opacity: 0;
  transition: opacity .15s;
}
.product-list-image-spinner {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(255, 255, 255, .55);
}
.product-list-image-spinner::after {
  content: '';
  width: 16px;
  height: 16px;
  border: 2px solid rgba(15, 23, 42, .18);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: brand-saving-spin .7s linear infinite;
}
.product-list-image:hover .product-list-image-overlay,
.product-list-image:focus-within .product-list-image-overlay { opacity: 1; }
.product-list-image.has-image .product-list-image-overlay { opacity: 0; }
.product-list-image.has-image:hover .product-list-image-overlay,
.product-list-image.has-image:focus-within .product-list-image-overlay { opacity: 1; }
.product-list-image.is-uploading { cursor: wait; }
.product-list-image.is-uploading .product-list-image-overlay { opacity: 0; }
.product-list-image.is-uploading .product-list-image-spinner { display: grid; }
.product-list-image.is-uploading .product-list-image-preview { filter: blur(1px); opacity: .5; }

/* Forms */
.field { margin-bottom: 16px; }
.label { display: block; font-size: 13px; color: var(--slate-600); margin-bottom: 6px; font-weight: 500; }
.input { width: 100%; border: 1px solid var(--slate-300); border-radius: 10px; padding: 10px 12px; font-size: 14px; outline: 0; transition: border-color .15s, box-shadow .15s; }
.input:focus { border-color: var(--primary); box-shadow: var(--ring-primary); }
.input.invalid { border-color: var(--red-400); }
.field-error { margin-top: 6px; font-size: 13px; color: var(--red-600); }
.field-hint { margin-top: 5px; font-size: 12px; color: var(--muted); }

/* Product editor */
.product-editor {
  display: grid;
  grid-template-columns: minmax(320px, .8fr) minmax(0, 1.5fr);
  gap: 20px;
  align-items: stretch;
}
.product-editor-fields { min-width: 0; }
.product-section-head,
.product-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.product-section-head { margin-bottom: 22px; }
.product-section-copy { font-size: 12px; margin-top: 3px; }
.product-fields-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 20px;
}
.product-status-row {
  margin: 4px -20px -20px;
  padding: 18px 20px;
  border-top: 1px solid var(--line-soft);
  background: var(--slate-50);
  border-radius: 0 0 14px 14px;
}
.product-switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; color: var(--slate-700); }
.product-switch input { position: absolute; opacity: 0; pointer-events: none; }
.product-switch-track { width: 42px; height: 24px; padding: 3px; border-radius: 999px; background: var(--slate-300); transition: background .15s; }
.product-switch-track::after { content: ""; display: block; width: 18px; height: 18px; border-radius: 50%; background: var(--white); box-shadow: 0 1px 3px rgba(15, 23, 42, .25); transition: transform .15s; }
.product-switch input:checked + .product-switch-track { background: var(--primary); }
.product-switch input:checked + .product-switch-track::after { transform: translateX(18px); }
.product-switch input:focus-visible + .product-switch-track { box-shadow: var(--ring-primary); }

.product-media-card { display: flex; flex-direction: column; min-width: 0; overflow: hidden; padding: 14px; }
.product-media-preview {
  position: relative;
  display: block;
  cursor: pointer;
  flex: 1 1 auto;
  min-height: 390px;
  border-radius: 12px;
  overflow: hidden;
  background:
    linear-gradient(45deg, var(--slate-100) 25%, transparent 25%),
    linear-gradient(-45deg, var(--slate-100) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--slate-100) 75%),
    linear-gradient(-45deg, transparent 75%, var(--slate-100) 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}
.product-media-preview img { display: block; width: 100%; height: 100%; min-height: 390px; object-fit: contain; background: rgba(255,255,255,.78); }
.product-media-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px;
  background: linear-gradient(to top, rgba(15, 23, 42, .34), rgba(15, 23, 42, .02) 55%);
  transition: background .18s;
}
.product-media-preview:hover .product-media-overlay { background: linear-gradient(to top, rgba(15, 23, 42, .48), rgba(15, 23, 42, .08) 60%); }
.product-upload-button { pointer-events: none; box-shadow: 0 8px 24px rgba(15, 23, 42, .18); }
/* Existing-image mode: a compact edit icon in the top-right corner. */
.product-media-edit {
  position: absolute;
  top: 12px;
  right: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  color: var(--white);
  background: rgba(15, 23, 42, .82);
  box-shadow: 0 6px 18px rgba(15, 23, 42, .28);
  pointer-events: none;
  transition: background .15s, transform .12s;
}
.product-media-edit svg { width: 18px; height: 18px; }
.product-media-preview.has-image:hover .product-media-edit { background: var(--slate-900); transform: translateY(-1px); }
.product-media-format { color: var(--white); font-size: 11px; font-weight: 600; text-shadow: 0 1px 3px rgba(15,23,42,.6); }
.product-file-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.product-media-caption { padding: 12px 6px 0; color: var(--muted); font-size: 12px; text-align: center; overflow-wrap: anywhere; }
.product-media-error { padding: 0 6px 4px; text-align: center; }

/* Product line thumbnail (order / supplier-order detail tables). */
.cell-product { display: flex; align-items: center; gap: 10px; }
.cell-thumb {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: contain;
  background: var(--slate-50);
  border: 1px solid var(--line-soft);
}

.catalog-combobox { position: relative; }
.catalog-combobox-control {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--slate-300);
  border-radius: 10px;
  background: var(--surface);
  padding-left: 11px;
  transition: border-color .15s, box-shadow .15s;
}
.catalog-combobox:focus-within .catalog-combobox-control { border-color: var(--primary); box-shadow: var(--ring-primary); }
.catalog-combobox.invalid .catalog-combobox-control { border-color: var(--red-400); }
.catalog-combobox-control > .icon { color: var(--faint); }
.catalog-combobox-control input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  padding: 10px 0;
  background: transparent;
  color: var(--text);
  font: inherit;
}
.catalog-combobox-control input::-webkit-search-cancel-button { display: none; }
.catalog-combobox-control button {
  display: grid;
  place-items: center;
  align-self: stretch;
  width: 40px;
  border: 0;
  border-left: 1px solid var(--line-soft);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.catalog-options {
  position: absolute;
  z-index: 20;
  top: calc(100% + 7px);
  left: 0;
  right: 0;
  max-height: 320px;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 18px 45px rgba(15, 23, 42, .16);
}
.catalog-option {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--slate-700);
  text-align: left;
  cursor: pointer;
}
.catalog-option:hover,
.catalog-option.active { background: var(--primary-soft); color: var(--primary-strong); }
.catalog-option-category { font-weight: 650; }
.catalog-option-separator { color: var(--slate-300); }
.catalog-option-subcategory { color: var(--muted); }
.catalog-option:hover .catalog-option-subcategory,
.catalog-option.active .catalog-option-subcategory { color: var(--primary-strong); }
.catalog-option-empty { padding: 14px 12px; color: var(--muted); text-align: center; }
/* A combobox opened inside a horizontally-scrolling table would be clipped by
   the wrap's overflow (overflow-x:auto forces overflow-y to auto). Lift the clip
   only while its option list is open, so the dropdown shows in full; normal
   horizontal scrolling resumes once it closes. */
.table-wrap:has(.catalog-combobox-control input[aria-expanded="true"]) { overflow: visible; }
/* Same escape hatch for the date-range calendar popup (marked .drp-open while shown),
   so it isn't clipped by the table-wrap when the table has few rows. */
.table-wrap:has(.drp-open) { overflow: visible; }
.product-sku-table-wrap { overflow-x: auto; }
.product-sku-card {
  padding-top: 14px;
  padding-bottom: 14px;
}
.product-sku-card .between { margin-bottom: 12px; }
.product-sku-note {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.35;
}
.product-sku-table { min-width: 1060px; }
.product-sku-table th,
.product-sku-table td { padding-top: 12px; padding-bottom: 12px; }
.product-sku-table tbody tr { height: 86px; }
.product-sku-table .input { padding-top: 9px; padding-bottom: 9px; }
.product-sku-table select.input { padding-right: 34px; }
.product-sku-table input[name="sku_code[]"] { min-width: 130px; }
.product-sku-table input[name="barcode[]"] { min-width: 120px; }
.product-sku-table input[name="supplier_ref[]"] { margin-top: 4px !important; }

/* Product import */
.import-card { margin-bottom: 18px; overflow: hidden; }
.import-upload-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: end;
}
.import-upload-actions { display: flex; align-items: center; }
.import-sample {
  margin-top: 16px;
  padding: 14px 16px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: var(--slate-50);
}
.import-sample code {
  display: block;
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface);
  color: var(--slate-700);
  overflow-x: auto;
}
.import-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.import-table-wrap { overflow-x: auto; }
.import-table { min-width: 1680px; table-layout: fixed; }
.import-table th,
.import-table td { font-size: 13px; }
.import-name-cell { color: var(--ink); font-weight: 600; }
.import-issues { display: flex; flex-wrap: wrap; gap: 6px; }
.import-issue {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.2;
}
.import-issue-missing,
.import-issue-invalid { background: var(--red-50); color: var(--red-600); }
.import-issue-duplicate { background: var(--amber-50); color: var(--amber-700); }
.import-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
}
.import-row-success td { background: rgba(236, 253, 245, .85); }
.import-row-warning td { background: rgba(255, 251, 235, .9); }
.import-row-error td { background: rgba(254, 242, 242, .85); }
.import-flash-error { background: var(--red-50); color: var(--red-600); border-color: var(--red-400); }

/* Inline brand creation */
.brand-inline-card {
  display: grid;
  grid-template-columns: minmax(240px, .65fr) minmax(0, 1.35fr);
  gap: 22px;
  align-items: center;
  margin-bottom: 18px;
  padding: 18px 20px;
  border: 1px solid var(--emerald-200);
  border-radius: 14px;
  background: linear-gradient(110deg, var(--primary-soft), var(--surface) 46%);
  box-shadow: var(--shadow-card);
}
.brand-inline-intro { display: flex; align-items: center; gap: 12px; }
.brand-inline-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--primary); color: var(--white); }
.brand-inline-icon .icon { width: 19px; height: 19px; }
.brand-inline-copy { margin-top: 3px; font-size: 12px; }
.brand-inline-form { display: grid; grid-template-columns: minmax(180px, 1fr) auto auto; gap: 14px; align-items: end; }
.brand-inline-name .label { margin-bottom: 5px; }
.brand-inline-status { min-height: 42px; padding-bottom: 1px; }
.brand-inline-form .btn { min-height: 42px; justify-content: center; }
.brand-inline-form .btn:disabled { opacity: .65; cursor: wait; }
.brand-name-cell { color: var(--ink) !important; font-weight: 600; }
.brand-identity { display: flex; align-items: center; gap: 12px; min-width: 220px; }
.brand-logo {
  position: relative;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 11px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .02em;
  border: 1px solid rgba(255,255,255,.7);
  box-shadow: inset 0 0 0 1px rgba(15,23,42,.04);
  overflow: hidden;
  cursor: pointer;
}
.brand-logo img { width: 100%; height: 100%; object-fit: cover; }
.brand-logo-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.brand-logo-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, .66);
  color: var(--white);
  opacity: 0;
  transition: opacity .15s;
}
.brand-logo:hover .brand-logo-overlay,
.brand-logo:focus-within .brand-logo-overlay { opacity: 1; }
.brand-logo.is-uploading { opacity: .58; cursor: wait; }
.brand-logo.is-uploading .brand-logo-overlay { opacity: 1; }
.brand-logo.is-uploading .brand-logo-overlay .icon { animation: brand-saving-spin .7s linear infinite; }
.brand-logo-1 { background: #dcfce7; color: #166534; }
.brand-logo-2 { background: #dbeafe; color: #1e40af; }
.brand-logo-3 { background: #fef3c7; color: #92400e; }
.brand-logo-4 { background: #fce7f3; color: #9d174d; }
.brand-logo-5 { background: #ede9fe; color: #5b21b6; }
.brand-logo-6 { background: #cffafe; color: #155e75; }
.brand-name-editor { position: relative; min-width: 0; }
.brand-name-display {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  margin-left: -8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  text-align: left;
  cursor: text;
}
.brand-name-text { white-space: normal; overflow-wrap: anywhere; }
.brand-name-pencil { display: inline-flex; color: var(--faint); opacity: 0; transform: translateX(-4px); transition: opacity .15s, transform .15s; }
.brand-name-display:hover { background: var(--slate-100); }
.brand-name-display:hover .brand-name-pencil,
.brand-name-display:focus-visible .brand-name-pencil { opacity: 1; transform: translateX(0); }
.brand-name-input {
  display: none;
  width: min(360px, 100%);
  border: 1px solid var(--primary);
  border-radius: 8px;
  padding: 7px 9px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  outline: 0;
  box-shadow: var(--ring-primary);
}
.brand-name-editor.is-editing .brand-name-display { display: none; }
.brand-name-editor.is-editing .brand-name-input { display: block; }
.brand-name-editor.is-saving .brand-name-input {
  color: var(--slate-400);
  background: var(--slate-100);
  border-color: var(--slate-300);
  box-shadow: none;
  cursor: wait;
}
.brand-name-editor.is-saving::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 9px;
  width: 13px;
  height: 13px;
  margin-top: -7px;
  border: 2px solid var(--slate-300);
  border-top-color: var(--slate-600);
  border-radius: 50%;
  animation: brand-saving-spin .7s linear infinite;
}
.brand-name-editor.is-saving .brand-name-input { padding-right: 30px; }
@keyframes brand-saving-spin { to { transform: rotate(360deg); } }
.brand-empty-cell { padding: 28px !important; text-align: center; }
.brand-row-new { animation: brand-row-arrive .45s ease-out both; }
@keyframes brand-row-arrive {
  from { opacity: 0; transform: translateY(-8px); background: var(--primary-soft); }
  to { opacity: 1; transform: translateY(0); background: transparent; }
}
.brand-table-head-left { display: flex; align-items: center; gap: 18px; }
.brand-page-size { display: inline-flex; align-items: center; gap: 8px; }
.brand-page-size label { font-size: 12px; font-weight: 600; color: var(--muted); }
.brand-page-size select {
  min-width: 72px;
  height: 34px;
  padding: 0 28px 0 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  outline: 0;
}
.brand-page-size select:focus { border-color: var(--primary); box-shadow: var(--ring-primary); }
.table-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 20px;
  border-top: 1px solid var(--line-soft);
}
.table-page-link,
.table-page-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--slate-600);
  font-size: 13px;
  font-weight: 600;
}
.table-page-link { padding: 6px 11px; }
.table-page-number { min-width: 34px; padding: 6px; }
.table-page-link:hover,
.table-page-number:hover { border-color: var(--slate-300); background: var(--hover); color: var(--ink); }
.table-page-number.active { border-color: var(--primary); background: var(--primary); color: var(--white); }
.table-page-link.disabled { opacity: .42; pointer-events: none; }
.table-page-numbers { display: flex; align-items: center; gap: 6px; }

/* Inline taxonomy management */
.taxonomy-inline-card {
  display: grid;
  grid-template-columns: minmax(260px, .7fr) minmax(0, 1.3fr);
  gap: 24px;
  align-items: center;
  margin-bottom: 18px;
  padding: 18px 20px;
  border: 1px solid #bfdbfe;
  border-radius: 14px;
  background:
    linear-gradient(112deg, rgba(219, 234, 254, .72), rgba(255, 255, 255, .94) 48%),
    var(--surface);
  box-shadow: var(--shadow-card);
}
.taxonomy-inline-intro { display: flex; align-items: center; gap: 12px; }
.taxonomy-inline-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 12px;
  background: var(--blue-600);
  color: var(--white);
  box-shadow: 0 8px 20px rgba(37, 99, 235, .18);
}
.taxonomy-inline-icon .icon { width: 20px; height: 20px; }
.taxonomy-inline-copy,
.taxonomy-table-copy { margin-top: 3px; font-size: 12px; }
.taxonomy-inline-form {
  display: grid;
  grid-template-columns: minmax(190px, 1fr) auto auto;
  gap: 14px;
  align-items: end;
}
.taxonomy-inline-status { min-height: 42px; padding-bottom: 1px; }
.taxonomy-inline-form .btn { min-height: 42px; justify-content: center; }
.taxonomy-inline-form .btn:disabled,
.taxonomy-subcategory-form .btn:disabled { opacity: .6; cursor: wait; }
.taxonomy-card { overflow: hidden; }
.taxonomy-card-head { min-height: 70px; }
.taxonomy-card-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.taxonomy-collapse-toggle { white-space: nowrap; }
.taxonomy-table-wrap { overflow-x: auto; }
.taxonomy-table { min-width: 800px; table-layout: fixed; }
.taxonomy-col-name { width: 44%; }
.taxonomy-col-type { width: 15%; }
.taxonomy-col-products { width: 11%; }
.taxonomy-col-status { width: 13%; }
.taxonomy-col-action { width: 17%; }
.taxonomy-table td { vertical-align: middle; }
.taxonomy-table tbody.taxonomy-group + tbody.taxonomy-group .taxonomy-category-row td {
  border-top: 8px solid var(--slate-50);
}
.taxonomy-table tbody tr.taxonomy-category-row { background: rgba(248, 250, 252, .76); }
.taxonomy-table tbody tr.taxonomy-category-row:hover { background: var(--slate-100); }
.taxonomy-category-row { cursor: pointer; }
.taxonomy-category-row .taxonomy-name-cell { color: var(--ink); font-weight: 700; }
.taxonomy-subcategory-row .taxonomy-name-cell { padding-left: 34px; }
.taxonomy-identity { display: flex; align-items: center; gap: 12px; min-width: 0; }
.taxonomy-group-toggle {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  margin-left: -4px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--faint);
  cursor: pointer;
}
.taxonomy-group-toggle:hover,
.taxonomy-group-toggle:focus-visible { background: rgba(226, 232, 240, .72); color: var(--slate-700); }
.taxonomy-group-toggle .icon { transition: transform .15s ease, color .15s ease; }
.taxonomy-group.is-collapsed .taxonomy-subcategory-row { display: none; }
.taxonomy-group.is-collapsed .taxonomy-group-toggle .icon { transform: rotate(-90deg); }
.taxonomy-subcategory-identity { position: relative; }
.taxonomy-branch {
  position: relative;
  width: 16px;
  height: 24px;
  flex: 0 0 16px;
  margin-left: -14px;
  border-left: 1px solid var(--slate-300);
  border-bottom: 1px solid var(--slate-300);
  border-radius: 0 0 0 8px;
  transform: translateY(-7px);
}
.taxonomy-image {
  position: relative;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .8);
  border-radius: 12px;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, .04);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}
.taxonomy-subcategory-row .taxonomy-image {
  width: 34px;
  height: 34px;
  flex-basis: 34px;
  border-radius: 10px;
}
.taxonomy-image img { width: 100%; height: 100%; object-fit: cover; background: var(--white); }
.taxonomy-image-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.taxonomy-image-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, .68);
  color: var(--white);
  opacity: 0;
  transition: opacity .15s;
}
.taxonomy-image:hover .taxonomy-image-overlay,
.taxonomy-image:focus-within .taxonomy-image-overlay,
.taxonomy-image.is-uploading .taxonomy-image-overlay { opacity: 1; }
.taxonomy-image.is-uploading { opacity: .6; cursor: wait; }
.taxonomy-image.is-uploading .taxonomy-image-overlay .icon { animation: brand-saving-spin .7s linear infinite; }
.taxonomy-image-1 { background: #dbeafe; color: #1e40af; }
.taxonomy-image-2 { background: #dcfce7; color: #166534; }
.taxonomy-image-3 { background: #fef3c7; color: #92400e; }
.taxonomy-image-4 { background: #fce7f3; color: #9d174d; }
.taxonomy-image-5 { background: #ede9fe; color: #5b21b6; }
.taxonomy-image-6 { background: #cffafe; color: #155e75; }
.taxonomy-name-editor {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
}
.taxonomy-name-display {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  max-width: 100%;
  gap: 8px;
  margin-left: -8px;
  padding: 6px 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: inherit;
  text-align: left;
  cursor: text;
}
.taxonomy-name-text {
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
}
.taxonomy-name-pencil {
  display: inline-flex;
  flex: 0 0 auto;
  color: var(--faint);
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity .15s, transform .15s;
}
.taxonomy-name-display:hover { background: rgba(226, 232, 240, .72); }
.taxonomy-name-display:hover .taxonomy-name-pencil,
.taxonomy-name-display:focus-visible .taxonomy-name-pencil { opacity: 1; transform: translateX(0); }
.taxonomy-name-input {
  display: none;
  width: min(360px, 100%);
  border: 1px solid var(--primary);
  border-radius: 8px;
  padding: 7px 9px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  outline: 0;
  box-shadow: var(--ring-primary);
}
.taxonomy-name-editor.is-editing .taxonomy-name-display { display: none; }
.taxonomy-name-editor.is-editing .taxonomy-name-input { display: block; }
.taxonomy-name-editor.is-saving .taxonomy-name-input {
  padding-right: 30px;
  color: var(--slate-400);
  background: var(--slate-100);
  border-color: var(--slate-300);
  box-shadow: none;
  cursor: wait;
}
.taxonomy-name-editor.is-saving::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 9px;
  width: 13px;
  height: 13px;
  margin-top: -7px;
  border: 2px solid var(--slate-300);
  border-top-color: var(--slate-600);
  border-radius: 50%;
  animation: brand-saving-spin .7s linear infinite;
}
.taxonomy-type {
  display: inline-flex;
  align-items: center;
  border-radius: 7px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.taxonomy-type-category { background: var(--blue-50); color: var(--blue-700); }
.taxonomy-type-subcategory { background: var(--slate-100); color: var(--slate-600); }
.taxonomy-table form { margin: 0; }
.taxonomy-table form > .pill { border: 0; cursor: pointer; }
.taxonomy-add-sub { white-space: nowrap; }
.taxonomy-subcategory-form-row td { padding: 14px 20px 16px 68px; background: var(--blue-50); }
.taxonomy-subcategory-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  gap: 14px;
  align-items: end;
  padding: 14px;
  border: 1px solid #bfdbfe;
  border-radius: 12px;
  background: rgba(255, 255, 255, .86);
}
.taxonomy-subcategory-actions { display: flex; align-items: center; gap: 6px; min-height: 42px; }
.taxonomy-subcategory-form .btn { min-height: 38px; }
.taxonomy-empty-cell { padding: 44px 20px !important; color: var(--muted) !important; text-align: center; }
.taxonomy-row-new,
.taxonomy-group-new { animation: taxonomy-arrive .45s ease-out both; }
@keyframes taxonomy-arrive {
  from { opacity: 0; transform: translateY(-7px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Suppliers */
.supplier-form-card { overflow: hidden; }
.supplier-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 20px;
}
.supplier-form-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 8px -20px -20px;
  padding: 18px 20px;
  border-top: 1px solid var(--line-soft);
  background: var(--slate-50);
}
.supplier-title-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.supplier-detail-head .sub { margin-top: 4px; }
.supplier-hero-card { padding: 22px; margin-bottom: 18px; }
.supplier-hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(280px, .9fr);
  gap: 18px;
  align-items: stretch;
}
.supplier-hero-main,
.supplier-hero-side {
  border: 1px solid var(--line-soft);
  border-radius: 16px;
  background: var(--surface);
}
.supplier-hero-main {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  padding: 18px;
  background: linear-gradient(180deg, rgba(255,255,255,.96), rgba(248,250,252,.96));
}
.supplier-avatar {
  width: 84px;
  height: 84px;
  border-radius: 22px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--primary-soft), #dbeafe);
  color: var(--primary-strong);
  font-size: 28px;
  font-weight: 800;
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, .08);
}
.supplier-hero-copy { min-width: 0; }
.supplier-contact-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 18px;
  margin-top: 18px;
}
.supplier-label {
  display: block;
  margin-bottom: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--faint);
}
.supplier-hero-side {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
}
.supplier-side-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.supplier-hero-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.supplier-mini-stat {
  padding: 14px;
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  background: var(--slate-50);
}
.supplier-mini-value {
  font-size: 20px;
  font-weight: 800;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.supplier-mini-label {
  margin-top: 3px;
  font-size: 12px;
  color: var(--muted);
}
.supplier-tabs-card { overflow: hidden; }
.supplier-tabs-head { align-items: flex-start; gap: 16px; }
.supplier-tabs-copy { margin-top: 3px; font-size: 12px; }
.supplier-tabs {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}
.supplier-tab {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--slate-600);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.supplier-tab:hover { background: var(--hover); color: var(--ink); }
.supplier-tab.is-active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-strong);
}
.supplier-panels { padding: 0; }
.supplier-panel { padding: 0; }
.supplier-empty-state {
  padding: 18px 20px 0;
}
.supplier-empty-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 4px;
}
.supplier-info-table th {
  width: 190px;
  font-size: 12px;
  color: var(--faint);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.supplier-info-table td,
.supplier-info-table th { padding-left: 20px; padding-right: 20px; }
.supplier-info-table tbody tr:hover { background: transparent; }
.table-wrap { overflow-x: auto; }

.supplier-tabs-card .card-head { min-height: 74px; }
.supplier-panel .table { min-width: 920px; }
.supplier-info-table { min-width: 0; }

@media (max-width: 880px) {
  .supplier-form-card .supplier-form-grid { grid-template-columns: 1fr; }
  .supplier-form-footer { align-items: flex-start; flex-direction: column; }
  .supplier-tabs-head { align-items: flex-start; flex-direction: column; }
  .supplier-tabs { justify-content: flex-start; }
  .supplier-hero-grid { grid-template-columns: 1fr; }
}

/* Supplier orders */
.supplier-order-list-card,
.supplier-order-lines-card,
.supplier-order-history-card { overflow: hidden; }
.supplier-order-table { min-width: 1100px; }
.supplier-order-row { cursor: pointer; }
.order-progress { height: 7px; overflow: hidden; border-radius: 999px; background: var(--slate-200); }
.order-progress span { display: block; height: 100%; border-radius: inherit; background: var(--primary); }
.supplier-order-progress-copy,
.supplier-order-card-copy { margin-top: 4px; font-size: 12px; }
.supplier-order-empty { padding: 44px 20px !important; text-align: center; color: var(--muted) !important; }
.supplier-order-editor {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(270px, .7fr);
  gap: 20px;
  align-items: start;
  margin-bottom: 20px;
}
.supplier-order-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 20px;
}
.supplier-order-notes { resize: vertical; min-height: 104px; }
.supplier-order-summary { position: sticky; top: 84px; }
.supplier-order-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 18px -20px -4px;
  padding: 18px 20px;
  border-top: 1px solid var(--line-soft);
  background: var(--slate-50);
  color: var(--slate-600);
}
.supplier-order-total strong { color: var(--ink); font-size: 18px; }
.supplier-order-lines-card { margin-bottom: 20px; }
.supplier-order-lines { min-width: 1220px; }
.supplier-order-lines th:nth-child(1) { min-width: 280px; }
.supplier-order-lines th:nth-child(2) { min-width: 240px; }
.supplier-order-lines .line-quantity,
.supplier-order-lines .line-received,
.supplier-order-lines .line-price { min-width: 112px; text-align: right; }
.supplier-order-line-error {
  padding: 10px 20px;
  border-bottom: 1px solid var(--red-400);
  background: var(--red-50);
  color: var(--red-600);
}
.supplier-order-title { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.supplier-order-detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(300px, .75fr);
  gap: 20px;
  align-items: stretch;
  margin-bottom: 20px;
}
/* Left overview card fills the row height (matching the taller status card) and
   spreads its fields so there's no dead space below it. The right card stays
   content-height so nothing floats under its button. */
.supplier-order-detail-grid > section { display: flex; flex-direction: column; }
.supplier-order-detail-grid > section .supplier-order-overview { flex: 1 1 auto; align-content: space-between; }
.supplier-order-detail-grid > aside { align-self: start; }
.supplier-order-detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.supplier-order-value { color: var(--ink); font-size: 23px; font-weight: 800; white-space: nowrap; }
.supplier-order-value span { color: var(--muted); font-size: 12px; font-weight: 700; }
.supplier-order-overview {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 24px;
  margin-top: 24px;
}
.supplier-order-overview > div > span,
.supplier-order-notes-box > span {
  display: block;
  margin-bottom: 5px;
  color: var(--faint);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.supplier-order-overview strong { color: var(--ink); }
.supplier-order-notes-box { margin-top: 22px; padding: 16px; border: 1px solid var(--line-soft); border-radius: 12px; background: var(--slate-50); }
.supplier-order-notes-box p { margin: 0; color: var(--slate-700); }
.supplier-order-progress-large { margin-top: 20px; }
.supplier-order-progress-large > .order-progress { height: 10px; margin: 10px 0; }
.supplier-order-progress-large strong { color: var(--ink); font-size: 24px; }
.supplier-order-status-form { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line-soft); }
.supplier-order-history-card { margin-top: 20px; }
.supplier-order-timeline { padding: 20px; }
.supplier-order-timeline-item { position: relative; display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 12px; padding-bottom: 20px; }
.supplier-order-timeline-item:last-child { padding-bottom: 0; }
.supplier-order-timeline-item:not(:last-child)::before { content: ""; position: absolute; left: 14px; top: 28px; bottom: 0; width: 2px; background: var(--line); }
.supplier-order-timeline-marker { position: relative; z-index: 1; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--slate-100); color: var(--slate-400); }
.supplier-order-timeline-marker.is-current { background: var(--primary-soft); color: var(--primary); }
.supplier-order-timeline-content { padding: 3px 0 0; }
.supplier-order-timeline-content p { margin: 8px 0 0; color: var(--slate-600); }
.supplier-order-flash-error { background: var(--red-50); color: var(--red-600); border-color: var(--red-400); }

@media (max-width: 980px) {
  .supplier-order-editor,
  .supplier-order-detail-grid { grid-template-columns: 1fr; }
  .supplier-order-summary { position: static; }
}

@media (max-width: 620px) {
  .supplier-order-fields,
  .supplier-order-overview { grid-template-columns: 1fr; }
  .supplier-order-detail-head { flex-direction: column; }
}

/* Stepper */
.stepper { display: flex; align-items: flex-start; }
.step { flex: 1; text-align: center; position: relative; }
.step .bullet { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 8px; background: var(--surface); border: 2px solid var(--line); color: var(--slate-300); position: relative; z-index: 1; }
.step.done .bullet { background: var(--primary); border-color: var(--primary); color: var(--white); }
.step.done .bullet .icon { width: 15px; height: 15px; }
.step::before { content: ""; position: absolute; top: 13px; left: -50%; width: 100%; height: 2px; background: var(--line); z-index: 0; }
.step.done::before { background: var(--primary); }
.step:first-child::before { display: none; }
.s-title { font-size: 13px; font-weight: 600; color: var(--slate-700); }
.s-sub { font-size: 12px; color: var(--faint); }

/* Flash / page header (components) */
.flash { display: flex; align-items: center; gap: 8px; background: var(--primary-soft); color: var(--primary-strong); border: 1px solid var(--emerald-200); border-radius: 10px; padding: 10px 14px; font-size: 14px; margin-bottom: 18px; }
.flash .icon { width: 18px; height: 18px; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.page-head h2 { margin: 0; font-size: 22px; font-weight: 700; color: var(--ink); }
.page-head .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }

/* Responsive shell adjustments */
@media (max-width: 880px) {
  .sidebar { width: 68px; flex-basis: 68px; }
  .brand-text, .nav-label, .nav-group-label { display: none; }
  .nav-item { justify-content: center; padding: 10px; }
  .brand { justify-content: center; padding: 16px 0; }
  .searchbox { display: none; }
  .product-editor { grid-template-columns: 1fr; }
  .product-media-card { min-height: 520px; }
  .brand-inline-card { grid-template-columns: 1fr; }
  .import-upload-form { grid-template-columns: 1fr; }
  .import-footer { align-items: flex-start; flex-direction: column; }
  .taxonomy-inline-card { grid-template-columns: 1fr; }
  .brand-table-head { align-items: flex-start; gap: 10px; }
  .brand-table-head-left { align-items: flex-start; flex-direction: column; gap: 8px; }
  .taxonomy-subcategory-form { grid-template-columns: 1fr auto; }
  .taxonomy-subcategory-field { grid-column: 1 / -1; }
}
@media (max-width: 520px) {
  .main { padding: 18px; }
  .topbar { padding: 0 16px; }
  .page-head { align-items: flex-start; gap: 12px; }
  .product-fields-grid { grid-template-columns: 1fr; }
  .product-section-head { align-items: flex-start; }
  .product-status-row { align-items: flex-start; flex-direction: column; }
  .product-media-preview,
  .product-media-preview img { min-height: 300px; }
  .brand-inline-form { grid-template-columns: 1fr; }
  .taxonomy-inline-form,
  .taxonomy-subcategory-form { grid-template-columns: 1fr; }
  .brand-inline-status { min-height: auto; }
  .taxonomy-inline-status { min-height: auto; }
  .taxonomy-subcategory-field { grid-column: auto; }
  .taxonomy-subcategory-actions { justify-content: flex-start; }
  .supplier-form-grid { grid-template-columns: 1fr; }
  .supplier-form-footer { align-items: flex-start; flex-direction: column; }
  .supplier-hero-main { grid-template-columns: 1fr; }
  .supplier-contact-grid { grid-template-columns: 1fr; }
  .supplier-hero-stats { grid-template-columns: 1fr; }
  .table-pagination { padding: 12px; }
  .table-page-link { font-size: 0; }
  .table-page-link .icon { width: 17px; height: 17px; }
}

/* ---- Custom date picker ------------------------------------------ */
[x-cloak] { display: none !important; }

/* --- Side dock (slide-in drawer) + its history timeline --- */
.btn-icon { padding: 0; width: 38px; height: 38px; justify-content: center; }
.dock { display: inline-flex; }
.dock-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 90; }
.dock-panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 92vw); background: var(--surface); z-index: 91; box-shadow: -14px 0 44px rgba(15, 23, 42, .20); display: flex; flex-direction: column; }
.dock-anim { transition: transform .25s ease, opacity .25s ease; }
.dock-off { transform: translateX(100%); opacity: 0; }
.dock-on { transform: translateX(0); opacity: 1; }
.dock-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.dock-head-sub { font-size: 13px; margin-top: 2px; }
.dock-close { background: transparent; border: 0; cursor: pointer; color: var(--muted); padding: 4px; border-radius: 8px; display: inline-flex; }
.dock-close:hover { background: var(--hover); color: var(--ink); }
.dock-body { overflow-y: auto; padding: 20px; }
.dock-empty { text-align: center; padding: 24px; }
.dock-timeline-item { display: flex; gap: 12px; padding-bottom: 18px; position: relative; }
.dock-timeline-item:not(:last-child)::before { content: ''; position: absolute; left: 11px; top: 24px; bottom: 0; width: 2px; background: var(--line); }
.dock-timeline-marker { flex: 0 0 auto; width: 24px; height: 24px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; background: var(--slate-100); color: var(--slate-400); z-index: 1; }
.dock-timeline-marker.is-current { background: var(--primary-soft); color: var(--primary-strong); }
.dock-timeline-content { flex: 1 1 auto; min-width: 0; }
.dock-timeline-note { margin: 6px 0 0; font-size: 13px; color: var(--slate-600); }
.dock-event { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 600; color: var(--slate-700); }
.dock-event svg { width: 14px; height: 14px; color: var(--slate-400); }
.dock-by { display: inline-flex; align-items: center; gap: 5px; margin-top: 6px; font-size: 12px; color: var(--muted); }
.dock-by svg { width: 13px; height: 13px; }

/* Order line fulfilment qty (prepared/delivered) + livreur pointing */
.qty-short { color: var(--amber-600); font-weight: 700; }
.lv-pack-all { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; cursor: pointer; }
.lv-pack-all svg { width: 15px; height: 15px; color: var(--slate-400); }
.lv-check-col { width: 1%; text-align: center; white-space: nowrap; }
.lv-line-check, .pick-row input[type="checkbox"] { width: 18px; height: 18px; }
.stock-summary { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.stock-summary .pill { display: inline-flex; align-items: center; gap: 5px; }
.datepicker-wrap { position: relative; }
.datepicker-control { position: relative; display: flex; align-items: center; }
.datepicker-control .datepicker-input { flex: 1; padding-right: 38px; }
.datepicker-cal-btn {
    position: absolute; right: 10px; background: none; border: none;
    cursor: pointer; color: var(--muted); display: flex; align-items: center; padding: 0;
}
.datepicker-cal-btn:hover { color: var(--text); }
.datepicker-popup {
    position: absolute; top: calc(100% + 6px); left: 0; z-index: 200;
    background: var(--surface, #fff); border: 1px solid var(--line);
    border-radius: 12px; box-shadow: 0 8px 32px rgba(15,23,42,.16);
    padding: 14px; min-width: 264px;
}
.datepicker-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.datepicker-nav-btn {
    background: none; border: none; cursor: pointer; color: var(--muted);
    display: flex; align-items: center; border-radius: 6px; padding: 4px;
}
.datepicker-nav-btn:hover { background: var(--slate-100); color: var(--text); }
.datepicker-month-label { font-weight: 600; font-size: 14px; }
.datepicker-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); margin-bottom: 4px; }
.datepicker-weekdays span { text-align: center; font-size: 11px; font-weight: 600; color: var(--muted); padding: 4px 0; }
.datepicker-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.datepicker-day {
    aspect-ratio: 1; width: 100%; display: flex; align-items: center; justify-content: center;
    border: none; background: none; border-radius: 6px; font-size: 13px;
    cursor: pointer; color: var(--text); padding: 0;
}
.datepicker-day:hover:not(:disabled):not(.dp-sel) { background: var(--slate-100); }
.datepicker-day.dp-today { font-weight: 700; color: var(--primary); }
.datepicker-day.dp-sel { background: var(--primary); color: #fff; font-weight: 600; }
.datepicker-day.dp-empty { visibility: hidden; pointer-events: none; }

/* ---- PDF split-button dropdown ---------------------------------------- */
.pdf-dropdown {
    position: absolute; top: calc(100% + 4px); right: 0; z-index: 100;
    background: var(--surface, #fff); border: 1px solid var(--line);
    border-radius: 10px; box-shadow: 0 6px 20px rgba(15,23,42,.12);
    min-width: 140px; overflow: hidden;
}
.pdf-dropdown-item {
    display: block; padding: 9px 14px; font-size: 13px; color: var(--text);
    text-decoration: none; white-space: nowrap;
}
.pdf-dropdown-item:hover { background: var(--slate-100); }

/* ---- Orders table filter row ------------------------------------------ */
.input-sm { padding: 5px 10px; font-size: 13px; height: 32px; }
.btn-sm   { padding: 4px 10px; font-size: 13px; height: 32px; }

tr.table-filter-row th {
    background: var(--slate-50, #f8fafc);
    padding: 6px 10px;
    border-bottom: 1px solid var(--line);
}
.filter-select {
    width: 100%; padding: 4px 8px; font-size: 12px; height: 30px;
    border: 1px solid var(--line); border-radius: 6px;
    background: var(--card-bg, #fff); color: var(--text);
    font-family: inherit; cursor: pointer;
}
.filter-select:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
.filter-drp-btn {
    display: flex; align-items: center; gap: 5px; width: 100%;
    padding: 4px 8px; font-size: 12px; height: 30px;
    border: 1px solid var(--line); border-radius: 6px;
    background: var(--card-bg, #fff); color: var(--text);
    font-family: inherit; cursor: pointer; white-space: nowrap; overflow: hidden;
}
.filter-drp-btn:hover { border-color: var(--primary); }
.btn-filter-reset {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 11px; color: var(--muted); text-decoration: none;
    padding: 2px 6px; border-radius: 4px; white-space: nowrap;
}
.btn-filter-reset:hover { color: var(--danger, #dc2626); background: var(--red-50, #fef2f2); }

/* ---- Multiselect dropdown (filter row) --------------------------------- */
.multisel-popup {
    position: absolute; top: calc(100% + 4px); left: 0; z-index: 300;
    background: var(--card-bg, #fff); border: 1px solid var(--line);
    border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.12);
    padding: 6px 4px; display: flex; flex-direction: column; gap: 1px;
}
.multisel-option {
    display: flex; align-items: center; gap: 8px;
    padding: 5px 10px; border-radius: 6px; cursor: pointer;
    font-size: 12px; white-space: nowrap;
}
.multisel-option:hover { background: var(--slate-50, #f8fafc); }
.multisel-option input[type="checkbox"] { accent-color: var(--primary); cursor: pointer; }

/* ---- Date range picker popup ------------------------------------------ */
.drp-popup {
    position: absolute; top: calc(100% + 6px); left: 0; z-index: 300;
    background: var(--card-bg, #fff); border: 1px solid var(--line);
    border-radius: 12px; box-shadow: 0 8px 28px rgba(0,0,0,.14);
    width: 280px; padding: 12px;
}
.drp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.drp-month { font-weight: 600; font-size: 14px; }
.drp-nav { background: none; border: none; cursor: pointer; padding: 4px; border-radius: 6px; color: var(--text); display: flex; }
.drp-nav:hover { background: var(--slate-100, #f1f5f9); }
.drp-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); margin-bottom: 4px; }
.drp-weekdays span { text-align: center; font-size: 11px; font-weight: 600; color: var(--muted); padding: 4px 0; }
.drp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.drp-day {
    aspect-ratio: 1; width: 100%; display: flex; align-items: center; justify-content: center;
    border: none; background: none; border-radius: 6px; font-size: 12px;
    cursor: pointer; color: var(--text); padding: 0;
}
.drp-day:hover:not(:disabled):not(.drp-start):not(.drp-end) { background: var(--slate-100, #f1f5f9); }
.drp-day.drp-today  { font-weight: 700; color: var(--primary); }
.drp-day.drp-range  { background: var(--blue-50, #eff6ff); border-radius: 0; }
.drp-day.drp-start,
.drp-day.drp-end    { background: var(--primary); color: #fff; font-weight: 600; border-radius: 6px; }
.drp-day.drp-empty  { visibility: hidden; pointer-events: none; }

/* ---- Order info card (show page) -------------------------------------- */
.order-info-card { display: flex; gap: 24px; align-items: flex-start; }
.order-info-main { flex: 1; min-width: 0; }
.order-status-aside { flex-shrink: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 12px 16px; background: var(--slate-50, #f8fafc); border-radius: 10px; text-align: center; }
.order-confirm-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, .46);
}
.order-confirm-modal {
  width: min(100%, 420px);
  padding: 24px 28px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
  box-shadow: 0 20px 50px rgba(15, 23, 42, .24);
}
.order-confirm-title { margin-bottom: 8px; color: var(--ink); font-size: 16px; font-weight: 700; }
.order-confirm-copy { margin-bottom: 20px; color: var(--muted); font-size: 13px; }
.order-confirm-copy strong { color: var(--ink); }
.order-tracking-card { margin: 16px 0; overflow: hidden; }
.order-tracking-scroll { overflow-x: auto; padding: 26px 22px 22px; }
.order-tracking-progress { padding: 20px 22px 0; }
.order-tracking-progress > .order-progress { height: 10px; margin-top: 8px; }
.order-status-stepper { min-width: 620px; }
.order-status-stepper .step .bullet { width: 40px; height: 40px; margin-bottom: 10px; }
.order-status-stepper .step::before { top: 19px; }
.order-status-stepper .step .bullet .icon { width: 19px; height: 19px; }
.order-status-stepper .step.done::before,
.order-status-stepper .step.current::before { background: var(--primary); }
.order-status-stepper .step.current .bullet {
  border-color: var(--blue-600);
  background: var(--blue-50);
  color: var(--blue-600);
  box-shadow: 0 0 0 4px var(--blue-50);
}
.order-status-stepper .s-title { font-size: 14px; }
.order-status-stepper .s-sub { margin-top: 3px; }
.order-tracking-cancelled { display: flex; align-items: center; gap: 12px; padding: 22px; color: var(--red-600); background: var(--red-50); }
.order-tracking-cancelled > .icon { flex: 0 0 auto; width: 26px; height: 26px; }

/* Compact, header-less tracking stepper (supplier order detail, top of page) */
.sup-track-card { margin: 0 0 16px; padding: 12px 16px 6px; overflow: hidden; }
.sup-track-top { font-size: 12px; margin-bottom: 5px; }
.sup-track-bar { height: 6px; }
.sup-track-scroll { overflow-x: auto; padding: 14px 4px 6px; }
.stepper--compact { min-width: 480px; }
.stepper--compact .step .bullet { width: 28px; height: 28px; margin-bottom: 5px; }
.stepper--compact .step::before { top: 13px; }
.stepper--compact .step .bullet .icon { width: 14px; height: 14px; }
.stepper--compact .step.done::before,
.stepper--compact .step.current::before { background: var(--primary); }
.stepper--compact .step.current .bullet { border-color: var(--blue-600); background: var(--blue-50); color: var(--blue-600); box-shadow: 0 0 0 4px var(--blue-50); }
.stepper--compact .s-title { font-size: 12px; }
.stepper--compact .s-sub { font-size: 11px; margin-top: 1px; }
.order-tracking-cancelled strong,
.order-tracking-cancelled span { display: block; }
.order-tracking-cancelled span { margin-top: 2px; color: var(--slate-600); font-size: 13px; }

/* User administration */
.user-list-card { overflow: hidden; }
.user-name-cell { display: flex; align-items: center; gap: 10px; color: var(--ink); }
.user-name-cell .avatar { width: 32px; height: 32px; }
.user-status-button { border: 0; cursor: pointer; }
.user-empty { padding: 36px 20px !important; text-align: center; color: var(--muted) !important; }
.user-form-card { max-width: 900px; }
.user-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.user-active-field { align-self: end; padding-bottom: 9px; }
.field-hint { margin-top: 5px; color: var(--muted); font-size: 12px; }
@media (max-width: 720px) {
  .user-form-grid { grid-template-columns: 1fr; }
  .user-active-field { padding-bottom: 0; }
}

/* Authentication */
/* Auth — modern split: gradient brand panel + flowing waves + floating card. */
.auth-body {
  min-height: 100vh;
  background:
    radial-gradient(1100px 720px at 8% 8%, var(--emerald-50) 0%, rgba(236, 253, 245, 0) 60%),
    linear-gradient(135deg, #f3fbf7 0%, #eef6ff 55%, #f6fffb 100%);
  overflow: hidden;
}

/* Decorative background layer (waves + soft blobs), never interactive. */
.auth-bg { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
.auth-wave { position: absolute; left: 0; bottom: 0; width: 100%; height: 62%; }
.auth-blob { position: absolute; border-radius: 50%; filter: blur(70px); opacity: .5; }
.auth-blob-1 { width: 460px; height: 460px; top: -140px; left: -120px;
  background: radial-gradient(circle, var(--emerald-200), transparent 68%); }
.auth-blob-2 { width: 520px; height: 520px; bottom: -180px; right: -120px;
  background: radial-gradient(circle, #bfdbfe, transparent 68%); opacity: .45; }

.auth-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 40px;
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 40px 48px;
}

/* Left brand panel — big wordmark over the wave. */
.auth-aside { flex: 1 1 auto; max-width: 620px; padding: 8px 8px 8px 0; user-select: none; }
.auth-aside-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 56px;
  color: var(--primary-strong); font-weight: 600; letter-spacing: .12em; text-transform: uppercase; font-size: 12px; }
.auth-aside-logo .brand-mark { color: var(--primary); }
.auth-aside-copy { display: flex; flex-direction: column; }
.auth-aside-eyebrow { margin: 0; color: var(--faint); letter-spacing: .55em;
  text-transform: uppercase; font-size: 13px; font-weight: 600; padding-left: 6px; }
.auth-aside-eyebrow-end { align-self: flex-end; padding-right: 8px; }
.auth-wordmark {
  margin: 2px 0;
  font-size: clamp(44px, 6.4vw, 82px);
  line-height: .94;
  font-weight: 800;
  letter-spacing: -.02em;
  background: linear-gradient(120deg, var(--slate-900) 0%, var(--emerald-700) 60%, var(--emerald-600) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.auth-aside-tag { margin: 40px 0 0; max-width: 360px; color: var(--slate-600); font-size: 15px; line-height: 1.5; }

/* Floating login card. */
.auth-card {
  flex: 0 0 auto;
  width: min(100%, 420px);
  padding: 34px 34px 30px;
  border: 1px solid rgba(255, 255, 255, .7);
  border-radius: 22px;
  background: rgba(255, 255, 255, .82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 30px 70px -20px rgba(15, 23, 42, .28), 0 2px 10px rgba(15, 23, 42, .05);
}
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.auth-brand .brand-mark { flex: 0 0 auto; color: var(--primary); }
.auth-brand strong,
.auth-brand span { display: block; }
.auth-brand strong { color: var(--ink); font-size: 16px; }
.auth-brand span { color: var(--muted); font-size: 12px; }
.auth-heading { margin-bottom: 24px; }
.auth-heading h1 { margin: 0 0 6px; color: var(--ink); font-size: 26px; letter-spacing: -.01em; }
.auth-heading p { margin: 0; color: var(--muted); font-size: 14px; }
.auth-form { display: grid; gap: 16px; }
.auth-form .input {
  height: 46px;
  border-radius: 12px;
  background: var(--slate-50);
  border-color: transparent;
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.auth-form .input:focus {
  background: var(--surface);
  border-color: var(--primary);
  box-shadow: var(--ring-primary);
}
.auth-submit {
  width: 100%;
  height: 48px;
  justify-content: center;
  margin-top: 8px;
  border: 0;
  border-radius: 12px;
  font-size: 15px;
  background: linear-gradient(120deg, var(--emerald-600), var(--emerald-700));
  box-shadow: 0 12px 24px -10px rgba(5, 150, 105, .65);
  transition: transform .12s ease, box-shadow .15s ease, filter .15s ease;
}
.auth-submit:hover { filter: brightness(1.04); box-shadow: 0 16px 30px -10px rgba(5, 150, 105, .7); }
.auth-submit:active { transform: translateY(1px); }
.auth-alert,
.auth-success { margin-bottom: 18px; padding: 11px 13px; border-radius: 10px; font-size: 13px; }
.auth-alert { border: 1px solid var(--red-400); background: var(--red-50); color: var(--red-600); }
.auth-success { border: 1px solid var(--emerald-200); background: var(--primary-soft); color: var(--primary-strong); }

/* Collapse to a single centred card on narrow screens. */
@media (max-width: 900px) {
  .auth-aside { display: none; }
  .auth-shell { justify-content: center; padding: 24px; }
  .auth-card { width: min(100%, 440px); }
}

/* ============================================================================
 | Two-phase timers — preparation + delivery (supervisor board & order detail)
 | Phases never run at once: prep ticks until the order goes out for delivery,
 | then delivery ticks until completion. A running phase shows a live, colour-
 | coded clock with a pulsing dot; a finished phase shows start → end + a total.
 ========================================================================== */

.tl-timer { display: inline-flex; align-items: center; gap: 7px; font-variant-numeric: tabular-nums; line-height: 1.2; }
.tl-timer .tl-clock { font-weight: 700; font-size: 15px; letter-spacing: .3px; }

.tl-idle { color: var(--muted); font-size: 12.5px; font-style: italic; }

/* Running clock — coloured by ageing threshold, with a breathing dot. */
.tl-timer.lvl-ok     { color: var(--emerald-600); }
.tl-timer.lvl-warn   { color: var(--amber-600); }
.tl-timer.lvl-danger { color: var(--red-600); }
.tl-dot { width: 9px; height: 9px; border-radius: 50%; background: currentColor; flex: 0 0 auto; animation: tl-pulse 1.5s ease-in-out infinite; }
@keyframes tl-pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(.6); } }

/* Finished phase — quiet range plus an emphasised total badge. */
.tl-timer.tl-done { color: var(--muted); flex-wrap: wrap; }
.tl-done .tl-range { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 600; color: var(--slate-500); }
.tl-done .tl-range .tl-arrow { display: inline-flex; opacity: .55; }
.tl-done .tl-range .tl-arrow svg { width: 13px; height: 13px; }
.tl-done .tl-total { font-weight: 800; font-size: 12.5px; color: var(--primary-strong); background: var(--primary-soft); border: 1px solid var(--emerald-200); border-radius: 999px; padding: 1px 9px; }

/* Stacked cell on the supervisor board. */
.tl-stack { display: flex; flex-direction: column; gap: 6px; }
.tl-line { display: flex; align-items: center; gap: 8px; }
.tl-line .tl-tag { display: inline-flex; color: var(--slate-400); flex: 0 0 auto; }
.tl-line .tl-tag svg { width: 15px; height: 15px; }

/* Order-detail timeline: two phase columns linked by an arrow. */
.tl-card .tl-track { display: flex; align-items: stretch; gap: 14px; flex-wrap: wrap; }
.tl-card .tl-track--single .tl-phase { flex: 0 1 460px; }
.tl-phase { flex: 1 1 260px; min-width: 240px; border: 1px solid var(--line); border-radius: 14px; padding: 15px 16px; background: var(--surface); transition: border-color .2s, box-shadow .2s; }
.tl-phase.is-idle { border-style: dashed; background: var(--bg); }
.tl-phase.is-running { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.tl-phase.is-done { background: var(--bg); }

.tl-phase-head { display: flex; align-items: center; gap: 9px; margin-bottom: 13px; }
.tl-phase-ic { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 9px; background: var(--primary-soft); color: var(--primary-strong); flex: 0 0 auto; }
.tl-phase-ic svg { width: 17px; height: 17px; }
.tl-phase.is-idle .tl-phase-ic { background: var(--slate-100); color: var(--slate-400); }
.tl-phase-name { font-weight: 700; font-size: 15px; color: var(--ink); }
/* Workload badge lifted into the header (right after the name) to save a row. */
.tl-phase-badge { display: inline-flex; align-items: center; }
.tl-phase-state { margin-left: auto; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; padding: 2px 9px; border-radius: 999px; }
.tl-state-idle    { color: var(--slate-500); background: var(--slate-100); }
.tl-state-running { color: var(--primary-strong); background: var(--primary-soft); }
.tl-state-done    { color: var(--slate-600); background: var(--slate-100); }

/* Compact body — the picker (label stacked on top of its control) takes the
   row, the chrono sits to its right so the phase is two lines tall, not four.
   FALLBACK: this whole layout lives in supervisor_phase_column()
   (modules/supervisor/functions.php); the prior four-row version is one
   `git revert` away of that function + this CSS block. */
.tl-phase-body { display: flex; align-items: flex-end; gap: 16px; }
/* Picker capped at ~half the row so the chrono gets the rest of the width. */
.tl-phase-pick { flex: 0 1 50%; min-width: 0; }
.tl-phase-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); margin-bottom: 7px; }
.tl-phase-pick form, .tl-phase-pick .catalog-combobox { width: 100%; margin: 0; }
.tl-phase-chrono { flex: 0 0 auto; margin-left: auto; padding-bottom: 9px; white-space: nowrap; }
.tl-locked { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--ink); padding-bottom: 9px; }
.tl-locked svg { width: 16px; height: 16px; color: var(--slate-400); }
.tl-locked-note { font-size: 12px; margin-top: 8px; }
/* Preparator workload badge: 🛒 customer orders · 📦 supplier orders */
.prep-load-badge { display: inline-flex; align-items: center; gap: 8px; font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--muted); background: rgba(100, 116, 139, .14); border-radius: 999px; padding: 2px 8px; white-space: nowrap; cursor: help; }
.prep-load-seg { display: inline-flex; align-items: center; gap: 3px; }
.prep-load-ic { width: 13px; height: 13px; }

.tl-connector { display: flex; align-items: center; justify-content: center; color: var(--slate-300); flex: 0 0 auto; }
.tl-connector svg { width: 22px; height: 22px; }
@media (max-width: 720px) {
    .tl-connector { transform: rotate(90deg); padding: 4px 0; }
}

/* ============================================================================
 | Warehouse — visual facility map + structure editor
 | Each area carries an accent colour via the inline custom property --wh-c.
 | Cells/sections tint to a soft wash of that colour; inactive areas go grey
 | and hatched. Occupancy colouring is layered on later (stock placement phase).
 ========================================================================== */

/* Accent dot reused at every level. */
.wh-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--wh-c, var(--slate-400)); flex: 0 0 auto; box-shadow: 0 0 0 3px color-mix(in srgb, var(--wh-c, #64748b) 18%, transparent); }
.wh-dot-lg { width: 14px; height: 14px; }

/* Depot tabs. */
.wh-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.wh-tab { display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: 11px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; color: var(--ink); transition: border-color .15s, background .15s; }
.wh-tab:hover { border-color: var(--wh-c, var(--primary)); }
.wh-tab.active { border-color: var(--wh-c, var(--primary)); background: color-mix(in srgb, var(--wh-c, #10b981) 10%, var(--surface)); box-shadow: inset 0 -2px 0 var(--wh-c, var(--primary)); }
.wh-tab.is-off { opacity: .5; }
.wh-tab .wh-tab-name { color: var(--muted); font-weight: 500; }
.wh-tab .wh-tab-count { font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; background: color-mix(in srgb, var(--wh-c, #64748b) 16%, transparent); color: var(--ink); border-radius: 999px; padding: 1px 8px; }

/* Map + sidebar layout. */
.wh-layout { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.wh-map { flex: 1 1 560px; min-width: 320px; }
.wh-aside { flex: 0 0 290px; }
@media (max-width: 900px) { .wh-aside { flex-basis: 100%; } }

.wh-legend { display: flex; gap: 14px; }
.wh-legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.wh-swatch { width: 13px; height: 13px; border-radius: 4px; display: inline-block; }
.wh-swatch-loaded { background: var(--primary); border: 1px solid var(--primary-strong); }
.wh-swatch-empty { background: var(--primary-soft); border: 1px solid var(--primary); }
.wh-swatch-off { background: repeating-linear-gradient(45deg, var(--slate-100), var(--slate-100) 3px, var(--slate-200) 3px, var(--slate-200) 6px); border: 1px solid var(--line); }

/* Section panels + étage cell grid. */
.wh-sections { display: flex; flex-direction: column; gap: 14px; }
.wh-section { border: 1px solid var(--line); border-left: 3px solid var(--wh-c, var(--slate-300)); border-radius: 12px; padding: 12px 14px; background: color-mix(in srgb, var(--wh-c, #64748b) 4%, var(--surface)); }
.wh-section.is-off { border-left-color: var(--slate-300); background: var(--bg); opacity: .65; }
.wh-section-head { display: flex; align-items: center; gap: 9px; margin-bottom: 11px; flex-wrap: wrap; }
.wh-section-code { font-weight: 700; }
.wh-section-name { font-weight: 500; }
.wh-section-count { margin-left: auto; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.wh-section-empty { font-size: 12px; font-style: italic; padding: 4px 0; }

.wh-grid { display: flex; flex-wrap: wrap; gap: 7px; }
.wh-cell { position: relative; width: 46px; height: 46px; border-radius: 9px; border: 1.5px solid var(--wh-c, var(--slate-400)); display: flex; align-items: center; justify-content: center; cursor: pointer; transition: transform .1s, box-shadow .1s; }
.wh-cell:hover { transform: translateY(-2px); box-shadow: 0 4px 10px color-mix(in srgb, var(--wh-c, #64748b) 30%, transparent); }
.wh-cell-code { font-size: 10.5px; font-weight: 700; font-family: var(--mono, ui-monospace, monospace); color: var(--ink); letter-spacing: -.2px; }
/* Occupancy states (placement-based): filled when loaded, faint when empty. */
.wh-cell.is-loaded { background: color-mix(in srgb, var(--wh-c, #64748b) 62%, var(--surface)); }
.wh-cell.is-loaded .wh-cell-code { color: #fff; text-shadow: 0 1px 1px rgba(0,0,0,.28); }
.wh-cell.is-empty { background: color-mix(in srgb, var(--wh-c, #64748b) 8%, var(--surface)); }
.wh-cell.is-off { border-style: dashed; border-color: var(--slate-300); background: repeating-linear-gradient(45deg, var(--slate-50), var(--slate-50) 4px, var(--slate-100) 4px, var(--slate-100) 8px); }
.wh-cell.is-off .wh-cell-code { color: var(--muted); }
.wh-cell-badge { position: absolute; top: -5px; right: -5px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; background: var(--ink); color: #fff; font-size: 9.5px; font-weight: 800; line-height: 16px; text-align: center; }
.wh-cell.is-match { box-shadow: 0 0 0 3px var(--amber-600), 0 4px 12px color-mix(in srgb, var(--amber-600) 45%, transparent); animation: wh-pop .25s ease; }
@keyframes wh-pop { 0% { transform: scale(.85); } 60% { transform: scale(1.12); } 100% { transform: scale(1); } }

/* Product search + result chips. */
.wh-search { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.wh-search-box { display: inline-flex; align-items: center; gap: 8px; flex: 1 1 320px; min-width: 240px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--muted); }
.wh-search-box input { border: 0; outline: 0; background: transparent; padding: 11px 0; width: 100%; font-size: 14px; color: var(--ink); }
.wh-results { margin-bottom: 16px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); }
.wh-results-head { display: flex; align-items: center; gap: 7px; font-weight: 600; font-size: 13px; margin-bottom: 10px; }
.wh-results-list { display: flex; flex-wrap: wrap; gap: 8px; }
.wh-result { display: inline-flex; align-items: center; gap: 8px; padding: 6px 11px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); font-size: 12.5px; }
.wh-result.here { border-color: var(--amber-600); background: var(--amber-50); }
.wh-result .mono { font-weight: 700; }

/* Grouped locate results: product → SKU → locations. */
.wh-locate { display: flex; flex-direction: column; gap: 10px; }
.wh-locate-product { padding: 11px 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); }
.wh-locate-pname { font-size: 14px; margin-bottom: 8px; display: flex; align-items: baseline; gap: 8px; }
.wh-locate-sku { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 6px 0; }
.wh-locate-sku + .wh-locate-sku { border-top: 1px dashed var(--line-soft); }
.wh-locate-meta { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; min-width: 180px; }
.wh-locate-locs { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.wh-locate-none { font-size: 12px; font-style: italic; color: var(--muted); }

/* Occupancy gauge + sidebar row. */
.wh-gauge { width: 148px; height: 148px; border-radius: 50%; margin: 4px auto 16px; display: grid; place-items: center; background: conic-gradient(var(--wh-c, var(--primary)) calc(var(--p, 0) * 1%), var(--line) 0); }
.wh-gauge-hole { width: 110px; height: 110px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; text-align: center; box-shadow: inset 0 0 0 1px var(--line-soft); }
.wh-gauge-pct { font-size: 30px; font-weight: 800; line-height: 1; color: var(--ink); font-variant-numeric: tabular-nums; }
.wh-gauge-cap { font-size: 11px; color: var(--muted); margin-top: 3px; }
.wh-aside-row { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line-soft); font-size: 13px; }

/* Étage detail breadcrumb. */
.wh-crumb { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.wh-crumb svg { opacity: .6; }

/* Sidebar stats. */
.wh-aside-title { display: flex; align-items: baseline; gap: 8px; font-size: 16px; font-weight: 700; margin-bottom: 14px; }
.wh-aside-title .muted { font-size: 13px; font-weight: 500; }
.wh-statgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.wh-stat { border: 1px solid var(--line); border-radius: 11px; padding: 12px; background: var(--bg); }
.wh-stat-value { font-size: 26px; font-weight: 800; line-height: 1; color: var(--ink); font-variant-numeric: tabular-nums; }
.wh-stat-label { font-size: 12px; font-weight: 600; color: var(--text); margin-top: 5px; }
.wh-stat-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.wh-soon { display: flex; gap: 8px; align-items: flex-start; margin-top: 14px; padding: 10px 12px; border-radius: 10px; background: var(--blue-50); color: var(--blue-700); font-size: 12px; line-height: 1.5; }
.wh-soon svg { flex: 0 0 auto; margin-top: 1px; }

/* Empty state. */
.wh-empty { text-align: center; padding: 40px 24px; }
.wh-empty-ic { display: inline-flex; align-items: center; justify-content: center; width: 56px; height: 56px; border-radius: 16px; background: var(--primary-soft); color: var(--primary-strong); margin-bottom: 12px; }
.wh-empty-ic svg { width: 28px; height: 28px; }

/* ---- structure editor ---- */
.wh-edit-card { border-left: 3px solid var(--wh-c, var(--slate-300)); }
.wh-edit-card.is-off { opacity: .7; }
.wh-edit-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.wh-edit-code { font-size: 16px; font-weight: 800; }
.wh-edit-meta { font-size: 12px; color: var(--muted); }
.wh-edit-actions { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.wh-icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); cursor: pointer; transition: background .12s, color .12s, border-color .12s; }
.wh-icon-btn:hover { background: var(--hover); color: var(--ink); }
.wh-icon-danger:hover { background: var(--red-50); color: var(--red-600); border-color: var(--red-400); }

.wh-subform { margin-top: 14px; padding: 14px; border: 1px dashed var(--line); border-radius: 11px; background: var(--bg); }
.wh-subform-title { font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 12px; }
.wh-form-grid { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-end; }
.wh-form-grid .field { margin: 0; min-width: 130px; }
.wh-form-active { display: inline-flex; align-items: center; gap: 8px; }

.wh-colorpick { display: flex; align-items: center; gap: 8px; }
.wh-color-input { width: 42px; height: 38px; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); cursor: pointer; }
.wh-swatches { display: inline-flex; gap: 5px; flex-wrap: wrap; }
.wh-swatch-pick { width: 20px; height: 20px; border-radius: 6px; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line); cursor: pointer; }
.wh-swatch-pick:hover { transform: scale(1.12); }

.wh-row { margin-top: 12px; padding: 11px 12px; border: 1px solid var(--line); border-left: 3px solid var(--wh-c, var(--slate-300)); border-radius: 10px; background: var(--surface); }
.wh-row.is-off { opacity: .65; }
.wh-row-head { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.wh-row-code { font-weight: 700; }

.wh-etage-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.wh-etage { border: 1px solid var(--line); border-radius: 9px; background: color-mix(in srgb, var(--wh-c, #64748b) 7%, var(--surface)); }
.wh-etage.is-off { opacity: .6; background: var(--bg); }
.wh-etage-chip { display: inline-flex; align-items: center; gap: 7px; padding: 6px 8px 6px 10px; }
.wh-etage-name { font-size: 12px; }
.wh-etage-form { width: 100%; }

/* ============================================================================
 | Livreur (delivery driver) board + supervisor dispatch
 ========================================================================== */

/* Driver queue — one card per stop, big and tappable. */
.lv-queue { display: flex; flex-direction: column; gap: 12px; }
.lv-stop { display: flex; gap: 14px; align-items: stretch; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.lv-stop-seq { flex: 0 0 38px; width: 38px; height: 38px; border-radius: 50%; background: var(--primary); color: #fff; font-weight: 800; font-size: 16px; display: grid; place-items: center; }
.lv-stop-body { flex: 1 1 auto; min-width: 0; }
.lv-stop-top { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-bottom: 4px; }
.lv-stop-ref { font-weight: 700; }
.lv-stop-lines { font-size: 12px; }
.lv-stop-name { font-size: 16px; font-weight: 700; color: var(--ink); }
.lv-stop-addr { display: flex; align-items: center; gap: 6px; color: var(--text); font-size: 13.5px; margin-top: 3px; }
.lv-stop-addr svg { color: var(--slate-400); flex: 0 0 auto; }
.lv-stop-phone { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; color: var(--primary-strong); font-weight: 600; margin-top: 4px; }
.lv-stop-actions { flex: 0 0 auto; display: flex; flex-direction: column; gap: 8px; justify-content: center; }
@media (max-width: 640px) { .lv-stop { flex-wrap: wrap; } .lv-stop-actions { flex-direction: row; width: 100%; } .lv-stop-actions .btn { flex: 1; justify-content: center; } }
.lv-empty-ic { display: inline-flex; width: 56px; height: 56px; border-radius: 16px; background: var(--primary-soft); color: var(--primary-strong); align-items: center; justify-content: center; margin-bottom: 12px; }
.lv-empty-ic svg { width: 28px; height: 28px; }

/* Stop detail. */
.lv-addr-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.lv-addr-text { display: flex; align-items: center; gap: 7px; font-size: 16px; font-weight: 600; margin-top: 4px; }

/* Signature pad. */
.lv-sign { position: relative; border: 1px dashed var(--line); border-radius: 12px; background: var(--bg); padding: 6px; }
.lv-sign-pad { width: 100%; height: 200px; touch-action: none; border-radius: 8px; background:
    repeating-linear-gradient(0deg, transparent, transparent 39px, var(--line-soft) 39px, var(--line-soft) 40px) var(--surface); cursor: crosshair; }
.lv-sign-clear { position: absolute; top: 12px; right: 12px; }

/* Dispatch board. */
.dispatch-group { margin-bottom: 16px; }
.dispatch-group-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.dispatch-failed { background: var(--red-50); }
.dispatch-noaddr { color: var(--red-600); }
.dispatch-order { display: inline-flex; gap: 4px; }
.dispatch-move { font-size: 14px; font-weight: 800; line-height: 1; }
.dispatch-move:disabled { opacity: .35; cursor: default; }
.dispatch-group .filter-select { min-width: 130px; }

/* ============================================================================
 | Receiving (goods-in) + putaway + pick list
 ========================================================================== */
.rc-card { margin-bottom: 16px; }
.rc-phase { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.rc-phase-no { flex: 0 0 34px; width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color: #fff; font-weight: 800; font-size: 16px; display: grid; place-items: center; }
.rc-phase-no.is-off { background: var(--slate-300); color: var(--slate-600); }
.rc-slip { padding: 12px; border: 1px dashed var(--line); border-radius: 11px; background: var(--bg); margin-bottom: 14px; }
.rc-unplanned { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line-soft); }
.rc-locked { display: flex; align-items: center; gap: 8px; margin: 4px 0 12px; padding: 9px 12px; border-radius: 10px;
  background: var(--amber-50); color: var(--amber-700); border: 1px solid var(--amber-600); font-size: 13px; }
.rc-locked svg { flex: 0 0 auto; }
/* Inline-editable destination: collapsed clickable text ⇄ select. */
.dest-cell { min-width: 220px; }
.dest-text { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 7px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--hover); color: var(--ink); font-weight: 600; font-family: var(--mono, ui-monospace, monospace);
  cursor: pointer; transition: border-color .15s, background .15s; }
.dest-text:hover { border-color: var(--primary); background: var(--primary-soft); }
.dest-text svg { flex: 0 0 auto; color: var(--primary); }
.dest-text.is-empty { color: var(--muted); font-weight: 500; }
.dest-edit { display: block; }
tr.rc-done td { opacity: .6; }
.rc-etage { margin-top: 12px; }
.rc-etage-head { display: flex; align-items: center; gap: 8px; font-weight: 600; margin: 6px 0; }

/* Pick list. */
.pick-list { display: flex; flex-direction: column; }
.pick-row { display: grid; grid-template-columns: 26px minmax(120px, 200px) 1fr auto; align-items: center; gap: 14px; padding: 11px 6px; border-bottom: 1px solid var(--line-soft); cursor: pointer; }
.pick-row:hover { background: var(--hover); }
.pick-row input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--primary); }
.pick-row:has(input:checked) { opacity: .55; }
.pick-row:has(input:checked) .pick-name { text-decoration: line-through; }
.pick-loc { display: flex; flex-wrap: wrap; gap: 4px; }
.pick-loc .pill { display: inline-flex; align-items: center; gap: 3px; }
.pick-prod { display: flex; flex-direction: column; gap: 1px; }
.pick-name { font-weight: 600; }
.pick-qty { font-weight: 800; font-size: 15px; }

/* ============================================================================
 | Warehouse structure overview — a GitHub-style dot/rail tree
 | depot (root bead) → sections → étages, connected by rails + elbow connectors.
 | Each area carries its accent colour via the inline --wh-c custom property.
 ========================================================================== */
.wh-gstats { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.wh-gstat { flex: 1 1 110px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.wh-gstat-n { font-size: 22px; font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums; }
.wh-gstat-l { font-size: 12px; color: var(--muted); margin-top: 2px; }

.wh-graph { font-size: 14px; }
.wh-gtree { padding: 2px 0; }
.wh-gtree + .wh-gtree { margin-top: 10px; padding-top: 14px; border-top: 1px solid var(--line-soft); }

/* one row (bead + labels); étage rows are links */
.wh-grow { display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 4px 8px 4px 4px; border-radius: 9px; color: var(--ink); text-decoration: none; }
a.wh-grow:hover { background: color-mix(in srgb, var(--wh-c, #64748b) 10%, var(--surface)); }
.wh-grow.is-off { opacity: .55; }

/* the dot */
.wh-bead { width: 13px; height: 13px; flex: 0 0 auto; border-radius: 50%; background: var(--surface);
    border: 3px solid var(--wh-c, var(--slate-400)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--wh-c, #64748b) 14%, transparent); }
.wh-bead.is-fill { background: var(--wh-c, var(--slate-400)); }
.wh-bead--root { width: 16px; height: 16px; border-width: 4px; }
.is-off .wh-bead { border-style: dashed; box-shadow: none; }

.wh-gcode { font-weight: 700; }
.wh-grow--depot .wh-gcode { font-size: 16px; font-weight: 800; }
.wh-gname { color: var(--muted); }
.wh-gmeta { color: var(--faint); font-size: 12px; }

/* rails + elbow connectors for the nested levels */
.wh-gchildren { margin-left: 10px; }
.wh-gnode { position: relative; padding-left: 26px; }
.wh-gnode::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px; background: var(--line); }
.wh-gnode::after { content: ""; position: absolute; left: 0; top: 18px; width: 36px; height: 2px; background: var(--line); }
.wh-gnode:last-child::before { bottom: auto; height: 18px; }

/* per-étage state tag, pushed to the right */
.wh-gtag { display: inline-flex; align-items: center; gap: 4px; margin-left: auto; font-size: 11px; font-weight: 700;
    font-variant-numeric: tabular-nums; border-radius: 999px; padding: 2px 9px; }
.wh-gtag-load { background: color-mix(in srgb, var(--wh-c, #10b981) 20%, transparent); color: var(--ink); }
.wh-gtag-empty { background: var(--line-soft); color: var(--muted); }
.wh-gtag-off { background: var(--slate-100); color: var(--faint); }

.wh-gempty { color: var(--faint); font-style: italic; }

/* ============================================================================
 | Field UI — minimal mobile/tablet shell for preparator & driver roles.
 | No sidebar; a slim sticky top bar + full-width main. Touch-first sizing.
 ========================================================================== */
.m-body { background: var(--bg); }
.m-shell { min-height: 100vh; display: flex; flex-direction: column; }
.m-topbar {
    position: sticky; top: 0; z-index: 30;
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; min-height: 56px;
    background: var(--surface); border-bottom: 1px solid var(--line);
    padding-top: max(10px, env(safe-area-inset-top));
}
.m-back {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; flex: 0 0 auto; margin-left: -6px;
    border-radius: 10px; color: var(--ink);
}
.m-back:active { background: var(--slate-100); }
.m-topbar-title { flex: 1 1 auto; min-width: 0; }
.m-title { font-size: 17px; font-weight: 700; color: var(--ink); line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-sub { font-size: 12px; color: var(--muted); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-menu { position: relative; flex: 0 0 auto; }
.m-menu-btn { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 10px; color: var(--ink); }
.m-menu-btn:active { background: var(--slate-100); }
.m-menu-pop { position: absolute; top: calc(100% + 6px); right: 0; z-index: 40; min-width: 200px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 32px rgba(15,23,42,.18); padding: 6px; }
.m-menu-user { padding: 8px 12px; font-weight: 700; color: var(--ink); border-bottom: 1px solid var(--line-soft); margin-bottom: 4px; }
.m-menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 11px 12px; border-radius: 8px; font-size: 15px; color: var(--ink); background: none; text-align: left; }
.m-menu-item:active { background: var(--slate-100); }
.m-main { flex: 1 1 auto; padding: 14px; padding-bottom: max(14px, env(safe-area-inset-bottom)); max-width: 720px; width: 100%; margin: 0 auto; }

/* Tabs (field board) */
.m-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.m-tab { flex: 1 1 0; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 10px; font-weight: 600; font-size: 14px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.m-tab.active { color: var(--primary-strong); border-color: var(--primary); background: var(--primary-soft); }
.m-tab .count { font-size: 12px; background: rgba(100,116,139,.16); border-radius: 999px; padding: 1px 8px; }
.m-tab.active .count { background: rgba(16,185,129,.20); color: var(--primary-strong); }

/* Order cards (preparator board) */
.pcard-list { display: flex; flex-direction: column; gap: 8px; }
.pcard { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; color: inherit; }
.pcard:active { background: var(--slate-100); }
.pcard.tmr-warn   { border-left: 4px solid #f59e0b; }
.pcard.tmr-danger { border-left: 4px solid #ef4444; }
.pcard.tmr-ok     { border-left: 4px solid #10b981; }
.pcard-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.pcard-ref { font-family: var(--mono, ui-monospace, monospace); font-weight: 700; font-size: 15px; color: var(--ink); }
.pcard-cust { color: var(--ink); font-size: 14px; margin-top: 2px; }
.pcard-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 6px; color: var(--muted); font-size: 13px; }
.pcard-timer { font-variant-numeric: tabular-nums; font-weight: 700; }
.pcard-timer.tmr-warn { color: #b45309; }
.pcard-timer.tmr-danger { color: #dc2626; }
.pcard-go { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; font-weight: 700; color: var(--primary-strong); }
.m-empty { text-align: center; color: var(--muted); padding: 40px 16px; }

/* Pick view — sticky scan + counters */
.pick-head { position: sticky; top: 56px; z-index: 20; background: var(--bg); padding: 10px 0 12px; margin: -4px 0 6px; }
.pick-counts { display: flex; gap: 10px; margin-bottom: 10px; }
.pick-count { flex: 1 1 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; text-align: center; }
.pick-count-val { font-size: 22px; font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums; line-height: 1.1; }
.pick-count-val.is-complete { color: var(--primary-strong); }
.pick-count-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); margin-top: 2px; }
.scan-bar { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 2px solid var(--line); border-radius: 12px; padding: 4px 6px 4px 12px; }
.scan-bar.is-ok { border-color: var(--primary); }
.scan-bar.is-err { border-color: var(--red-400, #f87171); }
.scan-bar > svg { color: var(--faint); flex: 0 0 auto; }
.scan-bar input { flex: 1 1 auto; border: 0; outline: 0; background: none; font-size: 16px; padding: 10px 0; min-width: 0; }
.scan-msg { font-size: 12px; min-height: 16px; margin-top: 6px; }
.scan-msg.is-ok  { color: var(--emerald-600, #059669); }
.scan-msg.is-err { color: var(--red-600, #dc2626); }

/* Pick rows (mobile cards) */
.pick-list { display: flex; flex-direction: column; gap: 8px; }
.pick-row { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; cursor: pointer; }
/* Completed line: de-emphasised, light grey, and sunk to the bottom (flex order). */
.pick-row.is-picked { background: var(--slate-100); border-color: var(--line); }
.pick-row.is-picked .pick-name { color: var(--muted); font-weight: 500; }
.pick-row.is-picked .pick-qtyin { color: var(--muted); }
.pick-check { flex: 0 0 auto; width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--line); display: inline-flex; align-items: center; justify-content: center; color: #fff; }
.pick-row.is-picked .pick-check { background: var(--primary); border-color: var(--primary); }
.pick-check svg { width: 16px; height: 16px; opacity: 0; }
.pick-row.is-picked .pick-check svg { opacity: 1; }
.pick-body { flex: 1 1 auto; min-width: 0; }
.pick-name { font-weight: 600; color: var(--ink); }
.pick-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.pick-locs { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.pick-qty { flex: 0 0 auto; font-variant-numeric: tabular-nums; font-weight: 700; color: var(--ink); font-size: 15px; }
.pick-actions { position: sticky; bottom: 0; padding: 12px 0; padding-bottom: max(12px, env(safe-area-inset-bottom)); background: linear-gradient(to top, var(--bg) 70%, transparent); }
.pick-actions .btn { width: 100%; justify-content: center; padding: 14px; font-size: 16px; }

/* Pick — quantity controls (scan batch qty + per-line scanned count) */
.scan-qty { display: inline-flex; align-items: center; gap: 2px; flex: 0 0 auto; border-left: 1px solid var(--line); padding-left: 8px; margin-right: 4px; }
.scan-qty input { width: 46px; border: 0; outline: 0; background: none; font-size: 16px; font-weight: 700; text-align: center; padding: 8px 0; }
.pick-row .pick-check { background: none; cursor: pointer; }
/* Partially-scanned line: stronger amber border so it stands out. */
.pick-row.is-partial { border-color: #f59e0b; border-width: 2px; box-shadow: inset 0 0 0 1px #f59e0b; }
.pick-qtybox { flex: 0 0 auto; display: inline-flex; align-items: baseline; gap: 4px; }
.pick-qtyin { min-width: 22px; text-align: right; font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--ink); }
.pick-row.is-partial .pick-qtyin { color: #b45309; }
.pick-qtyord { color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.pick-qtyedit { width: 56px; text-align: center; font-size: 16px; font-weight: 700; padding: 8px 4px; border: 1px solid var(--line); border-radius: 8px; font-variant-numeric: tabular-nums; color: var(--ink); }
.pick-qtyedit:focus { border-color: var(--primary); outline: 0; }

/* Pick — scan qty as a native select (renders as the iOS wheel picker) */
.scan-qty-sel { border: 0; background: none; font-size: 16px; font-weight: 700; padding: 8px 2px; color: var(--ink); font-variant-numeric: tabular-nums; }
.scan-qty-sel:focus { outline: 0; }
/* Pick row body — each piece on its own line */
.pick-body { display: flex; flex-direction: column; align-items: flex-start; }
.pick-name, .pick-sub { display: block; }

/* Receiving — single big slip-upload button (label wraps a hidden file input). */
.slip-btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; padding: 16px; border: 2px dashed var(--line); border-radius: 12px; font-weight: 700; font-size: 15px; color: var(--ink); background: var(--surface); cursor: pointer; }
.slip-btn:active { background: var(--slate-100); }
.slip-btn svg { width: 20px; height: 20px; flex: 0 0 auto; color: var(--slate-400); }
.slip-btn.is-attached { border-style: solid; border-color: var(--primary); background: var(--primary-soft); color: var(--primary-strong); }
.slip-btn.is-attached svg { color: var(--primary-strong); }

/* Receiving — scan/search results dropdown (add a line by EAN or name). */
.scan-wrap { position: relative; }
.scan-results { position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 40; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 32px rgba(15,23,42,.18); padding: 6px; max-height: 280px; overflow: auto; }
.scan-result { display: block; width: 100%; text-align: left; padding: 10px 12px; border-radius: 8px; background: none; }
.scan-result:active, .scan-result:hover { background: var(--slate-100); }
.scan-result-name { display: block; font-weight: 600; color: var(--ink); }
.scan-result-sub { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }

/* Receiving — putaway as mobile cards (no overflowing table). */
.pa-list { display: flex; flex-direction: column; gap: 8px; }
.pa-row { border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: var(--surface); }
.pa-row.is-done { background: var(--slate-100); }
.pa-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.pa-prod { min-width: 0; }
.pa-name { display: block; font-weight: 600; color: var(--ink); }
.pa-action { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
/* Location shown below as a big grey selector (editable — change where it goes). */
.pa-dest { display: flex; align-items: center; gap: 8px; width: 100%; padding: 4px 12px; border-radius: 10px; background: var(--slate-100); border: 1px solid var(--line); color: var(--slate-500); }
.pa-dest svg { flex: 0 0 auto; }
.pa-dest select { flex: 1 1 auto; min-width: 0; border: 0; background: none; padding: 10px 0; font-size: 15px; font-weight: 700; color: var(--ink); }
.pa-dest select:focus { outline: 0; }
.pa-dest.is-done { font-weight: 700; color: var(--ink); padding: 10px 12px; }
.pa-action .btn { width: 100%; justify-content: center; padding: 12px; }
/* Warehouse positions summary (all spots an item lives in — multi-position aware). */
.pa-positions { margin-bottom: 16px; padding-bottom: 14px; border-bottom: 1px solid var(--line-soft); }
.pa-pos-list { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.pa-pos-list .pill svg { width: 13px; height: 13px; }
/* Inline assign (étage select + button) inside the positions table. */
.pa-assign { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0; }
.pa-assign .pa-dest { width: auto; min-width: 200px; flex: 1 1 200px; }
.pa-assign .btn { flex: 0 0 auto; }
