:root {
  --ink-strong: #1d2433;
  --ink-soft: #5f6778;
  --paper: rgba(255, 252, 247, 0.92);
  --paper-border: rgba(29, 36, 51, 0.08);
  --accent: #d8612b;
  --accent-dark: #8f3816;
  --accent-soft: #ffd5bf;
  --success: #1f7a59;
  --warning: #9f5b11;
  --danger: #a12c2c;
  --bg-top: #f7d8be;
  --bg-bottom: #f4efe8;
  --shadow: 0 22px 60px rgba(61, 45, 32, 0.12);
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink-strong);
  font-family: "Avenir Next", "Trebuchet MS", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(216, 97, 43, 0.16), transparent 24rem),
    radial-gradient(circle at top right, rgba(29, 36, 51, 0.12), transparent 18rem),
    linear-gradient(155deg, var(--bg-top), var(--bg-bottom));
}

body.is-loading {
  overflow: hidden;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", serif;
  letter-spacing: -0.03em;
}

p {
  margin: 0;
  line-height: 1.6;
}

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

img {
  display: block;
  max-width: 100%;
}

button,
input,
select {
  font: inherit;
}

button,
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 999px;
  padding: 0.9rem 1.4rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

button {
  color: #fff9f3;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  box-shadow: 0 10px 24px rgba(143, 56, 22, 0.24);
}

button:hover,
.ghost-button:hover {
  transform: translateY(-1px);
}

.ghost-button {
  color: var(--accent-dark);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(143, 56, 22, 0.16);
}

.danger-button {
  background: linear-gradient(135deg, #cf5656, var(--danger));
  box-shadow: none;
}

input,
select {
  width: 100%;
  border: 1px solid rgba(29, 36, 51, 0.14);
  border-radius: 14px;
  padding: 0.85rem 1rem;
  background: rgba(255, 255, 255, 0.94);
}

label,
dt,
.eyebrow,
.muted {
  color: var(--ink-soft);
}

label,
dt {
  font-size: 0.9rem;
  font-weight: 700;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.75rem;
  font-weight: 800;
}

.muted {
  font-size: 0.95rem;
}

.page-shell {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1rem 0 3rem;
}

.site-header,
.hero-card,
.detail-card,
.table-card,
.checkout-panel,
.token-card,
.auth-card,
.product-card,
.order-card,
.empty-state {
  background: var(--paper);
  border: 1px solid var(--paper-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.site-header {
  display: grid;
  gap: 1rem;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.brand-link {
  font-size: clamp(2rem, 4vw, 3.2rem);
  font-weight: 800;
}

.brand-copy {
  margin-top: 0.5rem;
  max-width: 58ch;
}

.top-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
}

.top-nav a {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.85rem 1.1rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(29, 36, 51, 0.08);
}

.nav-form {
  margin: 0;
}

.nav-button {
  color: var(--ink-strong);
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(29, 36, 51, 0.08);
  box-shadow: none;
}

.token-banner,
.total-badge,
.order-summary {
  display: inline-grid;
  gap: 0.2rem;
  padding: 1rem 1.2rem;
  border-radius: var(--radius-md);
  background: linear-gradient(160deg, rgba(255, 213, 191, 0.72), rgba(255, 255, 255, 0.84));
  justify-self: start;
}

.token-banner strong,
.total-badge strong,
.order-summary strong {
  font-size: 1rem;
}

.pill {
  min-width: 1.6rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  color: #fff;
  background: var(--accent-dark);
  text-align: center;
}

.flash-stack {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.flash {
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  font-weight: 700;
}

.flash-success {
  background: rgba(31, 122, 89, 0.12);
  color: var(--success);
}

.flash-error {
  background: rgba(161, 44, 44, 0.12);
  color: var(--danger);
}

.flash-warning,
.flash-info {
  background: rgba(159, 91, 17, 0.12);
  color: var(--warning);
}

.content-area,
.detail-layout,
.orders-stack {
  display: grid;
  gap: 1.5rem;
}

.hero-card,
.section-heading,
.checkout-panel,
.token-card,
.auth-card {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
}

.checkout-actions,
.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  align-items: center;
}

.search-form {
  min-width: min(100%, 24rem);
}

.inline-form,
.compact-form {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.compact-form input {
  width: 6rem;
}

.stack-form {
  display: grid;
  gap: 0.85rem;
  width: min(100%, 24rem);
  margin-top: 1.25rem;
}

.variant-stock-list {
  display: grid;
  gap: 0.7rem;
  margin-top: 0.25rem;
}

.variant-stock-item {
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  align-items: center;
  padding: 0.9rem 1rem;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(29, 36, 51, 0.08);
}

.variant-stock-meta {
  display: grid;
  gap: 0.2rem;
  text-align: right;
  color: var(--ink-soft);
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.25rem;
  margin-top: 1.5rem;
}

.product-card {
  display: grid;
  gap: 1rem;
  padding: 1rem;
}

.product-visual,
.detail-visual {
  display: grid;
  place-items: center;
  border-radius: calc(var(--radius-md) + 2px);
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(255, 213, 191, 0.72), rgba(255, 255, 255, 0.92));
  min-height: 220px;
}

.product-visual img,
.detail-visual img {
  padding: 1rem;
  width: auto;
  height: auto;
  max-width: 100%;
  object-fit: contain;
  image-rendering: auto;
  image-rendering: -webkit-optimize-contrast;
}

.product-visual img {
  max-height: 180px;
}

.detail-visual img {
  max-height: 320px;
}

.detail-card {
  display: grid;
  gap: 1.5rem;
  padding: 1.5rem;
}

.product-reference {
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-dark);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
  margin: 1.2rem 0;
}

.stats-grid div {
  padding: 1rem;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.7);
}

.stats-grid dd {
  margin: 0.35rem 0 0;
  font-size: 1.15rem;
  font-weight: 800;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: space-between;
  align-items: center;
}

.product-name-link {
  font-weight: 800;
  color: var(--ink-strong);
}

.catalog-product-cell {
  display: flex;
  gap: 0.9rem;
  align-items: center;
  min-width: 260px;
}

.catalog-product-thumb {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  flex: 0 0 64px;
  border-radius: 14px;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(255, 213, 191, 0.72), rgba(255, 255, 255, 0.92));
  border: 1px solid rgba(29, 36, 51, 0.08);
  color: var(--ink-soft);
  font-size: 0.72rem;
  font-weight: 700;
  text-align: center;
}

.catalog-product-thumb img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  padding: 0.35rem;
}

.catalog-product-meta {
  min-width: 0;
}

.catalog-action-cell {
  width: 1%;
  white-space: nowrap;
}

.table-card,
.order-card,
.empty-state {
  padding: 1.5rem;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(29, 36, 51, 0.42);
  backdrop-filter: blur(6px);
  z-index: 20;
}

.modal-card {
  position: relative;
  display: grid;
  gap: 1rem;
  width: min(100%, 420px);
  padding: 1.5rem;
  background: rgba(255, 252, 247, 0.97);
  border: 1px solid var(--paper-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.modal-close {
  justify-self: end;
  color: var(--ink-soft);
  font-size: 0.9rem;
  font-weight: 700;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  padding: 1rem;
  background: rgba(29, 36, 51, 0.34);
  backdrop-filter: blur(4px);
  z-index: 30;
}

.loading-overlay.is-visible {
  display: grid;
}

.loading-card {
  display: grid;
  justify-items: center;
  gap: 1rem;
  min-width: 260px;
  padding: 1.4rem 1.6rem;
  background: rgba(255, 252, 247, 0.98);
  border: 1px solid var(--paper-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  text-align: center;
}

.loading-card-inline {
  margin: 0 auto;
}

.catalog-loading-state {
  display: grid;
  place-items: center;
  min-height: 320px;
}

.loading-spinner {
  width: 46px;
  height: 46px;
  border: 4px solid rgba(216, 97, 43, 0.18);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 1rem 0.9rem;
  text-align: left;
  border-bottom: 1px solid rgba(29, 36, 51, 0.08);
}

th {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-soft);
}

tbody tr:last-child td {
  border-bottom: none;
}

.order-head {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.image-placeholder {
  display: grid;
  place-items: center;
  min-height: 220px;
  padding: 1rem;
  color: var(--ink-soft);
  font-weight: 700;
}

.image-placeholder.large {
  min-height: 340px;
}

.empty-state {
  display: grid;
  gap: 0.8rem;
  justify-items: start;
}

@media (min-width: 860px) {
  .site-header {
    grid-template-columns: 1.7fr 1.1fr auto;
    align-items: center;
  }

  .detail-card {
    grid-template-columns: minmax(300px, 0.95fr) minmax(0, 1.05fr);
    align-items: start;
  }
}

@media (max-width: 720px) {
  .page-shell {
    width: min(100% - 1rem, 1180px);
  }

  .site-header,
  .hero-card,
  .section-heading,
  .checkout-panel,
  .token-card,
  .table-card,
  .order-card,
  .empty-state {
    padding: 1.15rem;
    border-radius: 22px;
  }

  .inline-form,
  .compact-form,
  .card-actions,
  .checkout-actions,
  .modal-actions,
  .variant-stock-item {
    flex-direction: column;
    align-items: stretch;
  }

  .compact-form input {
    width: 100%;
  }

  .variant-stock-meta {
    text-align: left;
  }
}
