:root {
  --bg: #0f1419;
  --bg-mid: #141c28;
  --surface: #1a2332;
  --muted: #8b9cb3;
  --text: #e8eef5;
  --accent: #3d9cf0;
  --accent-dim: #2b7fc4;
  --border: #2c3a4f;
  --ok: #3ecf8e;
  --err: #f07178;
  --img-area-bg: #121820;
  --placeholder-grad-a: #1e2a3d;
  --placeholder-grad-b: #141c28;
  --table-head-bg: rgba(0, 0, 0, 0.2);
  --pill-bg: rgba(61, 156, 240, 0.15);
  --shadow-toast: rgba(0, 0, 0, 0.35);
  --nav-link-pad-y: 0.5rem;
  --nav-link-pad-x: 0.65rem;
  font-family: "Segoe UI", system-ui, sans-serif;
}

html[data-theme="light"] {
  --bg: #eef1f6;
  --bg-mid: #e4e9f0;
  --surface: #ffffff;
  --muted: #5c6b80;
  --text: #1a2332;
  --accent: #156fc9;
  --accent-dim: #0f5ca8;
  --border: #c5ced9;
  --ok: #0d8f5f;
  --err: #c42b3a;
  --img-area-bg: #e8ecf2;
  --placeholder-grad-a: #dde3eb;
  --placeholder-grad-b: #cfd6e0;
  --table-head-bg: rgba(0, 40, 100, 0.06);
  --pill-bg: rgba(21, 111, 201, 0.12);
  --shadow-toast: rgba(0, 0, 0, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: linear-gradient(160deg, var(--bg) 0%, var(--bg-mid) 50%, var(--bg) 100%);
  color: var(--text);
  line-height: 1.5;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

@media (hover: none) {
  a:active {
    opacity: 0.85;
  }
}

.wrap {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 max(1rem, env(safe-area-inset-right, 0px)) max(2.5rem, env(safe-area-inset-bottom, 0px))
    max(1rem, env(safe-area-inset-left, 0px));
}

@media (min-width: 720px) {
  .wrap {
    padding: 0 max(1.25rem, env(safe-area-inset-right, 0px)) 3rem max(1.25rem, env(safe-area-inset-left, 0px));
  }
}

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.25rem;
}

@media (max-width: 719px) {
  .top {
    flex-direction: column;
    align-items: stretch;
    gap: 0.85rem;
  }
}

.brand {
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.02em;
  color: var(--text);
  padding: var(--nav-link-pad-y) 0;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

@media (min-width: 720px) {
  .brand {
    font-size: 1.15rem;
  }
}

.brand span {
  color: var(--accent);
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.65rem;
  margin-left: auto;
  align-items: center;
}

@media (max-width: 719px) {
  .nav {
    margin-left: 0;
    width: 100%;
    justify-content: flex-start;
  }
}

.nav > a {
  padding: var(--nav-link-pad-y) var(--nav-link-pad-x);
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.75rem;
  min-height: 44px;
  font: inherit;
  font-size: 0.85rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.theme-toggle__icon {
  font-size: 1rem;
  line-height: 1;
  opacity: 0.9;
}

.muted {
  color: var(--muted);
  font-size: 0.9rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.15rem;
  margin-bottom: 1rem;
}

@media (max-width: 719px) {
  .card {
    padding: 0.9rem 1rem;
  }
}

.grid {
  display: grid;
  gap: 1rem;
}

@media (min-width: 640px) {
  .grid.products {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  }
}

.product-card h3 {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
  font-weight: 600;
}

@media (min-width: 720px) {
  .product-card h3 {
    font-size: 1rem;
  }
}

.product-meta {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.price {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ok);
}

@media (min-width: 720px) {
  .price {
    font-size: 1.2rem;
  }
}

form.inline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.5rem;
}

form.inline button {
  min-height: 44px;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="email"],
input[type="file"],
textarea,
select {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem 0.65rem;
  border-radius: 6px;
  font: inherit;
  max-width: 100%;
  min-height: 44px;
}

textarea {
  width: 100%;
  min-height: 4rem;
  min-height: 5rem;
}

input[type="number"],
.qty-input {
  min-height: 44px;
}

button,
.btn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0.55rem 1rem;
  min-height: 44px;
  border-radius: 6px;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button.secondary,
.btn.secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

button:hover,
.btn:hover {
  background: var(--accent-dim);
}

button.secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.banner {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
}

.banner.ok {
  background: rgba(62, 207, 142, 0.15);
  border: 1px solid rgba(62, 207, 142, 0.35);
}

html[data-theme="light"] .banner.ok {
  background: rgba(13, 143, 95, 0.1);
  border-color: rgba(13, 143, 95, 0.35);
}

.banner.err {
  background: rgba(240, 113, 120, 0.12);
  border: 1px solid rgba(240, 113, 120, 0.35);
}

html[data-theme="light"] .banner.err {
  background: rgba(196, 43, 58, 0.08);
  border-color: rgba(196, 43, 58, 0.3);
}

.row-between {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

@media (min-width: 720px) {
  table {
    font-size: 0.95rem;
  }
}

th,
td {
  text-align: left;
  padding: 0.5rem 0.65rem;
  border-bottom: 1px solid var(--border);
}

th {
  color: var(--muted);
  font-weight: 600;
}

h1 {
  font-size: 1.35rem;
  margin: 0 0 0.85rem;
}

@media (min-width: 720px) {
  h1 {
    font-size: 1.5rem;
    margin: 0 0 1rem;
  }
}

h2 {
  font-size: 1.05rem;
  margin: 1.35rem 0 0.65rem;
}

@media (min-width: 720px) {
  h2 {
    font-size: 1.15rem;
    margin: 1.5rem 0 0.75rem;
  }
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: flex-end;
  margin-bottom: 1.25rem;
}

.filters button {
  flex-shrink: 0;
}

.pill {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: var(--pill-bg);
  color: var(--accent);
  font-size: 0.75rem;
  margin-bottom: 0.35rem;
}

.nav-cart-link {
  display: inline-flex;
  align-items: center;
}

.cart-badge {
  display: none;
  align-items: center;
  justify-content: center;
  min-width: 1.35rem;
  height: 1.35rem;
  padding: 0 0.4rem;
  font-size: 0.72rem;
  font-weight: 700;
  background: var(--ok);
  color: #fff;
  border-radius: 999px;
  margin-left: 0.35rem;
  line-height: 1;
}

.catalog-layout {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

@media (min-width: 880px) {
  .catalog-layout {
    flex-direction: row;
    align-items: flex-start;
    gap: 2rem;
  }

  .catalog-sidebar {
    flex: 0 0 260px;
    position: sticky;
    top: 0.75rem;
  }
}

.catalog-sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.1rem;
}

.sidebar-heading {
  margin: 0 0 0.65rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.sidebar-label {
  display: block;
  margin-bottom: 0.45rem;
  font-size: 0.85rem;
}

.cat-sidebar-form .cat-select-dropdown {
  width: 100%;
  min-height: 48px;
}

.catalog-main {
  flex: 1;
  min-width: 0;
}

.catalog-title {
  margin-bottom: 0.35rem;
}

.catalog-lead {
  margin-top: 0;
  margin-bottom: 1rem;
}

.catalog-search {
  margin-bottom: 1.25rem;
}

.catalog-search-input {
  flex: 1;
  min-width: 0;
  width: 100%;
}

@media (min-width: 480px) {
  .catalog-search-input {
    min-width: 180px;
    width: auto;
  }
}

.catalog-grid {
  margin-top: 0.25rem;
}

.grid.products.catalog-grid {
  grid-template-columns: 1fr;
}

@media (min-width: 480px) {
  .grid.products.catalog-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 900px) {
  .grid.products.catalog-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  }
}

.product-card {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.product-card__media {
  background: var(--img-area-bg);
  border-bottom: 1px solid var(--border);
}

.product-card__img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.product-card__img--placeholder {
  background: linear-gradient(145deg, var(--placeholder-grad-a) 0%, var(--placeholder-grad-b) 100%);
  min-height: 140px;
}

@media (min-width: 720px) {
  .product-card__img--placeholder {
    min-height: 160px;
  }
}

.product-card__body {
  padding: 0.9rem 1rem 1rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.product-card__body .price {
  margin-top: auto;
}

.product-card__body form.inline {
  margin-top: 0.65rem;
}

.qty-input {
  width: 3.75rem;
}

.cart-toast {
  position: fixed;
  bottom: max(1rem, env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  max-width: calc(100vw - 2rem);
  padding: 0.65rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--ok);
  color: var(--ok);
  border-radius: 8px;
  font-size: 0.9rem;
  box-shadow: 0 8px 24px var(--shadow-toast);
  text-align: center;
}

.admin-products-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.admin-products-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

@media (min-width: 720px) {
  .admin-products-table {
    font-size: 0.9rem;
  }
}

.admin-products-table th,
.admin-products-table td {
  vertical-align: top;
  padding: 0.65rem 0.75rem;
}

@media (min-width: 720px) {
  .admin-products-table th,
  .admin-products-table td {
    padding: 0.75rem 1rem;
  }
}

.admin-products-table th {
  background: var(--table-head-bg);
}

.admin-product-thumb-cell {
  width: 88px;
}

.admin-product-thumb {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
  display: block;
  border: 1px solid var(--border);
}

.admin-product-thumb--empty {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: var(--muted);
  background: var(--bg);
}

.cart-page-table-wrap,
.checkout-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
