:root {
  --ink: #17181d;
  --muted: #68707c;
  --line: #dfe5ea;
  --paper: #fff7fb;
  --surface: #ffffff;
  --accent: #ff6fae;
  --accent-dark: #c93377;
  --secondary: #2ec4b6;
  --warm: #ffd166;
  --card: #ffffff;
  --soft: #fff0f7;
  --green-bg: #e7f6ee;
  --green-text: #16603d;
  --red-bg: #fff0ed;
  --red-text: #9a341f;
  --shadow: 0 16px 36px rgba(64, 40, 68, 0.12);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background:
    radial-gradient(circle at 12px 12px, color-mix(in srgb, var(--accent) 18%, transparent) 0 2px, transparent 2px 100%),
    linear-gradient(135deg, var(--paper), #f4fffd 48%, #fff8df);
  background-size: 28px 28px, auto;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}
body.theme-classic { background: var(--paper); }
body.theme-mint {
  background:
    radial-gradient(circle at 12px 12px, rgba(46, 196, 182, 0.16) 0 2px, transparent 2px 100%),
    linear-gradient(135deg, var(--paper), #f5fff7 48%, #fff7e6);
  background-size: 28px 28px, auto;
}
body.theme-sunny {
  background:
    radial-gradient(circle at 12px 12px, rgba(255, 209, 102, 0.24) 0 2px, transparent 2px 100%),
    linear-gradient(135deg, var(--paper), #fff8df 48%, #f3fffb);
  background-size: 28px 28px, auto;
}
button, input, select, textarea { font: inherit; }
.shell { width: min(1120px, calc(100% - 32px)); margin: 0 auto; padding: 28px 0 52px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 18px; }
body[data-page="order"] .topbar { display: none; }
.eyebrow { color: var(--accent-dark); font-size: 12px; font-weight: 900; text-transform: uppercase; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(28px, 5vw, 48px); line-height: 1.05; }
h2 { font-size: 24px; }
h3 { font-size: 16px; }
.muted { color: var(--muted); font-size: 14px; }
.layout { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(300px, .65fr); gap: 18px; align-items: start; }
.panel, .summary, .receipt, .admin-panel, .loading-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.panel, .receipt, .admin-panel, .loading-card { padding: 24px; }
.summary { padding: 20px; position: sticky; top: 18px; display: grid; gap: 16px; }
.order-banner {
  width: 100%;
  aspect-ratio: 7 / 1;
  min-height: 104px;
  max-height: 168px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line));
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}
.order-banner img { width: 100%; height: 100%; object-fit: cover; display: block; }
.order-hero {
  position: relative;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--accent) 34%, var(--line));
  border-radius: 8px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 18%, #fff), color-mix(in srgb, var(--secondary) 15%, #fff)), var(--card);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
  padding: 22px;
}
.hero-badge {
  width: fit-content;
  max-width: 100%;
  border: 1px solid rgba(255, 255, 255, .9);
  border-radius: 8px;
  background: rgba(255, 255, 255, .78);
  color: var(--accent-dark);
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}
.hero-copy { display: grid; gap: 10px; max-width: 740px; }
.hero-copy h2 { font-size: clamp(30px, 6vw, 56px); line-height: 1.02; }
.hero-title { display: grid; gap: 3px; }
.hero-title small { display: block; color: var(--accent-dark); font-size: clamp(16px, 3vw, 24px); font-weight: 900; }
.order-tabs-wrap {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  margin: 0 0 14px;
}
.order-tabs-label {
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 900;
}
.order-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
}
.order-tabs button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .86);
  color: var(--ink);
  font-weight: 900;
  padding: 0 14px;
  white-space: nowrap;
}
.order-tabs button.active {
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), var(--secondary));
  color: #fff;
}
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
label { display: grid; gap: 7px; font-size: 13px; font-weight: 800; color: #2c333d; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  min-height: 44px;
  padding: 10px 12px;
  outline: none;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.products { display: grid; gap: 10px; margin: 18px 0; }
.products.products-invalid {
  border: 2px solid #e2518f;
  border-radius: 8px;
  background: var(--red-bg);
  padding: 10px;
}
.products.products-invalid .product-row { border-color: #e2518f; }
.product-row {
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr) 118px;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid color-mix(in srgb, var(--accent) 20%, var(--line));
  border-radius: 8px;
  background: linear-gradient(180deg, #fff, color-mix(in srgb, var(--soft) 72%, #fff));
}
.product-row.sold-out { opacity: .58; }
.product-media, .product-preview {
  width: 100%;
  aspect-ratio: 4 / 3;
  border: 1px solid color-mix(in srgb, var(--secondary) 24%, var(--line));
  border-radius: 8px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 14%, #fff), color-mix(in srgb, var(--secondary) 18%, #fff));
  overflow: hidden;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.product-media img, .product-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.product-group { display: grid; gap: 10px; }
.product-group-title { padding-top: 6px; color: var(--accent-dark); font-size: 15px; font-weight: 900; }
.price { color: var(--accent-dark); font-weight: 900; white-space: nowrap; }
.stock-note { color: var(--muted); font-size: 12px; font-weight: 700; }
.line-item, .admin-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; border-bottom: 1px solid var(--line); padding: 10px 0; }
.line-item:last-child, .admin-row:last-child { border-bottom: 0; }
.total { display: flex; justify-content: space-between; align-items: baseline; border-top: 1px solid var(--line); padding-top: 16px; font-weight: 900; }
.total strong { font-size: 30px; color: var(--accent-dark); }
.primary-button, .ghost-button, .danger-button, .icon-button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  text-decoration: none;
}
.primary-button { background: linear-gradient(135deg, var(--accent), var(--secondary)); border-color: transparent; color: #fff; font-weight: 800; }
.danger-button { border-color: #f2c6ba; color: var(--red-text); }
.notice { border: 1px solid var(--line); border-left: 4px solid var(--secondary); border-radius: 8px; background: #fbfcfd; padding: 12px 14px; color: #26303b; font-size: 14px; }
.error { border-color: #f2c6ba; border-left-color: #c65336; background: var(--red-bg); color: var(--red-text); }
.field-invalid { border-color: #e2518f !important; box-shadow: 0 0 0 3px rgba(226, 81, 143, .16); }
.label-invalid { color: var(--red-text); }
.checkbox-row.field-invalid {
  border: 2px solid #e2518f;
  border-radius: 8px;
  background: var(--red-bg);
  padding: 10px;
}
.empty { border: 1px dashed var(--line); border-radius: 8px; padding: 22px; color: var(--muted); text-align: center; }
.hidden { display: none !important; }
.status { display: inline-flex; justify-content: center; align-items: center; min-height: 30px; border-radius: 999px; padding: 0 10px; font-size: 12px; font-weight: 900; white-space: nowrap; }
.status-paid, .status-picked_up { color: var(--green-text); background: var(--green-bg); }
.status-new, .status-paypal_created { color: #6d4a00; background: #fff6d8; }
.status-error { color: var(--red-text); background: var(--red-bg); }
.qr-wrap { display: grid; justify-items: center; gap: 12px; padding: 18px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
#qr-canvas { width: 220px; height: 220px; }
.receipt-actions, .admin-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.receipt-actions { justify-content: center; }
.admin-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.round-icon { width: 44px; height: 44px; border-radius: 999px; padding: 0; flex: 0 0 auto; }
.admin-tools { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(160px, .7fr) auto; gap: 10px; margin-bottom: 16px; }
.scan-tools { grid-template-columns: minmax(220px, 1fr) auto auto auto; }
.admin-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 16px 0;
}
.admin-tabs button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 900;
  padding: 0 10px;
}
.admin-tabs button.active {
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), var(--secondary));
  color: #fff;
}
.admin-section, .scan-box, .product-editor {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 16px;
  margin: 16px 0;
  display: grid;
  gap: 12px;
}
.step-list { margin: 0; padding-left: 22px; color: var(--muted); font-size: 14px; font-weight: 700; }
.step-list li + li { margin-top: 4px; }
.save-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border: 1px solid color-mix(in srgb, var(--secondary) 28%, var(--line));
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  margin-bottom: 14px;
}
.save-bar .primary-button { min-width: 96px; }
.save-settings-button.saved {
  background: #eef1f4;
  border-color: var(--line);
  color: var(--muted);
}
.help-grid, .settings-grid, .design-grid, .dashboard-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.settings-grid, .design-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.dashboard-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.finance-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.help-item, .metric { border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 10px; color: var(--muted); font-size: 13px; }
.help-item strong, .metric strong { display: block; color: var(--ink); }
.metric strong { font-size: 24px; color: var(--accent-dark); }
.owner-settings-form {
  display: grid;
  grid-template-columns: minmax(190px, 1.2fr) minmax(130px, .5fr) minmax(130px, .5fr) minmax(130px, .5fr) auto;
  gap: 10px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}
.unpicked-row { border-left: 4px solid var(--accent); padding-left: 12px; }
.inventory-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto auto; gap: 10px; align-items: center; border-bottom: 1px solid var(--line); padding: 8px 0; font-size: 14px; }
.page-preview-editor { display: grid; gap: 14px; }
.banner-editor {
  border: 1px solid color-mix(in srgb, var(--accent) 24%, var(--line));
  border-radius: 8px;
  background: #fff;
  padding: 14px;
  display: grid;
  gap: 12px;
}
.banner-upload { cursor: pointer; }
.banner-upload input { display: none; }
.banner-preview {
  width: 100%;
  aspect-ratio: 7 / 1;
  min-height: 92px;
  overflow: hidden;
  border: 1px dashed color-mix(in srgb, var(--secondary) 45%, var(--line));
  border-radius: 8px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 10%, #fff), color-mix(in srgb, var(--secondary) 12%, #fff));
  display: grid;
  place-items: center;
  color: var(--accent-dark);
}
.banner-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.banner-empty { display: inline-flex; align-items: center; gap: 8px; font-weight: 900; }
.banner-controls { grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: end; }
.preview-hero, .preview-panel, .preview-summary {
  border: 1px solid color-mix(in srgb, var(--accent) 24%, var(--line));
  border-radius: 8px;
  background: #fff;
  padding: 14px;
  display: grid;
  gap: 10px;
}
.preview-hero {
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 13%, #fff), color-mix(in srgb, var(--secondary) 11%, #fff));
}
.preview-layout { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(260px, .75fr); gap: 12px; }
.preview-title-line { display: grid; align-items: start; gap: 5px; font-size: clamp(24px, 4vw, 42px); font-weight: 900; line-height: 1.04; }
.preview-title-line input {
  width: min(360px, 100%);
  min-height: 50px;
  padding: 4px 8px;
  font-size: inherit;
  font-weight: inherit;
}
.preview-title-line span { color: var(--accent-dark); font-size: clamp(16px, 2.5vw, 24px); }
.preview-badge-input { width: min(360px, 100%); color: var(--accent-dark); font-size: 12px; font-weight: 900; text-transform: uppercase; }
.preview-heading-input { font-size: 24px; font-weight: 900; }
.preview-button-input { color: #fff; border-color: transparent; background: linear-gradient(135deg, var(--accent), var(--secondary)); text-align: center; font-weight: 900; }
.preview-product-row { display: grid; grid-template-columns: 72px minmax(0, 1fr) auto; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: 10px; font-size: 13px; }
.preview-product-row div { aspect-ratio: 4 / 3; border-radius: 6px; background: var(--soft); }
.compact-design { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.csv-flow { display: grid; grid-template-columns: auto minmax(220px, 1fr) auto; gap: 10px; align-items: end; border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 12px; }
.csv-upload input { margin-top: 7px; }
.product-edit-form { display: grid; grid-template-columns: 96px minmax(145px, .9fr) minmax(260px, 2fr) 84px 82px 76px 92px auto; gap: 10px; align-items: end; padding: 12px 0; border-bottom: 1px solid var(--line); }
.product-image-picker {
  position: relative;
  width: 96px;
  aspect-ratio: 1;
  border: 1px solid color-mix(in srgb, var(--secondary) 24%, var(--line));
  border-radius: 8px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 14%, #fff), color-mix(in srgb, var(--secondary) 18%, #fff));
  overflow: hidden;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--accent-dark);
}
.product-image-picker input { display: none; }
.product-image-picker img { width: 100%; height: 100%; object-fit: cover; display: block; }
.image-empty-icon, .image-edit-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 999px; background: rgba(255,255,255,.82); box-shadow: var(--shadow); }
.image-edit-icon { position: absolute; right: 6px; bottom: 6px; width: 32px; height: 32px; }
.name-field input { min-width: 0; }
.number-field input { text-align: right; }
.wide { grid-column: span 2; }
.full { grid-column: 1 / -1; }
.enabled-control { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.enabled-control input, .checkbox-row input { width: 18px; min-height: 18px; }
.checkbox-row { display: flex; align-items: flex-start; gap: 10px; margin-top: 14px; font-size: 13px; font-weight: 700; }
.scan-box-compact { max-width: 760px; }
.scanner-frame { display: none; overflow: hidden; border-radius: 8px; border: 1px solid var(--line); background: #101318; aspect-ratio: 16 / 9; max-height: 360px; }
.scanner-frame.active { display: block; }
.scanner-frame video { width: 100%; height: 100%; object-fit: cover; }
.lookup-result {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--secondary);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
  font-size: 13px;
}
.order-code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-weight: 900; word-break: break-word; }
.utility-footer { position: fixed; right: 18px; bottom: 18px; z-index: 20; display: flex; gap: 8px; align-items: center; }
.admin-login-link { width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--accent-dark); box-shadow: var(--shadow); display: inline-grid; place-items: center; text-decoration: none; padding: 0; }
.owner-login-link { color: var(--secondary); }
.portal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(20, 22, 28, .42);
}
.portal-dialog {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 22px;
  display: grid;
  gap: 14px;
  position: relative;
}
.portal-close {
  position: absolute;
  right: 10px;
  top: 10px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.loading-card { width: min(720px, 100%); margin: 34px auto; text-align: center; }
.loading-dots { display: flex; justify-content: center; gap: 6px; }
.loading-dots span { width: 8px; height: 8px; border-radius: 999px; background: var(--accent); animation: pulse 900ms ease-in-out infinite alternate; }
.loading-dots span:nth-child(2) { animation-delay: 160ms; background: var(--secondary); }
.loading-dots span:nth-child(3) { animation-delay: 320ms; background: var(--warm); }
@keyframes pulse { from { opacity: .35; transform: translateY(0); } to { opacity: 1; transform: translateY(-4px); } }
button:disabled, input:disabled { cursor: not-allowed; opacity: .52; }

@media (max-width: 820px) {
  .shell { width: min(100% - 24px, 720px); padding-top: 18px; }
  body[data-page="order"] .shell { padding-bottom: 150px; }
  .topbar { align-items: stretch; flex-direction: column; }
  .order-tabs-wrap {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: 10px;
    z-index: 30;
    margin: 0;
    padding: 8px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255,255,255,.94);
    box-shadow: var(--shadow);
  }
  .order-tabs-label { text-align: center; }
  .order-tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; overflow: visible; }
  .order-tabs button { min-height: 34px; padding: 0 8px; }
  body[data-page="order"] .utility-footer { bottom: 126px; }
  .layout, .grid, .admin-tools, .dashboard-grid, .finance-grid, .help-grid, .settings-grid, .design-grid, .inventory-row, .product-edit-form, .preview-layout, .compact-design, .csv-flow, .lookup-result, .banner-controls, .owner-settings-form { grid-template-columns: 1fr; }
  .admin-tabs { grid-template-columns: 1fr; }
  .order-banner, .banner-preview { aspect-ratio: 3 / 1; }
  .save-bar { align-items: stretch; flex-direction: column; }
  .summary { position: static; }
  .product-row { grid-template-columns: 96px minmax(0, 1fr); }
  .product-row label, .wide, .full { grid-column: 1 / -1; }
  .preview-title-line input { width: 100%; }
  .product-edit-form { align-items: stretch; }
  .product-image-picker { width: 100%; max-width: 180px; }
  .admin-row { grid-template-columns: 1fr; }
}
