:root {
  --ink: #1e2228;
  --muted: #67707d;
  --line: #d9dee6;
  --paper: #fbfaf7;
  --panel: #ffffff;
  --green: #176b5b;
  --green-dark: #0e4d42;
  --coral: #d95d49;
  --gold: #d49b36;
  --blue: #315f8f;
  --shadow: 0 18px 45px rgba(30, 34, 40, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto minmax(220px, 1fr) auto;
  gap: 18px;
  align-items: center;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(251, 250, 247, 0.96);
  backdrop-filter: blur(14px);
}

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

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

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

.brand strong {
  font-size: 24px;
  letter-spacing: 0;
}

.brand small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

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

.search svg {
  flex: 0 0 auto;
  width: 19px;
}

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

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-button,
.cart-button,
.admin-button,
.ghost-button,
.primary-button,
.chip,
.quantity-button {
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease, background 140ms ease;
}

.icon-button:hover,
.cart-button:hover,
.admin-button:hover,
.ghost-button:hover,
.chip:hover,
.quantity-button:hover {
  border-color: #aeb8c5;
  transform: translateY(-1px);
}

.icon-button {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
}

.icon-button.active {
  border-color: var(--green);
  color: white;
  background: var(--green);
}

.icon-button.compact {
  width: 36px;
  height: 36px;
}

.cart-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 12px;
}

.admin-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 12px;
  font-weight: 800;
}

.admin-button.active {
  border-color: var(--green);
  color: white;
  background: var(--green);
}

.cart-button strong {
  display: grid;
  min-width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 999px;
  color: white;
  background: var(--coral);
  font-size: 13px;
}

.shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 340px;
  gap: 24px;
  align-items: start;
  padding: 26px 28px 36px;
}

.filters,
.cart-panel {
  position: sticky;
  top: 92px;
}

.filters,
.cart-panel,
.stats-row article,
.product-card,
.seller-callout {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.filters,
.cart-panel {
  padding: 18px;
  box-shadow: 0 10px 30px rgba(30, 34, 40, 0.06);
}

.panel-title,
.content-head,
.card-footer,
.rating-line,
.cart-line,
.cart-summary div,
.range-line,
.check-line {
  display: flex;
  align-items: center;
}

.panel-title,
.content-head,
.card-footer,
.cart-line,
.cart-summary div {
  justify-content: space-between;
  gap: 14px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  max-width: 760px;
  font-size: 44px;
  line-height: 1.03;
  letter-spacing: 0;
}

h2 {
  font-size: 20px;
}

h3 {
  font-size: 14px;
}

.eyebrow {
  margin-bottom: 7px;
  color: var(--coral);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.filter-group {
  padding: 20px 0;
  border-top: 1px solid var(--line);
}

.filter-group h3 {
  margin-bottom: 12px;
}

.segmented {
  display: grid;
  gap: 8px;
}

.chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 40px;
  padding: 0 11px;
  text-align: left;
}

.chip.active {
  border-color: var(--green);
  color: white;
  background: var(--green);
}

.range-line {
  gap: 12px;
}

.range-line input {
  width: 100%;
  accent-color: var(--green);
}

.range-line span {
  min-width: 74px;
  color: var(--muted);
  text-align: right;
}

.check-line {
  gap: 10px;
  min-height: 34px;
  color: var(--ink);
}

.check-line input {
  width: 18px;
  height: 18px;
  accent-color: var(--green);
}

.seller-callout {
  display: grid;
  gap: 10px;
  padding: 16px;
  background: #f1f6f4;
}

.seller-callout svg {
  color: var(--green);
}

.seller-callout p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.ghost-button {
  min-height: 34px;
  padding: 0 10px;
  color: var(--muted);
}

.ghost-button.wide {
  width: 100%;
  margin-top: 10px;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border: 0;
  background: var(--green);
  color: white;
  font-weight: 800;
}

.primary-button:hover {
  background: var(--green-dark);
  box-shadow: 0 10px 24px rgba(23, 107, 91, 0.22);
  transform: translateY(-1px);
}

.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid rgba(217, 93, 73, 0.35);
  border-radius: 8px;
  background: #fff0ed;
  color: var(--coral);
  font-weight: 800;
}

.danger-button:hover {
  border-color: var(--coral);
  background: var(--coral);
  color: white;
}

.content {
  min-width: 0;
}

.content-head {
  margin-bottom: 18px;
}

.sort {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  white-space: nowrap;
}

.sort select {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  padding: 0 10px;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.stats-row article {
  padding: 14px;
}

.stats-row strong,
.stats-row span {
  display: block;
}

.stats-row strong {
  color: var(--blue);
  font-size: 24px;
}

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

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

.product-card {
  overflow: hidden;
  min-width: 0;
  box-shadow: 0 12px 28px rgba(30, 34, 40, 0.08);
}

.product-media {
  position: relative;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  background: #eef1f4;
}

.product-media img {
  position: relative;
  z-index: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.badge {
  position: absolute;
  left: 10px;
  top: 10px;
  z-index: 2;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--green-dark);
  padding: 6px 9px;
  font-size: 12px;
  font-weight: 800;
}

.remove-photo {
  position: absolute;
  right: 10px;
  top: 10px;
  z-index: 2;
  display: none;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 8px;
  place-items: center;
  color: white;
  background: rgba(217, 93, 73, 0.95);
}

.edit-product {
  position: absolute;
  right: 52px;
  top: 10px;
  z-index: 2;
  display: none;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 8px;
  place-items: center;
  color: white;
  background: rgba(49, 95, 143, 0.95);
}

body.editing .remove-photo,
body.editing .edit-product {
  display: grid;
}

.edit-card-button {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border: 1px solid var(--blue);
  border-radius: 8px;
  background: #eef5fb;
  color: var(--blue);
  font-weight: 800;
}

body.editing .edit-card-button {
  display: inline-flex;
}

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

.product-body h3 {
  min-height: 40px;
  font-size: 17px;
  line-height: 1.2;
}

.store-name,
.rating-line,
.meta-line {
  color: var(--muted);
  font-size: 13px;
}

.rating-line {
  gap: 5px;
}

.rating-line svg {
  width: 16px;
  height: 16px;
  color: var(--gold);
  fill: currentColor;
}

.meta-line {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.meta-line span {
  border-radius: 999px;
  background: #f0f2f5;
  padding: 5px 8px;
}

.price {
  font-size: 20px;
  font-weight: 900;
}

.add-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 112px;
  padding: 0 12px;
}

.cart-panel {
  display: grid;
  max-height: calc(100vh - 118px);
  grid-template-rows: auto minmax(140px, 1fr) auto;
}

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

.cart-line {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.cart-line h3 {
  margin-bottom: 4px;
  font-size: 14px;
}

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

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

.quantity-button {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
}

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

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

.checkout {
  width: 100%;
}

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

.photo-form {
  display: grid;
  gap: 10px;
}

.add-category-form {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.photo-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.photo-form input,
.photo-form select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  padding: 0 10px;
}

.photo-form input:focus,
.photo-form select:focus {
  outline: 2px solid rgba(23, 107, 91, 0.18);
  border-color: var(--green);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(30, 34, 40, 0.46);
}

.modal[hidden] {
  display: none;
}

.modal-panel {
  display: grid;
  width: min(560px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 18px;
  box-shadow: var(--shadow);
}

.modal-panel label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

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

.modal-panel textarea {
  min-height: 88px;
  padding: 10px;
  resize: vertical;
}

.order-message {
  min-height: 22px;
  color: var(--muted);
  font-size: 14px;
}

.order-message.success {
  color: var(--green);
  font-weight: 800;
}

.order-message.error {
  color: var(--coral);
  font-weight: 800;
}

.orders-panel {
  width: min(720px, 100%);
}

.login-panel {
  width: min(420px, 100%);
}

.login-panel .primary-button {
  width: 100%;
}

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

.order-card {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfd;
}

.order-card header,
.order-card footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.order-card h3 {
  font-size: 16px;
}

.order-card p,
.order-card li {
  color: var(--muted);
  font-size: 13px;
}

.order-card ul {
  margin: 0;
  padding-left: 18px;
}

.edit-preview {
  overflow: hidden;
  width: 100%;
  height: 280px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef1f4;
}

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

.frame-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid var(--blue);
  border-radius: 8px;
  background: #eef5fb;
  color: var(--blue);
  font-weight: 800;
}

.frame-controls {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #f7f9fb;
}

.frame-controls[hidden] {
  display: none;
}

.frame-controls input[type="range"] {
  accent-color: var(--green);
}

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

  .cart-panel {
    position: fixed;
    top: 82px;
    right: 20px;
    bottom: 20px;
    z-index: 30;
    width: min(380px, calc(100vw - 40px));
    max-height: none;
    transform: translateX(calc(100% + 30px));
    box-shadow: var(--shadow);
    transition: transform 180ms ease;
  }

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

@media (max-width: 820px) {
  .topbar {
    grid-template-columns: 1fr auto;
    padding: 12px 16px;
  }

  .search {
    grid-column: 1 / -1;
    order: 3;
  }

  .top-actions {
    justify-self: end;
  }

  .shell {
    display: block;
    padding: 16px;
  }

  .filters {
    position: static;
    margin-bottom: 18px;
  }

  .content-head {
    display: grid;
    align-items: start;
  }

  h1 {
    font-size: 34px;
  }

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

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

@media (max-width: 520px) {
  .brand small,
  .cart-button span {
    display: none;
  }

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

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

  h1 {
    font-size: 30px;
  }
}
