/* Компоненты: баннеры, кнопки и поля, вкладки, карточки, пилюли, сигналы, таблицы, календарь, формы, модальное окно, тост, вход. */

/* ── Баннеры и вывод ── */
.banner { padding: 14px 16px; border-radius: 16px; display: flex; gap: 12px; align-items: flex-start; background: var(--surface); border: 1px solid var(--card-line); font-size: 14px; }
.banner .ic, .banner > svg { width: 20px; height: 20px; flex: none; }
.banner.warn { background: var(--warn-wash); border-color: transparent; }
.banner.warn .ic { color: var(--warning); }
.banner.crit { background: var(--crit-wash); border-color: transparent; }
.banner.crit .ic { color: var(--critical); }
.banner.info { background: var(--brand-wash); border-color: transparent; }
.verdict { display: flex; gap: 14px; align-items: center; padding: 16px 20px; border-radius: var(--r-card); background: var(--surface); border: 1px solid var(--card-line); }
.verdict .ic { width: 36px; height: 36px; padding: 8px; border-radius: 10px; flex: none; }
.verdict b { display: block; font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.verdict span { display: block; color: var(--muted); margin-top: 2px; font-size: 13px; }
.verdict.good .ic { color: var(--good-ink); background: var(--good-wash); }
.verdict.warn .ic { color: var(--warn-ink); background: var(--warn-wash); }
.verdict.crit .ic { color: var(--critical-ink); background: var(--crit-wash); }
.verdict.info .ic { color: var(--brand-ink); background: var(--brand-wash); }

/* ── Контролы ── */
.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.seg { display: inline-flex; padding: 4px; gap: 2px; border-radius: var(--r-ctl); background: var(--surface-2); flex-wrap: wrap; }
.seg button { height: 32px; padding: 0 14px; border-radius: 9px; border: 0; background: none; font-size: 13px; font-weight: 500; color: var(--ink-2); white-space: nowrap; transition: background-color var(--t-fast), color var(--t-fast), transform var(--t-press); }
.seg button:not(.on):hover { color: var(--ink); background: var(--border); }
.seg button:active { transform: scale(.96); }
.seg button.on { background: var(--dark); color: #fff; font-weight: 600; }
:root[data-theme="dark"] .seg button.on { background: var(--brand); color: var(--dark); }
@media (prefers-color-scheme: dark) { :root:where(:not([data-theme="light"])) .seg button.on { background: var(--brand); color: var(--dark); } }
select, input[type=text], input[type=date], input[type=password], input[type=number], input[type=url], textarea {
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 0 12px; min-height: 40px; font-size: 14px;
}
textarea { padding: 10px 12px; }
select { padding-right: 8px; }
select, input, textarea { transition: box-shadow var(--t-fast), border-color var(--t-fast), background-color var(--t-theme); }
select:hover, input[type=text]:hover, input[type=date]:hover, input[type=password]:hover, input[type=number]:hover, input[type=url]:hover, textarea:hover { border-color: rgba(26, 26, 26, .2); }
input:focus, select:focus, textarea:focus { outline: none; box-shadow: 0 0 0 2px var(--brand); border-color: transparent; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: var(--r-ctl);
  border: 1px solid var(--border); background: var(--panel); font-size: 13px; font-weight: 600; color: var(--ink); white-space: nowrap;
}
.btn { transition: background-color var(--t-fast), border-color var(--t-fast), color var(--t-fast), transform var(--t-press); }
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.97); }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--dark); border-color: var(--dark); color: #fff; }
.btn.primary:hover { background: #2e2d2b; border-color: #2e2d2b; }
:root[data-theme="dark"] .btn.primary { background: var(--brand); border-color: var(--brand); color: var(--dark); }
@media (prefers-color-scheme: dark) { :root:where(:not([data-theme="light"])) .btn.primary { background: var(--brand); border-color: var(--brand); color: var(--dark); } }
:root[data-theme="dark"] .btn.primary:hover { background: #cba97c; border-color: #cba97c; }
@media (prefers-color-scheme: dark) { :root:where(:not([data-theme="light"])) .btn.primary:hover { background: #cba97c; border-color: #cba97c; } }
:root[data-theme="dark"] select:hover, :root[data-theme="dark"] input:hover, :root[data-theme="dark"] textarea:hover { border-color: rgba(255, 255, 255, .22); }
@media (prefers-color-scheme: dark) { :root:where(:not([data-theme="light"])) :is(select, input, textarea):hover { border-color: rgba(255, 255, 255, .22); } }
.btn.ghost { border-color: transparent; background: none; color: var(--brand-ink); padding: 0; height: auto; min-height: 24px; gap: 6px; text-underline-offset: 3px; }
.btn.ghost:hover { background: none; text-decoration: underline; }
.btn.ghost svg { transition: transform var(--t-fast); }
.btn.ghost:hover svg:last-child { transform: translateX(2px); }
.btn.danger { color: var(--critical-ink); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.filter-btn .count { background: var(--brand); color: var(--dark); border-radius: 999px; font-size: 11px; padding: 0 7px; line-height: 18px; }
.filter-btn.on { border-color: var(--brand); color: var(--brand-ink); }
.icon-btn { background: none; border: 0; width: 32px; height: 32px; border-radius: 9px; color: var(--ink-2); display: inline-grid; place-items: center; }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn { transition: background-color var(--t-fast), transform var(--t-press); }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:active { transform: scale(.94); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filters select { max-width: 200px; }
/* вкладки раздела — подчёркнутые: навигация внутри раздела, а не ещё один переключатель как у периода */
.tabs { display: flex; gap: 28px; overflow-x: auto; max-width: 100%; scrollbar-width: none; box-shadow: inset 0 -1px 0 var(--border); }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { height: 44px; display: inline-flex; align-items: center; color: var(--muted); white-space: nowrap; font-size: 15px; font-weight: 500; flex: none; transition: color var(--t-fast); }
.tabs a:not(.on):hover { color: var(--ink); }
.tabs a.on { color: var(--ink); font-weight: 600; box-shadow: inset 0 -2px 0 var(--brand); }

/* ── Карточки и сетка ── */
.card { background: var(--surface); border: 1px solid var(--card-line); border-radius: var(--r-card); padding: 24px; min-width: 0; }
.card > .card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px 16px; margin-bottom: 20px; flex-wrap: wrap; }
.card-head h2 { font-size: 17px; font-weight: 600; letter-spacing: -.015em; }
.card-head .sub { color: var(--muted); font-size: 13px; }
.card-head .controls { gap: 8px 12px; }
.card-head .btn.ghost { font-size: 13px; }
.grid { display: grid; gap: 20px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g12 { grid-template-columns: repeat(12, minmax(0, 1fr)); }
.s4 { grid-column: span 4; } .s5 { grid-column: span 5; } .s6 { grid-column: span 6; } .s7 { grid-column: span 7; } .s8 { grid-column: span 8; } .s12 { grid-column: span 12; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 20px; }
.kpi { background: var(--surface); border: 1px solid var(--card-line); border-radius: var(--r-card); padding: 20px 24px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.kpi .label { font-size: 13px; font-weight: 500; color: var(--muted); }
.kpi .value { font-size: 30px; font-weight: 700; letter-spacing: -.03em; line-height: 1.1; margin-top: 6px; }
.kpi .meta { font-size: 13px; color: var(--muted); display: flex; gap: 6px 10px; flex-wrap: wrap; align-items: center; margin-top: 4px; }
.hero { display: flex; flex-wrap: wrap; gap: 24px 40px; align-items: flex-end; }
.hero .big { font-size: 48px; font-weight: 700; letter-spacing: -.035em; line-height: 1; }
.hero .of { color: var(--ink-2); font-size: 15px; margin-top: 6px; }
.stat-col { display: flex; flex-direction: column; gap: 2px; }
.stat-col .l { font-size: 13px; color: var(--muted); }
.stat-col .v { font-size: 20px; font-weight: 600; letter-spacing: -.02em; }
.caption { font-size: 13px; color: var(--muted); margin-top: 12px; }

/* Методика — свёрнута */
.howto { margin-top: 14px; font-size: 12px; color: var(--muted); }
.howto > summary { cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: 6px; color: var(--muted); transition: color var(--t-fast); }
.howto > summary:hover { color: var(--ink-2); }
.howto[open] > div { animation: fadeUp var(--t-enter) var(--ease-out) both; }
.howto > summary::-webkit-details-marker { display: none; }
.howto > summary::before { content: 'i'; width: 15px; height: 15px; border-radius: 50%; border: 1px solid currentColor; display: inline-grid; place-items: center; font-size: 10px; font-weight: 700; font-style: italic; }
.howto > div { margin-top: 8px; max-width: 900px; line-height: 1.55; }

/* Свёрнутая карточка второго плана */
details.card.fold > summary { cursor: pointer; list-style: none; margin-bottom: 0; align-items: center; }
details.card.fold > summary::-webkit-details-marker { display: none; }
details.card.fold > summary h2::before { content: ''; display: inline-block; width: 7px; height: 7px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); margin: 0 12px 2px 2px; transition: transform var(--t-slow), border-color var(--t-fast); }
details.card.fold > summary:hover h2::before { border-color: var(--ink); }
details.card.fold[open] > :not(summary) { animation: fadeUp var(--t-enter) var(--ease-out) both; }
details.card.fold[open] > summary { margin-bottom: 20px; }
details.card.fold[open] > summary h2::before { transform: rotate(45deg); }
details.card.fold:not([open]) { padding-top: 18px; padding-bottom: 18px; }

/* Горизонтальные полосы */
.hbars { display: flex; flex-direction: column; gap: 14px; }
.hbar { display: grid; grid-template-columns: minmax(110px, 200px) minmax(0, 1fr) 90px; gap: 14px; align-items: center; }
.hbar .name { font-size: 14px; color: var(--ink); min-width: 0; overflow-wrap: anywhere; line-height: 1.3; }
.hbar .name .sub { display: block; font-size: 12px; color: var(--muted); }
.hbar .track { position: relative; height: 8px; background: var(--track); border-radius: 999px; }
.hbar .fill { position: absolute; inset: 0 auto 0 0; background: var(--brand); border-radius: 999px; min-width: 4px; transform-origin: left; animation: fillIn var(--t-grow) var(--ease-out) both; }
.hbar .fill.warn { background: var(--warning); }
.hbar .fill.crit { background: var(--critical); }
.hbar .fill.muted { background: var(--axis); }
.hbar .tick { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--ink); border-radius: 1px; }
.hbar .v { font-size: 14px; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Строка «главных цифр» внутри карточки */
.figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 20px; }
.figure .l { font-size: 13px; color: var(--muted); }
.figure .v { font-size: 24px; font-weight: 700; letter-spacing: -.025em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.figure .v small { font-size: 15px; font-weight: 500; color: var(--muted); letter-spacing: -.01em; }
.figures.f3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.figure .s { font-size: 13px; color: var(--muted); margin-top: 4px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.split { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 20px; }
.section-title { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin: 8px 0 -4px; }

/* ── Метр (прогресс к плану) ── */
.meter { position: relative; height: 8px; border-radius: 999px; background: var(--track); }
.meter > .fill { position: absolute; inset: 0 auto 0 0; border-radius: 999px; background: var(--brand); max-width: 100%; transform-origin: left; animation: fillIn var(--t-grow) var(--ease-out) both; }
.meter > .tick { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--ink); border-radius: 1px; }

/* ── Пилюли (статусы — с точкой и подписью) ── */
.pill { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--surface-2); color: var(--ink-2); }
.pill.good::before, .pill.warn::before, .pill.crit::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.good { color: var(--good-ink); background: var(--good-wash); }
.pill.warn { color: var(--warn-ink); background: var(--warn-wash); }
.pill.crit { color: var(--critical-ink); background: var(--crit-wash); }
.pill.info, .pill.brand { color: var(--brand-ink); background: var(--brand-wash); }
.pill.dark { background: var(--dark); color: #fff; }
:root[data-theme="dark"] .pill.dark { background: #f3f1ec; color: var(--dark); }
@media (prefers-color-scheme: dark) { :root:where(:not([data-theme="light"])) .pill.dark { background: #f3f1ec; color: var(--dark); } }
.pill.line { background: transparent; box-shadow: inset 0 0 0 1px var(--border); }
.delta-up { color: var(--good-ink); }
.delta-down { color: var(--critical-ink); }

/* ── Сигналы ── */
.signals { display: flex; flex-direction: column; }
.signal { display: flex; align-items: flex-start; gap: 14px; padding: 14px 0; border-top: 1px solid var(--border); }
.signals > .signal:first-child { border-top: 0; padding-top: 0; }
.signal .ic { width: 36px; height: 36px; padding: 9px; border-radius: 10px; flex: none; }
.signal.red .ic { color: var(--critical-ink); background: var(--crit-wash); }
.signal.yellow .ic { color: var(--warn-ink); background: var(--warn-wash); }
.signal.ok .ic { color: var(--good-ink); background: var(--good-wash); }
.signal .txt { flex: 1; min-width: 0; font-size: 14px; color: var(--ink); padding-top: 2px; }
.signal .lvl { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.signal .lvl .btn.ghost { font-size: 13px; min-height: 22px; }
.signals details > summary { list-style: none; cursor: pointer; margin-top: 4px; font-size: 13px; }
.signals details[open] > summary { display: none; }
.signals details > .signals > .signal:first-child { border-top: 1px solid var(--border); padding-top: 14px; }
.signals details > summary::-webkit-details-marker { display: none; }

/* ── Таблицы ── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-wrap.tall { max-height: 640px; overflow-y: auto; }
table.t { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 14px; }
table.t th, table.t td { padding: 13px 0 13px 16px; border-top: 1px solid var(--border); vertical-align: middle; }
table.t th { position: sticky; top: 0; background: var(--surface); text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; white-space: nowrap; z-index: 1; border-top: 0; padding-top: 0; padding-bottom: 12px; }
table.t th.sortable { cursor: pointer; user-select: none; transition: color var(--t-fast); }
table.t th.sortable:hover { color: var(--ink); }
table.t td { transition: background-color var(--t-fast); }
table.t tbody tr:hover > td { background: var(--row-hover); }
table.t th .arrow { color: var(--brand-ink); margin-left: 3px; }
table.t td { font-variant-numeric: tabular-nums; }
table.t td.num, table.t th.num { text-align: right; }
table.t td.c, table.t th.c { text-align: center; padding-right: 0; }
table.t td.first, table.t th.first { position: sticky; left: 0; background: var(--surface); z-index: 2; max-width: 280px; padding-left: 0; font-weight: 500; }
table.t th.first { z-index: 3; font-weight: 500; }
table.t tr.total td { font-weight: 600; }
table.t td > select { min-width: 180px; }
table.t td .sub { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }
.cell-bar { display: flex; align-items: center; gap: 10px; justify-content: flex-end; }
.cell-bar .bt { width: 64px; height: 6px; border-radius: 999px; background: var(--track); display: flex; flex: none; order: 2; }
.cell-bar .b { height: 6px; border-radius: 999px; background: var(--brand); min-width: 3px; transform-origin: left; animation: fillIn var(--t-grow) var(--ease-out) both; }
.table-more { display: flex; gap: 16px; padding-top: 12px; }
.link-btn { background: none; border: 0; padding: 2px 0; color: var(--brand-ink); font-size: 13px; font-weight: 600; text-underline-offset: 3px; }
.link-btn:hover, .caption a:hover, .hero-of a:hover, .cal-item .who a:hover, .chart-note a:hover, .banner a:hover { text-decoration: underline; }
td.empty { color: var(--muted); text-align: center; padding: 28px; }

/* Календарь встреч */
.cal-list { display: flex; flex-direction: column; }
.cal-item { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: 16px; padding: 14px 0; border-top: 1px solid var(--border); align-items: center; }
.cal-list > .cal-item:first-child { border-top: 0; padding-top: 0; }
.cal-item .time { font-size: 15px; font-weight: 600; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.cal-item .who { font-size: 14px; font-weight: 500; padding-left: 16px; border-left: 3px solid var(--track); min-width: 0; }
.cal-item.next .who { border-left-color: var(--brand); }
.cal-item .who .sub { display: block; color: var(--muted); font-size: 13px; font-weight: 400; margin-top: 2px; }
.cal-item .end { display: flex; align-items: center; gap: 10px; }
.cal-list.compact .who > a, .cal-list.compact .who .sub { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Формы ── */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px 20px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-size: 13px; color: var(--ink-2); font-weight: 500; }
.form-grid > .field > label:first-child { min-height: 38px; display: flex; align-items: flex-end; line-height: 19px; }
.field .hint { font-size: 12px; color: var(--muted); }
.field input, .field select { width: 100%; }
.check { display: inline-flex; gap: 8px; align-items: center; font-size: 14px; cursor: pointer; }
input[type=checkbox], input[type=radio] { accent-color: var(--brand); width: 16px; height: 16px; }
.utm-out { display: flex; gap: 8px; align-items: stretch; }
.utm-out input { flex: 1; font-family: ui-monospace, Consolas, monospace; font-size: 12px; }

/* ── Модальное окно и тост ── */
.modal-back { position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 80; display: grid; place-items: center; padding: 16px; animation: fadeIn var(--t-pop) both; }
.modal { background: var(--panel); border-radius: 24px; width: min(960px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 28px; box-shadow: 0 24px 80px rgba(0, 0, 0, .3); animation: popIn var(--t-slow) var(--ease-out) both; }
.modal-back.closing { animation: fadeOut .18s both; }
.modal-back.closing .modal { animation: popOut .18s both; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.toast { --tx: -50%; position: fixed; bottom: 24px; left: 50%; transform: translateX(var(--tx)); background: var(--dark); color: #fff; padding: 12px 18px; border-radius: 12px; z-index: 120; font-size: 14px; box-shadow: 0 12px 40px rgba(0, 0, 0, .2); animation: toastIn var(--t-slow) var(--ease-out) both; }
.toast.out { animation: toastOut .25s ease-in both; }

/* ── Вход ── */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--sb-bg); }
.login form { width: min(380px, 100%); display: flex; flex-direction: column; gap: 16px; background: var(--panel); border-radius: var(--r-panel); padding: 32px; animation: fadeUp .45s var(--ease-out) both; }
.login .logo { color: var(--ink); margin-bottom: 8px; }
.login .logo-sub { color: var(--muted); }
.login input { width: 100%; }
.login .btn { height: 44px; font-size: 14px; }
.err { color: var(--critical-ink); font-size: 13px; }

.skeleton { height: 120px; border-radius: var(--r-card); background: linear-gradient(100deg, var(--surface) 30%, var(--surface-2) 50%, var(--surface) 70%); background-size: 200% 100%; animation: shimmer 1.6s linear infinite; }
.empty { padding: 28px; text-align: center; color: var(--muted); }
