/* MVP аналитики (Surco Labs). Базовые токены — surco.css; здесь палитра графиков и раскладка.
   Категориальная палитра проверена validate_palette.js (светлый фон): c1…c6 в фиксированном порядке. */
:root{
  --an-c1:#9a3b26; --an-c2:#2a78a8; --an-c3:#c9962e; --an-c4:#4f7d3a; --an-c5:#9b59b6; --an-c6:#e07b67;
  --an-c1-soft:rgba(154,59,38,.12); --an-ok-soft:rgba(61,122,74,.13);
  --an-seq1:#f3e4dc; --an-seq2:#c9765c; --an-seq3:#6e2414;
  --an-free:#e9e3da; --an-land:#ece6dd;
}
.an-hero{padding-top:36px}
.an-hero-top{display:flex;flex-wrap:wrap;gap:10px;align-items:center;margin-bottom:14px}
.an-for{font-size:14px;color:var(--muted);background:var(--surface);border:1px solid var(--line);border-radius:999px;padding:3px 12px}
.an-for b{color:var(--ink)}
.an-hero h1{font-size:clamp(28px,4vw,44px);max-width:820px}
.an-lead{font-size:18px;color:var(--muted);max-width:760px;margin:0 0 8px}
.an-farm{font-size:14px;color:var(--muted);margin:0 0 22px}
.an-tabs{display:flex;gap:4px;border-bottom:1px solid var(--line);overflow-x:auto;scrollbar-width:none}
.an-tabs::-webkit-scrollbar{display:none}
.an-tabs a{display:flex;align-items:center;gap:8px;padding:12px 16px;color:var(--muted);text-decoration:none;font-weight:500;
  border-bottom:2px solid transparent;margin-bottom:-1px;white-space:nowrap}
.an-tabs a:hover{color:var(--ink)}
.an-tabs a.on{color:var(--ink);border-bottom-color:var(--accent)}
.an-tab-n{display:inline-grid;place-items:center;width:20px;height:20px;border-radius:50%;font-size:11px;background:var(--line);color:var(--ink)}
.an-tabs a.on .an-tab-n{background:var(--accent);color:#fff}
.an-body{padding-top:20px}
.an-tab-lead{color:var(--muted);margin:0 0 18px;max-width:820px}

/* панель фильтров */
.an-bar{display:flex;flex-wrap:wrap;gap:12px 20px;align-items:flex-end;justify-content:space-between;margin-bottom:18px}
.an-seg{display:inline-flex;background:var(--surface);border:1px solid var(--line);border-radius:999px;padding:3px}
.an-seg button{font:inherit;font-size:14px;border:0;background:transparent;padding:8px 16px;border-radius:999px;cursor:pointer;color:var(--muted)}
.an-seg button.on{background:var(--ink);color:#fff}
.an-filters,.an-ctrls{display:flex;flex-wrap:wrap;gap:10px}
.an-f{display:flex;flex-direction:column;gap:4px;font-size:12px;color:var(--muted)}
.an-f select{font:inherit;font-size:14px;color:var(--ink);background:var(--surface);border:1px solid var(--line);border-radius:8px;
  padding:7px 30px 7px 10px;min-width:150px;max-width:100%}
.an-f[hidden],.an-board[hidden]{display:none}

/* KPI */
.an-kpis{display:grid;grid-template-columns:repeat(auto-fit,minmax(170px,1fr));gap:12px;margin-bottom:16px}
.an-kpi{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);padding:14px 16px;display:flex;flex-direction:column;gap:2px;min-width:0}
.an-kpi-l{font-size:13px;color:var(--muted)}
.an-kpi-v{font-size:24px;font-weight:600;letter-spacing:-.01em;font-variant-numeric:tabular-nums;overflow-wrap:anywhere}
.an-kpi-n{font-size:12px;color:var(--muted)}
.an-kpi-n em{font-style:normal;font-weight:600}
.an-kpi-n em.up{color:var(--ok)} .an-kpi-n em.down{color:var(--bad)}
.an-kpis.small .an-kpi{background:var(--bg);border:0;padding:10px 12px}
.an-kpis.small .an-kpi-v{font-size:19px}

/* карточки графиков */
.an-grid{display:grid;grid-template-columns:repeat(12,minmax(0,1fr));gap:16px;margin-bottom:16px}
.an-card{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);padding:18px 18px 12px;box-shadow:var(--shadow);min-width:0}
.an-card h3{font-family:var(--sans);font-size:15px;font-weight:600;margin:0 0 2px}
.an-card h4{font-size:13px;font-weight:500;color:var(--muted);margin:10px 0 0}
.an-sub{font-size:13px;color:var(--muted);margin:0 0 6px}
.w4{grid-column:span 4}.w5{grid-column:span 5}.w6{grid-column:span 6}.w7{grid-column:span 7}.w8{grid-column:span 8}
.an-wide{margin-bottom:16px}
.an-chart{width:100%;height:300px}
.an-chart.sm{height:220px}.an-chart.lg{height:380px}.an-map{height:320px}
.an-split{display:grid;grid-template-columns:1fr 1fr;gap:20px}
.an-note{font-size:12px;color:var(--muted);margin:8px 0 0}
.loading .an-chart,.loading [data-kpis],.loading [data-verdict]{opacity:.45;transition:opacity .2s}
.an-err,.an-empty{background:var(--accent-soft);color:var(--accent);border-radius:8px;padding:12px 14px;margin:0 0 14px;font-size:14px}

/* гипотезы */
.an-hyp{display:grid;grid-template-columns:300px 1fr;gap:20px;align-items:start}
.an-hyp-list{display:flex;flex-direction:column;gap:8px}
.an-hyp-item{font:inherit;text-align:left;background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);padding:14px 16px;
  cursor:pointer;display:flex;flex-direction:column;gap:4px;color:var(--ink)}
.an-hyp-item b{font-weight:500;font-size:15px;line-height:1.35}
.an-hyp-item.on{border-color:var(--accent);box-shadow:inset 3px 0 0 var(--accent)}
.an-hyp-k{font-size:11px;text-transform:uppercase;letter-spacing:.06em;color:var(--muted)}
.an-hyp-panel h2{font-size:24px}
.an-hyp-panel .an-ctrls{margin:10px 0 6px}
.an-verdict{border-radius:10px;padding:14px 16px;margin:8px 0 10px;background:var(--bg);border-left:4px solid var(--muted)}
.an-verdict.yes{border-left-color:var(--ok);background:var(--an-ok-soft)}
.an-verdict.no{border-left-color:var(--warn);background:#f8efdf}
.an-verdict b{display:block;font-size:16px;margin-bottom:4px}
.an-verdict p{margin:0;font-size:14px}
.an-stats summary{cursor:pointer;font-size:14px;color:var(--accent);padding:4px 0}
.an-stats table{border-collapse:collapse;font-size:13px;margin:6px 0;font-variant-numeric:tabular-nums}
.an-stats td{padding:4px 16px 4px 0;border-bottom:1px solid var(--line)}
.an-stats td:first-child{color:var(--muted)}

/* отчёты */
.an-rep{display:grid;grid-template-columns:260px 1fr;gap:20px;align-items:start}
.an-rep-list{display:flex;flex-direction:column;gap:8px}
.an-rep-list a{display:flex;flex-direction:column;gap:2px;padding:12px 14px;border:1px solid var(--line);border-radius:var(--radius);
  background:var(--surface);text-decoration:none;color:var(--ink)}
.an-rep-list a span{font-size:13px;color:var(--muted)}
.an-rep-list a.on{border-color:var(--accent);box-shadow:inset 3px 0 0 var(--accent)}
.an-rep-head{display:flex;flex-wrap:wrap;gap:12px;justify-content:space-between;align-items:flex-end;margin-bottom:8px}
.an-rep-head h2{font-size:24px;margin:0}
.an-rep-actions{display:flex;flex-wrap:wrap;gap:8px;align-items:flex-end}
.an-btn{padding:8px 16px;font-size:14px}
.an-summary{background:var(--bg);border-radius:8px;padding:10px 14px;font-size:14px;margin:6px 0 12px}
.an-table-wrap{overflow-x:auto;-webkit-overflow-scrolling:touch}
.an-table{width:100%;border-collapse:collapse;font-size:14px;font-variant-numeric:tabular-nums}
.an-table th{text-align:left;font-weight:500;font-size:12px;color:var(--muted);padding:8px 10px;border-bottom:1px solid var(--line);white-space:nowrap}
.an-table td{padding:8px 10px;border-bottom:1px solid var(--line);white-space:nowrap}
.an-table .num{text-align:right}
.an-table tfoot td{font-weight:600;border-top:2px solid var(--ink);border-bottom:0}
.an-table tbody tr:hover{background:var(--bg)}
.an-table .pos{color:var(--ok)} .an-table .neg{color:var(--bad)}
.an-print-head{display:none}

/* правила потерь */
.an-al{display:grid;grid-template-columns:minmax(0,5fr) minmax(0,7fr);gap:20px;align-items:start}
.an-rules{display:grid;gap:10px}
.an-rule{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);padding:14px 16px}
.an-rule header{display:flex;justify-content:space-between;gap:10px;align-items:flex-start}
.an-rule h3{font-family:var(--sans);font-size:15px;font-weight:600;margin:0}
.an-count{min-width:32px;text-align:center;font-weight:700;font-size:15px;padding:2px 10px;border-radius:999px;background:var(--bad);color:#fff}
.an-rule.quiet .an-count{background:var(--line);color:var(--muted)}
.an-slider{display:flex;flex-direction:column;gap:4px;font-size:13px;margin:6px 0}
.an-slider input{width:100%;accent-color:var(--accent)}
.an-rule footer{display:flex;flex-wrap:wrap;justify-content:space-between;gap:6px;align-items:center;font-size:12px;color:var(--muted)}
.an-sevs{display:flex;gap:4px;flex-wrap:wrap}
.an-sev{display:inline-block;font-size:11px;font-weight:600;padding:2px 8px;border-radius:999px;white-space:nowrap}
.an-sev.high{background:var(--bad);color:#fff}
.an-sev.med{background:#f6e3c4;color:#7a4f10}
.an-sev.low{background:var(--line);color:var(--ink)}
.an-chan{font-weight:500;color:var(--accent-2)}
.an-al-side{display:grid;gap:16px;min-width:0}
.an-al-chart .an-chart{height:320px}
.an-feed header{display:flex;justify-content:space-between;align-items:baseline;gap:8px;flex-wrap:wrap}
.an-feed ol{list-style:none;margin:8px 0 0;padding:0;max-height:560px;overflow-y:auto}
.an-feed li{display:grid;grid-template-columns:auto 1fr;gap:10px;padding:10px 8px;border-top:1px solid var(--line);cursor:pointer;border-radius:6px}
.an-feed li:hover,.an-feed li.on{background:var(--bg)}
.an-feed li.on{box-shadow:inset 3px 0 0 var(--accent)}
.an-feed li > .an-sev{align-self:start;margin-top:2px}
.an-feed-top{display:flex;justify-content:space-between;gap:8px;font-size:14px}
.an-feed-top b{font-weight:600;min-width:0;overflow-wrap:anywhere}
.an-feed time{font-size:12px;color:var(--muted);white-space:nowrap}
.an-feed li p{margin:2px 0;font-size:13px}
.an-feed li small{font-size:12px;color:var(--accent-2)}

@media (max-width:960px){
  .w4,.w5,.w6,.w7,.w8{grid-column:span 12}
  .an-hyp,.an-rep,.an-al{grid-template-columns:1fr}
  .an-hyp-list,.an-rep-list{flex-direction:row;overflow-x:auto;scrollbar-width:thin;padding-bottom:4px}
  .an-hyp-item,.an-rep-list a{min-width:230px;flex:1 0 230px}
}
@media (max-width:640px){
  .an-hero{padding-top:22px}
  .an-lead{font-size:16px}
  .an-split{grid-template-columns:1fr;gap:0}
  .an-kpis{grid-template-columns:1fr 1fr;gap:8px}
  .an-kpi{padding:10px 12px}
  .an-kpi-v{font-size:18px}
  .an-card{padding:14px 12px 8px}
  .an-filters{width:100%}
  .an-f{flex:1 1 140px}
  .an-f select{min-width:0;width:100%}
  .an-chart{height:260px}.an-chart.lg{height:380px}.an-map{height:220px}
  .an-tabs a{padding:10px 10px}
}
@media print{
  .sx-top,.sx-foot,.an-tabs,.an-tab-lead,.an-rep-list,.an-rep-actions,.an-hero .an-lead,.an-hero-top{display:none!important}
  body{background:#fff;font-size:12px}
  .an-hero{padding-top:0}.an-hero h1{display:none}
  .an-rep{display:block}
  .an-card{box-shadow:none;border:0;padding:0}
  .an-print-head{display:block;font-size:11px;color:#666;margin-bottom:8px}
  .an-table{font-size:11px}.an-table td,.an-table th{padding:4px 6px}
  .an-table-wrap{overflow:visible}
}
@media (max-width:640px){
  .an-top .sx-nav{order:3;flex-basis:100%;gap:14px}
  .an-top .sx-nav a{font-size:14px}
  .an-top .sx-lang{margin-left:auto}
  .an-tabs{display:grid;grid-template-columns:1fr 1fr;gap:0;border-bottom:0}
  .an-tabs a{border:1px solid var(--line);margin:0 -1px -1px 0;white-space:normal;font-size:14px;line-height:1.25}
  .an-tabs a.on{border-color:var(--line);box-shadow:inset 0 -2px 0 var(--accent);background:var(--surface)}
}
@media (max-width:640px){
  .an-feed li{grid-template-columns:1fr;gap:4px}
  .an-feed li > .an-sev{justify-self:start}
  .an-top{top:auto;position:static}
}
@media (max-width:640px){
  .an-table th:first-child,.an-table td:first-child{position:sticky;left:0;background:var(--surface);z-index:1;
    white-space:normal;min-width:120px;max-width:150px;box-shadow:1px 0 0 var(--line)}
  .an-table{font-size:13px}
}
