/* Scarpa Mango online app · Boutique design system.
   Local fonts, flat surfaces and one control scale; no decorative motion. */
:root {
  color-scheme: light;
  --ink: #302821;
  --muted: #766a60;
  --line: #e4dbcf;
  --bg: #f6f3ee;
  --surface: #ffffff;
  --surface-soft: #fbf9f5;
  --accent: #593c2d;
  --accent-hover: #422a20;
  --accent-soft: #eee5d9;
  --cognac: #8b5b3d;
  --focus: #906343;
  --field-border: #a48f78;
  --danger: #9d3f33;
  --success: #435e49;
  --shadow: 0 3px 14px #30282105;
  --control-height: 46px;
  --radius-control: 8px;
  --radius-panel: 12px;
  --radius-modal: 16px;
}
* { box-sizing: border-box; }
html { min-width: 320px; scroll-padding-top: 156px; -webkit-text-size-adjust: 100%; }
body { margin: 0; -webkit-font-smoothing: antialiased; background: var(--bg); color: var(--ink); font: 14px/1.5 -apple-system, BlinkMacSystemFont, system-ui, 'Segoe UI', sans-serif; }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { touch-action: manipulation; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
button, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
a { color: var(--accent); }
::selection { background: #e8d6bf; color: var(--ink); }
[hidden] { display: none !important; }
img { max-width: 100%; }
main, section, .panel, .card, .formfield, .layout > *, .pagegrid > * { min-width: 0; }
.shell { display: block; min-height: 100vh; min-height: 100dvh; }
.shell > main { width: 100%; max-width: 1740px; margin: 0 auto; padding: 28px clamp(20px, 3.5vw, 56px) calc(48px + env(safe-area-inset-bottom)); }

/* Header and navigation */
.appheader { position: sticky; top: 0; z-index: 6; display: grid; grid-template-columns: minmax(220px, 1fr) auto; align-items: center; gap: 10px 24px; padding: calc(14px + env(safe-area-inset-top)) max(clamp(20px, 3.5vw, 56px), env(safe-area-inset-right)) 0 max(clamp(20px, 3.5vw, 56px), env(safe-area-inset-left)); background: var(--surface-soft); border-bottom: 1px solid var(--line); }
.headerbrand { grid-column: 1; grid-row: 1; display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--muted); font-size: 11px; }
.brand-logo { display: block; width: 190px; max-width: 100%; height: auto; object-fit: contain; flex-shrink: 0; background: transparent; filter: none; opacity: 1; }
.headerbrand .brand-logo { width: 178px; height: auto; }
.headerbrand span { margin-left: 7px; padding-left: 14px; border-left: 1px solid var(--line); white-space: nowrap; font-size: 11px; letter-spacing: .02em; }
.appheader .nav { grid-column: 1 / -1; grid-row: 2; display: flex; align-items: center; justify-content: flex-start; gap: 5px; padding: 0 0 10px; min-width: 0; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
.nav button { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 7px; flex: 0 0 auto; min-height: var(--control-height); padding: 10px 15px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: #6d5e51; text-align: center; white-space: nowrap; font-size: 13px; font-weight: 600; }
.nav button:focus-visible, .customer-match:focus-visible { outline-offset: -3px; }
.nav button.active { border-color: #e1d2bf; background: var(--accent-soft); color: var(--accent); }
.navicon { display: inline-grid; place-items: center; width: 19px; font-size: 18px; line-height: 1; }
.gift-nav-badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 50px; background: var(--danger); color: var(--surface); font-size: 11px; font-weight: 800; }
.headerprofile { grid-column: 2; grid-row: 1; display: flex; align-items: center; justify-content: flex-end; gap: 9px; min-width: 0; white-space: nowrap; }
.profile-name { max-width: 200px; overflow: hidden; text-overflow: ellipsis; font-size: 12px; font-weight: 700; }
.iconbtn { display: inline-flex; align-items: center; justify-content: center; min-height: var(--control-height); padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--muted); }
.lock-toggle { width: var(--control-height); min-width: var(--control-height); padding: 10px; font-size: 17px; }
.lock-toggle svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.lock-toggle.is-open { color: var(--danger); border-color: #cb8e83; background: #fbefed; box-shadow: 0 0 0 2px #9d3f3312; }
.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 30px; margin-bottom: 13px; }
.crumb { color: var(--muted); font-size: 11px; letter-spacing: .02em; }
.topactions { display: flex; align-items: center; gap: 9px; }
.page { display: none; }
.page.active { display: block; }
.heading { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px 24px; margin: 0 0 25px; }
.heading > div { min-width: 0; }
.eyebrow { margin-bottom: 9px; color: var(--accent); font-size: 10px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; }
.heading h1 { margin: 0; font-size: clamp(29px, 2.6vw, 37px); line-height: 1.15; font-weight: 650; letter-spacing: -1.1px; }
.heading p { margin: 8px 0 0; color: var(--muted); line-height: 1.5; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--control-height); padding: 11px 17px; border: 1px solid transparent; border-radius: var(--radius-control); font-size: 13px; font-weight: 650; line-height: 1.3; text-decoration: none; }
.btn.primary { background: var(--accent); color: var(--surface); }
.btn.ghost { border-color: var(--line); background: var(--surface); color: var(--ink); }
.btn.ghost.danger { color: var(--danger); }
.linkbtn { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 8px 6px; border: 0; border-radius: 7px; background: transparent; color: var(--accent); font-size: 12px; font-weight: 700; line-height: 1.3; }
.linkbtn.danger { color: var(--danger); }

/* Cards, panels and tables */
.cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 24px; }
.cards:has(> :nth-child(2):last-child) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card, .panel { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-panel); background: var(--surface); box-shadow: var(--shadow); }
.card { padding: 22px; }
.stathead { display: flex; align-items: flex-start; justify-content: space-between; gap: 9px; color: var(--muted); font-size: 12px; font-weight: 650; line-height: 1.4; }
.staticon { display: grid; place-items: center; flex: 0 0 32px; width: 32px; height: 32px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); font-size: 15px; }
.statvalue { display: block; margin: 14px 0 5px; overflow-wrap: anywhere; font-size: clamp(23px, 2vw, 31px); line-height: 1.2; font-weight: 650; letter-spacing: -1px; font-variant-numeric: tabular-nums; }
.statfoot { color: var(--muted); font-size: 11px; line-height: 1.4; }
.layout { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 18px; }
.pagegrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.sectionpanel { margin-top: 18px; }
.panelhead { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 20px 23px; border-bottom: 1px solid var(--line); }
.panelhead > div { min-width: 0; }
.panelhead h2 { margin: 0; font-size: 16px; line-height: 1.35; font-weight: 650; }
.panelhead p { margin: 5px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.panelhead .linkbtn { flex-shrink: 0; }
.tablewrap { position: relative; scrollbar-color: #b4a18c #f6f3ee; max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; text-align: left; }
thead { background: var(--surface-soft); }
th { padding: 14px 20px; color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .65px; text-transform: uppercase; white-space: nowrap; }
td { padding: 14px 20px; border-top: 1px solid #eee8df; font-size: 13px; white-space: nowrap; vertical-align: middle; font-variant-numeric: tabular-nums; }
td small { font-size: 11px; }
.table-actions, td:last-child:has(.linkbtn) { white-space: nowrap; }
.table-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 3px 7px; }
.person { display: flex; align-items: center; gap: 9px; min-width: 0; font-weight: 700; }
.miniavatar { display: grid; place-items: center; width: 30px; height: 30px; flex: 0 0 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: 10px; }
.customer-name { min-height: 40px; padding: 4px 0; border: 0; border-radius: 4px; background: transparent; color: var(--ink); font-weight: 750; text-align: left; }
.pill { display: inline-flex; align-items: center; padding: 5px 9px; border-radius: 20px; background: #efe8dd; color: var(--accent); font-size: 11px; font-weight: 700; white-space: nowrap; }
.progressline { height: 6px; margin-top: 6px; overflow: hidden; border-radius: 10px; background: #eee8df; }
.progressline span { display: block; height: 100%; border-radius: 10px; background: var(--cognac); }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.toolbar .field { min-width: 180px; }
.toolbar .search { flex: 1; min-width: 260px; max-width: 620px; }
.filters, .sales-history-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; min-width: 0; }
.filters .field, .sales-history-filters .field { min-width: 160px; }
.pagination { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px 14px; padding: 14px 20px; border-top: 1px solid var(--line); }
.pagination > span, .pagination > small { color: var(--muted); font-size: 12px; text-align: center; }
.pagination .btn { min-height: var(--control-height); padding: 9px 13px; font-size: 12px; }
.pagination-buttons { display: flex; align-items: center; gap: 8px; }
.notice { margin-top: 16px; padding: 12px 14px; border-radius: 10px; background: #f1ebe2; color: var(--muted); font-size: 12px; line-height: 1.5; }
.alert, .form-error { margin: 12px 0; padding: 12px 14px; border-radius: 10px; background: #fbf1e5; color: #80552f; font-size: 13px; overflow-wrap: anywhere; }
.alert.success { background: #edf2ec; color: var(--success); }
.form-error { border: 1px solid #e3b7af; background: #fcf1ee; color: var(--danger); }
.loading, .empty, .chart-empty { padding: 38px 22px; color: var(--muted); text-align: center; line-height: 1.5; }
/* Initial loading screen stays still and readable on slow connections. */
.boot-splash { position: fixed; z-index: 50; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; min-height: 100vh; min-height: 100dvh; padding: 24px; background: var(--accent); color: #fff; }
.boot-orbit { display: none; }
.boot-logo { display: block; width: min(300px, 72vw); max-height: 90px; object-fit: contain; }
.boot-caption { color: #f4eee4; font-size: 12px; font-weight: 500; letter-spacing: .03em; }
.boot-progress { width: 120px; height: 2px; overflow: hidden; background: #ffffff30; }
.boot-progress i { display: block; width: 42%; height: 100%; background: #d5b897; }
#toast { position: sticky; top: 144px; z-index: 7; box-shadow: var(--shadow); }

/* Forms and customer selection */
.field { min-height: var(--control-height); min-width: 0; padding: 11px 12px; border: 1px solid var(--field-border); border-radius: var(--radius-control); outline: none; background: var(--surface); color: var(--ink); line-height: 1.4; }
input.field, select.field { height: var(--control-height); }
select.field { appearance: none; -webkit-appearance: none; padding-right: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='m1 1 5 5 5-5' fill='none' stroke='%23593c2d' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 12px 8px; }
select.field[multiple] { height: auto; min-height: 130px; background-image: none; padding-right: 12px; }
.field:focus { border-color: var(--focus); box-shadow: 0 0 0 3px #9063431c; }
.field[aria-invalid='true'] { border-color: var(--danger); }
input[type='checkbox'], input[type='radio'] { accent-color: var(--accent); }
input[type='checkbox']:focus-visible, input[type='radio']:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.field:disabled { cursor: not-allowed; background: #f2ede5; color: #8c8074; opacity: 1; }
.field::placeholder { color: #807467; opacity: 1; }
textarea.field { display: block; width: 100%; height: auto; min-height: 110px; resize: vertical; }
input[type='date'].field { max-width: 100%; min-width: 0; appearance: none; -webkit-appearance: none; }
.formgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.formfield { display: grid; align-content: start; gap: 7px; }
.formfield label { color: #65584c; font-size: 12px; font-weight: 700; line-height: 1.4; }
.formfield > .field-label { display: block; color: #65584c; font-size: 12px; font-weight: 700; line-height: 1.4; }
.formfield .field { width: 100%; }
.full { grid-column: 1 / -1; }
.checkrow { display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 12px; border-radius: 10px; background: #f4eee6; color: #655346; }
.checkrow input { width: 20px; height: 20px; margin: 0; flex: 0 0 20px; accent-color: var(--accent); }
.checkrow:has(input:checked) { background: var(--accent-soft); box-shadow: inset 0 0 0 1px #bba387; }
.checkrow:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.formactions { display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: 9px; margin-top: 20px; }
.customer-search-field { position: relative; }
.customer-matches { position: absolute; z-index: 8; top: calc(100% + 6px); right: 0; left: 0; max-height: min(320px, 42dvh); overflow: auto; overscroll-behavior: contain; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); box-shadow: 0 12px 30px #30282114; }
.customer-matches:empty { display: none; }
.customer-match { display: flex; align-items: flex-start; justify-content: space-between; gap: 7px 12px; width: 100%; min-height: 48px; padding: 12px; border: 0; border-bottom: 1px solid #eee8df; background: var(--surface); color: var(--ink); text-align: left; line-height: 1.4; }
.customer-match > * { min-width: 0; overflow-wrap: anywhere; }
.customer-match span, .search-empty { color: var(--muted); font-size: 12px; }
.search-empty { padding: 14px; }
.customer-details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 20px; padding: 8px 0; }
.customer-details small { display: block; margin-bottom: 4px; color: var(--muted); font-size: 12px; }
.customer-details b { display: block; overflow-wrap: anywhere; font-size: 13px; line-height: 1.5; }
.customer-details a { color: var(--accent); text-decoration: none; }
.profile-history-head { flex-wrap: wrap; margin-top: 10px; padding: 17px 0; }
.profile-history-head > div { flex: 1 1 180px; }
.internal-note-display { margin: 10px 0 14px; padding: 12px 14px; border-radius: 10px; background: #f4eee6; }
.internal-note-display small { display: block; margin-bottom: 5px; color: var(--accent); font-weight: 800; }
.internal-note-display div { white-space: pre-wrap; overflow-wrap: anywhere; }

/* Purchase entry: major inputs remain visible while optional fields wrap. */
.sales-heading { align-items: flex-start; }
.sales-heading-tools { display: grid; justify-items: stretch; gap: 7px; width: min(100%, 260px); }
.sale-date-control { display: grid; gap: 4px; color: #655346; font-size: 11px; font-weight: 800; letter-spacing: .35px; }
.sale-date-control .field { width: 100%; min-height: 40px; padding: 7px 10px; font-size: 14px; font-weight: 700; }
.sale-date-control small { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: capitalize; }
.sale-date-row { display: flex; align-items: end; justify-content: flex-start; flex-wrap: wrap; gap: 12px; margin: 0 0 16px; padding: 13px 15px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); }
.sale-date-row label { display: grid; align-content: start; gap: 6px; color: #655346; font-size: 11px; font-weight: 800; letter-spacing: .35px; }
.sale-edit-top label { display: flex; align-items: center; justify-content: flex-end; gap: 9px; color: var(--muted); font-size: 11px; }
.sale-date-row .field { width: 184px; min-height: 46px; padding: 8px 11px; font-size: 15px; font-weight: 700; }
.sale-edit-top .field { width: 154px; min-height: 40px; padding: 7px 9px; font-size: 13px; }
.daily-revenue-card { display: flex; align-items: center; justify-content: space-between; gap: 24px; width: min(100%, 380px); min-height: 74px; margin: 0 0 14px auto; padding: 12px 16px; border: 1px solid var(--accent); border-radius: 10px; background: var(--accent); color: #fff; text-align: left; cursor: pointer; }
.daily-revenue-card span { display: grid; gap: 3px; }
.daily-revenue-card span small { color: #e7d8c6; font-size: 12px; font-weight: 700; }
.daily-revenue-card span b { font-size: 20px; font-variant-numeric: tabular-nums; }
.daily-revenue-card > small { color: #e7d8c6; font-size: 11px; font-weight: 700; }
.daily-revenue-card:hover, .daily-revenue-card:focus-visible { border-color: var(--accent); outline: 2px solid #90634325; }
.daily-revenue-breakdown { display: grid; gap: 0; }
.daily-revenue-breakdown > div { display: flex; justify-content: space-between; gap: 14px; padding: 13px 4px; border-bottom: 1px solid var(--line); }
.daily-revenue-breakdown > div:first-child { font-size: 18px; font-weight: 800; }
.daily-revenue-breakdown > div:last-child { border-bottom: 0; }
.daily-revenue-breakdown b { font-variant-numeric: tabular-nums; }
.sale-layout { overflow: visible; padding: 24px; }
#saleItems { overflow-x: auto; overscroll-behavior-inline: contain; }
.sale-customer-row { display: grid; grid-template-columns: minmax(240px, 1.05fr) minmax(210px, .85fr) minmax(220px, 1fr); align-items: stretch; gap: 14px; }
.major-label { color: var(--ink) !important; font-weight: 700 !important; }
.major-input { font-size: 16px; font-weight: 750; }
.selected-customer, .internal-note { display: flex; flex-direction: column; justify-content: center; gap: 5px; min-height: 76px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-soft); overflow-wrap: anywhere; }
.selected-customer b { font-size: 14px; }
.selected-customer span, .internal-note span { color: var(--muted); font-size: 12px; line-height: 1.45; }
.internal-note { border-color: var(--line); background: #f4eee6; }
.internal-note b { color: var(--accent); font-size: 10px; font-weight: 800; letter-spacing: .5px; text-transform: uppercase; }
.internal-note span { color: var(--ink); white-space: pre-wrap; }
.bonus-status { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 14px; margin: 14px 0; padding: 13px 15px; border-radius: 11px; background: #f4ecde; color: #786144; font-size: 12px; line-height: 1.5; }
.bonus-status > div { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.bonus-status > div + div { padding-left: 15px; border-left: 1px solid #dfd0bc; }
.bonus-status b { color: #57442e; }
.bonus-due { margin-top: 3px; color: #87542d; font-weight: 800; }
.sale-items-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 17px 0 8px; }
.sale-items-head b { font-size: 14px; }
.sale-items-head span { color: var(--muted); font-size: 11px; }
.sale-items-scroll { width: 100%; overflow-x: auto; overscroll-behavior-inline: contain; }
.sale-item-row { display: grid; grid-template-columns: minmax(112px, 1fr) 224px minmax(145px, 1.1fr) 70px 105px 190px 160px 132px 68px; grid-template-areas: 'brand category type size amount discount bonus summary remove'; align-items: end; gap: 10px; min-width: 1286px; padding: 17px 0; border-top: 1px solid var(--line); }
.brand-field { grid-area: brand; }
.category-field { grid-area: category; min-width: 0; }
.type-field { grid-area: type; }
.size-field { grid-area: size; }
.amount-field { grid-area: amount; }
.discount-field { grid-area: discount; display: grid; grid-template-columns: 98px 84px; align-items: end; gap: 8px; }
.sale-item-row select.field { height: var(--control-height); min-height: var(--control-height); padding: 10px 30px 10px 11px; font-size: 13px; line-height: 1.4; background-position: right 10px center; }
.discount-kind-field, .discount-value-field { min-width: 0; }
.bonus-field { grid-area: bonus; }
.amount-summary { grid-area: summary; }
.item-remove { grid-area: remove; }
.sale-item-row .formfield { min-width: 0; }
.sale-item-row .formfield label, .sale-item-row .field-label { font-size: 11px; }
.sale-item-row .field { width: 100%; min-width: 0; min-height: var(--control-height); height: var(--control-height); padding: 10px 11px; font-size: 13px; }
.sale-item-row .major-input { font-size: 16px; }
.category-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
.category-choice { min-width: 0; min-height: var(--control-height); padding: 7px 5px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--muted); font-size: 11px; font-weight: 700; line-height: 1.15; text-align: center; white-space: nowrap; cursor: pointer; }
.category-choice.is-selected { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.category-choice:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sale-item-row .checkrow { width: 100%; min-height: var(--control-height); padding: 6px 8px; gap: 7px; border: 1px solid #dfd1bf; border-radius: 9px; background: #f4eee3; color: var(--accent); cursor: pointer; }
.sale-item-row .checkrow span { display: grid; gap: 2px; min-width: 0; }
.sale-item-row .checkrow b { font-size: 12px; font-weight: 800; }
.sale-item-row .checkrow small { font-size: 9px; line-height: 1.1; white-space: nowrap; }
.sale-item-row .item-discount-value:disabled { background: var(--surface); color: var(--muted); }
.amount-summary { display: grid; align-content: center; gap: 5px; min-height: var(--control-height); color: var(--muted); font-size: 11px; line-height: 1.4; }
.amount-summary b { color: var(--ink); font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.amount-summary span:last-child b { font-size: 14px; }
.sale-item-row.invalid-discount .item-discount-value { border-color: var(--danger); background: #fcf1ee; }
.sale-item-row > .item-remove { justify-self: end; padding: 10px 5px; }
.sale-footer { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.sale-footer label { display: grid; gap: 7px; width: min(420px, 60%); color: var(--muted); font-size: 12px; font-weight: 700; }
.sale-footer .field { width: 100%; }
.sale-edit-top { display: flex; justify-content: flex-end; margin-bottom: 12px; }
.sale-edit-customer { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 14px; padding: 12px 14px; border-radius: 10px; background: #f4eee6; overflow-wrap: anywhere; }
.sale-edit-customer span { color: var(--muted); font-size: 12px; }
/* A purchase editor must fit inside its modal even on a wide desktop. */
.modal.wide-modal { width: min(1500px, 100%); }
#editItems { overflow-x: auto; }
.modal .sale-item-row { min-width: 1286px; }

/* Gifts and manual voucher workflow */
.giftpanel { border-color: #e3d5bf; background: #fcf8ef; }
.giftcount { color: #865b35; font-size: 30px; line-height: 1.15; font-weight: 800; white-space: nowrap; }
.giftitem { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 16px 20px; border-top: 1px solid #eee4d4; }
.giftperson { display: flex; align-items: center; gap: 10px; min-width: 0; }
.giftperson > div, .giftperson > span:last-child { min-width: 0; }
.giftperson b { display: block; overflow-wrap: anywhere; font-size: 13px; line-height: 1.4; }
.giftperson small { display: block; margin-top: 3px; overflow-wrap: anywhere; color: var(--muted); font-size: 11px; line-height: 1.5; }
.giftbadge { display: inline-flex; flex-shrink: 0; padding: 5px 9px; border-radius: 20px; background: #f0e0c6; color: #865b35; font-size: 11px; font-weight: 700; }
.gift-expand-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; width: 100%; min-height: 80px; padding: 20px 23px; border: 0; border-bottom: 1px solid var(--line); background: var(--surface); color: var(--ink); text-align: left; }
.gift-expand-head span:first-child { display: grid; gap: 5px; min-width: 0; }
.gift-expand-head b { font-size: 16px; font-weight: 750; line-height: 1.4; }
.gift-expand-head small { color: var(--muted); font-size: 12px; line-height: 1.45; }
.gift-expand-head.expanded { background: var(--surface-soft); }
.gift-expand-head .giftcount { font-size: 26px; }
.gift-expand-body { display: none; }
.gift-expand-body.expanded { display: block; }
.gift-workflow { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; max-width: 68%; }
.gift-workflow .btn { min-height: var(--control-height); padding: 9px 12px; font-size: 12px; }
.gift-step { display: grid; align-content: start; justify-items: stretch; gap: 6px; min-width: 150px; max-width: 215px; }
.gift-step > small { padding-inline: 3px; color: var(--muted); font-size: 11px; line-height: 1.4; text-align: center; overflow-wrap: anywhere; }
.gift-step .btn:disabled { opacity: 1; background: #f4f0e9; border-color: var(--line); color: #897b6d; }
.gift-step .btn:disabled:not(.ghost) { opacity: .6; }
.gift-step .linkbtn { min-height: 36px; padding-block: 6px; font-size: 11px; }
.gift-expand-head .giftcount { display: flex; align-items: center; gap: 16px; }
.gift-expand-head .giftcount > span { display: inline-block; font-size: 21px; }
.gift-expand-head.expanded .giftcount > span { transform: rotate(180deg); }
.gift-due-row > .btn { flex-shrink: 0; }
.gift-status { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 3px; padding: 7px 10px; border-radius: 20px; background: #f5ecdf; color: #75614b; font-size: 11px; font-weight: 700; line-height: 1.4; }
.gift-status.done { background: #edf2ec; color: var(--success); }
.gift-status small { font-size: 10px; font-weight: 500; }
.issue-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 16px 20px; border-top: 1px solid var(--line); }
.issue-row > div { min-width: 0; }
.issue-row p { margin: 6px 0; color: var(--ink); font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
.issue-row small { color: var(--muted); font-size: 11px; }
.issue-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; flex-shrink: 0; max-width: 48%; }

/* Statistics */
.chartbox { padding: 20px; overflow-x: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
.stats-scope { margin: -7px 0 15px; color: var(--muted); font-size: 12px; }
.stats-details { display: grid; gap: 0; margin: 0; padding: 6px 20px; }
.stats-details > div { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.stats-details > div:last-child { border-bottom: 0; }
.stats-details dt { min-width: 0; color: var(--muted); font-size: 12px; }
.stats-details dd { flex-shrink: 0; margin: 0; text-align: right; font-size: 13px; font-weight: 750; font-variant-numeric: tabular-nums; }
.bars { display: flex; align-items: flex-end; gap: 13px; height: 200px; padding: 0 4px; border-bottom: 1px solid var(--line); }
.barcol { display: flex; flex: 1; flex-direction: column; align-items: center; justify-content: flex-end; gap: 7px; height: 100%; min-width: 0; }
.bar { width: min(34px, 70%); min-height: 5px; border-radius: 7px 7px 2px 2px; background: #bc9a79; }
.bar.active { background: var(--accent); }
.barcol small, .barcol em { color: var(--muted); font-size: 10px; line-height: 1.3; }
.barcol em { max-width: 100%; text-align: center; overflow-wrap: anywhere; font-style: normal; font-variant-numeric: tabular-nums; }
.productrow { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 14px 18px; border-top: 1px solid #eee8df; }
.productrow b { min-width: 0; overflow-wrap: anywhere; font-size: 13px; line-height: 1.45; }
.productrow > span { flex-shrink: 0; color: var(--muted); font-size: 12px; }
.productrank { display: inline-grid; place-items: center; width: 26px; height: 26px; margin-right: 8px; border-radius: 8px; background: #f3ede4; color: var(--accent); font-weight: 700; }
.stats-extra { grid-template-columns: repeat(4, minmax(0, 1fr)); padding: 0; margin: 18px 0 0; }
.status { display: inline-flex; align-items: center; gap: 8px; line-height: 1.4; }
.status::before { width: 7px; height: 7px; flex: 0 0 7px; border-radius: 50%; background: var(--success); content: ''; }
.status.off::before { background: #ad695b; }

/* Modals and interactive detail lists */
.modalback { position: fixed; inset: 0; z-index: 30; display: none; place-items: center; height: 100vh; height: 100dvh; overflow-y: auto; padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left)); background: #21180f73; overscroll-behavior: contain; }
.modalback.open { display: grid; }
.modal { width: min(760px, 100%); max-height: calc(100vh - 36px); max-height: calc(100dvh - max(36px, env(safe-area-inset-top) + env(safe-area-inset-bottom))); padding: 24px; overflow-y: auto; overscroll-behavior: contain; border: 1px solid #d6c7b6; border-radius: var(--radius-modal); background: var(--surface); box-shadow: 0 25px 90px #21180f2e; }
.modal.wide-modal { width: min(980px, 100%); }
.modal-open { overflow: hidden; }
.modal-header { position: relative; display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 5px; }
.modal-header > div { min-width: 0; }
.modal h2 { margin: 0 0 6px; overflow-wrap: anywhere; font-size: 24px; line-height: 1.25; font-weight: 650; letter-spacing: -.5px; }
.modal > p, #modalSub { margin: 0 0 20px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.modal-close { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; flex: 0 0 44px; margin-top: -5px; padding: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--muted); font-size: 22px; line-height: 1; }
.modal .tablewrap { max-width: 100%; }
.detail-list { display: grid; gap: 8px; max-height: 58vh; max-height: 58dvh; overflow-y: auto; overscroll-behavior: contain; }
.detail-list-item { display: flex; flex-direction: column; gap: 5px; width: 100%; min-height: 56px; padding: 13px 14px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); color: var(--ink); text-align: left; }
.detail-list-item b { font-size: 13px; overflow-wrap: anywhere; }
.detail-list-item span { overflow-wrap: anywhere; color: var(--muted); font-size: 12px; }
.interactive-card { display: block; width: 100%; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.interactive-card:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.interactive-row { width: 100%; border-right: 0; border-left: 0; border-bottom: 0; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.clickable-row { cursor: pointer; }
.clickable-row:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }

/* Bereichsauswahl uses the whole viewport, independent of the application shell. */
.entrybody { display: grid; place-items: center; width: 100%; min-height: 100vh; min-height: 100dvh; margin: 0; padding: max(22px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(22px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left)); }
.brand { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.brand .brand-logo { width: 190px; height: auto; }
.brand small { color: var(--muted); font-size: 12px; }
.workspace-box { width: min(860px, 100%); padding: clamp(20px, 4vw, 34px); border: 1px solid var(--line); border-radius: var(--radius-modal); background: var(--surface); box-shadow: 0 14px 55px #3028210b; }
.workspace-box.login-box { width: min(480px, 100%); }
.login-box .brand { align-items: flex-start; flex-direction: column; gap: 13px; }
.login-box .brand .brand-logo { width: 210px; }
.login-box form { display: grid; gap: 18px; }
.password-wrap { position: relative; display: block; }
.password-wrap .field { padding-right: 50px; }
.password-toggle { position: absolute; top: 50%; right: 5px; display: grid; place-items: center; width: 40px; height: 40px; transform: translateY(-50%); border: 0; border-radius: 8px; background: transparent; color: var(--muted); }
.password-toggle:hover { background: #f2ece3; color: var(--accent); }
.password-toggle svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.workspace-box h1 { margin: 24px 0 9px; font-size: 29px; font-weight: 650; letter-spacing: -.7px; }
.workspace-box > p { margin: 0 0 22px; color: var(--muted); }
.workspace-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 13px; margin: 20px 0; }
.workspace-tile { display: grid; align-content: start; justify-items: start; gap: 8px; min-height: 150px; padding: 17px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); color: var(--ink); text-align: left; }
.workspace-tile > span { color: var(--accent); font-size: 23px; }
.workspace-tile b { font-size: 15px; }
.workspace-tile small { color: var(--muted); line-height: 1.45; }
.workspace-tile:hover, .workspace-tile.selected { border-color: var(--accent); background: var(--accent-soft); }
#workspaceCodeForm { display: grid; gap: 13px; max-width: 420px; margin: 0 auto 14px; padding: 17px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-soft); }
#workspaceCodeForm .formfield { gap: 7px; }
.workspace-box > .linkbtn { display: flex; margin: 10px auto 0; }
.headerprofile #workspaceSwitch { padding: 8px 10px; font-size: 11px; }

.access-list { padding: 4px 18px 14px; }
.access-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 66px; padding: 10px 3px; border-bottom: 1px solid var(--line); }
.access-row:last-child { border-bottom: 0; }
.access-row > div { display: grid; gap: 4px; min-width: 0; }
.access-row small { color: var(--muted); overflow-wrap: anywhere; }
.access-actions { display: flex; align-items: center; justify-content: flex-end; gap: 7px; flex-wrap: wrap; }
.access-form { padding: 18px 20px; }

/* WhatsApp setup and consent */
.wa-consent { display: flex !important; grid-column: 1 / -1; align-items: flex-start !important; gap: 11px; }
.wa-consent input { margin-top: 2px; }
.wa-consent span { display: grid; gap: 4px; }
.wa-consent b { font-size: 13px; }
.wa-consent small, .consent-hint { color: var(--muted); font-size: 12px; line-height: 1.55; }
.wa-setup { margin-bottom: 16px; }
.wa-setup-note { padding: 15px 20px; color: var(--muted); font-size: 13px; line-height: 1.6; overflow-wrap: anywhere; }
.wa-setup-note code { padding: 2px 5px; border-radius: 4px; background: #eee6da; }
.wa-form { padding: 20px; }
.wa-form textarea { min-height: 130px; }
.wa-form .formactions { margin-top: 16px; }
.consent-hint { margin: 0; padding: 0 20px 16px; }
.formfield > .consent-hint { padding: 0; }
.wa-setup .status { flex-shrink: 0; }

/* Retail analytics: filters, reports and tables share the screen calculation scope. */
.analytics-toolbar, .analytics-filter-panel { margin-bottom: 22px; padding: 22px; overflow: visible; }
.analytics-toolbar .panelhead, .analytics-filter-panel .panelhead { margin: -22px -22px 20px; }
.analytics-filters, .analytics-filter-grid { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); align-items: end; gap: 16px 14px; }
.analytics-filters > label, .analytics-filter-grid > label { display: grid; align-content: start; gap: 7px; min-width: 0; color: #65584c; font-size: 12px; font-weight: 650; }
.analytics-filters .field, .analytics-filter-grid .field { width: 100%; }
.analytics-filters .wide, .analytics-filter-grid .wide { grid-column: span 2; }
.analytics-filter-actions, .analytics-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
.analytics-filter-actions { justify-content: space-between; margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }
.analytics-actions .field { max-width: 260px; }
.analytics-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 7px 16px; margin: 0 0 18px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.analytics-meta strong { color: var(--ink); font-weight: 650; }
.analytics-meta .pill { padding: 5px 10px; }
.analytics-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 24px; }
.analytics-kpis .card { display: grid; align-content: start; }
.card.analytics-value { display: grid; align-content: start; gap: 10px; font-weight: 400; }
.card.analytics-value > small { color: var(--muted); font-size: 12px; line-height: 1.45; font-weight: 600; }
.card.analytics-value > strong { color: var(--ink); font-size: clamp(23px, 2vw, 31px); line-height: 1.2; letter-spacing: -.8px; font-weight: 650; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.card.analytics-value > span { color: var(--muted); font-size: 11px; line-height: 1.5; font-weight: 400; }
.analytics-kpis .statvalue { margin-top: 16px; }
.analytics-kpis .statfoot { margin-top: 3px; }
.analytics-grid, .analytics-section-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 20px; }
.analytics-grid > *, .analytics-section-grid > * { min-width: 0; }
.analytics-grid > .full, .analytics-section-grid > .full { grid-column: 1 / -1; }
.analytics-section { margin-top: 22px; }
.analytics-section > .analytics-grid { padding: 20px; }
.analytics-section > h3 { margin: 0; padding: 17px 20px 12px; color: var(--muted); font-size: 11px; line-height: 1.4; font-weight: 700; letter-spacing: .65px; text-transform: uppercase; }
.analytics-section > .analytics-actions { justify-content: space-between; padding: 17px 20px 0; }
.analytics-section > .analytics-actions p { margin: 0; color: var(--muted); font-size: 12px; }
.analytics-toolbar > details { margin: 20px 0; padding: 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.analytics-toolbar > details > summary { width: fit-content; min-height: var(--control-height); padding: 14px 0; color: var(--accent); font-size: 12px; font-weight: 650; cursor: pointer; }
.analytics-toolbar > details > summary:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.analytics-toolbar > details > .analytics-filters { padding: 5px 0 20px; }
.analytics-toolbar > .analytics-note:last-child { margin-bottom: 0; }
#analysis-definitions .stats-details { padding: 6px 20px; }
#analysis-definitions .stats-details > div { display: grid; grid-template-columns: minmax(130px, .35fr) minmax(0, 1fr); align-items: start; gap: 18px; padding: 15px 0; }
#analysis-definitions .stats-details dd { min-width: 0; text-align: left; white-space: normal; overflow-wrap: anywhere; font-size: 12px; font-weight: 400; line-height: 1.65; }
.analytics-section > .panelhead { align-items: flex-start; flex-wrap: wrap; }
.analytics-section .panelhead .btn { min-height: 38px; padding: 8px 12px; font-size: 12px; }
.analytics-value, .analytics-table td:not(:first-child) { font-variant-numeric: tabular-nums; }
.analytics-table th:not(:first-child), .analytics-table td:not(:first-child) { text-align: right; }
.analytics-table td:first-child { max-width: 320px; white-space: normal; overflow-wrap: anywhere; }
.analytics-value { font-weight: 650; }
.analytics-trend { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 12px; font-weight: 600; }
.analytics-trend.positive { color: var(--success); }
.analytics-trend.negative { color: var(--danger); }
.analytics-note, .analytics-warning { margin: 16px 0; padding: 14px 16px; border: 1px solid #e4d5bf; border-radius: 8px; background: #faf5ec; color: #715b40; font-size: 12px; line-height: 1.65; overflow-wrap: anywhere; }
.analytics-note p, .analytics-warning p { margin: 0; }
.analytics-note p + p, .analytics-warning p + p { margin-top: 8px; }
.analytics-note strong, .analytics-warning strong { color: var(--accent); }
.analytics-section > .analytics-note { margin: 17px 20px; }
.analytics-chart { padding: 22px; overflow-x: auto; }
.analytics-chart svg { display: block; width: 100%; height: auto; }
.analytics-chart .bars { min-width: 560px; }
.analytics-table { width: 100%; }
.analytics-table th, .analytics-table td { padding: 13px 18px; }
.analytics-table th:first-child, .analytics-table td:first-child { min-width: 130px; }
.analytics-table .numeric, .analytics-table th.numeric { text-align: right; }
.analytics-table .wrap { max-width: 280px; white-space: normal; overflow-wrap: anywhere; }
.analytics-table caption { padding: 14px 18px; color: var(--muted); text-align: left; font-size: 12px; }
.analytics-empty { display: grid; justify-items: center; gap: 8px; padding: 42px 24px; color: var(--muted); text-align: center; }
.analytics-empty strong { color: var(--ink); font-size: 15px; font-weight: 650; }
.analytics-definition-list { display: grid; gap: 14px; padding: 20px; margin: 0; font-size: 12px; line-height: 1.6; }
.analytics-definition-list dt { color: var(--ink); font-weight: 650; }
.analytics-definition-list dd { margin: 4px 0 0; color: var(--muted); }
.report-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 18px 0; }
.report-section-choice { display: flex; align-items: flex-start; gap: 10px; min-height: 60px; padding: 13px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-soft); color: var(--ink); font-size: 13px; cursor: pointer; }
.report-section-choice input { flex: 0 0 18px; width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--accent); }
.report-section-choice span { display: grid; gap: 4px; min-width: 0; }
.report-section-choice small { color: var(--muted); font-size: 11px; line-height: 1.5; }
.report-section-choice:has(input:checked) { border-color: #bba387; background: var(--accent-soft); }
.report-section-choice:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Responsive layouts preserve every control and avoid page-level overflow. */
@media (max-width: 1359px) {
  .appheader { grid-template-columns: minmax(210px, 1fr) auto; gap: 10px 16px; }
  .headerbrand { grid-column: 1; grid-row: 1; }
  .headerprofile { grid-column: 2; grid-row: 1; }
  .profile-name { max-width: 220px; }
  .appheader .nav { justify-content: flex-start; padding: 0 0 10px; }
  #toast { top: 145px; }
}
@media (max-width: 1099px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats-extra { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sale-customer-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sale-customer-row > .internal-note { grid-column: 1 / -1; min-height: 60px; }
  #saleItems { overflow: visible; }
  .sale-item-row, .modal .sale-item-row { grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-areas: 'brand brand category category' 'type type size amount' 'discount discount bonus bonus' 'summary summary remove remove'; min-width: 0; gap: 14px 12px; margin-bottom: 15px; padding: 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-soft); }
  .discount-field { grid-template-columns: minmax(92px, 1fr) minmax(84px, .8fr); }
  .analytics-filters, .analytics-filter-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .analytics-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .gift-due-row, #issuedGiftPanel .giftitem { flex-direction: column; align-items: flex-start; }
  .gift-workflow { width: 100%; max-width: none; justify-content: flex-start; }
  .gift-due-row > .btn { align-self: flex-start; }
}
@media (max-width: 800px) {
  .shell > main { padding: 18px 20px calc(36px + env(safe-area-inset-bottom)); }
  .appheader { padding-inline: max(20px, env(safe-area-inset-left)); }
  .nav button { padding-inline: 11px; }
  .heading h1 { font-size: 28px; }
  .heading p { font-size: 13px; }
  .tablewrap table { min-width: 640px; }
  .stats-extra { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sale-layout { padding: 18px; }
  .sale-customer-row { gap: 12px; }
  .sale-item-row .field, .sale-item-row select.field, .field { font-size: 16px; }
  .sale-date-row .field, .sale-edit-top .field { font-size: 16px; }
  .sale-date-row .field { width: 165px; }
  .issue-row { align-items: flex-start; flex-direction: column; }
  .issue-actions { width: 100%; max-width: none; justify-content: flex-start; }
  .filters .field { min-width: 145px; }
  .modal { padding: 22px; }
  .analytics-grid, .analytics-section-grid { grid-template-columns: minmax(0, 1fr); }
  .analytics-filters, .analytics-filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .headerbrand span { display: none; }
  .profile-name { max-width: 130px; }
}
@media (max-width: 600px) {
  html { scroll-padding-top: 132px; }
  .appheader { grid-template-columns: minmax(120px, 1fr) auto; gap: 8px 10px; padding: calc(10px + env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left)); }
  .headerbrand span, .profile-name { display: none; }
  .headerbrand .brand-logo { width: 150px; height: auto; }
  .headerprofile { gap: 7px; }
  .headerprofile #logout { padding-inline: 11px; font-size: 12px; }
  .appheader .nav { gap: 4px; padding: 0 0 9px; }
  .nav button { flex-direction: row; gap: 7px; min-width: 0; min-height: var(--control-height); padding: 9px 12px; font-size: 12px; line-height: 1.25; }
  .navicon { font-size: 18px; }
  .nav .gift-nav-badge { position: absolute; top: 2px; right: 4px; min-width: 17px; height: 17px; font-size: 10px; }
  .shell > main { padding: 14px max(12px, env(safe-area-inset-right)) calc(28px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
  .topbar { min-height: 25px; margin-bottom: 15px; }
  .crumb { font-size: 11px; }
  .heading { flex-direction: column; align-items: stretch; gap: 14px; margin-bottom: 19px; }
  .heading h1 { font-size: 29px; line-height: 1.2; }
  .heading p { font-size: 13px; }
  .heading > .btn { width: 100%; min-height: 46px; }
  .cards { gap: 10px; margin-bottom: 17px; }
  .card { padding: 14px 12px; border-radius: 13px; }
  .stathead { align-items: center; gap: 6px; font-size: 11px; }
  .staticon { width: 28px; height: 28px; flex-basis: 28px; border-radius: 9px; }
  .statvalue { margin: 12px 0 5px; font-size: 21px; letter-spacing: -.5px; }
  .statfoot { font-size: 11px; }
  .layout, .pagegrid, .formgrid { grid-template-columns: minmax(0, 1fr); gap: 13px; }
  .full { grid-column: auto; }
  .panelhead { padding: 14px; gap: 9px; flex-wrap: wrap; align-items: flex-start; }
  .panelhead h2 { font-size: 15px; }
  .panelhead .linkbtn { padding: 6px 0; }
  .sectionpanel { margin-top: 15px; }
  .toolbar { gap: 10px; padding: 12px; }
  .toolbar .field, .toolbar .search { flex: 1 1 100%; width: 100%; min-width: 0; max-width: none; }
  .filters, .sales-history-filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
  .filters .field, .sales-history-filters .field { width: 100%; min-width: 0; padding-left: 11px; font-size: 16px; }
  .sales-history-filters .search { grid-column: 1 / -1; }
  .customer-details { gap: 13px; }
  .formactions .btn { flex: 1 1 auto; min-height: 46px; }
  .customer-match { flex-direction: column; gap: 3px; }
  .selected-customer, .internal-note { min-height: 61px; }
  .sale-layout { padding: 13px; }
  .sale-date-row { justify-content: flex-start; flex-wrap: wrap; margin-top: 0; margin-bottom: 11px; }
  .sale-date-row label { flex: 1 1 150px; justify-content: start; }
  .sale-date-row .field { width: 100%; }
  .access-row { align-items: flex-start; flex-direction: column; }
  .access-actions { justify-content: flex-start; }
  .access-row .btn { flex: 0 0 auto; }
  .daily-revenue-card { width: 100%; margin: 0 0 13px; }
  .sale-customer-row { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .sale-customer-row > .internal-note { grid-column: auto; }
  .bonus-status { grid-template-columns: minmax(0, 1fr); gap: 10px; padding: 12px; }
  .bonus-status > div + div { padding: 10px 0 0; border-top: 1px solid #dfd0bc; border-left: 0; }
  .sale-items-head { align-items: flex-start; gap: 9px; margin-top: 17px; }
  .sale-items-head span { text-align: right; max-width: 58%; }
  #saleItems { overflow: visible; }
  .sale-item-row, .modal .sale-item-row { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-areas: 'brand brand' 'category category' 'type size' 'amount amount' 'discount discount' 'bonus summary' 'remove remove'; gap: 13px 10px; min-width: 0; margin-bottom: 13px; padding: 13px 11px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); }
  .sale-item-row .field { min-height: var(--control-height); height: var(--control-height); padding: 10px 11px; font-size: 16px; background-color: var(--surface); }
  .sale-item-row select.field { font-size: 16px; padding-right: 34px; }
  .sale-item-row .field:disabled { cursor: not-allowed; background: #f3eee6; }
  .sale-item-row .formfield label { font-size: 11px; }
  .sale-item-row .checkrow { min-height: 46px; padding: 9px; }
  .sale-item-row .checkrow small { font-size: 10px; }
  .sale-item-row > .item-remove { align-self: end; min-height: var(--control-height); padding-inline: 6px; }
  .amount-summary { gap: 8px; padding-top: 1px; }
  .amount-summary b { display: block; font-size: 13px; }
  .amount-summary span:last-child b { font-size: 16px; }
  #addSaleItem, #addEditItem { width: 100%; }
  .sale-footer { flex-direction: column; align-items: stretch; gap: 15px; margin-top: 16px; }
  .sale-footer label { width: 100%; }
  .sale-footer .btn { min-height: 48px; }
  .sale-edit-customer { flex-direction: column; align-items: flex-start; gap: 4px; }
  .workspace-box { padding: 21px 17px; }
  .workspace-tiles { grid-template-columns: minmax(0, 1fr); gap: 9px; }
  .workspace-tile { grid-template-columns: 30px minmax(0, 1fr); align-items: center; min-height: 74px; padding: 12px; }
  .workspace-tile > span { grid-row: span 2; }
  .workspace-tile small { grid-column: 2; }
  .headerprofile #workspaceSwitch { padding: 8px; font-size: 10px; }
  .giftitem { padding: 15px 14px; gap: 12px; }
  .gift-expand-head { min-height: 80px; padding: 15px 14px; gap: 10px; }
  .gift-expand-head b { font-size: 15px; }
  .gift-expand-head small { font-size: 11px; }
  .gift-expand-head .giftcount { font-size: 23px; }
  .gift-workflow { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .gift-workflow > * { min-width: 0; max-width: none; text-align: center; justify-content: center; }
  .gift-step { min-width: 0; max-width: none; align-content: start; }
  .gift-step > .btn { width: 100%; }
  .gift-due-row > .btn { width: 100%; min-height: 46px; }
  #issuedGiftPanel .giftitem > .table-actions { width: 100%; justify-content: flex-start; }
  .gift-workflow .gift-status { border-radius: 9px; min-height: 38px; }
  .gift-workflow > .btn.primary { grid-column: 1 / -1; }
  .gift-workflow .btn { padding: 10px 8px; font-size: 12px; }
  .giftperson .miniavatar { align-self: flex-start; margin-top: 1px; }
  .issue-row { gap: 13px; padding: 15px 14px; }
  .issue-actions .btn { flex: 1; }
  .chartbox { padding: 17px 12px; }
  .stats-details { padding-inline: 14px; }
  .stats-details dt { font-size: 12px; }
  .stats-details dd { font-size: 12px; }
  .bars { gap: 7px; min-width: 0; height: 185px; }
  .barcol em { font-size: 9px; line-height: 1.25; overflow-wrap: anywhere; }
  .barcol small { font-size: 9px; }
  .pagination { padding: 12px; gap: 9px; }
  .pagination .btn { flex: 1 1 0; padding-inline: 10px; }
  .pagination > span, .pagination > small { flex: 0 1 auto; font-size: 11px; }
  .pagination-buttons { width: 100%; }
  .productrow { padding: 13px 14px; gap: 10px; }
  .productrow > span { font-size: 11px; }
  .stats-extra { gap: 10px; padding: 0; }
  #stats .tablewrap table { min-width: 0; }
  #stats .tablewrap th, #stats .tablewrap td { padding: 12px 13px; }
  .stats-extra .card { padding: 13px 11px; box-shadow: none; }
  .stats-extra .statvalue { font-size: 20px; }
  .modalback { padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); }
  .modal { width: 100%; max-height: calc(100vh - 16px); max-height: calc(100dvh - max(16px, env(safe-area-inset-top) + env(safe-area-inset-bottom))); padding: 19px 15px; border-radius: 17px; }
  .modal h2 { font-size: 22px; }
  .modal-close { margin-top: -3px; }
  .detail-list { max-height: 60dvh; }
  .profile-history-head { gap: 10px; }
  .profile-history-head .btn { flex: 1 1 150px; }
  .entrybody { padding-inline: 16px; }
  .wa-setup .panelhead { flex-direction: column; }
  .wa-setup-note, .wa-form { padding: 15px; }
  .consent-hint { padding: 0 15px 15px; }
  .wa-consent { grid-column: auto; }
  #toast { top: 134px; }
  .analytics-toolbar, .analytics-filter-panel { padding: 16px; margin-bottom: 18px; }
  .analytics-toolbar .panelhead, .analytics-filter-panel .panelhead { margin: -16px -16px 16px; }
  .analytics-filters, .analytics-filter-grid { gap: 13px 10px; }
  .analytics-filters .field, .analytics-filter-grid .field { font-size: 16px; }
  .analytics-filter-actions { align-items: stretch; gap: 12px; }
  .analytics-actions { width: 100%; }
  .analytics-actions .btn { flex: 1 1 auto; }
  .analytics-actions .field { width: 100%; max-width: none; }
  .analytics-kpis { gap: 10px; margin-bottom: 18px; }
  .analytics-kpis .card { padding: 16px 13px; }
  .analytics-kpis .statvalue { font-size: 22px; letter-spacing: -.6px; }
  .card.analytics-value > strong { font-size: 23px; }
  .analytics-section > .analytics-grid { padding: 14px; }
  .analytics-section > h3 { padding-inline: 14px; }
  .analytics-section > .analytics-actions { align-items: stretch; padding-inline: 14px; }
  .analytics-section > .analytics-note { margin-inline: 14px; }
  #analysis-definitions .stats-details { padding-inline: 14px; }
  #analysis-definitions .stats-details > div { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .analytics-section .panelhead .btn { min-height: var(--control-height); }
  .analytics-meta { gap: 6px 12px; }
  .analytics-chart { padding: 16px; }
  .analytics-note, .analytics-warning { padding: 12px 13px; }
  .analytics-grid, .analytics-section-grid { gap: 16px; }
  .report-options { grid-template-columns: minmax(0, 1fr); gap: 9px; }
  .analytics-table th, .analytics-table td { padding: 12px 14px; }
  #stats .tablewrap .analytics-table { min-width: 600px; }

  /* These tables carry labels from the same headers used on desktop. */
  .tablewrap.mobile-cards { overflow-x: visible; padding: 0 12px 12px; }
  .mobile-cards table { display: block; min-width: 0; }
  .mobile-cards thead { display: none; }
  .mobile-cards tbody { display: grid; gap: 11px; }
  .mobile-cards tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px 14px; min-width: 0; margin-top: 12px; padding: 13px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); }
  .mobile-cards td { display: block; min-width: 0 !important; padding: 0; border: 0; white-space: normal; overflow-wrap: anywhere; font-size: 13px; }
  .mobile-cards td::before { display: block; margin-bottom: 4px; color: var(--muted); font-size: 10px; font-weight: 750; letter-spacing: .4px; text-transform: uppercase; content: attr(data-label); }
  .mobile-cards td:first-child { grid-column: 1 / -1; }
  .mobile-cards td[data-label=''], .mobile-cards td[colspan], .mobile-cards .table-actions { grid-column: 1 / -1; }
  .mobile-cards td[data-label='']::before, .mobile-cards td[colspan]::before { display: none; }
  .mobile-cards td:has(.table-actions) { grid-column: 1 / -1; }
  .mobile-cards .person { gap: 9px; font-size: 14px; }
  .mobile-cards .customer-name { min-height: 38px; }
  .mobile-cards .table-actions { display: flex; flex-wrap: wrap; gap: 4px 9px; padding-top: 5px; border-top: 1px solid var(--line); }
  .mobile-cards .table-actions .linkbtn { min-height: var(--control-height); }
  .mobile-cards td.empty { padding: 14px 0; }
}
@media (max-width: 440px) {
  html { scroll-padding-top: 200px; }
  .appheader { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .headerbrand { grid-column: 1; grid-row: 1; justify-content: center; }
  .headerbrand .brand-logo { width: 160px; }
  .headerprofile { grid-column: 1; grid-row: 2; justify-content: stretch; gap: 7px; }
  .headerprofile #workspaceSwitch, .headerprofile #logout { flex: 1 1 0; padding-inline: 9px; font-size: 11px; }
  .appheader .nav { grid-column: 1; grid-row: 3; }
  .analytics-filters, .analytics-filter-grid { grid-template-columns: minmax(0, 1fr); }
  .analytics-filters .wide, .analytics-filter-grid .wide { grid-column: auto; }
  #toast { top: 190px; }
}
@media (max-width: 380px) {
  .headerbrand .brand-logo { width: 138px; }
  .nav button { min-width: 0; padding-inline: 10px; font-size: 12px; }
  .card { padding: 13px 10px; }
  .statvalue { font-size: 19px; }
  .filters { grid-template-columns: minmax(0, 1fr); }
  .customer-details { grid-template-columns: minmax(0, 1fr); }
  .sale-item-row, .modal .sale-item-row { padding-inline: 9px; gap: 11px 8px; }
  .sale-item-row .checkrow { padding-inline: 7px; gap: 6px; }
}
@media (hover: none) and (pointer: coarse) {
  .linkbtn, .customer-name, .gift-step .linkbtn, .mobile-cards .customer-name { min-height: var(--control-height); }
  .field, .sale-item-row .field, .sale-item-row select.field, .sale-date-row .field, .sale-edit-top .field { font-size: 16px; }
}
@media (hover: hover) and (pointer: fine) {
  .nav button:hover, .customer-match:hover { background: #eee5d9; color: var(--accent); }
  .btn.primary:hover { background: var(--accent-hover); }
  .btn.ghost:hover { background: #faf6ef; border-color: #bfaa90; }
  .linkbtn:hover { background: #eee5d9; }
  .linkbtn.danger:hover { background: #faeae4; }
  .customer-name:hover { color: var(--accent); text-decoration: underline; }
  .interactive-card:hover { border-color: #bfaa90; box-shadow: 0 12px 30px #30282114; }
  .interactive-row:hover, .detail-list-item:hover, .clickable-row:hover { background: #faf6ef; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}

/* Optional V11 sale attributes follow the primary sale fields. */
.analytics-chart svg { display: block; width: 100%; height: auto; max-height: 300px; }
