/* Stitch by Stitch Gifts — mobile-first UI. Large touch targets (min 48px). */
:root {
  --berry: #8e2c48;
  --berry-d: #6f1f37;
  --berry-l: #f6e7ec;
  --pine: #2f6b4f;
  --gold: #c99a3b;
  --bg: #faf6f1;
  --card: #ffffff;
  --ink: #2b2226;
  --muted: #776b70;
  --line: #e8dfe2;
  --err: #b42318;
  --err-bg: #fdecea;
  --warn-bg: #fff6e0;
  --ok: #1f7a4d;
  --r: 14px;
  --shadow: 0 1px 2px rgba(60, 20, 35, .06), 0 4px 16px rgba(60, 20, 35, .06);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
body.modal-open { overflow: hidden; }
a { color: var(--berry); }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; margin-top: 1rem; color: var(--muted); }
code { background: #f1eaec; padding: 1px 5px; border-radius: 5px; font-size: .9em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.err { color: var(--err); }
.pad { padding: 1rem; }
.sku { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: .02em; }
[hidden] { display: none !important; }

.page { max-width: 980px; margin: 0 auto; padding: 16px 16px calc(24px + var(--safe-b)); }
.card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 16px; margin: 0 0 14px; }
.card.empty { text-align: center; color: var(--muted); }
.page-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.page-head h1 { flex: 1; margin: 0; font-size: 1.3rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.back { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 12px;
  font-size: 2rem; text-decoration: none; color: var(--berry); background: var(--card); box-shadow: var(--shadow); flex: none; }

/* ---------- buttons & inputs */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 48px; padding: 0 18px;
  border-radius: 12px; border: 1.5px solid var(--berry); background: var(--card); color: var(--berry);
  font: 600 1rem/1 inherit; font-family: inherit; text-decoration: none; cursor: pointer; user-select: none;
  touch-action: manipulation; transition: transform .06s, background .15s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--berry); color: #fff; }
.btn.primary:active { background: var(--berry-d); }
.btn.ghost { border-color: var(--line); color: var(--ink); background: var(--card); }
.btn.text { border: 0; background: none; color: var(--berry); padding: 0 10px; }
.btn.danger { color: var(--err); border-color: var(--err); }
.btn.primary.danger { background: var(--err); color: #fff; }
.btn.text.danger { border: 0; }
.btn.small { min-height: 38px; padding: 0 12px; font-size: .9rem; }
.btn.big { min-height: 56px; font-size: 1.05rem; width: 100%; }
.btn.huge { min-height: 64px; font-size: 1.2rem; width: 100%; }
.btn:disabled, .btn.is-busy { opacity: .55; pointer-events: none; }
.btn.is-busy::after { content: ""; width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
.icon-btn { width: 44px; height: 44px; border: 0; border-radius: 12px; background: transparent; font-size: 1.25rem; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; color: var(--ink); text-decoration: none; touch-action: manipulation; }
.row-2 { display: flex; gap: 10px; flex-wrap: wrap; margin: 8px 0; }
.row-2 > * { flex: 1 1 160px; }

.fld { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.fld > span { font-size: .85rem; font-weight: 600; color: var(--muted); }
input, select, textarea {
  font: inherit; font-size: 16px; /* 16px prevents iOS zoom on focus */
  min-height: 48px; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); width: 100%;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--berry); box-shadow: 0 0 0 3px var(--berry-l); }
.big-input { font-size: 1.1rem; min-height: 54px; margin-bottom: 12px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 48px; font-weight: 500; }
.check input { width: 24px; height: 24px; min-height: 0; accent-color: var(--berry); }
.inline { display: flex; gap: 8px; }
.inline select { flex: 0 0 48%; }
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 0 14px; }
.grid-3 { display: grid; grid-template-columns: 1fr; gap: 0 12px; }
@media (min-width: 640px) { .grid-2 { grid-template-columns: 1fr 1fr; } .grid-3 { grid-template-columns: 2fr 1fr 1fr; } }

/* ---------- login */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { width: 100%; max-width: 400px; background: var(--card); padding: 28px 22px; border-radius: 20px; box-shadow: var(--shadow); text-align: center; }
.login-card form { text-align: left; margin-top: 18px; }
.brand-mark { width: 48px; height: 48px; border-radius: 14px; background: var(--berry); color: #fff; display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.5rem; border: 2px dashed rgba(255,255,255,.6); outline: 3px solid var(--berry); flex: none; }
.brand-mark.big { width: 64px; height: 64px; font-size: 2rem; margin-bottom: 10px; }

/* ---------- dashboard */
.dash-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.dash-head > div:not(.brand-mark):not(.brand-logo) { flex: 1; }
.dash-head h1 { margin: 0; font-size: 1.25rem; }
.dash-head p { margin: 0; }
.scan-hero { width: 100%; min-height: 120px; flex-direction: column; gap: 4px; font-size: 2rem; border: 0; color: #fff; border-radius: 20px;
  background: linear-gradient(135deg, var(--berry), #b2405f); box-shadow: 0 8px 24px rgba(142, 44, 72, .3); margin-bottom: 14px; }
.scan-hero span { font-size: 1.5rem; font-weight: 700; }
.scan-hero small { font-size: .85rem; font-weight: 500; opacity: .9; }
.resume { display: flex; flex-direction: column; background: var(--warn-bg); border: 1.5px solid #f0d58f; border-radius: var(--r); padding: 12px 16px;
  margin-bottom: 14px; text-decoration: none; color: var(--ink); }
.resume span { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: #8a6510; font-weight: 700; }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
@media (min-width: 700px) { .tiles { grid-template-columns: repeat(3, 1fr); } }
.tile { position: relative; background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); min-height: 104px; padding: 14px;
  display: flex; flex-direction: column; justify-content: space-between; text-decoration: none; color: var(--ink); }
.tile:active { transform: scale(.98); }
.tile .ti { font-size: 1.8rem; }
.tile b { font-size: 1.02rem; }
.badge { position: absolute; top: 12px; right: 12px; background: var(--berry); color: #fff; border-radius: 99px; min-width: 26px; height: 26px;
  font-size: .85rem; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; padding: 0 8px; }

/* ---------- lists */
.inv-list { list-style: none; padding: 0; margin: 0; }
.inv-list.card { padding: 0 4px; }
.inv-list li { border-bottom: 1px solid var(--line); position: relative; }
.inv-list li:last-child { border-bottom: 0; }
.inv-list a { display: flex; align-items: center; gap: 12px; padding: 14px 12px; min-height: 64px; text-decoration: none; color: var(--ink); }
.inv-list .ir-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.inv-list .ir-main .muted { font-size: .85rem; }
.inv-list .ir-amt { font-weight: 700; white-space: nowrap; }
.inv-list .upd { display: block; padding: 0 12px 10px; margin-top: -8px; }
.filters .row-2 { margin-bottom: 0; }
.result-count { margin: 4px 4px 8px; }

/* ---------- order entry */
.editor-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 8px 0; }
.eh-title { flex: 1; display: flex; flex-direction: column; }
.save-state { font-size: .8rem; color: var(--ok); }
.save-state.dirty, .save-state.saving { color: var(--muted); }
.save-state.error { color: var(--err); }
.lines-head { display: flex; justify-content: space-between; align-items: baseline; }
.lines { list-style: none; margin: 0; padding: 0; }
.line { border-top: 1px solid var(--line); padding: 12px 0; }
.line:first-child { border-top: 0; }
.line.flash { animation: flash 1.4s ease-out; }
@keyframes flash { 0% { background: #fff2b8; } 100% { background: transparent; } }
.l-top { display: flex; gap: 8px; align-items: flex-start; }
.l-name { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.l-name .sku { color: var(--muted); font-size: .9rem; }
.l-bottom { display: flex; align-items: center; gap: 10px; margin-top: 6px; flex-wrap: wrap; }
.l-price { color: var(--muted); font-size: .95rem; }
.l-total { margin-left: auto; font-weight: 700; font-size: 1.05rem; }
.line.below { background: linear-gradient(90deg, var(--warn-bg), transparent); }
.moq-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; padding: 6px 10px; border-radius: 10px; background: var(--warn-bg); color: #7a5300; font-size: .9rem; font-weight: 600; }
.moq-row span { flex: 1 1 140px; }
.moq-row.ok { background: #eef6f1; color: var(--ok); }
.empty-lines { text-align: center; color: var(--muted); padding: 8px 0; }

.stepper { display: inline-flex; align-items: stretch; border: 1.5px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; }
.stepper button { width: 48px; min-height: 48px; border: 0; background: #f7f1f3; font-size: 1.5rem; color: var(--berry); cursor: pointer; touch-action: manipulation; }
.stepper input { width: 70px; border: 0; border-radius: 0; text-align: center; font-weight: 700; font-size: 1.1rem; -moz-appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper.big button { width: 64px; min-height: 60px; font-size: 1.8rem; }
.stepper.big input { width: 100px; font-size: 1.4rem; }

.totals { margin: 0; }
.totals > div { display: flex; justify-content: space-between; padding: 4px 0; }
.totals dt { color: var(--muted); }
.totals dd { margin: 0; font-variant-numeric: tabular-nums; }
.totals .grand-row { border-top: 2px solid var(--ink); margin-top: 6px; padding-top: 8px; font-size: 1.2rem; font-weight: 800; }
.totals .grand-row dt { color: var(--ink); }

.fold summary { list-style: none; display: flex; align-items: baseline; gap: 10px; cursor: pointer; min-height: 32px; flex-wrap: wrap; }
.fold summary::-webkit-details-marker { display: none; }
.fold summary h2 { margin: 0; }
.fold summary::after { content: "▾"; margin-left: auto; color: var(--muted); }
.fold[open] summary::after { content: "▴"; }
.fold summary .muted { font-size: .9rem; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fold-body { margin-top: 12px; }
.linked { font-size: .85rem; margin: 0 0 8px; }

.issue-box { margin: 18px 0; }
.problems { color: #7a5300; background: var(--warn-bg); border-radius: 10px; padding: 10px 10px 10px 30px; margin: 0 0 12px; }
.problems:empty { display: none; }
.bottom-spacer { height: calc(96px + var(--safe-b)); }

.scanbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; gap: 10px; align-items: center;
  padding: 10px 16px calc(10px + var(--safe-b)); background: rgba(255,255,255,.96); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid var(--line); box-shadow: 0 -4px 20px rgba(60,20,35,.08); }
.scanbar-total { display: flex; flex-direction: column; min-width: 92px; }
.scanbar-total span { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.scanbar-total b { font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.scan-manual { flex-direction: column; gap: 0; min-height: 60px; padding: 0 12px; font-size: 1.1rem; }
.scan-manual span { font-size: .7rem; }
.scan-btn { flex: 1; min-height: 64px; font-size: 1.25rem; background: var(--berry); color: #fff; border: 0; border-radius: 16px; box-shadow: 0 4px 14px rgba(142,44,72,.35); }
@media (min-width: 980px) { .scanbar { left: 50%; right: auto; transform: translateX(-50%); width: 980px; border-radius: 18px 18px 0 0; } }

/* ---------- modals */
.modal-wrap { position: fixed; inset: 0; z-index: 100; background: rgba(30, 15, 22, .55); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--card); width: 100%; max-width: 560px; max-height: 92vh; max-height: 92dvh; overflow-y: auto; -webkit-overflow-scrolling: touch;
  border-radius: 20px 20px 0 0; padding: 18px 16px calc(16px + var(--safe-b)); animation: up .2s ease-out; }
@keyframes up { from { transform: translateY(30px); opacity: .6; } }
@media (min-width: 640px) { .modal-wrap { align-items: center; } .modal { border-radius: 20px; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.modal-head h2 { margin: 0; }
.modal-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.modal-actions .row-2 { margin: 0; }
.confirm-msg { font-size: 1.1rem; }

.confirm-card { display: flex; flex-direction: column; gap: 14px; }
@media (min-width: 640px) { .confirm-card { flex-direction: row; } .confirm-photo { flex: 0 0 44%; } }
.confirm-photo img, .confirm-photo .noimg { width: 100%; aspect-ratio: 1; object-fit: contain; background: #f6f2ef; border-radius: 14px; }
.confirm-photo { max-height: 30vh; display: flex; justify-content: center; }
.confirm-photo img { max-height: 30vh; width: auto; max-width: 100%; }
@media (min-width: 640px) { .confirm-photo, .confirm-photo img { max-height: 46vh; } }
.confirm-info { flex: 1; }
.confirm-info h2 { font-size: 1.3rem; }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px 0 12px; }
.facts div { background: #f8f3f5; border-radius: 10px; padding: 8px; }
.facts dt { font-size: .72rem; text-transform: uppercase; color: var(--muted); letter-spacing: .04em; }
.facts dd { margin: 0; font-weight: 700; font-size: 1.05rem; word-break: break-all; }
.qty-label { font-weight: 600; display: block; margin-bottom: 6px; }
.note { background: #eef6f1; color: var(--ok); padding: 8px 10px; border-radius: 10px; font-size: .92rem; }
.moq-warn { background: var(--warn-bg); color: #7a5300; padding: 8px 10px; border-radius: 10px; font-size: .9rem; margin: 10px 0 0; }
.line-preview { margin: 8px 0 0; font-variant-numeric: tabular-nums; }
.alts { margin-top: 10px; }
.alts summary { cursor: pointer; color: var(--berry); font-weight: 600; min-height: 40px; display: flex; align-items: center; }
.noimg { display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 2rem; background: #f6f2ef; border-radius: 10px; color: var(--muted); }
.noimg small { font-size: .8rem; }

.choice-list, .pick-list { list-style: none; padding: 0; margin: 8px 0; display: flex; flex-direction: column; gap: 8px; }
.choice, .pick-list button { width: 100%; display: flex; align-items: center; gap: 12px; padding: 8px; min-height: 64px; border: 1.5px solid var(--line);
  border-radius: 12px; background: #fff; text-align: left; cursor: pointer; font: inherit; color: var(--ink); }
.choice:active, .pick-list button:active { border-color: var(--berry); background: var(--berry-l); }
.choice img, .choice .noimg { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; flex: none; font-size: 1.3rem; }
.c-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.c-main .sku { color: var(--muted); font-size: .9rem; }
.c-side { text-align: right; font-weight: 700; display: flex; flex-direction: column; }
.c-side small { font-weight: 500; color: var(--muted); font-size: .75rem; }
.pick-list button { flex-direction: column; align-items: flex-start; gap: 2px; }
.manual-form { display: flex; gap: 8px; }
.manual-form .big-input { margin: 0; flex: 1; }
.manual-form .btn { width: auto; }

/* ---------- scanner */
.modal-wrap.fullscreen { align-items: stretch; background: #000; }
.modal-wrap.fullscreen .modal { max-width: none; max-height: none; height: 100%; border-radius: 0; padding: 0; background: #111; color: #fff; overflow: hidden; }
.scanner { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.scan-top { display: flex; align-items: center; gap: 8px; padding: calc(8px + env(safe-area-inset-top, 0px)) 10px 8px; }
.seg { flex: 1; display: flex; background: #2a2a2a; border-radius: 12px; padding: 4px; }
.seg button { flex: 1; min-height: 44px; border: 0; border-radius: 9px; background: transparent; color: #ddd; font: 600 .95rem inherit; font-family: inherit; cursor: pointer; }
.seg button.active { background: #fff; color: var(--berry); }
.close-x { color: #fff; font-size: 1.4rem; }
.scan-stage { position: relative; flex: 1; overflow: hidden; background: #000; }
.scan-stage video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.guide { position: absolute; left: 8%; right: 8%; top: 36%; height: 24%; border: 3px solid rgba(255,255,255,.95); border-radius: 14px;
  box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); display: flex; align-items: flex-end; justify-content: center; pointer-events: none; }
.mode-photo .guide { left: 10%; right: 10%; top: 12%; height: 66%; }
.guide-hint { transform: translateY(calc(100% + 10px)); background: rgba(0,0,0,.6); padding: 4px 10px; border-radius: 8px; font-size: .9rem; }
.scan-msg { position: absolute; left: 12px; right: 12px; top: 12px; background: rgba(20,20,20,.88); padding: 12px 14px; border-radius: 12px; z-index: 2; }
.scan-msg.warn { background: #fff6e0; color: #4d3800; }
.scan-result { position: absolute; left: 0; right: 0; bottom: 0; max-height: 100%; overflow-y: auto; background: #fff; color: var(--ink);
  border-radius: 18px 18px 0 0; padding: 16px; z-index: 3; }
.result-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.scan-controls { padding: 12px 12px calc(12px + var(--safe-b)); display: flex; flex-direction: column; align-items: center; gap: 12px; background: #111; }
.shutter { width: 78px; height: 78px; border-radius: 50%; border: 5px solid #fff; background: transparent; padding: 5px; cursor: pointer; touch-action: manipulation; }
.shutter span { display: block; width: 100%; height: 100%; border-radius: 50%; background: #fff; }
.shutter:active span { background: #ddd; }
.shutter:disabled { opacity: .35; }
.scan-alt { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; width: 100%; }
.scan-alt .btn { background: #262626; color: #fff; border-color: #3a3a3a; flex: 1 1 auto; font-size: .95rem; padding: 0 12px; }
.spinner { display: inline-block; width: 18px; height: 18px; border: 2.5px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -3px; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- toasts */
#toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(100px + var(--safe-b)); z-index: 300; display: flex; flex-direction: column; gap: 8px; width: min(92vw, 480px); pointer-events: none; }
.toast { background: #2b2226; color: #fff; padding: 12px 14px; border-radius: 12px; box-shadow: 0 6px 20px rgba(0,0,0,.25); display: flex; gap: 10px; align-items: center; pointer-events: auto; transition: opacity .3s, transform .3s; }
.toast.ok { background: var(--ok); }
.toast.error { background: var(--err); }
.toast.hide { opacity: 0; transform: translateY(10px); }
.toast span { flex: 1; }
.toast button { background: rgba(255,255,255,.2); color: #fff; border: 0; border-radius: 8px; min-height: 36px; padding: 0 10px; font-weight: 700; }

/* ---------- catalog */
.catalog-tools { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.catalog-tools .btn { flex: 1 1 140px; }
.product-grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 640px) { .product-grid { grid-template-columns: 1fr 1fr; } }
.product-grid a { display: flex; gap: 12px; align-items: center; background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 10px; text-decoration: none; color: var(--ink); min-height: 88px; }
.product-grid img, .product-grid .noimg { width: 72px; height: 72px; object-fit: cover; border-radius: 10px; flex: none; }
.product-grid .pg-info { display: flex; flex-direction: column; min-width: 0; font-size: .9rem; }
.product-grid .pg-info b { font-size: 1rem; }
.product-grid .inactive { opacity: .55; }
.photo-grid { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.photo-grid li { position: relative; }
.photo-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; }
.photo-grid .icon-btn { position: absolute; top: 4px; right: 4px; background: rgba(255,255,255,.9); width: 36px; height: 36px; }

.summary-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.chip { display: inline-block; padding: 3px 10px; border-radius: 99px; background: #eee; font-size: .82rem; font-weight: 700; }
.chip.add { background: #e3f4ea; color: var(--ok); }
.chip.upd { background: #e6effc; color: #1f4f9a; }
.chip.bad { background: var(--err-bg); color: var(--err); }
.errors { background: var(--err-bg); border-radius: 10px; padding: 10px 14px; margin-bottom: 12px; color: #7a1a12; }
.warnings { background: var(--warn-bg); border-radius: 10px; padding: 10px 14px; margin-bottom: 12px; }
.errors ul, .warnings ul { margin: 0; padding-left: 18px; }
.errors h3, .warnings h3 { margin-top: 0; }
.table-wrap { overflow-x: auto; margin-bottom: 14px; -webkit-overflow-scrolling: touch; }
.preview-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.preview-table th, .preview-table td { padding: 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.preview-table tr.bad { background: #fff6f5; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; }

/* ---------- invoice document */
.view-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.view-actions .btn { flex: 1 1 auto; }
.draft-banner { background: var(--warn-bg); padding: 10px 14px; border-radius: 10px; color: #7a5300; }
.invoice-doc { background: #fff; box-shadow: var(--shadow); border-radius: 6px; padding: 28px 22px; font-size: 14px; color: #222; position: relative; }
.invoice-doc.is-draft::before { content: "DRAFT"; position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%) rotate(-24deg); font-size: 110px; font-weight: 900; color: rgba(142,44,72,.07); pointer-events: none; }
.doc-head { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; border-bottom: 3px solid var(--berry); padding-bottom: 16px; position: relative; }
.doc-head::after { content: ""; position: absolute; left: 0; right: 0; bottom: -8px; border-bottom: 2px dashed var(--berry); opacity: .45; }
.brand { display: flex; gap: 14px; align-items: flex-start; }
.brand h1 { color: var(--berry); font-size: 1.5rem; margin: 0; font-family: Georgia, "Times New Roman", serif; }
.tagline { margin: 2px 0 6px; color: var(--muted); font-style: italic; }
.biz { margin: 0; font-size: 13px; color: #444; }
.doc-meta h2 { font-size: 1.6rem; letter-spacing: .12em; color: var(--berry); margin: 0 0 6px; text-align: right; }
.doc-meta dl { margin: 0; }
.doc-meta dl div { display: flex; justify-content: space-between; gap: 16px; }
.doc-meta dt { color: var(--muted); }
.doc-meta dd { margin: 0; font-weight: 700; }
.parties { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin: 26px 0 18px; }
.parties h3 { margin: 0 0 4px; text-transform: uppercase; font-size: 12px; letter-spacing: .08em; color: var(--berry); }
.parties p { margin: 0 0 6px; }
.items { width: 100%; border-collapse: collapse; }
.items th { background: var(--berry); color: #fff; text-align: left; padding: 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.items td { padding: 8px; border-bottom: 1px solid #eee; vertical-align: top; }
.items tbody tr:nth-child(even) td { background: #fbf7f8; }
.doc-foot { display: flex; justify-content: space-between; gap: 24px; margin-top: 18px; flex-wrap: wrap; }
.doc-foot .notes { flex: 1 1 240px; }
.doc-foot .notes h3 { margin: 0 0 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--berry); }
.doc-foot .notes p { margin: 0 0 10px; }
.doc-foot .totals { flex: 0 1 300px; }
.thanks { text-align: center; margin-top: 24px; color: var(--berry); font-family: Georgia, serif; font-style: italic; font-size: 1.05rem; }
@media (max-width: 560px) {
  .invoice-doc { padding: 18px 12px; font-size: 13px; }
  .parties { grid-template-columns: 1fr; }
  .doc-meta h2 { text-align: left; }
  .items th:nth-child(4), .items td:nth-child(4) { display: none; }
}

/* ---------- logo */
.brand-logo { height: 56px; min-width: 56px; max-width: 150px; border-radius: 12px; background: #fff; display: inline-flex; align-items: center; justify-content: center;
  flex: none; padding: 4px 6px; box-shadow: 0 0 0 1px var(--line); overflow: hidden; }
.brand-logo img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.brand-logo.big { height: 96px; max-width: 240px; margin-bottom: 10px; }
.brand-logo.doc-logo { width: auto; height: auto; max-width: 180px; max-height: 72px; box-shadow: none; padding: 0; border-radius: 0; background: transparent; }
.brand-logo.doc-logo img { max-height: 72px; }
.logo-previews { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; margin: 10px 0; }
.logo-previews figure { margin: 0; }
.pv { border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: flex; gap: 10px; align-items: center; min-height: 96px; }
.pv small { display: block; color: var(--muted); font-size: .75rem; }
.pv-login { flex-direction: column; text-align: center; background: var(--bg); }
.pv-dash { background: var(--bg); }
.pv-inv { background: #fff; justify-content: space-between; flex-wrap: wrap; }
.pv-inv .brand-logo.doc-logo { max-width: 120px; }
.pv-inv .brand-logo.doc-logo img { max-height: 48px; }
.pv > div:not(.brand-logo):not(.brand-mark) { min-width: 0; flex: 1 1 90px; }
.pv-inv .pv-title { color: var(--berry); font-weight: 800; letter-spacing: .05em; }

/* ---------- banners, chips, misc */
.banner { background: var(--warn-bg); color: #7a5300; border-radius: 12px; padding: 10px 14px; margin: 0 0 12px; font-weight: 600; }
.banner a { color: inherit; }
.banner .btn { margin-left: 8px; }
.chip.ok { background: #e3f4ea; color: var(--ok); }
.chip.likely { background: #e3f4ea; color: var(--ok); }
.chip.suggest { background: var(--warn-bg); color: #7a5300; }
.chip.weak { background: #eee; color: var(--muted); }
.chip.tiny { font-size: .7rem; padding: 1px 7px; margin-top: 3px; }
.row-3 { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.row-3 > * { flex: 1 1 120px; }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.warns { color: #1f4f9a; background: #e6effc; border-radius: 10px; padding: 10px 10px 10px 30px; margin: 0 0 12px; }
.warns:empty { display: none; }
.sugg-head { margin-bottom: 6px; }
.sugg-head p { margin: 4px 0 0; }
.sugg-list .choice { position: relative; }
.sugg-list .rank { position: absolute; left: 4px; top: 4px; background: var(--berry); color: #fff; border-radius: 99px; font-size: .7rem; width: 18px; height: 18px;
  display: inline-flex; align-items: center; justify-content: center; z-index: 1; }
.sugg-list .c-main .chip { align-self: flex-start; }
.skipped ul, .matched ul { max-height: 38vh; overflow: auto; padding-left: 18px; font-size: .9rem; }
.skipped summary, .matched summary { cursor: pointer; margin: 8px 0; }
.share-list { list-style: none; padding: 0; margin: 0 0 6px; }
.share-list li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.share-body .review { margin: 10px 0; }
.share-body .review .facts { display: block; }
.share-body .review .facts > div { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; border-bottom: 1px solid var(--line); background: none; }
.share-body .review .facts dd { text-align: right; word-break: break-word; font-size: .95rem; }
.howto { background: var(--berry-l); border-radius: 10px; padding: 8px 12px; font-size: .92rem; }
table.simple { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.simple th, table.simple td { text-align: left; padding: 7px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.activity { list-style: none; padding: 0; margin: 0; }
.activity li { display: grid; grid-template-columns: auto auto auto 1fr; gap: 4px 10px; padding: 8px 4px; border-bottom: 1px solid var(--line); font-size: .9rem; align-items: baseline; }
.activity .when { color: var(--muted); font-size: .8rem; white-space: nowrap; }
.activity .who { font-weight: 700; }
@media (max-width: 560px) { .activity li { grid-template-columns: 1fr auto; } .activity .what { grid-column: 1 / -1; } }
.months { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 6px; margin: 8px 0; }
.month { border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px; }
.span-2 { grid-column: 1 / -1; }
.admin-tiles { margin-bottom: 14px; }

@media print {
  @page { margin: 14mm; }
  body { background: #fff; }
  .no-print, #toasts, .scanbar { display: none !important; }
  .page { padding: 0; max-width: none; }
  .invoice-doc { box-shadow: none; padding: 0; font-size: 11pt; }
  .items th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .items tbody tr:nth-child(even) td { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .items tr { page-break-inside: avoid; }
  .parties { grid-template-columns: 1fr 1fr !important; }
  .items th:nth-child(4), .items td:nth-child(4) { display: table-cell !important; }
  a { color: inherit; text-decoration: none; }
}
