:root {
  --bg: #0E1018; --surface: #171A26; --surface2: #1E2232; --line: #2A2F42; --text: #ECEAF4; --muted: #8E91A8;
  --gold: #E6BE73; --violet: #9C8CFF; --green: #5FD39A; --red: #FF7A85; --amber: #F2B65A; --blue: #6FB6FF;
  --first: #9C8CFF; --repeat: #E6BE73; --radius: 18px; --shadow: 0 6px 24px rgba(0,0,0,.25);
}
:root[data-theme="light"] {
  --bg: #F4F2EC; --surface: #FFFFFF; --surface2: #F0EDE5; --line: #E3DED2; --text: #1C1A24; --muted: #7A7586;
  --gold: #B88A2E; --violet: #6E5BE8; --green: #1F9D63; --red: #D9475A; --amber: #C5861E; --blue: #2E7BD6;
  --first: #6E5BE8; --repeat: #B88A2E; --shadow: 0 4px 18px rgba(40,30,10,.08);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
body { font: 15px/1.4 "Onest", system-ui, -apple-system, Segoe UI, Roboto, sans-serif; min-height: 100vh; overflow-x: hidden; }
h1, h2, h3, .display { font-family: "Unbounded", "Onest", sans-serif; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 16px; margin: 22px 0 10px; }
h3 { font-size: 14px; margin: 0 0 6px; }
a { color: var(--violet); text-decoration: none; }
button { font: inherit; color: inherit; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface2); border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; width: 100%; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--violet); }
textarea { min-height: 110px; resize: vertical; }
label { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 5px; }
input[type=checkbox] { width: auto; }

#app { max-width: 720px; margin: 0 auto; padding: 14px 16px calc(170px + env(safe-area-inset-bottom, 0px)); }  /* низ не прячется под меню и «Спросить ИИ» */
.top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 4px 0 14px; }
.top .sub { color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.right { text-align: right; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden, [hidden] { display: none !important; }
/* задачи: доска и календарь */
.tcard { cursor: pointer; }
.board { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; }
.bcol { flex: 0 0 74%; max-width: 300px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; }
.bhead { font-weight: 700; padding: 4px 6px 8px; }
.bcol .item { background: var(--surface2); border-radius: 12px; margin-bottom: 4px; }
.bcol { transition: background .2s, border-color .2s; min-height: 160px; }
.bcol.dropover { border-color: var(--violet); background: color-mix(in srgb, var(--violet) 10%, var(--surface)); }
.bempty { padding: 14px 8px; text-align: center; border: 1px dashed var(--line); border-radius: 12px; }
.tcard.dragging, .sortable-fallback { box-shadow: 0 12px 30px rgba(0,0,0,.45); border-radius: 12px; background: var(--surface2); opacity: .95 !important; transform: rotate(2deg); }
.drag-ghost { opacity: .35; border: 1px dashed var(--violet) !important; }
.drag-chosen { background: color-mix(in srgb, var(--violet) 14%, var(--surface2)) !important; }
.board .tcard { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.chips.wrap { flex-wrap: wrap; overflow: visible; margin-bottom: 6px; }
.when .wdate, .when .wtimein { margin-top: 6px; }
.whobox div { margin: 2px 0; }
.fpick { display: flex; flex-direction: column; gap: 6px; }
.fpitem { display: flex; justify-content: space-between; align-items: center; background: var(--surface2); border-radius: 10px; padding: 8px 10px; font-size: 13px; }
.fpitem .x { cursor: pointer; color: var(--muted); padding: 0 4px; }
.ppl .pplq { margin-bottom: 6px; }
.chip.sm { padding: 3px 8px; font-size: 12px; }
.vtabs { display: flex; gap: 8px; margin-bottom: 10px; }
.vtab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 6px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--surface); color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; transition: background .2s, color .2s, border-color .2s; }
.vtab b { font-size: 20px; color: var(--text); line-height: 1.1; }
.vtab.on { background: color-mix(in srgb, var(--violet) 20%, var(--surface)); border-color: var(--violet); color: var(--text); }
.stages { display: flex; align-items: center; gap: 2px; margin-top: 8px; }
.stg { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; border: 1px solid var(--line); background: var(--surface2); color: var(--muted);
  border-radius: 12px; padding: 8px 2px; font: inherit; font-size: 12px; cursor: pointer; transition: background .2s, color .2s, border-color .2s; }
.stg span { font-size: 18px; }
.stg.on { background: color-mix(in srgb, var(--violet) 22%, var(--surface2)); border-color: var(--violet); color: var(--text); font-weight: 700; }
.stg:disabled { cursor: default; opacity: .7; }
.stg-arrow { color: var(--muted); }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 8px; }
.cwd { text-align: center; font-size: 11px; color: var(--muted); }
.cday { min-height: 48px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); padding: 4px; cursor: pointer; font-size: 12px; }
.cday.today { border-color: var(--violet); }
.cday i { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin: 2px 2px 0 0; }
/* ИИ-продавец */
.drop { text-align: center; border: 1.5px dashed color-mix(in srgb, var(--violet) 55%, var(--line)); border-radius: var(--radius); padding: 18px 14px; background: color-mix(in srgb, var(--violet) 6%, var(--surface)); }
.drop.tap { cursor: pointer; }
.aiacc + .aiacc { border-top: 1px solid var(--line); }
.aibody { padding: 4px 12px 12px; }
.kf .chips { margin-bottom: 0; }
.aitabs .chip { white-space: nowrap; }
/* календарь v2 */
.calbar { display: flex; align-items: center; gap: 8px; margin: 10px 0 6px; }
.caltitle { flex: 1; text-align: center; font-size: 16px; }
.caltitle::first-letter, .whead b::first-letter { text-transform: uppercase; }
.mgrid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
.mcell { min-height: 64px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); padding: 3px; cursor: pointer; overflow: hidden; transition: border-color .2s; }
.mcell.empty { background: none; border: 0; cursor: default; }
.mcell.past { opacity: .6; }
.mcell.today { border-color: var(--violet); box-shadow: 0 0 0 1px var(--violet) inset; }
.mnum { font-size: 12px; font-weight: 700; margin-bottom: 2px; }
.mcell.today .mnum { color: var(--violet); }
.mev { font-size: 10px; line-height: 1.25; padding: 1px 3px; margin-bottom: 2px; border-radius: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: color-mix(in srgb, var(--c) 22%, transparent); border-left: 2px solid var(--c); }
.mmore { font-size: 10px; color: var(--muted); }
.wlist { display: flex; flex-direction: column; gap: 6px; }
.wday { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 6px 8px; }
.wday.today { border-color: var(--violet); }
.whead { display: flex; justify-content: space-between; align-items: center; cursor: pointer; margin-bottom: 4px; }
.evp { font-size: 13px; padding: 6px 8px; margin: 3px 0; border-radius: 8px; cursor: pointer; background: color-mix(in srgb, var(--c) 16%, var(--surface2)); border-left: 3px solid var(--c); }
.dgrid { position: relative; border-left: 1px solid var(--line); margin-left: 44px; }
.dslot { position: absolute; left: 0; right: 0; height: 52px; border-top: 1px solid var(--line); cursor: pointer; }
.dslot:hover { background: color-mix(in srgb, var(--violet) 8%, transparent); }
.dslot span { position: absolute; left: -44px; top: -8px; font-size: 11px; color: var(--muted); }
.dblock { position: absolute; left: 6px; right: 6px; border-radius: 10px; padding: 4px 8px; overflow: hidden; cursor: pointer; z-index: 2;
  background: color-mix(in srgb, var(--gold) 26%, var(--surface2)); border-left: 3px solid var(--gold); font-size: 13px; }
.dnow { position: absolute; left: -6px; right: 0; height: 2px; background: var(--red); z-index: 3; }
.dnow::before { content: ""; position: absolute; left: -4px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--red); }
.checks { display: grid; gap: 6px; max-height: 200px; overflow-y: auto; }
.phead { cursor: pointer; }
.phead .chev { flex: 0 0 auto; margin-left: 8px; transition: transform .2s ease; }
.pclamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pgroup > summary { list-style: none; cursor: pointer; margin: 10px 0 8px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.pgroup > summary h2 { margin: 0 !important; font-size: 15px; }
.pgroup > summary::-webkit-details-marker { display: none; }
.pgroup > summary::after { content: "▾"; color: var(--muted); font-size: 14px; flex: none; }
.pgroup:not([open]) > summary::after { content: "›"; font-size: 20px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow); }
.card.flat { box-shadow: none; }
.card.tap { cursor: pointer; transition: transform .08s; }
.card.tap:active { transform: scale(.985); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 380px) { .grid3 { gap: 6px; } .grid3 .card { padding: 12px; } }
.grid3 > *, .grid2 > * { min-width: 0; }
.big { font-family: "Unbounded", sans-serif; font-size: 28px; font-weight: 600; letter-spacing: -.02em; }
.mid { font-family: "Unbounded", sans-serif; font-size: 18px; font-weight: 600; }
.label { font-size: 12px; color: var(--muted); text-transform: none; }
.delta { font-size: 12px; padding: 3px 8px; border-radius: 999px; background: var(--surface2); }
.delta.up { color: var(--green); } .delta.down { color: var(--red); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.dot.on { background: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 25%, transparent); }
.dot.off { background: var(--line); }

.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 12px; }
.item { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--line); cursor: pointer; }
.item:last-child { border-bottom: 0; }
.item:active { background: var(--surface2); }
.item .t { font-weight: 500; }
.item .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.avatar { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; font-weight: 600; flex: none; background: var(--surface2); color: var(--violet); }
.chev::after { content: "›"; color: var(--muted); font-size: 20px; margin-left: 4px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 14px; padding: 12px 16px; background: var(--violet); color: #fff; font-weight: 600; cursor: pointer; }
.btn.gold { background: var(--gold); color: #1a1408; }
.btn.ghost { background: var(--surface2); color: var(--text); }
.btn.danger { background: color-mix(in srgb, var(--red) 18%, var(--surface2)); color: var(--red); }
.btn.sm { padding: 7px 11px; border-radius: 10px; font-size: 13px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 8px 13px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: 13px; cursor: pointer; white-space: nowrap; }
.chip.on { background: var(--violet); border-color: var(--violet); color: #fff; }
.badge { display: inline-block; font-size: 11px; padding: 2px 7px; border-radius: 999px; background: var(--surface2); color: var(--muted); }
.badge.red { background: color-mix(in srgb, var(--red) 18%, transparent); color: var(--red); }
.badge.green { background: color-mix(in srgb, var(--green) 18%, transparent); color: var(--green); }
.badge.gold { background: color-mix(in srgb, var(--gold) 20%, transparent); color: var(--gold); }
.badge.violet { background: color-mix(in srgb, var(--violet) 18%, transparent); color: var(--violet); }

.seg { display: flex; background: var(--surface2); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 8px 6px; border-radius: 10px; font-size: 13px; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.period { margin-bottom: 14px; }
.period .range { font-size: 12px; color: var(--muted); margin-top: 6px; }

.bar { height: 8px; background: var(--surface2); border-radius: 999px; overflow: hidden; display: flex; }
.bar > i { display: block; height: 100%; }
.split { display: flex; gap: 10px; }
.split > div { flex: 1; }

.nav { position: fixed; left: 0; right: 0; bottom: 0; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(14px);
  border-top: 1px solid var(--line); display: flex; justify-content: center; padding: 6px 6px calc(8px + env(safe-area-inset-bottom)); z-index: 20; }
.nav .in { display: flex; width: 100%; max-width: 720px; }
.nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; color: var(--muted); padding: 6px 2px; border-radius: 12px; }
.nav a.on { color: var(--text); }
.nav a.on svg { color: var(--violet); }
.nav svg { width: 22px; height: 22px; }

.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 40; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.sheet { background: var(--bg); width: 100%; max-width: 720px; max-height: 92vh; overflow-y: auto; border-radius: 22px 22px 0 0; padding: 8px 16px calc(24px + env(safe-area-inset-bottom)); animation: up .2s; }
.sheet .grip { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 6px auto 12px; }
.sheet .head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sheet .x { background: var(--surface2); border: 0; width: 32px; height: 32px; border-radius: 50%; cursor: pointer; }
@keyframes up { from { transform: translateY(40px); opacity: .5; } }
@keyframes fade { from { opacity: 0; } }

.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; z-index: 60; font-size: 14px; max-width: 90vw; box-shadow: var(--shadow); }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.loader { display: grid; place-items: center; padding: 50px; color: var(--muted); }
.spin { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--violet); border-radius: 50%; animation: rot 0.8s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }

table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th { text-align: left; color: var(--muted); font-weight: 500; padding: 8px 6px; border-bottom: 1px solid var(--line); }
table.t td { padding: 9px 6px; border-bottom: 1px solid var(--line); }
.scroll-x { overflow-x: auto; }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.tile { border-radius: 18px; padding: 14px; cursor: pointer; background: linear-gradient(140deg, color-mix(in srgb, var(--violet) 22%, var(--surface)), var(--surface)); border: 1px solid var(--line); min-height: 92px; display: flex; flex-direction: column; justify-content: space-between; }
.tile.gold { background: linear-gradient(140deg, color-mix(in srgb, var(--gold) 22%, var(--surface)), var(--surface)); }
.tile .ic { font-size: 22px; }
.tile .n { font-weight: 600; }
.tile .d { font-size: 11px; color: var(--muted); }

.moon { width: 46px; height: 46px; border-radius: 50%; flex: none; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .h { font-size: 11px; color: var(--muted); text-align: center; padding: 4px 0; }
.cal .d { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; min-height: 54px; padding: 4px; font-size: 12px; position: relative; cursor: pointer; }
.cal .d.today { border-color: var(--violet); }
.cal .d .ld { font-size: 10px; color: var(--muted); }
.cal .d .ph { position: absolute; right: 4px; top: 3px; font-size: 13px; }
.cal .d .ev { display: flex; gap: 2px; margin-top: 3px; flex-wrap: wrap; }
.cal .d .ev i { width: 5px; height: 5px; border-radius: 50%; background: var(--gold); display: block; }
.cal .d .ev i.m { background: var(--violet); }
.cal .d .ev i.t { background: var(--green); }

.chart { width: 100%; height: 140px; display: block; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

.msg { max-width: 85%; padding: 8px 12px; border-radius: 14px; margin: 4px 0; font-size: 14px; white-space: pre-wrap; }
.msg.c { background: var(--surface2); }
.msg.m { background: color-mix(in srgb, var(--violet) 22%, var(--surface)); margin-left: auto; }
.msg .w { font-size: 10px; color: var(--muted); margin-top: 3px; }
.md p { margin: 0 0 10px; } .md h1, .md h2, .md h3 { margin: 16px 0 8px; } .md ul { padding-left: 20px; }
.lock { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 14px; background: var(--surface2); font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.receipt-img { width: 100%; max-height: 360px; object-fit: contain; border-radius: 12px; background: var(--surface2); }
.step { border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin-bottom: 10px; background: var(--surface); }
.step .n { font-size: 12px; color: var(--muted); }

/* шкала плана: факт поверх прогноза, метка плана на 100% */
.planbar { position: relative; height: 12px; border-radius: 999px; background: var(--surface2); overflow: hidden; }
.planbar i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px; }
.planbar .fc { background: color-mix(in srgb, var(--green) 30%, transparent); }
.planbar .ft { background: var(--green); }
.planbar .pl { position: absolute; right: 0; top: -2px; bottom: -2px; width: 3px; background: var(--gold); }

/* свой выпадающий список */
.selbtn { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; min-height: 44px; text-align: left; font: inherit; color: var(--text);
  background: var(--surface2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; cursor: pointer; }
.selbtn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.selbtn svg { flex: none; color: var(--muted); }
.selbtn:focus-visible, .picker-opt:focus-visible { outline: 2px solid var(--violet); outline-offset: 2px; }
.picker { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.picker-opt { display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: left; font: inherit; color: var(--text); background: transparent;
  border: 0; border-bottom: 1px solid var(--line); padding: 14px 16px; min-height: 48px; cursor: pointer; }
.picker-opt:last-child { border-bottom: 0; }
.picker-opt.on { color: var(--violet); font-weight: 600; }
.picker-opt i { font-style: normal; flex: none; }
.picker-search { margin-bottom: 10px; }
.row > .selbtn { width: auto; flex: 1 1 0; min-width: 0; }
.row > input, .row > select { min-width: 0; }

/* ---------- подсказки, переключатели, матрица доступов, воронка ---------- */
:root { color-scheme: dark; }
:root[data-theme="light"] { color-scheme: light; }
input[type=checkbox], input[type=radio] { accent-color: var(--violet); width: 18px; height: 18px; }
.hint { font-size: 12px; line-height: 1.5; padding: 9px 12px; border-radius: 12px; background: var(--surface2); color: var(--muted); margin: 6px 0; }
.hint.warn { background: color-mix(in srgb, var(--amber) 14%, var(--surface2)); color: var(--text); }
.switch { position: relative; display: inline-block; width: 44px; height: 26px; flex: none; margin: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--line); transition: background .2s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .22s cubic-bezier(.3,1.4,.6,1); box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:disabled + span { opacity: .5; }
.bar > i { background: var(--violet); }
.card.glow { border-color: color-mix(in srgb, var(--violet) 45%, var(--line)); box-shadow: var(--shadow), 0 0 0 1px color-mix(in srgb, var(--violet) 15%, transparent), 0 10px 40px -12px color-mix(in srgb, var(--violet) 45%, transparent); }
.card.alert { border-left: 4px solid var(--line); }
.card.alert.red { border-left-color: var(--red); }
.card.alert.gold { border-left-color: var(--amber); }
.card.kpi .mid { margin-top: 2px; }
table.matrix td.c, table.matrix th { text-align: center; }
table.matrix td:first-child { white-space: nowrap; }
table.matrix th.tap { cursor: pointer; color: var(--violet); }
.lv { display: inline-grid; place-items: center; width: 26px; height: 22px; border-radius: 7px; font-size: 12px; }
.lv.none { color: var(--muted); }
.lv.view { background: color-mix(in srgb, var(--blue) 16%, transparent); }
.lv.edit { background: color-mix(in srgb, var(--green) 18%, transparent); }
.perm-row { padding: 10px 0; border-bottom: 1px solid var(--line); }
.perm-row .seg { margin: 6px 0 4px; }
.funnel-bars { display: flex; align-items: flex-end; gap: 4px; height: 56px; margin: 10px 0 2px; }
.funnel-bars .fb { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 2px; }
.funnel-bars .fb i { width: 100%; border-radius: 6px 6px 3px 3px; background: linear-gradient(180deg, var(--violet), color-mix(in srgb, var(--violet) 45%, transparent)); transform-origin: bottom; animation: growY .6s cubic-bezier(.2,.8,.2,1) both; }
.funnel-bars .fb span { font-size: 10px; color: var(--muted); }
/* шаги сценария: показываем только нужные поля */
.step .f-sec, .step .f-file, .step .f-pay { display: none; }
.step[data-kind="wait"] .f-sec { display: block; }
.step[data-kind="wait"] .f-text, .step[data-kind="wait"] .f-tr, .step[data-kind="wait"] .f-save,
.step[data-kind="wait_payment"] .f-text, .step[data-kind="wait_payment"] .f-tr, .step[data-kind="wait_payment"] .f-row,
.step[data-kind="file"] .f-text, .step[data-kind="file"] .f-tr, .step[data-kind="file"] .f-row { display: none; }
.step[data-kind="file"] .f-file, .step[data-kind="file"] .f-pay { display: block; }
.step[data-kind="file"] .f-pay { display: flex; }
.step[data-kind="message"] .f-save, .step[data-kind="handoff"] .f-save, .step[data-kind="handoff"] .f-tr { display: none; }
.step[data-kind="message"] .f-row, .step[data-kind="handoff"] .f-row { display: none; }

/* ---------- живость: мягкие появления, нажатия, подсветки ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes growX { from { transform: scaleX(0); } }
@keyframes growY { from { transform: scaleY(0); } }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--green) 45%, transparent); } 50% { box-shadow: 0 0 0 5px transparent; } }
@keyframes sheen { from { background-position: -160% 0; } to { background-position: 260% 0; } }
@keyframes pop { 0% { transform: scale(.96); opacity: 0; } 100% { transform: none; opacity: 1; } }
.screen-in > .card, .screen-in > .list, .screen-in > .tiles, .screen-in > .grid2, .screen-in > .grid3, .screen-in > h2, .screen-in > .lock,
.screen-in > .chips, .screen-in > div > .card { animation: rise .38s cubic-bezier(.2,.8,.2,1) both; }
.screen-in > :nth-child(2) { animation-delay: .03s; } .screen-in > :nth-child(3) { animation-delay: .06s; } .screen-in > :nth-child(4) { animation-delay: .09s; }
.screen-in > :nth-child(5) { animation-delay: .12s; } .screen-in > :nth-child(6) { animation-delay: .15s; } .screen-in > :nth-child(n+7) { animation-delay: .18s; }
.bar > i, .planbar i:not(.pl) { transform-origin: left; animation: growX .8s cubic-bezier(.2,.8,.2,1) both; }
.dot.on { animation: pulse 2.2s ease-in-out infinite; }
.btn { transition: transform .12s ease, box-shadow .2s ease, filter .2s ease, background .2s ease; position: relative; overflow: hidden; }
.btn:active { transform: scale(.97); }
.btn:not(.ghost):not(.danger) { background-image: linear-gradient(110deg, transparent 30%, rgba(255,255,255,.18) 50%, transparent 70%); background-size: 200% 100%; background-position: -160% 0; background-repeat: no-repeat; }
.btn:focus-visible { outline: 2px solid var(--violet); outline-offset: 2px; }
.chip { transition: background .2s, border-color .2s, color .2s, transform .12s; }
.chip:active { transform: scale(.96); }
.chip.on { box-shadow: 0 4px 14px -4px color-mix(in srgb, var(--violet) 60%, transparent); }
.seg button { transition: background .2s, color .2s, box-shadow .2s; }
.tile { transition: transform .15s, box-shadow .25s, border-color .25s; }
.tile:active { transform: scale(.97); }
.item { transition: background .15s; }
.nav a { transition: color .2s, background .2s; }
.nav a.on { background: color-mix(in srgb, var(--violet) 12%, transparent); }
.nav a.on svg { animation: pop .25s ease both; }
.toast { animation: rise .25s ease both; }
.card.tap { transition: transform .1s, box-shadow .25s, border-color .25s; }
@media (hover: hover) {
  .btn:not(.ghost):not(.danger):hover { box-shadow: 0 6px 20px -6px color-mix(in srgb, var(--violet) 70%, transparent); animation: sheen 1.1s ease; }
  .btn.gold:hover { box-shadow: 0 6px 20px -6px color-mix(in srgb, var(--gold) 70%, transparent); }
  .btn.ghost:hover { filter: brightness(1.08); }
  .tile:hover, .card.tap:hover { border-color: color-mix(in srgb, var(--violet) 40%, var(--line)); box-shadow: var(--shadow), 0 8px 28px -14px color-mix(in srgb, var(--violet) 60%, transparent); }
  .item:hover { background: color-mix(in srgb, var(--surface2) 60%, transparent); }
  .chip:hover:not(.on) { border-color: color-mix(in srgb, var(--violet) 45%, var(--line)); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
label.btn { display: inline-flex; font-size: 15px; color: var(--text); margin: 0; }
label.btn.sm { font-size: 13px; }

/* красная плашка «Что не так с данными» */
.plaque { background: color-mix(in srgb, var(--red) 16%, var(--surface)); border: 1px solid color-mix(in srgb, var(--red) 55%, transparent); color: var(--text); border-radius: 16px; padding: 14px 16px; margin-bottom: 12px; cursor: pointer; }
.plaque b { color: var(--red); }
.pcard .src { margin-top: 6px; font-size: 12px; color: var(--blue); cursor: pointer; }
.pcard.closed { opacity: .7; }
table.frag td, table.frag th { white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
table.frag tr.hlrow td { background: color-mix(in srgb, var(--amber) 14%, transparent); }
table.frag .hl { background: color-mix(in srgb, var(--red) 30%, transparent) !important; font-weight: 600; }

/* ИИ-помощник */
.askai { position: fixed; right: 14px; bottom: calc(78px + env(safe-area-inset-bottom, 0px)); z-index: 40; border: 0; border-radius: 22px; padding: 10px 14px; background: var(--violet); color: #fff; font: inherit; font-size: 13px; box-shadow: 0 6px 18px rgba(0,0,0,.3); cursor: pointer; }
.chatlog { max-height: 55vh; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.chatlog .msg { padding: 8px 12px; border-radius: 14px; font-size: 14px; white-space: pre-wrap; max-width: 92%; }
.chatlog .msg.me { align-self: flex-end; background: color-mix(in srgb, var(--violet) 25%, var(--surface2)); }
.chatlog .msg.ai { align-self: flex-start; background: var(--surface2); }
.chatlog .msg .btn { margin: 6px 6px 0 0; }
.aiimg { padding: 8px 10px; border-radius: 10px; background: var(--surface2); cursor: pointer; margin-top: 4px; }

/* ИИ-чат на весь экран */
.aiwrap { position: fixed; inset: 0; z-index: 30; display: flex; flex-direction: column; background: var(--bg); padding-top: env(safe-area-inset-top, 0px); }
.aitop { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; }
.aiicon { background: none; border: 0; color: var(--text); font-size: 20px; padding: 6px 10px; cursor: pointer; }
.aipill { border: 0; border-radius: 22px; padding: 9px 16px; background: var(--surface2); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; }
.ailog { flex: 1; overflow-y: auto; padding: 8px 14px 12px; display: flex; flex-direction: column; gap: 10px; }
.ailog.static { overflow: visible; padding: 0; }
.aiempty { margin: auto; text-align: center; }
.aiempty h2 { font-size: 28px; margin: 0 0 8px; }
.aimsg { max-width: 92%; padding: 10px 14px; border-radius: 16px; font-size: 15px; line-height: 1.45; white-space: pre-wrap; word-wrap: break-word; }
.aimsg.me { align-self: flex-end; background: color-mix(in srgb, var(--violet) 28%, var(--surface2)); }
.aimsg.ai { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); }
.aimeta { font-size: 11px; color: var(--muted); margin-top: 6px; }
.aifiles { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.aifile { display: inline-block; border: 1px solid var(--line); background: var(--surface2); color: var(--text); border-radius: 10px; padding: 6px 10px; font: inherit; font-size: 13px; cursor: pointer; margin: 0 4px 4px 0; }
.aifile.sm { font-size: 12px; padding: 3px 8px; }
.aisugg { display: flex; gap: 8px; overflow-x: auto; padding: 0 14px 8px; scrollbar-width: none; scroll-snap-type: x proximity; scroll-padding: 0 14px;
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 14px, #000 calc(100% - 28px), transparent 100%); mask-image: linear-gradient(90deg, transparent 0, #000 14px, #000 calc(100% - 28px), transparent 100%); }
.aisugg::-webkit-scrollbar { display: none; }
.aicard { flex: 0 0 auto; max-width: 240px; text-align: left; border: 0; border-radius: 16px; padding: 12px 14px; background: var(--surface2); color: var(--text); font: inherit; cursor: pointer; scroll-snap-align: start; transition: transform .15s ease, background .2s ease; }
.aicard:active { transform: scale(.97); }
.aicard b { display: block; } .aicard span { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.aibar { border-top: 1px solid var(--line); padding: 8px 12px calc(10px + env(safe-area-inset-bottom, 0px)); background: var(--bg); }
.aiopts { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.aichip { border: 1px solid var(--line); background: none; color: var(--muted); border-radius: 14px; padding: 4px 10px; font: inherit; font-size: 12px; cursor: pointer; }
.aichip.on { color: var(--text); background: color-mix(in srgb, var(--violet) 25%, transparent); border-color: var(--violet); }
.aiinput { display: flex; align-items: flex-end; gap: 4px; }
.aiinput textarea { flex: 1; resize: none; border-radius: 22px; padding: 10px 14px; min-height: 42px; margin: 0; }
.aisend { width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--violet); color: #fff; font-size: 20px; cursor: pointer; flex: 0 0 auto; }
.aipend { display: flex; flex-wrap: wrap; }
.aidots i { display: inline-block; width: 6px; height: 6px; margin: 0 2px; border-radius: 50%; background: var(--muted); animation: aid 1s infinite; }
.aidots i:nth-child(2) { animation-delay: .2s; } .aidots i:nth-child(3) { animation-delay: .4s; }
@keyframes aid { 0%, 100% { opacity: .3; } 50% { opacity: 1; } }
.inchat #askai { display: none; }

/* плавная прокрутка и аккуратные полосы прокрутки везде (вместо системных) */
html { scroll-behavior: smooth; -webkit-tap-highlight-color: transparent; }
* { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--muted) 35%, transparent) transparent; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
*::-webkit-scrollbar { width: 6px; height: 6px; background: transparent; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--muted) 35%, transparent); border-radius: 999px; }
*::-webkit-scrollbar-thumb:hover { background: color-mix(in srgb, var(--muted) 60%, transparent); }
*::-webkit-scrollbar-corner { background: transparent; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

/* ---- проход по удобству (22.10) ---- */
.grid3 .mid { font-size: clamp(14px, 4.2vw, 18px); overflow-wrap: anywhere; }  /* суммы в три колонки не переносятся по строкам */
.loader.small { padding: 24px; }
.secret { cursor: pointer; border-bottom: 1px dashed currentColor; white-space: nowrap; }
.secret[data-open] { white-space: normal; word-break: break-all; }
.more-btn { margin-top: 8px; }
.dayhead { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin: 14px 2px 6px; font-size: 13px; color: var(--muted); }
.dayhead b { color: var(--text); font-weight: 600; }
.seg.sm button { padding: 6px 8px; font-size: 12px; }
.notif-row { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.notif-row:last-child { border-bottom: 0; }
.legend.wrap { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.kfrow { cursor: pointer; }
.kfrow .t { overflow-wrap: anywhere; }

.legend span { white-space: nowrap; }

/* ---- свои поля: дата, файл, переключатели вместо галочек (22.10) ---- */
.dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.dp-grid.m { grid-template-columns: repeat(3, 1fr); gap: 8px; }
.dp-w { text-align: center; font-size: 11px; color: var(--muted); padding: 4px 0; }
.dp-d { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; min-height: 40px; cursor: pointer; }
.dp-d.today { border-color: var(--violet); }
.dp-d.on { background: var(--violet); border-color: var(--violet); color: #fff; font-weight: 600; }
.dp-d:hover { border-color: var(--violet); }
.filebtn { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 10px 14px; border: 1.5px dashed var(--line); border-radius: var(--radius); background: var(--surface); cursor: pointer; color: var(--text); }
.filebtn:hover { border-color: var(--violet); }
.filebtn .ic { font-size: 18px; }
.filebtn .grow { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
/* галочки в формах — аккуратные переключатели (кроме спрятанных внутри .switch и чипов) */
input[type=checkbox]:not(.switch input):not(.native) { appearance: none; -webkit-appearance: none; width: 40px; height: 24px; flex: none; margin: 0; border-radius: 999px;
  background: var(--line); position: relative; cursor: pointer; transition: background .2s; vertical-align: middle; }
input[type=checkbox]:not(.switch input):not(.native)::after { content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .2s cubic-bezier(.3,1.4,.6,1); }
input[type=checkbox]:not(.switch input):not(.native):checked { background: var(--green); }
input[type=checkbox]:not(.switch input):not(.native):checked::after { transform: translateX(16px); }
input[type=checkbox]:not(.switch input):not(.native):disabled { opacity: .5; }
label.row:has(> input[type=checkbox]) { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.formmore { margin-top: 14px; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; }
.formmore > summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.formmore[open] > summary { margin-bottom: 4px; }

.row > .selbtn { min-width: 96px; }

.grid3 .big, .grid3 .kpi .big { font-size: clamp(15px, 4.6vw, 22px); white-space: nowrap; }

/* ---- переписка как в мессенджере (23.10) ---- */
.chathead { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; display: flex; align-items: center; gap: 10px; padding: 10px 0; margin-bottom: 6px;
  background: var(--bg); border-bottom: 1px solid var(--line); }
.convlog { display: flex; flex-direction: column; gap: 6px; padding-bottom: 90px; }
.convlog [data-msgs] { display: flex; flex-direction: column; gap: 6px; }
.daysep { text-align: center; margin: 10px 0 4px; }
.daysep span { font-size: 12px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); padding: 3px 10px; border-radius: 999px; }
.bub { max-width: 82%; padding: 8px 12px 6px; border-radius: 16px; position: relative; word-wrap: break-word; overflow-wrap: anywhere; }
.bub.in { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.bub.out { align-self: flex-end; background: color-mix(in srgb, var(--violet) 22%, var(--surface)); border: 1px solid color-mix(in srgb, var(--violet) 35%, transparent); border-bottom-right-radius: 6px; }
.bub.del { border: 1.5px dashed var(--red); background: color-mix(in srgb, var(--red) 8%, var(--surface)); }
.btext { white-space: pre-wrap; line-height: 1.4; }
.bmeta { font-size: 11.5px; color: var(--muted); margin-bottom: 3px; }
.bmeta.warn { color: var(--red); font-weight: 600; }
.btime { font-size: 11px; color: var(--muted); text-align: right; margin-top: 3px; }
.bimg { max-width: 100%; border-radius: 10px; cursor: zoom-in; display: block; margin: 2px 0 4px; }
.bedit { margin-top: 4px; font-size: 12px; }
.bedit summary { color: var(--gold); cursor: pointer; }
/* все раскрывающиеся блоки — без системного треугольника, со стрелкой справа */
details > summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
details > summary::-webkit-details-marker { display: none; }
details:not(.pgroup) > summary::after { content: "›"; color: var(--muted); font-size: 18px; flex: none; transition: transform .15s; }
details:not(.pgroup)[open] > summary::after { transform: rotate(90deg); }

/* переводчик в «Переписках»: русский перевод под оригиналом */
.btr { margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--line); white-space: pre-wrap; font-size: 13.5px; color: var(--text); opacity: .85; }
.convlog.tr-off .btr { display: none; }
.chathead [data-tr] { flex: none; white-space: nowrap; }

/* «Кто что может»: названия ролей компактно, первая колонка (раздел) не уезжает при прокрутке вбок */
table.matrix th { font-size: 12px; line-height: 1.2; white-space: nowrap; vertical-align: bottom; padding: 0 10px 8px; }
table.matrix td:first-child, table.matrix th:first-child { position: sticky; left: 0; background: var(--surface, #fff); z-index: 1; }

/* выбор цвета: кружок и палитра */
.swatch { width: 40px; height: 40px; flex: none; border-radius: 50%; border: 2px solid var(--surface, #fff); box-shadow: 0 0 0 1px var(--line); cursor: pointer; padding: 0; }
.swatch.sm { width: 30px; height: 30px; }
.swatch.on { box-shadow: 0 0 0 2px var(--text, #222); }
.palette { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 2px 4px; }

/* чеки: светлая рамка (в тёмной теме не сливаются), просмотр во весь экран с приближением */
.receipt-frame { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 8px; margin-top: 8px; }
.receipt-frame .receipt-img { display: block; width: 100%; max-height: 420px; object-fit: contain; cursor: zoom-in; border-radius: 6px; }
.zoom-bg { position: fixed; inset: 0; z-index: 1000; background: rgba(0,0,0,.85); display: flex; align-items: center; justify-content: center; }
.zoom-bg .x { position: absolute; top: calc(12px + env(safe-area-inset-top, 0px)); right: 12px; width: 40px; height: 40px; border-radius: 50%; border: 0; background: #fff; font-size: 18px; z-index: 2; }
.zoom-wrap { width: 100%; height: 100%; overflow: auto; touch-action: pinch-zoom; display: flex; align-items: center; justify-content: center; }
.zoom-wrap img { max-width: 100%; max-height: 100%; background: #fff; transition: transform .2s; transform-origin: center; }

/* главная: выручка+план в одной карточке, разбор ИИ, прибыль таблицей */
.card.hero .hr { height: 1px; background: var(--line); margin: 14px 0 10px; }
.planbar { position: relative; }
.planbar .pl { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text, #222); opacity: .55; border-radius: 1px; }
.card.insight { border-color: var(--violet); }
.ins-head { font-size: 15px; font-weight: 600; margin: 8px 0 4px; line-height: 1.4; }
.ins-sec { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 12px 0 4px; }
.ins-sec.good { color: var(--green); } .ins-sec.bad { color: var(--red); }
.ins-row { display: flex; gap: 8px; font-size: 13.5px; line-height: 1.45; margin: 4px 0; }
.ins-row > span:first-child { flex: none; }
.ptable { margin-top: 10px; border-top: 1px solid var(--line); }
.pt-row { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.pt-row > span:first-child { color: var(--muted); }
.pt-row i { font-style: normal; color: var(--muted); font-size: 12px; margin-left: 4px; }
.pt-row.in > span:first-child { color: var(--text); }
.pt-row.total { border-bottom: 0; font-size: 14.5px; } .pt-row.total > span:first-child { color: var(--text); font-weight: 600; }
.card.hero .split2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.card.hero .split2 > div { background: color-mix(in srgb, var(--text) 4%, transparent); border-radius: 12px; padding: 10px 12px; cursor: pointer; }
.card.hero .split2 b { display: block; font-size: 17px; margin: 2px 0; }
.pt-row.e > span:first-child { color: var(--text); }
.ptable .pt-row:last-child { border-bottom: 0; }
details.pdet { margin-top: 8px; }
details.pdet > summary { cursor: pointer; color: var(--violet); list-style: none; }
details.pdet > summary::-webkit-details-marker { display: none; }
details.pdet > summary::after { content: ' ▾'; }
details.pdet[open] > summary::after { content: ' ▴'; }
.card.rv .rv-why { margin-top: 10px; border-radius: 12px; background: color-mix(in srgb, var(--amber) 10%, transparent); padding: 4px 12px; }
.card.rv .rv-r { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid color-mix(in srgb, var(--amber) 18%, transparent); font-size: 13.5px; line-height: 1.45; }
.card.rv .rv-r:last-child { border-bottom: 0; }
.card.rv .rv-r > span { flex: none; font-size: 16px; }
.card.rv .rv-r .small { color: var(--muted); margin-top: 2px; }
.card.rv .rv-act { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 10px; }
