/* Публічна сторінка: SSR-каркас + графіки (ТЗ розд. 9). */
header.site {
  background: var(--surface); border-bottom: 1px solid var(--line);
  padding: 14px 20px; display: flex; gap: 16px; align-items: baseline; flex-wrap: wrap;
}
header.site h1 { font-size: 20px; margin: 0; }
header.site .desc { color: var(--muted); font-size: 13px; }
header.site .spacer { margin-left: auto; }

main.page { padding: 16px 20px 48px; max-width: 1700px; margin: 0 auto; }

.filterbar {
  display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 14px; margin-bottom: 14px;
}
.filterbar .f { flex: 0 1 220px; }
.filterbar label { margin-top: 0; }
.filterbar .actions { margin-left: auto; display: flex; gap: 8px; align-items: flex-end; }

.grid12 { display: grid; grid-template-columns: repeat(12, 1fr); gap: 12px; align-items: stretch; }
/* Кожна комірка — колонка: віджет усередині розтягується на всю її висоту. */
.grid12 > div { display: flex; flex-direction: column; }
@media (max-width: 900px) { .grid12 { display: block; } .grid12 > div { margin-bottom: 12px; } }

.widget {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden;
}
.widget > header { padding: 9px 12px 4px; }
.widget > header h2 { font-size: 14px; margin: 0; }
.widget > header .sub { color: var(--muted); font-size: 12px; }
.widget .chart { flex: 1; min-height: 160px; }
.widget .tools {
  padding: 4px 10px 8px; display: flex; gap: 10px; align-items: center;
  font-size: 11.5px; color: var(--muted); flex-wrap: wrap;
}
.widget .tools a, .widget .tools button {
  font-size: 11.5px; padding: 2px 8px; background: none; border: 1px solid var(--line);
  color: var(--muted); border-radius: 5px; cursor: pointer; text-decoration: none;
}
.widget .state { padding: 20px 14px; color: var(--muted); font-size: 13px; text-align: center; }
.widget .state.error { color: var(--bad); }
.widget .note { font-size: 11.5px; margin: 0 10px 8px; }

.kpi { padding: 10px 14px 16px; }
.kpi .value { font-size: 34px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi .delta { font-size: 13px; margin-top: 4px; }
.kpi .delta.up { color: var(--ok); }
.kpi .delta.down { color: var(--bad); }


footer.site {
  border-top: 1px solid var(--line); padding: 14px 20px; color: var(--muted);
  font-size: 12px; display: flex; gap: 16px; flex-wrap: wrap;
}
.stale-banner { background: var(--warn-bg); color: var(--warn); padding: 8px 14px;
  border-radius: var(--radius); margin-bottom: 12px; font-size: 13px; }
.pager { display: flex; gap: 6px; margin-bottom: 12px; }
.pager a { padding: 4px 11px; border: 1px solid var(--line); border-radius: 6px;
  text-decoration: none; background: var(--surface); font-size: 13px; }
.pager a.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

body.embed header.site, body.embed footer.site { display: none; }
body.embed main.page { padding: 8px; }

/* Розкладка полотна: позиції блоків — класами, не атрибутом style
   (CSP style-src 'self'). x -> .cs-N, w -> .cw-N, h -> .ch-N. */
.cs-1 { grid-column-start: 1; }
.cs-2 { grid-column-start: 2; }
.cs-3 { grid-column-start: 3; }
.cs-4 { grid-column-start: 4; }
.cs-5 { grid-column-start: 5; }
.cs-6 { grid-column-start: 6; }
.cs-7 { grid-column-start: 7; }
.cs-8 { grid-column-start: 8; }
.cs-9 { grid-column-start: 9; }
.cs-10 { grid-column-start: 10; }
.cs-11 { grid-column-start: 11; }
.cs-12 { grid-column-start: 12; }
.cw-1 { grid-column-end: span 1; }
.cw-2 { grid-column-end: span 2; }
.cw-3 { grid-column-end: span 3; }
.cw-4 { grid-column-end: span 4; }
.cw-5 { grid-column-end: span 5; }
.cw-6 { grid-column-end: span 6; }
.cw-7 { grid-column-end: span 7; }
.cw-8 { grid-column-end: span 8; }
.cw-9 { grid-column-end: span 9; }
.cw-10 { grid-column-end: span 10; }
.cw-11 { grid-column-end: span 11; }
.cw-12 { grid-column-end: span 12; }
.ch-1 { min-height: 36px; }
.ch-2 { min-height: 72px; }
.ch-3 { min-height: 108px; }
.ch-4 { min-height: 144px; }
.ch-5 { min-height: 180px; }
.ch-6 { min-height: 216px; }
.ch-7 { min-height: 252px; }
.ch-8 { min-height: 288px; }
.ch-9 { min-height: 324px; }
.ch-10 { min-height: 360px; }
.ch-11 { min-height: 396px; }
.ch-12 { min-height: 432px; }
.ch-13 { min-height: 468px; }
.ch-14 { min-height: 504px; }
.ch-15 { min-height: 540px; }
.ch-16 { min-height: 576px; }
.ch-17 { min-height: 612px; }
.ch-18 { min-height: 648px; }
.ch-19 { min-height: 684px; }
.ch-20 { min-height: 720px; }
.ch-21 { min-height: 756px; }
.ch-22 { min-height: 792px; }
.ch-23 { min-height: 828px; }
.ch-24 { min-height: 864px; }
.ch-25 { min-height: 900px; }
.ch-26 { min-height: 936px; }
.ch-27 { min-height: 972px; }
.ch-28 { min-height: 1008px; }
.ch-29 { min-height: 1044px; }
.ch-30 { min-height: 1080px; }
.ch-31 { min-height: 1116px; }
.ch-32 { min-height: 1152px; }
.ch-33 { min-height: 1188px; }
.ch-34 { min-height: 1224px; }
.ch-35 { min-height: 1260px; }
.ch-36 { min-height: 1296px; }
.ch-37 { min-height: 1332px; }
.ch-38 { min-height: 1368px; }
.ch-39 { min-height: 1404px; }
.ch-40 { min-height: 1440px; }

@media (max-width: 900px) {
  /* На вузькому екрані сітка розпадається в стовпчик — позиції не застосовуються. */
  .grid12 > * { grid-column: auto !important; }
}

.widget .tools .grow { flex: 1; }
.widget.fill { flex: 1; }
.md-block { padding: 12px 14px; }
