/* Общие стили каркаса (WP-00). Стили раздела — в web/modules/<id>.css (export const css = true). */
:root {
  --ink: #121a2b;
  --ink-2: #24304a;
  --muted: #5f6a80;
  --line: #e4e8ef;
  --surface: #ffffff;
  --canvas: #f3f5f8;
  --accent: #4263eb;
  --accent-soft: #eef1ff;
  --lime: #c8ff5c;
  --c1: #4263eb;
  --c2: #15b8c2;
  --c3: #ff9f43;
  --c4: #1fab68;
  --c5: #ef5c5c;
  --c6: #8b5cf6;
  --plan: #c6cede;
  --warn-bg: #fff7e6;
  --warn-line: #f5d9a8;
  --bad-bg: #fff0f0;
  --bad-line: #f3c4c4;
  --ok: #1fab68;
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow: 0 8px 25px rgba(20, 31, 53, .05);
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body { margin: 0; font: 14px/1.45 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif; color: var(--ink); background: var(--canvas); -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums; }
body.modal-open { overflow: hidden; }
button, input, select { font: inherit; color: inherit; }
svg { fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
a { color: var(--accent); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --- оболочка --- */
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 50; display: flex; flex-direction: column; width: 250px; padding: 20px 14px 16px; color: #eef2fb; background: linear-gradient(180deg, #11192b 0%, #17223b 62%, #111a2d 100%); }
.brand { display: flex; align-items: center; gap: 11px; padding: 0 6px 14px; }
.brand-mark { display: grid; place-items: center; width: 36px; height: 36px; flex: 0 0 36px; color: #11192b; background: var(--lime); border-radius: 11px; font-weight: 900; font-size: 18px; }
.brand-copy { display: flex; min-width: 0; flex-direction: column; line-height: 1.15; }
.brand-copy b { font-size: 14px; }
.brand-copy span { margin-top: 4px; color: #9aa8c2; font-size: 12px; }
.nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav-group { margin: 14px 10px 5px; color: #8190ab; font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.nav-item { display: flex; align-items: center; gap: 11px; min-height: 42px; padding: 8px 10px; color: #b7c1d4; border-radius: 11px; text-decoration: none; transition: background .15s ease; }
.nav-item:hover { color: #fff; background: rgba(255, 255, 255, .06); }
.nav-item.active { color: #fff; background: rgba(89, 112, 255, .22); box-shadow: inset 3px 0 0 #7890ff; }
.nav-item svg { width: 19px; height: 19px; flex: 0 0 19px; }
.nav-item span { font-size: 13.5px; font-weight: 650; }
.nav-item.locked { color: #7c89a1; }
.nav-item .nav-lock { width: 15px; height: 15px; margin-left: auto; }

.main { min-width: 0; margin-left: 250px; }
.topbar { position: sticky; top: 0; z-index: 35; display: flex; align-items: center; gap: 14px; min-height: 66px; padding: 10px 28px; background: rgba(255, 255, 255, .96); border-bottom: 1px solid var(--line); backdrop-filter: blur(12px); }
.title-block { display: flex; min-width: 0; flex-direction: column; }
.title-block h1 { margin: 0; font-size: 21px; letter-spacing: -.03em; line-height: 1.15; }
.fresh { display: flex; align-items: center; gap: 6px; margin-top: 3px; color: var(--muted); font-size: 12px; }
.dot { display: inline-block; width: 7px; height: 7px; flex: 0 0 7px; background: #b8c0cf; border-radius: 50%; }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--c3); }
.top-actions { display: flex; align-items: center; gap: 9px; margin-left: auto; }
.user-chip { color: var(--muted); font-size: 12px; white-space: nowrap; }
.icon-button { display: none; width: 42px; height: 42px; flex: 0 0 42px; background: #fff; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.icon-button span { display: block; width: 16px; height: 1.5px; margin: 3px auto; background: currentColor; }
.mobile-scrim { display: none; }

.button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 8px 14px; border: 1px solid transparent; border-radius: 10px; cursor: pointer; font-size: 13px; font-weight: 700; text-decoration: none; transition: .15s ease; }
.button.primary { color: #fff; background: var(--accent); }
.button.primary:hover { background: #3454dc; }
.button.ghost { color: var(--ink-2); background: #fff; border-color: var(--line); }
.button.ghost:hover { border-color: #bac3d3; }
.button.small { min-height: 36px; padding: 6px 11px; font-size: 12.5px; }
.button:disabled { cursor: default; opacity: .45; }

.banners { display: grid; gap: 8px; padding: 12px 28px 0; }
.banners:empty { display: none; }
.banner { padding: 10px 14px; border: 1px solid; border-radius: var(--radius-sm); font-size: 13px; }
.banner.warn { background: var(--warn-bg); border-color: var(--warn-line); }
.banner.bad { background: var(--bad-bg); border-color: var(--bad-line); }
.banner.muted { color: var(--muted); background: #f7f8fa; border-color: var(--line); }

/* --- глобальные фильтры --- */
.filterbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 9px; margin: 14px 28px 0; padding: 10px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius-md); }
.period { display: flex; align-items: stretch; min-height: 44px; background: #f6f8fa; border-radius: var(--radius-sm); }
.period .step { width: 40px; background: transparent; border: 0; cursor: pointer; font-size: 20px; }
.period .step:disabled { cursor: default; opacity: .3; }
.period-label { min-width: 150px; padding: 0 6px; background: transparent; border: 0; cursor: pointer; font-weight: 750; white-space: nowrap; }
.period-label small { color: var(--muted); font-weight: 600; }
.range { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; }
.range label, .field { display: flex; min-width: 0; flex-direction: column; gap: 2px; padding: 5px 10px; background: #f6f8fa; border-radius: var(--radius-sm); }
.range span, .field span { color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.field { flex: 1 1 150px; max-width: 240px; }
.field select, .range input { min-height: 26px; padding: 0; overflow: hidden; background: transparent; border: 0; outline: 0; font-weight: 650; text-overflow: ellipsis; }
.field:focus-within, .range label:focus-within { box-shadow: inset 0 0 0 1px #aebcff; background: #fff; }
.reset { width: 44px; height: 44px; margin-left: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm); cursor: pointer; font-size: 18px; }

/* --- страница раздела --- */
.page { padding: 18px 28px 48px; }
.view { max-width: 1440px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.page-head h2 { margin: 0 0 4px; font-size: 24px; letter-spacing: -.035em; }
.page-head p { margin: 0; color: var(--muted); }
.basis { font-size: 12.5px; }
.page-head, .page-head > div { min-width: 0; }
.one-line { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.loading, .empty { padding: 28px; color: var(--muted); text-align: center; background: #fff; border: 1px dashed var(--line); border-radius: var(--radius-md); }
.empty.error { color: #a33; border-color: var(--bad-line); background: var(--bad-bg); }
.hint { color: var(--muted); font-size: 12.5px; }
.badge { display: inline-block; padding: 3px 8px; border-radius: 6px; font-size: 11.5px; font-weight: 800; }
.badge.muted { color: var(--ink-2); background: #eef1f5; }
.badge.ok { color: #116b40; background: #e3f6ec; }
.badge.warn { color: #8a5600; background: var(--warn-bg); }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 14px; }
.kpi { display: flex; min-width: 0; flex-direction: column; gap: 4px; padding: 15px 17px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius-md); }
.kpi.clickable { cursor: pointer; }
.kpi.clickable:hover { border-color: #9eacf8; }
.kpi.featured { color: #fff; background: linear-gradient(140deg, #314ce0, #6679f4); border-color: transparent; }
.kpi.warning { background: #fff9f5; border-color: #f6d8c0; }
.kpi-label { color: var(--muted); font-size: 11.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.kpi-value { font-size: 25px; letter-spacing: -.035em; }
.kpi small { color: var(--muted); font-size: 12.5px; }
.kpi.featured .kpi-label, .kpi.featured small { color: #dce2ff; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
.panel { min-width: 0; margin-bottom: 14px; padding: 18px 19px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.grid-2 > .panel { margin-bottom: 0; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.panel-head h3 { margin: 3px 0 0; font-size: 16px; letter-spacing: -.02em; }
.section-label { color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
[role="button"] { cursor: pointer; }

.table-scroll { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { padding: 8px 10px; color: var(--muted); font-size: 11.5px; font-weight: 800; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--line); }
.data-table td { padding: 9px 10px; border-bottom: 1px solid #f0f2f6; white-space: nowrap; }
.data-table .num { text-align: right; }
.data-table tr[role="button"]:hover td { background: #f6f8ff; }

/* --- графики (core/charts.js) --- */
.chart { display: block; max-width: 100%; overflow: visible; }
.chart .grid { stroke: #edf0f4; stroke-width: 1; }
.chart .axis { fill: var(--muted); stroke: none; font-size: 11px; }
.chart .hit { fill: transparent; stroke: none; }
.chart .hit[role="button"]:hover, .chart .hit:focus-visible { fill: rgba(66, 99, 235, .06); outline: none; }
.chart .bar { stroke: none; }
.chart .line { fill: none; stroke-width: 2.2; }
.chart .line.dashed { stroke-dasharray: 5 4; stroke-width: 1.6; }
.chart .dot { stroke: #fff; stroke-width: 1.5; }
.chart.donut .seg-base, .chart.donut .seg { fill: none; stroke-width: 6; }
.chart.donut .seg-base { stroke: #eef1f5; }
.chart.donut .seg { transform: rotate(-90deg); transform-origin: 21px 21px; }
.chart.donut .seg[role="button"]:hover { stroke-width: 7.5; }
.donut-value { fill: var(--ink); stroke: none; font-size: 7px; font-weight: 800; text-anchor: middle; }
.donut-label { fill: var(--muted); stroke: none; font-size: 3.6px; text-anchor: middle; }
.s1 { fill: var(--c1); stroke: var(--c1); }
.s2 { fill: var(--c2); stroke: var(--c2); }
.s3 { fill: var(--c3); stroke: var(--c3); }
.s4 { fill: var(--c4); stroke: var(--c4); }
.s5 { fill: var(--c5); stroke: var(--c5); }
.s6 { fill: var(--c6); stroke: var(--c6); }
.plan { fill: var(--plan); stroke: var(--plan); }
.muted-series { fill: #dfe3ea; stroke: #b8c0cf; }
path.line.s1, path.line.s2, path.line.s3, path.line.s4, path.line.s5, path.line.s6, path.line.plan { fill: none; }
.spark { display: block; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; color: var(--muted); font-size: 12px; }
.legend i { display: inline-block; width: 10px; height: 10px; margin-right: 5px; border-radius: 3px; vertical-align: -1px; }
.legend .s1 { background: var(--c1); } .legend .s2 { background: var(--c2); } .legend .s3 { background: var(--c3); }
.legend .s4 { background: var(--c4); } .legend .s5 { background: var(--c5); } .legend .s6 { background: var(--c6); }
.legend .plan { background: var(--plan); }

/* --- модалка, детализация, методология --- */
.modal-backdrop { position: fixed; inset: 0; z-index: 1100; display: none; align-items: center; justify-content: center; padding: 22px; background: rgba(10, 16, 29, .6); }
.modal-backdrop.open { display: flex; }
.modal { position: relative; width: min(94vw, 660px); max-height: calc(100vh - 44px); overflow: auto; padding: 28px; background: #fff; border-radius: 22px; box-shadow: 0 30px 90px rgba(6, 12, 25, .32); }
.modal.wide { width: min(96vw, 1180px); }
.modal-close { position: absolute; top: 14px; right: 14px; display: grid; place-items: center; width: 40px; height: 40px; color: var(--muted); background: #f1f3f6; border: 0; border-radius: 10px; cursor: pointer; font-size: 22px; }
.modal h2 { margin: 6px 48px 8px 0; font-size: 22px; letter-spacing: -.03em; }
.modal-kicker { color: var(--accent); font-size: 11px; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
.modal-lead { margin: 0 0 14px; color: var(--muted); }
.formula-list { display: grid; gap: 8px; margin: 0 0 14px; }
.formula-list div { padding: 10px 12px; background: #f6f8fa; border-radius: var(--radius-sm); }
.formula-list dt { font-weight: 800; }
.formula-list dd { margin: 3px 0 0; color: var(--ink-2); }
.method-note { margin-top: 12px; padding: 12px 14px; background: var(--accent-soft); border-radius: var(--radius-sm); }
.method-note p { margin: 4px 0 0; }
.local-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.local-filters label { display: flex; min-width: 150px; flex-direction: column; padding: 5px 10px; background: #f6f8fa; border-radius: var(--radius-sm); }
.local-filters span { color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.local-filters select { min-height: 26px; background: transparent; border: 0; }
.drill-totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin-bottom: 12px; }
.drill-totals div { padding: 10px 12px; background: #f6f8fa; border-radius: var(--radius-sm); }
.drill-totals span { display: block; color: var(--muted); font-size: 12px; }
.drill-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; }
.pager { display: flex; align-items: center; gap: 8px; }

.toast { position: fixed; right: 22px; bottom: 22px; z-index: 1200; max-width: min(360px, calc(100vw - 32px)); padding: 12px 15px; color: #fff; background: #17223a; border-radius: 12px; box-shadow: 0 18px 45px rgba(10, 18, 34, .25); opacity: 0; pointer-events: none; transform: translateY(12px); transition: .2s ease; font-size: 13px; }
.toast.show { opacity: 1; transform: none; }

/* --- вход --- */
.auth-page { display: grid; min-height: 100vh; place-items: center; padding: 16px; }
.auth-card { width: min(100%, 380px); padding: 30px 26px; background: #fff; border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); }
.auth-card h1 { margin: 16px 0 4px; font-size: 22px; letter-spacing: -.03em; }
.auth-lead { margin: 0 0 18px; color: var(--muted); }
.auth-form { display: grid; gap: 6px; }
.auth-form label { margin-top: 8px; font-size: 13px; font-weight: 700; }
.auth-form input { min-height: 44px; padding: 10px 12px; border: 1px solid #d3d9e4; border-radius: var(--radius-sm); font-size: 16px; }
.auth-form input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px rgba(66, 99, 235, .15); }
.auth-form .button { margin-top: 16px; min-height: 46px; font-size: 15px; }

/* --- адаптив --- */
@media (max-width: 1240px) {
  .sidebar { width: 220px; }
  .main { margin-left: 220px; }
}
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform .22s ease; }
  body.menu-open .sidebar { transform: none; box-shadow: 24px 0 60px rgba(8, 14, 25, .22); }
  body.menu-open .mobile-scrim { position: fixed; inset: 0; z-index: 45; display: block; background: rgba(9, 15, 27, .48); }
  .main { margin-left: 0; }
  .icon-button { display: block; }
  .topbar { padding-inline: 16px; }
  .banners { padding-inline: 16px; }
  .filterbar { margin-inline: 16px; }
  .page { padding-inline: 16px; }
  .grid-2 { grid-template-columns: 1fr; }
  .user-chip { display: none; }
}
@media (max-width: 680px) {
  .topbar { gap: 10px; min-height: 60px; padding: 8px 16px; }
  .title-block h1 { font-size: 18px; }
  .fresh { font-size: 11.5px; }
  #methodologyButton span { display: none; }
  #methodologyButton, #logoutButton { min-width: 40px; min-height: 40px; padding: 6px 10px; }
  .filterbar { gap: 7px; padding: 8px; }
  .period { flex: 1 1 100%; }
  .period-label { flex: 1; min-width: 0; }
  .field { flex: 1 1 calc(50% - 4px); max-width: none; }
  .reset { margin-left: 0; }
  .page { padding-top: 14px; }
  .page-head h2 { font-size: 21px; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi-value { font-size: 21px; }
  .panel { padding: 15px; }
  .modal-backdrop { padding: 0; }
  .modal, .modal.wide { width: 100%; max-height: 100vh; min-height: 100vh; padding: 22px 16px; border-radius: 0; }
  /* цели касания ≥ 40 px */
  .button.small { min-height: 40px; }
  .field select, .local-filters select { min-height: 40px; }
  .local-filters label { flex: 1 1 100%; }
  /* детализация на телефоне — карточки строк вместо таблицы с прокруткой вбок */
  .drill-table thead { display: none; }
  .drill-table, .drill-table tbody, .drill-table td { display: block; }
  .drill-table tr { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; padding: 10px 2px; border-bottom: 1px solid var(--line); }
  .drill-table td { min-width: 0; padding: 0; border: 0; white-space: normal; overflow-wrap: anywhere; }
  .drill-table td.num { text-align: left; }
  .drill-table td::before { content: attr(data-label); display: block; color: var(--muted); font-size: 11px; font-weight: 700; }
  .drill-table td.macro { grid-column: 1 / -1; }
  #modalBody td a { display: inline-flex; align-items: center; min-height: 40px; }
}
@media (max-width: 440px) {
  .kpis { grid-template-columns: 1fr; }
}
