/* ───────────────────────────────────────────────────────────────────
   Anamika's Creations — Business Manager
   Mobile-first (designed at 390px), warm ivory, restrained berry accent.
   ─────────────────────────────────────────────────────────────────── */

:root {
  --bg: #FBF8F3;
  --surface: #FFFFFF;
  --surface-2: #F4EEE6;
  --surface-3: #EDE5DA;
  --text: #211A1D;
  --text-2: #5C5257;
  --text-3: #71656B; /* 4.8:1+ on the page backgrounds (was #85797F, below 4.5:1) */
  --border: #E6DDD2;
  --border-strong: #CFC3B5;
  --field-border: #9C8E7F; /* form field edges: 3:1 against white */
  --brand: #A0215A;
  --brand-hover: #861A4B;
  --brand-ink: #FFFFFF;
  --brand-soft: #F8E7EE;
  --brand-soft-2: #F2D3E0;
  --focus: #A0215A;

  --info: #22577A;   --info-bg: #E5EEF5;
  --warn: #7F5310;   --warn-bg: #FBEFD9;
  --ok: #2C6A3C;     --ok-bg: #E4F1E6;
  --done: #1F5E36;   --done-bg: #D9EDDF;
  --danger: #A2322A; --danger-bg: #FBE5E1;
  --muted: #6D6368;  --muted-bg: #EFEAE5;

  --radius: 14px;
  --radius-sm: 10px;
  --radius-pill: 999px;
  --shadow: 0 1px 2px rgba(33, 26, 29, .05), 0 2px 8px rgba(33, 26, 29, .04);
  --shadow-up: 0 -1px 0 var(--border), 0 -6px 18px rgba(33, 26, 29, .05);
  --tap: 48px;
  --gutter: 16px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --t-fast: 140ms;
  --t: 180ms;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--nav-h) + var(--safe-b) + 8px);
  overflow-x: hidden;
}
body.no-nav { padding-bottom: 0; }
img, svg { max-width: 100%; }
a { color: var(--brand); text-decoration-thickness: 1px; text-underline-offset: 2px; }
h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 1.45rem; font-weight: 700; }
h2 { font-size: 1.05rem; font-weight: 650; }
h3 { font-size: .95rem; font-weight: 650; }
p { margin: 0 0 .75rem; }
.sprite { display: none; }
.i { width: 20px; height: 20px; flex: none; vertical-align: middle; }
.mono { font-family: var(--mono); font-size: max(.88em, 12.5px); letter-spacing: -0.01em; } /* order IDs stay readable inside small text */
.muted { color: var(--text-2); }
.small { font-size: .875rem; }
.tiny { font-size: .78rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.hidden, [hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -9999px; top: 8px; background: var(--text); color: #fff; padding: 8px 12px; border-radius: 8px; z-index: 100; }
.skip-link:focus { left: 8px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
main:focus { outline: none; }

/* ─── Top bar (desktop nav) ─────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 10px var(--gutter);
  padding-top: max(10px, env(safe-area-inset-top));
  background: rgba(251, 248, 243, .92);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-weight: 650; min-width: 0; }
.brand-logo { display: block; height: 42px; width: auto; flex: none; margin: -4px 0; }
.brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .98rem; }
.topnav { display: none; }
.topbar-new { display: none; }

/* ─── Bottom nav (mobile) ───────────────────────────────────────── */
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
  height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: var(--surface);
  box-shadow: var(--shadow-up);
}
.bottomnav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: var(--tap); color: var(--text-3); text-decoration: none; font-size: .72rem; font-weight: 550;
}
.bottomnav a .i { width: 24px; height: 24px; }
.bottomnav a.active { color: var(--brand); }
.bottomnav a.fab {
  justify-self: center; width: 56px; height: 56px; border-radius: 18px; margin-top: -18px;
  background: var(--brand); color: var(--brand-ink); box-shadow: 0 6px 16px rgba(160, 33, 90, .32);
}
.bottomnav a.fab .i { width: 28px; height: 28px; }
.bottomnav a.fab:active { transform: scale(.96); }

/* ─── Page layout ───────────────────────────────────────────────── */
.page { max-width: 760px; margin: 0 auto; padding: 16px var(--gutter) 24px; }
.page-wide { max-width: 1120px; margin: 0 auto; padding: 16px var(--gutter) 24px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 16px; }
.page-head .sub { color: var(--text-2); font-size: .9rem; margin-top: 2px; }
.back-link { display: inline-flex; align-items: center; gap: 2px; color: var(--text-2); text-decoration: none; font-size: .92rem; min-height: 40px; margin: -6px 0 2px -6px; padding-right: 8px; }
.stack > * + * { margin-top: 12px; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 22px 2px 10px; }
.section-title h2 { font-size: 1rem; }
.section-title a { font-size: .9rem; text-decoration: none; font-weight: 550; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-2 > .field + .field { margin-top: 0; } /* side-by-side fields line up */
.cluster { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* ─── Cards ─────────────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card-tight { padding: 12px 14px; }
.card + .card { margin-top: 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.card-soft { background: var(--surface-2); border-color: transparent; box-shadow: none; }
.card-brand { background: var(--brand-soft); border-color: var(--brand-soft-2); box-shadow: none; }
.card-warn { background: var(--warn-bg); border-color: #F0DDB8; box-shadow: none; color: var(--warn); }
.card-danger { background: var(--danger-bg); border-color: #F2C9C2; box-shadow: none; color: var(--danger); }
.divider { height: 1px; background: var(--border); margin: 12px 0; border: 0; }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kpi {
  display: block; text-decoration: none; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow);
  min-height: 88px;
}
.kpi .label { font-size: .8rem; color: var(--text-2); font-weight: 550; display: flex; align-items: center; gap: 6px; }
.kpi .value { font-size: 1.5rem; font-weight: 700; margin-top: 6px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi .hint { font-size: .78rem; color: var(--text-3); margin-top: 2px; }
.kpi.kpi-alert .value { color: var(--danger); }
.kpi.kpi-warn .value { color: var(--warn); }
.kpi.kpi-brand { background: var(--brand-soft); border-color: var(--brand-soft-2); box-shadow: none; }

/* Quick actions */
.quick-actions { display: grid; gap: 8px; }
.qa {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center;
  min-height: 76px; padding: 10px 4px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border);
  color: var(--text); text-decoration: none; font-size: .78rem; font-weight: 550; line-height: 1.15;
}
.qa .i { width: 24px; height: 24px; color: var(--brand); }

/* Big primary action */
.hero-action {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 60px;
  border-radius: var(--radius); background: var(--brand); color: var(--brand-ink); text-decoration: none;
  font-size: 1.1rem; font-weight: 650; box-shadow: 0 6px 18px rgba(160, 33, 90, .22);
}
.hero-action .i { width: 26px; height: 26px; }
.hero-action:active { transform: scale(.99); }

/* List rows */
.list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.list > * + * { border-top: 1px solid var(--border); }
.row-card { display: flex; gap: 12px; padding: 12px 14px; text-decoration: none; color: var(--text); min-height: 64px; align-items: center; }
.row-card:active { background: var(--surface-2); }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { font-size: .84rem; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.row-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; align-items: center; }
.row-side { text-align: right; flex: none; }
.row-side .amount { font-weight: 650; font-variant-numeric: tabular-nums; }
.row-side .due { font-size: .8rem; color: var(--danger); font-weight: 600; margin-top: 2px; }
.row-side .paid { font-size: .8rem; color: var(--ok); font-weight: 600; margin-top: 2px; }
.meta { display: inline-flex; align-items: center; gap: 4px; font-size: .78rem; color: var(--text-2); }
.meta .i { width: 14px; height: 14px; }
.meta-warn { color: var(--warn); font-weight: 600; }
.meta-danger { color: var(--danger); font-weight: 600; }
.empty { text-align: center; color: var(--text-2); padding: 28px 16px; }
.empty .i { width: 32px; height: 32px; color: var(--text-3); margin-bottom: 6px; }

/* Key/value rows */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: .94rem; margin: 0; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kv .total { font-weight: 700; }
.kv .strong { font-weight: 650; }

/* ─── Badges ────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 9px;
  border-radius: var(--radius-pill); font-size: .75rem; font-weight: 650; white-space: nowrap; line-height: 1;
}
.badge .i { width: 13px; height: 13px; }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-done { background: var(--done-bg); color: var(--done); }
.badge-muted { background: var(--muted-bg); color: var(--muted); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-brand { background: var(--brand-soft); color: var(--brand); }
.badge-sync { background: var(--surface-2); color: var(--text-2); font-weight: 550; }
.badge-sync-failed, .badge-sync-conflict { background: var(--danger-bg); color: var(--danger); }
.badge-sync-pending { background: var(--warn-bg); color: var(--warn); }

/* ─── Flash ─────────────────────────────────────────────────────── */
.flash { border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 14px; font-weight: 550; font-size: .94rem; }
.flash-ok { background: var(--ok-bg); color: var(--ok); }
.flash-info { background: var(--info-bg); color: var(--info); }
.flash-error { background: var(--danger-bg); color: var(--danger); }

/* ─── Buttons ───────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 18px; border-radius: 12px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 600; text-decoration: none;
  cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; white-space: nowrap;
}
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; pointer-events: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: var(--brand-hover); }
.btn-soft { background: var(--brand-soft); border-color: transparent; color: var(--brand); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-danger { background: var(--surface); border-color: #E3B6AE; color: var(--danger); }
.btn-block { width: 100%; }
.btn-sm { min-height: 40px; padding: 0 12px; font-size: .88rem; border-radius: 10px; }
.btn-lg { min-height: 56px; font-size: 1.05rem; border-radius: 14px; }
.btn .i { width: 20px; height: 20px; }
.icon-btn { width: 44px; height: 44px; display: inline-grid; place-items: center; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); cursor: pointer; text-decoration: none; }

/* ─── Forms ─────────────────────────────────────────────────────── */
.field { display: block; }
.field + .field, .field + .grid-2, .grid-2 + .field, .grid-2 + .grid-2 { margin-top: 14px; }
.label { display: block; font-size: .88rem; font-weight: 600; margin: 0 0 6px 2px; color: var(--text); }
.label .opt { color: var(--text-3); font-weight: 500; }
.help { font-size: .8rem; color: var(--text-3); margin: 5px 2px 0; }
.input, .select, .textarea {
  display: block; width: 100%; min-height: var(--tap); padding: 10px 14px;
  border: 1px solid var(--field-border); border-radius: 12px; background: var(--surface); color: var(--text);
  font: inherit; font-size: 16px; /* prevents iOS zoom */
  appearance: none; -webkit-appearance: none;
}
.textarea { min-height: 84px; resize: vertical; }
.select {
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='%235C5257' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft-2); }
.input-lg { min-height: 58px; font-size: 1.25rem; font-weight: 600; letter-spacing: .02em; }
.input-money { position: relative; }
.input-money::before { content: "₹"; position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-2); font-weight: 600; pointer-events: none; }
.input-money .input { padding-left: 30px; font-variant-numeric: tabular-nums; }
.input-prefix { position: relative; }
.input-prefix > span { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-2); font-weight: 600; pointer-events: none; }
.input-prefix .input { padding-left: 32px; }
.has-error .input, .has-error .select, .has-error .textarea { border-color: var(--danger); background: #FFFBFA; }
.error-text { color: var(--danger); font-size: .82rem; font-weight: 600; margin: 5px 2px 0; }
.form-errors { background: var(--danger-bg); color: var(--danger); border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 14px; font-weight: 550; font-size: .92rem; }
.form-actions { display: flex; gap: 10px; margin-top: 18px; }
.form-actions .btn { flex: 1; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: .94rem; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--brand); flex: none; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { padding: 0; }

/* Pill radio groups (one-tap choices) */
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { position: relative; }
.pill input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.pill span {
  display: inline-flex; align-items: center; min-height: 42px; padding: 0 14px; border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong); background: var(--surface); font-size: .92rem; font-weight: 550; color: var(--text);
}
.pill input:checked + span { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.pill input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.pills-scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 calc(-1 * var(--gutter)); padding: 2px var(--gutter); }
.pills-scroll::-webkit-scrollbar { display: none; }
.pills-scroll .pill { flex: none; }

/* Segmented control */
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; background: var(--surface-3); border-radius: 14px; }
.segmented .pill span { width: 100%; justify-content: center; border: 0; background: transparent; border-radius: 10px; min-height: 44px; font-size: .88rem; text-align: center; line-height: 1.15; padding: 4px 6px; }
.segmented .pill input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* Chip buttons (quick fill) */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { min-height: 36px; padding: 0 12px; border-radius: var(--radius-pill); border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font: inherit; font-size: .85rem; font-weight: 550; cursor: pointer; }
.chip:active { background: var(--surface-3); }

/* Search */
.search { position: relative; }
.search .i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
.search .input { padding-left: 44px; }
.filters { margin: 12px 0 14px; }

/* Disclosure */
details.more { border-top: 1px solid var(--border); margin-top: 14px; }
details.more > summary {
  list-style: none; cursor: pointer; min-height: 48px; display: flex; align-items: center; justify-content: space-between;
  font-weight: 600; font-size: .94rem; color: var(--text-2);
}
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::after { content: "+"; font-size: 1.3rem; font-weight: 400; color: var(--text-3); }
details.more[open] > summary::after { content: "–"; }
details.more > .more-body { padding-bottom: 6px; }
details.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
details.panel + details.panel, .card + details.panel, details.panel + .card { margin-top: 12px; }
details.panel > summary { list-style: none; cursor: pointer; padding: 0 16px; min-height: 56px; display: flex; align-items: center; justify-content: space-between; gap: 8px; font-weight: 650; }
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary .i { color: var(--text-3); transition: transform .15s; }
details.panel[open] > summary .i.chev { transform: rotate(90deg); }
details.panel > .panel-body { padding: 0 16px 16px; }

/* ─── Order wizard ──────────────────────────────────────────────── */
.wizard-progress { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 0 0 16px; padding: 0; list-style: none; counter-reset: step; }
.wizard-progress li { font-size: .74rem; font-weight: 600; color: var(--text-3); text-align: center; }
.wizard-progress li::before { content: ""; display: block; height: 4px; border-radius: 4px; background: var(--surface-3); margin-bottom: 6px; }
.wizard-progress li.done::before, .wizard-progress li.current::before { background: var(--brand); }
.wizard-progress li.current { color: var(--brand); }
.js .step { display: none; }
.js .step.current { display: block; }
.step + .step { margin-top: 24px; }
.js .step + .step { margin-top: 0; }
.step-title { font-size: 1.25rem; margin: 0 0 4px; }
.step-sub { color: var(--text-2); margin: 0 0 16px; font-size: .92rem; }
.wizard-bar {
  position: sticky; bottom: calc(var(--nav-h) + var(--safe-b)); z-index: 10;
  display: flex; gap: 10px; padding: 12px var(--gutter); margin: 20px calc(-1 * var(--gutter)) 0;
  background: linear-gradient(to top, var(--bg) 70%, rgba(251, 248, 243, 0));
}
.wizard-bar .btn { flex: 1; }
.wizard-bar .btn-ghost { flex: 0 0 auto; }
.no-js-only { display: block; }
.js .no-js-only { display: none; }
.js-only { display: none; }
.js .js-only { display: block; }

.customer-found { display: flex; align-items: center; gap: 12px; }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 700; flex: none; text-transform: uppercase; }
.lookup-status { min-height: 22px; font-size: .85rem; color: var(--text-2); margin: 6px 2px 0; }

.item-card { position: relative; }
.item-card + .item-card { margin-top: 12px; }
.item-card .item-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.item-card .item-num { font-size: .8rem; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; }
.item-total { display: flex; justify-content: space-between; align-items: baseline; margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--border); font-weight: 650; }
.qty { display: grid; grid-template-columns: 44px 1fr 44px; gap: 6px; }
.qty .input { text-align: center; padding: 10px 4px; }
.qty button { min-height: var(--tap); border-radius: 12px; border: 1px solid var(--border-strong); background: var(--surface-2); font-size: 1.3rem; cursor: pointer; color: var(--text); }
.suggest { position: relative; }
.suggest-list { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 15; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 12px; box-shadow: 0 10px 24px rgba(33, 26, 29, .12); overflow: hidden; margin: 0; padding: 0; list-style: none; }
.suggest-list li { padding: 11px 14px; cursor: pointer; display: flex; justify-content: space-between; gap: 10px; font-size: .94rem; }
.suggest-list li + li { border-top: 1px solid var(--border); }
.suggest-list li[aria-selected="true"], .suggest-list li:hover { background: var(--brand-soft); }
.suggest-list .s-meta { color: var(--text-2); font-size: .82rem; white-space: nowrap; }
.add-item { width: 100%; margin-top: 12px; border-style: dashed; color: var(--brand); background: transparent; }
.running-total { display: flex; justify-content: space-between; align-items: baseline; padding: 14px 4px 0; font-weight: 700; font-size: 1.1rem; }

.review-block + .review-block { margin-top: 12px; }
.review-line { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; font-size: .95rem; }
.review-line + .review-line { border-top: 1px dashed var(--border); }
.review-line .r-name { min-width: 0; }
.review-line .r-sub { font-size: .8rem; color: var(--text-2); }
.review-total { font-size: 1.1rem; font-weight: 700; }

/* Success */
.success { text-align: center; padding: 24px 8px 8px; }
.success-icon { width: 72px; height: 72px; border-radius: 50%; background: var(--ok-bg); color: var(--ok); display: grid; place-items: center; margin: 0 auto 14px; }
.success-icon .i { width: 38px; height: 38px; }
.order-code { display: inline-block; font-family: var(--mono); font-size: 1.5rem; font-weight: 700; background: var(--surface); border: 1px dashed var(--border-strong); border-radius: 12px; padding: 8px 16px; margin: 10px 0 4px; letter-spacing: .02em; }

/* Order detail */
.order-hero h1 { font-size: 1.3rem; }
.order-hero .cluster { margin-top: 8px; }
.contact-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
/* Call · WhatsApp · Instagram · Order fit one row on ~380px+ phones; on narrower ones only
   "Order" wraps to its own full-width row, so the Instagram icon always stays next to WhatsApp. */
.contact-actions .btn { flex: 1 1 auto; white-space: nowrap; padding: 0 8px; gap: 6px; }
.contact-actions .btn-icon { flex: 0 0 auto; width: 40px; padding: 0; }
.contact-actions .btn-icon .i { margin: 0; }
.btn-ig-add { border-style: dashed; color: var(--text-2); }
.money-strip { display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; gap: 4px; }
.money-strip .m-label { font-size: .75rem; color: var(--text-2); font-weight: 550; }
.money-strip .m-value { font-weight: 700; font-size: 1.05rem; margin-top: 2px; font-variant-numeric: tabular-nums; }
.money-strip .m-due { color: var(--danger); }
.money-strip .m-ok { color: var(--ok); }
.item-row { padding: 14px 0; }
.item-row + .item-row { border-top: 1px solid var(--border); }
.item-row .ir-head { display: flex; justify-content: space-between; gap: 10px; }
.item-row .ir-name { font-weight: 650; }
.item-row .ir-sub { font-size: .84rem; color: var(--text-2); margin-top: 2px; }
.assignment { margin-top: 10px; padding: 10px 12px; background: var(--surface-2); border-radius: 12px; font-size: .88rem; }
.inline-form { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.inline-form .select, .inline-form .input { min-height: 42px; padding-top: 6px; padding-bottom: 6px; font-size: 15px; }
.inline-form .btn { min-height: 42px; }
.timeline { list-style: none; margin: 0; padding: 0; font-size: .86rem; }
.timeline li { padding: 8px 0; display: flex; gap: 10px; justify-content: space-between; }
.timeline li + li { border-top: 1px solid var(--border); }
.timeline .t-when { color: var(--text-3); white-space: nowrap; font-size: .78rem; }

/* Tables (reports, admin) */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); border: 1px solid var(--border); }
table { border-collapse: collapse; width: 100%; font-size: .88rem; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); background: var(--surface-2); font-weight: 650; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }
tfoot td { font-weight: 700; background: var(--surface-2); }
.neg { color: var(--danger); }
.pos { color: var(--ok); }

/* Login */
.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 24px var(--gutter); }
.login-card { width: 100%; max-width: 380px; }
.login-card .login-logo { height: 120px; margin: 4px auto 18px; }

/* More menu */
.menu { list-style: none; margin: 0; padding: 0; }
.menu a { display: flex; align-items: center; gap: 14px; padding: 0 16px; min-height: 60px; color: var(--text); text-decoration: none; font-weight: 550; }
.menu a .i:first-child { color: var(--brand); width: 22px; height: 22px; }
.menu a .chev { margin-left: auto; color: var(--text-3); }
.menu li + li { border-top: 1px solid var(--border); }

/* ─── Larger screens ────────────────────────────────────────────── */
@media (min-width: 560px) {
  .kpis { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 960px) {
  body { padding-bottom: 0; }
  .bottomnav { display: none; }
  .topbar { padding: 12px 28px; }
  .topnav { display: flex; gap: 2px; margin-left: 18px; flex: 1; }
  .topnav a { color: var(--text-2); text-decoration: none; padding: 8px 12px; border-radius: 10px; font-weight: 550; font-size: .94rem; }
  .topnav a:hover { background: var(--surface-2); color: var(--text); }
  .topnav a.active { background: var(--brand-soft); color: var(--brand); }
  .topbar-new { display: inline-flex; }
  .page { padding-top: 28px; }
  .page-wide { padding: 28px 28px 40px; }
  .kpis { grid-template-columns: repeat(4, 1fr); }
  .dash-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 24px; align-items: start; } /* minmax: long names shorten with … instead of widening the page */
  .wizard-bar { bottom: 0; }
  h1 { font-size: 1.7rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ─── Progressive enhancement helpers (must stay last) ──────────── */
.js-only-flex, .js-only-inline { display: none; }
.js .js-only-flex { display: flex; }
.js .js-only-inline { display: block; }
.qty { display: block; }
.js .qty { display: grid; }
.js .btn.js-only-flex { display: inline-flex; }
.js .btn.add-item.js-only-flex { display: flex; }

a.pill { text-decoration: none; }
a.pill span.pill-on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.link-plain { color: inherit; text-decoration: none; }
.link-plain:hover { text-decoration: underline; }
.card-focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft-2); }
.cluster + .contact-actions, .card .cluster { margin-top: 8px; }
.form-actions-reverse { flex-direction: row-reverse; }
.js .wizard-progress.js-only { display: grid; }

/* ─── Invoice / customer bill ─────────────────────────────────────── */
.btn-invoice { margin-top: 8px; gap: 8px; }
.btn-invoice .invoice-ref { font-family: var(--mono); font-size: .78rem; color: var(--text-3); font-weight: 500; }
.card-title { font-size: 1rem; margin: 0 0 12px; }
.card-head .card-title { margin: 0; }
.bill-form .card + .card, .bill-form .card + section { margin-top: 12px; }
.bill-rows { display: grid; gap: 12px; }
.bill-row { position: relative; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.bill-nums { display: grid; grid-template-columns: 76px 1fr auto; gap: 10px; align-items: start; margin-top: 10px; }
.bill-nums .field + .field { margin-top: 0; }
.bill-line { text-align: right; min-width: 84px; }
.bill-line-total { display: block; min-height: var(--tap); line-height: var(--tap); font-weight: 700; font-variant-numeric: tabular-nums; }
.bill-remove { margin-top: 6px; }
.bill-rows + [data-add-row] { margin-top: 12px; }
.paid-row { display: flex; gap: 8px; align-items: stretch; }
.paid-row .input-money { flex: 1; }
.js .paid-row .js-only-inline { display: inline-flex; }
.bill-summary .sum-line { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; font-variant-numeric: tabular-nums; color: var(--text-2); }
.bill-summary .sum-total { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 10px; font-size: 1.15rem; font-weight: 700; color: var(--text); }
.bill-summary .sum-total span:last-child { color: var(--brand); }
.bill-summary .sum-balance { font-weight: 700; color: var(--text); }
.bill-summary .sum-status { margin-top: 8px; }
.bill-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.bill-actions .btn { flex: 1 1 160px; }
.js .bill-actions .js-only-inline { display: inline-flex; }
.btn-wa { background: #1F7A4D; border-color: #1F7A4D; color: #fff; }
.btn-wa:hover { background: #18663f; }
.bill-note { text-align: center; margin-top: 10px; }
.wa-steps { margin: 0 0 12px; padding-left: 20px; display: grid; gap: 6px; font-size: .92rem; }
[data-wa-fallback] { margin-top: 14px; }
/* Two columns only where there is room for the longer labels. */
.grid-wide { grid-template-columns: 1fr; }
.grid-wide .field + .field { margin-top: 14px; }
@media (min-width: 560px) { .grid-wide { grid-template-columns: 1fr 1fr; } .grid-wide .field + .field { margin-top: 0; } }

/* ─── Sign-in security ─────────────────────────────────────────────── */
.otp-input { text-align: center; letter-spacing: .4em; font-variant-numeric: tabular-nums; }
.otp-actions { display: flex; justify-content: space-between; gap: 8px; margin-top: 10px; }
.login-help { margin-top: 14px; text-align: center; }
.card-title .i { width: 18px; height: 18px; vertical-align: -3px; color: var(--brand); }
#two-step .card-warn { margin-top: 10px; }

/* ─── Customization & reference image ─────────────────────────────── */
.pre-wrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.customization-text { margin: 0; line-height: 1.55; }
.customization-field { margin-top: 16px; }
.input-file { padding: 10px; font-size: .9rem; }
.ref-help { margin: 0 2px 8px; }
.ref-thumb { display: block; max-width: 160px; max-height: 160px; border-radius: 10px; border: 1px solid var(--border); margin-top: 10px; object-fit: contain; background: var(--surface-2); }
.ref-view { display: block; text-align: center; background: var(--surface-2); border-radius: var(--radius-sm); padding: 8px; }
.ref-image { max-width: 100%; max-height: 320px; border-radius: 8px; object-fit: contain; }
.ref-upload { margin-top: 14px; display: grid; gap: 8px; }
.ref-card .card-warn { margin-top: 10px; }

/* ─── Freelancer earnings & payments ──────────────────────────────── */
.range-pills { margin: 12px 0; }
.fin-note { margin-bottom: 12px; font-size: .9rem; }
.fin-summary { display: grid; gap: 14px; margin-bottom: 14px; }
.fin-group-title { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--brand); margin-bottom: 8px; }
.fin-group-title .opt { text-transform: none; letter-spacing: 0; color: var(--text-3); font-weight: 500; }
.fin-group-life { border-top: 1px solid var(--border); padding-top: 12px; }
.fin-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.fin-metrics .m-label { font-size: .75rem; color: var(--text-2); font-weight: 550; }
.fin-metrics .m-value { font-weight: 700; font-size: 1.05rem; margin-top: 2px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.fin-metrics .m-due { color: var(--danger); }
.fin-metrics .m-ok { color: var(--ok); }
.fin-extra { margin: 10px 0 0; color: var(--text-2); }
.fin-list { display: grid; gap: 8px; }
.fin-row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; padding: 12px 14px; text-decoration: none; color: var(--text); font-variant-numeric: tabular-nums; }
.fin-row .fin-name { grid-column: 1 / -1; display: grid; gap: 2px; }
.fin-row [data-label]::before { content: attr(data-label); display: block; font-size: .72rem; color: var(--text-3); font-weight: 550; }
.fin-row small { display: block; font-size: .72rem; font-weight: 500; }
.fin-row .due { color: var(--danger); font-weight: 700; }
.fin-row .paid { color: var(--ok); font-weight: 700; }
.fin-head { display: none; }
.fin-help { margin-top: 10px; }
.fin-work .card + .card { margin-top: 0; }
.fin-review { margin-top: 8px; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--warn-bg); color: var(--warn); }
.fin-review p { margin: 0 0 4px; }
.fin-history { display: grid; gap: 0; padding: 4px 14px; }
.fin-pay { padding: 10px 0; border-bottom: 1px solid var(--border); }
.fin-pay:last-child { border-bottom: 0; }
.fin-pay .badge { margin-left: 6px; }
.fin-pay.is-reversed > .between strong { text-decoration: line-through; color: var(--text-3); }
.fin-pay .neg { color: var(--danger); }
.fin-reverse summary { font-size: .85rem; }
@media (min-width: 760px) {
  .fin-summary { grid-template-columns: 1fr 1fr; }
  .fin-group-life { border-top: 0; padding-top: 0; border-left: 1px solid var(--border); padding-left: 16px; }
  .fin-row { grid-template-columns: 2fr repeat(4, 1fr); align-items: center; }
  .fin-row .fin-name { grid-column: auto; }
  .fin-row [data-label]::before { display: none; }
  .fin-row > span:not(.fin-name) { text-align: right; }
  .fin-head { display: grid; background: none; box-shadow: none; padding-top: 0; padding-bottom: 0; font-size: .75rem; color: var(--text-2); font-weight: 650; }
  .fin-head span:not(:first-child) { text-align: right; }
  .fin-head span:first-child { text-align: left; }
}

/* ─── Profit Calculator ───────────────────────────────────────────── */
.pc { display: grid; gap: 12px; }
.pc .card + .card { margin-top: 0; }
.pc-inputs { display: grid; gap: 12px; }
.pc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 10px; }
.pc-grid .field + .field { margin-top: 0; }
.pc-field .help { margin-top: 4px; }
.pc-field .error-text:empty { display: none; }
.pc-note-top { margin: -6px 2px 12px; }
.pc-summary { align-self: start; }
.pc-empty { margin: 4px 0 12px; }
.pc-headline { border-radius: var(--radius-sm); padding: 14px 16px; margin-bottom: 12px; background: var(--surface-2); }
.pc-headline-label { font-size: .85rem; font-weight: 650; }
.pc-headline-value { font-size: 2rem; font-weight: 750; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; line-height: 1.15; margin-top: 2px; }
.pc-headline.is-profit { background: var(--ok-bg); color: var(--ok); }
.pc-headline.is-loss { background: var(--danger-bg); color: var(--danger); }
.pc-headline.is-zero { background: var(--surface-2); color: var(--text); }
.pc-lines { margin: 0; display: grid; }
.pc-lines > div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.pc-lines > div:last-child { border-bottom: 0; }
.pc-lines dt { color: var(--text-2); }
.pc-lines dd { margin: 0; font-weight: 650; font-variant-numeric: tabular-nums; text-align: right; overflow-wrap: anywhere; }
.pc-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.pc-actions .btn { flex: 1 1 140px; }
.pc-copy-status { min-height: 1.2em; margin: 8px 2px 0; color: var(--ok); }
.pc-copy-fallback { white-space: pre-wrap; font-size: .82rem; background: var(--surface-2); padding: 10px; border-radius: var(--radius-sm); user-select: all; }
.pc-disclaimer { margin-top: 10px; }
@media (max-width: 380px) { .pc-grid { grid-template-columns: 1fr; } }
@media (min-width: 960px) {
  .pc { grid-template-columns: minmax(0, 1.4fr) minmax(300px, 1fr); align-items: start; }
  .pc-summary { position: sticky; top: 76px; }
}

/* ─── Delivery Deadline Alerts ────────────────────────────────────── */
.nav-badge { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 9px; background: var(--danger); color: #fff; font-size: .72rem; font-weight: 700; line-height: 18px; text-align: center; vertical-align: 1px; }
.nav-badge-list { margin-left: 8px; }
.dl-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.dl-card { text-decoration: none; color: var(--text); border-left: 4px solid var(--border); }
.dl-card .value { margin-top: 0; }
.dl-card .label { margin-top: 2px; color: var(--text); font-weight: 650; }
.dl-card[aria-current] { outline: 2px solid var(--brand); outline-offset: 1px; }
.dl-card-overdue.has-items { border-left-color: var(--danger); background: var(--danger-bg); }
.dl-card-overdue.has-items .value { color: var(--danger); }
.dl-card-today.has-items { border-left-color: var(--warn); background: var(--warn-bg); }
.dl-card-today.has-items .value { color: var(--warn); }
.dl-card-tomorrow.has-items { border-left-color: var(--info); }
.dl-card-upcoming.has-items { border-left-color: var(--border-strong); }
.dl-search { margin-bottom: 10px; }
.dl-filters { margin-bottom: 12px; }
.dl-count { font-weight: 500; opacity: .8; margin-left: 4px; font-size: .85em; }
.dl-result-note { margin: 0 2px 10px; }
.dl-list { display: grid; gap: 8px; }
.dl-row { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; padding: 12px 14px; align-items: center; }
.dl-row > span { min-width: 0; }
.dl-order { display: grid; gap: 2px; grid-column: 1 / 2; min-width: 0; }
.dl-id { font-weight: 700; }
.dl-customer { font-weight: 600; overflow-wrap: anywhere; }
.dl-products { color: var(--text-2); overflow-wrap: anywhere; }
.dl-date { color: var(--text-2); font-size: .9rem; }
.dl-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; }
.dl-actions .btn { flex: 1 1 auto; }
.dl-status { flex: 1 1 100%; }
.dl-status > summary { list-style: none; width: 100%; }
.dl-status > summary::-webkit-details-marker { display: none; }
.dl-status-form { display: flex; gap: 6px; margin-top: 6px; }
.dl-status-form .select { flex: 1; min-height: 38px; }
.dl-flag { display: inline-block; font-weight: 700; font-size: .84rem; padding: 3px 9px; border-radius: 8px; white-space: nowrap; }
.dl-flag-danger { background: var(--danger-bg); color: var(--danger); }
.dl-flag-warn { background: var(--warn-bg); color: var(--warn); }
.dl-flag-info { background: var(--info-bg); color: var(--info); }
.dl-flag-muted { background: var(--surface-2); color: var(--text-2); }
.dl-overdue { border-left: 4px solid var(--danger); }
.dl-today { border-left: 4px solid var(--warn); }
.dl-head { display: none; }
.dl-empty .i { color: var(--ok); }
.dl-help { margin-top: 14px; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; }
@media (min-width: 640px) { .dl-cards { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 960px) {
  .dl-row { grid-template-columns: minmax(0, 1fr) 112px 112px 150px 200px; }
  .dl-order, .dl-actions { grid-column: auto; }
  .dl-actions .btn, .dl-status, .dl-status > summary { width: 100%; }
  .dl-mobile-label { display: none; }
  .dl-head { display: grid; background: none; padding-top: 0; padding-bottom: 0; font-size: .75rem; color: var(--text-2); font-weight: 650; }
  .dl-actions { flex-direction: column; align-items: stretch; }
  .dl-actions .btn { flex: 0 0 auto; }
  .dl-status { flex: 0 0 auto; position: relative; }
  .dl-status[open] .dl-status-form { position: absolute; right: 0; top: calc(100% + 4px); z-index: 5; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 8px; box-shadow: 0 10px 24px rgba(33, 26, 29, .12); width: 280px; }
  .dl-status-form .select { flex: 1 1 auto; min-width: 0; }
  .dl-actions .dl-status-form .btn { width: auto; flex: none; }
}
/* Top menu: every item stays on one line and the bar never overflows. */
@media (min-width: 960px) {
  .topnav a { white-space: nowrap; display: inline-flex; align-items: center; }
}
/* The same items at every desktop width (less-used pages are on More); narrower bars hide the brand name. */
@media (min-width: 960px) and (max-width: 1199px) {
  .brand-name { display: none; } /* the logo stays */
  .topnav { gap: 0; margin-left: 12px; }
  .topnav a { padding: 8px 10px; }
}

/* ─── Daily Work Checklist ────────────────────────────────────────── */
.tk-card-today.has-items { border-left-color: var(--warn); }
.tk-card-done.has-items { border-left-color: var(--ok); }
.tk-card-done.has-items .value { color: var(--ok); }
.tk-card-overdue.has-items { border-left-color: var(--danger); background: var(--danger-bg); }
.tk-card-overdue.has-items .value { color: var(--danger); }
.tk-card-upcoming.has-items { border-left-color: var(--info); }
.tk-overdue-note { display: block; margin-bottom: 12px; text-decoration: none; }
.tk-add { margin-bottom: 12px; padding: 0; overflow: hidden; }
.tk-add > summary { list-style: none; display: flex; width: 100%; border-radius: 0; }
.tk-add > summary::-webkit-details-marker { display: none; }
.tk-add[open] > summary { margin-bottom: 4px; }
.tk-add .form-errors { margin: 12px 16px 0; }
.tk-form { padding: 12px 16px 16px; }
.tk-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.tk-divider { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); margin: 10px 2px 0; }
.tk-item { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px; align-items: start; padding: 12px 14px; }
.tk-item.tk-overdue { border-left: 4px solid var(--danger); }
.tk-item.tk-today { border-left: 4px solid var(--warn); }
.tk-check-form { grid-row: span 2; }
.tk-check { width: 34px; height: 34px; border-radius: 9px; border: 2px solid var(--border-strong); background: var(--surface); display: grid; place-items: center; cursor: pointer; padding: 0; color: transparent; }
.tk-check:hover { border-color: var(--brand); color: var(--text-3); }
.tk-check:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.tk-check.is-done { background: var(--ok); border-color: var(--ok); color: #fff; }
.tk-check .i { width: 20px; height: 20px; }
.tk-body { min-width: 0; }
.tk-title { font-weight: 650; overflow-wrap: anywhere; }
.tk-completed .tk-title { text-decoration: line-through; color: var(--text-2); font-weight: 550; }
.tk-notes { color: var(--text-2); white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.tk-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 6px; }
.tk-actions { grid-column: 2; display: flex; gap: 6px; justify-content: flex-end; }
.tk-actions form { margin: 0; }
.tk-delete { color: var(--danger); }
@media (min-width: 760px) {
  .tk-item { grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; }
  .tk-check-form { grid-row: auto; }
  .tk-actions { grid-column: auto; }
}

/* ─── Raw Material Stock Tracker ──────────────────────────────────── */
.rm-card-total { border-left-color: var(--brand); }
.rm-card-in.has-items { border-left-color: var(--ok); }
.rm-card-low.has-items { border-left-color: var(--warn); background: var(--warn-bg); }
.rm-card-low.has-items .value { color: var(--warn); }
.rm-card-out.has-items { border-left-color: var(--danger); background: var(--danger-bg); }
.rm-card-out.has-items .value { color: var(--danger); }
.rm-table { width: 100%; border-collapse: collapse; }
.rm-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.rm-table tbody { display: grid; gap: 8px; }
.rm-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); border-left: 4px solid var(--border); }
.rm-row.rm-st-low { border-left-color: var(--warn); }
.rm-row.rm-st-out { border-left-color: var(--danger); }
.rm-row.rm-st-archived { opacity: .85; }
.rm-row td { display: block; padding: 0; border: 0; min-width: 0; }
.rm-name { grid-column: 1; font-weight: 650; overflow-wrap: anywhere; }
.rm-name a { color: var(--text); text-decoration: none; }
.rm-name a:hover { text-decoration: underline; }
.rm-notes { font-weight: 400; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.rm-status { grid-column: 2; grid-row: 1; justify-self: end; }
.rm-row td.rm-qty, .rm-row td.rm-min { text-align: left; font-variant-numeric: tabular-nums; }
.rm-qty { grid-column: 1; font-size: 1.05rem; }
.rm-row td.rm-min { grid-column: 2; color: var(--text-2); text-align: right; align-self: end; }
.rm-k { display: block; font-size: .74rem; color: var(--text-3); font-weight: 550; }
.rm-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.rm-actions .btn { flex: 1 1 auto; }
.rm-in { color: var(--ok); }
.rm-out { color: var(--danger); }
.btn-primary.rm-in { color: var(--brand-ink); }
.rm-now { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-bottom: 12px; }
.rm-now > .small:first-child { flex: 1 1 100%; }
.rm-now-qty { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.rm-detail-notes { flex: 1 1 100%; margin: 4px 0 0; color: var(--text-2); white-space: pre-wrap; overflow-wrap: anywhere; }
.rm-title { overflow-wrap: anywhere; }
.rm-detail-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.rm-detail-actions .btn { min-height: 48px; font-size: 1rem; }
.rm-detail-more { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.rm-detail-more form { margin: 0; }
.rm-archived-note { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.rm-archived-note p { margin: 0; }
.rm-qty-input { font-size: 1.15rem; }
/* Table only where all columns and the action buttons fit; cards below that (phones and tablets). */
@media (min-width: 1024px) {
  .rm-table-wrap { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow-x: auto; }
  .rm-table thead { position: static; width: auto; height: auto; clip: auto; display: table-header-group; }
  .rm-table tbody { display: table-row-group; }
  .rm-table th { text-align: left; font-size: .8rem; font-weight: 650; color: var(--text-2); padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
  .rm-table th.num { text-align: right; }
  .rm-row { display: table-row; border: 0; border-radius: 0; box-shadow: none; padding: 0; }
  .rm-row td { display: table-cell; padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
  .rm-row:last-child td { border-bottom: 0; }
  .rm-row.rm-st-low td:first-child { box-shadow: inset 4px 0 0 var(--warn); }
  .rm-row.rm-st-out td:first-child { box-shadow: inset 4px 0 0 var(--danger); }
  .rm-row td.rm-qty, .rm-row td.rm-min { text-align: right; white-space: nowrap; }
  .rm-k { display: none; }
  .rm-status { white-space: nowrap; }
  .rm-actions { display: table-cell; margin: 0; white-space: nowrap; text-align: right; }
  .rm-actions .btn { flex: none; }
}
@media (min-width: 760px) { .rm-detail-actions { max-width: 420px; } }

/* ─── Product presets: delete ─────────────────────────────────────── */
.preset-row { display: flex; align-items: center; }
.preset-row > .row-card { flex: 1; min-width: 0; }
.preset-delete { margin: 0; padding-right: 8px; flex: none; }
.preset-delete .btn { color: var(--danger); }
.preset-delete-label { display: none; }
.preset-delete-page { margin-top: 12px; text-align: center; }
.preset-delete-btn { color: var(--danger); }
@media (min-width: 640px) { .preset-delete-label { display: inline; } }

/* ─── Ideas ─── */
.idea-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.idea-item { padding: 12px 14px; display: grid; gap: 4px; }
.idea-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 10px; }
.idea-cat { text-decoration: none; max-width: 100%; overflow-wrap: anywhere; }
.idea-title { font-weight: 650; overflow-wrap: anywhere; }
.idea-desc { color: var(--text-2); white-space: pre-wrap; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.idea-actions { display: flex; gap: 6px; justify-content: flex-end; }
.idea-actions form { margin: 0; }

/* ─── Freelancer Work Brief ─── */
.wb-btn { margin-top: 8px; }
.wb-blocked { margin: 6px 0 0; }
.wb-link { color: var(--brand); font-weight: 600; text-decoration: none; }
.wb-link:hover { text-decoration: underline; }
.wb-summary, .wb-form .card { margin-bottom: 12px; }
.wb-h { font-size: 1rem; margin: 0 0 10px; }
.wb-dl { display: grid; grid-template-columns: 1fr; gap: 8px; margin: 0; }
.wb-dl > div { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.wb-dl > div:last-child { border-bottom: 0; padding-bottom: 0; }
.wb-dl dt { color: var(--text-2); font-size: .88rem; }
.wb-dl dd { margin: 0; text-align: right; font-weight: 600; overflow-wrap: anywhere; min-width: 0; }
.wb-textarea { min-height: 180px; }
.wb-warn { color: var(--warn); }
.wb-warn .i { width: 15px; height: 15px; vertical-align: -2px; }
.wb-check { margin-top: 10px; font-weight: 600; }
.wb-actions { display: grid; grid-template-columns: 1fr; gap: 8px; }
.js .wb-actions .js-only-inline { display: inline-flex; }
.wb-privacy { margin-top: 10px; }
@media (min-width: 640px) {
  .wb-dl { grid-template-columns: 1fr 1fr; column-gap: 24px; }
  .wb-actions { grid-template-columns: repeat(3, 1fr); }
}
.wb-dl.wb-pay { grid-template-columns: 1fr; max-width: 460px; }

/* ─── Reference images: several per order ─── */
.ref-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.ref-tile { display: grid; gap: 4px; min-width: 0; }
.ref-tile-bar { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.ref-tile-bar form { margin: 0; }
.ref-remove { color: var(--danger); }
.ref-delete-all { margin-top: 10px; }
.ref-previews { display: flex; flex-wrap: wrap; gap: 8px; }
.ref-previews .ref-thumb { margin-top: 0; max-width: 110px; max-height: 110px; }
.ref-previews:empty { display: none; }
@media (min-width: 760px) { .ref-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.ref-tile .ref-view { aspect-ratio: 1 / 1; display: flex; align-items: center; justify-content: center; padding: 6px; }
.ref-tile .ref-image { max-height: 100%; max-width: 100%; width: auto; height: auto; }
.ref-tile-bar > span { white-space: nowrap; }
.ref-tile-bar .btn { padding-left: 8px; padding-right: 8px; }

/* ─── Raw materials: vendor contacts ─── */
.vendor-section { border-top: 1px solid var(--border); padding-top: 14px; display: grid; gap: 10px; }
.vendor-h { font-size: 1rem; margin: 0; }
.vendor-section > .help { margin: 0; }
.vendor-rows { display: grid; gap: 10px; }
.vendor-row { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px 2px; margin: 0; min-width: 0; background: var(--surface-2); }
.vendor-row-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.vendor-legend { font-weight: 650; font-size: .92rem; }
.vendor-remove { color: var(--danger); }
.vendor-add[disabled] { opacity: .6; cursor: not-allowed; }
.vendor-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.vendor-card { padding: 12px 14px; display: grid; gap: 4px; }
.vendor-name { font-weight: 650; overflow-wrap: anywhere; }
.vendor-details { display: flex; flex-wrap: wrap; gap: 4px 14px; overflow-wrap: anywhere; }
.vendor-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.vendor-actions .btn { min-height: 40px; }
.vendor-empty { margin: 0; }
@media (min-width: 760px) { .vendor-list { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.vendor-row .grid-2 { grid-template-columns: 1fr; gap: 0; }
@media (min-width: 640px) { .vendor-row .grid-2 { grid-template-columns: 1fr 1fr; gap: 0 12px; } }
.vendor-list > .vendor-card { margin: 0; }
.rm-delete { color: var(--danger); }

/* ─── Orders: review follow-up tick ─── */
.order-rf-row > .rf { padding: 0 14px 10px; }
.rf { display: flex; flex-wrap: wrap; align-items: center; gap: 0 10px; font-size: .9rem; color: var(--text-2); }
.order-hero .rf { margin-top: 10px; }
.rf-form { margin: 0; }
.rf-btn { display: inline-flex; align-items: center; gap: 10px; min-height: 40px; padding: 4px 10px 4px 4px; margin-left: -4px; border: 0; border-radius: 10px; background: transparent; color: var(--text); font: inherit; font-weight: 600; cursor: pointer; }
.rf-btn:hover { background: var(--surface-2); }
.rf-btn:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.rf-box { width: 26px; height: 26px; flex: none; border-radius: 7px; border: 2px solid var(--border-strong); background: var(--surface); display: grid; place-items: center; color: transparent; }
.rf-box .i { width: 17px; height: 17px; }
.rf-box.is-done { background: var(--ok); border-color: var(--ok); color: #fff; }
.rf-hint { flex-basis: 100%; margin: 0 0 2px; padding-left: 36px; font-size: .84rem; line-height: 1.35; color: var(--text-2); overflow-wrap: anywhere; }
.rf-done .rf-text { color: var(--ok); }

/* ─── Customer Follow-ups (leads) ─── */
.kpis.lead-kpis { grid-template-columns: 1fr 1fr; margin-bottom: 12px; }
.lead-kpi { min-height: 0; }
.lead-kpi.is-on { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.lead-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.lead-dot-unreached { background: var(--warn); }
.lead-dot-reached { background: var(--ok); }
.lead-contact-help { margin: 4px 2px 0; }
.lead-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.lead-list > .lead-card { margin: 0; }
.lead-card { padding: 12px 14px; display: grid; gap: 6px; min-width: 0; }
.lead-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.lead-name { font-weight: 650; overflow-wrap: anywhere; min-width: 0; }
.lead-status { flex: none; }
.lead-details { margin: 0; display: flex; flex-wrap: wrap; gap: 2px 16px; color: var(--text-2); }
.lead-details > div { display: flex; gap: 6px; min-width: 0; }
.lead-details dt { color: var(--text-3); }
.lead-details dd { margin: 0; overflow-wrap: anywhere; color: var(--text); font-variant-numeric: tabular-nums; }
.lead-notes { color: var(--text-2); white-space: pre-wrap; overflow-wrap: anywhere; background: var(--surface-2); border-radius: var(--radius-sm); padding: 8px 10px; }
.lead-contact { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.lead-contact .btn { flex: 1 1 0; min-width: max-content; min-height: 44px; padding: 0 10px; gap: 6px; }
.lead-manage { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px; border-top: 1px solid var(--border); padding-top: 8px; margin-top: 2px; }
.lead-manage form { margin: 0; }
.lead-manage .btn { min-height: 40px; }
.lead-edit-del { display: flex; align-items: center; gap: 2px; margin-left: auto; }
.lead-edit-del .btn { padding: 0 10px; }
.lead-empty .i { color: var(--text-3); }
@media (min-width: 900px) { .lead-list { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; } }

/* ═══ Refinement layer: interaction, consistency, small-screen fixes ═══ */

/* Smooth, quick feedback (120–180 ms). Reduced-motion users get none (see the rule above). */
.btn, .chip, .pill span, .icon-btn, .qa, a.kpi, .row-card, .menu a, .topnav a, .bottomnav a, .rf-btn, .rf-box, .tk-check,
.input, .select, .textarea, details.panel > summary, details.more > summary, .back-link {
  transition: background-color var(--t-fast) ease, border-color var(--t-fast) ease, color var(--t-fast) ease,
    box-shadow var(--t-fast) ease, transform var(--t-fast) var(--ease), opacity var(--t-fast) ease;
}
.btn:active, .qa:active, a.kpi:active, .icon-btn:active, .chip:active { transform: scale(.98); }
@media (hover: hover) {
  .btn:hover { background-color: var(--surface-2); }
  .btn-primary:hover { background-color: var(--brand-hover); border-color: var(--brand-hover); }
  .btn-soft:hover { background-color: var(--brand-soft-2); }
  .btn-ghost:hover { background-color: var(--surface-2); color: var(--text); }
  .btn-danger:hover { background-color: var(--danger-bg); }
  .btn-wa:hover { background-color: #18663f; }
  .icon-btn:hover, .qa:hover { border-color: var(--border-strong); background-color: var(--surface-2); }
  a.kpi:hover { border-color: var(--border-strong); }
  .row-card:hover, .menu a:hover, details.panel > summary:hover { background-color: var(--surface-2); }
  .back-link:hover { color: var(--text); }
  .pill span:hover { border-color: var(--brand); }
}
/* Sections that open (Add forms, panels, "Record a payment"…) fade in instead of jumping. */
@keyframes bm-reveal { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
details[open] > :not(summary) { animation: bm-reveal var(--t) var(--ease); }
.flash { animation: bm-reveal var(--t) var(--ease); }

/* Larger tap areas for small inline links, without moving anything on screen. */
.section-title a { display: inline-flex; align-items: center; min-height: 44px; margin: -12px -6px; padding: 0 6px; border-radius: 8px; }
a.small, .row-sub a, .meta a, .dl-id, .rm-name a, td > a, .vendor-section a { padding-block: 6px; }
.icon-btn { flex: none; }

/* Freelancer profile header: the edit button keeps its size; long details wrap. */
.profile-head { align-items: flex-start; }
.profile-head .customer-found { flex: 1; min-width: 0; }
.profile-head h1 { overflow-wrap: anywhere; }
.profile-head .row-sub { white-space: normal; overflow-wrap: anywhere; }

/* Production cards: names wrap (2 lines) instead of being cut to a few letters; badges move under when tight. */
.prod-head { flex-wrap: wrap; align-items: flex-start; gap: 6px 10px; }
.prod-head .row-main { flex: 1 1 200px; }
.prod-head .row-title { white-space: normal; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.prod-head .row-sub { white-space: normal; overflow-wrap: anywhere; }
.prod-badges { flex: none; gap: 6px; }

/* New order, step 1: the same spacing between every field. */
.step > [data-new-customer] + .field, .step > .field + [data-new-customer] { margin-top: 14px; }

/* Wide tables (Reports): the first column stays visible while scrolling sideways; edge shadows hint there is more. */
.table-sticky th:first-child, .table-sticky td:first-child { position: sticky; left: 0; z-index: 1; background: var(--surface); box-shadow: 1px 0 0 var(--border); }
.table-sticky thead th:first-child, .table-sticky tfoot td:first-child { background: var(--surface-2); }
.table-wrap {
  background:
    linear-gradient(to right, var(--surface) 30%, rgba(255, 255, 255, 0)) left / 40px 100% no-repeat local,
    linear-gradient(to left, var(--surface) 30%, rgba(255, 255, 255, 0)) right / 40px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, rgba(33, 26, 29, .14), transparent) left / 12px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, rgba(33, 26, 29, .14), transparent) right / 12px 100% no-repeat scroll,
    var(--surface);
}

/* File pickers styled like the app's buttons (the native control stays, so it works everywhere). */
.input-file { cursor: pointer; color: var(--text-2); }
.input-file::file-selector-button {
  font: inherit; font-weight: 600; font-size: .9rem; margin-right: 12px; padding: 8px 14px; min-height: 40px;
  border: 1px solid transparent; border-radius: 10px; background: var(--brand-soft); color: var(--brand); cursor: pointer;
  transition: background-color var(--t-fast) ease;
}
.input-file:hover::file-selector-button { background: var(--brand-soft-2); }

/* Phones: while typing in a field the bottom bar slides away (more room above the keyboard) and comes
   back as soon as the field loses focus. Pure CSS: there is no state that could leave it hidden. */
@media (max-width: 959px) and (pointer: coarse) {
  /* Both move with the same short slide, so a tap that ends typing (e.g. on "Next") still lands:
     the bar is where it was at the moment of the tap, then glides to its place. */
  .bottomnav { transition: transform var(--t) var(--ease); }
  .wizard-bar { transition: bottom var(--t) var(--ease); }
  body:has(:is(input:not([type=checkbox], [type=radio], [type=file], [type=submit], [type=button], [type=hidden]), textarea):focus) .bottomnav { transform: translateY(calc(100% + 24px)); }
  body:has(:is(input:not([type=checkbox], [type=radio], [type=file], [type=submit], [type=button], [type=hidden]), textarea):focus) .wizard-bar { bottom: 0; }
}

/* "← More" links that are only needed on phones (the page is in the desktop top bar). */
@media (min-width: 960px) { .phone-only { display: none !important; } }

/* Sync page: waiting jobs inside a panel; menu labels. */
.list-flat { border: 0; border-top: 1px solid var(--border); border-radius: 0; box-shadow: none; }
.panel-more { padding-top: 12px; }
.menu-label { min-width: 0; overflow-wrap: anywhere; }

/* Dashboard: on desktop the top bar already has "New order", so the large button is phone-only. */
@media (min-width: 960px) { .hero-action { display: none; } }
/* Rows that cut long text with "…" clip their content: give links inside them room for the larger tap area. */
.row-sub:has(a) { padding-block: 6px; margin: -5px 0 -6px; }
/* Quick actions share the width equally, whether 3 or 4 are shown (depends on the account). */
.quick-actions { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); }
/* The top bar's "New order" button is desktop-only (phones have the + button in the bottom bar).
   Needs the extra class: .btn (declared later than .topbar-new) would otherwise show it. */
.topbar .topbar-new { display: none; }
@media (min-width: 960px) { .topbar .topbar-new { display: inline-flex; } }
/* Paired buttons that each sit in their own form share the row equally. */
.form-actions > form { flex: 1; min-width: 0; }
/* More small links with a larger tap area (visual layout unchanged). */
a.mono, a.meta, .panel-more a { padding-block: 6px; }
a.small { padding-inline: 4px; margin-inline: -4px; }
/* Review follow-up not due yet (7 days after delivery): a faded, inactive box. */
.rf-pending .rf-box { opacity: .5; }
/* Tap areas of at least 44px without changing the look: the invisible ring around the control counts too. */
.tk-check, .idea-cat { position: relative; }
.tk-check::after { content: ""; position: absolute; inset: -8px; }      /* 34px box (2px border) → 46px tap area */
.idea-cat::after { content: ""; position: absolute; inset: -10px -4px; } /* 24px chip → 44px tap area */
.brand { padding-block: 5px; margin-block: -5px; }

/* ─── Notifications ─── */
.nt-toolbar { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px 8px; margin: -6px 0 10px; }
.nt-toolbar form { margin: 0; }
.nt-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.nt-list > .nt-item { margin: 0; }
.nt-item { padding: 0; display: flex; align-items: center; gap: 4px; overflow: hidden; }
.nt-item.is-unread { border-left: 4px solid var(--brand); }
.nt-link { flex: 1; min-width: 0; display: grid; gap: 2px; padding: 12px 14px; color: var(--text); text-decoration: none; }
.nt-when { margin-top: 2px; }
.nt-title { font-weight: 650; }
.is-unread .nt-title::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); margin-right: 6px; vertical-align: 1px; }
.nt-body { color: var(--text-2); overflow-wrap: anywhere; }
.nt-row-actions { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; padding: 6px 6px 6px 0; }
.nt-row-actions form, .nt-read { margin: 0; }
.nt-delete { border-color: transparent; background: transparent; color: var(--text-2); }
@media (hover: hover) { .nt-delete:hover { color: var(--danger); background: var(--danger-bg); border-color: transparent; } }
.nt-confirm-text { font-weight: 600; }
@media (hover: hover) { .nt-link:hover { background: var(--surface-2); } }
.nt-group { padding: 6px 16px 10px; }
.nt-legend { float: left; width: 100%; font-weight: 650; padding: 12px 0 4px; } /* floated: the title sits inside the card, not on its border */
.nt-legend + * { clear: both; }
.nt-main { min-height: 48px; }
.nt-device .nt-status { margin: 0 0 8px; font-weight: 600; }
.nt-device .help { margin: 0 0 8px; }
.nt-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.nt-actions .btn { flex: 1 1 180px; }
.nt-device-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px 6px 16px; min-height: 56px; }
.nt-device-row form { margin: 0; }
.nt-device-name { min-width: 0; overflow-wrap: anywhere; }

/* ═══ Phase 1 mobile refinements ═══ */

/* Narrow phones (under 380px): Category and Quantity (and Freelancer / fee) stack, so the quantity
   box between − and + keeps room for the number. */
@media (max-width: 379px) {
  .item-card .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .item-card .grid-2 > .field + .field { margin-top: 14px; }
}

/* Lists: long customer / product names use up to two lines instead of being cut after a few words. */
.row-card .row-title { white-space: normal; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Touch screens: controls reach the 44px touch-target goal. Mouse/trackpad layouts are unchanged. */
@media (pointer: coarse) {
  .btn-sm, .back-link, .chip, .pill span, .lead-manage .btn, .vendor-actions .btn, .rf-btn,
  .inline-form .select, .inline-form .input, .inline-form .btn, .dl-status-form .select { min-height: 44px; }
  .section-title a { min-width: 44px; justify-content: center; }
  .assignment .wb-btn { margin-top: 10px; } /* clear of the link above it */
  .row-sub:has(a), .row-main > .row-title:has(a) { white-space: normal; overflow: visible; } /* rows holding a link wrap instead of clipping the link's tap area */
  th, td { padding-top: 12px; padding-bottom: 12px; } /* table rows (Reports) at least 44px apart */
  /* Small text links get an invisible larger tap area; the text itself does not move. */
  a.small, a.mono, a.meta, a.link-plain, .row-sub a, .meta a, .rm-name a, td > a, .panel-more a { position: relative; }
  a.small::after, a.mono::after, a.meta::after, a.link-plain::after, .row-sub a::after, .meta a::after, .rm-name a::after, td > a::after, .panel-more a::after {
    content: ""; position: absolute; inset: -8px -6px;
  }
  a.small::after { inset: -6px; } /* already has 6px padding */
}

/* Tap feedback: the app's own pressed states replace the grey flash phones draw over tapped links.
   (Long-press menus, link previews and accessibility features are left as they are.) */
a, button, summary, label, .pill { -webkit-tap-highlight-color: transparent; }
.menu a:active, .nt-link:active, details.panel > summary:active, details.more > summary:active, .row-card:active { background-color: var(--surface-2); }
.bottomnav a:not(.fab):active { color: var(--brand); }
.bottomnav a.fab:active { background: var(--brand-hover); }
.pill:active span { border-color: var(--brand); }
.back-link:active, .section-title a:active, a.small:active, a.mono:active, .meta a:active { opacity: .7; }
@media (pointer: coarse) {
  .contact-actions .btn-icon { width: 44px; }
  .prod-head .row-sub { overflow: visible; } /* wraps anyway; lets the order link's tap area extend */
}

/* iPhone landscape: the page is drawn edge to edge (viewport-fit=cover), so side padding grows to clear
   the notch / Dynamic Island and rounded corners. In portrait the insets are 0 and nothing changes. */
:root { --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px); }
.topbar, .page, .page-wide { padding-left: max(var(--gutter), var(--safe-l)); padding-right: max(var(--gutter), var(--safe-r)); }
.bottomnav { padding-left: var(--safe-l); padding-right: var(--safe-r); }
.wizard-bar {
  margin-left: calc(-1 * max(var(--gutter), var(--safe-l))); margin-right: calc(-1 * max(var(--gutter), var(--safe-r)));
  padding-left: max(var(--gutter), var(--safe-l)); padding-right: max(var(--gutter), var(--safe-r));
}
@media (min-width: 960px) {
  .topbar, .page-wide { padding-left: max(28px, var(--safe-l)); padding-right: max(28px, var(--safe-r)); }
}

/* Top-bar notification bell (only when notifications are switched on). On phones it sits at the right
   of the header; on desktop between the menu and "New order". */
.topbar-bell { position: relative; margin: -5px 0 -5px auto; border-color: transparent; background: transparent; color: var(--text-2); } /* negative margins: the header keeps its height */
.topbar-bell .i { width: 22px; height: 22px; }
.bell-badge {
  position: absolute; top: 3px; right: 2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--danger); color: #fff; font-size: .72rem; font-weight: 700; line-height: 18px; text-align: center;
  box-shadow: 0 0 0 2px var(--bg);
}
@media (min-width: 960px) { .topbar-bell { margin-left: 0; } }

/* Offline page: the app icon (kept by the service worker, so it shows without a connection). */
.offline-icon { display: block; width: 88px; height: 88px; border-radius: 20px; margin: 4px auto 18px; }

/* Desktop dashboard: the summary tiles (5 or 6, depending on the account) in three columns, so a row
   is never left with two empty slots. */
@media (min-width: 960px) { .dash-grid .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
