:root {
  --brand: #0f766e;
  --brand-dark: #115e59;
  --accent: #f59e0b;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f8fafc;
  --card: #ffffff;
  --danger: #dc2626;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .05);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.8rem; line-height: 1.2; margin: 0 0 .75rem; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
.container { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.main { padding-top: 24px; padding-bottom: 48px; min-height: calc(100vh - 140px); }
.muted { color: var(--muted); }
.right { text-align: right; }
.inline { display: inline; }
.pad { padding: 0 20px 16px; }

/* Top bar */
.topbar { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.2rem; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 800; }
.nav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.nav-link { color: var(--ink); padding: 8px 10px; border-radius: 10px; font-weight: 500; }
.nav-link:hover { background: var(--bg); text-decoration: none; }
.pill { background: var(--accent); color: #fff; border-radius: 999px; padding: 1px 8px; font-size: .8rem; font-weight: 700; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: 10px; padding: 10px 16px;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-ghost { background: var(--card); border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { background: var(--bg); }
.btn-danger { background: #fff; border-color: #fecaca; color: var(--danger); }
.btn-danger:hover { background: #fef2f2; }
.btn-sm { padding: 6px 12px; font-size: .9rem; }
.btn-block { width: 100%; }
.disabled { opacity: .45; pointer-events: none; }

/* Cards, forms */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.form-card { padding: 28px; max-width: 460px; margin: 0 auto; display: grid; gap: 14px; }
.form-card.wide { max-width: 760px; }
.field { display: grid; gap: 6px; font-weight: 600; font-size: .92rem; }
.field input, .field select, .field textarea, .search-form input, .qty-form input {
  font: inherit; font-weight: 400; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus, .search-form input:focus { outline: 2px solid #99f6e4; border-color: var(--brand); }
.error { color: var(--danger); font-weight: 500; }
.check { display: flex; gap: 8px; align-items: center; font-size: .92rem; }
.switch { text-align: center; margin: 0; color: var(--muted); }
.auth { padding: 24px 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; }
.preview { max-width: 160px; border-radius: 10px; border: 1px solid var(--line); }

/* Flash */
.flash { padding: 12px 16px; border-radius: 10px; margin-bottom: 18px; font-weight: 500; }
.flash-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.flash-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

/* Shop */
.hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 18px; flex-wrap: wrap; }
.hero h1 { font-size: 2.1rem; margin-bottom: .25rem; }
.hero p { margin: 0; }
.search-form { display: flex; gap: 8px; min-width: min(420px, 100%); }
.inline-search { max-width: 420px; margin-bottom: 16px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.chip { padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font-weight: 500; font-size: .92rem; }
.chip:hover { text-decoration: none; border-color: var(--brand); }
.chip.is-active { background: var(--brand); border-color: var(--brand); color: #fff; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px; }
.product-card { overflow: hidden; transition: transform .15s, box-shadow .15s; }
.product-card:hover { transform: translateY(-2px); box-shadow: 0 10px 30px rgba(15, 23, 42, .1); }
.product-link { color: inherit; display: block; }
.product-link:hover { text-decoration: none; }
.product-img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; }
.placeholder { display: grid; place-items: center; font-size: 3.2rem; font-weight: 800; color: rgba(255, 255, 255, .92); }
.cat-electronics { background: linear-gradient(135deg, #0ea5e9, #6366f1); }
.cat-home { background: linear-gradient(135deg, #f59e0b, #ef4444); }
.cat-fitness { background: linear-gradient(135deg, #10b981, #0f766e); }
.cat-books { background: linear-gradient(135deg, #a855f7, #ec4899); }
.placeholder:not([class*="cat-electronics"]):not([class*="cat-home"]):not([class*="cat-fitness"]):not([class*="cat-books"]) { background: linear-gradient(135deg, #64748b, #334155); }
.product-body { padding: 14px 16px 16px; }
.tag { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.product-name { font-size: 1.05rem; margin: 4px 0 8px; }
.product-meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.price { color: var(--ink); font-weight: 800; }
.price.big { font-size: 1.6rem; margin: 0; }
.stock { font-size: .82rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; display: inline-block; }
.stock-ok { background: #ecfdf5; color: #047857; }
.stock-low { background: #fffbeb; color: #b45309; }
.stock-out { background: #fef2f2; color: #b91c1c; }
.empty { padding: 40px; text-align: center; }
.back { display: inline-block; margin-bottom: 14px; font-weight: 500; }
.product-detail { display: grid; grid-template-columns: 1fr 1fr; overflow: hidden; }
.product-img.large { height: 100%; min-height: 320px; aspect-ratio: auto; }
.placeholder.large { font-size: 6rem; }
.detail-body { padding: 28px; display: grid; gap: 12px; align-content: start; }
.detail-body h1 { margin: 0; }
.description { color: #334155; margin: 0; }
.add-form { display: flex; gap: 10px; align-items: flex-end; }
.qty-field { width: 110px; }

/* Tables */
.table-card { overflow: hidden; }
.card-title { padding: 18px 20px 0; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 12px 16px; border-bottom: 1px solid var(--line); background: #fbfdff; }
td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tfoot td { background: #fbfdff; }
.row-product { display: inline-flex; align-items: center; gap: 12px; color: var(--ink); font-weight: 600; }
.product-img.thumb { width: 48px; height: 48px; border-radius: 10px; aspect-ratio: 1; font-size: 1.2rem; }
.qty-form { display: flex; gap: 6px; align-items: center; }
.qty-form input { width: 76px; padding: 6px 8px; }
.actions { white-space: nowrap; }
.actions form { margin-left: 6px; }
.cart-summary { margin-top: 18px; padding: 18px 20px; display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.cart-summary div { display: grid; }
.pagination { display: flex; justify-content: center; align-items: center; gap: 14px; margin-top: 22px; }

/* Checkout + orders */
.checkout { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; align-items: start; }
.checkout .form-card { max-width: none; margin: 0; }
.summary { padding: 22px; }
.summary-list { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 8px; }
.summary-list li, .summary-total { display: flex; justify-content: space-between; gap: 12px; }
.summary-total { border-top: 1px solid var(--line); padding-top: 12px; font-size: 1.1rem; }
.payment { background: #fffbeb; border: 1px solid #fde68a; border-radius: 10px; padding: 10px 12px; }
.address { white-space: pre-line; }
.order-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.order-head h1 { margin-bottom: .2rem; }
.status-form { display: grid; gap: 10px; border-top: 1px solid var(--line); padding-top: 14px; margin-top: 8px; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .8rem; font-weight: 700; }
.badge-pending { background: #fffbeb; color: #b45309; }
.badge-shipped { background: #eff6ff; color: #1d4ed8; }
.badge-delivered { background: #ecfdf5; color: #047857; }
.badge-cancelled { background: #f1f5f9; color: #475569; }

/* Admin */
.admin-nav { display: flex; gap: 6px; margin-bottom: 20px; border-bottom: 1px solid var(--line); }
.admin-nav a { padding: 10px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.admin-nav a:hover { color: var(--ink); text-decoration: none; }
.admin-nav a.is-active { color: var(--brand); border-bottom-color: var(--brand); }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.page-head h1 { margin: 0; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.stat { padding: 18px 20px; display: grid; gap: 4px; }
.stat-label { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.stat-value { font-size: 1.9rem; font-weight: 800; }
.two-col { display: grid; grid-template-columns: 1.5fr 1fr; gap: 20px; align-items: start; }

.footer { border-top: 1px solid var(--line); color: var(--muted); font-size: .88rem; padding: 18px 0; background: var(--card); }

/* Mobile */
@media (max-width: 760px) {
  h1, .hero h1 { font-size: 1.5rem; }
  .topbar-inner { height: auto; padding: 10px 16px; flex-wrap: wrap; }
  .product-detail, .checkout, .two-col, .grid-2 { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
  .search-form { min-width: 0; width: 100%; }
  thead { display: none; }
  table, tbody, tr, td, tfoot { display: block; width: 100%; }
  tr { border-bottom: 1px solid var(--line); padding: 8px 0; }
  td { border: 0; padding: 6px 16px; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  td[data-label]::before { content: attr(data-label); font-weight: 600; color: var(--muted); text-align: left; }
  td.right { justify-content: flex-end; }
  .cart-summary { flex-direction: column; align-items: stretch; }
}
