: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;
}

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; }
.portal-main > .card + .card { margin-top: 24px; }
.portal-main details { margin: 16px 0; }
.portal-main summary { cursor: pointer; }
.wholesale-cart-controls { display: grid; gap: 4px; max-width: 90px; }
.wholesale-cart-controls input { min-width: 0; width: 100%; }
.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; }
.compact { padding: 6px 9px; font-size: 12px; }
.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-customers { margin: 14px 0; }
.recent-customers h2 { font-size: 1.1rem; margin: 0 0 6px; }
.recent-customer > span { display: grid; gap: 2px; }
.recent-customer small { color: var(--muted); }
.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; }
.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-catalog { border-bottom: 1px solid var(--line); margin: 0 0 20px; padding: 4px 0 20px; }
.pos-catalog-heading { align-items: center; display: flex; gap: 12px; justify-content: space-between; margin-bottom: 12px; }
.pos-catalog-heading h3 { margin: 0; }
.pos-catalog.is-collapsed .pos-catalog-heading { margin-bottom: 0; }
.pos-catalog.is-collapsed .pos-catalog-heading > div,
.pos-catalog.is-collapsed .pos-catalog-layout { display: none; }
.pos-add-quantity { align-items: center; color: var(--muted); display: flex; font-size: 12px; gap: 8px; }
.pos-quantity-trigger { align-items: center; display: inline-flex; gap: 8px; min-height: 44px; min-width: 92px; }
.pos-quantity-trigger strong { color: var(--text); font-size: 18px; font-variant-numeric: tabular-nums; }
.pos-quantity-trigger span { color: var(--muted); font-size: 12px; }
.pos-quantity-dialog { background: var(--bg-card); border: 1px solid var(--line); border-radius: 8px; color: var(--text); margin: auto; max-width: 360px; padding: 20px; width: calc(100% - 32px); }
.pos-quantity-dialog::backdrop { background: rgba(0, 0, 0, .6); }
.pos-quantity-dialog-heading { align-items: center; display: flex; justify-content: space-between; margin-bottom: 16px; }
.pos-quantity-dialog-heading h3 { margin: 0; }
.pos-quantity-preview { color: var(--accent); font-size: 24px; font-variant-numeric: tabular-nums; font-weight: 700; min-width: 48px; text-align: right; }
.pos-quantity-keypad { display: grid; gap: 8px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.pos-quantity-keypad button { min-height: 56px; }
.pos-quantity-keypad button[data-pos-quantity-key="clear"],
.pos-quantity-keypad button[data-pos-quantity-key="backspace"] { font-size: 13px; }
.pos-quantity-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.pos-eyebrow { color: var(--accent); font-size: 11px; font-weight: 700; margin: 0 0 4px; }
.pos-order-entry { overflow: visible; }
.pos-catalog-toggle { display: inline-flex; min-height: 44px; }
.pos-order-entry button,
.pos-order-entry a,
.pos-order-entry input,
.pos-order-entry select,
.pos-order-entry textarea { touch-action: manipulation; }
.pos-order-entry input,
.pos-order-entry select,
.pos-order-entry textarea { font-size: 16px; }
.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-pagination { display: none; }
.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: #ffffff; border-radius: 4px; color: #333333; display: grid; gap: 3px; font-weight: 700; max-width: 100%; padding: 4px 6px; position: relative; text-align: center; z-index: 1; }
.pos-product-sku { color: inherit; font-family: var(--mono); font-size: 14px; 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 .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; }
.order-notes { display: block; margin-top: 12px; }
.order-notes textarea { display: block; width: 100%; margin-top: 4px; resize: vertical; }
.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 > .shipping-method-picker { display: block; margin: 10px 0; }
.shipping-method-picker label { max-width: 420px; }
.totals > div:first-child > strong { display: flex; gap: 18px; }
.totals .adjustment { grid-template-columns: 1fr 100px 120px 100px; }
.totals .shipping-adjustment.shipping-method-active { grid-template-columns: 1fr auto; }
.shipping-method-active [name="shippingType"],
.shipping-method-active [name="shippingValue"] { display: none; }
.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: 1100px), (any-hover: none) and (any-pointer: coarse) {
  .pos-catalog-heading { align-items: flex-start; flex-wrap: wrap; }
  .pos-catalog-toggle { display: inline-flex; flex: 0 0 100%; justify-content: center; min-height: 44px; }
  .pos-product-pagination:not([hidden]) { align-items: center; display: flex; gap: 12px; justify-content: center; margin-top: 14px; }
  .pos-product-pagination button { min-height: 44px; min-width: 92px; }
  .pos-product-pagination span { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
}

@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;
  }
}

@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%; }
}

@media print {
  header, .print-actions, .button, button, .order-note-dialog { display: none !important; }
  body { background: #ffffff; color: #000000; }
  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; }
}
