/* ==========================================================================
   Дизайн-система витрины «Горный источник»
   Палитра: горный изумруд (бренд) + известняк (фон) + гранат (акценты) + абрикос (подсветка).
   Шрифты — только системные. Страничные стили — store.css (витрина) и account.css (кабинет).
   ========================================================================== */
:root {
  /* бренд */
  --brand: #0e5a4f; --brand-600: #0b4a41; --brand-700: #083a33; --brand-900: #062723;
  --brand-50: #eaf3f0; --brand-100: #d3e7e1; --brand-200: #a9d2c6;
  --accent: #c0392b; --accent-50: #fcebe9;          /* гранат */
  --sun: #f2b544; --sun-50: #fdf4df;                /* абрикос */
  /* нейтральные */
  --c-bg: #f5f3ee; --c-surface: #fff; --c-surface-2: #faf8f4; --c-sunken: #efece5;
  --c-text: #15211f; --c-text-2: #33423f; --c-muted: #5d6b68; --c-border: #e2ddd2; --c-border-strong: #cfc8ba;
  /* состояния */
  --c-ok: #17784a; --c-ok-50: #e5f4ec; --c-warn: #9a5800; --c-warn-50: #fdf2dc; --c-err: #b42318; --c-err-50: #fdeceb;
  --c-info: #1d5f8a; --c-info-50: #e6f0f7;
  /* совместимость со старыми именами */
  --c-primary: var(--brand); --c-primary-dark: var(--brand-600);
  /* форма */
  --radius: 14px; --radius-sm: 10px; --radius-xs: 7px; --gap: 16px;
  --shadow-sm: 0 1px 2px rgba(21, 33, 31, .06), 0 1px 1px rgba(21, 33, 31, .04);
  --shadow: 0 1px 2px rgba(21, 33, 31, .05), 0 6px 18px -8px rgba(21, 33, 31, .14);
  --shadow-lg: 0 18px 40px -16px rgba(8, 58, 51, .35);
  --focus: #d97706;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", "Liberation Sans", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --header-h: 72px;
}

/* ---------- База ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 12px); }
body { margin: 0; font: 15px/1.55 var(--font); color: var(--c-text); background: var(--c-bg); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
img, svg { max-width: 100%; }
a { color: var(--brand); text-decoration: none; text-underline-offset: .18em; }
a:hover { color: var(--brand-600); text-decoration: underline; }
h1, h2, h3 { color: var(--c-text); line-height: 1.2; letter-spacing: -.015em; }
h1 { font-size: clamp(24px, 2.4vw + 12px, 34px); font-weight: 800; margin: 6px 0 18px; }
h2 { font-size: clamp(19px, 1vw + 14px, 23px); font-weight: 750; margin: 32px 0 14px; }
h3 { font-size: 16px; font-weight: 700; }
p { margin: 0 0 12px; }
hr { border: 0; border-top: 1px solid var(--c-border); margin: 20px 0; }
b, strong { font-weight: 650; }
::selection { background: var(--brand-100); }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline-offset: 0; }

.container { width: 100%; max-width: 1280px; margin: 0 auto; padding: 0 20px; }
@media (max-width: 600px) { .container { padding: 0 14px; } }
.site-main { padding-top: 22px; padding-bottom: 56px; min-height: 60vh; }
.site-main:focus { outline: none; }

/* ---------- Утилиты ---------- */
.muted { color: var(--c-muted); }
.small { font-size: 13px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.inline { display: inline; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); font-size: .92em; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 100; background: var(--brand-700); color: #fff; padding: 10px 16px; border-radius: var(--radius-sm); }
.skip-link:focus { top: 12px; color: #fff; }
.i { width: 20px; height: 20px; flex: none; display: inline-block; vertical-align: middle; }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--brand); }
.eyebrow::before { content: ""; width: 18px; height: 2px; background: currentColor; border-radius: 2px; }

/* ---------- Кнопки ---------- */
.btn, button.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 9px 18px; border: 1px solid var(--brand); border-radius: var(--radius-sm);
  background: var(--brand); color: #fff; font: inherit; font-weight: 650; line-height: 1.2; cursor: pointer;
  text-align: center; text-decoration: none; transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s, transform .05s;
}
.btn:hover { background: var(--brand-600); border-color: var(--brand-600); color: #fff; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-secondary, button.btn-secondary { background: var(--c-surface); color: var(--brand); border-color: var(--brand-200); }
.btn-secondary:hover { background: var(--brand-50); color: var(--brand-600); border-color: var(--brand); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--brand); }
.btn-ghost:hover { background: var(--brand-50); color: var(--brand-600); border-color: transparent; }
.btn-sun { background: var(--sun); border-color: var(--sun); color: var(--brand-900); }
.btn-sun:hover { background: #e9a52a; border-color: #e9a52a; color: var(--brand-900); }
.btn-danger, button.btn-danger { background: var(--c-err); border-color: var(--c-err); color: #fff; }
.btn-danger:hover { background: #8f1c13; border-color: #8f1c13; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn-lg { min-height: 50px; padding: 12px 24px; font-size: 16px; }
.btn-sm { min-height: 32px; padding: 5px 12px; font-size: 13px; border-radius: var(--radius-xs); }
.btn-block { display: flex; width: 100%; }
button.link { background: none; border: 0; color: var(--brand); cursor: pointer; font: inherit; padding: 0; }
button.link:hover { text-decoration: underline; }
.link-danger, button.link-danger { color: var(--c-err); }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 42px; height: 42px; padding: 0; border: 1px solid transparent; border-radius: var(--radius-sm); background: transparent; color: var(--c-text); cursor: pointer; }
.icon-btn:hover { background: var(--c-sunken); }
.icon-btn .i { width: 24px; height: 24px; }

/* ---------- Поля ---------- */
input[type=text], input[type=search], input[type=email], input[type=tel], input[type=password], input[type=number], input[type=url], input[type=date], select, textarea {
  min-height: 42px; padding: 9px 12px; border: 1px solid var(--c-border-strong); border-radius: var(--radius-sm);
  font: inherit; color: var(--c-text); background: #fff; max-width: 100%; transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: #8a9592; }
input:hover, select:hover, textarea:hover { border-color: #b3ab9b; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(14, 90, 79, .16); outline: none; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--brand); outline-offset: 0; }
select { appearance: none; -webkit-appearance: none; padding-right: 36px; cursor: pointer;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%2333423f' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 13px center; }
select[multiple] { background-image: none; padding-right: 12px; }
textarea { width: 100%; min-height: 96px; resize: vertical; }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; accent-color: var(--brand); cursor: pointer; }
input[type=number] { font-variant-numeric: tabular-nums; }

.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 5px; color: var(--c-text-2); }
.form-row input, .form-row select { width: 100%; }
.form-row input[type=checkbox], .form-row input[type=radio] { width: 18px; }
.errorlist { color: var(--c-err); list-style: none; padding: 0; margin: 5px 0 0; font-size: 13px; font-weight: 500; }
.helptext { color: var(--c-muted); font-size: 13px; margin-top: 4px; }
.helptext ul { margin: 4px 0 0; padding-left: 18px; }
.req { color: var(--c-err); }
.has-error input, .has-error select, .has-error textarea { border-color: var(--c-err); background: #fffafa; }

/* ---------- Карточки, таблицы, значки ---------- */
.card { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); }
.grid { display: grid; gap: var(--gap); }
.grid-products { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.layout-sidebar { display: grid; grid-template-columns: 272px minmax(0, 1fr); gap: 28px; align-items: start; }
@media (max-width: 900px) { .layout-sidebar { grid-template-columns: minmax(0, 1fr); gap: 16px; } }

.price { font-size: 19px; font-weight: 800; letter-spacing: -.01em; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--c-text); }
.avail { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; }
.avail::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 18%, transparent); flex: none; }
.avail-in_stock { color: var(--c-ok); } .avail-on_order { color: var(--c-warn); } .avail-out_of_stock { color: var(--c-err); }

table.table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); overflow: hidden; font-variant-numeric: tabular-nums; }
.table th, .table td { padding: 11px 14px; border-bottom: 1px solid var(--c-border); text-align: left; vertical-align: top; }
.table thead th { background: var(--c-surface-2); font-weight: 700; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--c-muted); white-space: nowrap; }
.table tbody tr:last-child > * { border-bottom: 0; }
.table tbody tr:hover > td { background: #fcfbf8; }
.table th.right, .table td.right { text-align: right; }
.table tfoot td { background: var(--c-surface-2); border-top: 1px solid var(--c-border); border-bottom: 0; }
.table tfoot tr + tr td { border-top: 0; }
.table-wrap { overflow-x: auto; border-radius: var(--radius); -webkit-overflow-scrolling: touch; }

.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--brand); color: #fff; font-size: 12px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.badge-accent { background: var(--accent); }
.tag { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; letter-spacing: .02em; background: var(--brand-50); color: var(--brand-600); white-space: nowrap; }
.tag-opt { background: var(--accent); color: #fff; letter-spacing: .06em; text-transform: uppercase; font-size: 11px; }
.status { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; background: var(--c-sunken); color: var(--c-text-2); font-size: 13px; font-weight: 600; white-space: nowrap; }

/* ---------- Сообщения ---------- */
.messages { list-style: none; padding: 0; margin: 0 0 18px; }
.msg { --msg-c: var(--c-info); position: relative; padding: 12px 16px 12px 44px; border-radius: var(--radius-sm); margin-bottom: 10px; background: var(--c-info-50); color: var(--msg-c); border: 1px solid color-mix(in srgb, var(--msg-c) 22%, transparent); font-weight: 500; }
.msg::before { content: "i"; position: absolute; left: 14px; top: 12px; width: 20px; height: 20px; border-radius: 50%; background: var(--msg-c); color: #fff; font: 700 13px/20px var(--font); text-align: center; }
.msg-success { --msg-c: var(--c-ok); background: var(--c-ok-50); } .msg-success::before { content: "✓"; }
.msg-error { --msg-c: var(--c-err); background: var(--c-err-50); } .msg-error::before { content: "!"; }
.msg-warning { --msg-c: var(--c-warn); background: var(--c-warn-50); } .msg-warning::before { content: "!"; }
.msg a { color: inherit; text-decoration: underline; }
.msg ul { color: var(--c-text-2); font-weight: 400; }

/* ---------- Пагинация, вкладки ---------- */
.pagination { display: flex; gap: 6px; margin-top: 28px; flex-wrap: wrap; align-items: center; }
.pagination a, .pagination span { display: inline-flex; align-items: center; justify-content: center; min-width: 40px; height: 40px; padding: 0 12px; border: 1px solid var(--c-border); border-radius: var(--radius-sm); background: #fff; color: var(--c-text); font-weight: 600; font-variant-numeric: tabular-nums; }
.pagination a:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.pagination .current { background: var(--brand); color: #fff; border-color: var(--brand); }
.pagination .gap { border: 0; background: none; min-width: 20px; padding: 0; }

.tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 7px 14px; border-radius: 999px; color: var(--c-text-2); background: var(--c-surface); border: 1px solid var(--c-border); font-size: 14px; font-weight: 600; }
.tabs a:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.tabs a.active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ==========================================================================
   Шапка
   ========================================================================== */
.topbar { background: var(--brand-900); color: #cfe3dd; font-size: 13px; }
.topbar-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; min-height: 36px; }
.topbar-contacts { display: flex; gap: 20px; align-items: center; }
.topbar-item { display: inline-flex; align-items: center; gap: 6px; color: #e6f1ed; }
.topbar a.topbar-item:hover { color: #fff; }
.topbar .i { width: 15px; height: 15px; color: var(--sun); }
.topbar-tagline { color: #a7c7bf; }
@media (max-width: 900px) { .topbar-tagline, .topbar-email, .topbar-hours { display: none; } .topbar-row { justify-content: center; } }

.site-header { background: #fff; border-bottom: 1px solid var(--c-border); position: sticky; top: 0; z-index: 40; }
body.nav-open .site-header { z-index: 60; } /* выезжающее меню — поверх затемнения */
.header-row { display: flex; align-items: center; gap: 14px; min-height: var(--header-h); padding-top: 10px; padding-bottom: 10px; }
.logo { display: inline-flex; align-items: center; gap: 10px; color: var(--c-text); flex: none; max-width: 270px; }
.logo:hover { text-decoration: none; color: var(--c-text); }
.logo-mark { width: 42px; height: 42px; flex: none; }
.logo-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.logo-name { font-weight: 800; font-size: 17px; letter-spacing: -.015em; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.logo-sub { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--brand); margin-top: 2px; }
.catalog-btn { flex: none; }
.catalog-btn .i { width: 18px; height: 18px; }

.search { flex: 1; position: relative; display: flex; min-width: 0; }
.search input { flex: 1; min-width: 0; height: 46px; padding-left: 42px; padding-right: 92px; border-radius: 999px; background: var(--c-surface-2); border-color: var(--c-border-strong); }
.search input:focus { background: #fff; }
.search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--c-muted); width: 19px; height: 19px; pointer-events: none; }
.search-btn { position: absolute; right: 4px; top: 4px; bottom: 4px; min-height: 0; padding: 0 18px; border-radius: 999px; }
.search input::-webkit-search-cancel-button { margin-right: 4px; }

.header-nav { display: flex; align-items: center; gap: 2px; }
.nav-link { position: relative; display: inline-flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 10px; border-radius: var(--radius-sm); color: var(--c-text-2); font-size: 12px; font-weight: 600; line-height: 1.1; white-space: nowrap; }
button.nav-link { color: var(--c-text-2); font-size: 12px; font-weight: 600; line-height: 1.1; padding: 6px 10px; }
.nav-link:hover, button.nav-link:hover { background: var(--brand-50); color: var(--brand); text-decoration: none; }
.nav-link .i, .cart-link .i { width: 24px; height: 24px; }
.nav-ico { position: relative; display: inline-flex; }
.nav-ico .badge { position: absolute; top: -9px; left: 14px; height: 18px; min-width: 18px; font-size: 11px; padding: 0 5px; border: 2px solid #fff; box-sizing: content-box; }
.cart-link { flex: none; display: inline-flex; align-items: center; gap: 20px; padding: 8px 16px 8px 13px; border-radius: 999px; background: var(--brand-50); color: var(--brand-700); font-weight: 700; border: 1px solid var(--brand-100); }
.cart-link:hover { background: var(--brand-100); color: var(--brand-700); text-decoration: none; }
.cart-link .nav-ico .badge { border-color: var(--brand-50); }
.drawer-head, .drawer-only, .drawer-contacts, .nav-toggle { display: none; }
.nav-backdrop { display: none; }

@media (max-width: 1180px) {
  .nav-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .nav-link, button.nav-link { padding: 9px; }
  .logo { max-width: 210px; }
}
@media (max-width: 960px) {
  .catalog-btn span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .catalog-btn { padding: 0; width: 46px; height: 46px; }
  .logo-sub { display: none; }
}

/* Мобильная шапка: меню уходит в выезжающую панель (только при включённом JS) */
@media (max-width: 820px) {
  :root { --header-h: 60px; }
  .header-row { flex-wrap: wrap; gap: 8px 10px; padding-top: 8px; padding-bottom: 10px; }
  .logo { flex: 1; max-width: none; min-width: 0; }
  .logo-mark { width: 36px; height: 36px; }
  .logo-name { font-size: 16px; -webkit-line-clamp: 1; }
  .catalog-btn { display: none; }
  .search { order: 10; flex-basis: 100%; }
  .search input { height: 44px; }
  .cart-link { padding: 8px 12px; }
  .cart-label { display: none; }
  .header-nav { order: 11; flex-basis: 100%; flex-wrap: wrap; }
  .nav-label { position: static; width: auto; height: auto; overflow: visible; clip: auto; }

  .js .nav-toggle { display: inline-flex; margin-left: -6px; }
  .js .header-nav {
    position: fixed; z-index: 60; top: 0; bottom: 0; left: 0; width: min(86vw, 340px); order: 0;
    flex-direction: column; align-items: stretch; flex-wrap: nowrap; gap: 2px; padding: 12px 12px 24px;
    background: #fff; box-shadow: var(--shadow-lg); overflow-y: auto;
    transform: translateX(-105%); visibility: hidden; transition: transform .22s ease, visibility 0s linear .22s;
  }
  .js body.nav-open .header-nav { transform: none; visibility: visible; transition: transform .22s ease; }
  .js .header-nav .nav-link, .js .header-nav button.nav-link { flex-direction: row; gap: 14px; padding: 12px 12px; font-size: 16px; width: 100%; justify-content: flex-start; }
  .js .nav-logout { display: block; }
  .js .drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 4px 12px 12px; margin-bottom: 6px; border-bottom: 1px solid var(--c-border); }
  .js .drawer-title { font-weight: 800; font-size: 18px; }
  .js .drawer-only { display: inline-flex; }
  .js .drawer-contacts { display: flex; flex-direction: column; gap: 6px; margin-top: auto; padding: 16px 12px 0; border-top: 1px solid var(--c-border); font-weight: 600; }
  .js .nav-backdrop:not([hidden]) { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(6, 39, 35, .45); }
  .js .nav-ico .badge { border-color: #fff; }
}
body.nav-open { overflow: hidden; }

.notice-bar { background: var(--c-warn-50); color: var(--c-warn); border-top: 1px solid #f3dfb3; padding: 9px 16px; text-align: center; font-size: 14px; font-weight: 600; }

/* ==========================================================================
   Подвал
   ========================================================================== */
.site-footer { margin-top: 24px; color: var(--brand-900); }
.footer-ridge { display: block; width: 100%; height: 44px; margin-bottom: -1px; }
.footer-inner { background: var(--brand-900); color: #b9d2cb; padding: 28px 0 0; }
.footer-grid { display: grid; grid-template-columns: 1.4fr 1fr 1.2fr 1.3fr; gap: 32px; padding-bottom: 32px; }
.footer-brand p { margin: 14px 0 0; font-size: 14px; max-width: 360px; }
.logo-invert, .logo-invert:hover { color: #fff; }
.logo-invert .logo-sub { color: var(--sun); }
.footer-title { font-size: 13px; letter-spacing: .09em; text-transform: uppercase; color: #fff; margin: 4px 0 14px; font-weight: 750; }
.footer-links, .contact-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 9px; font-size: 14px; }
.footer-links a, .contact-list a { color: #e3efeb; }
.footer-links a:hover, .contact-list a:hover { color: #fff; }
.footer-points li { position: relative; padding-left: 16px; }
.footer-points li::before { content: ""; position: absolute; left: 0; top: .6em; width: 6px; height: 6px; border-radius: 2px; background: var(--sun); }
.contact-list li { display: flex; gap: 10px; align-items: flex-start; }
.contact-list .i { width: 18px; height: 18px; color: var(--sun); margin-top: 2px; }
.footer-bottom { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; padding-top: 16px; padding-bottom: 22px; border-top: 1px solid rgba(255, 255, 255, .1); font-size: 13px; color: #8fb3aa; }
@media (max-width: 960px) { .footer-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .footer-grid { grid-template-columns: 1fr; gap: 26px; } }

/* ---------- Движение ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; scroll-behavior: auto !important; }
}
