/* TGPoster · стиль «Графит»
   Тёмная тема — основная. Светлая — те же места, другие значения.
   «Системная» следует настройке macOS. */

:root {
  --bg: #f4f5f0; --side: #ffffff; --panel: #ffffff; --panel-2: #f1f2ec; --panel-3: #e9ebe4;
  --ink: #15171a; --muted: #62665e; --faint: #8a8e86;
  --line: #e3e5de; --line-2: #d4d7ce;
  --lime: #c6f24e; --on-lime: #0d0e10; --link: #4a6800; --link-hover: #2f4400;
  --ok: #3f6b00; --ok-soft: #eaf5cf;
  --bad: #c7343a; --bad-soft: #fbe4e4; --bad-line: #f1c7c9;
  --warn: #8f5d00; --warn-soft: #fbf0d9;
  --skip: #9aa6b6;
  --heat0: #eceee7; --heat1: #d6eaa0; --heat2: #a6cc45; --heat3: #6f9420;
  --shadow: 0 1px 2px rgba(15,17,20,.05), 0 6px 20px rgba(15,17,20,.05);
  --r: 16px; --r-sm: 11px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d0e10; --side: #111215; --panel: #17191c; --panel-2: #1d2024; --panel-3: #23262b;
    --ink: #eef0ea; --muted: #8a8e86; --faint: #6c7068;
    --line: #22252a; --line-2: #2c2f35;
    --link: #c6f24e; --link-hover: #dcff7a;
    --ok: #c6f24e; --ok-soft: #26301a;
    --bad: #ff6b6b; --bad-soft: #3a1f21; --bad-line: #4a2729;
    --warn: #f5b83d; --warn-soft: #3a301a;
    --skip: #7c8aa0;
    --heat0: #1f2226; --heat1: #3d4a1f; --heat2: #7ea12f; --heat3: #c6f24e;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d0e10; --side: #111215; --panel: #17191c; --panel-2: #1d2024; --panel-3: #23262b;
  --ink: #eef0ea; --muted: #8a8e86; --faint: #6c7068;
  --line: #22252a; --line-2: #2c2f35;
  --link: #c6f24e; --link-hover: #dcff7a;
  --ok: #c6f24e; --ok-soft: #26301a;
  --bad: #ff6b6b; --bad-soft: #3a1f21; --bad-line: #4a2729;
  --warn: #f5b83d; --warn-soft: #3a301a;
  --skip: #7c8aa0;
  --heat0: #1f2226; --heat1: #3d4a1f; --heat2: #7ea12f; --heat3: #c6f24e;
  --shadow: none;
  color-scheme: dark;
}

/* --- основа --- */
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 14px/1.45 Manrope, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); }
h1, .display { font-family: Unbounded, Manrope, sans-serif; letter-spacing: -.03em; }
h1 { font-size: 26px; font-weight: 600; margin: 0 0 4px; }
h2 { font-size: 15px; margin: 0 0 12px; font-weight: 700; }
h3 { font-size: 13.5px; margin: 16px 0 8px; font-weight: 700; }
.sub { color: var(--muted); margin: 0 0 18px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
code { font-size: 12.5px; background: var(--panel-2); padding: 1px 5px; border-radius: 5px; }

/* --- каркас --- */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
nav.side { background: var(--side); border-right: 1px solid var(--line); padding: 20px 14px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 3px; }
main { padding: 24px 32px 60px; max-width: 1320px; width: 100%; }

.brand-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 0 2px 16px 6px; }
.brand { display: flex; align-items: center; gap: 9px; font-family: Unbounded, sans-serif; font-weight: 600;
  font-size: 14.5px; letter-spacing: -.02em; color: var(--ink); }
.brand:hover { color: var(--ink); }
.logo { width: 30px; height: 30px; border-radius: 9px; background: var(--lime); display: grid; place-items: center; flex-shrink: 0; }
.theme { display: inline-flex; gap: 2px; padding: 3px; border-radius: 99px; background: var(--panel-2); }
.theme button { width: 25px; height: 22px; border: 0; padding: 0; border-radius: 99px; background: transparent;
  color: var(--faint); font-size: 12px; font-weight: 700; cursor: pointer; }
.theme button:hover { color: var(--ink); }
.theme button.on { background: var(--panel-3); color: var(--ink); }

nav.side > a.nav { display: flex; align-items: center; justify-content: space-between; height: 38px; padding: 0 12px;
  border-radius: var(--r-sm); color: var(--muted); font-weight: 500; }
nav.side > a.nav:hover { background: var(--panel-2); color: var(--ink); }
nav.side > a.nav.on { background: var(--lime); color: var(--on-lime); font-weight: 700; }
.side-head { margin: 16px 0 6px; padding: 0 8px; font-size: 11px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--faint); }
.people { display: flex; flex-direction: column; gap: 2px; }
.person { display: flex; align-items: center; gap: 10px; padding: 5px 8px; border-radius: var(--r-sm); color: var(--ink); }
.person:hover { background: var(--panel-2); color: var(--ink); }
.person .who { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.person .who b { font-size: 13px; font-weight: 600; }
.person .who span { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ava { width: 32px; height: 32px; border-radius: 50%; padding: 2px; border: 2px solid var(--line-2); flex-shrink: 0; }
.ava i { display: grid; place-items: center; width: 100%; height: 100%; border-radius: 50%; font-style: normal;
  font-weight: 700; font-size: 12.5px; color: #fff; }
.ava.st-active { border-color: var(--lime); }
.ava.st-new, .ava.st-paused { border-color: var(--warn); }
.ava.st-flood, .ava.st-dead { border-color: var(--bad); }

.side .state { margin-top: auto; padding: 14px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 8px; }
.side .state .live { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; }
.side .state button { width: 100%; }
.side .state a { display: inline; padding: 0; }

.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--lime); flex-shrink: 0; animation: pulse 1.8s infinite; }
.pulse.red { background: var(--bad); animation-name: pulseRed; }
.pulse.off { background: var(--bad); animation: none; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(198,242,78,.55); } 70% { box-shadow: 0 0 0 9px rgba(198,242,78,0); } 100% { box-shadow: 0 0 0 0 rgba(198,242,78,0); } }
@keyframes pulseRed { 0% { box-shadow: 0 0 0 0 rgba(255,93,93,.55); } 70% { box-shadow: 0 0 0 9px rgba(255,93,93,0); } 100% { box-shadow: 0 0 0 0 rgba(255,93,93,0); } }
@media (prefers-reduced-motion: reduce) { .pulse { animation: none; } }

/* --- карточки и сетки --- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px;
  margin-bottom: 14px; box-shadow: var(--shadow); }
.grid { display: grid; gap: 14px; }
.grid > .card { margin-bottom: 0; }
.grid > * { min-width: 0; }
.grid + .card, .grid + .grid { margin-top: 14px; }
.g2 { grid-template-columns: 1fr 1fr; }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }
.g21 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
@media (max-width: 1050px) { .g2, .g3, .g4, .g21 { grid-template-columns: 1fr; } .shell { grid-template-columns: 1fr; } nav.side { position: static; height: auto; } }

.stat .n { font-family: Unbounded, sans-serif; font-size: 30px; font-weight: 600; letter-spacing: -.03em; line-height: 1.1; }
.stat .l { color: var(--muted); font-size: 12.5px; }

/* --- таблицы --- */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 700; color: var(--faint); font-size: 11.5px; text-transform: uppercase;
  letter-spacing: .05em; padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tr.dim td { opacity: .5; }

/* --- метки --- */
.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600;
  background: var(--panel-2); color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.acc { background: var(--lime); color: var(--on-lime); }

.flash { padding: 11px 14px; border-radius: 12px; margin-bottom: 16px; font-weight: 600; }
.flash.ok { background: var(--ok-soft); color: var(--ok); }
.flash.bad { background: var(--bad-soft); color: var(--bad); }
.note { padding: 10px 14px; border-radius: 12px; background: var(--warn-soft); color: var(--warn); margin: 8px 0; }
.problems a { display: flex; gap: 10px; align-items: center; padding: 9px 12px; margin-bottom: 6px; border-radius: 12px;
  background: var(--panel-2); color: var(--ink); font-size: 13.5px; }
.problems a:hover { background: var(--panel-3); color: var(--ink); }
.problems .pill { padding: 0; width: 8px; height: 8px; border-radius: 50%; font-size: 0; background: var(--warn); }
.problems .pill.bad { background: var(--bad); }

/* --- формы --- */
label { display: block; font-size: 12.5px; color: var(--muted); margin: 10px 0 4px; font-weight: 600; }
label.inline { display: inline-flex; align-items: center; gap: 6px; color: var(--ink); font-size: 14px; margin: 4px 14px 4px 0; font-weight: 500; }
input[type=text], input[type=number], input[type=time], input[type=date], input[type=password],
input[type=tel], input[type=search], select, textarea {
  width: 100%; padding: 8px 11px; border: 1px solid var(--line-2); border-radius: 10px;
  background: var(--panel-2); color: var(--ink); font: inherit; }
textarea { min-height: 170px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--lime); outline-offset: 1px; border-color: transparent; }
input[type=checkbox] { accent-color: var(--lime); width: 15px; height: 15px; }
.row { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 120px; }
.row > .shrink { flex: 0 0 auto; min-width: 0; }

button, .btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 15px;
  border-radius: 10px; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--ink);
  font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; white-space: nowrap; }
button:hover, .btn:hover { background: var(--panel-3); color: var(--ink); }
button.primary, .btn.primary { background: var(--lime); border-color: var(--lime); color: var(--on-lime); font-weight: 700; }
button.primary:hover, .btn.primary:hover { filter: brightness(1.06); background: var(--lime); color: var(--on-lime); }
button.danger { color: var(--bad); }
button.small, .btn.small { height: 28px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
button:disabled { opacity: .5; cursor: default; }
form.inline { display: inline; }

.tabs { display: inline-flex; gap: 4px; padding: 4px; flex-wrap: wrap; margin-bottom: 14px; border-radius: 12px;
  background: var(--panel); border: 1px solid var(--line); }
.tabs a { padding: 6px 13px; border-radius: 9px; color: var(--muted); font-size: 13px; font-weight: 600; }
.tabs a:hover { color: var(--ink); background: var(--panel-2); }
.tabs a.on { background: var(--lime); color: var(--on-lime); font-weight: 700; }

.pre { white-space: pre-wrap; background: var(--panel-2); border-radius: 10px; padding: 10px 12px; font-size: 13px; max-height: 260px; overflow: auto; }
.console { white-space: pre-wrap; background: #0a0b0c; color: #cfe8a8; border-radius: 12px; padding: 12px; font: 12.5px/1.5 ui-monospace, Menlo, monospace; height: 320px; overflow: auto; }
.bar { height: 8px; background: var(--panel-3); border-radius: 99px; overflow: hidden; }
.bar > div { height: 100%; background: var(--lime); border-radius: 99px; transition: width .4s; }
.variants .v { white-space: pre-wrap; border-left: 3px solid var(--lime); padding: 6px 10px; margin: 8px 0; background: var(--panel-2); border-radius: 0 8px 8px 0; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.thumbs label { margin: 0; color: var(--ink); }
.thumbs img { width: 90px; height: 90px; object-fit: cover; border-radius: 10px; display: block; border: 1px solid var(--line); }
dialog { border: 1px solid var(--line-2); border-radius: 18px; padding: 22px; background: var(--panel); color: var(--ink); width: min(440px, 92vw); }
dialog::backdrop { background: rgba(0,0,0,.5); backdrop-filter: blur(3px); }
.msg { margin-top: 10px; min-height: 20px; }
.sticky-actions { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0; border-top: 1px solid var(--line); margin-top: 8px; z-index: 3; }
details summary { cursor: pointer; }

/* --- статусы для графиков --- */
:root { --st-good: var(--lime); --st-bad: var(--bad); --st-warn: var(--skip); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.sw-ring { display: inline-block; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--link); }

/* --- счётчик ошибок --- */
.badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px;
  background: var(--bad); color: #fff; font-size: 11.5px; font-weight: 700; }
nav.side > a.nav.on .badge { background: var(--on-lime); color: var(--lime); }

/* ===================== главная ===================== */
.page-head { display: flex; align-items: flex-end; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head .grow { flex-grow: 1; }
.page-head .date { font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.page-head .tabs { margin: 0; }
.cmdk-btn { width: 290px; justify-content: flex-start; color: var(--muted); font-weight: 500; background: var(--panel); border-color: var(--line); }
.cmdk-btn span.grow { flex-grow: 1; text-align: left; }
kbd { padding: 2px 6px; border-radius: 6px; background: var(--panel-3); color: var(--muted); font: 700 11.5px Manrope, sans-serif; }

.tile { border-radius: var(--r); padding: 15px 18px; background: var(--panel); border: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 4px; min-height: 124px; box-shadow: var(--shadow); color: var(--ink); }
a.tile:hover { border-color: var(--line-2); color: var(--ink); }
.tile .top { display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.tile .mid { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; }
.tile .n { font-family: Unbounded, sans-serif; font-size: 32px; font-weight: 600; letter-spacing: -.03em; line-height: 1; }
.tile .foot { font-size: 12.5px; color: var(--muted); margin-top: auto; }
.tile .chip { padding: 1px 8px; border-radius: 99px; font-size: 11.5px; font-weight: 700; background: var(--panel-2); color: var(--muted); }
.tile .chip.up { color: var(--ok); background: var(--ok-soft); }
.tile .chip.down { color: var(--bad); background: var(--bad-soft); }
.tile.hero { background: var(--lime); border-color: var(--lime); color: var(--on-lime); }
.tile.hero .top, .tile.hero .foot { color: var(--on-lime); opacity: .75; }
.tile.hero .chip { background: rgba(13,14,16,.12); color: var(--on-lime); }
.tile.alert { border-color: var(--bad-line); }
.tile svg.spark { width: 110px; height: 36px; overflow: visible; }
.ring { width: 72px; height: 72px; flex-shrink: 0; border-radius: 50%; display: grid; place-items: center; }
.ring > div { width: 56px; height: 56px; border-radius: 50%; background: var(--panel); display: grid; place-items: center;
  font-family: Unbounded, sans-serif; font-size: 15px; font-weight: 600; }

.tl { position: relative; height: 78px; margin: 4px 10px 0; }
.tl .track { position: absolute; left: 0; right: 0; top: 32px; height: 12px; border-radius: 99px; background: var(--panel-2); }
.tl .win { position: absolute; top: 32px; height: 12px; border-radius: 99px; background: var(--ok-soft); }
.tl .ev { position: absolute; top: 29px; width: 18px; height: 18px; margin-left: -9px; border-radius: 50%; border: 3px solid var(--panel); cursor: default; }
.tl .ev.sent { background: var(--lime); }
.tl .ev.fail { background: var(--bad); }
.tl .ev.skip { background: var(--skip); }
.tl .ev.plan { background: var(--panel); border: 2px solid var(--link); }
.tl .ev:hover { transform: scale(1.25); z-index: 2; }
.tl .now { position: absolute; top: 16px; bottom: 18px; width: 2px; margin-left: -1px; background: var(--ink); border-radius: 2px; }
.tl .now span { position: absolute; top: -16px; left: 50%; transform: translateX(-50%); padding: 1px 7px; border-radius: 6px;
  background: var(--ink); color: var(--bg); font-size: 11px; font-weight: 700; white-space: nowrap; }
.tl .tick { position: absolute; bottom: 0; transform: translateX(-50%); font-size: 11px; color: var(--faint); }
.tl .tick:first-child { transform: none; }

.next { background: linear-gradient(160deg, var(--ok-soft), var(--panel) 62%); border-color: var(--line-2); display: flex; flex-direction: column; gap: 8px; }
.next .when { font-family: Unbounded, sans-serif; font-size: 27px; font-weight: 600; letter-spacing: -.03em; color: var(--link); line-height: 1.15; }
.next .actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; }
.next .actions form { flex: 1 1 auto; min-width: 0; }
.next .actions form:first-child { flex-grow: 3; }
.next .actions button, .next .actions .btn { width: 100%; white-space: nowrap; }

.heat { display: flex; flex-direction: column; gap: 8px; }
.heat .hr { display: flex; align-items: center; gap: 12px; }
.heat .hn { width: 78px; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink); }
.heat .cells { flex-grow: 1; display: grid; grid-template-columns: repeat(14, minmax(0, 1fr)); gap: 5px; }
.heat .cells i { height: 22px; border-radius: 5px; background: var(--heat0); }
.heat .cells i.l1 { background: var(--heat1); } .heat .cells i.l2 { background: var(--heat2); } .heat .cells i.l3 { background: var(--heat3); }
.heat .ht { width: 34px; text-align: right; font-family: Unbounded, sans-serif; font-size: 13px; font-weight: 600; }
.heat-legend { display: flex; align-items: center; gap: 4px; font-size: 11.5px; color: var(--faint); }
.heat-legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

.feed { display: flex; flex-direction: column; gap: 11px; }
.feed .it { display: flex; gap: 10px; font-size: 13px; }
.feed .it > i { width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; flex-shrink: 0; background: var(--skip); }
.feed .it > i.sent { background: var(--lime); } .feed .it > i.fail { background: var(--bad); } .feed .it > i.test { background: var(--faint); }
.feed .it div { display: flex; flex-direction: column; min-width: 0; }
.feed .it div span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed .it div span:last-child { font-size: 11.5px; color: var(--faint); }
.feed .it.fresh { animation: fresh 1.2s ease-out; }
@keyframes fresh { from { background: var(--ok-soft); } to { background: transparent; } }
.livetag { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 800; color: var(--link); letter-spacing: .04em; }

/* --- график по дням (журнал / сводка) --- */
.chart-wrap { position: relative; margin-top: 10px; }
svg.chart { width: 100%; height: auto; display: block; overflow: visible; }
svg.chart .grid-line { stroke: var(--line); stroke-width: 1; }
svg.chart .axis-line { stroke: var(--line-2); stroke-width: 1; }
svg.chart .tick { fill: var(--faint); font-size: 11px; }
svg.chart .st-good { fill: var(--lime); } svg.chart .st-bad { fill: var(--bad); } svg.chart .st-warn { fill: var(--skip); }
svg.chart .hit { fill: transparent; } svg.chart .hit.on { fill: var(--ink); fill-opacity: .05; }
.tip { position: absolute; pointer-events: none; background: var(--panel); border: 1px solid var(--line-2); border-radius: 10px;
  padding: 7px 10px; font-size: 12.5px; line-height: 1.5; box-shadow: 0 8px 24px rgba(0,0,0,.25); min-width: 120px; z-index: 5; }

/* --- уведомления --- */
#toasts { position: fixed; right: 22px; bottom: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 50; }
.toast { width: 340px; padding: 12px 14px; border-radius: 14px; background: var(--panel); border: 1px solid var(--bad-line);
  box-shadow: 0 14px 36px rgba(0,0,0,.35); display: flex; gap: 12px; align-items: flex-start; animation: toastIn .35s ease-out; }
.toast .ico { width: 28px; height: 28px; flex-shrink: 0; border-radius: 8px; background: var(--bad-soft); color: var(--bad);
  display: grid; place-items: center; font-weight: 800; }
.toast .txt { flex-grow: 1; display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: var(--ink); }
.toast .txt span { color: var(--muted); }
.toast button { height: 24px; width: 24px; padding: 0; border: 0; background: transparent; color: var(--faint); font-size: 17px; }
@keyframes toastIn { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }

/* --- ⌘K --- */
#cmdk { width: min(560px, 92vw); padding: 0; overflow: hidden; margin-top: 12vh; }
#cmdk input { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 16px 18px; font-size: 16px; background: var(--panel); }
#cmdk input:focus { outline: none; }
#cmdk ul { list-style: none; margin: 0; padding: 6px; max-height: 50vh; overflow-y: auto; }
#cmdk li a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; color: var(--ink); }
#cmdk li a .k { font-size: 11px; font-weight: 700; color: var(--faint); text-transform: uppercase; letter-spacing: .05em; width: 64px; }
#cmdk li a.sel, #cmdk li a:hover { background: var(--panel-2); }
#cmdk .empty { padding: 14px 18px; color: var(--muted); font-size: 13px; }
#cmdk .hint { padding: 8px 14px; border-top: 1px solid var(--line); font-size: 11.5px; color: var(--faint); }

/* --- роли --- */
.role-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.role-bar a.sort-on { color: var(--ink); font-weight: 700; }
.role-stats { margin-bottom: 14px; }
.pill.role { background: var(--panel-3); color: var(--ink); }
a.pill.role:hover { background: var(--lime); color: var(--on-lime); }
.pick-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.pick { display: flex; align-items: center; gap: 10px; margin: 0; padding: 9px 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--ink); cursor: pointer; font-size: 13.5px; }
.pick:has(input:checked) { border-color: var(--lime); background: var(--ok-soft); }
.pick > span { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.pick[hidden] { display: none; }
.side-role summary { list-style: none; display: flex; justify-content: space-between; align-items: center; padding: 6px 8px;
  border-radius: 9px; font-size: 12.5px; font-weight: 700; color: var(--muted); cursor: pointer; }
.side-role summary::-webkit-details-marker { display: none; }
.side-role summary:hover { background: var(--panel-2); color: var(--ink); }
.side-role summary .cnt { font-weight: 600; color: var(--faint); }
.side-role summary::before { content: "▸"; margin-right: 6px; color: var(--faint); }
.side-role[open] summary::before { content: "▾"; }
.side-role summary .nm { flex-grow: 1; }

/* --- лиды --- */
.leads { display: grid; grid-template-columns: 360px 1fr; gap: 14px; align-items: start; }
@media (max-width: 1050px) { .leads { grid-template-columns: 1fr; } }
.lead-list { padding: 6px; margin: 0; max-height: calc(100vh - 210px); overflow-y: auto; }
.lead-item { display: flex; gap: 10px; padding: 10px; border-radius: 12px; color: var(--ink); }
.lead-item:hover { background: var(--panel-2); color: var(--ink); }
.lead-item.on { background: var(--ok-soft); }
.lead-item .ava { border-color: transparent; }
.li-body { display: flex; flex-direction: column; min-width: 0; flex-grow: 1; gap: 1px; }
.li-top { display: flex; justify-content: space-between; gap: 8px; font-size: 13.5px; }
.li-top b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li-time { font-size: 11px; color: var(--faint); white-space: nowrap; }
.li-text { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li-meta { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--faint); }
.li-meta .badge { margin-left: auto; }
.small-pill { padding: 0 7px; font-size: 11px; }
.chat { margin: 0; display: flex; flex-direction: column; height: calc(100vh - 210px); min-height: 460px; }
.chat-head { display: flex; gap: 12px; align-items: flex-start; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.chat-head .grow { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.chat-body { flex-grow: 1; overflow-y: auto; padding: 14px 4px; display: flex; flex-direction: column; gap: 6px; }
.chat-day { align-self: center; font-size: 11.5px; color: var(--faint); background: var(--panel-2); padding: 2px 10px; border-radius: 99px; margin: 8px 0 4px; }
.bubble { max-width: 72%; padding: 8px 12px 6px; border-radius: 16px; font-size: 14px; line-height: 1.4; }
.bubble .bt { white-space: pre-wrap; word-wrap: break-word; }
.bubble .bm { font-size: 10.5px; opacity: .6; text-align: right; margin-top: 2px; }
.bubble.in { align-self: flex-start; background: var(--panel-2); border-bottom-left-radius: 5px; }
.bubble.out { align-self: flex-end; background: var(--lime); color: var(--on-lime); border-bottom-right-radius: 5px; }
.bubble.fresh { animation: toastIn .3s ease-out; }
.composer { display: flex; gap: 8px; align-items: flex-end; padding-top: 10px; border-top: 1px solid var(--line); }
.composer textarea { min-height: 42px; max-height: 180px; resize: none; font-family: inherit; font-size: 14px; }
.composer button { height: 42px; }
.chat-empty { margin: auto; text-align: center; max-width: 420px; }
.badge.lead { background: var(--lime); color: var(--on-lime); }
nav.side > a.nav.on .badge.lead { background: var(--on-lime); color: var(--lime); }
.toast.lead { border-color: var(--line-2); }
.toast.lead .ico { background: var(--lime); color: var(--on-lime); }
[hidden] { display: none !important; }

/* сегодня по часам */
.hb-sum { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 4px; }
.hb-sum .chip { padding: 4px 11px; border-radius: 99px; background: var(--panel-2); color: var(--muted); font-size: 12.5px; font-weight: 700; text-decoration: none; }
.hb-sum .chip.ok { background: var(--ok-soft); color: var(--ok); }
.hb-sum .chip.bad { background: var(--bad-soft); color: var(--bad); }
.hb { display: flex; gap: 6px; height: 190px; margin-top: 10px; }
.hb-col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 6px 2px 4px; border-radius: 10px; cursor: default; }
.hb-col:hover { background: var(--panel-2); }
.hb-col.now { background: color-mix(in srgb, var(--lime) 10%, transparent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--lime) 45%, transparent); }
.hb-col b { font-family: Unbounded, sans-serif; font-size: 12.5px; font-weight: 600; min-height: 16px; color: var(--muted); }
.hb-col.now b, .hb-col.now span { color: var(--ink); font-weight: 800; }
.hb-bar { flex: 1; width: 100%; max-width: 40px; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; border-bottom: 1px solid var(--line); }
.hb-bar i { display: block; min-height: 4px; border-radius: 4px; }
.hb-bar i.sent { background: var(--lime); }
.hb-bar i.fail { background: var(--bad); }
.hb-bar i.skip { background: var(--skip); }
.hb-bar i.plan { border: 2px dashed var(--link); box-sizing: border-box; opacity: .75; }
.hb-col span { font-size: 11px; color: var(--faint); }
.sw-dash { display: inline-block; width: 10px; height: 10px; border: 2px dashed var(--link); border-radius: 3px; box-sizing: border-box; }
@media (max-width: 700px) { .hb { gap: 2px; } .hb-col b { font-size: 10.5px; } }
.hb-col.off .hb-bar { background: repeating-linear-gradient(135deg, transparent 0 6px, var(--panel-2) 6px 12px); border-radius: 6px 6px 0 0; }
/* LIVE в живой ленте — розовый */
.livetag { color: #d6247a; }
:root[data-theme="dark"] .livetag { color: #ff4fa3; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .livetag { color: #ff4fa3; } }
.livetag .pulse { background: #ff4fa3; animation-name: pulsePink; }
@keyframes pulsePink { 0% { box-shadow: 0 0 0 0 rgba(255,79,163,.55); } 70% { box-shadow: 0 0 0 9px rgba(255,79,163,0); } 100% { box-shadow: 0 0 0 0 rgba(255,79,163,0); } }

/* вход */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; box-sizing: border-box; background: var(--bg); }
.login-card { width: 100%; max-width: 360px; padding: 28px; border-radius: var(--r); background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 14px; }
.login-card h1 { margin: 0; font-size: 22px; }
.login-card input { width: 100%; box-sizing: border-box; }
/* удаление диалога */
.lead-del { position: relative; }
.lead-del > summary { list-style: none; cursor: pointer; color: var(--bad); }
.lead-del > summary::-webkit-details-marker { display: none; }
.lead-del-pop { position: absolute; right: 0; top: 34px; z-index: 5; width: 260px; padding: 12px; border-radius: 12px;
  background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 8px; }
.lead-del-pop label { display: flex; align-items: center; gap: 6px; }

/* ================================================================ ТЕЛЕФОН */
.mbar, .tabbar, .nav-backdrop, .m-only { display: none; }

@media (max-width: 760px) {
  html { -webkit-text-size-adjust: 100%; }
  body { overflow-x: hidden; }
  .shell { display: block; }
  main { padding: 14px 16px calc(84px + env(safe-area-inset-bottom)); }
  .m-hide { display: none !important; }
  .m-only { display: block; }

  /* верхняя панель */
  .mbar { display: flex; align-items: center; gap: 6px; position: sticky; top: 0; z-index: 30;
    padding: calc(6px + env(safe-area-inset-top)) 8px 6px; background: var(--side); border-bottom: 1px solid var(--line); }
  .mbar-btn { width: 42px; height: 42px; padding: 0; border: 0; background: transparent; color: var(--ink); border-radius: 12px; }
  .mbar-btn:active { background: var(--panel-2); }
  .mbar-title { flex-grow: 1; display: flex; align-items: center; justify-content: center; gap: 8px;
    font-family: Unbounded, sans-serif; font-weight: 600; font-size: 16px; color: var(--ink); letter-spacing: -.02em; }

  /* боковое меню выезжает слева */
  nav.side { position: fixed; top: 0; left: 0; bottom: 0; z-index: 60; width: min(300px, 86vw); height: 100%;
    padding-top: calc(16px + env(safe-area-inset-top)); padding-bottom: calc(16px + env(safe-area-inset-bottom));
    transform: translateX(-105%); transition: transform .22s ease; box-shadow: var(--shadow); }
  body.nav-open nav.side { transform: none; }
  .nav-backdrop { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(0,0,0,.45);
    opacity: 0; pointer-events: none; transition: opacity .2s; }
  body.nav-open .nav-backdrop { opacity: 1; pointer-events: auto; }
  body.nav-open { overflow: hidden; }
  nav.side a.nav { padding: 11px 12px; font-size: 15px; }

  /* нижнее меню */
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); background: var(--side); border-top: 1px solid var(--line); }
  .tabbar a, .tabbar button { display: flex; flex-direction: column; align-items: center; gap: 2px; height: auto; padding: 6px 0 4px;
    border: 0; background: transparent; color: var(--faint); font-size: 10.5px; font-weight: 700; border-radius: 12px; }
  .tabbar a.on, .tabbar button.on { color: var(--ink); }
  .tabbar a.on .ti { background: var(--lime); color: var(--on-lime); }
  .tabbar .ti { position: relative; display: grid; place-items: center; width: 48px; height: 30px; border-radius: 99px; }
  .tabbar .badge { position: absolute; top: -3px; right: 2px; min-width: 17px; height: 17px; padding: 0 4px; font-size: 10.5px; line-height: 17px; }

  /* типографика и отступы */
  h1 { font-size: 22px; }
  .page-head { align-items: stretch; gap: 10px; }
  .page-head > * { width: 100%; }
  .page-head .shrink, .page-head form.shrink { width: auto; }
  .card { padding: 14px; border-radius: 16px; }
  .grid { gap: 10px; }
  .grid + .card, .grid + .grid { margin-top: 10px; }
  .row > * { min-width: 0; flex-basis: 100%; }
  .row > .shrink { flex-basis: auto; }

  /* поля: 16px, чтобы iPhone не увеличивал страницу при вводе */
  input[type=text], input[type=number], input[type=time], input[type=date], input[type=password],
  input[type=tel], input[type=search], select, textarea { font-size: 16px; }
  button, .btn { min-height: 40px; }
  button.small, .btn.small { min-height: 34px; height: auto; }

  /* вкладки листаются пальцем */
  .tabs { display: flex; flex-wrap: nowrap; overflow-x: auto; max-width: 100%; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs a { white-space: nowrap; flex-shrink: 0; padding: 8px 13px; }

  /* поиск на главной — в верхней панели */
  .cmdk-btn { display: none; }
  #cmdk { margin-top: calc(8px + env(safe-area-inset-top)); width: calc(100vw - 16px); max-width: none; }
  #cmdk .hint { display: none; }

  /* таблицы → карточки */
  table.stack, table.stack tbody { display: block; width: 100%; }
  table.stack tr.th-row, table.stack thead { display: none; }
  table.stack tr { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
  table.stack tr:last-child { border-bottom: 0; }
  table.stack td { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 12px; width: 100%;
    padding: 2px 0; border: 0; text-align: right; font-size: 13.5px; }
  table.stack td::before { content: attr(data-label); flex-shrink: 0; margin-right: auto; color: var(--faint); font-size: 12px; font-weight: 600; text-align: left; }
  table.stack td[data-label=""]::before { display: none; }
  table.stack td[data-label=""] { justify-content: flex-start; width: auto; }
  table.stack td.t-title { order: -1; width: auto; flex: 1 1 0; min-width: 0; justify-content: flex-start; text-align: left;
    font-size: 15px; font-weight: 700; }
  table.stack td.t-title::before { display: none; }
  table.stack td.t-empty { display: none; }
  table.stack td.t-long { flex-direction: column; align-items: flex-start; text-align: left; gap: 1px; }
  table.stack td form.inline, table.stack td .btn, table.stack td button { margin: 2px 0; }
  table.stack tr.wide td { display: block; width: 100%; text-align: left; }
  table.stack tr.wide td::before { display: none; }

  /* главная */
  .tile .n { font-size: 28px; }
  .hb { height: 150px; }
  .hb-col b { font-size: 10px; }
  .hb-col span { font-size: 10px; }
  .heat .hn { width: 58px; font-size: 12px; }
  .heat .cells { gap: 2px !important; }
  .heat .cells i { height: 16px; border-radius: 3px; }
  .heat .ht { width: 24px; font-size: 11px; }
  .next .when { font-size: 24px; }

  /* лиды: список и чат — отдельными экранами */
  .leads { display: block; }
  .leads.has-lead .lead-list { display: none; }
  .leads:not(.has-lead) .chat { display: none; }
  .lead-list { max-height: none; }
  .chat { height: calc(100dvh - 150px - env(safe-area-inset-bottom) - env(safe-area-inset-top)); min-height: 380px; padding: 12px; }
  .chat-back { font-weight: 700; margin: 0 0 8px; }
  .chat-head { flex-wrap: wrap; gap: 8px; }
  .chat-head .grow { flex-basis: 100%; }
  .composer textarea { font-size: 16px; }
  .lead-del-pop { right: auto; left: 0; width: min(280px, 80vw); }

  .role-stats { display: none; }
  .sticky-actions { bottom: calc(60px + env(safe-area-inset-bottom)); gap: 8px; }
  .sticky-actions > * { flex: 1 1 auto; }

  /* уведомления над нижним меню */
  #toasts { left: 10px; right: 10px; bottom: calc(76px + env(safe-area-inset-bottom)); }
  .toast { width: auto; }
}

.hb-col { cursor: pointer; }
.hb-col.sel { background: var(--panel-2); }
.hb-detail { margin-top: 10px; padding: 10px 12px; border-radius: 12px; background: var(--panel-2); font-size: 13px; white-space: pre-line; }
.hb-detail b { display: block; margin-bottom: 4px; }
