:root {
  --ivory: #f7f3eb;
  --paper: #fffdf8;
  --mist: #e8e1d5;
  --line: #d7cec0;
  --ink: #22211f;
  --muted: #716a60;
  --olive: #465545;
  --wine: #743c3d;
  --copper: #b98657;
  --sage: #aeb8a3;
  --danger: #a24036;
  --shadow: 0 18px 44px rgba(34, 33, 31, .08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--ivory);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 76px;
  padding: 16px clamp(18px, 4vw, 48px);
  background: rgba(247, 243, 235, .92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  color: var(--paper);
  background: var(--ink);
  border-radius: 50%;
  font-family: Georgia, serif;
  font-size: 20px;
}

.brand strong,
.brand small {
  display: block;
  line-height: 1.1;
}

.brand small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.quiet-link,
.ghost-button,
.icon-button,
.primary-button,
.tab-button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 14px;
  background: transparent;
  color: var(--ink);
}

.primary-button {
  border-color: var(--olive);
  background: var(--olive);
  color: var(--paper);
}

.ghost-button:hover,
.icon-button:hover,
.quiet-link:hover,
.tab-button:hover {
  border-color: var(--ink);
}

.wide-button {
  width: 100%;
  justify-content: center;
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.shop-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: 28px;
  align-items: end;
  min-height: 260px;
  padding: 52px 0 36px;
  border-bottom: 1px solid var(--line);
}

.member-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: 28px;
  align-items: end;
  min-height: 220px;
  padding: 46px 0 32px;
  border-bottom: 1px solid var(--line);
}

.member-hero h1 {
  max-width: 760px;
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(34px, 5vw, 60px);
  font-weight: 500;
  line-height: 1;
}

.member-login {
  margin: 28px 0;
}

.member-dashboard {
  display: grid;
  gap: 18px;
  padding: 28px 0 60px;
}

.member-metrics {
  margin-bottom: 0;
}

.shop-hero h1,
.admin-content h1 {
  max-width: 760px;
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(36px, 6vw, 76px);
  font-weight: 500;
  line-height: .96;
}

.hero-panel {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 20px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.hero-panel span {
  color: var(--muted);
}

.hero-panel strong {
  font-size: 46px;
  font-family: Georgia, serif;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--wine);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.catalog-shell {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 28px;
  padding: 34px 0 60px;
}

.filters,
.data-panel,
.form-panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.filters {
  position: sticky;
  top: 98px;
  align-self: start;
  padding: 18px;
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

.field span,
.check-row span,
.role-picker span {
  color: var(--muted);
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fffefa;
  color: var(--ink);
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(70, 85, 69, .22);
  border-color: var(--olive);
}

.check-row {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
}

.check-row input {
  width: 18px;
  min-height: 18px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.section-head h1,
.section-head h2,
.data-panel h2,
.form-panel h2 {
  margin: 0;
}

.compact {
  margin-bottom: 12px;
}

.muted {
  color: var(--muted);
  font-size: 14px;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.catalog-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: -4px 0 16px;
}

.catalog-toolbar .small-button.active,
.segmented-control .small-button.active {
  border-color: var(--olive);
  background: var(--olive);
  color: var(--paper);
}

.segmented-control {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.product-card {
  display: grid;
  grid-template-rows: 240px 1fr;
  overflow: hidden;
  min-height: 420px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.image-button {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  padding: 0;
  background: transparent;
  overflow: hidden;
}

.image-button:hover img {
  transform: scale(1.025);
}

.image-button img,
.detail-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--mist);
  transition: transform .25s ease;
}

.product-body {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.product-summary {
  display: -webkit-box;
  overflow: hidden;
  min-height: 64px;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.product-title {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.product-title h3 {
  margin: 0;
  font-size: 18px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.badge.preorder {
  color: var(--wine);
  border-color: rgba(116, 60, 61, .32);
  background: rgba(116, 60, 61, .06);
}

.price-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
}

.price-line strong {
  font-size: 20px;
}

.drawer {
  width: min(760px, calc(100% - 24px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.drawer::backdrop {
  background: rgba(34, 33, 31, .36);
}

.dialog-shell {
  position: relative;
  padding: 28px;
}

.dialog-close {
  position: absolute;
  top: 18px;
  right: 18px;
}

.detail-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 24px;
  padding-top: 20px;
}

.detail-image {
  height: 340px;
  border-radius: 8px;
}

.long-description {
  max-height: 220px;
  margin: 12px 0 16px;
  overflow: auto;
  color: var(--muted);
  line-height: 1.75;
  white-space: pre-wrap;
}

.stack {
  display: grid;
  gap: 12px;
}

.variant-list {
  display: grid;
  gap: 9px;
  margin: 16px 0;
}

.variant-option,
.cart-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 54px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.variant-option.selected {
  border-color: var(--olive);
  background: rgba(70, 85, 69, .07);
}

.quantity-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cart-quantity {
  width: 86px;
  min-height: 32px;
  padding: 5px 8px;
}

.quantity-row input {
  width: 90px;
}

.totals {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin: 18px 0;
  padding: 16px;
  background: rgba(232, 225, 213, .5);
  border-radius: 8px;
}

.checkout-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.wide {
  grid-column: 1 / -1;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 10;
  max-width: min(420px, calc(100vw - 40px));
  padding: 14px 16px;
  color: var(--paper);
  background: var(--ink);
  border-radius: 8px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: .2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.admin-layout {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: 24px;
  width: min(1460px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0 60px;
}

.admin-topbar {
  min-height: 66px;
  background: rgba(248, 249, 246, .95);
}

.admin-topbar .brand-mark {
  background: #2f4641;
}

.admin-content h1 {
  font-family: inherit;
  font-size: clamp(26px, 3vw, 36px);
  font-weight: 650;
  line-height: 1.12;
}

.admin-menu {
  position: sticky;
  top: 98px;
  display: grid;
  gap: 4px;
  align-self: start;
  padding: 8px;
  background: #eef2ee;
  border: 1px solid #d6ddd5;
  border-radius: 8px;
}

.tab-button {
  width: 100%;
  min-height: 38px;
  border-color: transparent;
  padding: 8px 10px;
  text-align: left;
  background: transparent;
  color: #46524f;
  font-size: 14px;
}

.tab-button.active {
  border-color: #3f847b;
  background: #3f847b;
  color: var(--paper);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.dashboard-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-bottom: 18px;
}

.ops-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
}

.ops-card {
  display: grid;
  gap: 8px;
  min-height: 112px;
  padding: 14px;
  color: var(--ink);
  text-align: left;
  background: #fbfcf7;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.ops-card:hover {
  border-color: var(--accent);
}

.ops-card span,
.ops-card small {
  color: var(--muted);
}

.ops-card strong {
  font-family: Georgia, serif;
  font-size: 28px;
  font-weight: 500;
}

.ops-card.attention {
  background: #fff9ee;
  border-color: #e7c782;
}

.ops-card.warning {
  background: #f6faf8;
  border-color: #9bb9a6;
}

.metric {
  min-height: 96px;
  padding: 16px;
  background: #fffefa;
  border: 1px solid #d9d7cf;
  border-radius: 8px;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 10px;
  font-family: Georgia, serif;
  font-size: 30px;
  font-weight: 500;
}

.data-panel {
  padding: 16px;
  box-shadow: 0 10px 26px rgba(50, 57, 52, .05);
}

.compact-list {
  display: grid;
  gap: 10px;
}

.compact-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.compact-item.with-thumb {
  grid-template-columns: 48px minmax(0, 1fr);
}

.compact-item img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--mist);
}

.compact-item strong,
.compact-item small {
  display: block;
}

.compact-item small {
  margin-top: 3px;
  color: var(--muted);
}

.empty-state {
  min-height: 48px;
  padding: 14px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.management-grid {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.split-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.single-check {
  display: flex;
  align-items: center;
  min-height: 42px;
  margin-bottom: 12px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid #ddd8cf;
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 620px;
  background: #fffefa;
  font-size: 13px;
}

th,
td {
  padding: 10px 9px;
  border-bottom: 1px solid #e4dfd6;
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: #5f6864;
  background: #f0f3ef;
  font-size: 12px;
  font-weight: 700;
}

tbody tr:nth-child(even) {
  background: rgba(238, 242, 238, .46);
}

tbody tr:hover {
  background: rgba(63, 132, 123, .08);
}

tbody tr.is-expanded {
  background: rgba(63, 132, 123, .1);
}

.order-detail-row,
.order-detail-row:hover {
  background: #f7f6f0;
}

.order-detail-panel {
  display: grid;
  gap: 14px;
  padding: 14px;
  border: 1px solid #d8ded7;
  border-radius: 8px;
  background: #fffefa;
}

.order-detail-grid {
  display: grid;
  grid-template-columns: 1.2fr 1.1fr 1fr;
  gap: 16px;
}

.order-detail-grid h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.order-detail-grid p {
  margin: 4px 0;
  color: #46524f;
}

.mini-table-wrap {
  overflow: auto;
  border: 1px solid #e4dfd6;
  border-radius: 8px;
}

.mini-table {
  min-width: 560px;
  font-size: 12px;
}

.row-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.small-button {
  min-height: 30px;
  padding: 5px 8px;
  border: 1px solid #b8cec8;
  border-radius: 6px;
  background: #f6fbf8;
  color: #2f5f58;
  font-size: 12px;
}

.danger-button {
  color: var(--danger);
  border-color: rgba(162, 64, 54, .36);
  background: rgba(162, 64, 54, .05);
}

.select-inline {
  max-width: 220px;
}

.order-tools {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 220px;
  gap: 14px;
  margin-bottom: 14px;
  background: #f8f9f6;
}

.order-tools .field {
  margin-bottom: 0;
}

.batch-bar {
  display: grid;
  grid-template-columns: minmax(180px, auto) minmax(180px, 1fr) auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

.buyer-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.buyer-card {
  padding: 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.buyer-card strong,
.buyer-card small {
  display: block;
}

.buyer-card small {
  margin-top: 4px;
  color: var(--muted);
}

.buyer-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 12px 0 8px;
}

.buyer-stats span {
  min-height: 26px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.summary-pill {
  min-height: 70px;
  padding: 13px;
  background: #fffefa;
  border: 1px solid #d9d7cf;
  border-radius: 8px;
}

.summary-pill span,
.summary-pill strong {
  display: block;
}

.summary-pill span {
  color: var(--muted);
  font-size: 13px;
}

.summary-pill strong {
  margin-top: 8px;
  color: #2f4641;
  font-size: 22px;
}

.compact-summary {
  min-height: 0;
  margin: 0;
  padding: 10px 12px;
}

.compact-summary strong {
  margin-top: 4px;
  font-size: 18px;
}

.admin-content .badge {
  min-height: 24px;
  border-radius: 6px;
  padding: 3px 7px;
  background: #f6f7f4;
  font-size: 12px;
}

.admin-content .badge.preorder {
  color: #8b4a24;
  border-color: rgba(185, 134, 87, .42);
  background: rgba(185, 134, 87, .11);
}

.admin-content .section-head {
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(215, 206, 192, .65);
}

.role-picker {
  display: flex;
  align-items: center;
  gap: 8px;
}

.role-picker select {
  width: 140px;
}

.keyword-list,
.audit-list {
  display: grid;
  gap: 10px;
  max-height: 420px;
  overflow: auto;
}

.keyword-item,
.audit-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.keyword-item.with-thumb {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.keyword-item.with-thumb img {
  width: 58px;
  height: 58px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--mist);
}

.hidden-by-role {
  display: none !important;
}

@media (max-width: 980px) {
  .catalog-shell,
  .admin-layout,
  .management-grid,
  .shop-hero,
  .member-hero,
  .detail-layout,
  .dashboard-split,
  .order-tools,
  .order-detail-grid,
  .buyer-summary,
  .summary-strip,
  .ops-grid {
    grid-template-columns: 1fr;
  }

  .filters,
  .admin-menu {
    position: static;
  }

  .admin-menu {
    grid-template-columns: repeat(3, 1fr);
  }

  .product-grid,
  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ops-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .topbar {
    align-items: flex-start;
  }

  .brand strong {
    font-size: 14px;
  }

  .product-grid,
  .metric-grid,
  .checkout-grid,
  .split-fields,
  .admin-menu {
    grid-template-columns: 1fr;
  }

  .product-card {
    grid-template-rows: 220px 1fr;
  }

  .dialog-shell {
    padding: 22px 16px;
  }
}
