:root {
  color-scheme: light;
  --paper: #f2f0e9;
  --white: #fffefa;
  --deep: #0b1b1a;
  --ink: #10201f;
  --ink-2: #263b39;
  --muted: #687774;
  --teal: #1f716c;
  --acid: #d7f252;
  --line: #d9ddd7;
  --danger: #a33d34;
  font-family: var(--font-sans);
}

* { box-sizing: border-box; }
html { background: var(--paper); color: var(--ink); }
body { min-width: 320px; margin: 0; background: var(--paper); }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

.admin-header {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 clamp(1rem, 4vw, 3rem);
  border-bottom: 1px solid rgba(255,255,255,.12);
  background: var(--deep);
  color: var(--white);
}

.admin-brand { display: flex; align-items: center; gap: .75rem; color: inherit; text-decoration: none; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; background: var(--acid); color: var(--deep); font-family: var(--font-sans); font-weight: 700; }
.admin-brand > span:last-child { display: grid; gap: .08rem; }
.admin-brand strong { font-family: var(--font-sans); font-size: 1.05rem; font-weight: 600; }
.admin-brand small { color: rgba(255,255,255,.56); font-size: .59rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.shop-link { color: rgba(255,255,255,.78); font-size: .72rem; font-weight: 750; text-decoration: none; }
.shop-link:hover { color: var(--acid); }

main { width: min(1440px, calc(100% - 40px)); margin: 0 auto; padding: clamp(2.5rem, 6vw, 5.5rem) 0; }
.eyebrow { margin: 0 0 .75rem; color: var(--teal); font-size: .62rem; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; }
h1, h2, h3 { margin: 0; font-family: var(--font-sans); font-weight: 600; }
h1 { font-size: clamp(2.2rem, 5vw, 3.6rem); line-height: 1.12; letter-spacing: -.025em; }
h2 { font-size: clamp(1.75rem, 3vw, 2.6rem); line-height: 1.12; }
h3 { font-size: 1.15rem; }
.lead { max-width: 660px; margin: 1rem 0 0; color: var(--muted); font-size: .86rem; line-height: 1.7; }

.auth-panel { width: min(560px, 100%); margin: clamp(1rem, 7vw, 6rem) auto; padding: clamp(1.6rem, 5vw, 3rem); border: 1px solid var(--line); border-radius: 22px; background: var(--white); box-shadow: 0 24px 80px rgba(11,27,26,.08); }
.auth-panel h1 { font-size: clamp(2.2rem, 5vw, 3.4rem); }
.admin-login-form { display: grid; gap: 1rem; margin-top: 2rem; }
.admin-login-form label { display: grid; gap: .42rem; color: var(--ink-2); font-size: .7rem; font-weight: 750; }
.admin-login-form input, .search-form input, .search-form select { min-height: 48px; width: 100%; padding: .75rem .85rem; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); color: var(--ink); outline: none; }
.admin-login-form input:focus, .search-form input:focus, .search-form select:focus, button:focus-visible, a:focus-visible { border-color: var(--teal); outline: 3px solid rgba(31,113,108,.16); outline-offset: 2px; }
.form-error { min-height: 1.2em; margin: 0; color: var(--danger); font-size: .72rem; }
.primary-button, .secondary-button, .view-button, .load-more { min-height: 46px; border-radius: 10px; cursor: pointer; font-weight: 650; }
.primary-button { border: 0; background: var(--deep); color: var(--white); }
.primary-button:hover { background: var(--teal); }
.primary-button:disabled, .secondary-button:disabled, .load-more:disabled { cursor: wait; opacity: .58; }
.security-note { display: flex; gap: .55rem; margin: 1.25rem 0 0; color: var(--muted); font-size: .65rem; line-height: 1.55; }
.security-note span { color: var(--teal); }

.dashboard-heading { display: flex; align-items: end; justify-content: space-between; gap: 2rem; }
.dashboard-heading h1 { max-width: 760px; }
.admin-identity { min-width: 220px; display: grid; justify-items: end; gap: .3rem; padding: 1rem 0; color: var(--muted); font-size: .66rem; }
.admin-identity strong { max-width: 310px; color: var(--ink); font-size: .78rem; text-align: right; overflow-wrap: anywhere; }
.text-button { border: 0; border-bottom: 1px solid currentColor; background: transparent; color: var(--teal); cursor: pointer; padding: .2rem 0; font-size: .68rem; font-weight: 650; }
.dashboard-nav { display: flex; flex-wrap: wrap; gap: .65rem; margin: 1.5rem 0 0; }
.dashboard-nav a { display: inline-flex; align-items: center; min-height: 42px; padding: .6rem 1rem; border: 1px solid var(--line); border-radius: 999px; background: var(--white); color: var(--teal); font-size: .72rem; font-weight: 800; text-decoration: none; }
.dashboard-nav a:hover { border-color: var(--teal); }

.summary-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin: 3.2rem 0; }
.summary-grid article { min-height: 138px; display: grid; align-content: space-between; padding: 1.2rem; border: 1px solid var(--line); border-radius: 16px; background: var(--white); }
.summary-grid span { color: var(--muted); font-size: .68rem; font-weight: 700; }
.summary-grid strong { font-family: var(--font-sans); font-size: clamp(2.2rem, 4vw, 3.5rem); font-weight: 600; }
.summary-grid small { color: #92711e; font-size: .58rem; font-weight: 750; }

.orders-section { padding: clamp(1.2rem, 3vw, 2rem); border: 1px solid var(--line); border-radius: 20px; background: var(--white); }
.inventory-section { margin-bottom: 1.5rem; padding: clamp(1.2rem, 3vw, 2rem); border: 1px solid var(--line); border-radius: 20px; background: var(--white); }
.inventory-section, .orders-section { scroll-margin-top: 1rem; }
.inventory-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .75rem; margin: 1.5rem 0 .65rem; }
.inventory-summary article { display: grid; align-content: start; gap: .4rem; padding: 1rem; border-radius: 12px; background: var(--paper); }
.inventory-summary article:nth-child(3) { background: rgba(31,113,108,.09); }
.inventory-summary span { color: var(--ink-2); font-size: .68rem; font-weight: 800; }
.inventory-summary strong { color: var(--teal); font-family: var(--font-sans); font-size: clamp(2rem, 4vw, 3rem); font-weight: 600; }
.inventory-summary small, .inventory-summary-note { color: var(--muted); font-size: .62rem; line-height: 1.6; }
.inventory-summary-note { margin: .6rem 0 0; }
.inventory-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 1.2rem; }
.inventory-search { flex: 1; }
.inventory-result-count { color: var(--muted); font-size: .65rem; white-space: nowrap; }
.inventory-meta { margin: 1.4rem 0 1rem; color: var(--muted); font-size: .68rem; line-height: 1.6; }
.inventory-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 1rem; }
.inventory-card { min-width: 0; padding: 1.2rem; border: 1px solid var(--line); border-radius: 14px; }
.inventory-photo { display: block; width: 100%; height: 170px; margin: 0 0 1rem; border-radius: 10px; background: var(--paper); object-fit: contain; }
.inventory-card h3 { font-size: 1.35rem; line-height: 1.2; overflow-wrap: anywhere; }
.inventory-presentation { margin: .45rem 0 0; color: var(--muted); font-size: .65rem; line-height: 1.6; overflow-wrap: anywhere; }
.inventory-counts { display: flex; flex-wrap: wrap; gap: .4rem 1rem; margin: .8rem 0 .4rem; color: var(--ink-2); font-size: .7rem; font-weight: 700; }
.inventory-availability { min-height: 1.5em; margin: 0 0 1rem; color: var(--teal); font-size: .65rem; line-height: 1.5; }
.inventory-form { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.inventory-form label { display: grid; align-content: start; gap: .42rem; min-width: 0; color: var(--ink-2); font-size: .65rem; font-weight: 750; }
.inventory-form input { min-height: 46px; width: 100%; padding: .7rem; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); color: var(--ink); }
.inventory-form input:focus-visible { border-color: var(--teal); outline: 3px solid rgba(31,113,108,.16); outline-offset: 2px; }
.inventory-form input:disabled { opacity: .65; }
.inventory-help, .inventory-feedback, .inventory-form button { grid-column: 1 / -1; }
.inventory-help { margin: 0; color: var(--muted); font-size: .6rem; line-height: 1.6; }
.inventory-feedback { min-height: 1.5em; margin: 0; color: var(--teal); font-size: .68rem; line-height: 1.5; overflow-wrap: anywhere; }
.inventory-feedback.is-error { color: var(--danger); }
.inventory-economics { margin: 0 0 1rem; padding: .9rem; border-radius: 10px; background: var(--paper); }
.inventory-economics dl { gap: .55rem; }
.inventory-economics-row { display: flex; justify-content: space-between; align-items: baseline; gap: .75rem; }
.inventory-economics dt { font-size: .6rem; text-transform: none; }
.inventory-economics dd { color: var(--ink); font-size: .74rem; font-weight: 800; text-align: right; }
.inventory-economics-note { margin: .7rem 0 0; color: var(--muted); font-size: .58rem; line-height: 1.65; overflow-wrap: anywhere; }
.inventory-economics-note strong { display: block; color: var(--ink-2); font-weight: 750; }
.inventory-cost-missing { margin: 0 0 1rem; color: var(--muted); font-size: .62rem; line-height: 1.6; }
.orders-toolbar { display: flex; align-items: end; justify-content: space-between; gap: 1.5rem; }
.toolbar-actions { display: flex; align-items: center; gap: .7rem; }
.search-form { display: grid; grid-template-columns: minmax(220px, 340px) 170px; gap: .7rem; }
.secondary-button { padding: 0 1rem; border: 1px solid var(--line); background: var(--white); color: var(--ink); }
.secondary-button:hover, .view-button:hover { border-color: var(--teal); color: var(--teal); }
.orders-meta { display: flex; justify-content: space-between; gap: 1rem; margin: 1.4rem 0 .65rem; color: var(--muted); font-size: .62rem; }
.orders-table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: .8rem .65rem; border-bottom: 1px solid var(--line); color: var(--muted); font-size: .57rem; letter-spacing: .06em; text-align: left; text-transform: uppercase; }
td { padding: 1rem .65rem; border-bottom: 1px solid #e7e9e4; font-size: .68rem; vertical-align: middle; }
.reference-cell, .customer-cell { display: grid; gap: .2rem; min-width: 150px; }
.reference-cell time, .customer-cell span { color: var(--muted); font-size: .59rem; }
.total-cell { font-family: var(--font-sans); font-size: .9rem; }
.status-badge { display: inline-flex; width: max-content; padding: .32rem .5rem; border-radius: 999px; background: rgba(31,113,108,.1); color: var(--teal); font-size: .55rem; font-weight: 850; text-transform: uppercase; }
.action-cell { text-align: right; }
.view-button { min-height: 38px; padding: 0 .75rem; border: 1px solid var(--line); background: var(--white); color: var(--ink); font-size: .62rem; }
.empty-state { padding: 4rem 1rem; border: 1px dashed var(--line); border-radius: 14px; text-align: center; }
.empty-state strong { font-family: var(--font-sans); font-size: 1.5rem; font-weight: 600; }
.empty-state p { margin: .5rem 0 0; color: var(--muted); font-size: .72rem; }
.load-more { display: block; margin: 1.2rem auto 0; padding: 0 1.2rem; border: 1px solid var(--line); background: var(--paper); color: var(--ink); }
.orders-error, .detail-error { margin: 1rem 0; padding: 1rem; border: 1px solid #e4b7b2; border-radius: 10px; background: #fff4f2; color: var(--danger); font-size: .7rem; }
.orders-error { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.orders-error button { border: 0; border-bottom: 1px solid currentColor; background: transparent; color: inherit; cursor: pointer; }

.order-dialog { width: min(720px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: clamp(1.4rem, 4vw, 2.4rem); border: 0; border-radius: 22px; background: var(--white); color: var(--ink); box-shadow: 0 40px 120px rgba(0,0,0,.32); overflow-y: auto; }
.order-dialog::backdrop { background: rgba(5,14,14,.7); backdrop-filter: blur(4px); }
.dialog-close { position: absolute; top: .8rem; right: .8rem; width: 42px; height: 42px; border: 0; border-radius: 50%; background: var(--paper); cursor: pointer; color: var(--ink); font-size: 1.25rem; }
.order-detail-heading { display: flex; align-items: start; justify-content: space-between; gap: 1rem; padding-right: 3rem; }
.order-detail-heading h2 { overflow-wrap: anywhere; }
.order-detail-heading p:last-child { margin: .5rem 0 0; color: var(--muted); font-size: .68rem; }
.detail-flags { display: flex; flex-wrap: wrap; gap: .45rem; margin: 1.3rem 0; }
.detail-flags span { padding: .35rem .55rem; border-radius: 999px; background: var(--paper); color: var(--muted); font-size: .57rem; font-weight: 700; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.detail-grid section, .detail-items { padding: 1rem; border: 1px solid var(--line); border-radius: 13px; }
.detail-grid h3, .detail-items h3 { margin-bottom: .8rem; }
dl { display: grid; gap: .7rem; margin: 0; }
.definition-row { display: grid; gap: .2rem; }
dt { color: var(--muted); font-size: .58rem; font-weight: 800; text-transform: uppercase; }
dd { margin: 0; font-size: .72rem; overflow-wrap: anywhere; }
address { display: grid; gap: .28rem; font-size: .72rem; font-style: normal; line-height: 1.45; }
.detail-items { margin-top: 1rem; }
.detail-item-row { display: flex; justify-content: space-between; gap: 1rem; padding: .7rem 0; border-bottom: 1px solid var(--line); font-size: .7rem; }
.detail-item-row:last-child { border-bottom: 0; }
.detail-item-row div { display: grid; gap: .2rem; }
.detail-item-row span, .muted { color: var(--muted); font-size: .62rem; }
.detail-totals { margin: 1rem 0 0 auto; width: min(330px, 100%); }
.total-row { display: flex; justify-content: space-between; padding: .55rem 0; color: var(--muted); font-size: .7rem; }
.total-row strong { color: var(--ink); }
.grand-total { margin-top: .35rem; padding-top: .85rem; border-top: 1px solid var(--line); color: var(--ink); font-size: .9rem; }
.grand-total strong { font-family: var(--font-sans); font-size: 1.35rem; font-weight: 600; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 900px) {
  .dashboard-heading { align-items: start; flex-direction: column; }
  .admin-identity { justify-items: start; padding: 0; }
  .admin-identity strong { text-align: left; }
  .summary-grid, .inventory-summary { grid-template-columns: 1fr 1fr; }
  .orders-toolbar { align-items: stretch; flex-direction: column; }
  .toolbar-actions { align-items: stretch; }
  .search-form { flex: 1; }
  th:nth-child(3), td:nth-child(3), th:nth-child(4), td:nth-child(4) { display: none; }
}

@media (max-width: 600px) {
  main { width: min(100% - 20px, 1440px); padding: 1.5rem 0 3rem; }
  .admin-header { min-height: 66px; padding-inline: .75rem; }
  .shop-link { font-size: 0; }
  .shop-link span { font-size: 1rem; }
  .auth-panel, .orders-section, .inventory-section { padding: 1.1rem; border-radius: 16px; }
  .summary-grid { gap: .6rem; margin: 2rem 0; }
  .summary-grid article { min-height: 112px; padding: .9rem; }
  .summary-grid strong { font-size: 2rem; }
  .inventory-summary { gap: .4rem; }
  .inventory-summary article { padding: .7rem .55rem; }
  .inventory-summary span, .inventory-summary small { font-size: .57rem; }
  .inventory-controls { align-items: stretch; flex-direction: column; gap: .75rem; }
  .toolbar-actions, .search-form { display: grid; grid-template-columns: 1fr; }
  .orders-meta { align-items: start; flex-direction: column; }
  .orders-table-wrap { overflow: visible; }
  table, tbody, tr, td { display: block; width: 100%; }
  thead { display: none; }
  tr { margin-bottom: .75rem; padding: .9rem; border: 1px solid var(--line); border-radius: 12px; }
  td { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .45rem 0; border: 0; text-align: right; }
  td::before { content: attr(data-label); color: var(--muted); font-size: .55rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
  .reference-cell, .customer-cell { display: flex; min-width: 0; }
  .reference-cell strong, .customer-cell strong { overflow-wrap: anywhere; }
  .action-cell { padding-top: .75rem; }
  .action-cell::before { content: none; }
  .view-button { width: 100%; min-height: 44px; }
  th:nth-child(3), td:nth-child(3), th:nth-child(4), td:nth-child(4) { display: none; }
  .order-dialog { width: calc(100vw - 12px); max-height: calc(100vh - 12px); padding: 1.15rem; border-radius: 16px; }
  .order-detail-heading, .detail-grid { grid-template-columns: 1fr; }
  .order-detail-heading { display: grid; }
  .detail-grid { display: grid; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}


