/* CRM — один шрифт (IBM Plex Sans) во всём интерфейсе, светлая тема, адаптив под телефон. */
@font-face { font-family: 'Plex'; font-weight: 400; font-display: swap; src: url(/fonts/ibm-plex-sans-cyrillic-400-normal.woff2) format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Plex'; font-weight: 500; font-display: swap; src: url(/fonts/ibm-plex-sans-cyrillic-500-normal.woff2) format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Plex'; font-weight: 600; font-display: swap; src: url(/fonts/ibm-plex-sans-cyrillic-600-normal.woff2) format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Plex'; font-weight: 400; font-display: swap; src: url(/fonts/ibm-plex-sans-latin-400-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+20BD, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Plex'; font-weight: 500; font-display: swap; src: url(/fonts/ibm-plex-sans-latin-500-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+20BD, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Plex'; font-weight: 600; font-display: swap; src: url(/fonts/ibm-plex-sans-latin-600-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+20BD, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  color-scheme: light;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --ink: #172033;
  --ink-2: #5a6478;
  --line: #e2e7ee;
  --line-2: #cfd6e0;
  --accent: #1d63d8;
  --accent-2: #174fae;
  --accent-soft: #e8f0fe;
  --yellow: #ffc21a;
  --yellow-soft: #fff6db;
  --good: #13652a; --good-soft: #e3f6e8;
  --warn: #7a5200; --warn-soft: #fff4d6;
  --bad: #b3261e; --bad-soft: #fde8e8;
  --violet: #4b33b5; --violet-soft: #efeaff;
  --s1: #257de0; --s2: #f47230; --s3: #00b894;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 30, 50, .06), 0 2px 8px rgba(20, 30, 50, .04);
  --tap: 44px;
  font-family: 'Plex', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-height: 100dvh; }
h1, h2, h3 { margin: 0; font-weight: 600; line-height: 1.25; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: .95rem; margin-bottom: .5rem; }
p { margin: .25rem 0 .75rem; }
a { color: var(--accent); }
code { font-family: inherit; background: var(--bg); padding: .1em .35em; border-radius: 6px; }
code.wrap { word-break: break-all; display: block; padding: .5rem .6rem; }
.muted { color: var(--ink-2); }
.small { font-size: .85rem; }
.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.good { color: var(--good); } .bad { color: var(--bad); } .warn { color: var(--warn); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- раскладка ---------- */
.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100dvh; }
.side { position: sticky; top: 0; height: 100dvh; overflow-y: auto; background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 14px 10px; gap: 10px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 8px; font-size: 1.1rem; }
.proj-select, .proj-name { margin: 0 4px; font-size: .88rem; }
.side .proj-select { padding-right: 4px; }
.side .proj-slot { display: grid; }
.proj-name { font-weight: 600; padding: 6px 8px; background: var(--accent-soft); border-radius: 8px; }
.nav-list { display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 6px 10px; border-radius: 9px; color: var(--ink); text-decoration: none; background: none; border: 0; font: inherit; cursor: pointer; text-align: left; width: 100%; }
.nav-item:hover { background: var(--bg); }
.nav-item[aria-current] { background: var(--accent-soft); color: var(--accent-2); font-weight: 600; }
.nav-ico { width: 22px; text-align: center; flex: none; }
.nav-txt { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 8px; }
.badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; font-size: .75rem; font-weight: 600; display: inline-grid; place-items: center; background: var(--line); color: var(--ink); }
.badge.new { background: var(--accent); color: #fff; }
.badge.bad { background: var(--bad); color: #fff; }
.badge.warn { background: var(--yellow); color: #3a2a00; }
.content { min-width: 0; display: flex; flex-direction: column; }
.main { padding: 22px 28px 60px; outline: none; max-width: 1500px; width: 100%; }
.topbar, .tabbar { display: none; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.wm { position: fixed; inset: 0; pointer-events: none; z-index: 5; background-repeat: repeat; }
.dlg .wm { position: absolute; z-index: 50; }
.dlg-head h1, .card, .card-meta, .feed-body, .need, .quote, .step-text, .info dd, .tbl td, .deal, .col-body b { overflow-wrap: anywhere; min-width: 0; }

/* ---------- элементы ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 7px 14px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); font: inherit; font-weight: 500; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.primary.danger, .btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.warn { background: var(--yellow-soft); border-color: var(--yellow); }
.btn.money { background: var(--good-soft); border-color: #9ad3a9; color: var(--good); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--bg); color: var(--ink); }
.btn.sm { min-height: 32px; padding: 4px 10px; font-size: .88rem; }
.btn.big { min-height: 48px; padding: 10px 22px; font-size: 1.02rem; }
.btn.contact { min-height: 44px; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 9px; border: 0; background: transparent; cursor: pointer; font-size: 1.05rem; color: var(--ink-2); text-decoration: none; }
.icon-btn:hover { background: var(--bg); color: var(--ink); }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-align: left; }
.link.danger { color: var(--bad); }
.link.cname { color: var(--ink); font-weight: 600; }
.link.cname:hover { color: var(--accent); }
.row-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; font-size: .8rem; font-weight: 500; white-space: nowrap; background: var(--bg); color: var(--ink-2); }
.chip.t-new { background: var(--accent-soft); color: var(--accent-2); }
.chip.t-open { background: #eef1f5; color: #384356; }
.chip.t-active { background: var(--good-soft); color: var(--good); }
.chip.t-risk { background: var(--warn-soft); color: var(--warn); }
.chip.t-winback { background: var(--violet-soft); color: var(--violet); }
.chip.t-churned, .chip.t-gone { background: #eeeff2; color: #555c69; }
.chip.t-lost { background: var(--bad-soft); color: var(--bad); }
.tag { display: inline-block; padding: 1px 7px; border-radius: 6px; font-size: .78rem; background: var(--bg); color: var(--ink-2); white-space: nowrap; }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.good { background: var(--good-soft); color: var(--good); }
.tag.ml, .tag + .tag { margin-left: 6px; }
.icon-btn:disabled { opacity: .3; cursor: default; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--line-2); }
.dot.on { background: #0aac23; }
.sla { font-size: .82rem; font-weight: 600; padding: 2px 8px; border-radius: 6px; background: var(--accent-soft); color: var(--accent-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.sla.soon { background: var(--yellow-soft); color: var(--warn); }
.sla.late { background: var(--bad); color: #fff; }
.due { font-size: .82rem; white-space: nowrap; color: var(--ink-2); }
.due.soon { color: var(--warn); font-weight: 500; }
.due.late { color: var(--bad); font-weight: 600; }
.due.none { color: var(--bad); }
.hint { color: var(--ink-2); font-size: .86rem; margin: 4px 0 8px; }
.hint.big { font-size: .95rem; margin-bottom: 14px; }
.empty { padding: 22px; text-align: center; color: var(--ink-2); background: var(--surface); border: 1px dashed var(--line-2); border-radius: var(--radius); }
.loading { padding: 30px; text-align: center; color: var(--ink-2); }
.notice { background: var(--bg); border-radius: 10px; padding: 10px 12px; margin: 10px 0; display: grid; gap: 6px; }
.notice.warn { background: var(--yellow-soft); }
.notice.bad { background: var(--bad-soft); }
.quote { border-left: 3px solid var(--line-2); padding: 2px 0 2px 10px; color: var(--ink); white-space: pre-wrap; overflow-wrap: anywhere; }
.secret { background: var(--bg); padding: 12px; border-radius: 10px; font-size: 1.05rem; display: grid; gap: 4px; margin: 8px 0; }
.copyrow { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.copyrow code { flex: 1; min-width: 200px; }

.block { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 16px; }
.block-title { margin-bottom: 10px; }
.subhead { font-weight: 600; font-size: .9rem; margin: 10px 0 6px; }
.subhead.bad { color: var(--bad); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 16px; }
.grid2 > .block { margin-bottom: 0; }
.grid2 { margin-bottom: 16px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 10px; margin-bottom: 16px; }
.kpis.small { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); margin-bottom: 10px; }
.kpi { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; border-top: 3px solid transparent; }
.kpis.small .kpi { box-shadow: none; background: var(--bg); }
.kpi-label { font-size: .8rem; color: var(--ink-2); }
.kpi-value { font-size: 1.35rem; font-weight: 600; margin-top: 2px; }
.kpis.small .kpi-value { font-size: 1.05rem; }
.kpi-sub { font-size: .78rem; color: var(--ink-2); margin-top: 2px; }
.kpi.tone-good { border-top-color: #0aac23; }
.kpi.tone-bad { border-top-color: var(--bad); }
.kpi.tone-warn { border-top-color: var(--yellow); }

.list { display: flex; flex-direction: column; gap: 1px; background: var(--line); border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.row { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 10px 12px; background: var(--surface); min-height: 52px; }
.row.late { background: #fff8f7; }
.row.warn { background: #fffcf2; }
.row.muted { opacity: .6; }
.row-main { min-width: 0; flex: 1; }
.row-sub { color: var(--ink-2); font-size: .86rem; overflow: hidden; text-overflow: ellipsis; }
.row-side { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.lead-row .row-sub { white-space: nowrap; }
.list .row { position: relative; }
.list .row .link.cname::after { content: ''; position: absolute; inset: 0; }
.list .row .row-side .btn, .list .row .row-side a { position: relative; z-index: 1; }

.tbl-wrap { overflow-x: auto; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); }
.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tbl th { text-align: left; font-weight: 500; color: var(--ink-2); font-size: .8rem; padding: 8px 10px; border-bottom: 1px solid var(--line); background: #fafbfc; white-space: nowrap; position: sticky; top: 0; }
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl.rows tbody tr { cursor: pointer; }
.tbl.rows tbody tr:hover td { background: #f7f9fc; }
.tbl.compact td { padding: 6px 8px; }
.tbl.wrap-head th { white-space: normal; vertical-align: bottom; }
.tbl.wrap-head td:first-child { white-space: nowrap; }
.tbl tr.alert td { background: #fff6f5; }
.tbl tr.muted td { color: var(--ink-2); }
.tbl tfoot td { font-weight: 600; background: #fafbfc; }

/* ---------- фильтры и формы ---------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line-2); border-radius: 9px; padding: 8px 10px; min-height: 38px; max-width: 100%; }
textarea { width: 100%; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: 2px solid var(--accent-soft); outline-offset: 0; }
input[type=checkbox] { min-height: 0; width: 18px; height: 18px; accent-color: var(--accent); vertical-align: middle; }
.search { flex: 1; min-width: 220px; }
.form { display: grid; gap: 12px; }
.panel { background: var(--surface); }
.field { display: grid; gap: 4px; min-width: 0; align-content: start; }
.dyn { display: grid; gap: 12px; }
.field label { font-size: .85rem; font-weight: 500; color: var(--ink-2); }
.field input:not([type=checkbox]), .field select { width: 100%; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; align-items: start; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px 12px; margin: 0; display: grid; gap: 10px; }
legend { font-weight: 600; padding: 0 6px; font-size: .9rem; }
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; min-height: 32px; }
.form-err { color: var(--bad); font-weight: 500; min-height: 0; }
.form-err:empty { display: none; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 4px; }
.presets { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.pill { border: 1px solid var(--line-2); background: var(--surface); border-radius: 999px; padding: 4px 10px; font: inherit; font-size: .82rem; cursor: pointer; min-height: 30px; }
.pill:hover { border-color: var(--accent); color: var(--accent); }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 10px; overflow: hidden; background: var(--surface); }
.seg.wrap { flex-wrap: wrap; margin-bottom: 12px; }
.seg button { border: 0; background: transparent; padding: 7px 12px; font: inherit; cursor: pointer; min-height: 36px; color: var(--ink-2); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed=true] { background: var(--accent-soft); color: var(--accent-2); font-weight: 600; }
.days { display: flex; gap: 6px; flex-wrap: wrap; }
.day { display: inline-flex; gap: 4px; align-items: center; padding: 4px 8px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
details.more summary, details.table-view summary { cursor: pointer; color: var(--accent); margin: 6px 0; }
fieldset.pm legend { font-weight: 600; }

/* ---------- воронка ---------- */
.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 10px; align-items: flex-start; scroll-snap-type: x proximity; scroll-padding-inline: 12px; }
.col { min-width: 0; flex: 0 0 272px; background: #eaeef3; border-radius: var(--radius); display: flex; flex-direction: column; max-height: calc(100dvh - 210px); scroll-snap-align: start; }
.col.drop { outline: 2px dashed var(--accent); background: var(--accent-soft); }
.col-head { padding: 10px 12px 6px; }
.col-head > div:first-child { display: flex; justify-content: space-between; gap: 8px; }
.count { background: var(--surface); border-radius: 8px; padding: 0 8px; font-size: .82rem; font-weight: 600; }
.col-body { overflow-y: auto; padding: 4px 8px 10px; display: flex; flex-direction: column; gap: 8px; }
.col-empty { color: var(--ink-2); font-size: .85rem; text-align: center; padding: 12px; }
.deal { background: var(--surface); border-radius: 10px; padding: 10px 11px; box-shadow: var(--shadow); cursor: pointer; display: grid; gap: 5px; border: 1px solid transparent; }
.deal:hover { border-color: var(--accent); }
.deal.dragging { opacity: .5; }
.deal-name { font-weight: 600; overflow-wrap: anywhere; }
.deal-foot { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.clip { display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: var(--ink-2); }
.board-foot { display: flex; gap: 16px; margin-top: 8px; flex-wrap: wrap; }

/* ---------- карточки команды ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr)); gap: 12px; margin-bottom: 16px; }
.ucard { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; display: grid; gap: 8px; }
.ucard.off { opacity: .6; }
.ucard-head { display: flex; justify-content: space-between; gap: 8px; }

/* ---------- диалоги (native dialog) ---------- */
dialog.dlg { border: 0; border-radius: 16px; padding: 0; width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 40px); box-shadow: 0 20px 60px rgba(10, 20, 40, .25); color: var(--ink); background: var(--surface); }
dialog.dlg.wide { width: min(860px, calc(100vw - 24px)); }
dialog.dlg[open] { display: flex; flex-direction: column; }
dialog:modal { overscroll-behavior: contain; }
dialog::backdrop { background: rgba(15, 23, 42, .45); overflow: hidden; overscroll-behavior: contain; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px 10px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.dlg-head h1 { font-size: 1.15rem; }
.dlg-head .icon-btn { flex: none; }
.dlg-body { overscroll-behavior: contain; }
.dlg-body { padding: 16px 20px 20px; overflow-y: auto; }
.more-sheet { padding: 10px !important; }

/* ---------- карточка клиента ---------- */
.card { display: grid; gap: 12px; }
.card-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: .88rem; }
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.step { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: #fafbfd; }
.step.late { border-color: #f1b4b0; background: #fff8f7; }
.step-title { font-size: .8rem; color: var(--ink-2); margin-bottom: 4px; }
.step-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.step-text { font-weight: 600; }
.contacts { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 10px 12px; background: var(--accent-soft); border-radius: 12px; }
.contacts-list { display: flex; gap: 14px; flex-wrap: wrap; flex: 1; align-items: center; }
.contacts .hint { width: 100%; margin: 0; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 16px; }
.card-grid > * { min-width: 0; }
.info { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; }
.info .item { display: contents; }
.info dt { color: var(--ink-2); font-size: .86rem; }
.info dd { margin: 0; word-break: break-word; }
.need p { white-space: pre-wrap; margin: 4px 0 0; overflow-wrap: anywhere; }
.timeline h3 { margin-top: 4px; }
.feed { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.feed li { display: grid; grid-template-columns: 26px 1fr; gap: 8px; }
.feed-ico { width: 26px; height: 26px; border-radius: 50%; background: var(--bg); display: grid; place-items: center; font-size: .8rem; }
.feed-body { display: grid; gap: 3px; font-size: .92rem; }
.feed-top .muted { font-size: .8rem; }
.a-payment .feed-ico { background: var(--good-soft); }
.a-stage .feed-ico { background: var(--accent-soft); }
.a-sla .feed-ico, .a-risk .feed-ico { background: var(--warn-soft); }

/* ---------- графики ---------- */
.hbars { display: grid; gap: 8px; }
.hbar { display: grid; grid-template-columns: minmax(120px, 38%) 1fr auto; gap: 10px; align-items: center; outline-offset: 2px; border-radius: 6px; }
.hbar-label { font-size: .86rem; overflow: hidden; text-overflow: ellipsis; }
.hbar-track { height: 14px; background: transparent; position: relative; }
.hbar-fill { height: 100%; background: var(--s1); border-radius: 0 4px 4px 0; min-width: 0; }
.hbar:hover .hbar-fill, .hbar:focus .hbar-fill { background: #1b64be; }
.hbar-val { font-variant-numeric: tabular-nums; font-size: .86rem; white-space: nowrap; }
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: #e7e7e7; stroke-width: 1; }
.chart .axis { stroke: #c2c2c2; stroke-width: 1; }
.chart .tick { fill: #666; font-size: 11px; font-family: inherit; }
.chart .bar-g:hover, .chart .bar-g:focus { opacity: .85; outline: none; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .85rem; color: var(--ink-2); margin-bottom: 6px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.tip { position: fixed; z-index: 100; background: #191919; color: #efefef; padding: 7px 10px; border-radius: 8px; font-size: .82rem; pointer-events: none; opacity: 0; transition: opacity .1s; max-width: 260px; }
.tip.on { opacity: 1; }

/* ---------- уведомления ---------- */
#toasts { position: fixed; z-index: 1000; inset: auto 16px 16px auto; margin: 0; padding: 0; border: 0; background: none; overflow: visible; color: inherit; display: grid; gap: 8px; max-width: min(420px, calc(100vw - 32px)); pointer-events: none; }
#toasts:empty { display: none; }
#toasts:popover-open { width: auto; height: auto; } /* у popover по умолчанию width: fit-content — на телефоне тосты сжимались к левому краю */
.toast { background: #172033; color: #fff; padding: 11px 14px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); transition: opacity .3s, transform .3s; }
.toast.k-ok { background: #13652a; }
.toast.k-err { background: var(--bad); }
.toast.k-warn { background: #fff4d6; color: #3a2a00; border: 1px solid var(--yellow); }
.toast.k-new { background: var(--accent); font-weight: 600; }
.toast.out { opacity: 0; transform: translateY(8px); }

/* ---------- вход ---------- */
.login { min-height: 100dvh; display: grid; place-items: start center; padding: 12vh 16px 24px; }
.login-form { width: min(400px, 100%); background: var(--surface); padding: 26px 24px; border-radius: 18px; box-shadow: var(--shadow); display: grid; gap: 14px; }
.login-form .btn { width: 100%; }

/* ---------- телефон ---------- */
@media (max-width: 820px), (pointer: coarse) and (max-height: 520px) {
  :root { font-size: 15px; }
  input, select, textarea { font-size: 16px; }
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .topbar { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--line); padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); }
  .topbar .proj-select { flex: 1; margin: 0; min-width: 0; font-size: 16px; min-height: 40px; }
  .topbar .icon-btn, .dlg-head .icon-btn { width: 44px; height: 44px; }
  .topbar > b { flex: 1; }
  .topbar .proj-slot { flex: 1; min-width: 0; display: flex; }
  .topbar .proj-slot > * { flex: 1; min-width: 0; }
  .main { padding: 14px 12px calc(84px + env(safe-area-inset-bottom)); }
  html { scroll-padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
  .tabbar .nav-item { flex-direction: column; gap: 2px; min-height: 58px; padding: 6px 2px; justify-content: center; font-size: .72rem; border-radius: 0; position: relative; text-align: center; }
  .tabbar .nav-ico { font-size: 1.15rem; width: auto; }
  .tabbar .nav-txt { flex: none; }
  .tabbar .badge { position: absolute; top: 4px; left: calc(50% + 6px); }
  .tabbar .nav-item.on { background: var(--accent-soft); color: var(--accent-2); font-weight: 600; }
  .page-head h1 { font-size: 1.25rem; }
  .kpis { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .kpi { padding: 10px 12px; }
  .kpi-value { font-size: 1.15rem; }
  .block { padding: 12px; border-radius: 12px; }
  .row { flex-direction: column; align-items: stretch; gap: 6px; }
  .row-side { justify-content: flex-start; }
  .lead-row .row-side .btn { flex: 1; min-height: var(--tap); }
  .btn { min-height: var(--tap); }
  .btn.sm { min-height: 40px; }
  .pill { min-height: 38px; padding: 6px 12px; font-size: .9rem; }
  .seg button { min-height: 40px; white-space: nowrap; }
  .list .row .link.cname { padding: 2px 0; }
  details > summary { padding: 8px 0; }
  .tbl .link { display: inline-block; padding: 8px 0; }
  .board { scroll-snap-type: x mandatory; margin: 0 -12px; padding: 0 12px 10px; }
  .col { flex-basis: min(86vw, 340px); max-height: none; }
  .filters > * { flex: 1 1 140px; }
  .search { flex-basis: 100%; }
  dialog.dlg, dialog.dlg.wide { width: 100vw; max-width: 100vw; max-height: 100dvh; height: 100dvh; margin: 0; border-radius: 0; }
  dialog.dlg.more-sheet { top: auto; bottom: 0; height: auto; max-height: 85dvh; margin: 0; overflow-y: auto; border-radius: 16px 16px 0 0; padding-bottom: max(10px, env(safe-area-inset-bottom)) !important; }
  .dlg-head { padding-top: max(12px, env(safe-area-inset-top)); }
  .dlg-body { padding: 14px 14px calc(20px + env(safe-area-inset-bottom)); }
  .card-actions .btn { flex: 1 1 calc(50% - 8px); }
  .card-actions .btn.big { flex-basis: 100%; }
  .info { grid-template-columns: 1fr; gap: 0; }
  .info dd { margin-bottom: 8px; }
  .tbl.rows thead { display: none; }
  .tbl.rows, .tbl.rows tbody, .tbl.rows tr, .tbl.rows td { display: block; }
  .tbl.rows tr { padding: 10px 12px; border-bottom: 1px solid var(--line); }
  .tbl.rows td { border: 0; padding: 2px 0; text-align: left; }
  .tbl.rows td .cname { font-weight: 600; }
  .tbl.rows td[data-label]::before { content: attr(data-label) ': '; color: var(--ink-2); font-size: .82rem; }
  #toasts { inset: auto 12px calc(70px + env(safe-area-inset-bottom)) 12px; max-width: none; }
  .hbars { gap: 12px; }
  .hbar { grid-template-columns: 1fr auto; row-gap: 3px; }
  .hbar-track { grid-column: 1 / -1; grid-row: 2; }
  .form-actions .btn { flex: 1; }
}
@media (pointer: coarse) {
  input, select, textarea, .proj-select { font-size: 16px; }
}
/* телефон в горизонтальной ориентации: компактные панели, верхняя уезжает при прокрутке */
@media (pointer: coarse) and (max-height: 520px) {
  .topbar { position: static; }
  .tabbar .nav-item { min-height: 46px; flex-direction: row; gap: 6px; font-size: .8rem; }
  .tabbar .badge { position: static; }
  .main { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  #toasts { bottom: calc(56px + env(safe-area-inset-bottom)); }
}
/* на сенсорных экранах :hover «залипает» после тапа */
@media (hover: none) {
  .deal:hover { border-color: transparent; }
  .btn:not(.primary):not(.danger):not(.money):not(.warn):not(.ghost):hover { border-color: var(--line-2); }
  .nav-item:hover:not([aria-current]):not(.on) { background: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media print { .side, .tabbar, .topbar { display: none; } .wm { display: block; } }
