:root {
  color-scheme: light dark;
  --bg: #f5f5f2;
  --ink: #171817;
  --muted: #666d66;
  --panel: #ffffff;
  --field: #ffffff;
  --field-disabled: #f1f2ef;
  --media-bg: #e9ebe6;
  --line: #d9ddd8;
  --line-strong: #b9c0b8;
  --accent: #1f7a4d;
  --accent-dark: #125534;
  --danger: #a64034;
  --shadow: 0 14px 38px rgba(17, 24, 20, 0.1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101211;
    --ink: #f2f4f0;
    --muted: #a5aea6;
    --panel: #171b18;
    --field: #111512;
    --field-disabled: #202620;
    --media-bg: #222821;
    --line: #2d352f;
    --line-strong: #465047;
    --accent: #3fc982;
    --accent-dark: #2fa368;
    --danger: #e18c7d;
    --shadow: 0 14px 38px rgba(0, 0, 0, 0.34);
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  padding-bottom: 7.5rem;
  background: var(--bg);
  color: var(--ink);
  font-family: Tahoma, Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  min-height: 4.5rem;
  padding: 0.75rem clamp(1rem, 4vw, 3rem);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 2.75rem;
  height: 2.75rem;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 900;
}

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

.brand small {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 0.1rem;
}

main {
  width: min(1280px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.5rem 0 4rem;
}

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

.eyebrow {
  color: var(--accent);
  font-weight: 800;
  margin: 0 0 0.35rem;
}

h1 {
  font-size: clamp(1.9rem, 4vw, 3.6rem);
  line-height: 1.05;
  margin: 0;
}

.visible-count {
  color: var(--muted);
  direction: ltr;
  margin: 0 0 0.3rem;
  min-width: max-content;
}

.tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(11rem, 16rem);
  gap: 0.75rem;
  align-items: end;
  margin-bottom: 1rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.search-box,
.category-box {
  display: grid;
  gap: 0.35rem;
}

.search-box span,
.category-box span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.search-box input,
.category-box select,
.quantity-input {
  width: 100%;
  min-height: 2.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  color: var(--ink);
  outline: none;
  padding: 0.75rem 0.85rem;
}

.search-box input:focus,
.category-box select:focus,
.quantity-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 122, 77, 0.12);
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(162px, 1fr));
  gap: 0.9rem;
}

.product-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 1px 0 rgba(17, 24, 20, 0.04);
}

.product-card.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(31, 122, 77, 0.22), var(--shadow);
}

.product-media-button {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  cursor: zoom-in;
  padding: 0;
}

.product-media {
  aspect-ratio: 1;
  background: var(--media-bg);
}

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

.product-body {
  display: grid;
  gap: 0.55rem;
  padding: 0.75rem;
}

.product-body strong {
  direction: ltr;
  font-size: 0.98rem;
}

.product-body > span {
  color: var(--muted);
  font-size: 0.82rem;
  min-height: 1.1rem;
}

.select-product {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  min-height: 2.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  padding: 0.65rem 0.75rem;
}

.select-product input {
  width: 1.15rem;
  height: 1.15rem;
  accent-color: var(--accent);
}

.quantity-input:disabled {
  background: var(--field-disabled);
  color: var(--muted);
}

.empty {
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  margin: 1rem 0 0;
  padding: 2rem;
  text-align: center;
}

.order-panel {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: minmax(14rem, 1fr) minmax(12rem, 20rem) auto;
  align-items: center;
  gap: 1rem;
  padding: 0.8rem clamp(1rem, 4vw, 3rem);
  background: color-mix(in srgb, var(--panel) 96%, transparent);
  border-top: 1px solid var(--line);
  box-shadow: 0 -12px 34px rgba(17, 24, 20, 0.08);
}

.order-panel strong,
.order-panel span {
  display: block;
}

.order-panel span {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 0.15rem;
}

.customer-field {
  display: grid;
  gap: 0.25rem;
}

.customer-field span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  margin: 0;
}

.customer-field input {
  width: 100%;
  min-height: 2.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  color: var(--ink);
  outline: none;
  padding: 0.65rem 0.8rem;
}

.customer-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 122, 77, 0.12);
}

.order-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.order-actions span {
  display: grid;
  min-width: 2.75rem;
  height: 2.75rem;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  margin: 0;
}

.order-actions button {
  min-height: 2.75rem;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 800;
  padding: 0.7rem 1rem;
}

.order-actions button:first-of-type {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--danger);
}

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

.preview-dialog {
  width: min(760px, calc(100vw - 1.5rem));
  border: 0;
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  padding: 0;
  box-shadow: var(--shadow);
}

.preview-dialog::backdrop {
  background: rgba(0, 0, 0, 0.62);
}

.close-button {
  position: absolute;
  top: 0.65rem;
  left: 0.65rem;
  z-index: 1;
  display: grid;
  width: 2.4rem;
  height: 2.4rem;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.72);
  color: white;
  cursor: pointer;
  font-size: 1.4rem;
}

.preview-media {
  max-height: 72vh;
  background: var(--media-bg);
}

.preview-media img,
.preview-media video {
  display: block;
  width: 100%;
  max-height: 72vh;
  object-fit: contain;
}

.preview-details {
  padding: 1rem;
}

@media (max-width: 700px) {
  body {
    padding-bottom: 11rem;
    font-size: 15px;
  }

  .topbar {
    position: static;
    min-height: 3.8rem;
    padding: 0.55rem 0.8rem;
  }

  .brand {
    gap: 0.55rem;
  }

  .brand-mark {
    width: 2.35rem;
    height: 2.35rem;
  }

  .brand strong {
    font-size: 1.05rem;
  }

  .brand small {
    font-size: 0.76rem;
  }

  main {
    width: min(100% - 0.75rem, 1280px);
    padding-top: 0.75rem;
  }

  .section-head,
  .tools,
  .order-panel {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .section-head,
  .order-panel {
    display: grid;
  }

  .section-head {
    gap: 0.45rem;
    margin-bottom: 0.65rem;
  }

  .eyebrow {
    font-size: 0.82rem;
    margin-bottom: 0.2rem;
  }

  h1 {
    font-size: 1.45rem;
  }

  .visible-count {
    font-size: 0.82rem;
  }

  .tools {
    gap: 0.55rem;
    margin-bottom: 0.75rem;
    padding: 0.55rem;
  }

  .search-box span,
  .category-box span {
    font-size: 0.76rem;
  }

  .search-box input,
  .category-box select,
  .quantity-input {
    min-height: 2.35rem;
    padding: 0.55rem 0.65rem;
  }

  .gallery {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
  }

  .product-body {
    gap: 0.4rem;
    padding: 0.5rem;
  }

  .product-body strong {
    font-size: 0.88rem;
  }

  .product-body > span {
    font-size: 0.74rem;
    min-height: 0.9rem;
  }

  .select-product {
    min-height: 2.25rem;
    padding: 0.45rem 0.55rem;
  }

  .select-product input {
    width: 1rem;
    height: 1rem;
  }

  .order-panel {
    gap: 0.55rem;
    padding: 0.6rem 0.75rem;
  }

  .order-panel span {
    font-size: 0.78rem;
  }

  .customer-field input {
    min-height: 2.35rem;
    padding: 0.5rem 0.65rem;
  }

  .order-actions {
    justify-content: stretch;
    gap: 0.4rem;
  }

  .order-actions span {
    min-width: 2.35rem;
    height: 2.35rem;
  }

  .order-actions button {
    flex: 1;
    min-height: 2.35rem;
    padding: 0.5rem 0.7rem;
  }
}
