:root {
  color-scheme: light;
  --navy: #11223b;
  --canvas: #f2f5fa;
  --surface: #fff;
  --panel-subtle: #f6f8fc;
  --text: #14233b;
  --muted: #54647b;
  --line: #dce4f0;
  --blue: #225acc;
  --blue-soft: #e9f0ff;
  --primary-ink: #fff;
  --on-photo: #294773;
  --photo: #e8eef8;
  --photo-line: #d7e2f2;
  --gold: #775219;
  --gold-soft: #fbefd8;
  --danger: #a1252f;
  --shadow: 0 6px 18px #152d5310;
  font-family: "Segoe UI", system-ui, sans-serif;
  font-synthesis: none;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --navy: #0d1729;
  --canvas: #101929;
  --surface: #182338;
  --panel-subtle: #131e30;
  --text: #edf3fc;
  --muted: #aebcd2;
  --line: #35445c;
  --blue: #92b5ff;
  --blue-soft: #253b65;
  --primary-ink: #111f38;
  --on-photo: #c0d5fa;
  --photo: #21334e;
  --photo-line: #2d4261;
  --gold: #f1ce89;
  --gold-soft: #46371e;
  --danger: #ff9da6;
  --shadow: 0 6px 18px #0002;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--text); background: var(--canvas); line-height: 1.5; -webkit-text-size-adjust: 100%; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3, p, a, label, legend { overflow-wrap: anywhere; }
h1 { font-size: clamp(1.65rem, 4vw, 2.35rem); letter-spacing: -.037em; line-height: 1.12; }
h2 { font-size: 1.25rem; letter-spacing: -.022em; line-height: 1.2; }
h3 { font-size: 1.1rem; letter-spacing: -.015em; line-height: 1.25; }
a { color: var(--blue); }
button, input, select, textarea { font: inherit; color: inherit; }
button, select { cursor: pointer; }
button:disabled { cursor: default; opacity: .58; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }

.shell { width: min(calc(100% - 32px), 1032px); margin-inline: auto; }
.masthead { color: #f5f8ff; background: var(--navy); }
.brand-row { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: .55rem; }
.wordmark, .account { display: flex; align-items: center; gap: .55rem; }
.wordmark div { display: grid; gap: .12rem; }
.wordmark strong { font-size: 1.2rem; letter-spacing: -.04em; line-height: 1.05; }
.wordmark small { color: #bdc9df; font-size: .74rem; }
.mark { width: 39px; aspect-ratio: 1; display: grid; place-items: center; border-radius: 11px; color: white; background: #2a64d7; font-size: 1.2rem; font-weight: 850; }
.header-button { min-height: 44px; padding: 0 .55rem; background: none; border: 1px solid #ffffff40; color: #f5f8ff; border-radius: 10px; font-size: .83rem; font-weight: 650; }
.header-button:hover { background: #ffffff12; }
.theme { width: 44px; padding: 0; font-size: 1.2rem; }
.masthead :focus-visible { outline-color: #b3ceff; }
.tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .2rem; }
.tabs a { display: grid; place-items: center; min-height: 49px; border: 1px solid transparent; border-radius: 11px 11px 0 0; color: #c9d6ec; font-size: .86rem; font-weight: 700; text-decoration: none; }
.tabs a:hover { background: #ffffff12; }
.tabs a[aria-current="page"] { color: var(--text); background: var(--canvas); }

main.shell { padding: 24px 0 max(48px, env(safe-area-inset-bottom)); }
#content, .order-list, .product-list, .detail, .unit-list, .sales { display: grid; gap: 14px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding-block: 2px; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; min-height: 44px; padding: .45rem .78rem; border: 1px solid var(--line); border-radius: 10px; color: var(--text); background: var(--surface); font-size: .88rem; font-weight: 700; line-height: 1.3; text-align: center; text-decoration: none; }
.button:not(.primary):hover:not(:disabled) { background: var(--blue-soft); }
.button.primary { background: var(--blue); border-color: var(--blue); color: var(--primary-ink); }
.button.primary:hover:not(:disabled) { filter: brightness(.92); }
.button.text-button { border-color: transparent; background: transparent; color: var(--blue); }
.button.danger { color: var(--danger); }
.button.destructive, .button.destructive:hover:not(:disabled) { background: var(--danger); border-color: var(--danger); color: var(--surface); }
.panel, .empty { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.panel { padding: 14px; }
.empty { grid-column: 1 / -1; padding: 24px 16px; border-style: dashed; box-shadow: none; color: var(--muted); text-align: center; }
.sign-in { max-width: 420px; margin: clamp(16px, 9vh, 86px) auto; padding: clamp(18px, 5vw, 32px); }
.sign-in h1 { margin-bottom: 20px; }
.muted { color: var(--muted); font-size: .9rem; }
.connection { border: 1px solid var(--line); border-radius: 10px; background: var(--gold-soft); color: var(--gold); margin-bottom: 16px; padding: .65rem .8rem; font-size: .9rem; }

.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
.metric { min-width: 0; padding: 11px 8px; display: grid; align-content: space-between; gap: 5px; }
.metric dt { color: var(--muted); font-size: clamp(.72rem, 2.3vw, .88rem); font-weight: 650; line-height: 1.18; }
.metric dd { margin: 5px 0 0; font-size: clamp(.94rem, 3.8vw, 1.65rem); font-weight: 850; letter-spacing: -.04em; font-variant-numeric: tabular-nums; line-height: 1.15; overflow-wrap: anywhere; }
.metric.warn { border-color: var(--gold); }
.metric.warn dd { color: var(--gold); }
.metrics dl { margin: 0; }
.filters, .meta, .card-actions, .dialog-actions, .breadcrumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.filter { min-height: 44px; padding: .35rem .58rem; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--muted); font-weight: 650; font-size: .82rem; }
.filter[aria-pressed="true"] { background: var(--blue-soft); border-color: var(--blue); color: var(--blue); }
.filter span { margin-inline-start: .3rem; font-variant-numeric: tabular-nums; }

.product { display: grid; gap: 12px; min-width: 0; align-content: start; }
.product-head, .sale-summary { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 12px; }
.product-head h3 + p, .order-title + p { margin-top: 2px; }
.product-head .price { display: block; margin-top: 3px; }
.price { font-weight: 800; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.media { overflow: hidden; position: relative; border-radius: 10px; background: var(--photo); color: var(--on-photo); border: 1px solid var(--photo-line); display: grid; place-items: center; }
.media img { display: block; width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.initials { font-size: clamp(1.25rem, 5vw, 2.1rem); font-weight: 850; letter-spacing: -.05em; }
.thumbnail { width: 66px; height: 66px; }
.badge { display: inline-block; border-radius: 100px; background: var(--blue-soft); color: var(--blue); padding: .23rem .58rem; font-size: .78rem; font-weight: 750; line-height: 1.23; overflow-wrap: anywhere; }
.badge.warn { color: var(--gold); background: var(--gold-soft); }
.badge.neutral { color: var(--muted); background: var(--panel-subtle); border: 1px solid var(--line); }
.card-actions { justify-content: space-between; }
.card-actions .text-button:last-child { margin-inline-start: auto; }
.safe-link { display: inline-flex; align-items: center; min-height: 44px; font-size: .88rem; font-weight: 700; text-underline-offset: .2em; }
.unit { min-width: 0; border-top: 1px solid var(--line); padding-top: 10px; display: grid; gap: 8px; }
.unit-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; font-size: .95rem; overflow-wrap: anywhere; }
.steppers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.stepper { display: grid; gap: 4px; padding: 6px; border: 1px solid var(--line); background: var(--panel-subtle); border-radius: 10px; text-align: center; min-width: 0; }
.stepper-label { color: var(--muted); font-size: .8rem; font-weight: 700; }
.stepper-controls { display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; align-items: center; gap: 2px; }
.stepper-controls button { width: 44px; height: 44px; padding: 0; font-size: 1.25rem; }
.stepper-controls .increase { background: var(--blue-soft); color: var(--blue); }
.stepper-controls output { font-size: clamp(.85rem, 4vw, 1.35rem); font-weight: 850; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; line-height: 1.1; }

.exhibit { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tile { display: grid; min-width: 0; grid-template-rows: auto 1fr auto; gap: 9px; padding: 8px; color: var(--text); font: inherit; cursor: pointer; text-align: left; }
.tile:hover { border-color: var(--blue); }
.tile.sold-out { opacity: .67; }
.tile .media { aspect-ratio: 1 / 1; }
.tile .badge { position: absolute; top: 6px; right: 6px; max-width: calc(100% - 12px); }
.tile-copy { display: grid; gap: 3px; padding-inline: 3px; }
.tile .price { padding: 0 3px 4px; font-size: 1.12rem; }

.detail-hero { display: grid; align-items: start; gap: 15px; }
.detail-hero .media { aspect-ratio: 4 / 3; }
.detail-copy { display: grid; gap: 8px; }
.breadcrumbs { justify-content: space-between; }
.selling-unit { display: grid; gap: 6px; grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
.selling-unit-details { display: flex; gap: 9px; align-items: center; min-width: 0; }
.selling-unit-details .detail-copy { min-width: 0; }
.unit-photo { width: 54px; height: 54px; flex-shrink: 0; }
.sell { min-height: 52px; min-width: 108px; }
.sales { padding-top: 16px; gap: 8px; }
.sale-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 5px 10px; padding-top: 5px; border-top: 1px solid var(--line); }
.sale-row strong { overflow-wrap: anywhere; }
.sale-row small { color: var(--muted); margin-right: .55rem; }
.sale-row [data-confirmed="true"] { color: var(--danger); }
.sale-row .price { font-size: .9rem; }
.daily-group { border-top: 1px solid var(--line); min-width: 0; }
.daily-summary { min-height: 44px; padding-block: 10px; cursor: pointer; font-weight: 670; }
.daily-line { display: inline-grid; width: calc(100% - 1.25rem); vertical-align: top; }
.daily-line, .daily-items li { grid-template-columns: minmax(0, 1fr) minmax(0, .6fr); gap: 10px; overflow-wrap: anywhere; }
.daily-total { display: grid; text-align: end; font-size: .92rem; }
.daily-total .muted { font-size: .82rem; font-weight: 550; }
.daily-items { margin: 0 0 9px; padding: 0 0 0 1.25rem; list-style: none; }
.daily-items li { display: grid; align-items: center; padding-block: 7px; border-top: 1px solid var(--line); font-size: .92rem; }

.order { display: grid; gap: 9px; align-content: start; }
.order[data-overdue="true"] { border-inline-start: 3px solid var(--gold); }
.order .meta { gap: 8px 12px; }
.order-title { color: var(--text); }
.order .safe-link { width: fit-content; }
.order .detail-copy { gap: 3px; }
.order-photo { display: block; width: min(100%, 360px); border-radius: 10px; }
.order-photo .media { aspect-ratio: 16 / 9; }
.order-photo img { object-fit: contain; }

dialog { position: fixed; top: auto; bottom: 0; width: 100%; max-width: 100%; max-height: calc(100dvh - 12px); margin: 0; padding: 18px 16px max(18px, env(safe-area-inset-bottom)); border: 1px solid var(--line); border-radius: 18px 18px 0 0; background: var(--surface); color: var(--text); box-shadow: var(--shadow); overscroll-behavior: contain; }
dialog::backdrop { background: #080e1cc0; }
html:has(dialog[open]) { overflow: hidden; }
.form-stack { display: grid; gap: 12px; }
.form-stack > h2 { margin-bottom: 2px; }
.form-stack label:not(.button) { display: grid; gap: 4px; color: var(--muted); font-weight: 700; font-size: .86rem; min-width: 0; }
.form-stack :is(input, select, textarea):not([type="file"]) { display: block; min-width: 0; width: 100%; padding: .48rem .66rem; min-height: 44px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel-subtle); color: var(--text); font-size: 1rem; font-weight: 450; }
textarea { resize: vertical; }
input[type="date"]::-webkit-date-and-time-value { min-width: 0; text-align: left; }
.field-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.form-error { color: var(--danger); font-size: .86rem; }
.dialog-actions { justify-content: flex-end; gap: 7px; }
.dialog-actions .danger { margin-inline-end: auto; }
.completion-actions, .photo-actions { display: grid; gap: 6px; }
.photo-field { display: flex; align-items: center; gap: 12px; }
.field-photo { width: 66px; height: 66px; flex-shrink: 0; }
.photo-picker { cursor: pointer; }
.photo-actions:has(input:focus-visible) .photo-picker { outline: 2px solid var(--blue); outline-offset: 3px; }
.variant-fields, .color-fields { display: grid; gap: 9px; margin: 0; padding: 10px; min-width: 0; border: 1px solid var(--line); border-radius: 10px; }
.variant-fields legend, .color-fields legend { color: var(--muted); font-size: .86rem; font-weight: 750; }
#variants, .variant-edit-fields, .variant-removal, #order-colors { display: grid; gap: 9px; }
.variant-edit { padding: 8px 0 10px; border-bottom: 1px solid var(--line); }
.variant-edit .danger { justify-self: end; }
.variant-removal { align-items: center; grid-template-columns: minmax(0, 1fr) auto; font-size: .88rem; }
.color-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 6px; }
.input-hint { margin-top: -6px; }
#removal-variants { margin: 0; padding-inline-start: 1.25rem; overflow-wrap: anywhere; }
.sale-amount { display: grid; gap: 4px; }
.sale-quantity { display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; gap: 6px; }
.sale-quantity button { padding: 0; font-size: 1.25rem; }
.sale-quantity input[type="number"] { text-align: center; appearance: textfield; }
.sale-quantity input::-webkit-inner-spin-button { appearance: none; }
.sale-confirm { width: 100%; min-height: 54px; font-size: 1rem; }
.toast { position: fixed; z-index: 2; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); transform: translateX(-50%); width: max-content; max-width: calc(100% - 24px); display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 14px; background: #11223b; color: white; border: 1px solid #496483; border-radius: 12px; font-size: .9rem; box-shadow: var(--shadow); }
.toast span { overflow-wrap: anywhere; }
.toast .button { background: #e9f0ff; border-color: #e9f0ff; color: #163561; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

@media (min-width: 600px) {
  .shell { width: min(calc(100% - 56px), 1032px); }
  main.shell { padding-top: 36px; }
  .tabs { display: flex; }
  .tabs a { padding-inline: 22px; font-size: .94rem; }
  .metrics { gap: 12px; }
  .metric { padding: 15px; }
  .panel { padding: 16px; }
  .exhibit { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .detail-hero { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  dialog { inset: 0; margin: auto; width: min(540px, calc(100% - 32px)); max-height: calc(100dvh - 24px); padding: 22px; border-radius: 18px; }
}

@media (min-width: 850px) {
  #content { gap: 18px; }
  .product-list, .order-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .exhibit { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
