@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700&display=swap");

/* ---------- База ---------- */
.tme, .tme * { box-sizing: border-box; }
.tme { font-family: var(--font-sans); font-size: 14px; line-height: 20px; color: var(--ink); -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums; }
.tme button { font: inherit; color: inherit; text-align: left; }
.tme :focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.tme-muted { color: var(--ink-muted); }
.tme-small { font-size: 12px; line-height: 16px; }
.tme-row { display: flex; align-items: center; gap: 10px; }
.tme-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.tme-icon { display: inline-block; flex: none; vertical-align: middle; }

/* ---------- Каркас приложения ---------- */
.tme-app { position: relative; overflow: hidden; display: flex; min-height: 100vh; background: radial-gradient(1200px 600px at 70% -10%, var(--bg-glow) 0%, var(--bg-page) 55%); color: var(--ink); }
.tme-main { flex: 1; min-width: 0; padding: 28px 36px 40px; display: flex; flex-direction: column; gap: 20px; }
.tme-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
.tme-grid > * { grid-column: span var(--span, 12); min-width: 0; }
@media (max-width: 1100px) { .tme-grid > * { grid-column: span var(--span-md, 12); } }
@media (max-width: 767px) { .tme-grid > * { grid-column: span 12 !important; } .tme-main { padding: 16px; } }

/* ---------- Левое меню ---------- */
.tme-side { width: var(--size-sidebar); flex: none; display: flex; flex-direction: column; gap: 6px; padding: 20px 16px; border-right: 1px solid var(--line-hairline); background: var(--bg-sidebar); transition: width var(--duration-base) cubic-bezier(.2, 0, 0, 1); overflow: hidden; align-self: stretch; }
.tme-side.is-collapsed { width: var(--size-sidebar-collapsed); }
.tme-fade { transition: opacity var(--duration-fast) ease; }
.tme-side.is-collapsed .tme-fade { opacity: 0; pointer-events: none; }
.tme-side-logo { height: 44px; display: flex; align-items: center; margin: 0 0 18px 6px; position: relative; }
.tme-side-logo img { height: 32px; display: block; }
.tme-side-logo .is-mark { position: absolute; left: 0; top: 6px; opacity: 0; transition: opacity var(--duration-fast) ease; }
.tme-side-logo .is-full { transition: opacity var(--duration-fast) ease; }
.tme-side.is-collapsed .tme-side-logo .is-full { opacity: 0; }
.tme-side.is-collapsed .tme-side-logo .is-mark { opacity: 1; }
.tme-side-logo .is-inv { display: none; }
[data-theme="dark"] .tme-side-logo .is-pos { display: none; }
[data-theme="dark"] .tme-side-logo .is-inv { display: block; }
.tme-nav { height: var(--size-nav-item); border-radius: var(--radius-nav); display: flex; align-items: center; gap: 12px; padding: 0 12px; color: var(--ink-faint); text-decoration: none; font-weight: 500; white-space: nowrap; border: 0; background: transparent; cursor: pointer; width: 100%; flex: none; transition: background-color var(--duration-fast), color var(--duration-fast); }
.tme-nav:hover { background: var(--surface-hover); color: var(--ink); }
.tme-nav.is-on { background: var(--nav-active-bg); color: var(--accent); box-shadow: inset 0 0 0 1px var(--nav-active-line); }
.tme-nav-count { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--radius-pill); background: var(--accent); color: var(--on-accent); font-size: 12px; line-height: 20px; text-align: center; }
.tme-side-spacer { flex: 1; }
.tme-user { display: flex; align-items: center; gap: 12px; padding: 14px 0 2px 6px; margin-top: 8px; border-top: 1px solid var(--line-soft); position: relative; white-space: nowrap; }
.tme-ava { width: 32px; height: 32px; border-radius: var(--radius-ava); flex: none; background: linear-gradient(135deg, var(--accent), var(--accent-press)); color: var(--on-accent); font-weight: 600; font-size: 12px; display: flex; align-items: center; justify-content: center; }
.tme-user-info { min-width: 0; display: flex; flex-direction: column; }
.tme-user-name { font-weight: 600; font-size: 13px; line-height: 18px; overflow: hidden; text-overflow: ellipsis; }
.tme-user-role { font-size: 12px; line-height: 16px; color: var(--ink-muted); }
.tme-logout { position: absolute; right: 0; bottom: 4px; width: 32px; height: 32px; border-radius: 10px; border: 0; background: transparent; color: var(--ink-faint); display: flex; align-items: center; justify-content: center; cursor: pointer; opacity: 0; transition: opacity var(--duration-fast); }
.tme-user:hover .tme-logout, .tme-logout:focus-visible { opacity: 1; }
.tme-logout:hover { color: var(--negative); background: var(--negative-bg); }
.tme-side.is-collapsed .tme-logout { display: none; }
@media (max-width: 767px) { .tme-side { display: none; } }

/* ---------- Шапка экрана ---------- */
.tme-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.tme-top-kicker { font-size: 12px; line-height: 16px; color: var(--ink-muted); }
.tme-h1 { margin: 2px 0 0; font-size: 30px; line-height: 38px; font-weight: 600; letter-spacing: 0.005em; }
.tme-top-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.tme-search { display: flex; align-items: center; gap: 8px; height: var(--size-control); padding: 0 14px; width: 280px; max-width: 100%; border-radius: var(--radius-pill); background: var(--surface-control); border: 1px solid var(--line-hairline); color: var(--ink-faint); }
.tme-search input { border: 0; background: transparent; outline: 0; font: inherit; color: var(--ink); width: 100%; }
.tme-search input::placeholder { color: var(--ink-faint); }
.tme-pills { display: inline-flex; flex: none; gap: 4px; padding: 4px; border-radius: var(--radius-pill); background: var(--surface-control); border: 1px solid var(--line-hairline); }
.tme-pills button { padding: 6px 14px; border-radius: var(--radius-pill); color: var(--ink-soft); font-weight: 500; font-size: 13px; line-height: 18px; border: 0; background: transparent; cursor: pointer; text-align: center; }
.tme-pills button[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); }
.tme-roundbtn { width: var(--size-control); height: var(--size-control); border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--surface-control); border: 1px solid var(--line-hairline); color: var(--icon-on-plate); cursor: pointer; padding: 0; flex: none; }
.tme-roundbtn.is-on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

/* ---------- Карточки ---------- */
.tme-card { background: linear-gradient(180deg, var(--surface-card), var(--surface-card-end)); border: 1px solid var(--line-hairline); border-radius: var(--radius-card); padding: 20px; box-shadow: var(--shadow-card); min-width: 0; position: relative; height: 100%; }
.tme-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.tme-h3 { margin: 0; font-size: 17px; line-height: 24px; font-weight: 600; }
.tme-legend { display: flex; gap: 16px; color: var(--ink-soft); font-size: 13px; flex-wrap: wrap; }
.tme-legend span { display: inline-flex; align-items: center; gap: 6px; }
.tme-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.tme-card-attention { background: linear-gradient(180deg, var(--attention-bg), var(--surface-card-end) 70%); border-color: var(--attention-line); }

/* ---------- Плитка показателя ---------- */
.tme-kpi { display: flex; flex-direction: column; gap: 12px; cursor: pointer; width: 100%; transition: transform var(--duration-fast), border-color var(--duration-fast); }
.tme-kpi:hover { transform: translateY(-2px); border-color: var(--attention-line); }
.tme-kpi.is-active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow-card); }
.tme-plate { width: 36px; height: 36px; border-radius: var(--radius-plate); display: flex; align-items: center; justify-content: center; background: var(--icon-plate); color: var(--icon-on-plate); flex: none; }
.tme-plate.is-accent { background: var(--icon-plate-accent); color: var(--accent); }
.tme-kpi-label { font-weight: 500; color: var(--ink-muted); }
.tme-kpi-more { margin-left: auto; color: var(--ink-faint); display: flex; }
.tme-kpi-body { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.tme-metric { font-size: 40px; line-height: 44px; font-weight: 600; letter-spacing: -0.01em; }
.tme-unit { font-size: 18px; color: var(--ink-muted); margin-left: 4px; }
.tme-chip { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 10px; border-radius: var(--radius-pill); font-size: 12px; font-weight: 600; white-space: nowrap; }
.tme-chip.is-up { background: var(--positive-bg); color: var(--positive); }
.tme-chip.is-down { background: var(--negative-bg); color: var(--negative); }
.tme-chip.is-flat { background: var(--surface-hover); color: var(--ink-muted); }
.tme-chip.is-accent { background: var(--negative-bg); color: var(--negative); }

/* ---------- Графики ---------- */
.tme-chart { position: relative; }
.tme-chart svg { display: block; }
.tme-ylab { position: absolute; right: 0; font-size: 11px; line-height: 16px; color: var(--ink-faint); pointer-events: none; }
.tme-xl { display: flex; justify-content: space-between; margin-top: 10px; font-size: 11px; line-height: 16px; color: var(--ink-faint); }
.tme-chart-dot { position: absolute; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--surface-card-end); transform: translate(-50%, -50%); pointer-events: none; }
.tme-chart-cursor { position: absolute; top: 10px; bottom: 0; width: 0; border-left: 1px dashed var(--chart-cursor); pointer-events: none; }
.tme-tip { position: absolute; background: var(--surface-raised); border: 1px solid var(--line-hairline); border-radius: var(--radius-plate); padding: 10px 12px; min-width: 150px; box-shadow: var(--shadow-tip); font-size: 12px; line-height: 16px; pointer-events: none; z-index: 2; }
.tme-tip-row { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.tme-tip-row b { margin-left: auto; font-weight: 600; padding-left: 12px; }
[data-theme="dark"] .tme-glow { filter: drop-shadow(0 0 6px rgba(252, 107, 40, 0.65)); }
.tme-donut { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.tme-donut-legend { align-self: stretch; }
.tme-leg { display: grid; grid-template-columns: 10px 1fr auto 44px; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); }
.tme-leg b { font-weight: 600; }
.tme-leg .tme-muted { text-align: right; }
.tme-bars { display: flex; flex-direction: column; }
.tme-bar-row { display: grid; grid-template-columns: minmax(140px, 1.6fr) 1fr 28px; align-items: center; gap: 12px; padding: 7px 0; }
.tme-bar-row b { text-align: right; font-weight: 600; }
.tme-track { height: 8px; border-radius: var(--radius-pill); background: var(--data-track); overflow: hidden; }
.tme-track div { height: 100%; border-radius: var(--radius-pill); background: var(--bar-neutral); }
.tme-track .is-main { background: linear-gradient(90deg, var(--accent-press), var(--accent)); }
.tme-statrow { display: grid; grid-template-columns: 1fr auto auto; gap: 4px 16px; align-items: baseline; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.tme-statrow:last-child { border-bottom: 0; }
.tme-statrow b { font-weight: 600; }
.tme-statrow .tme-small { grid-column: 1 / -1; }
.tme-attn-value { font-size: 56px; line-height: 60px; font-weight: 600; color: var(--accent); letter-spacing: -0.02em; margin-top: 12px; }
.tme-progress { height: 8px; border-radius: var(--radius-pill); background: var(--data-track); overflow: hidden; margin-top: 14px; }
.tme-progress div { height: 100%; border-radius: var(--radius-pill); background: linear-gradient(90deg, var(--accent-press), var(--accent)); }

/* ---------- Правая панель ---------- */
.tme-drawer { position: absolute; top: 0; right: 0; bottom: 0; width: var(--size-drawer); max-width: 100%; background: var(--surface-raised); border-left: 1px solid var(--line-hairline); box-shadow: var(--shadow-overlay); transform: translateX(100%); visibility: hidden; transition: transform var(--duration-slow) cubic-bezier(.2, 0, 0, 1), visibility 0s linear var(--duration-slow); display: flex; flex-direction: column; z-index: 5; }
.tme-drawer.is-open { transform: none; visibility: visible; transition: transform var(--duration-slow) cubic-bezier(.2, 0, 0, 1); }
.tme-handle { position: absolute; top: 50%; right: 0; transform: translateY(-50%); width: 28px; height: 72px; border-radius: var(--radius-nav) 0 0 var(--radius-nav); border: 1px solid var(--line-hairline); border-right: 0; background: var(--surface-raised); color: var(--icon-on-plate); display: flex; align-items: center; justify-content: center; cursor: pointer; z-index: 6; padding: 0; box-shadow: var(--shadow-overlay); transition: right var(--duration-slow) cubic-bezier(.2, 0, 0, 1); }
.tme-handle.is-open { right: var(--size-drawer); }
.tme-drawer-head { display: flex; align-items: flex-start; gap: 12px; padding: 22px 22px 16px; border-bottom: 1px solid var(--line-soft); }
.tme-drawer-title { margin: 0; font-size: 20px; line-height: 28px; font-weight: 600; flex: 1; }
.tme-drawer-body { flex: 1; overflow: auto; padding: 20px 22px; display: flex; flex-direction: column; gap: 12px; }
.tme-drawer-foot { display: flex; gap: 8px; padding: 16px 22px; border-top: 1px solid var(--line-soft); }
.tme-big { font-size: 56px; line-height: 60px; font-weight: 600; letter-spacing: -0.02em; }
.tme-section { display: flex; flex-direction: column; gap: 6px; padding-top: 14px; margin-top: 4px; border-top: 1px solid var(--line-soft); }
.tme-section-title { font-weight: 600; font-size: 13px; color: var(--ink-soft); }
.tme-detail { display: grid; grid-template-columns: 1fr auto 110px; gap: 12px; align-items: baseline; padding: 8px 0; border-bottom: 1px solid var(--line-soft); }
.tme-detail.is-two { grid-template-columns: 1fr auto; }
.tme-detail b { font-weight: 600; text-align: right; }
.tme-detail .tme-muted { text-align: right; font-size: 12px; }
@media (max-width: 767px) { .tme-drawer { width: 100%; } .tme-handle.is-open { right: 100%; } }

/* ---------- Сообщения ---------- */
.tme-callout { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-plate); background: var(--attention-bg); border: 1px solid var(--attention-line); }
.tme-callout > .tme-icon { color: var(--accent); margin-top: 1px; }
.tme-callout.is-warning { background: var(--warning-bg); border-color: transparent; }
.tme-callout.is-warning > .tme-icon { color: var(--warning); }
.tme-callout.is-info { background: var(--surface-hover); border-color: var(--line-hairline); }
.tme-callout.is-info > .tme-icon { color: var(--ink-soft); }
.tme-callout p { margin: 0; }
.tme-callout-title { font-weight: 600; margin: 0 0 2px; }
.tme-empty { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; padding: 40px 8px; max-width: 460px; }
.tme-empty-mark { width: 48px; height: 48px; border-radius: var(--radius-plate); background: var(--icon-plate); color: var(--icon-on-plate); display: flex; align-items: center; justify-content: center; position: relative; }
.tme-empty-mark::after { content: ""; position: absolute; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); right: -2px; top: -2px; }
.tme-empty h3 { margin: 0; font-size: 17px; line-height: 24px; font-weight: 600; }
.tme-empty p { margin: 0; color: var(--ink-muted); }
.tme-badge { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: var(--radius-pill); font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--surface-hover); color: var(--ink-soft); }
.tme-badge.is-positive { background: var(--positive-bg); color: var(--positive); }
.tme-badge.is-negative { background: var(--negative-bg); color: var(--negative); }
.tme-badge.is-warning { background: var(--warning-bg); color: var(--warning); }
.tme-badge.is-accent { background: var(--icon-plate-accent); color: var(--accent); }
.tme-badge.is-outline { background: transparent; box-shadow: inset 0 0 0 1px var(--line-hairline); color: var(--ink-muted); }
.tme-badge i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---------- Кнопки и формы ---------- */
.tme-btn { height: var(--size-control); padding: 0 18px; border-radius: var(--radius-pill); border: 1px solid var(--line-hairline); background: transparent; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 500; cursor: pointer; white-space: nowrap; color: var(--ink); transition: background-color var(--duration-fast); }
.tme-btn:hover { background: var(--surface-hover); }
.tme .tme-btn-primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.tme .tme-btn-accent { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.tme .tme-btn-accent:hover { background: var(--accent-hover); }
.tme-btn-ghost { border-color: transparent; }
.tme-btn-sm { height: 32px; padding: 0 14px; font-size: 13px; }
.tme-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.tme-field { display: flex; flex-direction: column; gap: 6px; }
.tme-field-label { font-weight: 500; }
.tme-field-hint { font-size: 12px; line-height: 16px; color: var(--ink-muted); }
.tme-field-error { font-size: 12px; line-height: 16px; color: var(--negative); }
.tme-input { height: var(--size-control); width: 100%; padding: 0 14px; border-radius: var(--radius-plate); border: 1px solid var(--line-hairline); background: var(--surface-control); color: var(--ink); font: inherit; }
.tme-input::placeholder { color: var(--ink-faint); }
.tme-input[aria-invalid="true"] { border-color: var(--negative); }
.tme-select { position: relative; }
.tme-select select { appearance: none; -webkit-appearance: none; padding-right: 36px; cursor: pointer; }
.tme-select .tme-icon { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); pointer-events: none; color: var(--ink-faint); }
.tme-switch { display: inline-flex; align-items: center; gap: 12px; cursor: pointer; }
.tme-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.tme-switch-track { width: 40px; height: 24px; border-radius: var(--radius-pill); background: var(--bar-neutral); position: relative; transition: background-color var(--duration-fast); flex: none; }
.tme-switch-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--surface-raised); box-shadow: 0 1px 2px rgba(9, 31, 68, 0.2); transition: transform var(--duration-fast); }
.tme-switch input:checked + .tme-switch-track { background: var(--accent); }
.tme-switch input:checked + .tme-switch-track::after { transform: translateX(16px); }
.tme-switch input:focus-visible + .tme-switch-track { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

/* ---------- Таблица ---------- */
.tme-table-wrap { width: 100%; overflow-x: auto; }
.tme-table { width: 100%; border-collapse: collapse; }
.tme-table th { text-align: left; font-size: 12px; line-height: 16px; font-weight: 500; color: var(--ink-muted); padding: 0 12px 10px; border-bottom: 1px solid var(--line-hairline); white-space: nowrap; }
.tme-table td { padding: 12px; border-bottom: 1px solid var(--line-soft); }
.tme-table tr:last-child td { border-bottom: 0; }
.tme-table .is-num { text-align: right; }
.tme-table tbody tr.is-click { cursor: pointer; }
.tme-table tbody tr.is-click:hover td { background: var(--surface-hover); }
@media (max-width: 767px) {
  .tme-table.is-cards thead { display: none; }
  .tme-table.is-cards, .tme-table.is-cards tbody, .tme-table.is-cards tr, .tme-table.is-cards td { display: block; width: 100%; }
  .tme-table.is-cards tr { padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
  .tme-table.is-cards td { border: 0; padding: 2px 0; display: flex; justify-content: space-between; gap: 12px; }
  .tme-table.is-cards td:first-child { font-weight: 600; }
  .tme-table.is-cards td:not(:first-child)::before { content: attr(data-label); color: var(--ink-muted); }
}

/* ---------- Воронка ---------- */
.tme-funnel { display: flex; flex-direction: column; gap: 12px; }
.tme-funnel-step { display: grid; grid-template-columns: minmax(140px, 1fr) 2fr 120px; align-items: center; gap: 12px; }
.tme-funnel-value { font-size: 21px; line-height: 28px; font-weight: 600; }
.tme-funnel-bar { height: 32px; border-radius: var(--radius-plate); background: var(--data-track); position: relative; overflow: hidden; }
.tme-funnel-fill { position: absolute; inset: 0 auto 0 0; background: var(--bar-neutral); border-radius: var(--radius-plate); }
.tme-funnel-step:last-child .tme-funnel-fill { background: linear-gradient(90deg, var(--accent-press), var(--accent)); }
.tme-funnel-conv { color: var(--ink-muted); text-align: right; font-size: 12px; line-height: 16px; }

@media (prefers-reduced-motion: reduce) { .tme *, .tme-drawer, .tme-side { transition: none !important; } }

/* Варианты для отчётов с произвольным периодом. */
.tme-period { display:flex; align-items:end; flex-wrap:wrap; gap:12px; }
.tme-period .tme-field { min-width:150px; max-width:100%; }
.tme-period .tme-input { min-height:44px; }
.tme-chart-legend { display:flex; flex-wrap:wrap; gap:16px; margin-bottom:18px; }
.tme-chart-legend span { display:inline-flex; align-items:center; gap:6px; }
.tme-chart-report .tme-chart { margin-right:38px; }
.tme-chart-report .tme-ylab { right:-38px; }
.tme-chart-report .tme-xl { margin-right:38px; }
.tme-chart-report .tme-xl span { white-space:nowrap; }
.tme-kpi-info { align-self:flex-end; cursor:help; }
.tme-table .is-highlight { background:var(--attention-bg); }
