:root {
  --bg: #f4f5f7; --surface: #ffffff; --surface-2: #f0f1f4; --text: #16181d; --muted: #6b7180;
  --border: #e3e5ea; --accent: #0a3fb8; --accent-text: #ffffff; --accent-soft: #e9effc;
  --ok: #1f8a4c; --ok-soft: #e6f5ec; --warn: #b26a00; --warn-soft: #fff4dc; --bad: #c92a2a; --bad-soft: #fde8e8;
  --nav-bg: #000000; --nav-text: #b9bec9; --nav-active: #ffffff; --brand: #0a3fb8;
  --radius: 12px; --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115; --surface: #171a20; --surface-2: #1e222a; --text: #e8eaee; --muted: #9298a5;
    --border: #2a2f39; --accent: #4d7cf3; --accent-soft: #14213f; --ok: #4cc27f; --ok-soft: #16301f;
    --warn: #f0b33c; --warn-soft: #3a2d12; --bad: #ff6b6b; --bad-soft: #3a1a1a; --nav-bg: #000000;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1115; --surface: #171a20; --surface-2: #1e222a; --text: #e8eaee; --muted: #9298a5;
  --border: #2a2f39; --accent: #4d7cf3; --accent-soft: #14213f; --ok: #4cc27f; --ok-soft: #16301f;
  --warn: #f0b33c; --warn-soft: #3a2d12; --bad: #ff6b6b; --bad-soft: #3a1a1a; --nav-bg: #000000;
  --shadow: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* каркас */
.layout { display: flex; min-height: 100vh; }
.nav {
  width: 220px; flex-shrink: 0; background: var(--nav-bg); color: var(--nav-text);
  padding: 20px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
}
.nav a.brand { display: block; color: #fff; font-weight: 800; font-size: 18px; letter-spacing: .04em; padding: 0 10px 18px; background: none; }
/* На чёрном фоне фирменный синий слишком тёмный — берём его светлый вариант. */
.brand span, .mobile-head .brand-text span { color: #4d7cf3; }
.mobile-head { display: none; }
.nav a {
  display: flex; align-items: center; gap: 10px; color: var(--nav-text); padding: 9px 10px;
  border-radius: 8px; font-weight: 500;
}
.nav a:hover { background: rgba(255, 255, 255, .06); text-decoration: none; }
.nav a.active { background: rgba(255, 255, 255, .1); color: var(--nav-active); }
.nav .ico { width: 20px; text-align: center; }
.nav .spacer { flex: 1; }
.nav .who { padding: 10px; font-size: 13px; border-top: 1px solid rgba(255, 255, 255, .08); margin-top: 8px; }
.nav .who b { color: #fff; display: block; }
main { flex: 1; min-width: 0; padding: 28px 32px 48px; max-width: 1180px; }
.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }

/* блоки */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.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)); }
.stack > * + * { margin-top: 16px; }
/* Элементы сетки и строк не должны распирать страницу длинным содержимым. */
.grid > *, .work > *, .row > *, .top > * { min-width: 0; }
td, .work, .card, .flash, h1, h2 { overflow-wrap: anywhere; }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }

.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin-top: 2px; }
.stat .sub { font-size: 13px; color: var(--muted); }
.stat.accent { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.stat.accent .label, .stat.accent .sub { color: rgba(255, 255, 255, .85); }

/* таблицы */
.table-wrap { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--border); }
td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; }
tr.link { cursor: pointer; }
tr.link:hover td { background: var(--surface-2); }

/* метки */
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.muted { background: var(--surface-2); color: var(--muted); }

/* формы */
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; font-weight: 500; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 9px 11px; min-height: 40px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
textarea { min-height: 70px; resize: vertical; }
.field { margin-bottom: 12px; }
.fields { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr)); margin-bottom: 12px; }
.fields .field { margin: 0; }
.money { display: grid; grid-template-columns: 1fr 92px; gap: 6px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 8px;
  padding: 9px 14px; min-height: 40px; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { color: var(--bad); }
.btn.sm { min-height: 32px; padding: 5px 10px; font-size: 13px; }
.search { display: flex; gap: 8px; }
.search input { flex: 1; min-width: 0; }
details.inline > summary { list-style: none; cursor: pointer; }
details.inline > summary::-webkit-details-marker { display: none; }
details.inline[open] > summary { margin-bottom: 14px; }

.flash { background: var(--accent-soft); border: 1px solid var(--accent); color: var(--text); padding: 10px 14px; border-radius: 10px; margin-bottom: 16px; }
.error { background: var(--bad-soft); color: var(--bad); padding: 10px 14px; border-radius: 10px; margin-bottom: 12px; }
.empty { color: var(--muted); padding: 18px 0; text-align: center; }

/* работы */
.work { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.work:last-child { border-bottom: 0; }
.work .title { font-weight: 600; }
.work .meta { color: var(--muted); font-size: 13px; }

/* график */
.chart { display: flex; align-items: flex-end; gap: 10px; height: 170px; padding-top: 10px; }
.chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.chart .bars { display: flex; align-items: flex-end; gap: 3px; height: 100%; width: 100%; justify-content: center; }
.chart .bar { width: 42%; max-width: 26px; border-radius: 4px 4px 0 0; min-height: 2px; }
.chart .bar.rev { background: var(--surface-2); border: 1px solid var(--border); }
.chart .bar.pro { background: var(--accent); }
.chart .bar.neg { background: var(--bad); }
.chart .m { font-size: 12px; color: var(--muted); margin-top: 6px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

/* вход */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth .card { width: 100%; max-width: 400px; padding: 28px; }
.auth .brand-text { color: var(--text); font-weight: 800; font-size: 22px; letter-spacing: .04em; padding: 0 0 18px; }
.auth .brand-text span { color: var(--accent); }

/* телефон */
@media (max-width: 860px) {
  .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g2, .g-main { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 720px) {
  .layout { display: block; }
  .nav {
    position: fixed; bottom: 0; top: auto; left: 0; right: 0; width: auto; height: auto; z-index: 10;
    flex-direction: row; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); justify-content: space-around;
  }
  .nav a.brand, .nav .spacer, .nav .who, .nav .lbl-hide { display: none; }
  .mobile-head { display: flex; align-items: center; justify-content: space-between; background: #000;
    margin: -18px -16px 16px; padding: 10px 16px; }
  .mobile-head .brand-text { color: #fff; font-weight: 800; font-size: 16px; letter-spacing: .04em; }
  .mobile-head a { color: #b9bec9; font-size: 13px; }
  .nav a { flex-direction: column; gap: 2px; font-size: 11px; padding: 6px 4px; flex: 1; min-width: 0; text-align: center; }
  .nav .ico { font-size: 18px; }
  .nav a.hide-sm { display: none; }  /* «Студии» на телефоне — ссылкой в шапке */
  main { padding: 18px 16px 96px; }
  h1 { font-size: 21px; }
  .card { padding: 14px; }
  .table-wrap { margin: 0 -14px; padding: 0 14px; }
  .stat .value { font-size: 21px; }
  .hide-sm { display: none; }
  html, body { overflow-x: hidden; }
  .grid { gap: 12px; }
  .g3 { grid-template-columns: minmax(0, 1fr); }
  .tag { white-space: normal; }
  .btn { white-space: normal; text-align: center; }
  /* Работа: статус — под названием, а не сбоку. */
  .work { grid-template-columns: minmax(0, 1fr); }
  .work > div:last-child { text-align: left !important; }
  /* Строки с полями (настройки мастеров, ботов): каждое поле — на всю ширину. */
  .row > input:not([type="checkbox"]), .row > span[style] { flex: 1 1 100% !important; min-width: 0 !important; }
  .stat .value.num { white-space: normal; font-size: 18px; }
  /* Форма добавления — над длинным списком, чтобы не листать вниз. */
  .g-main > :last-child { order: -1; }
  .search { flex-wrap: wrap; }
  .search .btn { flex: 1; }
  .chart { gap: 4px; height: 140px; }
  .chart .m { font-size: 10px; }
  /* Таблицы → карточки: каждая строка — блок, подпись колонки — перед значением. */
  table.cards, table.cards tbody, table.cards tr, table.cards td { display: block; width: 100%; }
  table.cards th { display: none; }
  table.cards tr { border-bottom: 1px solid var(--border); padding: 10px 0; }
  table.cards tr:last-child { border-bottom: 0; }
  table.cards td { border: 0; padding: 2px 0; text-align: left; }
  table.cards td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: 12px; }
  table.cards td.r form, table.cards td.r a { display: inline-block; margin-top: 4px; }
  .table-wrap:has(table.cards) { overflow: visible; margin: 0; padding: 0; }
}
@media (max-width: 360px) {
  .nav a { font-size: 10px; padding: 6px 1px; letter-spacing: -.02em; }  /* 6 пунктов меню влезают и на 320 px */
}

/* ---------- лендинг ---------- */
.landing { background: var(--bg); }
.l-wrap { max-width: 1120px; margin: 0 auto; padding: 0 20px; }
.l-head { background: #000; padding: 14px 0; position: sticky; top: 0; z-index: 5; }
.l-brand { color: #fff; font-weight: 800; font-size: 18px; letter-spacing: .04em; }
.l-brand span { color: #4d7cf3; }
.l-brand:hover { text-decoration: none; }
.l-ghost { background: transparent; color: inherit; }
.l-head .l-ghost { color: #fff; border-color: #333; }
.l-head .l-ghost:hover { background: #111; }
.l-hero { background: #000; color: #fff; padding: 56px 0 72px; }
.l-hero-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 48px; align-items: center; }
.l-kicker { color: #4d7cf3; font-weight: 700; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; margin-bottom: 14px; }
.l-hero h1 { font-size: 40px; line-height: 1.15; letter-spacing: -.02em; margin-bottom: 16px; }
.l-lead { color: #c5c9d3; font-size: 17px; max-width: 560px; margin: 0 0 26px; }
.l-hero .l-ghost { color: #fff; border-color: #333; }
.l-hero .l-ghost:hover { background: #111; }
.l-cta { min-height: 48px; padding: 12px 22px; font-size: 16px; }
.l-note { color: #8a90a0; font-size: 13px; margin-top: 14px; }
.l-hl { color: #4d7cf3; display: block; }
.l-lead b { color: #fff; }
.l-pain { background: var(--surface); border-bottom: 1px solid var(--border); }
.l-pains { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.l-pains > div { background: var(--bg); border-left: 4px solid var(--bad); border-radius: 10px; padding: 16px 18px; font-size: 15px; color: var(--muted); }
.l-pains b { color: var(--text); }
.l-pain-cta { font-size: 17px; font-weight: 600; margin: 24px 0 0; }
.l-phone { background: #0e1116; border: 1px solid #262b35; border-radius: 28px; padding: 16px; max-width: 360px; justify-self: end; width: 100%;
  box-shadow: 0 20px 60px rgba(10, 63, 184, .35); }
.l-chat-head { color: #8a90a0; font-size: 12px; text-align: center; padding: 4px 0 12px; border-bottom: 1px solid #1e232c; margin-bottom: 12px; }
.l-msg { background: #1b2130; color: #e8eaee; border-radius: 14px 14px 14px 4px; padding: 10px 12px; font-size: 14px; margin-bottom: 10px; }
.l-stars { display: flex; gap: 6px; margin: -2px 0 12px; }
.l-stars span { flex: 1; text-align: center; font-size: 12px; background: #151a24; border: 1px solid #262b35; border-radius: 8px; padding: 6px 0; color: #c5c9d3; }
.l-stars .on { background: #0a3fb8; border-color: #0a3fb8; color: #fff; }
.l-section { padding: 64px 0; }
.l-section h2 { font-size: 28px; margin-bottom: 24px; letter-spacing: -.01em; }
.l-alt { background: var(--surface); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.l-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.l-feat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.l-feat h3 { font-size: 17px; margin: 10px 0 8px; }
.l-feat p { color: var(--muted); margin: 0; font-size: 14px; }
.l-ico { font-size: 26px; }
.l-steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.l-steps b { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: #fff; }
.l-steps h3 { margin: 12px 0 6px; font-size: 17px; }
.l-steps p { color: var(--muted); margin: 0; font-size: 14px; }
.l-price { display: flex; justify-content: space-between; align-items: center; gap: 24px; flex-wrap: wrap;
  background: var(--surface); border: 2px solid var(--accent); border-radius: 18px; padding: 28px; }
.l-price-val { font-size: 30px; font-weight: 800; color: var(--accent); margin-bottom: 6px; }
.l-foot { background: #000; color: #8a90a0; padding: 22px 0; font-size: 14px; }
.l-foot a { color: #c5c9d3; }
.l-sub { color: var(--muted); margin: -14px 0 24px; }
.l-shot { margin: 0; border-radius: 14px; overflow: hidden; border: 1px solid var(--border); background: var(--surface);
  box-shadow: 0 24px 60px rgba(10, 30, 80, .16); }
.l-shot img { display: block; width: 100%; height: auto; }
.l-bar { display: flex; align-items: center; gap: 6px; padding: 9px 12px; background: #111318; }
.l-bar i { width: 10px; height: 10px; border-radius: 50%; background: #3a3f4b; }
.l-bar span { color: #8a90a0; font-size: 12px; margin-left: 10px; }
.l-cap { color: var(--muted); font-size: 15px; margin: 14px 0 0; }
.l-cap b { color: var(--text); }
.l-two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; margin-top: 36px; }
.l-mobiles { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: center; margin-top: 44px; }
.l-mobile-text h3 { font-size: 22px; margin-bottom: 10px; }
.l-mobile-text p { color: var(--muted); font-size: 15px; }
.l-phone-shot { width: 100%; max-width: 270px; justify-self: center; height: auto; border-radius: 28px; border: 6px solid #111318;
  box-shadow: 0 24px 60px rgba(10, 30, 80, .2); }
.l-chats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.l-chat { background: #0e1621; border-radius: 22px; overflow: hidden; box-shadow: 0 24px 60px rgba(10, 30, 80, .18); }
.l-chat-title { background: #17212b; color: #fff; padding: 12px 16px; display: flex; flex-direction: column; }
.l-chat-title span { color: #7f91a4; font-size: 12px; }
.l-chat-body { padding: 14px; }
.l-chat .l-msg { background: #182533; color: #e8eaee; }
.l-chat .l-msg.out { background: #2b5278; margin-left: 18%; border-radius: 14px 14px 4px 14px; }
.l-kb { display: flex; gap: 6px; margin: -4px 0 10px; }
.l-kb span { flex: 1; text-align: center; font-size: 13px; color: #e8eaee; background: #22303f; border-radius: 8px; padding: 7px 4px; }
.l-photo .l-img { height: 110px; border-radius: 10px; margin-bottom: 6px;
  background: linear-gradient(135deg, #e9edf2 0%, #c9d1db 45%, #f4f6f8 55%, #aab4c0 100%); position: relative; }
.l-photo .l-img::after { content: ""; position: absolute; left: 58%; top: 38%; width: 18px; height: 12px; border-radius: 40% 60% 50% 50%;
  background: #6b7480; box-shadow: 0 0 0 3px rgba(255, 80, 80, .7); }
@media (max-width: 860px) {
  .l-two, .l-chats { grid-template-columns: minmax(0, 1fr); }
  .l-mobiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .l-mobile-text { grid-column: 1 / -1; }
  .l-hero-grid { grid-template-columns: minmax(0, 1fr); gap: 32px; }
  .l-phone { justify-self: center; }
  .l-grid, .l-steps, .l-pains { grid-template-columns: minmax(0, 1fr); }
  .l-hero h1 { font-size: 30px; }
  .l-section { padding: 44px 0; }
  .l-cta { width: 100%; }
}

/* форма записи: услуги с ценами */
.appt-svcs { display: grid; margin-top: 4px; }
.appt-svc { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 6px 0; border-bottom: 1px solid var(--border); }
.appt-svc .money { width: 210px; }
.appt-svc.off .money { display: none; }
@media (max-width: 720px) { .appt-svc .money { width: 100%; } }
