:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #efece4;
  --text: #1d1c1a;
  --text-2: #57544d;
  --muted: #8a867c;
  --line: #e2ded3;
  --accent: #2f6b3b;
  --accent-ink: #ffffff;
  --accent-soft: #e3efe4;
  --danger: #b3261e;
  --warn: #9a6400;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141413; --surface: #1d1d1b; --surface-2: #262623; --text: #f0efec; --text-2: #c3c2b7;
    --muted: #8f8d84; --line: #34332f; --accent: #5fae6c; --accent-ink: #0f1a10; --accent-soft: #22321f;
    --danger: #f2827a; --warn: #e2a640; --series-1: #3987e5; --series-2: #d95926; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141413; --surface: #1d1d1b; --surface-2: #262623; --text: #f0efec; --text-2: #c3c2b7;
  --muted: #8f8d84; --line: #34332f; --accent: #5fae6c; --accent-ink: #0f1a10; --accent-soft: #22321f;
  --danger: #f2827a; --warn: #e2a640; --series-1: #3987e5; --series-2: #d95926; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .6em; }
h1 { font-size: 1.7rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
.container { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.pos { color: var(--accent); } .neg { color: var(--danger); }

/* ---- кнопки и формы ---- */
.btn {
  display: inline-block; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink);
  padding: .55em 1.1em; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn.secondary { background: transparent; color: var(--accent); }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn.sm { padding: .3em .7em; font-size: .85rem; font-weight: 500; }
.btn.link { background: none; border: none; color: var(--danger); padding: 0; font-weight: 400; }
label { display: block; font-size: .85rem; color: var(--text-2); margin-bottom: .25em; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: .5em .65em;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input[type=checkbox] { width: auto; margin-right: .4em; }
.check { display: flex; align-items: flex-start; color: var(--text); font-size: .95rem; margin: .3em 0; }
.grid { display: grid; gap: 12px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 760px) { .g2, .g3, .g4 { grid-template-columns: minmax(0, 1fr); } }
.field { margin-bottom: 12px; }
.hp { position: absolute; left: -9999px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.alert { padding: .7em 1em; border-radius: 8px; background: #fdecea; color: #7a1c15; margin-bottom: 12px; }

/* ---- таблицы ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .55em .6em; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }

.badge { display: inline-block; padding: .1em .55em; border-radius: 99px; font-size: .8rem; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.badge.new { background: #e6effb; color: #1d4f8f; }
.badge.done { background: var(--accent-soft); color: var(--accent); }
.badge.cancelled { background: #f6e3e1; color: #8c2a22; }
.badge.building, .badge.agreed { background: #fbefd9; color: #7a4f00; }

/* ---- публичный сайт ---- */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.site-header .container { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 64px; }
.logo { font-weight: 800; font-size: 1.2rem; color: var(--text); text-decoration: none; }
.logo span { color: var(--accent); }
.hero { padding: 56px 0 40px; }
.hero h1 { font-size: clamp(1.8rem, 4vw, 2.7rem); max-width: 18ch; }
.hero p { font-size: 1.1rem; color: var(--text-2); max-width: 60ch; }
.perks { display: flex; flex-wrap: wrap; gap: 8px 24px; padding: 0; list-style: none; color: var(--text-2); }
.perks li::before { content: "✓ "; color: var(--accent); font-weight: 700; }
.section { padding: 32px 0; }
.products { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.product { cursor: pointer; transition: border-color .15s; }
.product:hover, .product.selected { border-color: var(--accent); }
.product .size { color: var(--muted); font-size: .9rem; }
.product .price { font-weight: 700; margin-top: .5em; }
.order-layout { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 860px) { .order-layout { grid-template-columns: minmax(0, 1fr); } }
.estimate { position: sticky; top: 16px; }
.estimate .total { font-size: 2rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.site-footer { padding: 32px 0; color: var(--muted); font-size: .9rem; border-top: 1px solid var(--line); margin-top: 32px; }

/* ---- кабинет ---- */
.admin-nav { background: var(--surface); border-bottom: 1px solid var(--line); }
.admin-nav .container { display: flex; align-items: center; gap: 4px 18px; flex-wrap: wrap; min-height: 56px; }
.admin-nav a { color: var(--text-2); text-decoration: none; padding: .3em 0; }
.admin-nav a.active { color: var(--text); font-weight: 600; box-shadow: inset 0 -2px 0 var(--accent); }
.admin-nav .spacer { flex: 1; }
.page { padding: 24px 0 48px; }
.page-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.page-head h1 { margin: 0; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; }
.filters input, .filters select { width: auto; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { padding: .3em .8em; border-radius: 99px; border: 1px solid var(--line); color: var(--text-2); text-decoration: none; font-size: .9rem; background: var(--surface); }
.pill.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi .label { font-size: .8rem; color: var(--muted); }
.kpi .value { font-size: 1.45rem; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
.kpi .hint { font-size: .8rem; color: var(--text-2); }
.cols { display: grid; gap: 16px; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 960px) { .cols { grid-template-columns: minmax(0, 1fr); } }
.chart-box { position: relative; height: 300px; }
.legend { display: flex; gap: 16px; font-size: .85rem; color: var(--text-2); margin-bottom: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; margin-bottom: 8px; font-size: .9rem; }
.bar-row .bar { grid-column: 1 / -1; height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.bar-row .bar span { display: block; height: 100%; background: var(--series-1); border-radius: 3px; }
dl.props { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
dl.props dt { color: var(--muted); }
dl.props dd { margin: 0; }
.report { white-space: pre-wrap; font-size: .95rem; }
details summary { cursor: pointer; color: var(--accent); }
pre.json { max-height: 420px; overflow: auto; background: var(--surface-2); padding: 12px; border-radius: 8px; font-size: .8rem; }
.inline { display: inline; }
.login-box { max-width: 360px; margin: 12vh auto; }
