:root {
  --bg: #0f1419;
  --bg-elev: #171e26;
  --bg-card: #1c2530;
  --line: #2a3644;
  --text: #e8eef4;
  --muted: #8b9aab;
  --accent: #2dd4a8;
  --accent-dim: #0f3d32;
  --danger: #f07167;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --font: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

.split-unavailable { color: var(--muted); background: var(--bg-elev); opacity: .6; }
.split-unavailable input { cursor: not-allowed; }
.split-confirmation { display: flex; align-items: center; gap: .75rem; margin: 1rem 0; }
.split-confirmation input,
#split-order-form input[type="checkbox"] { width: auto; }
#split-order-form .table-scroll { overflow-x: auto; }

html[data-theme="light"] {
  --bg: #f4f7fb;
  --bg-elev: #ffffff;
  --bg-card: #fafdff;
  --line: #d7e0eb;
  --text: #243447;
  --muted: #64748b;
  --accent: #2563a8;
  --accent-dim: #e3edf8;
  --danger: #b42335;
  --shadow: 0 2px 6px rgba(36, 52, 71, .08), 0 10px 24px rgba(36, 52, 71, .06);
}

html[data-theme="light"] input,
html[data-theme="light"] select,
html[data-theme="light"] textarea {
  background: #ffffff;
  border-color: #aebed0;
  color: #243447;
}

html[data-theme="light"] .button:not(.secondary),
html[data-theme="light"] form button {
  color: #ffffff;
}

html[data-theme="light"] .customer-link {
  color: var(--accent);
}

html[data-theme="light"] header {
  background: #ffffff;
  border-bottom-color: #d7e0eb;
}

html[data-theme="light"] .card {
  border-radius: 12px;
}

html[data-theme="light"] .button:not(.secondary),
html[data-theme="light"] form button {
  background: var(--accent);
  border-color: var(--accent);
  color: #fffaf7;
}

html[data-theme="light"] .button:hover,
html[data-theme="light"] button:hover {
  border-color: #174b82;
}

html[data-theme="light"] main > .card > .grid:first-of-type > .card:nth-child(1) { background: #2563a8; }
html[data-theme="light"] main > .card > .grid:first-of-type > .card:nth-child(2) { background: #4f83b8; }
html[data-theme="light"] main > .card > .grid:first-of-type > .card:nth-child(3) { background: #64748b; }
html[data-theme="light"] main > .card > .grid:first-of-type > .card:nth-child(4) { background: #7896b5; }
html[data-theme="light"] main > .card > .grid:first-of-type > .card:nth-child(5) { background: #536273; }
html[data-theme="light"] main > .card > .grid:first-of-type > .card .help,
html[data-theme="light"] main > .card > .grid:first-of-type > .card strong {
  color: #fffaf7;
}

html[data-theme="dark"] {
  --bg: #080b10;
  --bg-elev: #101722;
  --bg-card: #151d28;
  --line: #303d4d;
  --text: #f2f5f8;
  --muted: #a5b2c0;
  --accent: #7dd3fc;
  --accent-dim: #12354a;
  --shadow: 0 10px 30px rgba(0, 0, 0, .5);
}

html[data-theme="colorful"] {
  --bg: #071a3d;
  --bg-elev: #0b2b68;
  --bg-card: #123d86;
  --line: #3764ae;
  --text: #ffffff;
  --muted: #d7e3ff;
  --accent: #ffffff;
  --accent-dim: #173c78;
  --danger: #ed1c24;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
}

html[data-theme="match"] {
  --bg: #f7f4ee;
  --bg-elev: #faf8f5;
  --bg-card: #ffffff;
  --line: #d8d1c5;
  --text: #2b3a31;
  --muted: #625e59;
  --accent: #2f4a3a;
  --accent-dim: #e9eee7;
  --danger: #9e3e3b;
  --radius: 8px;
  --shadow: 0 2px 12px rgba(43, 58, 49, .08);
  --font: "Assistant", "Trebuchet MS", sans-serif;
}

html[data-theme="match"] h1,
html[data-theme="match"] h2,
html[data-theme="match"] h3 { font-family: "Lora", Georgia, serif; font-weight: 400; }
html[data-theme="match"] header { background: #ffffff; }
html[data-theme="match"] input,
html[data-theme="match"] select,
html[data-theme="match"] textarea,
html[data-theme="match"] .address-autocomplete-results,
html[data-theme="match"] pre { background: #ffffff; border-color: #a9b3a9; color: var(--text); }
html[data-theme="match"] input[readonly] { background: var(--bg-elev); color: var(--muted); }
html[data-theme="match"] .button:not(.secondary),
html[data-theme="match"] form button { background: var(--accent); color: #ffffff; }
html[data-theme="match"] header nav a.button:not(.secondary) { color: #ffffff; }
html[data-theme="match"] .button.secondary { background: #ffffff; }
html[data-theme="match"] .button,
html[data-theme="match"] button,
html[data-theme="match"] .tag { border-radius: 6px; }
html[data-theme="match"] .notice { border-color: var(--accent); }
html[data-theme="match"] .address-actions button { color: #ffffff; }

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--text); font-family: var(--font); }
button, input, select, textarea { color: inherit; font: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }

header {
  align-items: center;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 12px;
  min-height: 64px;
  padding: 12px 5vw;
  position: sticky;
  top: 0;
  z-index: 20;
}
html[data-theme="colorful"] header {
  background: linear-gradient(105deg, #08245a 0%, #0b3d91 48%, #c51f32 100%);
  border-bottom: 3px solid #ed1c24;
}
html[data-theme="colorful"] .card {
  background: #123d86;
  border-color: #3764ae;
}
html[data-theme="colorful"] .button,
html[data-theme="colorful"] button {
  background: #0d3278;
  border-color: #4d78c4;
}
html[data-theme="colorful"] .button:not(.secondary),
html[data-theme="colorful"] form button {
  background: #ed1c24;
  border-color: #ff4a50;
  color: #fff;
}
html[data-theme="colorful"] .button:hover,
html[data-theme="colorful"] button:hover {
  border-color: #ffffff;
}
html[data-theme="colorful"] .button.secondary {
  color: #ffffff;
}
.brand { align-items: center; color: var(--text); display: inline-flex; font-weight: 700; gap: 8px; letter-spacing: .04em; text-decoration: none; }
.brand-logo { border-radius: 7px; height: 38px; object-fit: cover; width: 38px; }
.brand-name > span { color: var(--accent); }
header nav { align-items: center; color: var(--muted); display: inline-flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }
header nav a { color: inherit; }
header nav a.button { color: var(--text); text-decoration: none; }
header nav a.button:not(.secondary) { color: #06241c; }
.nav-user { font-size: 13px; padding: 0 4px; }
.theme-picker { align-items: center; color: var(--muted); display: inline-flex; gap: 5px; }
.theme-picker select { border-radius: 6px; padding: 4px 6px; }
.nav-toggle { background: none; border: 1px solid var(--line); border-radius: 8px; color: var(--text); display: none; font-size: 20px; line-height: 1; margin-left: auto; padding: 6px 10px; }

main { margin: 0 auto; max-width: 1296px; padding: 24px; }
.card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  overflow-x: auto;
}
.narrow { margin: 8vh auto; max-width: 440px; }
.customer-form-card { max-width: 760px; }
h1 { margin: 0 0 20px; }
h2 { margin: 28px 0 12px; }
.demo-entry { border-top: 1px solid var(--line); margin-top: 28px; padding-top: 2px; }
.demo-entry form { display: block; }
.demo-entry .help { margin-bottom: 12px; }

.toolbar { align-items: center; display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 18px; }
.toolbar h1 { margin: 0 auto 0 0; }
.button, button {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 13px;
  padding: 7px 10px;
  text-decoration: none;
}
.button:hover, button:hover { border-color: #3d4d5e; }
.portal-order-actions { display: grid; gap: 8px; min-width: 160px; }
.coupon-card { align-items: center; border: 1px solid var(--line); border-radius: 8px; display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; margin: 10px 0; padding: 12px; }
.coupon-card p { color: var(--muted); margin: 4px 0 0; }
.coupon-available-dot { background: #22c55e; border-radius: 50%; display: inline-block; height: 8px; margin-left: 8px; vertical-align: middle; width: 8px; }
.settings-dashboard-nav { display: grid; gap: 20px; margin-bottom: 24px; }
.settings-dashboard-nav h2 { font-size: 1.1rem; margin: 0 0 10px; }
.settings-dashboard-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }
.settings-dashboard-button { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; min-height: 90px; padding: 16px; text-align: left; white-space: normal; }
.settings-dashboard-button span { color: var(--muted); font-size: .85rem; font-weight: normal; }
.settings-dashboard-button.is-selected { border-color: var(--accent); background: var(--accent-dim); }
.settings-dashboard-ready > .settings-dashboard-panel { background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius); margin-top: 20px; padding: 20px; scroll-margin-top: 20px; }
.settings-dashboard-ready > .settings-dashboard-panel[hidden] { display: none; }
.settings-dashboard-panel > summary { cursor: default; display: block; font-size: 1.2rem; list-style: none; margin-bottom: 16px; }
.settings-dashboard-panel > summary::-webkit-details-marker { display: none; }
.settings-dashboard-panel > summary span { display: block; color: var(--muted); font-size: .9rem; margin-top: 4px; }
.settings-dashboard-panel .settings-grid-form, .settings-dashboard-panel .settings-inline-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); align-items: end; }
.settings-dashboard-panel .settings-full { grid-column: 1 / -1; }
.settings-dashboard-panel .settings-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.settings-dashboard-panel .settings-table-wrap { overflow-x: auto; }
.wholesale-coupon-dialog { background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius); color: var(--text); max-height: calc(100dvh - 32px); max-width: 620px; overflow-y: auto; padding: 24px; width: calc(100% - 32px); }
.wholesale-coupon-dialog::backdrop { background: rgba(0, 0, 0, .65); }
.portal-order-actions > .button {
  align-items: center;
  display: flex;
  justify-content: center;
  line-height: 1.4;
  min-height: 36px;
  text-align: center;
  white-space: normal;
}
.portal-order-actions > .help { margin: 0; }
.portal-orders td, #invoices td { vertical-align: top; }
.wholesale-account-summary { display: flex; justify-content: flex-end; margin-bottom: 20px; }
.wholesale-balance { max-width: 360px; text-align: right; width: 100%; }
.wholesale-balance h2 { font-size: 16px; margin: 0 0 8px; }
.wholesale-balance > strong { color: var(--accent); display: block; font-size: 26px; overflow-wrap: anywhere; }
.wholesale-balance .help { font-size: 12px; margin: 8px 0 0; }
.compact { padding: 6px 9px; font-size: 12px; }
.all-order-actions { align-items: center; display: flex; flex-wrap: nowrap; gap: 6px; white-space: nowrap; }
.all-order-actions form { margin: 0; }
.button:not(.secondary), form button { background: var(--accent); border-color: transparent; color: #06241c; font-weight: 700; }
.secondary { color: var(--text); }
button:disabled,
button[disabled],
.button.disabled,
.button[aria-disabled="true"] {
  background: var(--bg-card) !important;
  border-color: var(--line) !important;
  color: var(--muted) !important;
  cursor: not-allowed;
  opacity: .55;
  pointer-events: none;
}

form { display: grid; gap: 15px; }
.inline-form { display: inline; }
.customer-link { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; text-align: left; text-decoration: underline; }
.password-form { align-items: center; display: inline-flex; gap: 6px; }
.password-form input { padding: 6px 8px; width: 150px; }
label { color: var(--muted); display: grid; font-size: 13px; gap: 6px; }
.checkbox-row { align-items: center; display: flex; gap: 8px; }
.checkbox-row input { width: auto; }
input, select, textarea {
  box-sizing: border-box;
  background: #0b1015;
  border: 1px solid #4a5d70;
  border-radius: 10px;
  padding: 10px 12px;
  width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: 2px solid var(--accent); }
input[readonly] { background: #151d25; color: var(--muted); cursor: not-allowed; }
input[type="date"] { max-width: 170px; width: auto; }
small { color: var(--muted); font-weight: 400; }
.grid { display: grid; gap: 10px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.payment-terms-inline { display: flex; flex-direction: column; gap: 4px; }
.payment-terms-inline-fields { display: flex; gap: 8px; }
.payment-terms-inline-fields select { flex: 1 1 auto; min-width: 0; }
.payment-terms-inline-fields input[type="date"] { flex: 0 0 auto; }
.customer-results, .price-lookup-results { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; max-height: 320px; overflow-y: auto; }
.customer-result, .price-lookup-result { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; }
.recent-customer > span { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; }
.price-lookup-result { justify-content: space-between; }
.price-lookup-result strong { flex: 0 0 auto; }
.price-lookup-result span:first-of-type { flex: 1 1 auto; }
.shopify-insights > .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.table-filter { display: block; max-width: 360px; margin: 16px 0; }
.tag { background: var(--accent-dim); border: 1px solid var(--accent); border-radius: 999px; color: var(--text); display: inline-block; font-size: 13px; margin: 2px 4px 2px 0; padding: 4px 9px; }
.tag-remove { background: transparent; border: 0; color: inherit; font-size: 14px; padding: 0 0 0 4px; }
.tag-form { align-items: end; display: flex; gap: 8px; }
.tag-form label { flex: 1; }
.address-grid { display: grid; gap: 32px; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 28px 0; }
.address-grid address { color: var(--muted); font-style: italic; line-height: 1.5; }
.address-autocomplete-wrap { position: relative; }
.address-autocomplete-results { background: #0b1015; border: 1px solid #4a5d70; border-radius: 10px; list-style: none; margin: 4px 0 0; max-height: 220px; overflow-y: auto; padding: 0; position: absolute; width: 100%; z-index: 20; }
.address-autocomplete-results:empty { border: none; }
.address-autocomplete-results li { cursor: pointer; font-size: 13px; padding: 8px 12px; }
.address-autocomplete-results li:hover { background: var(--accent-dim); }
.order-header-grid { display: grid; gap: 24px; grid-template-columns: 1fr 1fr; }
.customer-summary { border-bottom: 1px solid var(--line); display: grid; gap: 4px; margin-bottom: 12px; padding-bottom: 12px; }
.customer-summary strong { color: var(--text); font-weight: 600; }
.shipping-summary { border-left: 1px solid var(--line); color: var(--muted); padding-left: 24px; }
.shipping-summary strong { color: var(--accent); display: block; margin-bottom: 8px; }
.shipping-summary address { line-height: 1.5; white-space: pre-line; }
.customer-tags { align-items: center; display: flex; flex-wrap: wrap; justify-content: flex-end; margin: 0 0 10px; min-height: 24px; }
.customer-tags .tag { margin: 2px 0 2px 6px; }
.address-picker { align-items: end; display: grid; gap: 10px; grid-template-columns: 1fr auto; margin: 12px 0; }
.address-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.address-actions button { color: #000; padding: 6px 8px; white-space: nowrap; }
.address-details { margin-top: 16px; }
.address-details summary { color: var(--accent); cursor: pointer; font-weight: 700; padding: 8px 0; }
.address-details .address-grid { align-items: center; gap: 10px; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); }
.address-copy-button { border-radius: 50%; font-size: 16px; height: 36px; line-height: 1; padding: 0; width: 36px; }
.pos-mode-link { display: inline-flex; margin-bottom: 16px; }
.pos-catalog { border-bottom: 1px solid var(--line); margin: 0 0 20px; padding: 4px 0 20px; }
.pos-catalog-heading { align-items: center; display: flex; justify-content: space-between; margin-bottom: 12px; }
.pos-catalog-heading h3 { margin: 0; }
.pos-add-quantity { align-items: center; color: var(--muted); display: flex; font-size: 12px; gap: 6px; }
.pos-add-quantity input { padding: 7px 8px; text-align: center; width: 64px; }
.pos-eyebrow { color: var(--accent); font-size: 11px; font-weight: 700; margin: 0 0 4px; }
.pos-catalog-layout { display: grid; gap: 20px; grid-template-columns: 180px minmax(0, 1fr) 190px; }
.pos-categories { border-right: 1px solid var(--line); padding-right: 16px; }
.pos-section-label { color: var(--muted); font-size: 11px; font-weight: 700; margin: 0 0 8px; text-transform: uppercase; }
.pos-category-list { display: grid; gap: 4px; }
.pos-category { background: transparent; border: 1px solid transparent; color: var(--muted); padding: 9px 10px; text-align: left; }
.pos-category:hover, .pos-category.active { background: var(--accent-dim); border-color: var(--accent); color: var(--text); }
.pos-products { min-width: 0; }
.pos-register-panel { align-self: start; border-left: 1px solid var(--line); max-height: calc(100vh - 96px); min-width: 0; overflow-y: auto; padding-left: 16px; position: sticky; top: 80px; }
.pos-register-heading { align-items: baseline; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; margin-bottom: 4px; padding-bottom: 8px; }
.pos-register-heading .pos-section-label { margin: 0; }
.pos-register-heading > span { color: var(--muted); font-size: 10px; }
.pos-register-list { display: grid; gap: 2px; }
.pos-register-row { align-items: center; display: grid; gap: 8px; grid-template-columns: minmax(0, 1fr) auto; padding: 7px 0; }
.pos-register-row span { font-family: var(--mono); font-size: 12px; overflow-wrap: anywhere; }
.pos-register-row strong { color: var(--accent); font-variant-numeric: tabular-nums; }
.pos-search-label { margin-bottom: 14px; }
.pos-product-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.pos-product { align-items: center; aspect-ratio: 4 / 3; background-color: transparent; display: flex; flex-direction: column; justify-content: center; min-height: 0; overflow: hidden; padding: 14px; position: relative; text-align: center; white-space: normal; }
html[data-theme] form .pos-product { background-color: transparent !important; }
.pos-product-image { height: 150px; left: 50%; object-fit: contain; position: absolute; top: 50%; transform: translate(-50%, -50%); width: 150px; }
.pos-product-copy { background: rgba(128, 128, 128, .3); border-radius: 4px; color: #ffffff; display: grid; gap: 5px; font-weight: 700; max-width: 100%; padding: 7px 10px; position: relative; text-align: center; z-index: 1; }
.pos-product-sku { color: inherit; font-family: var(--mono); font-size: 11px; font-weight: 700; }
.pos-product strong { color: inherit; font-size: 14px; line-height: 1.3; }
.pos-product-copy > span:not(.pos-product-sku) { color: inherit; font-size: 12px; overflow-wrap: anywhere; }
.pos-product-copy > span.pos-product-stock { color: #8ef0b4; font-size: 11px; line-height: 1.25; }
.pos-product-copy > span.pos-product-stock.out { color: #ffb4ae; }
.pos-register-row .pos-product-stock.out,
.wholesale-classic .pos-product-stock.out { color: var(--danger); }
.pos-product-copy > span.pos-product-action { background: var(--danger); border-radius: 999px; color: #fff; font-size: 11px; justify-self: center; padding: 2px 8px; }
.pos-register-row .pos-product-stock,
.wholesale-classic .pos-product-stock { display: block; font-family: var(--font); font-size: 11px; font-weight: 700; }
.pos-product .pos-product-price { color: var(--accent); font-size: 15px; font-variant-numeric: tabular-nums; font-weight: 700; margin-top: auto; }
.pos-cart-bar { display: none; }
.line-editor { border-top: 1px solid var(--line); margin-top: 18px; padding-top: 12px; }
.line-editor-head { align-items: center; display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; }
.line-editor-head h3 { margin: 0; }
.line-actions { display: flex; gap: 8px; }
.csv-import-line { align-items: center; display: flex; font-size: 12px; gap: 6px; }
.line-header,
.line-row { display: grid; gap: 8px; grid-template-columns: 1.1fr 1.5fr .8fr .55fr .7fr auto; }
.line-header { color: var(--muted); font-size: 12px; margin-top: 12px; text-transform: uppercase; }
.line-row { align-items: center; margin: 8px 0; }
.line-row input { min-width: 0; }
.sku-control { display: grid; gap: 4px; grid-template-columns: minmax(0, 1fr) auto; }
.sku-control button { padding: 7px; }
.add-lines-button { margin-top: 8px; }
.line-total { font-variant-numeric: tabular-nums; text-align: right; }
.totals { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 12px; }
.totals > div { align-items: center; display: grid; grid-template-columns: 1fr auto; gap: 10px; margin: 8px 0; }
.totals > div:first-child > strong { display: flex; gap: 18px; }
.totals .adjustment { grid-template-columns: 1fr 100px 120px 100px; }
.totals .total { border-top: 1px solid var(--line); font-size: 18px; margin-top: 12px; padding-top: 12px; }
.order-finalize-actions { align-items: center; display: flex; flex-wrap: wrap; gap: 24px; margin-top: 18px; }
.order-finalize-actions form { margin: 0; }
.order-totals { margin-left: auto; max-width: 320px; text-align: right; }
.order-totals > div { display: flex; justify-content: space-between; gap: 24px; padding: 3px 0; }
.order-totals .total { border-top: 1px solid var(--line); font-size: 1.1em; font-weight: 700; margin-top: 5px; padding-top: 8px; }
.order-note { background: var(--bg-elev); border: 1px solid var(--line); border-radius: 10px; margin: 20px 0; padding: 12px 16px; }
.order-note p { line-height: 1.5; margin: 0; white-space: normal; }
.order-note-dialog { background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius); color: var(--text); max-width: 620px; padding: 24px; width: calc(100% - 32px); }
.order-note-dialog::backdrop { background: rgba(0, 0, 0, .65); }
.order-tracking { margin: 20px 0; }
.order-tracking summary { color: var(--text); cursor: pointer; font-size: 1.25em; font-weight: 700; padding: 8px 0; }
.print-actions { align-items: center; display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }
.grid .card { box-shadow: none; text-align: center; }
.dashboard-metric { color: inherit; display: block; text-decoration: none; }
.dashboard-metric:hover { border-color: var(--accent); transform: translateY(-1px); }
.grid .card > strong { display: block; font-size: 28px; }
html[data-theme="light"] main > .card > .grid:first-of-type > .card {
  border: 0;
  color: #ffffff;
  min-height: 112px;
  padding: 20px 16px;
}
html[data-theme="light"] main > .card > .grid:first-of-type > .card:nth-child(1) { background: #b85c4b; }
html[data-theme="light"] main > .card > .grid:first-of-type > .card:nth-child(2) { background: #d18b78; }
html[data-theme="light"] main > .card > .grid:first-of-type > .card:nth-child(3) { background: #6f8f86; }
html[data-theme="light"] main > .card > .grid:first-of-type > .card:nth-child(4) { background: #d8aa72; }
html[data-theme="light"] main > .card > .grid:first-of-type > .card:nth-child(5) { background: #806b63; }
html[data-theme="light"] main > .card > .grid:first-of-type > .card .help { color: rgba(255, 255, 255, .88); }
html[data-theme="light"] main > .card > .shopify-insights {
  border-color: #d7e0eb;
}
pre { background: #0b1015; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); overflow: auto; padding: 12px; white-space: pre-wrap; }

table { border-collapse: collapse; margin: 18px 0; min-width: 0; width: 100%; }
th, td { border-bottom: 1px solid var(--line); padding: 12px 8px; text-align: left; white-space: nowrap; }
th { max-width: 420px; min-width: 90px; overflow: hidden; resize: horizontal; }
td { max-width: 520px; overflow: hidden; text-overflow: ellipsis; white-space: normal; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; }
th[data-sort-index] { cursor: pointer; }
th[data-sort-index]::after { content: " ↕"; opacity: .55; }
th[data-sort-index][data-sort-direction="asc"]::after { content: " ↑"; }
th[data-sort-index][data-sort-direction="desc"]::after { content: " ↓"; }
.notice { background: var(--accent-dim); border: 1px solid #1d6b56; border-radius: 10px; color: var(--accent); padding: 12px; }
.notice.error { border-color: var(--danger); color: var(--danger); }
.notice-inline { display: block; }
.notice-inline:not(:empty) { color: var(--danger); }
.help { color: var(--muted); line-height: 1.45; }

.draft-search { display: flex; align-items: flex-end; gap: 10px; margin: 10px 0 16px; flex-wrap: wrap; }
.draft-search label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted, #666); flex: 1 1 260px; }
.draft-search input { padding: 8px 10px; }
.draft-search label:has(input[type="checkbox"]) { flex-direction: row; align-items: center; }
.date-range-group { display: flex; gap: 10px; flex: 0 0 auto; }
.date-range-group label { flex: 0 0 auto; }
.import-panel { border-top: 1px solid var(--line); margin: 24px 0; padding-top: 4px; }
.import-panel h2 { margin-top: 0; }
.lead-details { border: 1px solid var(--line); border-radius: 10px; margin: 18px 0; padding: 16px; }
.lead-details legend { color: var(--text); font-weight: 700; padding: 0 8px; }
.task-detail-grid { display: grid; gap: 16px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.task-detail-grid > div { background: var(--bg-elev); border: 1px solid var(--line); border-radius: 10px; padding: 14px; }
.task-detail-grid p { margin-bottom: 0; }
.task-description { background: var(--bg-elev); border: 1px solid var(--line); border-radius: 10px; line-height: 1.7; padding: 16px; }
.task-detail-actions { margin-top: 20px; }
.task-edit-form { border-top: 1px solid var(--line); display: grid; gap: 14px; margin-top: 24px; padding-top: 20px; }
.task-edit-form textarea { font-family: inherit; min-height: 260px; resize: vertical; }
.task-bulk-actions { display: flex; gap: 10px; margin: 12px 0; }
.task-bulk-actions .danger { background: var(--danger); color: #fff; }
button.danger, a.button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.task-pagination { align-items: center; display: flex; justify-content: space-between; gap: 12px; margin-top: 16px; }

code { color: var(--accent); font-family: var(--mono); }
.hidden { display: none !important; }

@media (max-width: 650px) {
  header { flex-wrap: wrap; padding: 10px 16px; row-gap: 8px; }
  .nav-toggle { display: inline-block; }
  header nav {
    background: var(--bg-elev);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: var(--shadow);
    display: none;
    flex-basis: 100%;
    flex-direction: column;
    align-items: stretch;
    font-size: 13px;
    gap: 4px;
    margin: 8px 0 0;
    padding: 10px;
  }
  header.nav-open nav { display: flex; }
  header nav a.button, header nav button:not(.nav-toggle) { justify-content: flex-start; text-align: left; width: 100%; }
  .nav-user { order: -1; padding: 4px 4px 8px; }
  .theme-picker { flex-wrap: wrap; font-size: 12px; justify-content: space-between; width: 100%; }
  main { padding: 12px; }
  .card { overflow-x: auto; padding: 16px; }
  .pos-order-entry { margin-bottom: 84px; overflow: visible; }
  .pos-order-entry form { padding-bottom: 12px; }
  .pos-catalog { margin-top: 8px; }
  .pos-catalog-layout { grid-template-columns: 1fr; }
  .pos-categories { border-bottom: 1px solid var(--line); border-right: 0; overflow-x: auto; padding: 0 0 10px; }
  .pos-category-list { display: flex; gap: 6px; }
  .pos-category { flex: 0 0 auto; white-space: nowrap; }
  .pos-register-panel { border-left: 0; border-top: 1px solid var(--line); max-height: none; padding-left: 0; padding-top: 12px; position: static; }
  .pos-order-entry .empty-line { display: none; }
  .pos-product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pos-product { min-width: 0; min-height: 112px; padding: 12px; }
  .pos-product strong { overflow-wrap: anywhere; }
  .pos-cart-bar {
    align-items: center;
    background: var(--bg-elev);
    border-top: 1px solid var(--line);
    bottom: 0;
    display: flex;
    gap: 16px;
    justify-content: space-between;
    left: 0;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    position: fixed;
    right: 0;
    z-index: 25;
  }
  .pos-cart-bar > span { display: grid; gap: 2px; }
  .pos-cart-count { color: var(--muted); font-size: 12px; }
  .pos-cart-total { font-size: 18px; font-variant-numeric: tabular-nums; }
  .pos-cart-bar .pos-checkout { min-height: 44px; min-width: 132px; }
  .grid { grid-template-columns: 1fr; }
  .task-detail-grid { grid-template-columns: 1fr; }
  .shopify-insights > .grid { grid-template-columns: 1fr; }
  .address-grid { grid-template-columns: 1fr; }
  .address-details .address-grid,
  .address-picker,
  .order-header-grid { grid-template-columns: 1fr; }
  .shipping-summary { border-left: 0; border-top: 1px solid var(--line); padding-left: 0; padding-top: 12px; }
  .line-row { grid-template-columns: 1fr 1fr; }
  .line-header { display: none; }
  .line-row .line-description { grid-column: 1 / -1; }
  .line-row .remove-line { grid-column: 1 / -1; }
  .totals .adjustment { grid-template-columns: 1fr 90px 100px; }
  .totals .adjustment strong { grid-column: 2 / -1; text-align: right; }
  .order-finalize-actions { align-items: stretch; flex-direction: column; gap: 12px; }
  .order-finalize-actions form,
  .order-finalize-actions button { width: 100%; }
  .line-actions { flex-wrap: wrap; }
  .line-actions button { flex: 1 1 auto; }
  .address-actions { justify-content: stretch; }
  .address-actions button { flex: 1 1 auto; }
  .toolbar { align-items: flex-start; }
  .toolbar h1 { flex-basis: 100%; }
  table { font-size: 13px; }
  .draft-search { flex-direction: column; align-items: stretch; }
  .draft-search label { flex-basis: auto; }
  .date-range-group { flex-direction: column; }
  .tag-form { flex-direction: column; align-items: stretch; }
  .task-bulk-actions { flex-wrap: wrap; }
  .button, button { min-height: 40px; }
  input, select, textarea { font-size: 16px; }
  /* Wide tables scroll horizontally inside their card on mobile; pin the last
     action column (e.g. Delete/Sync buttons) so it stays reachable without
     having to scroll all the way to the right edge. */
  table td:last-child, table th:last-child {
    background: var(--bg-card);
    position: sticky;
    right: 0;
    white-space: nowrap;
    z-index: 1;
  }
  .portal-orders td:last-child, .portal-orders th:last-child,
  #invoices td:last-child, #invoices th:last-child {
    position: static;
    white-space: normal;
  }
}

.quick-order-page { overflow: visible; }
.quick-order-page > .toolbar { align-items: flex-start; justify-content: space-between; }
.quick-order-page h1 { margin-bottom: 4px; }
.quick-order-categories { background: var(--bg-elev); border: 1px solid var(--line); border-radius: 10px; display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 16px 0 10px; padding: 14px 16px; }
.quick-order-category { align-items: center; cursor: pointer; display: inline-flex; font-size: 14px; gap: 6px; margin: 0; }
.quick-order-category input, .quick-order-check input { min-height: 0; width: auto; }
.quick-order-count { color: var(--muted); font-size: 13px; margin: 0 0 12px; }
.quick-order-controls { align-items: end; display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 14px; }
.quick-order-controls > label { flex: 1 1 180px; margin: 0; }
.quick-order-controls > .quick-order-check { align-items: center; display: inline-flex; flex: 0 0 auto; gap: 8px; min-height: 42px; }
.quick-order-controls > button { flex: 0 0 auto; }
.quick-order-export { background: #1f9d55; border-color: #1f9d55; color: #fff; }
.quick-order-add { background: #111; border-color: #111; color: #fff; }
.quick-order-layout { align-items: start; display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr) 260px; }
.quick-order-catalog { min-width: 0; }
.quick-order-register { align-self: start; background: var(--bg-elev); border: 1px solid var(--line); border-radius: 10px; display: flex; flex-direction: column; max-height: calc(100dvh - 112px); min-height: 0; min-width: 0; padding: 16px; position: sticky; top: 96px; }
.quick-order-register h2 { flex-shrink: 0; font-size: 18px; margin: 0 0 12px; }
.quick-order-register-list { min-height: 0; overflow-y: auto; }
.quick-order-register-row { border-bottom: 1px solid var(--line); display: grid; gap: 8px; grid-template-columns: minmax(0, 1fr) auto; padding: 10px 0; }
.quick-order-register-details { display: grid; gap: 4px; overflow-wrap: anywhere; }
.quick-order-register-details .quick-order-sku { white-space: normal; }
.quick-order-register-details > span { font-size: 12px; }
.quick-order-register-controls { align-items: end; display: flex; flex-direction: column; gap: 8px; }
.quick-order-register-controls button { font-size: 11px; padding: 4px 8px; }
.quick-order-register-summary { border-top: 1px solid var(--line); flex-shrink: 0; margin-top: 12px; padding-top: 12px; }
.quick-order-register-summary .button { display: block; text-align: center; }
.quick-order-table-wrap { border: 1px solid var(--line); border-radius: 10px; max-height: 70vh; overflow: auto; }
.quick-order-table { border-collapse: collapse; min-width: 860px; width: 100%; }
.quick-order-table th { background: var(--bg-elev); font-size: 12px; letter-spacing: .04em; position: sticky; text-transform: uppercase; top: 0; z-index: 1; }
.quick-order-table th, .quick-order-table td { border-bottom: 1px solid var(--line); padding: 10px 12px; text-align: left; vertical-align: middle; }
.quick-order-image { width: 86px; }
.quick-order-image img { border-radius: 8px; display: block; height: 70px; object-fit: cover; width: 70px; }
.quick-order-sku { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 700; white-space: nowrap; }
.quick-order-pill { background: #fde2ec; border-radius: 999px; color: #9d174d; display: inline-block; font-size: 12px; padding: 3px 10px; }
.quick-order-stock { color: #22a35a; font-weight: 600; white-space: nowrap; }
.quick-order-stock.out { color: var(--danger); white-space: normal; }
.quick-order-preorder { color: var(--danger); display: block; font-size: 11px; font-weight: 700; margin-top: 4px; }
.quick-order-qty { max-width: 90px; text-align: center; }
.quick-order-qty[aria-invalid="true"] { border-color: var(--danger); }
.quick-order-review { border-top: 1px solid var(--line); margin-top: 24px; padding-top: 16px; scroll-margin-top: 16px; }
@media (max-width: 900px) {
  .quick-order-layout { grid-template-columns: minmax(0, 1fr); }
  .quick-order-register { grid-row: 1; max-height: none; position: static; }
  .quick-order-register-list { max-height: 240px; }
}
@media (max-width: 420px) {
  .toolbar { gap: 8px; }
  .task-bulk-actions { flex-direction: column; align-items: stretch; }
  .task-bulk-actions .button, .task-bulk-actions button { width: 100%; }
}

.order-invoice { display: none; }
.order-print-frame { position: fixed; left: -10000px; top: 0; width: 800px; height: 1000px; border: 0; }

@media print {
  *, *::before, *::after {
    background: none !important;
    color: #000000 !important;
    border-color: #666666 !important;
    box-shadow: none !important;
    text-shadow: none !important;
  }
  body:has(.invoice-profile-required) main > :not(.invoice-profile-required) { display: none !important; }
  body:has(.order-invoice) .demo-banner,
  body:has(.order-invoice) main > :not(.order-invoice) { display: none !important; }
  .order-invoice {
    display: block;
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    padding: 10px 30px;
    overflow-wrap: anywhere;
  }
  .order-packing-list { display: none; }
  body[data-print-document="packing-list"] .order-invoice:not(.order-packing-list) { display: none; }
  body[data-print-document="packing-list"] .order-packing-list { display: block; }
  body[data-print-document="both"] .order-packing-list { display: block; break-before: page; }
  .order-packing-list .invoice-summary { grid-template-columns: minmax(0, 1fr); }
  .order-invoice p { margin: 0 0 8px; }
  .invoice-header { display: flex; justify-content: space-between; gap: 24px; margin-bottom: 30px; }
  .invoice-brand { display: flex; align-items: center; gap: 12px; color: var(--accent); font-family: var(--font); font-size: 24px; }
  html[data-theme="match"] .invoice-brand { font-family: "Lora", Georgia, serif; }
  .invoice-brand img { width: 65px; height: 45px; object-fit: contain; }
  .invoice-heading { text-align: right; }
  .order-number-barcode { display: block; width: 2in; max-width: 100%; height: 40px; margin: 0 0 6px auto; }
  .invoice-heading { width: 262px; max-width: 100%; }
  .invoice-header { flex-wrap: wrap; }
  .invoice-checklist { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; width: max-content; margin: 20px 0 0 auto; }
  .invoice-checklist > span { display: inline-flex; align-items: center; gap: 6px; }
  .invoice-checkbox { display: inline-block; width: 12px; height: 12px; border: 1px solid currentColor; }
  .order-invoice .invoice-items .invoice-item-check { width: 20px; text-align: center; padding-left: 4px; padding-right: 4px; }
  .invoice-addresses { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; margin-bottom: 20px; }
  .order-invoice h2 { color: var(--accent); font-family: var(--font); font-size: 13px; font-weight: 400; text-transform: uppercase; margin: 0 0 8px; }
  .invoice-details { text-align: right; }
  .order-invoice .invoice-items { width: 100%; border-collapse: collapse; border-top: 2px solid var(--accent); border-bottom: 2px solid var(--accent); }
  .order-invoice .invoice-items th { background: var(--bg-elev); color: var(--accent); text-transform: uppercase; font-size: 13px; }
  .order-invoice .invoice-items th, .order-invoice .invoice-items td { padding: 5px 8px; border-bottom: 1px solid var(--accent); text-align: right; font-size: 12px; line-height: 1.25; }
  .order-invoice .invoice-items th:first-child, .order-invoice .invoice-items td:first-child { text-align: left; width: 11%; }
  .order-invoice .invoice-items th:nth-child(2), .order-invoice .invoice-items td:nth-child(2) { text-align: left; width: 62%; }
  .order-invoice .invoice-items th:nth-child(n+3), .order-invoice .invoice-items td:nth-child(n+3) { white-space: nowrap; overflow-wrap: normal; padding-left: 3px; padding-right: 3px; }
  .invoice-item-sku { font-weight: bold; }
  .invoice-items thead { display: table-header-group; }
  .invoice-items tfoot { display: table-row-group; font-weight: bold; }
  .order-invoice .invoice-items tfoot th { text-align: left; }
  .invoice-items tr { break-inside: avoid; }
  .invoice-summary { display: grid; grid-template-columns: 2fr 1fr; gap: 30px; margin-top: 15px; }
  .invoice-summary dl { margin: 0; border-bottom: 2px solid var(--accent); }
  .invoice-summary dl > div { display: flex; justify-content: space-between; gap: 20px; margin: 12px 0; break-inside: avoid; }
  .invoice-summary dd { margin: 0; white-space: nowrap; }
  .invoice-total { font-weight: bold; text-transform: uppercase; color: var(--accent); }
  .invoice-footer { margin-top: 30px; text-align: center; break-inside: avoid; }
  header, .print-actions, .button, button, .order-note-dialog, .wholesale-coupon-dialog { display: none !important; }
  main { max-width: none; padding: 0; }
  .card { border: 0; box-shadow: none; padding: 0; }
  .address-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .order-totals { color: #000000; }
}
