:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --ink: #1c2230;
  --muted: #6b7280;
  --line: #e4e7ec;
  --brand: #1f6feb;
  --brand-dark: #1856bd;
  --ok: #157347;
  --ok-bg: #e7f5ec;
  --err: #b42318;
  --err-bg: #fdecea;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.04);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; } /* перебивает display у .badge/.toast */
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  font-size: 15px;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
h1 { font-size: 24px; margin: 0 0 16px; }
h2 { font-size: 19px; margin: 0 0 14px; }
h3 { font-size: 16px; margin: 0 0 10px; }

.container { max-width: 1180px; margin: 0 auto; padding: 0 20px; }
.page { padding-top: 24px; padding-bottom: 48px; min-height: 60vh; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.ta-right { text-align: right; }
.block { margin-top: 36px; }

/* Header */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.header-inner { display: flex; align-items: center; gap: 20px; height: 64px; }
.logo { font-weight: 700; font-size: 20px; color: var(--ink); letter-spacing: -0.3px; }
.logo:hover { text-decoration: none; }
.search { flex: 1; display: flex; max-width: 560px; }
.search input {
  flex: 1; height: 40px; padding: 0 14px; font-size: 14px;
  border: 1px solid var(--line); border-right: 0;
  border-radius: 8px 0 0 8px; outline: none; background: #fff;
}
.search input:focus { border-color: var(--brand); }
.search button {
  height: 40px; padding: 0 18px; border: 0; cursor: pointer;
  background: var(--brand); color: #fff; border-radius: 0 8px 8px 0; font-size: 14px;
}
.search button:hover { background: var(--brand-dark); }
.main-nav { display: flex; align-items: center; gap: 18px; font-size: 15px; }
.main-nav a { color: var(--ink); }
.cart-link { font-weight: 600; }
.badge {
  display: inline-block; min-width: 20px; height: 20px; line-height: 20px; text-align: center;
  background: var(--brand); color: #fff; border-radius: 10px; font-size: 12px; padding: 0 6px;
}
.admin-nav a { color: var(--ink); }
.inline-form { display: inline; margin: 0; }
.linklike { background: none; border: 0; color: var(--brand); cursor: pointer; font: inherit; padding: 0; }
.linklike:hover { text-decoration: underline; }

/* Buttons */
.btn {
  display: inline-block; padding: 10px 20px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); cursor: pointer; font-size: 15px; font-weight: 500;
}
.btn:hover { text-decoration: none; border-color: #cfd4dc; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }

/* Hero */
.hero {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 40px; text-align: center; margin-top: 8px;
}
.hero h1 { font-size: 30px; margin-bottom: 8px; }
.hero .lead { color: var(--muted); font-size: 17px; margin: 0 0 22px; }

/* Category cards */
.group-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.group-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; display: flex; flex-direction: column; gap: 6px; color: var(--ink);
}
.group-card:hover { text-decoration: none; border-color: var(--brand); box-shadow: var(--shadow); }
.group-title { font-weight: 600; font-size: 16px; }

/* Catalog layout */
.catalog-layout { display: grid; grid-template-columns: 250px 1fr; gap: 28px; align-items: start; }
.sidebar {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; position: sticky; top: 84px;
}
.sidebar h3 { margin-bottom: 12px; }
.cat-nav { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.cat-nav > li { margin-bottom: 4px; }
.cat-nav a { color: var(--ink); display: block; padding: 5px 8px; border-radius: 6px; }
.cat-nav a:hover { background: var(--bg); text-decoration: none; }
.cat-nav a.active { background: #e8f0fe; color: var(--brand-dark); font-weight: 600; }
.subcat { list-style: none; margin: 4px 0 8px; padding-left: 10px; border-left: 2px solid var(--line); }
.subcat a { font-size: 13px; color: var(--muted); }
.subcat a.active { color: var(--brand-dark); }

.results-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 16px; gap: 12px; }
.results-head h1 { margin: 0; }

/* Product grid */
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; }
.product-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column; color: var(--ink);
}
.product-card:hover { box-shadow: var(--shadow); border-color: #cfd4dc; }
.pc-link { display: flex; flex-direction: column; flex: 1; color: var(--ink); }
.pc-link:hover { text-decoration: none; }
.pc-add { padding: 0 12px 12px; }
.btn-add { width: 100%; padding: 8px 10px; font-size: 14px; background: #eef4ff; border-color: #d6e4ff; color: var(--brand-dark); }
.btn-add:hover { background: var(--brand); border-color: var(--brand); color: #fff; }
.thumb {
  aspect-ratio: 1 / 1; background: #fff; display: flex; align-items: center; justify-content: center;
  border-bottom: 1px solid var(--line); overflow: hidden; position: relative;
}
.thumb img { width: 100%; height: 100%; object-fit: contain; }
.thumb.noimg::after, .noimg-label { content: "нет фото"; color: #b8bdc7; font-size: 12px; }
.noimg-label { position: absolute; }
.p-body { padding: 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.p-name { font-size: 13.5px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.p-art { font-size: 12px; color: var(--muted); }
.p-price { font-size: 17px; font-weight: 700; margin-top: auto; }

/* Pagination */
.pagination { display: flex; gap: 6px; margin-top: 28px; flex-wrap: wrap; }
.pagination a {
  min-width: 38px; height: 38px; padding: 0 10px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink);
}
.pagination a:hover { text-decoration: none; border-color: var(--brand); }
.pagination a.active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* Product page */
.breadcrumbs { font-size: 13px; color: var(--muted); margin-bottom: 16px; }
.product-page { display: grid; grid-template-columns: 440px 1fr; gap: 36px; align-items: start; }
.gallery { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.main-img { aspect-ratio: 1 / 1; display: flex; align-items: center; justify-content: center; }
.main-img img { max-width: 100%; max-height: 100%; object-fit: contain; }
.gallery.noimg-big .main-img { display: none; }
.gallery.noimg-big::after { content: "нет фото"; color: #b8bdc7; display: block; text-align: center; padding: 80px 0; }
.thumbs { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.thumbs img { width: 56px; height: 56px; object-fit: contain; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; padding: 3px; background: #fff; }
.thumbs img.active { border-color: var(--brand); }
.noimg-placeholder { aspect-ratio: 1/1; display: flex; align-items: center; justify-content: center; color: #b8bdc7; }
.product-info h1 { font-size: 22px; }
.meta { display: flex; gap: 16px; flex-wrap: wrap; color: var(--muted); font-size: 14px; margin-bottom: 18px; }
.in-stock { color: var(--ok); }
.out-stock { color: var(--muted); }
.price-big { font-size: 30px; font-weight: 700; margin-bottom: 18px; }
.add-form { display: flex; gap: 10px; align-items: center; margin-bottom: 26px; }
.qty { width: 80px; height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 16px; }
.add-form .btn { height: 44px; }
.description { border-top: 1px solid var(--line); padding-top: 18px; }
.description p { white-space: pre-line; color: #333a48; }

/* Cart */
.cart-layout { display: grid; grid-template-columns: 1fr 320px; gap: 28px; align-items: start; }
.cart-items { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.cart-row { display: grid; grid-template-columns: 64px 1fr 90px 110px 32px; gap: 14px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.cart-row:last-child { border-bottom: 0; }
.cart-thumb { width: 64px; height: 64px; display: flex; align-items: center; justify-content: center; }
.cart-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.cart-main a { color: var(--ink); font-size: 14px; }
.cart-qty input { width: 70px; height: 38px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; }
.cart-price { font-weight: 600; text-align: right; }
.remove { background: none; border: 0; font-size: 22px; color: var(--muted); cursor: pointer; line-height: 1; }
.remove:hover { color: var(--err); }
.checkout { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; position: sticky; top: 84px; }
.total-row { display: flex; justify-content: space-between; font-size: 18px; margin-bottom: 16px; }
.total-row strong { font-size: 22px; }
.checkout-form { display: flex; flex-direction: column; gap: 12px; }
.checkout-form label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
.checkout-form input, .checkout-form textarea { padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font: inherit; color: var(--ink); }
.checkout-form input:focus, .checkout-form textarea:focus { border-color: var(--brand); outline: none; }

/* Generic blocks */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.empty { color: var(--muted); padding: 30px 0; }
.done { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 48px; text-align: center; }
.done h1 { margin-bottom: 14px; }
.done .btn { margin-top: 18px; }
.contacts p { margin: 6px 0; }
.error { background: var(--err-bg); color: var(--err); padding: 12px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 14px; }
.success { background: var(--ok-bg); color: var(--ok); padding: 12px 14px; border-radius: 8px; margin-bottom: 18px; font-size: 14px; }

/* Footer */
.site-footer { background: var(--surface); border-top: 1px solid var(--line); padding: 22px 0; margin-top: 40px; color: var(--muted); font-size: 14px; }
.site-footer .container { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* Admin */
.stat-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 24px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; }
.stat .num { font-size: 28px; font-weight: 700; }
.stat .lbl { color: var(--muted); font-size: 13px; }
.import-form { max-width: 640px; }
.import-form input[type=file] { display: block; margin: 14px 0; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; margin-bottom: 16px; }
.check input { width: auto; }
.data-table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; font-size: 14px; }
.data-table th, .data-table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line); }
.data-table th { background: #fafbfc; font-weight: 600; color: #475063; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table tr.inactive { opacity: 0.5; }
.data-table img.mini { width: 40px; height: 40px; object-fit: contain; }
.admin-search { display: flex; gap: 10px; margin-bottom: 12px; max-width: 480px; }
.admin-search input { flex: 1; height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; }
.order-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.order-customer { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 24px; margin-bottom: 22px; }

/* Admin login */
.admin-login { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg); }
.login-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 32px; width: 320px; box-shadow: var(--shadow); }
.login-card h1 { margin-bottom: 4px; font-size: 20px; }
.login-card label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); margin: 16px 0; }
.login-card input { padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font: inherit; }
.login-card .btn { width: 100%; }

/* Button variants */
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-danger { background: #fff; border-color: #f1c4bf; color: var(--err); }
.btn-danger:hover { background: var(--err); border-color: var(--err); color: #fff; }
code { background: #eef0f3; padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }

/* Import mode */
.import-mode { border: 0; padding: 0; margin: 4px 0 18px; display: flex; flex-direction: column; gap: 10px; }
.import-mode .radio { display: flex; gap: 9px; align-items: flex-start; font-size: 13.5px; line-height: 1.45; cursor: pointer; }
.import-mode .radio input { margin-top: 3px; }
.import-mode em { color: var(--ok); font-style: normal; }

/* Products toolbar */
.products-toolbar { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 8px; }
.products-toolbar .admin-search { margin-bottom: 0; }

/* Order status badges */
.status { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; vertical-align: middle; }
.status-new { background: #e8f0fe; color: var(--brand-dark); }
.status-processing { background: #fff3e0; color: #9a5b00; }
.status-done { background: var(--ok-bg); color: var(--ok); }
.status-canceled { background: #f0f1f3; color: var(--muted); }

/* Status tabs (orders) */
.status-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 18px; }
.status-tabs a { padding: 7px 14px; border: 1px solid var(--line); border-radius: 999px; background: #fff; color: var(--ink); font-size: 14px; }
.status-tabs a:hover { text-decoration: none; border-color: var(--brand); }
.status-tabs a.active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* Status actions (order page) */
.status-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 16px 0 22px; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 16px);
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 10px;
  font-size: 14px; font-weight: 500; box-shadow: 0 6px 24px rgba(16,24,40,.22);
  opacity: 0; transition: opacity .2s ease, transform .2s ease; z-index: 60; pointer-events: none;
  max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-ok { background: var(--ok); }
.toast-err { background: var(--err); }

/* Responsive */
@media (max-width: 900px) {
  .catalog-layout { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .product-page { grid-template-columns: 1fr; }
  .cart-layout { grid-template-columns: 1fr; }
  .stat-cards { grid-template-columns: repeat(2, 1fr); }
  .order-customer { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .header-inner { flex-wrap: wrap; height: auto; padding: 12px 0; gap: 12px; }
  .search { order: 3; max-width: none; width: 100%; }
}
