/* ALPINE WHITE OS — Werkbank design language.
   Derived from alpinewhite.com's verified brand tokens (see docs/design-review.md):
   SangBleu Sunrise-style serif display, Roboto body, blue ladder, warm stone
   neutrals, 8px radii, hairlines instead of shadows, lowercase pill badges. */

* { box-sizing: border-box; }

:root {
  /* brand blue ladder */
  --blue-50: #E7EEF7;
  --blue-200: #C9DAEE;
  --blue-300: #99BCE0;
  --blue-600: #316BAB;
  --blue-700: #254E7F;
  --blue-800: #213A59;
  --blue-900: #16253B;
  /* warm stone neutrals */
  --stone-50: #F8F8F7;
  --stone-100: #F5F5F4;
  --stone-200: #E7E5E4;
  --stone-400: #A8A29E;
  --ink: #161616;
  --muted: #57534E;
  --line: rgba(22, 22, 22, 0.1);
  --line-strong: rgba(22, 22, 22, 0.2);
  /* semantic */
  --ok: #1E7A44;
  --ok-bg: #EAF4EE;
  --ok-line: #CBE3D3;
  --warn: #8A6116;
  --warn-bg: #F7EFDD;
  --warn-line: #EADFC2;
  --danger: #A63A22;
  --danger-strong: #CD492D;
  --danger-bg: #F9EDEA;
  --danger-line: #EFD2C9;
  --error: #D0021B;
  /* legacy alias kept for older rules/scripts */
  --bg-soft: var(--stone-50);
  /* type */
  --serif: 'SangBleu Sunrise', 'Iowan Old Style', 'Palatino Nova', Palatino, 'Book Antiqua', Georgia, serif;
  --sans: Roboto, -apple-system, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  --cond: 'Roboto Condensed', 'Avenir Next Condensed', 'Arial Narrow', sans-serif;
  /* geometry */
  --r-sm: 6px;
  --r: 8px;
  --r-lg: 10px;
  --r-pill: 20px;
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.06);
}

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--stone-50);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--ink); }
a:hover { color: var(--blue-600); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.pre { white-space: pre-line; }
.inline { display: inline; }

h1 {
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 500;
  letter-spacing: 0;
  line-height: 1.2;
  margin: 0;
}
h2 {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 36px 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

/* ---------- Admin shell: sidebar + canvas ---------- */
.os-shell { display: grid; grid-template-columns: 224px minmax(0, 1fr); min-height: 100vh; }
.os-side {
  background: #fff;
  border-right: 1px solid var(--line);
  padding: 22px 0 16px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.os-brand {
  display: block;
  padding: 0 20px 16px;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.14em;
  color: var(--ink);
  text-decoration: none;
}
.os-brand span {
  display: block;
  font-family: var(--cond);
  font-weight: 400;
  font-size: 10.5px;
  letter-spacing: 0.22em;
  color: var(--muted);
  margin-top: 2px;
}
.os-nav { display: flex; flex-direction: column; }
.os-nav-group {
  font-family: var(--cond);
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--stone-400);
  padding: 16px 20px 6px;
}
.os-nav a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 20px;
  font-size: 13.5px;
  color: var(--ink);
  text-decoration: none;
  border-left: 2px solid transparent;
}
.os-nav a:hover { background: var(--stone-50); color: var(--ink); }
.os-nav a[aria-current='page'] {
  border-left-color: var(--blue-600);
  background: var(--blue-50);
  color: var(--blue-700);
  font-weight: 600;
}
.os-side-foot {
  margin-top: auto;
  padding: 14px 20px 0;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.os-side-foot a, .os-side-foot .linklike { font-size: 12px; color: var(--muted); }
/* Environment marker under Account · Log out — staging must never look like production. */
.os-env {
  display: block;
  width: fit-content;
  margin-top: 10px;
  font-family: var(--cond);
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--stone-400);
}
.os-env-staging, .os-env-dev, .os-env-production {
  color: var(--warn);
  background: var(--warn-bg);
  border: 1px solid var(--warn-line);
  border-radius: 99px;
  padding: 1px 8px;
}
.os-env-production { color: var(--ok); background: var(--ok-bg); border-color: var(--ok-line); }
.os-main { padding: 28px 32px 64px; min-width: 0; }

/* ---------- Portal shell (distributors + login): utility strip + topbar ---------- */
.ustrip {
  background: var(--blue-800);
  color: #fff;
  text-align: center;
  font-size: 11.5px;
  letter-spacing: 0.02em;
  padding: 5px 16px;
}
.topbar { border-bottom: 1px solid var(--line); background: #fff; position: sticky; top: 0; z-index: 10; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 58px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
.brand { font-weight: 700; letter-spacing: 0.14em; text-decoration: none; color: var(--ink); font-size: 14px; }
.brand span { font-weight: 400; letter-spacing: 0.04em; color: var(--muted); margin-left: 8px; font-size: 12.5px; }
.nav { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.nav a { color: var(--ink); text-decoration: none; font-size: 13.5px; padding: 6px 0; border-bottom: 2px solid transparent; }
.nav a:hover { color: var(--blue-600); }
.nav a[aria-current='page'] { font-weight: 600; border-bottom-color: var(--blue-600); color: var(--blue-700); }
.nav-who { color: var(--muted); font-size: 12.5px; }

.container { max-width: 1040px; margin: 0 auto; padding: 0 20px; width: 100%; }
main.container { padding-top: 28px; padding-bottom: 64px; }

.footer { border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; padding: 16px 0; letter-spacing: 0.06em; background: transparent; }

/* ---------- Info tooltip: hover/focus via CSS, click/tap toggle via app.js ---------- */
.tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--muted);
  font: 600 11px/1 var(--sans);
  font-style: normal;
  cursor: pointer;
  position: relative;
  vertical-align: middle;
  padding: 0;
  flex: 0 0 auto;
}
.tip:hover, .tip[data-tip-open] { border-color: var(--blue-600); color: var(--blue-700); background: var(--blue-50); }
.tip::after {
  content: attr(data-tip);
  position: absolute;
  top: calc(100% + 8px);
  left: -8px;
  width: max-content;
  max-width: min(320px, 78vw);
  background: var(--blue-900);
  color: #fff;
  font: 400 12.5px/1.45 var(--sans);
  text-align: left;
  padding: 8px 12px;
  border-radius: var(--r);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s;
  z-index: 30;
  white-space: normal;
  letter-spacing: normal;
  text-transform: none;
}
.tip:hover::after, .tip:focus-visible::after, .tip[data-tip-open]::after { opacity: 1; }
.tip-end::after { left: auto; right: -8px; }
h1 .tip { margin-left: 8px; margin-top: -2px; }
h2 .tip { margin-left: 6px; }
label .tip { margin-left: 6px; } /* only next to label TEXT in a wrapper — never inside <label> (click forwarding) */

/* ---------- Modal (native <dialog>) ---------- */
dialog.modal {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 0;
  max-width: 460px;
  width: calc(100vw - 32px);
  box-shadow: 0 8px 32px rgba(22, 22, 22, 0.18);
  color: var(--ink);
}
dialog.modal::backdrop { background: rgba(22, 37, 59, 0.35); }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 20px 12px; border-bottom: 1px solid var(--line); }
.modal-head h2 {
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink);
  margin: 0;
  padding: 0;
  border: none;
}
.modal-close { border: none; background: none; font-size: 20px; line-height: 1; color: var(--muted); cursor: pointer; padding: 4px 9px; border-radius: var(--r-sm); }
.modal-close:hover { background: var(--stone-100); color: var(--ink); }
.modal-body { padding: 2px 20px 20px; }
.modal-body .form-card { max-width: none; }
.modal-body .flash { margin: 14px 0 2px; }

/* ---------- Page head ---------- */
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.page-head p { margin: 6px 0 0; font-size: 14px; max-width: 640px; color: var(--muted); }
.crumb { font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.crumb a { color: var(--muted); text-decoration: none; }
.crumb a:hover { color: var(--blue-600); text-decoration: underline; }

/* ---------- Flash messages ---------- */
.flash {
  padding: 12px 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  margin-bottom: 20px;
  font-size: 14px;
  background: #fff;
  white-space: pre-line;
}
.flash-error { border-color: var(--danger-line); color: var(--danger); background: var(--danger-bg); }
.flash-success { border-color: var(--ok-line); color: var(--ok); background: var(--ok-bg); }
.flash-warn { border-color: var(--warn-line); color: var(--warn); background: var(--warn-bg); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-lg); background: #fff; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table thead th {
  background: #fff;
  font-family: var(--cond);
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  white-space: nowrap;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: var(--stone-50); }
.table tfoot td { border-top: 1px solid var(--line-strong); border-bottom: none; }
.table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table a { font-weight: 500; }
.row-inactive td { color: var(--muted); }
.row-overdue td { background: var(--danger-bg); }
.row-overdue td:first-child { border-left: 3px solid var(--danger-strong); }
.actions { white-space: nowrap; text-align: right; }
.actions > * { margin-left: 6px; }
.email-status { max-width: 260px; }
.product-name { font-weight: 500; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  padding: 8px 16px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  font-family: inherit;
  line-height: 1.4;
  border-radius: var(--r);
}
.btn:hover { background: var(--stone-50); color: var(--ink); }
.btn-primary { background: var(--blue-600); border-color: var(--blue-600); color: #fff; }
.btn-primary:hover { background: var(--blue-800); border-color: var(--blue-800); color: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); }
.btn-primary:disabled { background: var(--stone-400); border-color: var(--stone-400); cursor: not-allowed; box-shadow: none; }
.btn-sm { padding: 4px 10px; font-size: 12.5px; border-radius: var(--r-sm); }
.btn-lg { padding: 12px 28px; font-size: 14px; }
.btn-block { width: 100%; }
.btn-danger { border-color: var(--danger-line); color: var(--danger); }
.btn-danger:hover { background: var(--danger-bg); color: var(--danger); }
.btn[aria-current='true'] { background: var(--blue-50); border-color: var(--blue-200); color: var(--blue-700); font-weight: 600; }
.linklike { background: none; border: none; padding: 0; color: var(--ink); font: inherit; font-size: 14px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.linklike:hover { color: var(--blue-600); }

/* ---------- Forms ---------- */
label { display: block; font-size: 13px; font-weight: 600; margin: 16px 0 6px; }
input[type='text'], input[type='email'], input[type='password'], input[type='number'], input[type='search'], select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line-strong);
  font-size: 15px;
  font-family: inherit;
  background: #fff;
  border-radius: var(--r);
  color: var(--ink);
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue-600); outline-offset: 1px; }
.btn:focus-visible, .nav a:focus-visible, .os-nav a:focus-visible, .linklike:focus-visible, .qty-btn:focus-visible, .view-tab:focus-visible { outline: 2px solid var(--blue-600); outline-offset: 1px; }
.table-filter { max-width: 280px; margin: 0 0 12px; }
.form-card { max-width: 480px; }
.form-actions { margin-top: 24px; display: flex; gap: 10px; align-items: center; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; font-size: 14px; margin-top: 20px; }
.check input { width: auto; }
/* Inline field error: add .field-error on a wrapper (or the input) + a .field-msg after */
.field-error input, .field-error select, .field-error textarea, input.field-error, select.field-error {
  border-color: var(--error);
  outline: 2px solid rgba(208, 2, 27, 0.12);
}
.field-msg { font-size: 12.5px; color: var(--error); margin-top: 4px; font-weight: 400; }

/* ---------- Login ---------- */
.login-box {
  max-width: 400px;
  margin: 9vh auto 0;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 32px 28px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}
.login-box h1 { letter-spacing: 0; }
.login-box .btn { margin-top: 24px; }

/* ---------- Badges: lowercase tinted pills ---------- */
.badge {
  display: inline-block;
  border: 1px solid var(--line);
  background: var(--stone-100);
  color: var(--muted);
  padding: 2.5px 10px;
  font-size: 11.5px;
  font-weight: 500;
  border-radius: var(--r-pill);
  white-space: nowrap;
}
.badge-ok { border-color: var(--ok-line); color: var(--ok); background: var(--ok-bg); }
.badge-off { border-color: var(--stone-200); color: var(--muted); background: var(--stone-100); }
.badge-dark { border-color: var(--blue-200); color: var(--blue-700); background: var(--blue-50); }
.badge-danger { border-color: var(--danger-line); color: var(--danger); background: var(--danger-bg); }
.badge-warn { border-color: var(--warn-line); color: var(--warn); background: var(--warn-bg); }
h1 .badge { vertical-align: middle; margin-left: 8px; }

/* ---------- Stats / KPI tiles: serif numerals ---------- */
.stat-row { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.stat { border: 1px solid var(--line); border-radius: var(--r-lg); background: #fff; padding: 16px 18px; min-width: 160px; text-decoration: none; flex: 1; }
a.stat:hover { border-color: var(--blue-300); color: inherit; }
.stat strong {
  display: block;
  font-family: var(--serif);
  font-size: 33px;
  font-weight: 500;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.stat span { color: var(--muted); font-family: var(--cond); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }
.stat-alert strong { color: var(--danger-strong); }

/* ---------- Meta grid (record summaries) ---------- */
.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px 24px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: #fff;
  padding: 16px 20px;
  margin-bottom: 20px;
  font-size: 14px;
}
.meta-grid .muted { font-family: var(--cond); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }

/* ---------- Tool cards ---------- */
.tool-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-bottom: 8px; }
.tool-card {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: #fff;
  padding: 18px 20px;
  text-decoration: none;
  display: block;
  color: var(--ink);
}
a.tool-card:hover { border-color: var(--blue-300); color: var(--ink); }
.tool-card strong { display: block; font-size: 15px; font-weight: 600; margin-bottom: 2px; }
.tool-card span { color: var(--blue-700); background: var(--blue-50); border: 1px solid var(--blue-200); border-radius: var(--r-pill); display: inline-block; padding: 1.5px 9px; font-size: 11px; font-weight: 500; margin-top: 2px; }
.tool-card p { margin: 8px 0 0; font-size: 13px; color: var(--muted); }
.tool-card-alert { border-color: var(--danger-line); }
.tool-card-alert span { color: var(--danger); background: var(--danger-bg); border-color: var(--danger-line); }

/* ---------- Document upload / detail bits ---------- */
.doc-upload { max-width: 480px; }
.doc-upload .form-actions { margin-top: 16px; }
.field-row { display: flex; gap: 12px; }
.field-row > div { flex: 1; }
.detail-footer { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-top: 24px; }
.qty-edit { max-width: 110px; text-align: right; }

/* ---------- Tool-grant checkboxes (team) ---------- */
.tools-form { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.check-row { display: flex; gap: 16px; margin-top: 6px; flex-wrap: wrap; }
.check-inline { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; font-size: 13px; margin: 0; white-space: nowrap; }
.check-inline input { width: auto; }

/* ---------- Order form (shop) ---------- */
.qty-control { display: inline-flex; align-items: stretch; border: 1px solid var(--line-strong); border-radius: var(--r); overflow: hidden; background: #fff; }
.qty-control input {
  width: 84px;
  text-align: center;
  border: none;
  border-radius: 0;
  -moz-appearance: textfield;
}
.qty-control input:focus { outline-offset: -2px; }
.qty-control input::-webkit-outer-spin-button, .qty-control input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.qty-btn { width: 34px; border: none; background: var(--stone-100); font-size: 16px; cursor: pointer; color: var(--muted); }
.qty-btn:hover { background: var(--stone-200); }
.qty-adjusted { outline: 2px solid var(--blue-600); outline-offset: -2px; }
.qty-note {
  display: inline-block;
  font-size: 11.5px;
  color: var(--blue-700);
  background: var(--blue-50);
  border: 1px solid var(--blue-200);
  border-radius: var(--r-sm);
  padding: 2px 8px;
  margin-top: 6px;
}
.line-total { min-width: 110px; }

.order-footer { display: flex; justify-content: space-between; gap: 32px; margin-top: 24px; flex-wrap: wrap; align-items: flex-start; }
.order-reference { flex: 1; min-width: 260px; max-width: 420px; }
.order-reference label { margin-top: 0; }
.order-summary {
  text-align: right;
  min-width: 260px;
  position: sticky;
  bottom: 0;
  z-index: 5;
  background: rgba(255, 255, 255, 0.97);
  border-top: 1px solid var(--line-strong);
  padding: 12px 16px 16px;
  margin-top: 16px;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05);
}
.order-total { display: flex; justify-content: space-between; gap: 24px; font-size: 14px; border-bottom: 1px solid var(--line); padding-bottom: 10px; margin-bottom: 14px; align-items: baseline; }
.order-total strong { font-family: var(--serif); font-weight: 500; font-size: 22px; font-variant-numeric: tabular-nums; }

/* ---------- Price list ---------- */
.price-input { max-width: 120px; text-align: right; }
.currency-select { width: auto; min-width: 120px; margin-bottom: 16px; }
.copy-form { display: flex; gap: 10px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
.copy-form label { margin: 0; }
.copy-form select { width: auto; min-width: 220px; }

/* ---------- Empty states ---------- */
.empty { border: 1px dashed var(--line-strong); border-radius: var(--r-lg); padding: 32px; text-align: center; color: var(--ink); background: #fff; }
.empty p { margin: 4px 0; }

/* ---------- View tabs: quiet underline tabs ---------- */
.view-nav { display: flex; gap: 22px; flex-wrap: wrap; align-items: flex-end; border-bottom: 1px solid var(--line); margin: 0 0 24px; }
.view-tab {
  border: none;
  background: none;
  color: var(--muted);
  padding: 8px 2px 9px;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.view-tab:hover { color: var(--ink); }
.view-tab[aria-selected='true'] { color: var(--blue-700); font-weight: 600; border-bottom-color: var(--blue-600); }
.view-panel > h2:first-child { margin-top: 0; }

/* ---------- Segmented control (list filters) ---------- */
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--r); background: #fff; overflow: hidden; }
.seg > a, .seg > button {
  padding: 7.5px 15px;
  font: inherit;
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  border: none;
  border-right: 1px solid var(--line);
  background: none;
  cursor: pointer;
}
.seg > :last-child { border-right: none; }
.seg > [aria-current='true'], .seg > [aria-pressed='true'] { background: var(--blue-50); color: var(--blue-700); font-weight: 600; }

/* ---------- Filter bar ---------- */
.filter-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.filter-bar select { width: auto; min-width: 180px; max-width: 300px; }
.filter-bar input[type='search'], .filter-bar input[type='text'] { width: auto; max-width: 260px; }
.filter-bar .table-filter { margin: 0; }
/* Filter rows mix inputs, selects, segs and buttons — one shared 36px control height. */
.filter-bar input[type='search'], .filter-bar input[type='text'], .filter-bar select { padding: 7px 12px; font-size: 13.5px; }
.page-head .table-filter, .page-head input[type='search'] { padding: 7px 12px; font-size: 13.5px; width: auto; max-width: 260px; }

/* ---------- Document editor split ---------- */
.editor-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 42%); gap: 28px; align-items: start; }
.editor-preview-col { position: sticky; top: 20px; max-height: calc(100vh - 40px); overflow: auto; }
.editor-preview-col h2:first-child { margin-top: 0; }
@media (max-width: 1100px) {
  .editor-split { grid-template-columns: 1fr; }
  .editor-preview-col { position: static; max-height: none; }
}

/* ---------- Document editor line-item table ---------- */
.lines-table th, .lines-table td { padding: 6px 10px; }
.lines-table td:first-child { white-space: nowrap; }
.lines-table td:nth-child(2) { width: 100%; min-width: 180px; }
.lines-table input { padding: 6px 8px; font-size: 14px; border-radius: var(--r-sm); }
.lines-table input[name^='sku_'] { width: 120px; }
.lines-table input[name^='qty_'] { width: 90px; text-align: right; }
.lines-table input[name^='unit_'] { width: 72px; }
.lines-table input[name^='price_'] { width: 110px; text-align: right; }
.lines-table input[name^='vat_'] { width: 70px; text-align: right; }
.lines-table input[name^='lot_'] { width: 120px; }
.lines-table td.disc-cell { white-space: nowrap; }
.lines-table .disc-cell input { width: 84px; text-align: right; display: block; }
.lines-table .disc-cell input + input { margin-top: 4px; }

/* ---------- Repeatable add-line rows ---------- */
.add-line-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 12px; }
.add-line-row > div { flex: 1; min-width: 130px; }
.add-line-row label { margin-top: 0; }
.add-line-row .add-line-remove { flex: 0 0 auto; margin-bottom: 1px; }

.order-notes { border: 1px solid var(--line); border-radius: var(--r); background: #fff; padding: 12px 16px; font-size: 14px; white-space: pre-line; }

/* ---------- Responsive ---------- */
@media (max-width: 880px) {
  .os-shell { grid-template-columns: 1fr; }
  .os-side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px 14px; padding: 10px 16px; border-right: none; border-bottom: 1px solid var(--line); }
  .os-brand { padding: 0 8px 0 0; }
  .os-brand span { display: none; }
  .os-nav { flex-direction: row; flex-wrap: wrap; }
  .os-nav-group { display: none; }
  .os-nav a { padding: 6px 10px; border-left: none; border-radius: var(--r-sm); }
  .os-nav a[aria-current='page'] { border-left: none; }
  .os-side-foot { margin: 0 0 0 auto; padding: 0; border: none; }
  .os-side-mail { display: none; }
  .os-main { padding: 20px 16px 48px; }
}
@media (max-width: 640px) {
  .order-summary { text-align: left; width: 100%; }
  .page-head { flex-direction: column; }
  .field-row { flex-direction: column; }
  .qty-btn { width: 44px; }
  .qty-control input { width: 64px; }
}
@media (pointer: coarse) {
  .btn-sm { padding: 9px 14px; }
  .qty-btn { min-width: 44px; min-height: 44px; }
  .nav a, .os-nav a { padding-top: 10px; padding-bottom: 10px; }
}

/* ---------- Asset hub (DAM) — prototype: docs/design/dam-prototype.html ---------- */
.pill {
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-family: var(--cond);
  font-weight: 500;
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: lowercase;
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
}
.pill:hover { border-color: var(--blue-300); color: var(--ink); }
.pill[aria-pressed='true'] { background: var(--blue-50); border-color: var(--blue-200); color: var(--blue-700); }
.asset-fbar { row-gap: 8px; }

.agrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 14px; }
.asset { background: #fff; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; display: flex; flex-direction: column; }
/* The author display:flex above beats the UA's [hidden]{display:none} — the
   filter pills toggle the hidden attribute, so re-assert it explicitly. */
.asset[hidden] { display: none; }
/* bulk selection */
.asel { display: inline-flex; align-items: center; margin-left: auto; cursor: pointer; padding: 2px 0 2px 12px; border-left: 1px solid var(--line); }
.asel input { margin: 0; width: 15px; height: 15px; cursor: pointer; accent-color: var(--blue-600); }
.bulkbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 0 0 16px; padding: 10px 14px; background: var(--blue-50); border: 1px solid var(--blue-200); border-radius: var(--r); }
.bulkbar[hidden] { display: none; }
.bulk-count { font-weight: 600; color: var(--blue-700); font-size: 13px; }
.bulk-group { display: inline-flex; gap: 6px; align-items: center; }
.bulkbar .btn { white-space: nowrap; }
.bulkbar input[type='text'], .bulkbar select { height: 30px; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 0 8px; font: 12.5px var(--sans); background: #fff; color: var(--ink); max-width: 180px; }
.label-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
/* asset settings: move row */
.move-row { display: flex; gap: 8px; align-items: end; margin-top: 18px; }
.move-row label { margin: 0 0 7px; }
.move-row select { flex: 1; }
/* upload progress */
.upl-progress { display: inline-block; vertical-align: middle; width: 86px; height: 6px; border-radius: 3px; background: var(--stone-200); overflow: hidden; }
.upl-progress i { display: block; height: 100%; background: var(--blue-600); border-radius: 3px; transition: width 0.2s; }
.upl-pct { margin-left: 6px; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
/* stat card as link */
a.stat-link { text-decoration: none; color: inherit; }
a.stat-link:hover { border-color: var(--blue-300); }

.dl-menu { position: relative; display: inline-block; }
.dl-menu summary { list-style: none; cursor: pointer; user-select: none; }
.dl-menu summary::-webkit-details-marker { display: none; }
.dl-menu-list {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 40;
  background: #fff; border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: 0 8px 32px rgba(22, 22, 22, 0.12); min-width: 240px; padding: 6px;
}
.dl-menu-list a {
  display: flex; justify-content: space-between; align-items: baseline; gap: 16px;
  padding: 8px 10px; border-radius: var(--r-sm); text-decoration: none;
  font-size: 13.5px; color: var(--ink); white-space: nowrap;
}
.dl-menu-list a:hover { background: var(--blue-50); color: var(--blue-700); }
.dl-menu-list a:first-child { border-bottom: 1px solid var(--line); border-bottom-left-radius: 0; border-bottom-right-radius: 0; margin-bottom: 4px; padding-bottom: 10px; }
.asset .thumb[data-lightbox] { cursor: zoom-in; }
.lightbox-body img[hidden] { display: none; }
.lightbox-video { max-width: 100%; max-height: 78vh; display: block; background: #000; }
.lightbox-video[hidden] { display: none; }
.thumb-play-overlay { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); pointer-events: none; opacity: 0.88; }
.lightbox-none { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 70px 40px; text-align: center; }
.lightbox-none[hidden] { display: none; }
.lightbox-ext {
  font-family: var(--cond); font-size: 13px; font-weight: 600; letter-spacing: 0.12em;
  color: var(--blue-700); background: var(--blue-50); border: 1px solid var(--blue-200);
  border-radius: var(--r-pill); padding: 4px 14px;
}
dialog.lightbox { max-width: min(92vw, 1000px); padding: 0; }
.lightbox-body { background: var(--stone-100); display: flex; align-items: center; justify-content: center; min-height: 200px; position: relative; }
.lightbox-nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.92); color: var(--ink);
  font: 400 22px/1 var(--sans); cursor: pointer; padding: 0 0 3px;
}
.lightbox-nav:hover { border-color: var(--blue-600); color: var(--blue-700); background: #fff; }
.lightbox-nav[hidden] { display: none; }
.lightbox-prev { left: 10px; }
.lightbox-next { right: 10px; }
.lightbox-body img { max-width: 100%; max-height: 78vh; display: block; }
.lightbox-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 14px; }
.lightbox-actions { display: flex; gap: 14px; align-items: center; }
.asset:hover { border-color: var(--blue-300); }
.asset .thumb { height: 132px; display: flex; align-items: center; justify-content: center; position: relative; background: var(--blue-50); overflow: hidden; }
.asset .thumb-ground { background: var(--stone-100); }
.asset .thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.thumb .corner { position: absolute; top: 8px; left: 8px; display: flex; gap: 5px; z-index: 1; flex-wrap: wrap; }
.thumb .corner-r { position: absolute; top: 8px; right: 8px; display: flex; gap: 5px; z-index: 1; flex-wrap: wrap; justify-content: flex-end; }
.abody { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.aname { font-size: 13.5px; line-height: 1.35; }
.ameta { font-size: 11.5px; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: auto; }
.acts { display: flex; gap: 10px; padding: 0 12px 12px; flex-wrap: wrap; align-items: center; }
.acts-more {
  width: 24px; height: 22px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm); font-size: 15px; line-height: 1; letter-spacing: 0.05em; padding-bottom: 6px;
}
.acts-more:hover { background: var(--stone-100); color: var(--ink); text-decoration: none; }
.lnk { background: none; border: 0; padding: 0; color: var(--blue-600); font-size: 12.5px; cursor: pointer; text-decoration: none; font-family: inherit; }
.lnk:hover { text-decoration: underline; color: var(--blue-700); }
.lnk-mut { color: var(--muted); }
.vhist { font-size: 11.5px; color: var(--muted); border-top: 1px solid var(--line); margin-top: 6px; padding-top: 6px; }

/* CSS art for files without a real preview (videos, PDFs, zips) */
.thumb-play { width: 54px; height: 54px; border-radius: 50%; background: var(--blue-900); position: relative; opacity: 0.85; }
.thumb-play::after { content: ''; position: absolute; left: 21px; top: 16px; border-left: 16px solid #fff; border-top: 11px solid transparent; border-bottom: 11px solid transparent; }
.thumb-doc { width: 64px; height: 84px; background: #fff; border: 1px solid var(--line); border-radius: 3px; padding: 9px 8px; }
.thumb-doc i { display: block; height: 4px; background: var(--stone-200); border-radius: 2px; margin: 0 0 5px; }
.thumb-doc i:first-child { background: var(--blue-300); width: 60%; }
.thumb-doc-warn i:first-child { background: var(--danger-strong); opacity: 0.55; }
.thumb-zip { width: 70px; height: 70px; border-radius: 12px; background: repeating-linear-gradient(45deg, var(--blue-200) 0 8px, var(--blue-50) 8px 16px); border: 1px solid var(--blue-200); }

/* upload drop zone */
.drop { border: 1.5px dashed var(--blue-300); border-radius: var(--r); background: var(--blue-50); padding: 22px; text-align: center; color: var(--blue-700); font-size: 13.5px; margin-bottom: 18px; }
.drop b { font-weight: 500; }

/* upload modal */
dialog.modal-wide { max-width: 760px; }
.setall { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 12px 0; padding: 10px 12px; background: var(--stone-50); border: 1px solid var(--line); border-radius: var(--r); font-size: 12.5px; color: var(--muted); }
.setall select { width: auto; border-radius: var(--r-sm); padding: 5px 8px; font-size: 12.5px; }
.uplt table { font-size: 13px; }
.uplt td { padding: 8px 10px; vertical-align: middle; }
.uplt select, .uplt input[type='text'] { width: 100%; border-radius: var(--r-sm); padding: 5px 8px; font-size: 12.5px; }
.uplt .fname { font: 11.5px ui-monospace, Menlo, monospace; color: var(--muted); white-space: nowrap; max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.upl-err { color: var(--danger-strong); font-size: 12px; }

/* share / public link URL row */
.share-url { display: flex; gap: 8px; margin: 10px 0 4px; }
.share-url[hidden] { display: none; }
.share-url input { flex: 1; height: 36px; border: 1px solid var(--line); border-radius: var(--r); padding: 0 10px; font: 12.5px ui-monospace, Menlo, monospace; color: var(--blue-700); background: var(--stone-50); }

/* version history in the asset settings modal */
.version-list { border: 1px solid var(--line); border-radius: var(--r); padding: 8px 12px; background: #fff; }
.version-row { display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; gap: 8px; }
.version-row + .version-row { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 6px; color: var(--muted); }

/* portal product cards */
.pcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(235px, 1fr)); gap: 14px; }
.pcard { background: #fff; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; text-decoration: none; color: var(--ink); display: flex; flex-direction: column; }
.pcard:hover { border-color: var(--blue-300); color: var(--ink); }
.pthumb { height: 120px; background: var(--blue-50); display: flex; align-items: center; justify-content: center; gap: 10px; overflow: hidden; }
.pthumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.pbody { padding: 12px 14px 14px; }
.pbody h3 { margin: 0 0 3px; font-family: var(--serif); font-weight: 500; font-size: 16px; }
