:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --panel: #ffffff;
  --ink: #17211c;
  --muted: #66736c;
  --line: #dfe5dd;
  --accent: #c94f5d;
  --accent-dark: #903640;
  --leaf: #2f6b4f;
  --leaf-soft: #e5f0e7;
  --sky: #e8f0f4;
  --warn: #b86120;
  --shadow: 0 18px 60px rgba(23, 33, 28, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 380px;
  min-height: 100vh;
}

.app-shell.cart-closed {
  grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar,
.cart-panel {
  background: var(--panel);
  border-color: var(--line);
  border-style: solid;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px;
  border-width: 0 1px 0 0;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  color: white;
  background: var(--leaf);
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small,
.eyebrow,
.auth-card p,
.status-line,
.cart-total span {
  color: var(--muted);
}

.brand small {
  margin-top: 2px;
  font-size: 12px;
}

.account-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 6px;
}

.account-icon {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: white;
}

.account-icon:hover,
.category-toggle:hover {
  border-color: #c7ddcc;
  background: var(--leaf-soft);
}

.nav-list {
  display: grid;
  gap: 8px;
}

.category-nav {
  grid-template-columns: 1fr;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.category-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: white;
  font-weight: 800;
}

.category-toggle svg {
  transition: transform 0.18s ease;
}

.category-nav:not(.collapsed) .category-toggle svg {
  transform: rotate(180deg);
}

.category-menu {
  display: grid;
  gap: 8px;
}

.category-nav.collapsed .category-menu {
  display: none;
}

.nav-item,
.category-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 12px;
  text-align: left;
  color: var(--ink);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
}

.nav-item span,
.nav-item small,
.category-item span,
.category-item small {
  display: block;
}

.nav-item small,
.category-item small {
  color: var(--muted);
  font-size: 12px;
}

.nav-item.active,
.category-item.active {
  background: var(--leaf-soft);
  border-color: #c7ddcc;
}

.auth-card {
  margin-top: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #f7faf8 100%);
}

.auth-card h2,
.cart-head h2,
.modal-head h2 {
  margin: 0;
  font-size: 20px;
}

.auth-card p {
  margin: 8px 0 0;
  line-height: 1.45;
  font-size: 14px;
}

.auth-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.main-content {
  min-width: 0;
  padding: 28px;
}

.toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.toolbar h1 {
  max-width: 760px;
  margin: 4px 0 0;
  font-size: clamp(32px, 5vw, 56px);
  line-height: 1;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.cart-toggle,
.icon-btn {
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  color: var(--ink);
  background: var(--panel);
}

.cart-toggle {
  position: relative;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  border-radius: 8px;
}

.cart-toggle span {
  position: absolute;
  top: -8px;
  right: -8px;
  display: grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  border-radius: 999px;
  color: white;
  background: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

.filters {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  align-items: end;
  gap: 12px;
  margin-bottom: 16px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 54px;
  min-height: 54px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
}

.select-row {
  display: flex;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

select,
input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: white;
  outline-color: var(--leaf);
}

select,
input {
  height: 54px;
  min-height: 54px;
  padding: 0 12px;
}

textarea {
  min-height: 96px;
  padding: 12px;
  resize: vertical;
}

.status-line {
  min-height: 24px;
  margin: 8px 0 14px;
  font-size: 14px;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
}

.view-section {
  min-width: 0;
}

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

.section-toolbar h2 {
  margin: 2px 0 0;
  font-size: 28px;
}

.order-list {
  display: grid;
  gap: 12px;
}

.order-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.order-card-head,
.order-card-foot {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.order-id {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--leaf);
  background: var(--leaf-soft);
  font-size: 12px;
  font-weight: 850;
  text-transform: capitalize;
}

.status-badge.cancelled {
  color: #9b2f3b;
  background: #fde8eb;
}

.status-badge.delivered {
  color: #245d45;
  background: #dff1e5;
}

.order-items {
  display: grid;
  gap: 8px;
}

.order-item-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.order-item-row strong,
.order-item-row span {
  min-width: 0;
}

.order-item-row > div {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.review-order-btn {
  justify-self: start;
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
}

.order-address {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

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

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

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.stat-card strong {
  display: block;
  margin-top: 6px;
  font-size: 26px;
}

.admin-table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.admin-products {
  display: grid;
  gap: 14px;
  margin: 18px 0;
}

.section-toolbar.compact {
  margin-bottom: 0;
}

.product-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(140px, 1fr));
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.product-form .wide {
  grid-column: span 2;
}

.product-form button {
  align-self: end;
}

.form-actions {
  display: flex;
  align-items: end;
  gap: 8px;
}

.admin-product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.admin-product-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.admin-product-card img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  background: var(--sky);
}

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

.admin-product-body h3 {
  margin: 0;
  font-size: 16px;
}

.admin-product-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.button-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.button-row .ghost-btn,
.button-row .danger-btn {
  width: 72px;
  min-width: 72px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  font-size: 14px;
  font-weight: 750;
}

.compact-btn {
  min-height: 36px;
  padding: 0 12px;
}

.admin-users {
  display: grid;
  gap: 14px;
  margin: 20px 0;
}

.danger-btn {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid #f0c4c9;
  border-radius: 8px;
  color: #9b2f3b;
  background: #fde8eb;
  font-weight: 800;
}

.admin-table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
}

.admin-table th,
.admin-table td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

.admin-table th {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.admin-table tr:last-child td {
  border-bottom: 0;
}

.admin-table select {
  min-width: 150px;
}

.muted {
  color: var(--muted);
}

.product-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 1px 0 rgba(23, 33, 28, 0.04);
  cursor: pointer;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.product-card:hover,
.product-card:focus-visible {
  border-color: #c7ddcc;
  box-shadow: 0 10px 30px rgba(23, 33, 28, 0.1);
  outline: 0;
  transform: translateY(-1px);
}

.product-image {
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--sky);
}

.product-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.stock-pill,
.rating-badge,
.color-dot {
  position: absolute;
  border-radius: 999px;
}

.stock-pill {
  left: 10px;
  top: 10px;
  padding: 6px 9px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.9);
  font-size: 12px;
  font-weight: 800;
}

.stock-pill.low {
  color: var(--warn);
}

.rating-badge {
  right: 12px;
  top: 12px;
  min-width: 42px;
  padding: 6px 9px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.94);
  font-size: 12px;
  font-weight: 850;
  text-align: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
}

.rating-badge::before {
  content: "\2605 ";
  color: #d6a334;
}

.color-dot {
  right: 12px;
  bottom: 12px;
  width: 22px;
  height: 22px;
  border: 2px solid white;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.16);
}

.product-info {
  display: grid;
  gap: 12px;
  padding: 14px;
}

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

.product-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  padding: 5px 8px;
  border-radius: 999px;
  color: var(--muted);
  background: #f2f5f1;
  font-size: 12px;
}

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

.price {
  font-size: 22px;
  font-weight: 850;
}

.primary-btn,
.secondary-btn,
.ghost-btn {
  min-height: 42px;
  padding: 0 14px;
  border-radius: 8px;
  font-weight: 800;
}

.primary-btn {
  border: 0;
  color: white;
  background: var(--accent);
}

.primary-btn:hover {
  background: var(--accent-dark);
}

.secondary-btn {
  border: 0;
  color: white;
  background: var(--leaf);
}

.ghost-btn {
  border: 1px solid var(--line);
  color: var(--ink);
  background: white;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 8px;
}

.cart-panel {
  position: sticky;
  top: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  padding: 22px;
  border-width: 0 0 0 1px;
}

.cart-panel.cart-closed {
  display: none;
}

.cart-head,
.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.cart-items {
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 18px 2px;
}

.empty-state {
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.empty-state.compact {
  padding: 14px;
  font-size: 13px;
}

.cart-item {
  display: grid;
  grid-template-columns: 62px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.cart-item img {
  width: 62px;
  height: 62px;
  border-radius: 8px;
  object-fit: cover;
}

.cart-item h3 {
  margin: 0 0 4px;
  font-size: 14px;
}

.cart-item p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.qty-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.qty-controls button {
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.checkout-form {
  display: grid;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.cart-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 16px;
}

.cart-total strong {
  font-size: 28px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(23, 33, 28, 0.44);
}

.auth-modal,
.review-modal {
  display: grid;
  gap: 14px;
  width: min(440px, 100%);
  padding: 22px;
  border-radius: 8px;
  background: white;
  box-shadow: var(--shadow);
}

.product-modal {
  overflow: hidden;
  display: flex;
  width: min(860px, 100%);
  max-height: min(720px, calc(100vh - 40px));
  border-radius: 8px;
  background: white;
  box-shadow: var(--shadow);
}

.product-modal-media {
  flex: 0.9;
  min-width: 260px;
  min-height: 360px;
  background: var(--sky);
}

.product-modal-media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-modal-body {
  flex: 1;
  min-width: 320px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px;
}

.product-modal-body h2 {
  margin: 2px 0 0;
  font-size: 28px;
  line-height: 1.1;
}

.product-modal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.product-modal-description {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.product-modal-body > * {
  flex-shrink: 0;
}

.product-modal-reviews {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  min-height: 0;
}

.reviews-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-shrink: 0;
}

.reviews-head h3 {
  margin: 2px 0 0;
  font-size: 18px;
}

.sold-count {
  flex: 0 0 auto;
  padding: 6px 9px;
  border-radius: 999px;
  color: var(--muted);
  background: #f2f5f1;
  font-size: 12px;
  font-weight: 800;
}

.review-list {
  flex: 1;
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 10px;
  overflow-y: auto;
  padding-right: 4px;
}

.review-list::-webkit-scrollbar {
  width: 6px;
}

.review-list::-webkit-scrollbar-track {
  background: transparent;
}

.review-list::-webkit-scrollbar-thumb {
  background: #dfe4dd;
  border-radius: 4px;
}

.review-item {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.review-item div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.review-item strong::before {
  content: "\2605 ";
  color: #d6a334;
}

.review-item span,
.review-item p {
  color: var(--muted);
}

.review-item span {
  font-size: 12px;
}

.review-item p {
  margin: 0;
  line-height: 1.45;
}

.product-modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  margin-top: auto;
}

.product-modal-actions strong {
  font-size: 28px;
}

.product-modal-actions .primary-btn {
  min-width: 140px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 30;
  transform: translateX(-50%) translateY(16px);
  max-width: min(560px, calc(100vw - 32px));
  padding: 12px 14px;
  border-radius: 8px;
  color: white;
  background: var(--ink);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .cart-panel {
    position: fixed;
    inset: 0 0 0 auto;
    z-index: 10;
    width: min(420px, 100vw);
    transform: translateX(100%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow);
  }

  .cart-panel.open {
    transform: translateX(0);
  }
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 16px;
    border-width: 0 0 1px;
  }

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

  .category-nav,
  .category-menu {
    grid-template-columns: 1fr;
  }

  .main-content {
    padding: 18px 14px 28px;
  }

  .toolbar h1 {
    font-size: 36px;
  }

  .filters,
  .select-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .product-grid {
    grid-template-columns: 1fr;
  }

  .product-modal {
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 28px);
  }

  .product-modal-media {
    flex-shrink: 0;
    min-height: 240px;
    max-height: 320px;
  }

  .product-modal-body {
    flex: 1;
    min-height: 0;
  }

  .order-card-head,
  .order-card-foot,
  .section-toolbar {
    display: grid;
  }

  .admin-stats {
    grid-template-columns: 1fr 1fr;
  }

  .product-form {
    grid-template-columns: 1fr;
  }

  .product-form .wide {
    grid-column: auto;
  }
}
