:root {
  color-scheme: light;
  --bg: #f6f5f2;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --line: #e2e0da;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #7a7873;
  --accent: #e6477c;            /* фирменные цвета «АВА вместе»: розовый, оранжевый, жёлтый */
  --accent-ink: #b8275d;
  --brand-orange: #f27a3e;
  --brand-yellow: #f4bf44;
  --brand-grad: linear-gradient(95deg, #e6477c 0%, #f27a3e 60%, #f4bf44 120%);
  --series-1: #2a78d6;
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(0 0 0 / .04), 0 4px 16px rgb(0 0 0 / .04);
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #121211; --surface: #1a1a19; --surface-2: #232321; --line: #33332f;
    --text: #ffffff; --text-2: #c3c2b7; --muted: #8f8d86;
    --accent: #f0659a; --accent-ink: #f58ab2; --series-1: #3987e5;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211; --surface: #1a1a19; --surface-2: #232321; --line: #33332f;
  --text: #ffffff; --text-2: #c3c2b7; --muted: #8f8d86;
  --accent: #f0659a; --accent-ink: #f58ab2; --series-1: #3987e5;
  --shadow: none;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 500 15px/1.45 Nunito, system-ui, sans-serif;
}
h2 { font-size: 16px; margin: 0; font-weight: 800; }
.muted { color: var(--muted); font-size: 13px; margin: 2px 0 0; }
button, input, select { font: inherit; color: inherit; }

.top {
  display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; justify-content: space-between;
  padding: 14px 24px; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; gap: 10px; align-items: center; }
.logo { width: 30px; height: auto; display: block; }
.brand-name { font: 900 17px/1.1 Montserrat, sans-serif; letter-spacing: .3px; background: var(--brand-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand-sub { font: 600 10.5px Montserrat, sans-serif; color: var(--muted); letter-spacing: 1.2px; text-transform: uppercase; margin-top: 2px; }
.tabs { display: flex; gap: 4px; overflow-x: auto; }
.tabs button {
  border: 0; background: none; padding: 8px 14px; border-radius: 999px; cursor: pointer; font-weight: 700; color: var(--text-2);
  white-space: nowrap;
}
.tabs button[aria-selected="true"] { background: var(--brand-grad); color: #fff; box-shadow: 0 4px 12px rgb(230 71 124 / .22); }

.filters {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 14px 24px;
}
.spacer { flex: 1; }
[hidden] { display: none !important; }
.field { display: flex; gap: 6px; align-items: center; font-size: 13px; color: var(--text-2); }
.field input, .field select {
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; min-height: 36px;
}
.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 700; color: var(--text-2); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 7px 14px; cursor: pointer; font-weight: 700; min-height: 36px; }
.btn.ghost:hover { border-color: var(--accent); color: var(--accent-ink); }
.btn.primary { background: var(--brand-grad); color: #fff; border-color: transparent; }
.btn.small { padding: 4px 10px; font-size: 13px; min-height: 30px; }

main { padding: 0 24px 24px; display: grid; gap: 16px; }
.tab { display: grid; gap: 16px; }
.tab[hidden] { display: none; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); position: relative; min-width: 0; }
.card-h { margin-bottom: 12px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.tile {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px;
  cursor: pointer; text-align: left; box-shadow: var(--shadow);
}
.tile:hover { border-color: var(--accent); }
.tile .t { font-size: 13px; color: var(--text-2); display: flex; gap: 6px; align-items: center; }
.tile .v { font-size: 28px; font-weight: 800; margin-top: 4px; font-variant-numeric: tabular-nums; }
.tile .s { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; display: inline-block; }
.st-good { background: var(--good); } .st-warning { background: var(--warning); }
.st-serious { background: var(--serious); } .st-critical { background: var(--critical); } .st-neutral { background: var(--muted); }

.chart { height: 220px; position: relative; }
.chart svg { width: 100%; height: 100%; display: block; }
.chart .bar { fill: var(--series-1); }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .hit:hover + .bar, .chart g:hover .bar { opacity: .75; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart text { fill: var(--muted); font: 500 11px Montserrat, sans-serif; }
.tooltip {
  position: absolute; pointer-events: none; background: var(--text); color: var(--surface); border-radius: 10px;
  padding: 8px 10px; font-size: 13px; line-height: 1.4; white-space: nowrap; z-index: 3;
}

.tbl { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 14px; }
.tbl th { text-align: left; font: 600 12px Montserrat, sans-serif; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 8px; border-bottom: 1px solid var(--line); }
.tbl td.num, .tbl th.num { text-align: right; white-space: nowrap; }
.tbl-wrap { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
.tbl tr:last-child td { border-bottom: 0; }
.diff-bad { color: var(--critical); font-weight: 700; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; gap: 6px; align-items: center; border: 1px solid var(--line); background: var(--surface);
  border-radius: 999px; padding: 5px 12px; cursor: pointer; font-size: 13px; font-weight: 700;
}
.chip[aria-pressed="true"] { border-color: var(--accent); color: var(--accent-ink); }
.chip .n { color: var(--muted); font-weight: 600; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

.list { display: grid; gap: 8px; }
.item {
  display: grid; grid-template-columns: auto 1fr auto; gap: 4px 14px; align-items: start;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
}
.card .item { background: var(--surface-2); border-color: transparent; }
.item .ttl { font-weight: 800; }
.item .meta { font-size: 13px; color: var(--muted); }
.item .det { font-size: 14px; color: var(--text-2); grid-column: 2 / 4; }
.item .act { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.item .dot { margin-top: 6px; }
.badge { font: 600 11px Montserrat, sans-serif; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); }
.resolved { font-size: 13px; color: var(--good); grid-column: 2 / 4; }

.acc .big { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
.drop { display: flex; align-items: center; justify-content: center; border: 2px dashed var(--line); border-radius: 12px; padding: 22px; cursor: pointer; color: var(--text-2); font-weight: 700; }
.drop:hover { border-color: var(--accent); }
.drop input { display: none; }
.empty { padding: 24px; text-align: center; color: var(--muted); }
.foot { padding: 0 24px 24px; }

@media (max-width: 640px) {
  .top, .filters { padding-left: 16px; padding-right: 16px; }
  main { padding: 0 16px 16px; }
  .grid2 { grid-template-columns: 1fr; }
  .item { grid-template-columns: auto 1fr; }
  .item .act { grid-column: 2; justify-content: flex-start; }
  .item .det, .resolved { grid-column: 2; }
  .spacer { display: none; }
  .tbl { font-size: 13px; }
  .tbl td, .tbl th { padding: 6px 5px; }
  .tile .v { font-size: 24px; }
  .tiles { grid-template-columns: 1fr 1fr; }
  .tile { padding: 12px; }
}

/* Воронка */
.funnels { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.funnel { background: var(--surface-2); border-radius: 12px; padding: 14px; }
.funnel h3 { margin: 0; font-size: 15px; font-weight: 800; }
.funnel .note { font-size: 12px; color: var(--muted); margin: 2px 0 10px; }
.fstep { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; align-items: center; margin-bottom: 8px; font-size: 13px; }
.fstep .lbl { color: var(--text-2); }
.fstep .num { font-weight: 800; font-variant-numeric: tabular-nums; }
.fstep .bar { grid-column: 1 / 3; height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.fstep .bar i { display: block; height: 100%; background: var(--series-1); border-radius: 4px; }
.fstep .cr { grid-column: 1 / 3; font-size: 12px; color: var(--muted); }
.warn { background: color-mix(in srgb, var(--warning) 18%, var(--surface)); border: 1px solid color-mix(in srgb, var(--warning) 50%, var(--line)); border-radius: 12px; padding: 10px 14px; font-size: 14px; }
.funnel .rev { font-size: 18px; font-weight: 800; margin: -4px 0 10px; font-variant-numeric: tabular-nums; }
.funnel .rev .muted { font-size: 12px; font-weight: 600; }
a.btn { text-decoration: none; color: var(--accent-ink); display: inline-flex; align-items: center; }

/* Доступы */
.uform { display: grid; gap: 12px; max-width: 640px; }
.uform .field { justify-content: space-between; }
.uform .field input:not([type=checkbox]), .uform .field select { width: 320px; max-width: 100%; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.checks label { display: inline-flex; gap: 6px; align-items: center; font-size: 14px; }
.pw-input { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 5px 10px; min-height: 30px; font: inherit; color: inherit; }
.off td { color: var(--muted); }
@media (max-width: 640px) { .uform .field { flex-direction: column; align-items: stretch; } .uform .field input:not([type=checkbox]), .uform .field select { width: 100%; } }
.uform > .btn { justify-self: start; }
.uform #activeField { justify-content: flex-start; }

/* Экономика */
.ec-in { width: 130px; text-align: right; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; color: var(--series-1); font: inherit; font-weight: 700; }
.ec-in:disabled { color: var(--text); border-color: transparent; background: none; }
.ec-auto { font-size: 12px; color: var(--muted); }
.good { color: var(--good); font-weight: 700; }

/* Панель */
.pn td, .pn th { white-space: nowrap; }
.pn td:first-child { white-space: normal; min-width: 210px; }
.pn .ec-in { width: 90px; }
.pn textarea { width: 180px; min-height: 54px; font: inherit; font-size: 13px; border: 1px solid var(--line); border-radius: 8px; padding: 6px; background: var(--surface); color: var(--text); }
.pn .sec td { background: var(--surface-2); font-weight: 800; }
.zone-green { color: var(--good); font-weight: 800; } .zone-yellow { color: #b88600; font-weight: 800; } .zone-red { color: var(--critical); font-weight: 800; }
.pn .src { font-size: 11px; color: var(--muted); }

.alert { background: color-mix(in srgb, var(--critical) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--critical) 45%, var(--line)); color: var(--text); border-radius: 12px; padding: 10px 14px; font-size: 14px; font-weight: 700; }
.row-alert td { background: color-mix(in srgb, var(--critical) 10%, var(--surface)); color: var(--critical); font-size: 13px; white-space: normal !important; }
.row-alert a { color: var(--critical); }

.tile .qm { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; background: var(--surface-2); color: var(--muted); font-size: 11px; font-weight: 800; }
.tile .hint { font-size: 12px; color: var(--muted); margin-top: 6px; line-height: 1.35; }
.gloss { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 10px 20px; font-size: 14px; color: var(--text-2); }
.gloss b { color: var(--text); }

/* Сверка по дням */
.daygrid { display: grid; grid-template-columns: 350px 1fr; gap: 18px; align-items: start; }
@media (max-width: 900px) { .daygrid { grid-template-columns: 1fr; } }
#dayList tr { cursor: pointer; }
#dayList tr.sel td { background: color-mix(in srgb, var(--accent) 10%, var(--surface)); font-weight: 800; }
.dd-head { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin-bottom: 10px; }
.dd-head h3 { margin: 0; font-size: 16px; }
.pill { font: 700 12px Nunito, sans-serif; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); }
.pill.ok { background: color-mix(in srgb, var(--good) 14%, var(--surface)); color: var(--good); }
.pill.bad { background: color-mix(in srgb, var(--critical) 12%, var(--surface)); color: var(--critical); }
.brrow td { background: var(--surface-2); font-weight: 800; }
.sub td:first-child { padding-left: 22px; color: var(--text-2); }
.src2 { display: block; font-size: 11.5px; color: var(--muted); }

.ai-out { line-height: 1.55; margin-top: 10px; }
.ai-out h4 { margin: 14px 0 6px; font-size: 15px; }
.ai-out ul, .ai-out ol { margin: 4px 0 8px 20px; padding: 0; }
.btn { border: 0; border-radius: 999px; padding: 9px 18px; font: 800 14px Nunito, system-ui, sans-serif; color: #fff; background: var(--brand-grad, var(--accent)); cursor: pointer; }
.btn[disabled] { opacity: .6; cursor: default; }

/* Красные сигналы панели */
.signals { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.sig { border: 1px solid var(--line); border-left: 4px solid var(--critical); border-radius: 10px; padding: 10px 12px; background: color-mix(in srgb, var(--critical) 5%, var(--surface)); }
.sig.neutral { border-left-color: var(--muted); background: var(--surface); }
.sig-t { font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.sig-d { font-size: 13px; color: var(--text-2); }
.mm { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.mm:last-child { border-bottom: 0; }
.mm-l { margin-top: 4px; font-size: 13px; line-height: 1.7; }
pre.dlg { white-space: pre-wrap; word-break: break-word; max-height: 520px; overflow: auto; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font: 13px/1.5 inherit; font-family: inherit; }
/* Контент → заявки */
.eff-chart { margin: 12px 0 14px; overflow-x: auto; }
.eff-chart svg { min-width: 560px; display: block; }
.eff-bar { fill: var(--accent, #e8505b); opacity: .85; }
.eff-promo { fill: var(--muted); opacity: .45; }
.eff-reel { fill: #f39c32; }
.eff-base { fill: none; stroke: var(--text-2); stroke-width: 1.5; stroke-dasharray: 4 3; }
.eff-ax { font-size: 10px; fill: var(--muted); }
.eff-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--text-2); margin-top: 6px; }
.eff-legend i { display: inline-block; width: 12px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.lg-bar { background: var(--accent, #e8505b); } .lg-promo { background: var(--muted); opacity: .45; }
.lg-base { border-top: 2px dashed var(--text-2); height: 0 !important; } .lg-reel { background: #f39c32; border-radius: 50% !important; width: 10px !important; }
.eff-wa { fill: #2bb673; opacity: .85; } .lg-wa { background: #2bb673; }

/* Акция 100: цвет уровня плана */
.tile.lvl-red { border-left: 4px solid var(--critical); }
.tile.lvl-yellow { border-left: 4px solid var(--warning); }
.tile.lvl-green, .tile.lvl-excellent { border-left: 4px solid var(--good); }
.tile .goal { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* Динамика SMM: мини-график на каждую страницу */
.spark-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; margin-top: 10px; }
.spark { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--surface); }
.spark .t { font-size: 13px; font-weight: 700; }
.spark .v { font-size: 20px; font-weight: 800; margin: 2px 0; }
.spark .s { font-size: 12px; color: var(--text-2); }
.spark svg { display: block; width: 100%; height: 64px; margin-top: 6px; overflow: visible; }
.spark .ln { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.spark .dt { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; }
.spark .dt.last { r: 4.5; }
.spark .gr { stroke: var(--line); stroke-width: 1; }
.spark .ax { font-size: 10px; fill: var(--text-2); }
.spark.missing { border-style: dashed; }

/* «Без ответа»: число раскрывается в список сделок */
details.nr summary { cursor: pointer; list-style: none; text-decoration: underline dotted; }
details.nr summary::-webkit-details-marker { display: none; }
details.nr summary::after { content: " ▾"; font-size: 11px; }
details.nr[open] summary::after { content: " ▴"; }
details.nr .nr-l { margin-top: 6px; max-height: 200px; overflow-y: auto; padding-right: 4px; font-weight: 400; font-size: 13px; line-height: 1.6; text-align: right; }
.warn-t { color: #b07800; font-weight: 700; }

.cmp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.cmp { background: var(--surface-2); border-radius: 12px; padding: 12px 14px; }
.cmp h3 { margin: 0 0 6px; font-size: 15px; }
.cmp-h { font-weight: 800; font-size: 12px; text-transform: uppercase; letter-spacing: .3px; margin-top: 6px; }
.cmp ul { margin: 4px 0 0; padding-left: 18px; font-size: 13px; }
.cmp li { margin-bottom: 3px; }
.cmp-title { margin: 16px 0 8px; font-size: 15px; }
.sec-h { margin: 22px 0 10px; font-size: 20px; }
/* Банки: плитки групп счетов — шире, с расшифровкой в таблице */
#bankGroups { grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); }
#bankGroups .tile { min-width: 0 !important; overflow: hidden; }
#bankGroups .tile .v { font-size: 22px; line-height: 1.2; }
#bankGroups .tbl td { padding: 6px 8px; vertical-align: top; }
#bankGroups .tbl td.num { white-space: nowrap; }
@media (max-width: 720px) { #bankGroups { grid-template-columns: 1fr; } }
