:root {
  color-scheme: light;
  --bg: #eef2f7;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --ink: #172033;
  --muted: #64748b;
  --line: #dbe3ef;
  --primary: #111827;
  --primary-soft: #e5e7eb;
  --success: #15803d;
  --shadow: 0 24px 80px rgba(15, 23, 42, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top left, #ffffff 0, var(--bg) 36rem);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(20rem, 28rem) minmax(24rem, 1fr) minmax(18rem, 24rem);
  gap: 1rem;
  height: 100vh;
  padding: 1rem;
  overflow: hidden;
}

.catalog-sidebar,
.details-panel,
.cart-sidebar {
  min-height: 0;
  border: 1px solid rgba(219, 227, 239, 0.9);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.catalog-sidebar,
.details-panel,
.cart-sidebar {
  position: sticky;
  top: 1rem;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 2rem);
  overflow: hidden;
  border-radius: 1.5rem;
}

.catalog-sidebar,
.details-panel,
.cart-sidebar {
  padding: 1.1rem;
}

.catalog-header,
.cart-card,
.details-card {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.catalog-header {
  flex: 0 0 auto;
  gap: 0.85rem;
  margin-bottom: 1rem;
}

.eyebrow {
  margin: 0 0 0.4rem;
  color: #475569;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0.75rem;
  font-size: clamp(1.6rem, 4vw, 2.5rem);
  line-height: 0.95;
}

h2 {
  margin-bottom: 0.6rem;
  line-height: 1.05;
}

p {
  color: var(--muted);
  line-height: 1.55;
}

.details-panel {
  overflow-y: auto;
}

.details-card,
.cart-card {
  flex: 1;
}

.details-card {
  gap: 1rem;
}

.details-image {
  display: grid;
  min-height: clamp(12rem, 32vh, 22rem);
  place-items: end start;
  padding: 1rem;
  border-radius: 1.2rem;
  background: linear-gradient(135deg, #cbd5e1, #111827);
  color: #ffffff;
  overflow: hidden;
}

.details-image span {
  max-width: 13rem;
  font-size: 1.5rem;
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 2px 20px rgba(0, 0, 0, 0.35);
}

.details-copy {
  padding: 0;
}

.details-copy h2 {
  font-size: 1.45rem;
}

.details-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin: 0 0 1rem;
}

.details-meta div {
  min-width: 0;
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--panel-soft);
}

.details-meta dt {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.details-meta dd {
  margin: 0.25rem 0 0;
  overflow-wrap: anywhere;
  font-weight: 800;
}

.details-actions {
  display: grid;
  grid-template-columns: auto 5rem 1fr;
  gap: 0.6rem;
  align-items: center;
  margin-top: auto;
  position: sticky;
  bottom: 0;
  padding-top: 0.75rem;
  background: linear-gradient(180deg, rgba(255,255,255,0), rgba(255,255,255,0.98) 30%);
}

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  background: #ffffff;
  color: var(--ink);
  padding: 0.72rem 0.8rem;
}

.primary-button,
.checkout-button,
.add-button,
.ghost-button,
.clear-cart-button,
.remove-item-button {
  border: 0;
  border-radius: 999px;
  font-weight: 850;
  transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

.primary-button,
.checkout-button,
.add-button {
  background: var(--primary);
  color: #ffffff;
}

.primary-button,
.checkout-button {
  padding: 0.8rem 1rem;
}

.add-button {
  padding: 0.55rem 0.8rem;
}

.ghost-button,
.clear-cart-button {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
  padding: 0.7rem 0.9rem;
}

.clear-cart-button {
  margin-bottom: 1rem;
}

.remove-item-button {
  display: inline-grid;
  width: 2.2rem;
  height: 2.2rem;
  place-items: center;
  border: 1px solid #fecaca;
  background: #fff1f2;
  color: #be123c;
  font-size: 1.2rem;
  line-height: 1;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.catalog-tools {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.search-field {
  display: grid;
  min-width: 100%;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.category-stack {
  flex: 1;
  overflow-y: auto;
  padding-right: 0.35rem;
}

.category-section {
  margin-bottom: 1rem;
  border: 1px solid var(--line);
  border-left: 0.45rem solid var(--category-accent, var(--primary));
  border-radius: 1.1rem;
  background: var(--panel);
  overflow: hidden;
}

.category-section summary {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  font-size: 1.05rem;
  font-weight: 900;
  list-style: none;
  cursor: pointer;
}

.category-section summary::-webkit-details-marker {
  display: none;
}

.category-section summary small {
  color: var(--muted);
  font-size: 0.8rem;
}

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

th,
td {
  padding: 0.85rem 1rem;
  border-top: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  background: var(--panel-soft);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

tbody tr {
  transition: background 0.18s ease, box-shadow 0.18s ease;
}

tbody tr:hover,
tbody tr.is-selected {
  background: #f1f5f9;
}

tbody tr.is-selected {
  box-shadow: inset 0 0 0 2px rgba(17, 24, 39, 0.12);
}

.product-link {
  display: block;
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 0;
  font-weight: 900;
  text-align: left;
}

td span {
  display: block;
  margin-top: 0.3rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.row-qty,
.cart-line input {
  max-width: 4.6rem;
  padding: 0.55rem;
}

.cart-header,
.cart-summary div,
.cart-line,
.cart-line-controls {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
}

.cart-header {
  margin-bottom: 1rem;
}

.cart-count {
  border-radius: 999px;
  background: var(--primary-soft);
  padding: 0.45rem 0.7rem;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 900;
}

.cart-items {
  flex: 1;
  min-height: 12rem;
  overflow-y: auto;
}

.empty-cart,
.no-results {
  border: 1px dashed var(--line);
  border-radius: 1rem;
  padding: 1rem;
  text-align: center;
}

.cart-line {
  margin-bottom: 0.75rem;
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--panel-soft);
}

.cart-line-controls {
  flex: 0 0 auto;
  gap: 0.45rem;
}

.cart-line strong,
.cart-line span {
  display: block;
}

.cart-line span {
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.cart-summary {
  display: grid;
  gap: 0.65rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.cart-summary span {
  color: var(--muted);
}

.total-row {
  color: var(--ink);
  font-size: 1.25rem;
}

.checkout-button {
  margin-top: 1rem;
  width: 100%;
  background: var(--success);
}

.checkout-note {
  margin: 0.8rem 0 0;
  font-size: 0.82rem;
  text-align: center;
}

.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: 1180px) {
  .app-shell {
    grid-template-columns: minmax(18rem, 24rem) minmax(24rem, 1fr);
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .catalog-sidebar,
  .details-panel,
  .cart-sidebar {
    position: static;
    height: auto;
  }

  .cart-sidebar {
    grid-column: 1 / -1;
  }

  .category-stack {
    max-height: 60vh;
  }

  .details-panel {
    max-height: none;
  }
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
    padding: 0.5rem;
  }

  .catalog-tools {
    grid-template-columns: 1fr;
  }

  .search-field {
    min-width: 100%;
  }

  th:nth-child(2),
  td:nth-child(2) {
    display: none;
  }

  .details-actions {
    grid-template-columns: 1fr;
  }
}
