:root {
  --brand: #2a56c6;
  --brand-dark: #1d3f94;
  --accent: #ff6f00;
  --text: #1d1d1f;
  --muted: #6b7280;
  --border: #e5e7eb;
  --bg: #f7f8fa;
  --success: #1a7f37;
  --error: #c81e1e;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Segoe UI', Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Header */
.topbar {
  background: var(--brand-dark);
  color: #fff;
  font-size: 13px;
}
.topbar .container { display: flex; justify-content: space-between; padding: 6px 20px; }

.header {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 16px 0;
}
.header .container { display: flex; align-items: center; gap: 24px; }
.logo { font-size: 22px; font-weight: 700; color: var(--brand); white-space: nowrap; }
.logo span { color: var(--accent); }

.search-form { flex: 1; display: flex; }
.search-form input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-right: none;
  border-radius: var(--radius) 0 0 var(--radius);
  font-size: 14px;
}
.search-form button {
  padding: 0 18px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 0 var(--radius) var(--radius) 0;
  cursor: pointer;
  font-weight: 600;
}

.header-actions { display: flex; align-items: center; gap: 18px; font-size: 14px; white-space: nowrap; }
.header-actions a { display: flex; align-items: center; gap: 6px; }
.cart-badge {
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  font-size: 11px;
  padding: 1px 7px;
  margin-left: 2px;
}

.nav {
  background: var(--brand);
}
.nav .container { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a {
  color: #fff;
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 500;
}
.nav a:hover, .nav a.active { background: var(--brand-dark); }

/* Flash messages */
.flash { padding: 12px 20px; margin: 16px 0; border-radius: var(--radius); font-size: 14px; }
.flash-success { background: #e6f4ea; color: var(--success); border: 1px solid #b7e1c3; }
.flash-error { background: #fdecec; color: var(--error); border: 1px solid #f5b8b8; }

/* Hero */
.hero {
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff;
  border-radius: var(--radius);
  padding: 48px 40px;
  margin: 24px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
}
.hero h1 { font-size: 32px; margin: 0 0 10px; }
.hero p { margin: 0 0 18px; opacity: 0.9; }
.btn {
  display: inline-block;
  padding: 10px 22px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
}
.btn:hover { opacity: 0.92; }
.btn-outline {
  background: transparent;
  border: 1px solid #fff;
}
.btn-secondary {
  background: #fff;
  color: var(--brand);
  border: 1px solid var(--border);
}
.btn-block { display: block; width: 100%; text-align: center; }

/* Category tiles */
.category-tiles { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; margin: 24px 0; }
.category-tile {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 10px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
}
.category-tile:hover { border-color: var(--brand); color: var(--brand); }

section.shelf { margin: 36px 0; }
.shelf-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 16px; }
.shelf-header h2 { font-size: 20px; margin: 0; }
.shelf-header a { color: var(--brand); font-size: 14px; font-weight: 600; }

/* Product grid */
.product-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
.product-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.product-card .thumb { aspect-ratio: 1 / 1; overflow: hidden; }
.product-card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.product-card-body { padding: 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.product-card .brand { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.product-card .name { font-size: 14px; font-weight: 600; min-height: 38px; }
.product-card .rating { font-size: 12px; color: var(--accent); }
.product-card .price-row { display: flex; align-items: baseline; gap: 8px; margin-top: auto; }
.price { font-size: 17px; font-weight: 700; color: var(--text); }
.price-old { font-size: 13px; color: var(--muted); text-decoration: line-through; }
.product-card form { margin-top: 8px; }

/* Layout: sidebar + listing */
.catalog-layout { display: grid; grid-template-columns: 240px 1fr; gap: 24px; margin: 24px 0; }
.filters { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; align-self: start; }
.filters h3 { font-size: 14px; margin: 18px 0 8px; }
.filters h3:first-child { margin-top: 0; }
.filters label { display: block; font-size: 13px; margin: 6px 0; }
.filters input[type="number"] { width: 100%; padding: 6px 8px; border: 1px solid var(--border); border-radius: 4px; margin-bottom: 6px; }

.listing-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; font-size: 14px; color: var(--muted); }
.listing-header select { padding: 6px 10px; border: 1px solid var(--border); border-radius: 4px; }

.pagination { display: flex; gap: 6px; justify-content: center; margin: 28px 0; }
.pagination a, .pagination span {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
  background: #fff;
}
.pagination .active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* Product detail */
.product-detail { display: grid; grid-template-columns: 420px 1fr; gap: 40px; margin: 28px 0; }
.gallery-main { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 10px; }
.gallery-thumbs { display: flex; gap: 8px; }
.gallery-thumbs .thumb-sm { width: 70px; height: 70px; border: 1px solid var(--border); border-radius: 4px; overflow: hidden; cursor: pointer; }

.pd-brand { color: var(--muted); text-transform: uppercase; font-size: 13px; letter-spacing: 0.04em; }
.pd-title { font-size: 26px; margin: 6px 0; }
.pd-rating { color: var(--accent); font-size: 14px; margin-bottom: 12px; }
.pd-price-row { display: flex; align-items: baseline; gap: 12px; margin: 16px 0; }
.pd-price { font-size: 30px; font-weight: 700; }
.pd-stock { font-size: 13px; color: var(--success); margin-bottom: 18px; }
.pd-stock.out { color: var(--error); }
.qty-row { display: flex; align-items: center; gap: 12px; margin: 18px 0; }
.qty-row input { width: 70px; padding: 8px; border: 1px solid var(--border); border-radius: 4px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 36px 0 0; }
.tabs button {
  padding: 10px 18px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
}
.tabs button.active { color: var(--brand); border-color: var(--brand); }
.tab-panel { padding: 20px 0; display: none; }
.tab-panel.active { display: block; }
.spec-table { width: 100%; border-collapse: collapse; }
.spec-table td { padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.spec-table td:first-child { color: var(--muted); width: 200px; }

/* Forms (auth/checkout) */
.form-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  max-width: 460px;
  margin: 32px auto;
}
.form-card h1 { font-size: 22px; margin-top: 0; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field input, .field select { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-footer-link { text-align: center; margin-top: 16px; font-size: 14px; color: var(--muted); }
.form-footer-link a { color: var(--brand); font-weight: 600; }

/* Cart / checkout */
.cart-table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.cart-table th { text-align: left; background: #fafafa; padding: 12px 16px; font-size: 12px; text-transform: uppercase; color: var(--muted); }
.cart-table td { padding: 14px 16px; border-top: 1px solid var(--border); font-size: 14px; vertical-align: middle; }
.cart-item-info { display: flex; align-items: center; gap: 14px; }
.cart-item-info img { width: 56px; height: 56px; border-radius: 6px; }
.cart-qty-input { width: 60px; padding: 6px; border: 1px solid var(--border); border-radius: 4px; }
.remove-link { color: var(--error); font-size: 13px; }

.checkout-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 28px; margin: 24px 0; }
.checkout-steps { display: flex; gap: 8px; margin: 20px 0; font-size: 13px; color: var(--muted); }
.checkout-steps .step { padding: 6px 14px; border-radius: 999px; background: #eef1f5; }
.checkout-steps .step.active { background: var(--brand); color: #fff; font-weight: 600; }
.summary-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; align-self: start; }
.summary-row { display: flex; justify-content: space-between; font-size: 14px; margin: 8px 0; }
.summary-row.total { font-weight: 700; font-size: 16px; border-top: 1px solid var(--border); padding-top: 10px; margin-top: 10px; }
.summary-items { max-height: 260px; overflow-y: auto; margin-bottom: 12px; }
.summary-item { display: flex; justify-content: space-between; font-size: 13px; margin: 6px 0; color: var(--muted); }

.review-block { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; }
.review-block h3 { margin: 0 0 10px; font-size: 15px; }
.review-block p { margin: 2px 0; font-size: 14px; color: var(--muted); }

.confirmation-card { text-align: center; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 48px 32px; max-width: 560px; margin: 40px auto; }
.confirmation-card .check { font-size: 48px; color: var(--success); }

/* Account */
.orders-table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.orders-table th { text-align: left; background: #fafafa; padding: 12px 16px; font-size: 12px; text-transform: uppercase; color: var(--muted); }
.orders-table td { padding: 12px 16px; border-top: 1px solid var(--border); font-size: 14px; }
.status-badge { background: #e6f4ea; color: var(--success); padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }

/* Footer */
.footer { background: #1d1d1f; color: #cfd2d6; margin-top: 60px; padding: 40px 0 20px; font-size: 13px; }
.footer .container { display: grid; grid-template-columns: repeat(4, 1fr); gap: 24px; }
.footer h4 { color: #fff; font-size: 14px; margin: 0 0 12px; }
.footer a { color: #cfd2d6; display: block; padding: 4px 0; }
.footer .bottom { text-align: center; padding-top: 24px; margin-top: 24px; border-top: 1px solid #333; color: #888; }

@media (max-width: 900px) {
  .catalog-layout, .product-detail, .checkout-grid { grid-template-columns: 1fr; }
  .product-grid { grid-template-columns: repeat(2, 1fr); }
  .category-tiles { grid-template-columns: repeat(3, 1fr); }
  .footer .container { grid-template-columns: repeat(2, 1fr); }
}
