:root {
  --brand: #ff2d3f;
  --brand-hover: #e81f31;
  --brand-soft: rgba(255, 45, 63, .09);
  --brand-line: rgba(255, 45, 63, .35);
  --bg: #f4f4f6;
  --surface: #ffffff;
  --surface-2: #f2f2f5;
  --surface-3: #e9e9ee;
  --text: #15161a;
  --muted: #6b6f7a;
  --border: #e4e5ea;
  --ok: #15803d;   --ok-soft: rgba(22, 163, 74, .11);
  --warn: #b45309; --warn-soft: rgba(217, 119, 6, .13);
  --bad: #dc2626;  --bad-soft: rgba(220, 38, 38, .1);
  --idle: #6b7280; --idle-soft: rgba(107, 114, 128, .13);
  --blue: #2563eb; --blue-soft: rgba(37, 99, 235, .1);
  --violet: #7c3aed; --violet-soft: rgba(124, 58, 237, .1);
  --shadow: 0 1px 2px rgba(15, 16, 20, .04), 0 2px 10px rgba(15, 16, 20, .04);
  --shadow-lg: 0 10px 40px rgba(15, 16, 20, .18);
  --radius: 16px;
  --font-head: 'Unbounded', system-ui, sans-serif;
  --font-body: 'Onest', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --sidebar: 248px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d0e12; --surface: #16171d; --surface-2: #1e2027; --surface-3: #282a33; --text: #eceef3; --muted: #9a9fab; --border: #272932;
    --brand-soft: rgba(255, 45, 63, .14); --brand-line: rgba(255, 45, 63, .45);
    --ok: #4ade80;  --ok-soft: rgba(74, 222, 128, .12);
    --warn: #fbbf24; --warn-soft: rgba(251, 191, 36, .12);
    --bad: #f87171; --bad-soft: rgba(248, 113, 113, .13);
    --idle: #9ca3af; --idle-soft: rgba(156, 163, 175, .13);
    --blue: #60a5fa; --blue-soft: rgba(96, 165, 250, .13);
    --violet: #a78bfa; --violet-soft: rgba(167, 139, 250, .13);
    --shadow: none; --shadow-lg: 0 10px 40px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d0e12; --surface: #16171d; --surface-2: #1e2027; --surface-3: #282a33; --text: #eceef3; --muted: #9a9fab; --border: #272932;
  --brand-soft: rgba(255, 45, 63, .14); --brand-line: rgba(255, 45, 63, .45);
  --ok: #4ade80;  --ok-soft: rgba(74, 222, 128, .12);
  --warn: #fbbf24; --warn-soft: rgba(251, 191, 36, .12);
  --bad: #f87171; --bad-soft: rgba(248, 113, 113, .13);
  --idle: #9ca3af; --idle-soft: rgba(156, 163, 175, .13);
  --blue: #60a5fa; --blue-soft: rgba(96, 165, 250, .13);
  --violet: #a78bfa; --violet-soft: rgba(167, 139, 250, .13);
  --shadow: none; --shadow-lg: 0 10px 40px rgba(0, 0, 0, .5);
  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 var(--font-body); -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-head); font-weight: 600; letter-spacing: -.015em; margin: 0; }
h1 { font-size: 24px; line-height: 1.2; }
h2 { font-size: 16px; }
h3 { font-size: 16px; line-height: 1.35; }
p { margin: 0; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }
.grow { flex: 1; min-width: 0; }
.spread { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.mt { margin-top: 12px; }

.ic { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ic.big { width: 32px; height: 32px; stroke-width: 1.6; opacity: .5; }

/* ---------- кнопки и поля ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 40px; padding: 0 16px; border-radius: 11px; border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; text-decoration: none; font-weight: 500; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .1s, box-shadow .15s;
}
.btn .ic { width: 17px; height: 17px; }
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 2px 8px rgba(255, 45, 63, .25); }
.btn.primary:hover { background: var(--brand-hover); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 13.5px; border-radius: 9px; }
.btn.lg { min-height: 46px; font-size: 16px; }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; transform: none; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; flex: none;
  border: none; background: transparent; color: var(--muted); cursor: pointer; transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.danger:hover { background: var(--bad-soft); color: var(--bad); }
.link { color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 500; }
.link:hover { color: var(--brand); }
:is(.btn, .icon-btn, .chip, .nav-item, .bn-item, .menu-item, a, input, select, textarea, summary):focus-visible {
  outline: 2px solid var(--brand); outline-offset: 2px;
}

input, select, textarea {
  width: 100%; min-height: 42px; padding: 9px 12px; border-radius: 11px;
  border: 1px solid var(--border); background: var(--surface); outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
textarea { resize: vertical; min-height: 72px; line-height: 1.5; }
select.inline { width: auto; min-height: 34px; padding: 4px 28px 4px 10px; font-size: 13.5px; border-radius: 9px; cursor: pointer; }
label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 500; }
.error { color: var(--bad); font-size: 14px; min-height: 1.2em; }
.note { font-size: 14px; background: var(--surface-2); padding: 10px 12px; border-radius: 10px; }
.note a { color: var(--brand); font-weight: 600; }

.toggle { display: inline-flex; flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-size: 14px; cursor: pointer; user-select: none; }
.toggle input { appearance: none; width: 36px; min-height: 0; height: 22px; padding: 0; border-radius: 11px; background: var(--surface-3); border: none; position: relative; cursor: pointer; transition: background .2s; box-shadow: none; }
.toggle input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.toggle input:checked { background: var(--brand); }
.toggle input:checked::after { transform: translateX(14px); }

/* ---------- вход ---------- */
.splash, .login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login { background: radial-gradient(1200px 500px at 50% -10%, var(--brand-soft), transparent 70%), var(--bg); }
.logo-lg { width: 60px; height: 60px; }
.login-card { width: 100%; max-width: 380px; display: grid; gap: 16px; padding: 32px 28px; box-shadow: var(--shadow-lg); }
.login-card h1 { font-size: 22px; }

/* ---------- каркас ---------- */
.shell { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar); z-index: 20;
  display: flex; flex-direction: column; gap: 8px; padding: 18px 14px 14px;
  background: var(--surface); border-right: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 14px; text-decoration: none; font-family: var(--font-head); font-size: 16px; font-weight: 600; }
.brand img { width: 34px; height: 34px; }
.brand b { color: var(--brand); font-weight: 700; }
.side-nav { display: grid; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 11px;
  color: var(--muted); text-decoration: none; font-weight: 500; transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--brand-soft); color: var(--brand); }
.nav-item.active .ic { stroke-width: 2.3; }
.nav-item .count { margin-left: auto; }
.count { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; font-size: 12px; font-weight: 700; background: var(--brand); color: #fff; font-variant-numeric: tabular-nums; }
.count.bad { background: var(--bad); }
.side-foot { margin-top: auto; display: grid; gap: 10px; }
.tg-status {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 11px; cursor: pointer; text-align: left;
  border: 1px dashed var(--brand-line); background: var(--brand-soft); color: var(--brand); font-weight: 600; font-size: 13.5px;
}
.tg-status.on { border: 1px solid var(--border); background: transparent; color: var(--muted); font-weight: 500; }
.tg-status.on .ic { color: var(--ok); }
.me { display: flex; align-items: center; gap: 8px; padding-top: 10px; border-top: 1px solid var(--border); }
.me .icon-btn { width: 32px; height: 32px; }
.me .icon-btn .ic { width: 17px; height: 17px; }
.avatar {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; flex: none;
  background: linear-gradient(135deg, var(--brand), #ff7a45); color: #fff; font-weight: 700; font-family: var(--font-head); font-size: 14px;
}
.me-text { flex: 1; min-width: 0; display: grid; line-height: 1.25; }
.me-text b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-text span { font-size: 12px; color: var(--muted); }

.mtop, .bottom-nav { display: none; }

main { margin-left: var(--sidebar); padding: 28px 32px 60px; display: grid; gap: 18px; max-width: calc(var(--sidebar) + 1120px); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel { padding: 18px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.page-head p { margin-top: 4px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.hint { font-size: 14px; color: var(--muted); background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }

/* ---------- сводка ---------- */
.banner {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: var(--radius);
  background: var(--brand-soft); border: 1px solid var(--brand-line);
}
.banner > .ic { color: var(--brand); width: 22px; height: 22px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stat { padding: 16px 18px; display: grid; gap: 2px; text-decoration: none; transition: border-color .15s, transform .15s; }
.stat .num { font-family: var(--font-head); font-size: 32px; font-weight: 600; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat .of { color: var(--muted); font-size: 20px; }
.stat .lbl { color: var(--muted); font-size: 14px; }
.stat.accent { background: var(--brand); border-color: var(--brand); color: #fff; }
.stat.accent .lbl { color: rgba(255, 255, 255, .85); }
a.stat:hover { border-color: var(--brand); transform: translateY(-1px); }
.cols { display: grid; grid-template-columns: 1.15fr 1fr; gap: 18px; align-items: start; }
.list { display: grid; }
.list-row { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border); }
.list-row:first-child { border-top: none; padding-top: 2px; }
.list-row:last-child { padding-bottom: 0; }
.empty { color: var(--muted); padding: 28px 0; text-align: center; display: grid; gap: 8px; justify-items: center; }
.wait-row { align-items: center; }
.row-title { font-weight: 600; text-decoration: none; display: block; }
.row-title:hover { color: var(--brand); }
.row-actions { flex: none; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.todo { display: flex; gap: 6px; align-items: flex-start; color: var(--warn); margin-top: 2px; }
.todo .ic { width: 15px; height: 15px; margin-top: 2px; }

/* ---------- значки ---------- */
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; margin-top: 7px; background: var(--idle); }
.dot.d-ok { background: var(--ok); } .dot.d-warn { background: var(--warn); } .dot.d-bad { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); } .dot.d-lead { background: var(--brand); }
.badge { display: inline-flex; align-items: center; height: 24px; padding: 0 9px; border-radius: 7px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.b-ok { background: var(--ok-soft); color: var(--ok); }
.b-warn { background: var(--warn-soft); color: var(--warn); }
.b-bad { background: var(--bad-soft); color: var(--bad); }
.b-idle { background: var(--idle-soft); color: var(--idle); }
.b-lead, .s-new { background: var(--brand-soft); color: var(--brand); }
.s-replied { background: var(--blue-soft); color: var(--blue); }
.s-talks { background: var(--warn-soft); color: var(--warn); }
.s-work { background: var(--violet-soft); color: var(--violet); }
.s-contract { background: var(--ok-soft); color: var(--ok); }
.s-rejected { background: var(--idle-soft); color: var(--idle); }
.pill { display: inline-flex; align-items: center; height: 24px; padding: 0 9px; border-radius: 7px; font-size: 12.5px; font-weight: 600; background: var(--surface-2); color: var(--text); }
.wait { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 600; color: var(--warn); }
.wait .ic { width: 14px; height: 14px; }
.wait.urgent { color: var(--bad); }

/* ---------- заявки ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.search { position: relative; flex: 1 1 260px; display: block; }
.search .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input { padding-left: 40px; }
.toolbar > select { width: auto; flex: 0 0 auto; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: 18px; border: 1px solid var(--border); background: var(--surface);
  cursor: pointer; font-size: 14px; font-weight: 500; white-space: nowrap; transition: background .15s, border-color .15s;
}
.chip:hover { border-color: var(--muted); }
.chip .dot { margin: 0; }
.chip.active { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip .n { opacity: .55; font-variant-numeric: tabular-nums; }

.leads { display: grid; gap: 14px; }
.lead { padding: 18px; display: grid; gap: 12px; scroll-margin-top: 80px; position: relative; overflow: hidden; }
.lead.is-new::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--brand); }
.lead.flash { animation: flash 1.6s ease-out; }
@keyframes flash { 0%, 30% { box-shadow: 0 0 0 3px var(--brand-line); } 100% { box-shadow: var(--shadow); } }
.lead-top { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.lead-top .time { margin-left: auto; }
.lead-title { display: flex; gap: 8px; align-items: flex-start; }
.lead-title h3 { flex: 1; font-size: 17px; }
.lead-title .icon-btn { margin: -6px -6px 0 0; }
.lead-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 14px; }
.lead-meta span { display: inline-flex; align-items: center; gap: 6px; }
.lead-meta .ic { width: 15px; height: 15px; color: var(--muted); }
.budget { font-weight: 700; }
.summary { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; cursor: pointer; }
.summary.full { display: block; color: var(--text); }

.reply { background: var(--surface-2); border-radius: 13px; padding: 14px; display: grid; gap: 10px; }
.reply.editing { background: var(--surface-2); outline: 2px solid var(--brand-line); }
.reply-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12.5px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.reply-head .btn { text-transform: none; letter-spacing: 0; font-weight: 500; margin: -6px -8px -6px 0; }
.reply-head select.inline { max-width: 60%; text-transform: none; letter-spacing: 0; font-weight: 500; background: var(--surface); }
.reply-text {
  white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14.5px; cursor: pointer;
  max-height: 7.6em; overflow: hidden; position: relative;
  -webkit-mask-image: linear-gradient(#000 60%, transparent); mask-image: linear-gradient(#000 60%, transparent);
}
.reply-text.full { max-height: none; -webkit-mask-image: none; mask-image: none; }
.reply textarea { background: var(--surface); min-height: 160px; }
.problems { display: flex; gap: 8px; align-items: flex-start; color: var(--warn); font-size: 13.5px; font-weight: 500; background: var(--warn-soft); padding: 8px 10px; border-radius: 9px; }
.problems .ic { width: 16px; height: 16px; margin-top: 2px; }
.replied { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--ok); font-weight: 500; font-size: 14px; background: var(--ok-soft); padding: 8px 12px; border-radius: 10px; }
.replied > span { flex: 1; }
.replied .btn { color: var(--ok); margin: -4px -6px; }
.lead-foot { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding-top: 12px; border-top: 1px solid var(--border); }
.status-select { font-weight: 600; border-color: transparent; }
.status-select option { background: var(--surface); color: var(--text); }
.comments-toggle { margin-left: auto; }
.comments-toggle.active { background: var(--surface-2); color: var(--text); }
.comments-box { display: grid; gap: 12px; }
.comments { display: grid; gap: 10px; }
.comment { font-size: 14px; background: var(--surface-2); padding: 9px 12px; border-radius: 11px; }
.comment .who { font-weight: 600; }
.comment .when { color: var(--muted); font-size: 12px; margin-left: 8px; }
.comment p { margin-top: 2px; white-space: pre-wrap; overflow-wrap: anywhere; }
.comment-form { display: flex; gap: 8px; align-items: flex-end; }
.comment-form textarea { min-height: 42px; flex: 1; }

/* ---------- площадки ---------- */
.platforms { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.platform { padding: 18px; display: grid; gap: 12px; align-content: start; }
.platform.st-bad { border-color: color-mix(in srgb, var(--bad) 40%, var(--border)); }
.platform.st-warn { border-color: color-mix(in srgb, var(--warn) 35%, var(--border)); }
.platform-head { display: flex; align-items: center; gap: 10px; }
.platform-head .dot { margin-top: 0; }
.platform-head h3 { flex: 1; }
.pl-note { font-size: 14.5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.todo-box { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; background: var(--warn-soft); color: var(--text); padding: 10px 12px; border-radius: 10px; }
.todo-box .ic { color: var(--warn); width: 16px; height: 16px; margin-top: 2px; }
.platform-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.platform form { display: grid; gap: 10px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }

/* ---------- лента ---------- */
.feed-text { overflow-wrap: anywhere; }

/* ---------- шаблоны ---------- */
.new-tpl > summary { list-style: none; display: inline-flex; }
.new-tpl > summary::-webkit-details-marker { display: none; }
.tpl-row { align-items: flex-start; }
.tpl-text { margin: 6px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; font-size: 14px; color: var(--muted); max-height: 7.5em; overflow: hidden;
  -webkit-mask-image: linear-gradient(#000 60%, transparent); mask-image: linear-gradient(#000 60%, transparent); }
.tpl-grid { grid-template-columns: 2fr 1fr; }
.template-form { display: grid; gap: 12px; }
code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .88em; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }

/* ---------- команда ---------- */
.form-grid { display: grid; grid-template-columns: repeat(4, 1fr) auto; gap: 10px; align-items: end; margin-top: 12px; }
.team { display: grid; gap: 10px; }
.member { display: flex; align-items: center; gap: 12px; padding: 12px 16px; flex-wrap: wrap; }
.member.inactive { opacity: .55; }

/* ---------- диалоги и уведомления ---------- */
dialog {
  border: 1px solid var(--border); border-radius: 20px; background: var(--surface); color: var(--text);
  padding: 24px; width: min(440px, calc(100vw - 32px)); box-shadow: var(--shadow-lg);
}
dialog::backdrop { background: rgba(10, 10, 14, .5); backdrop-filter: blur(2px); }
dialog[open] { animation: pop .18s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
dialog form { display: grid; gap: 14px; }
dialog h2 { display: flex; align-items: center; gap: 8px; font-size: 18px; }
dialog h2 .ic { color: var(--brand); }
dialog p { line-height: 1.55; }
.steps { margin: 0; padding-left: 20px; display: grid; gap: 4px; }
.confirm-text { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 40vh; overflow: auto; background: var(--surface-2); padding: 12px; border-radius: 11px; font-size: 14px; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 11px 18px; border-radius: 12px; font-size: 14px; font-weight: 500;
  transition: opacity .2s, transform .2s; z-index: 100; max-width: calc(100vw - 32px); box-shadow: var(--shadow-lg);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* меню «Ещё» снизу */
dialog.sheet { margin: auto auto 0; width: 100%; max-width: 520px; border-radius: 22px 22px 0 0; padding: 10px 16px calc(16px + env(safe-area-inset-bottom)); border-bottom: none; }
dialog.sheet[open] { animation: up .22s ease-out; }
@keyframes up { from { transform: translateY(100%); } }
.sheet-body::before { content: ''; display: block; width: 40px; height: 4px; border-radius: 2px; background: var(--surface-3); margin: 0 auto 14px; }
.sheet-body .me { border-top: none; padding: 0 4px 12px; }
.menu { display: grid; gap: 2px; }
.menu-item { display: flex; align-items: center; gap: 14px; padding: 13px 12px; border-radius: 12px; border: none; background: none; cursor: pointer; font-size: 16px; font-weight: 500; text-align: left; }
.menu-item:hover, .menu-item.active { background: var(--surface-2); }
.menu-item .ic { color: var(--muted); width: 20px; height: 20px; }
.menu-item .count { margin-left: auto; }
.menu-item.danger { color: var(--bad); }
.menu-item.danger .ic { color: var(--bad); }

/* ---------- планшет и телефон ---------- */
@media (max-width: 1100px) {
  .cols { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 900px) {
  .sidebar { display: none; }
  .mtop {
    display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 20;
    padding: 10px 12px 10px 16px; padding-top: calc(10px + env(safe-area-inset-top));
    background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
  }
  .mtop img { width: 30px; height: 30px; }
  .mtop-title { flex: 1; font-family: var(--font-head); font-weight: 600; font-size: 17px; }
  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
  }
  .bn-item {
    display: grid; justify-items: center; gap: 2px; padding: 4px 0; border: none; background: none; cursor: pointer;
    color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 500;
  }
  .bn-ic { position: relative; display: grid; place-items: center; width: 52px; height: 30px; border-radius: 15px; transition: background .15s; }
  .bn-ic .ic { width: 21px; height: 21px; }
  .bn-item.active { color: var(--brand); }
  .bn-item.active .bn-ic { background: var(--brand-soft); }
  .dot-count { position: absolute; top: -2px; right: 6px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--brand); color: #fff; font-size: 10.5px; font-weight: 700; display: grid; place-items: center; border: 2px solid var(--surface); }
  main { margin-left: 0; padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); gap: 14px; }
  main > .page-head:first-child h1 { font-size: 20px; }
  main > .page-head:not(.greet) h1 { display: none; } /* название раздела уже в шапке */
  main > .page-head:not(.greet):not(:has(> :not(h1))) { display: none; }
  .toast { bottom: calc(84px + env(safe-area-inset-bottom)); }
}
@media (max-width: 640px) {
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 14px; }
  .stat .num { font-size: 26px; }
  .platforms { grid-template-columns: 1fr; }
  .form-grid, .tpl-grid { grid-template-columns: 1fr; }
  .panel { padding: 16px; }
  .lead { padding: 16px; }
  .lead-top .time { margin-left: 0; }
  .chips { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 0 16px 2px; scrollbar-width: none; }
  .chips::-webkit-scrollbar { display: none; }
  .toolbar .search { flex-basis: 100%; }
  .toolbar > select { flex: 1; }
  .reply .row > .btn { flex: 1 1 auto; }
  .reply .row > .btn.primary { flex-basis: 100%; min-height: 46px; font-size: 15px; }
  .wait-row { flex-wrap: wrap; }
  .row-actions { width: 100%; }
  .row-actions .btn { width: 100%; }
  .banner { flex-wrap: wrap; }
  .banner .btn { width: 100%; }
  input, select, textarea { font-size: 16px; } /* iOS не зумит поле при фокусе */
  select.inline { font-size: 14px; }
  .member .row { width: 100%; }
}
@media (hover: none) { .btn:hover, .chip:hover, .icon-btn:hover { background: inherit; } .btn.primary:hover { background: var(--brand); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }
