:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --accent: #f59e0b;
  --bg: #f1f5f9;
  --card: #ffffff;
  --line: #e2e8f0;
  --success: #16a34a;
  --success-bg: #dcfce7;
  --danger: #dc2626;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15,23,42,.06), 0 6px 20px rgba(15,23,42,.06);
  --shadow-lg: 0 10px 40px rgba(15,23,42,.12);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
h1,h2,h3,h4 { line-height: 1.2; margin: 0 0 .5em; }
img { max-width: 100%; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 20px; }
.muted { color: var(--muted); }
.site-main { min-height: 60vh; }

/* ---------- Header ---------- */
.site-header { background: var(--ink); color: #fff; position: sticky; top: 0; z-index: 50; }
.header-inner { display: flex; align-items: center; gap: 20px; padding: 14px 20px; }
.logo { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 22px; letter-spacing: -.02em; color: #fff; flex-shrink: 0; }
.logo-gear { color: var(--accent); }
.logo-text { white-space: nowrap; }

.search { position: relative; flex: 1; display: flex; max-width: 640px; }
.search input {
  flex: 1; height: 46px; border: 2px solid transparent; border-radius: 10px 0 0 10px;
  padding: 0 16px; font-size: 15px; outline: none; background: #fff; color: var(--ink);
}
.search input:focus { border-color: var(--accent); }
.search button {
  width: 54px; border: none; border-radius: 0 10px 10px 0; background: var(--accent);
  color: #1a1300; cursor: pointer; display: grid; place-items: center;
}
.search button:hover { background: #eab308; }
.suggest {
  position: absolute; top: 52px; left: 0; right: 0; background: #fff; color: var(--ink);
  border-radius: 12px; box-shadow: var(--shadow-lg); overflow: hidden; z-index: 60;
}
.suggest a { display: flex; justify-content: space-between; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.suggest a:last-child { border-bottom: none; }
.suggest a:hover { background: var(--bg); }
.suggest .s-art { font-weight: 700; color: var(--primary); }
.suggest .s-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest .s-price { color: var(--success); font-weight: 700; white-space: nowrap; }

.header-actions { display: flex; align-items: center; gap: 18px; flex-shrink: 0; }
.ai-link { display: inline-flex; align-items: center; gap: 6px; background: rgba(255,255,255,.1); padding: 9px 14px; border-radius: 10px; font-weight: 600; font-size: 14px; }
.ai-link:hover { background: rgba(255,255,255,.2); }
.ai-link svg { color: var(--accent); }
.phone { font-weight: 700; font-size: 15px; }
.cart-link { position: relative; display: inline-flex; align-items: center; color: #fff; padding: 8px; border-radius: 10px; }
.cart-link:hover { background: rgba(255,255,255,.12); }
.cart-badge { position: absolute; top: -3px; right: -5px; background: var(--accent); color: #1a1300; font-size: 11px; font-weight: 800; min-width: 18px; height: 18px; border-radius: 9px; display: grid; place-items: center; padding: 0 4px; }
.btn-cart { background: var(--primary); color: #fff; border: none; width: 28px; height: 28px; border-radius: 7px; font-size: 17px; font-weight: 700; cursor: pointer; line-height: 1; margin-left: 8px; vertical-align: middle; }
.btn-cart:hover { background: var(--primary-dark); }

.subnav { background: #1e293b; border-top: 1px solid rgba(255,255,255,.06); }
.subnav-inner { display: flex; gap: 4px; overflow-x: auto; padding: 0; scrollbar-width: none; }
.subnav-inner::-webkit-scrollbar { display: none; }
.subnav-inner a { color: #cbd5e1; font-size: 13.5px; padding: 11px 12px; white-space: nowrap; border-bottom: 2px solid transparent; }
.subnav-inner a:hover { color: #fff; border-bottom-color: var(--accent); }
.subnav-all { font-weight: 700; color: #fff !important; display: inline-flex; align-items: center; gap: 6px; }

/* ---------- Buttons / chips ---------- */
.btn { display: inline-flex; align-items: center; gap: 8px; background: var(--primary); color: #fff; border: none; padding: 11px 20px; border-radius: 10px; font-size: 15px; font-weight: 600; cursor: pointer; }
.btn:hover { background: var(--primary-dark); }
.btn-ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-amber { background: var(--accent); color: #1a1300; }
.btn-amber:hover { background: #eab308; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; background: var(--bg); color: var(--ink-2); }
.chip.local { background: #e0f2fe; color: #0369a1; }
.chip.best { background: var(--success-bg); color: #15803d; }
.chip.demo { background: #fef3c7; color: #92400e; }
.chip.stock { background: var(--success-bg); color: #15803d; }
.chip.order { background: #fee2e2; color: #b91c1c; }

/* ---------- Hero ---------- */
.hero { background: linear-gradient(135deg, #0f172a, #1e3a8a); color: #fff; padding: 56px 0 64px; }
.hero h1 { font-size: 40px; letter-spacing: -.02em; max-width: 720px; }
.hero p.lead { font-size: 18px; color: #cbd5e1; max-width: 620px; margin-bottom: 26px; }
.hero-search { display: flex; max-width: 680px; background: #fff; border-radius: 12px; padding: 6px; box-shadow: var(--shadow-lg); }
.hero-search input { flex: 1; border: none; outline: none; padding: 0 16px; font-size: 16px; color: var(--ink); background: transparent; }
.hero-stats { display: flex; gap: 40px; margin-top: 34px; flex-wrap: wrap; }
.hero-stats .num { font-size: 30px; font-weight: 800; color: #fff; }
.hero-stats .lbl { color: #94a3b8; font-size: 14px; }

/* ---------- Sections ---------- */
.section { padding: 46px 0; }
.section h2 { font-size: 26px; letter-spacing: -.01em; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 22px; gap: 16px; }
.section-head a { color: var(--primary); font-weight: 600; font-size: 15px; }

/* ---------- Category grid ---------- */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.cat-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: flex; justify-content: space-between; align-items: center; gap: 12px; transition: .15s; }
.cat-card:hover { border-color: var(--primary); box-shadow: var(--shadow); transform: translateY(-2px); }
.cat-card .c-name { font-weight: 600; }
.cat-card .c-count { color: var(--muted); font-size: 13px; }
.cat-card .c-ico { width: 40px; height: 40px; border-radius: 10px; background: #eff6ff; color: var(--primary); display: grid; place-items: center; flex-shrink: 0; }

/* ---------- Product cards ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; transition: .15s; }
.card:hover { box-shadow: var(--shadow); border-color: #cbd5e1; transform: translateY(-2px); }
.card .p-cat { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.card .p-art { font-size: 12.5px; font-weight: 700; color: var(--primary); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.card .p-name { font-size: 14px; margin: 6px 0 12px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; min-height: 60px; }
.card .p-foot { margin-top: auto; display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; }
.card .p-price { font-size: 19px; font-weight: 800; }
.card .p-price small { display: block; font-size: 11px; color: var(--muted); font-weight: 500; }
.card .p-offers { font-size: 12px; color: var(--muted); text-align: right; }

/* ---------- Suppliers row ---------- */
.sup-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px,1fr)); gap: 14px; }
.sup-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.sup-card .s-top { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.sup-card .s-badge { width: 44px; height: 44px; border-radius: 10px; background: var(--ink); color: var(--accent); display: grid; place-items: center; font-weight: 800; }
.sup-card .s-name { font-weight: 700; }
.sup-card .s-city { font-size: 13px; color: var(--muted); }

/* ---------- Layout with sidebar ---------- */
.layout { display: grid; grid-template-columns: 250px 1fr; gap: 26px; padding: 30px 0; }
.sidebar { align-self: start; position: sticky; top: 120px; }
.filter-box { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.filter-box h4 { font-size: 14px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.filter-list { display: flex; flex-direction: column; }
.filter-list a { padding: 7px 0; font-size: 14px; display: flex; justify-content: space-between; }
.filter-list a:hover { color: var(--primary); }
.filter-list a.active { color: var(--primary); font-weight: 700; }
.filter-list a .n { color: var(--muted); font-size: 12px; }

/* ---------- Breadcrumbs / page head ---------- */
.crumbs { padding: 16px 0; font-size: 13.5px; color: var(--muted); }
.crumbs a:hover { color: var(--primary); }
.page-head { padding: 8px 0 4px; }
.page-head h1 { font-size: 28px; }
.result-meta { color: var(--muted); font-size: 14px; margin-bottom: 18px; }

/* ---------- Product page ---------- */
.product { display: grid; grid-template-columns: 1.4fr 1fr; gap: 30px; padding: 24px 0; }
.p-media { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 26px; }
.p-media .ph { aspect-ratio: 4/3; background: repeating-linear-gradient(45deg,#f8fafc,#f8fafc 12px,#f1f5f9 12px,#f1f5f9 24px); border-radius: 10px; display: grid; place-items: center; color: #cbd5e1; }
.p-media .ph svg { width: 96px; height: 96px; }
.p-info h1 { font-size: 24px; }
.p-attrs { list-style: none; padding: 0; margin: 16px 0; border-top: 1px solid var(--line); }
.p-attrs li { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.p-attrs li .k { color: var(--muted); }
.p-attrs li .v { font-weight: 600; font-family: ui-monospace, Menlo, monospace; }
.price-box { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-top: 8px; }
.price-box .big { font-size: 32px; font-weight: 800; }
.price-box .range { color: var(--muted); font-size: 14px; }

/* ---------- Comparison table ---------- */
.compare { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin: 24px 0; }
.compare .ct-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.compare h3 { font-size: 18px; margin: 0; }
.table-scroll { overflow-x: auto; }
table.offers { width: 100%; border-collapse: collapse; min-width: 640px; }
table.offers th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); padding: 12px 16px; border-bottom: 1px solid var(--line); font-weight: 700; }
table.offers td { padding: 14px 16px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: middle; }
table.offers tr:last-child td { border-bottom: none; }
table.offers tr.best-row { background: linear-gradient(90deg, var(--success-bg), transparent); }
table.offers .sup { font-weight: 700; }
table.offers .sup .s-city { display: block; font-weight: 400; font-size: 12px; color: var(--muted); }
table.offers .price { font-size: 17px; font-weight: 800; white-space: nowrap; }
table.offers .cost { color: var(--muted); font-variant-numeric: tabular-nums; }
table.offers .margin-pos { color: var(--success); font-weight: 700; }
table.offers .del { white-space: nowrap; color: var(--ink-2); }
.margin-note { background: #f8fafc; border: 1px dashed var(--line); border-radius: 10px; padding: 12px 16px; font-size: 13.5px; color: var(--ink-2); margin-top: 8px; }
.margin-note b { color: var(--success); }

/* ---------- Pagination ---------- */
.pager { display: flex; gap: 6px; justify-content: center; padding: 30px 0; flex-wrap: wrap; }
.pager a, .pager span { padding: 9px 14px; border-radius: 8px; border: 1px solid var(--line); background: #fff; font-size: 14px; font-weight: 600; }
.pager a:hover { border-color: var(--primary); color: var(--primary); }
.pager .cur { background: var(--primary); color: #fff; border-color: var(--primary); }
.pager .dots { border: none; background: none; }

/* ---------- Assistant ---------- */
.assist-hero { background: linear-gradient(135deg,#111827,#312e81); color: #fff; padding: 40px 0; }
.assist-box { background: #fff; border-radius: 14px; padding: 8px; display: flex; max-width: 720px; box-shadow: var(--shadow-lg); }
.assist-box input { flex: 1; border: none; outline: none; padding: 14px 16px; font-size: 16px; color: var(--ink); }
.assist-answer { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--primary); border-radius: 10px; padding: 18px 20px; margin: 24px 0; display: flex; gap: 14px; }
.assist-answer .ico { width: 40px; height: 40px; border-radius: 10px; background: #eef2ff; color: var(--primary); display: grid; place-items: center; flex-shrink: 0; }
.assist-answer .txt { font-size: 15px; }
.assist-badge { font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 6px; }
.assist-badge.on { background: var(--success-bg); color: #15803d; }
.assist-badge.off { background: #fef3c7; color: #92400e; }
.example-tags { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.example-tags a { background: rgba(255,255,255,.12); color: #e2e8f0; padding: 7px 13px; border-radius: 999px; font-size: 13px; }
.example-tags a:hover { background: rgba(255,255,255,.22); }

/* ---------- Feature blocks ---------- */
.features { display: grid; grid-template-columns: repeat(auto-fit,minmax(230px,1fr)); gap: 18px; }
.feature { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.feature .f-ico { width: 46px; height: 46px; border-radius: 12px; background: #eff6ff; color: var(--primary); display: grid; place-items: center; margin-bottom: 12px; }
.feature h3 { font-size: 17px; }
.feature p { color: var(--muted); font-size: 14px; margin: 0; }

/* ---------- Empty / 404 ---------- */
.empty { text-align: center; padding: 70px 20px; }
.empty svg { color: #cbd5e1; width: 80px; height: 80px; }
.empty h2 { margin-top: 16px; }

/* ---------- Footer ---------- */
.site-footer { background: var(--ink); color: #cbd5e1; margin-top: 50px; padding: 44px 0 24px; }
.footer-grid { display: grid; grid-template-columns: 1.6fr 1fr 1fr 1fr; gap: 30px; }
.footer-logo { color: #fff; font-size: 20px; margin-bottom: 10px; }
.site-footer h4 { color: #fff; font-size: 14px; text-transform: uppercase; letter-spacing: .04em; }
.site-footer a { display: block; padding: 4px 0; color: #cbd5e1; font-size: 14px; }
.site-footer a:hover { color: #fff; }
.footer-bottom { border-top: 1px solid rgba(255,255,255,.1); margin-top: 30px; padding-top: 18px; font-size: 13px; }

/* ---------- Admin ---------- */
.admin-shell { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.admin-side { background: var(--ink); color: #cbd5e1; padding: 22px 0; }
.admin-side .a-logo { color: #fff; font-weight: 800; font-size: 18px; padding: 0 22px 20px; display: flex; align-items: center; gap: 8px; }
.admin-side .a-logo svg { color: var(--accent); }
.admin-side a { display: flex; align-items: center; gap: 10px; padding: 11px 22px; color: #cbd5e1; font-size: 14.5px; }
.admin-side a:hover, .admin-side a.active { background: rgba(255,255,255,.08); color: #fff; border-left: 3px solid var(--accent); padding-left: 19px; }
.admin-main { padding: 28px 34px; background: var(--bg); }
.admin-main h1 { font-size: 24px; margin-bottom: 20px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(180px,1fr)); gap: 16px; margin-bottom: 26px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.stat .s-num { font-size: 28px; font-weight: 800; color: var(--ink); }
.stat .s-lbl { color: var(--muted); font-size: 13px; margin-top: 2px; }
.stat.accent { background: linear-gradient(135deg,var(--primary),var(--primary-dark)); color: #fff; border: none; }
.stat.accent .s-num, .stat.accent .s-lbl { color: #fff; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin-bottom: 22px; }
.panel h2 { font-size: 18px; }
table.data { width: 100%; border-collapse: collapse; }
table.data th { text-align: left; font-size: 12px; text-transform: uppercase; color: var(--muted); padding: 10px 12px; border-bottom: 2px solid var(--line); }
table.data td { padding: 11px 12px; border-bottom: 1px solid var(--line); font-size: 14px; }
table.data tr:hover td { background: #f8fafc; }
.form-row { margin-bottom: 16px; }
.form-row label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--ink-2); }
.form-row input[type=text], .form-row input[type=password], .form-row input[type=number], .form-row input[type=file] {
  width: 100%; padding: 11px 14px; border: 1px solid var(--line); border-radius: 9px; font-size: 15px; outline: none;
}
.form-row input:focus { border-color: var(--primary); }
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg,#0f172a,#1e3a8a); }
.login-card { background: #fff; border-radius: 16px; padding: 34px; width: 360px; box-shadow: var(--shadow-lg); }
.alert { padding: 12px 16px; border-radius: 9px; font-size: 14px; margin-bottom: 16px; }
.alert.err { background: #fee2e2; color: #b91c1c; }
.alert.ok { background: var(--success-bg); color: #15803d; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .header-inner { flex-wrap: wrap; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .product { grid-template-columns: 1fr; }
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .admin-shell { grid-template-columns: 1fr; }
  .admin-side { display: flex; flex-wrap: wrap; padding: 10px; }
  .admin-side .a-logo { flex-basis: 100%; padding: 8px 12px; }
  .hero h1 { font-size: 30px; }
  .header-actions .phone { display: none; }
}
@media (max-width: 560px) {
  .footer-grid { grid-template-columns: 1fr; }
  .hero-stats { gap: 24px; }
}
