/* «Расход» (templates/costs.html): сегодня, лимиты разделов, сервисы, две
   недели. Цвет раздела один на всей странице — --c у .a-*. */
.a-people   { --c: 142 52% 42%; }
.a-network  { --c: 214 72% 56%; }
.a-kol      { --c: 266 52% 60%; }
.a-outreach { --c: 28 88% 54%; }
.a-youtube  { --c: 356 70% 56%; }
.a-vk       { --c: 204 88% 50%; }
.a-instagram { --c: 326 68% 56%; }
.a-facebook { --c: 232 62% 60%; }
.a-collect  { --c: 186 56% 40%; }
.a-communities { --c: 48 82% 46%; }
:root[data-theme="dark"] .a-people  { --c: 142 50% 52%; }
:root[data-theme="dark"] .a-collect { --c: 186 55% 50%; }

.cx-block, .cx-today {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card);
  padding: var(--sp-4) var(--sp-6) var(--sp-6); margin-bottom: var(--sp-4);
}
.cx-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; margin-bottom: var(--sp-3); }
.cx-head h2 { font-size: var(--s2); font-weight: 650; margin: 0; }
.cx-sub { font-size: var(--s0); color: var(--muted); }

/* --- сегодня ---------------------------------------------------------------- */
.cx-today { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--sp-6); align-items: stretch; padding-top: var(--sp-6); }
.cx-label { display: block; font-size: var(--s1); color: var(--muted); }
.cx-big-row { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 14px; margin: 2px 0 14px; }
.cx-big { display: block; font-size: 44px; line-height: 1.05; font-weight: 700; letter-spacing: -0.035em; font-variant-numeric: tabular-nums; }
.cx-vs { font-size: var(--s1); color: var(--muted); font-variant-numeric: tabular-nums; }
.cx-stack { display: flex; gap: 2px; height: 10px; border-radius: 5px; overflow: hidden; background: var(--tint); }
.cx-stack > span { flex-basis: 0; min-width: 4px; background: hsl(var(--c)); }
.cx-stack-empty { flex: 1; background: transparent !important; }
.cx-legend { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: var(--s1); color: var(--muted); }
.cx-legend li { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.cx-legend i { width: 8px; height: 8px; border-radius: 2px; background: hsl(var(--c)); }
.cx-legend b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.cx-side { display: grid; grid-template-columns: repeat(2, auto); align-content: start; gap: 14px 32px;
  padding-left: var(--sp-6); border-left: 1px solid var(--line); }
.cx-kpi { display: flex; flex-direction: column; gap: 2px; min-width: 120px; }
.cx-mid { font-size: 28px; line-height: 1.15; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.cx-per-day { font-size: var(--s1); color: var(--muted); font-variant-numeric: tabular-nums; }
.cx-delta { align-self: flex-start; display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px;
  font-size: var(--s0); font-weight: 600; font-variant-numeric: tabular-nums; cursor: help; }
.cx-delta.is-up { color: hsl(var(--t-warning)); background: hsl(var(--t-warning) / .14); }
.cx-delta.is-down { color: hsl(var(--t-success, 142 60% 40%)); background: hsl(var(--t-success, 142 60% 40%) / .12); }
.cx-pill { display: inline-flex; align-items: center; gap: 5px; margin-top: 10px; padding: 3px 10px;
  border-radius: 999px; font-size: var(--s0); font-weight: 600; cursor: help;
  color: var(--muted); background: var(--tint); }
.cx-pill.is-free { color: hsl(var(--t-success, 142 60% 40%)); background: hsl(var(--t-success, 142 60% 40%) / .12); }
.cx-pill.is-paid { color: hsl(var(--t-warning)); background: hsl(var(--t-warning) / .14); }
.cx-big-row .cx-pill, .cx-history-head .cx-pill { margin: 0; align-self: center; font-variant-numeric: tabular-nums; }
.cx-num small { display: block; font-size: var(--s0); color: var(--muted); }

/* --- лимиты разделов ------------------------------------------------------- */
.cx-areas { list-style: none; margin: 0; padding: 0; }
.cx-area {
  display: grid; grid-template-columns: 32px minmax(180px, 240px) minmax(120px, 1fr) 132px minmax(0, max-content) 32px;
  align-items: center; gap: 14px; padding: 12px 0; border-top: 1px solid var(--line);
}
.cx-area:first-child { border-top: 0; padding-top: 4px; }
.cx-ic {
  width: 32px; height: 32px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center;
  color: hsl(var(--c, var(--t-muted-foreground))); background: hsl(var(--c, var(--t-muted-foreground)) / .12);
}
.cx-name { display: flex; flex-direction: column; min-width: 0; font-weight: 600; font-size: var(--s2); }
.cx-name a { color: inherit; text-decoration: none; }
.cx-name a:hover { text-decoration: underline; text-underline-offset: 3px; }
.cx-name small { font-weight: 400; font-size: var(--s0); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cx-meter { position: relative; display: block; height: 8px; border-radius: 4px; background: var(--tint); overflow: hidden; }
/* Отметка «обычно за день» на полосе лимита — вместо строки текста. */
.cx-usual { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; border-radius: 1px;
  background: hsl(var(--t-foreground) / .45); cursor: help; }
.cx-meter > span { display: block; height: 100%; min-width: 3px; border-radius: 4px; background: hsl(var(--c, var(--t-primary))); transition: width .5s var(--nx-ease, ease); }
.cx-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cx-num b { font-size: var(--s2); font-weight: 650; }
.cx-num span { font-size: var(--s1); color: var(--muted); }
.cx-state { display: flex; justify-content: flex-end; }
.cx-chip {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 11px; font-size: var(--s0);
  font-weight: 500; white-space: nowrap; color: hsl(var(--v)); background: hsl(var(--v) / .12);
}
.cx-chip.v-bad { --v: var(--t-destructive); }
.cx-chip.v-none { --v: var(--t-muted-foreground); }
.cx-area.is-near .cx-num b { color: hsl(var(--t-warning)); }
.cx-area.is-out .cx-meter > span { background: hsl(var(--t-destructive)); }
.cx-area.is-out .cx-num b { color: hsl(var(--t-destructive)); }
.cx-area.is-stop { opacity: .6; }
.cx-area.is-stop:hover, .cx-area.is-stop:focus-within { opacity: 1; }
.cx-total { border-top: 1px dashed var(--line); margin-top: 4px; padding-top: 14px; }
.cx-total .cx-ic { color: var(--text); background: var(--tint); }
.cx-total .cx-meter > span { background: hsl(var(--t-foreground) / .55); }

/* правка лимита — маленькое окно у карандаша */
.cx-edit { position: relative; justify-self: end; }
.cx-edit > summary {
  list-style: none; cursor: pointer; width: 30px; height: 30px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center; color: var(--muted);
}
.cx-edit > summary::-webkit-details-marker { display: none; }
.cx-edit > summary:hover, .cx-edit[open] > summary { background: var(--tint); color: var(--text); }
.cx-pop {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; display: grid; gap: 8px;
  min-width: 250px; padding: 12px; border: 1px solid var(--line-ctl); border-radius: 12px;
  background: hsl(var(--t-popover, var(--t-card))); box-shadow: var(--shadow);
}
.cx-pop-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; }
.cx-pop-row form { margin: 0; }
.cx-pop-sub { padding-top: 8px; border-top: 1px solid var(--line); }
.cx-pop-note { margin: 0; font-size: var(--s1); max-width: 260px; }
.cx-money { display: inline-flex; align-items: center; gap: 6px; font-size: var(--s1); color: var(--muted); }
.cx-money input { width: 96px; height: var(--h-sm, 30px); }
.cx-pop input[type="password"] { flex: 1; min-width: 220px; height: var(--h-sm, 30px); }

/* --- сервисы ------------------------------------------------------------------ */
.cx-services { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.cx-svc {
  display: flex; flex-direction: column; gap: 8px; padding: 14px 16px 12px;
  border: 1px solid var(--line); border-radius: 12px; background: hsl(var(--t-background) / .4);
}
.cx-svc > header { display: flex; align-items: center; gap: 8px; }
.cx-svc h3 { margin: 0; font-size: var(--s2); font-weight: 650; }
.cx-svc-ic { width: 26px; height: 26px; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center; background: var(--tint); color: var(--text); }
.cx-svc.a-collect .cx-svc-ic { color: hsl(var(--c)); background: hsl(var(--c) / .12); }
.cx-svc-what { font-size: var(--s0); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.cx-dot { width: 8px; height: 8px; border-radius: 50%; margin-left: auto; background: hsl(var(--v)); box-shadow: 0 0 0 3px hsl(var(--v) / .15); }
.cx-dot.v-ok { --v: var(--t-success); }
.cx-dot.v-bad { --v: var(--t-destructive); }
.cx-dot.v-none { --v: var(--t-muted-foreground); }
.cx-svc-num { margin: 2px 0 0; font-size: var(--s1); color: var(--muted); }
.cx-svc-num b { font-size: var(--s3); color: var(--text); font-weight: 650; font-variant-numeric: tabular-nums; margin-right: 2px; }
.cx-svc-foot { margin: 0; font-size: var(--s0); color: var(--muted); }
.cx-svc.is-out .cx-meter > span { background: hsl(var(--t-destructive)); }
.cx-svc.is-idle { opacity: .7; }
.cx-warn { margin: 0; font-size: var(--s0); color: hsl(var(--t-destructive)); display: flex; gap: 6px; align-items: center; }
.cx-svc > footer { display: flex; align-items: center; gap: 6px; margin-top: auto; padding-top: 4px; }
.cx-btn {
  list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px;
  border-radius: 8px; border: 1px solid var(--line-ctl); font-size: var(--s1); font-weight: 500;
  color: var(--text); text-decoration: none; background: var(--card);
}
.cx-btn::-webkit-details-marker { display: none; }
.cx-btn:hover { background: var(--tint); color: var(--text); }
.cx-keyedit { justify-self: start; }
.cx-keyedit > summary.cx-btn { width: auto; height: 30px; }
.cx-keyedit .cx-pop { left: 0; right: auto; min-width: 320px; }

/* --- две недели и на что ушло --------------------------------------------- */
.cx-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: var(--sp-4); align-items: stretch; }
.cx-grid > .cx-block { margin-bottom: var(--sp-4); display: flex; flex-direction: column; }
/* График: столбик — сумма дня по разделам, шкала круглым числом, пунктир —
   средний день. Подсказка над столбиком — из скрытого .cx-tip-src. */
.cx-facts { display: flex; flex-wrap: wrap; gap: 10px 36px; margin-bottom: var(--sp-4); }
.cx-facts b { display: block; font-size: 22px; line-height: 1.2; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.cx-facts small { font-size: var(--s0); color: var(--muted); }
.cx-plot { position: relative; flex: 1; display: flex; flex-direction: column; padding-left: 44px; }
.cx-axis { position: absolute; left: 0; top: 0; width: 38px; height: 200px; pointer-events: none; }
.cx-axis span { position: absolute; right: 0; transform: translateY(50%); font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.cx-bars { position: relative; display: flex; align-items: flex-end; gap: 6px; height: 200px;
  background: linear-gradient(to bottom, var(--line) 1px, transparent 1px) 0 0 / 100% 50%;
  border-bottom: 1px solid var(--line); }
.cx-col { position: relative; flex: 1; height: 100%; display: flex; align-items: flex-end; justify-content: center; outline: none; cursor: default; }
.cx-col::before { content: ""; position: absolute; inset: 0 -3px; border-radius: 6px; background: transparent; transition: background .15s; }
.cx-col.is-hot::before, .cx-col:focus-visible::before { background: hsl(var(--t-foreground) / .05); }
.cx-col-bar { position: relative; width: 100%; max-width: 30px; min-height: 2px; display: flex; flex-direction: column-reverse;
  gap: 1px; border-radius: 6px 6px 2px 2px; overflow: hidden; transition: opacity .15s, transform .2s var(--nx-ease, ease); transform-origin: bottom; }
.cx-col-bar > span { display: block; flex-basis: 0; min-height: 2px; background: hsl(var(--c)); }
.cx-col.is-empty .cx-col-bar { background: var(--tint); }
.cx-bars.has-hot .cx-col:not(.is-hot) .cx-col-bar { opacity: .45; }
.cx-col.is-hot .cx-col-bar { transform: scaleY(1.015); }
.cx-bars.is-dense { gap: 3px; }
.cx-bars.is-dense .cx-col-bar { border-radius: 3px 3px 1px 1px; }
.cx-avg { position: absolute; left: 0; right: 0; height: 0; border-top: 1.5px dashed hsl(var(--t-foreground) / .35); pointer-events: none; z-index: 1; }
.cx-avg span { position: absolute; right: 0; bottom: 3px; font-size: 10px; letter-spacing: .02em; color: var(--muted);
  background: var(--card); padding: 0 4px; border-radius: 4px; }
.cx-days { display: flex; gap: 6px; padding-top: 6px; }
.cx-bars.is-dense + .cx-days { gap: 3px; }
.cx-days span { flex: 1; text-align: center; font-size: var(--s0); color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.cx-days span.is-today { color: var(--text); font-weight: 650; }
.cx-tip { position: absolute; left: 0; top: 0; z-index: 5; width: max-content; min-width: 200px; max-width: 280px;
  padding: 10px 12px; border-radius: 12px; pointer-events: none;
  background: hsl(var(--t-popover, var(--t-card))); border: 1px solid var(--line-ctl, var(--line)); box-shadow: var(--shadow);
  font-size: var(--s1); }
.cx-tip p { margin: 0; }
.cx-tip-h { display: flex; justify-content: space-between; gap: 16px; font-weight: 600; margin-bottom: 6px !important; }
.cx-tip-h b { font-variant-numeric: tabular-nums; }
.cx-tip ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.cx-tip li { display: flex; align-items: center; gap: 8px; }
.cx-tip li span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.cx-tip li b { font-weight: 600; font-variant-numeric: tabular-nums; }
.cx-tip-list i { width: 8px; height: 8px; border-radius: 2px; background: hsl(var(--c)); flex: none; }
.cx-tip-ops { margin-top: 8px !important; padding-top: 8px !important; border-top: 1px solid var(--line); }
.cx-tip-ops li span { color: var(--text); }
.cx-tip-none { color: var(--muted); }
.cx-legend-chart { margin-top: var(--sp-4); }
/* История: заголовок и переключатель периода над графиком и списком. */
.cx-history-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; margin: var(--sp-6) 0 var(--sp-3); }
.cx-history-head h2 { margin: 0; font-size: var(--s3); font-weight: 700; letter-spacing: -0.01em; }
.cx-period { margin-left: auto; display: inline-flex; padding: 3px; gap: 2px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--card); }
.cx-period a { padding: 5px 12px; border-radius: 7px; font-size: var(--s1); color: var(--muted); text-decoration: none;
  white-space: nowrap; transition: background .15s, color .15s; }
.cx-period a:hover { color: var(--text); }
.cx-period a.is-on { color: var(--text); font-weight: 600; background: var(--tint); }
.cx-ops { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.cx-ops-top { display: flex; align-items: center; gap: 8px; font-size: var(--s1); margin-bottom: 5px; }
.cx-ops-top i { width: 8px; height: 8px; border-radius: 2px; flex: none; background: hsl(var(--c, var(--t-muted-foreground))); }
.cx-ops-top span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cx-ops-top b { font-weight: 600; font-variant-numeric: tabular-nums; }
.cx-ops-top em { font-style: normal; width: 36px; text-align: right; font-size: var(--s0); color: var(--muted); font-variant-numeric: tabular-nums; }
.cx-share { display: block; height: 5px; border-radius: 3px; background: var(--tint); overflow: hidden; }
.cx-share > span { display: block; height: 100%; background: hsl(var(--c, var(--t-muted-foreground))); border-radius: 3px; }
.cx-empty { color: var(--muted); font-size: var(--s1); margin: 0; }

@media (max-width: 980px) {
  .cx-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .cx-block, .cx-today { padding: var(--sp-4); }
  .cx-today { grid-template-columns: 1fr; gap: var(--sp-3); }
  .cx-side { padding: var(--sp-3) 0 0; border-left: 0; border-top: 1px solid var(--line); }
  .cx-big { font-size: 36px; }
  .cx-mid { font-size: 24px; }
  .cx-area { grid-template-columns: 32px minmax(0, 1fr) auto 30px; grid-template-areas: "ic name num edit" "ic meter meter meter" "ic state state state"; gap: 6px 10px; }
  .cx-area > .cx-state { justify-content: flex-start; }
  .cx-area > .cx-state:empty { display: none; }
  .cx-area > .cx-ic { grid-area: ic; align-self: start; }
  .cx-area > .cx-name { grid-area: name; }
  .cx-area > .cx-meter { grid-area: meter; }
  .cx-area > .cx-num { grid-area: num; }
  .cx-area > .cx-state { grid-area: state; }
  .cx-area > .cx-edit { grid-area: edit; }
  .cx-pop { right: -4px; min-width: min(300px, calc(100vw - 48px)); }
  .cx-keyedit .cx-pop { min-width: min(320px, calc(100vw - 48px)); }
  .cx-pop input[type="password"] { min-width: 0; width: 100%; }
  .cx-bars, .cx-axis { height: 160px; }
  .cx-bars, .cx-days { gap: 3px; }
  .cx-bars.is-dense, .cx-bars.is-dense + .cx-days { gap: 1px; }
  .cx-bars.is-dense + .cx-days span { font-size: 10px; }
  .cx-facts { gap: 8px 24px; }
  .cx-period { margin-left: 0; width: 100%; }
  .cx-period a { flex: 1; text-align: center; padding: 6px 4px; }
}
@media (prefers-reduced-motion: reduce) {
  .cx-meter > span, .cx-col-bar, .cx-col::before { transition: none; }
}
