@font-face { font-family: "Golos"; font-weight: 400; font-display: swap; src: url(/static/fonts/golos-text-cyrillic-400-normal.woff2) format("woff2"); unicode-range: U+0400-045F, U+0490-0491, U+2116; }
@font-face { font-family: "Golos"; font-weight: 400; font-display: swap; src: url(/static/fonts/golos-text-latin-400-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2212; }
@font-face { font-family: "Golos"; font-weight: 500; font-display: swap; src: url(/static/fonts/golos-text-cyrillic-500-normal.woff2) format("woff2"); unicode-range: U+0400-045F, U+0490-0491, U+2116; }
@font-face { font-family: "Golos"; font-weight: 500; font-display: swap; src: url(/static/fonts/golos-text-latin-500-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2212; }
@font-face { font-family: "Golos"; font-weight: 600; font-display: swap; src: url(/static/fonts/golos-text-cyrillic-600-normal.woff2) format("woff2"); unicode-range: U+0400-045F, U+0490-0491, U+2116; }
@font-face { font-family: "Golos"; font-weight: 600; font-display: swap; src: url(/static/fonts/golos-text-latin-600-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2212; }
@font-face { font-family: "Golos"; font-weight: 700; font-display: swap; src: url(/static/fonts/golos-text-cyrillic-700-normal.woff2) format("woff2"); unicode-range: U+0400-045F, U+0490-0491, U+2116; }
@font-face { font-family: "Golos"; font-weight: 700; font-display: swap; src: url(/static/fonts/golos-text-latin-700-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2212; }
/* Шрифты шаблонов — для «обложек» карточек */
@font-face { font-family: "T-unbounded"; font-weight: 700; font-display: swap; src: url(/static/fonts/unbounded-cyrillic-700-normal.woff2) format("woff2"); unicode-range: U+0400-045F; }
@font-face { font-family: "T-unbounded"; font-weight: 700; font-display: swap; src: url(/static/fonts/unbounded-latin-700-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F; }
@font-face { font-family: "T-cormorant"; font-weight: 600; font-display: swap; src: url(/static/fonts/cormorant-garamond-cyrillic-600-normal.woff2) format("woff2"); unicode-range: U+0400-045F; }
@font-face { font-family: "T-cormorant"; font-weight: 600; font-display: swap; src: url(/static/fonts/cormorant-garamond-latin-600-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F; }
@font-face { font-family: "T-playfair"; font-weight: 700; font-display: swap; src: url(/static/fonts/playfair-display-cyrillic-700-normal.woff2) format("woff2"); unicode-range: U+0400-045F; }
@font-face { font-family: "T-playfair"; font-weight: 700; font-display: swap; src: url(/static/fonts/playfair-display-latin-700-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F; }
@font-face { font-family: "T-marck"; font-weight: 400; font-display: swap; src: url(/static/fonts/marck-script-cyrillic-400-normal.woff2) format("woff2"); unicode-range: U+0400-045F; }
@font-face { font-family: "T-marck"; font-weight: 400; font-display: swap; src: url(/static/fonts/marck-script-latin-400-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F; }

:root {
  --bg: #e9ecf0;
  --rail: #dde2e8;
  --surface: #ffffff;
  --sunken: #f3f5f8;
  --ink: #18202b;
  --muted: #5a6573;
  --line: #d3d9e0;
  --accent: #2481cc;         /* синий Telegram */
  --accent-ink: #ffffff;
  --accent-soft: #e2effa;
  --ok: #23854f;
  --ok-soft: #e1f3e8;
  --warn: #9a6a00;
  --warn-soft: #fbf0d4;
  --bad: #c43d35;
  --bad-soft: #fbe5e3;
  --code: #10161f;
  --code-ink: #d7dee8;
  --radius: 14px;
  --font: "Golos", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
/* Тёмная тема: по настройке системы, а в Telegram — как в самом Telegram (data-theme) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14181e; --rail: #0f1216; --surface: #1c2129; --sunken: #171b22; --ink: #e7ebf0; --muted: #9aa4b1; --line: #2c333d;
    --accent: #4ba3e3; --accent-ink: #0b1622; --accent-soft: #17293a; --ok: #5cc98b; --ok-soft: #163024; --warn: #e6b450; --warn-soft: #2f2612;
    --bad: #f07a72; --bad-soft: #3a1c1b; --code: #0c1015; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14181e; --rail: #0f1216; --surface: #1c2129; --sunken: #171b22; --ink: #e7ebf0; --muted: #9aa4b1; --line: #2c333d;
  --accent: #4ba3e3; --accent-ink: #0b1622; --accent-soft: #17293a; --ok: #5cc98b; --ok-soft: #163024; --warn: #e6b450; --warn-soft: #2f2612;
  --bad: #f07a72; --bad-soft: #3a1c1b; --code: #0c1015; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 400 15px/1.5 var(--font); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.loading { color: var(--muted); padding: 40px; }

/* ---------- каркас ---------- */
.shell { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; }
.rail { background: var(--rail); padding: 22px 14px; display: flex; flex-direction: column; gap: 22px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.brand b { display: block; font-size: 19px; font-weight: 700; letter-spacing: -.01em; }
.brand small { display: block; color: var(--muted); font-size: 12px; }
.brand-mark { width: 22px; height: 34px; border-radius: 6px; background: var(--accent); position: relative; flex: none; }
.brand-mark::before { content: ""; position: absolute; left: 5px; right: 5px; top: 8px; height: 3px; border-radius: 2px; background: var(--accent-ink); }
.brand-mark::after { content: ""; position: absolute; left: 5px; right: 5px; top: 15px; bottom: 7px; border-radius: 3px; background: var(--accent-ink); opacity: .5; }
.rail-nav { display: grid; gap: 2px; }
.rail-nav button { text-align: left; border: 0; background: none; padding: 10px 12px; border-radius: 10px; cursor: pointer; font-weight: 500; color: var(--muted); display: flex; align-items: center; gap: 10px; }
.rail-nav svg { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.rail-nav .l-short { display: none; }
.rail-nav button:hover { color: var(--ink); background: color-mix(in srgb, var(--surface) 55%, transparent); }
.rail-nav button[aria-current="page"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 0 var(--line); }
.rail-foot { margin-top: auto; font-size: 13px; color: var(--muted); padding: 0 8px; }
.rail-foot b { color: var(--ink); font-weight: 600; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); margin-right: 6px; vertical-align: 1px; }
.dot.on { background: var(--ok); }
.dot.off { background: var(--bad); }
.main { padding: 34px clamp(18px, 4vw, 48px) 80px; min-width: 0; outline: none; }
.page { max-width: 1120px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
h1 { font-size: 30px; line-height: 1.15; font-weight: 700; letter-spacing: -.02em; margin: 0 0 6px; }
h2 { font-size: 20px; line-height: 1.25; font-weight: 650; margin: 0 0 10px; letter-spacing: -.01em; }
h3 { font-size: 16px; margin: 0 0 6px; font-weight: 650; }
.lead { color: var(--muted); max-width: 64ch; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
p { margin: 0 0 10px; }

/* ---------- кнопки и поля ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 600; text-decoration: none; color: var(--ink); white-space: nowrap; }
.btn:hover { border-color: color-mix(in srgb, var(--ink) 30%, var(--line)); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { border-color: var(--accent); filter: brightness(1.06); }
.btn-quiet { background: none; border-color: transparent; color: var(--accent); padding-inline: 10px; }
.btn-quiet:hover { background: var(--accent-soft); border-color: transparent; }
.btn-danger { color: var(--bad); }
.btn-sm { min-height: 32px; padding: 4px 12px; font-size: 14px; border-radius: 8px; }
.btn[disabled] { opacity: .5; cursor: default; pointer-events: none; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field > span { font-weight: 600; font-size: 14px; }
.field small { color: var(--muted); font-size: 13px; }
.input { width: 100%; min-height: 42px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.input:focus { outline: 3px solid var(--accent-soft); border-color: var(--accent); }
.input.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 14px; }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.check > span { font-weight: 400; }
.check b { font-weight: 600; }
.check input { margin-top: 4px; width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.err { color: var(--bad); font-size: 14px; margin-top: 6px; }

/* ---------- блоки ---------- */
.panel { background: var(--surface); border-radius: var(--radius); padding: 22px; border: 1px solid var(--line); }
.panel + .panel { margin-top: 16px; }
.two > .panel { margin-top: 0; }
.note { background: var(--sunken); border-radius: 12px; padding: 14px 16px; font-size: 14px; }
.note.warn { background: var(--warn-soft); }
.note.ok { background: var(--ok-soft); }
.note.bad { background: var(--bad-soft); }
.note b { font-weight: 600; }
.empty { text-align: left; padding: 28px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 22px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.kv.dns { align-items: center; }
.kv.dns .copy { padding-block: 4px; }
.two { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 16px; align-items: start; }
code, .code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13.5px; background: var(--sunken); padding: 2px 6px; border-radius: 6px; }
.copy { display: flex; gap: 8px; align-items: center; background: var(--sunken); border-radius: 10px; padding: 8px 8px 8px 12px; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 14px; overflow-wrap: anywhere; }
.copy span { flex: 1; }
ol.steps { padding-left: 22px; margin: 8px 0 0; }
ol.steps li { margin-bottom: 10px; padding-left: 4px; }
ol.steps li::marker { font-weight: 700; color: var(--accent); }

/* ---------- карточки шаблонов: «экран» в цветах шаблона ---------- */
.tgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }
.tcard { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden; display: flex; flex-direction: column; }
.tcover[data-act] { cursor: pointer; }
.tcover { position: relative; height: 150px; padding: 18px 20px; display: flex; flex-direction: column; justify-content: flex-end; overflow: hidden; }
.tcover .tname { font-size: 26px; line-height: 1.05; max-width: 74%; position: relative; }
.tcover .tbtn { position: absolute; right: 18px; top: 18px; padding: 6px 12px; font: 600 12px/1.2 var(--font); }
.tcover .tlines { position: absolute; right: 18px; bottom: 20px; width: 46px; display: grid; gap: 7px; }
.tcover .tlines i { display: block; height: 6px; border-radius: 3px; opacity: .28; }
.tcover .tlines i:nth-child(2) { width: 70%; justify-self: end; }
.tcover .tlines i:nth-child(3) { width: 45%; justify-self: end; }
.tbody { padding: 16px 20px 18px; display: flex; flex-direction: column; gap: 12px; flex: 1; }
.tdesc { color: var(--muted); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; margin: 0; }
.tdesc.open { -webkit-line-clamp: unset; display: block; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12.5px; padding: 3px 9px; border-radius: 999px; background: var(--sunken); color: var(--muted); }
.tactions { margin-top: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.running { background: var(--ok-soft); border-radius: 10px; padding: 10px 12px; font-size: 14px; display: grid; gap: 8px; }
.running .row { gap: 2px; margin-left: -10px; }
.open2 { display: flex; flex-wrap: wrap; gap: 6px; }
.open2 .btn { flex: 1 1 auto; white-space: normal; }
.more-btn { align-self: flex-start; margin: -8px 0 0 -10px; }

/* ---------- приложения клиентов ---------- */
.clist { display: grid; gap: 10px; }
.crow { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: 4px 14px; align-items: center; }
.crow .sw { width: 10px; align-self: stretch; border-radius: 5px; }
.crow h3 { margin: 0; }
.crow .meta { color: var(--muted); font-size: 14px; display: flex; gap: 14px; flex-wrap: wrap; }
details.menu { position: relative; }
details.menu > summary { list-style: none; }
details.menu > summary::-webkit-details-marker { display: none; }
details.menu .menu-list { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 6px; min-width: 250px; white-space: nowrap; box-shadow: 0 12px 30px rgba(10, 20, 30, .16); display: grid; }
details.menu .menu-list button { text-align: left; background: none; border: 0; padding: 9px 12px; border-radius: 8px; cursor: pointer; }
details.menu .menu-list button:hover { background: var(--sunken); }
details.menu .menu-list .danger { color: var(--bad); }

/* ---------- мастер «Новое приложение» ---------- */
.wizard { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 28px; align-items: start; }
.wsteps { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; position: sticky; top: 24px; }
.wsteps li { padding: 9px 12px; border-radius: 10px; color: var(--muted); display: flex; gap: 10px; align-items: center; font-weight: 500; }
.wsteps li b { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; background: var(--sunken); flex: none; }
.wsteps li.on { background: var(--surface); color: var(--ink); }
.wsteps li.on b { background: var(--accent); color: var(--accent-ink); }
.wsteps li.done b { background: var(--ok); color: #fff; }
.pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.pick label { display: flex; gap: 12px; align-items: center; border: 1.5px solid var(--line); border-radius: 12px; padding: 12px; cursor: pointer; background: var(--surface); }
.pick label:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.pick input { position: absolute; opacity: 0; pointer-events: none; }
.pick .sw { width: 34px; height: 44px; border-radius: 8px; flex: none; position: relative; }
.pick .sw::after { content: ""; position: absolute; left: 7px; right: 7px; bottom: 7px; height: 6px; border-radius: 3px; background: var(--sw-accent); }
.pick small { display: block; color: var(--muted); font-size: 12.5px; }
.mods { display: grid; gap: 4px; }
.mods label { padding: 10px 12px; border-radius: 10px; }
.mods label:hover { background: var(--sunken); }
.mods small { display: block; color: var(--muted); font-size: 13px; }
.wnav { display: flex; justify-content: space-between; gap: 10px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }

/* ---------- окно с журналом ---------- */
.overlay { position: fixed; inset: 0; background: rgba(10, 16, 24, .48); display: grid; place-items: center; padding: 20px; z-index: 50; }
.dialog { background: var(--surface); border-radius: 18px; width: min(760px, 100%); max-height: calc(100vh - 40px); display: flex; flex-direction: column; box-shadow: 0 30px 80px rgba(0, 0, 0, .3); }
.dialog-head { padding: 20px 22px 8px; display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; }
.dialog-head h2 { margin: 0; }
.dialog-body { padding: 8px 22px 6px; overflow: auto; }
.dialog-foot { padding: 14px 22px 20px; display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.log { background: var(--code); color: var(--code-ink); border-radius: 12px; padding: 14px 16px; font: 13px/1.55 ui-monospace, "Cascadia Mono", Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 52vh; overflow: auto; margin: 0; }
.status { display: flex; align-items: center; gap: 10px; font-weight: 600; margin-bottom: 12px; }
.status .spinner, .btn .spinner { margin-right: 0; }
.spinner { display: inline-block; vertical-align: -3px; margin-right: 6px; width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid var(--accent-soft); border-top-color: var(--accent); animation: spin 0.9s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
#toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: var(--surface); padding: 10px 18px; border-radius: 12px; font-weight: 500; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 60; max-width: calc(100% - 32px); }
#toast.show { opacity: 1; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px 14px; gap: 12px; min-width: 0; }
  .rail-nav { display: flex; overflow-x: auto; max-width: 100%; }
  .tgrid { grid-template-columns: minmax(0, 1fr); }
  .rail-nav button { white-space: nowrap; }
  .rail-foot { margin-top: 0; width: 100%; }
  .two, .wizard { grid-template-columns: 1fr; }
  .wsteps { position: static; display: flex; overflow-x: auto; }
  .wsteps li span { display: none; }
  .crow { grid-template-columns: 10px minmax(0, 1fr); }
  .crow .acts { grid-column: 2; }
  h1 { font-size: 25px; }
}
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 3s; }
  #toast { transition: none; }
}

/* ---------- CRM ---------- */
.back { margin: -10px 0 10px -10px; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 18px; }
.stat { text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; cursor: pointer; display: grid; gap: 2px; color: var(--ink); }
.stat:hover { border-color: color-mix(in srgb, var(--ink) 25%, var(--line)); }
.stat.on { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.stat span { color: var(--muted); font-size: 13.5px; }
.stat b { font-size: 24px; font-weight: 650; line-height: 1.2; }
.stat small { color: var(--muted); font-size: 12.5px; }
.stat.warn b { color: var(--warn); }
.crm-filters { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 14px; }
.crm-filters .input { max-width: 300px; min-height: 38px; }
.seg-row { display: flex; flex-wrap: wrap; gap: 4px; }
.seg-row button { border: 1px solid transparent; background: none; padding: 6px 12px; border-radius: 999px; cursor: pointer; color: var(--muted); font-weight: 500; font-size: 14px; }
.seg-row button:hover { color: var(--ink); background: var(--surface); }
.seg-row button.on { background: var(--surface); color: var(--ink); border-color: var(--line); font-weight: 600; }
.seg-row i { font-style: normal; color: var(--muted); font-size: 12.5px; margin-left: 2px; }
.crm-row { width: 100%; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; cursor: pointer; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 18px; align-items: center; color: var(--ink); }
.crm-row:hover { border-color: color-mix(in srgb, var(--ink) 25%, var(--line)); }
.crm-main { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; min-width: 0; }
.crm-main b { font-size: 16px; }
.crm-main .muted { flex-basis: 100%; }
.crm-side { display: grid; justify-items: end; gap: 2px; text-align: right; font-size: 14px; }
.st { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; padding: 2px 9px 2px 8px; border-radius: 999px; background: var(--sunken); color: var(--ink); }
.st::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.st-lead::before { background: #8b95a3; }
.st-talks::before { background: #7b61d1; }
.st-build::before { background: #d08b16; }
.st-active::before { background: var(--ok); }
.st-pause::before { background: #8b95a3; }
.st-gone { color: var(--muted); }
.st-gone::before { background: transparent; border: 1.5px solid var(--muted); }
.pay { font-weight: 600; font-size: 13.5px; }
.pay.bad { color: var(--bad); }
.pay.warn { color: var(--warn); }
.sel-status { min-height: 34px; padding: 4px 10px; width: auto; font-weight: 600; }
.crm-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.crm-cols .col { display: grid; gap: 16px; }
.crm-cols .panel + .panel { margin-top: 0; }
table.mini { width: 100%; border-collapse: collapse; margin-top: 14px; font-size: 14px; }
table.mini td { padding: 6px 4px; border-top: 1px solid var(--line); }
table.mini .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.x { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 2px 6px; border-radius: 6px; font-size: 13px; }
.x:hover { color: var(--bad); background: var(--bad-soft); }
.add-row { flex-wrap: nowrap; margin-bottom: 10px; }
.add-row .input { min-height: 36px; }
.add-row .input[type=date] { width: 150px; flex: none; }
ul.tasks, ul.timeline, ul.results { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
ul.tasks li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 4px; border-radius: 8px; }
ul.tasks li:hover { background: var(--sunken); }
ul.tasks li small { color: var(--muted); margin-left: 4px; }
ul.tasks li.due small { color: var(--warn); font-weight: 600; }
ul.tasks li.done span { color: var(--muted); text-decoration: line-through; }
.app-list { display: grid; gap: 8px; }
.app-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; background: var(--sunken); border-radius: 10px; }
ul.timeline { margin-top: 14px; gap: 0; }
ul.timeline li { position: relative; padding: 8px 30px 8px 14px; border-left: 2px solid var(--line); }
ul.timeline li.k-report, ul.timeline li.k-message { border-left-color: var(--accent); }
ul.timeline li.k-payment { border-left-color: var(--ok); }
ul.timeline li small { color: var(--muted); font-size: 12.5px; }
ul.timeline li p { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
ul.timeline li .x { position: absolute; right: 0; top: 6px; }
ul.results li { padding: 6px 0; }
ul.results li.ok { color: var(--ok); }
ul.results li.bad { color: var(--bad); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; align-items: start; }
.preview { width: 100%; height: 78vh; min-height: 560px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.link-chip { border: 0; background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 1px 9px; font-size: 13px; cursor: pointer; font-weight: 500; }
textarea.input { resize: vertical; line-height: 1.45; }
@media (max-width: 860px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .crm-cols, .form-grid { grid-template-columns: 1fr; }
  .crm-row { grid-template-columns: 1fr; }
  .crm-side { justify-items: start; text-align: left; }
  .crm-filters .input { max-width: none; }
  .add-row { flex-wrap: wrap; }
}

/* ---------- общее для компьютера и телефона ---------- */
html.no-nav .rail { display: none; }
html.no-nav .shell { grid-template-columns: 1fr; }
.grow { margin-right: auto; }
.wrap { overflow-wrap: anywhere; }
.btn-wide { width: 100%; }
.btn-del { background: var(--bad); border-color: var(--bad); color: #fff; }
.menu-title { display: none; }
.dialog-sm { width: min(440px, 100%); }
.dialog-sm .dialog-body { padding-top: 20px; font-size: 16px; }
.confirm { z-index: 80; }
.progress { height: 6px; border-radius: 3px; background: var(--sunken); overflow: hidden; margin: -4px 0 12px; }
.progress i { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width .2s; }
.qr-box { display: grid; grid-template-columns: 172px minmax(0, 1fr); gap: 18px; align-items: start; margin-top: 16px; padding: 14px; background: var(--sunken); border-radius: 12px; }
.qr-box .qr svg { display: block; width: 100%; height: auto; border-radius: 8px; }
.qr-box p { font-size: 14px; }
ul.people { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
ul.people li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 12px; background: var(--sunken); border-radius: 10px; }
.file-pick { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; cursor: pointer; }
.file-pick input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-pick:focus-within .btn { outline: 3px solid var(--accent); outline-offset: 2px; }
.login { max-width: 460px; margin: 8vh auto 0; display: grid; gap: 14px; }
.login h1 { margin: 0; }
.pair-code { font: 700 44px/1.1 ui-monospace, "Cascadia Mono", Consolas, monospace; letter-spacing: .18em; text-align: center; padding: 18px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
.brand-mark.big { width: 36px; height: 56px; border-radius: 10px; }
.brand-mark.big::before { left: 8px; right: 8px; top: 13px; height: 5px; border-radius: 3px; }
.brand-mark.big::after { left: 8px; right: 8px; top: 25px; bottom: 11px; border-radius: 5px; }
.link-row select { flex: 1 1 200px; width: auto; }

/* ---------- телефон: нижнее меню, окна снизу, крупные кнопки ---------- */
@media (max-width: 700px) {
  html, body { font-size: 15.5px; -webkit-tap-highlight-color: transparent; }
  .shell { display: block; min-height: 100dvh; }
  .rail {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; height: auto; z-index: 40;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); background: var(--surface);
    border-top: 1px solid var(--line); flex-direction: row; gap: 0;
  }
  .brand, .rail-foot { display: none; }
  .rail-nav { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); width: 100%; gap: 4px; overflow: visible; }
  .rail-nav button { flex-direction: column; justify-content: center; gap: 3px; padding: 7px 2px 6px; font-size: 11.5px; font-weight: 600; text-align: center; border-radius: 14px; min-height: 54px; white-space: nowrap; }
  .rail-nav svg { width: 24px; height: 24px; }
  .rail-nav .l-long { display: none; }
  .rail-nav .l-short { display: inline; }
  .rail-nav button:hover { background: none; color: var(--muted); }
  .rail-nav button[aria-current="page"] { background: var(--accent-soft); color: var(--accent); box-shadow: none; }
  .main { padding: 18px 16px calc(92px + env(safe-area-inset-bottom)); }
  html.no-nav .main { padding-bottom: 32px; }
  h1 { font-size: 24px; }
  h2 { font-size: 18px; }
  .lead { font-size: 14.5px; }
  .page-head { margin-bottom: 16px; gap: 12px; align-items: flex-start; }
  .page-head > .row { width: 100%; }
  .page-head > .row .btn-primary { flex: 1 1 auto; }
  .report-acts .btn-sm { flex: 1 1 0; }
  .report-acts .btn-primary { flex-basis: 100%; }
  .panel { padding: 16px; border-radius: 16px; }
  .two { gap: 12px; }
  .two + .two, .panel + .panel { margin-top: 12px; }
  .btn { min-height: 44px; }
  .btn-sm { min-height: 40px; padding: 6px 14px; font-size: 14.5px; }
  .input, select.input, textarea.input { font-size: 16px; min-height: 46px; }
  .x { min-width: 40px; min-height: 40px; font-size: 15px; display: inline-grid; place-items: center; }
  .check input { width: 22px; height: 22px; margin-top: 1px; }
  .kv { grid-template-columns: 1fr; gap: 0; }
  .kv dt { font-size: 13px; }
  .kv dd { margin-bottom: 10px; }
  .copy { font-size: 13px; }
  .note { font-size: 14.5px; }
  #toast { bottom: calc(84px + env(safe-area-inset-bottom)); text-align: center; }
  html.no-nav #toast { bottom: calc(24px + env(safe-area-inset-bottom)); }

  /* окна — снизу, во всю ширину */
  .overlay { place-items: end stretch; padding: 0; }
  .dialog { width: 100%; max-height: calc(100dvh - 16px); border-radius: 20px 20px 0 0; animation: sheet-up .22s ease-out; }
  .dialog-head { padding: 18px 16px 6px; }
  .dialog-body { padding: 6px 16px 4px; }
  .dialog-foot { padding: 12px 16px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
  .dialog-foot .btn { flex: 1 1 0; }
  .dialog-foot .grow { flex-basis: 100%; }
  .dialog-sm { width: 100%; }
  .log { max-height: 40dvh; font-size: 12.5px; }

  /* меню «Действия» — листом снизу */
  details.menu[open] > summary::before { content: ""; position: fixed; inset: 0; background: rgba(10, 16, 24, .48); z-index: 60; cursor: default; }
  details.menu .menu-list { position: fixed; left: 8px; right: 8px; top: auto; bottom: calc(8px + env(safe-area-inset-bottom)); z-index: 61; min-width: 0; border-radius: 20px; padding: 8px; white-space: normal; animation: sheet-up .2s ease-out; max-height: 80dvh; overflow: auto; }
  details.menu .menu-list button { padding: 14px; font-size: 16px; border-radius: 12px; }
  .menu-title { display: block; padding: 8px 14px 10px; font-weight: 700; color: var(--muted); font-size: 13.5px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }

  /* шаблоны */
  .tgrid { gap: 12px; }
  .tcover { height: 124px; }
  .tactions .btn { flex: 1 1 auto; }

  /* приложения клиентов */
  .crow { padding: 14px; gap: 6px 12px; }
  .crow .acts { justify-content: flex-start; }
  .crow .acts > .btn, .crow .acts > details { flex: 1 1 0; }
  .crow .acts summary.btn { width: 100%; }
  .crow .meta { gap: 4px 12px; font-size: 13.5px; }

  /* мастер */
  .wsteps { gap: 6px; margin-bottom: -6px; }
  .wsteps li { padding: 0; background: none !important; }
  .wsteps li b { width: 30px; height: 30px; }
  .pick { grid-template-columns: 1fr; }
  .wnav { position: sticky; bottom: calc(76px + env(safe-area-inset-bottom)); background: var(--surface); margin: 18px -16px -16px; padding: 12px 16px 16px; border-radius: 0 0 16px 16px; z-index: 5; }
  .wnav .btn { flex: 1 1 0; }

  /* CRM */
  .stats { gap: 8px; margin-bottom: 14px; }
  .stat { padding: 12px 14px; border-radius: 14px; }
  .stat b { font-size: 20px; }
  .stat span, .stat small { font-size: 12.5px; }
  .crm-filters { gap: 10px; }
  .seg-row { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-inline: -16px; padding-inline: 16px; width: calc(100% + 32px); }
  .seg-row::-webkit-scrollbar { display: none; }
  .seg-row button { white-space: nowrap; padding: 9px 14px; flex: none; }
  .crm-row { padding: 14px; }
  .crm-cols { gap: 12px; }
  .crm-cols .col { gap: 12px; }
  .add-row .input[name=text] { flex: 1 1 100%; }
  .add-row .input[type=date] { flex: 1 1 auto; width: auto; }
  ul.tasks li { padding: 4px 0 4px 4px; }
  ul.timeline li { padding-right: 44px; }
  .app-item .row { width: 100%; }
  .sel-status { min-height: 40px; flex: 1 1 auto; }
  .back { margin: -6px 0 6px -10px; }
  .range-row label { flex: 1 1 140px; }
  .range-row .input { flex: 1; }

  /* отчёт */
  .preview { height: 70dvh; min-height: 420px; border-radius: 12px; }

  /* сервер */
  .qr-box { grid-template-columns: 1fr; justify-items: center; text-align: left; }
  .qr-box .qr { width: min(240px, 70vw); }
}
@media (max-width: 700px) and (hover: none) {
  .btn:hover { border-color: var(--line); }
  .btn-primary:hover { border-color: var(--accent); filter: none; }
}
@keyframes sheet-up { from { transform: translateY(32px); } to { transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .dialog, details.menu .menu-list { animation: none; }
}

/* ---------- площадки: Telegram и ВКонтакте ---------- */
.plat { display: inline-flex; align-items: center; gap: 4px; }
.plat svg { width: 15px; height: 15px; flex: none; }
.plat.tg svg { color: #2aabee; }
.plat.vk svg { color: #0077ff; }
.btn-vk { gap: 6px; }
.btn-vk svg { width: 17px; height: 17px; }
.plat-pick { grid-template-columns: 1fr; }
.plat-pick label { align-items: flex-start; }
.plat-ic { display: flex; gap: 2px; flex: none; padding-top: 2px; }
.plat-ic svg { width: 26px; height: 26px; }
.plat-ic svg:first-child { color: #2aabee; }
.plat-ic svg:last-child { color: #0077ff; }
.plat-pick label:nth-child(1) .plat-ic svg { color: #2aabee; }
.plat-pick label:nth-child(2) .plat-ic svg { color: #0077ff; }
h3.sub { font-size: 16px; margin: 20px 0 6px; }
.vk-ok { display: grid; gap: 4px; margin: 4px 0 10px; color: var(--ok); font-weight: 600; }
.vk-ok .muted { font-weight: 400; }
.dialog .steps { padding-left: 20px; }
/* тарифы */
.tariff { display: inline-block; font-size: 12.5px; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); margin-right: 4px; }
fieldset.tariff-box { border: 1px solid var(--line); border-radius: 12px; padding: 4px 14px 12px; margin: 0 0 12px; min-width: 0; }
fieldset.tariff-box legend { font-weight: 600; padding: 0 6px; }
.form-grid.g3 { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr); }
details.incl { margin-top: 4px; }
details.incl summary { cursor: pointer; }
details.incl ul { margin: 4px 0 0; padding-left: 18px; }
@media (max-width: 860px) { .form-grid.g3 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .form-grid.g3 .field:first-child { grid-column: 1 / -1; } }
/* разбор «Что улучшить» в отчёте */
.adv-panel { margin: 0 0 14px; }
.adv-panel .adv-head { align-items: flex-start; }
.adv-list { display: grid; gap: 8px; margin-top: 12px; }
.adv-item { display: grid; grid-template-columns: 130px minmax(0, 1fr) auto; gap: 8px; align-items: start; padding-left: 10px; border-left: 3px solid var(--line); }
.adv-item.k-warn { border-left-color: #c2410c; }
.adv-item.k-tip { border-left-color: var(--accent); }
.adv-item.k-good { border-left-color: var(--ok); }
.adv-item select { min-height: 36px; padding: 4px 8px; }
.adv-item textarea { min-height: 58px; font-size: 14px; field-sizing: content; }
@media (max-width: 700px) { .adv-item { grid-template-columns: minmax(0, 1fr) auto; } .adv-item select { grid-column: 1; } .adv-item textarea { grid-column: 1 / -1; grid-row: 2; } .adv-item .x { grid-column: 2; grid-row: 1; } }
.bad-t { color: var(--bad); }
