:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-soft: #f1f5f9;
  --ink: #020617;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --primary: #0f172a;
  --primary-hover: #1e293b;
  --cta: #0369a1;
  --cta-hover: #075985;
  --ok-bg: #ecfdf5;
  --ok: #047857;
  --warn-bg: #fff7ed;
  --warn: #c2410c;
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(180deg, #ffffff 0, var(--bg) 280px),
    var(--bg);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

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

button {
  cursor: pointer;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px clamp(16px, 4vw, 48px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(14px);
}

.brand,
.top-actions,
.panel-head,
.cart-total,
.form-actions,
.admin-head,
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.brand {
  justify-content: flex-start;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 54px;
  height: 46px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
}

.eyebrow {
  margin-bottom: 3px;
  color: var(--cta);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.1;
}

h2 {
  font-size: 22px;
  line-height: 1.2;
}

h3 {
  font-size: 17px;
  line-height: 1.25;
}

.server-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border: 1px solid #bbf7d0;
  border-radius: 999px;
  padding: 0 12px;
  background: var(--ok-bg);
  color: var(--ok);
  font-size: 13px;
  font-weight: 700;
}

.page {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 390px);
  gap: 22px;
  padding: 22px clamp(16px, 4vw, 48px) 40px;
}

.catalog,
.cart-panel,
.admin-shell,
.product-form,
.import-box,
.toolbar {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.catalog {
  min-width: 0;
  padding: 18px;
}

.section-head {
  margin-bottom: 16px;
}

.section-head p {
  color: var(--muted);
}

#productCount {
  white-space: nowrap;
  color: var(--muted);
  font-size: 14px;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(180px, 250px);
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px;
  box-shadow: none;
}

.field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus,
button:focus-visible {
  border-color: var(--cta);
  box-shadow: 0 0 0 3px rgba(3, 105, 161, 0.14);
}

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

.product-card {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 315px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.product-card:hover {
  border-color: #bfdbfe;
  box-shadow: 0 16px 34px rgba(15, 23, 42, 0.10);
  transform: translateY(-1px);
}

.product-image {
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 9;
  background:
    linear-gradient(135deg, #e0f2fe, #f8fafc 60%),
    var(--surface-soft);
  color: var(--cta);
  font-size: 26px;
  font-weight: 900;
}

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

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

.product-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 9px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.badge.status {
  background: var(--ok-bg);
  color: var(--ok);
}

.description {
  min-height: 42px;
  color: var(--muted);
  font-size: 14px;
}

.price-row {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
}

.price {
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 0;
}

.unit {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.primary,
.ghost,
.link,
.tab,
.icon-button {
  min-height: 42px;
  border-radius: 7px;
  transition: background 180ms ease, border-color 180ms ease, color 180ms ease, box-shadow 180ms ease;
}

.primary {
  border: 1px solid var(--cta);
  background: var(--cta);
  color: white;
  font-weight: 800;
}

.primary:hover {
  border-color: var(--cta-hover);
  background: var(--cta-hover);
}

.ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
  padding: 0 14px;
  font-weight: 800;
  text-decoration: none;
}

.ghost:hover {
  border-color: var(--primary);
}

.link {
  border: 0;
  background: transparent;
  color: var(--cta);
  padding: 0;
  font-weight: 800;
}

.cart-panel {
  position: sticky;
  top: 92px;
  align-self: start;
  display: grid;
  gap: 14px;
  padding: 18px;
}

.cart-items {
  display: grid;
  gap: 10px;
  max-height: 310px;
  overflow: auto;
}

.cart-row,
.admin-row,
.order-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.cart-row {
  display: grid;
  gap: 9px;
}

.cart-row-head,
.qty {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.qty button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: white;
}

.cart-total {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  font-size: 18px;
}

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

.order-form,
.login-form {
  display: grid;
  gap: 10px;
}

.notice,
.hint {
  color: var(--warn);
  font-size: 13px;
  font-weight: 700;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 180px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.admin-dialog {
  width: min(1120px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  border: 0;
  padding: 0;
  background: transparent;
}

.admin-dialog::backdrop {
  background: rgba(15, 23, 42, 0.55);
}

.admin-shell {
  display: grid;
  gap: 16px;
  max-height: calc(100vh - 24px);
  overflow: auto;
  padding: 20px;
}

.admin-page {
  padding: 22px clamp(16px, 4vw, 48px) 40px;
}

.admin-standalone {
  max-width: 1120px;
  margin: 0 auto;
}

.admin-content {
  display: grid;
  gap: 16px;
}

.hidden {
  display: none;
}

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

.tab {
  border: 1px solid var(--line-strong);
  background: #fff;
  padding: 0 14px;
  color: var(--ink);
  font-weight: 800;
}

.tab.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: grid;
  gap: 16px;
}

.product-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 14px;
  box-shadow: none;
}

.wide,
.form-actions {
  grid-column: 1 / -1;
}

.admin-list {
  display: grid;
  gap: 10px;
}

.admin-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  align-content: start;
  gap: 8px;
}

.order-row {
  display: grid;
  gap: 10px;
}

.order-items {
  color: var(--muted);
  font-size: 14px;
}

.import-box {
  display: grid;
  gap: 12px;
  padding: 16px;
  box-shadow: none;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}

@media (max-width: 980px) {
  .page {
    grid-template-columns: 1fr;
  }

  .cart-panel {
    position: static;
  }
}

@media (max-width: 700px) {
  .topbar,
  .section-head,
  .top-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar,
  .toolbar,
  .product-form {
    display: grid;
    grid-template-columns: 1fr;
  }

  .brand {
    align-items: flex-start;
  }
}
