/* Тема повторяет админку payg_ui: дашборд должен выглядеть привычно. */
:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #232735;
  --border: #2d3248;
  --primary: #6c5ce7;
  --primary-hover: #7f70f0;
  --accent: #00cec9;
  --danger: #e74c3c;
  --success: #00b894;
  --warning: #fdcb6e;
  --text: #e8e8ef;
  --text-muted: #8f93a5;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0, 0, 0, .35);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

[hidden] { display: none !important; }

/* ─── каркас ─── */
.pg-shell { min-height: 100vh; display: flex; flex-direction: column; }
.pg-header {
  background: linear-gradient(180deg, var(--surface), var(--surface2));
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
}
.pg-header-inner {
  max-width: 1500px; margin: 0 auto; display: flex; align-items: center;
  justify-content: space-between; padding: 14px 0; gap: 12px; flex-wrap: wrap;
}
.pg-brand { display: flex; align-items: center; gap: 12px; font-size: 18px; font-weight: 600; }
.pg-brand-icon { font-size: 22px; }
.pg-header-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.pg-snap { color: var(--text-muted); font-size: 12px; }
.pg-main { padding: 24px 28px 48px; max-width: 1500px; margin: 0 auto; width: 100%; }

.pg-btn {
  background: var(--surface2); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 14px; font-size: 13px; font-weight: 600;
  cursor: pointer; font-family: inherit; transition: background .15s, border-color .15s;
}
.pg-btn:hover { border-color: var(--primary); }
.pg-btn:disabled { opacity: .5; cursor: default; }
.pg-btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.pg-btn-primary:hover { background: var(--primary-hover); }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.mk-card { padding: 18px 20px; margin-bottom: 16px; }
.mk-cardhead { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.mk-h3 { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 7px; margin-bottom: 4px; }
.mk-note { color: var(--text-muted); font-size: 12px; }

/* ─── вкладки ─── */
.mk-tabs {
  display: flex; gap: 6px; margin-bottom: 16px; background: var(--surface2);
  border: 1px solid var(--border); border-radius: 10px; padding: 4px; width: fit-content; flex-wrap: wrap;
}
.mk-tab {
  background: transparent; color: var(--text-muted); border: none; padding: 8px 18px;
  border-radius: 7px; cursor: pointer; font-size: 14px; font-weight: 600; font-family: inherit;
  transition: background .15s, color .15s;
}
.mk-tab:hover { color: var(--text); }
.mk-tab.active { background: var(--primary); color: #fff; box-shadow: 0 1px 4px rgba(108, 92, 231, .4); }

/* ─── фильтры ─── */
.mk-filters { padding: 16px 20px; margin-bottom: 16px; }
.mk-filter-row { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.mk-field { display: flex; flex-direction: column; gap: 8px; min-width: 150px; }
.mk-field > span {
  color: var(--text-muted); font-size: 11px; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; display: flex; align-items: center; gap: 5px;
}
.mk-pillgroup {
  display: flex; flex-wrap: wrap; gap: 6px; background: var(--surface2);
  border: 1px solid var(--border); border-radius: 10px; padding: 4px;
}
.mk-pill {
  background: transparent; color: var(--text-muted); border: none; padding: 6px 12px;
  border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 500; font-family: inherit;
}
.mk-pill:hover { color: var(--text); }
.mk-pill.active { background: var(--primary); color: #fff; }
.mk-select, .mk-date, .mk-input {
  background: var(--surface2); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 8px 12px; font-size: 13px; font-family: inherit;
  max-width: 100%; color-scheme: dark;
}
.mk-select { cursor: pointer; }
.mk-select:focus, .mk-date:focus, .mk-input:focus { outline: none; border-color: var(--primary); }
.mk-select:disabled { opacity: .55; cursor: not-allowed; }
.mk-arrow { color: var(--text-muted); }

/* ─── блоки когорт ─── */
.mk-cohorts { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 14px; }
.mk-cohort {
  border: 1px solid var(--border); border-left: 4px solid var(--c, #6c5ce7);
  border-radius: 10px; padding: 10px 14px; background: var(--surface2);
  display: flex; flex-direction: column; gap: 8px;
}
.mk-ctitle {
  display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em;
}
.mk-cdot { width: 10px; height: 10px; border-radius: 50%; background: var(--c, #6c5ce7); }
.mk-cdates { display: flex; align-items: center; gap: 8px; }
.mk-cdel {
  margin-left: auto; background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 15px; padding: 2px 6px; border-radius: 6px;
}
.mk-cdel:hover { color: #ff7675; background: rgba(255, 118, 117, .1); }
.mk-cadd {
  border: 1px dashed var(--border); border-radius: 10px; padding: 10px 18px;
  background: transparent; color: var(--text-muted); cursor: pointer;
  font-size: 13px; font-weight: 600; font-family: inherit;
}
.mk-cadd:hover { color: var(--text); border-color: var(--primary); }

/* ─── индикатор загрузки ─── */
.mk-spinner { display: flex; gap: 4px; align-items: center; height: 32px; margin-left: auto; opacity: 0; transition: opacity .2s; }
.mk-spinner.active { opacity: 1; }
.mk-spinner span { width: 6px; height: 6px; border-radius: 50%; background: var(--primary); animation: mkbounce 1.2s infinite ease-in-out both; }
.mk-spinner span:nth-child(2) { animation-delay: .15s; }
.mk-spinner span:nth-child(3) { animation-delay: .3s; }
@keyframes mkbounce { 0%, 80%, 100% { transform: scale(.4); } 40% { transform: scale(1); } }
.mk-content { transition: opacity .2s; }
.mk-content.loading { opacity: .45; pointer-events: none; }

/* ─── качество связки ─── */
.mk-quality { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; font-size: 12px; color: var(--text-muted); }
.mk-qbadge { background: var(--surface2); border: 1px solid var(--border); border-radius: 20px; padding: 4px 12px; color: var(--text); }
.mk-qbadge b { font-variant-numeric: tabular-nums; }

/* ─── карточки метрик ─── */
.mk-cohort-block { margin-bottom: 16px; }
.mk-chead { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.mk-chead .mk-cdot { width: 12px; height: 12px; }
.mk-clabel { font-size: 14px; font-weight: 700; }
.gs-metrics { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.gs-metric {
  background: linear-gradient(180deg, var(--surface), var(--surface2));
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.gs-metric::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--c, var(--primary)); border-radius: 3px 0 0 3px;
}
.gs-metric.accent::before { background: var(--accent); }
.gs-metric.success::before { background: var(--success); }
.gs-metric.warning::before { background: var(--warning); }
.gs-metric .lbl {
  font-size: 11px; font-weight: 600; color: var(--text-muted); letter-spacing: .06em;
  text-transform: uppercase; margin-bottom: 4px; display: flex; align-items: center; gap: 5px;
}
.gs-metric .val { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.gs-metric .sub { font-size: 12px; color: var(--text-muted); margin-top: 3px; }

/* ─── таблицы ─── */
.table-wrap { overflow-x: auto; }
.mk-table { width: 100%; border-collapse: collapse; }
.mk-table th, .mk-table td {
  padding: 9px 12px; border-bottom: 1px solid var(--border); text-align: left; font-size: 13px;
}
.mk-table th {
  background: var(--surface2); font-weight: 600; font-size: 11px;
  text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted);
}
.mk-table td.num, .mk-table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mk-table tbody tr:hover { background: rgba(108, 92, 231, .05); }
.mk-cdot-inline { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }

/* ─── графики ─── */
.mk-chart { min-height: 320px; }
.mk-chart-tall { min-height: 400px; }

/* ─── сообщения ─── */
.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-size: 13px; }
.alert-danger { background: rgba(231, 76, 60, .12); border: 1px solid rgba(231, 76, 60, .35); color: #ff7675; }
.alert-warn { background: rgba(253, 203, 110, .12); border: 1px solid rgba(253, 203, 110, .35); color: var(--warning); }

/* ─── подсказки ─── */
.mk-q {
  display: inline-flex; align-items: center; justify-content: center;
  width: 15px; height: 15px; border-radius: 50%; background: var(--surface2);
  border: 1px solid var(--border); color: var(--text-muted);
  font-size: 10px; font-weight: 700; cursor: help; flex: none;
}
.mk-q:hover { color: var(--text); border-color: var(--primary); }
.mk-tip {
  position: fixed; z-index: 1000; max-width: 340px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 13px;
  font-size: 12px; line-height: 1.5; color: var(--text); box-shadow: var(--shadow);
  pointer-events: none;
}

/* ─── диалог токена ─── */
.mk-modal {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .6);
  display: flex; align-items: center; justify-content: center; z-index: 1100; padding: 20px;
}
.mk-modal-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; width: 100%; max-width: 460px; box-shadow: var(--shadow);
}
.mk-modal-card .mk-input { width: 100%; margin: 14px 0; }
.mk-modal-actions { display: flex; gap: 10px; justify-content: flex-end; }
.mk-modal code {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 5px; padding: 1px 5px; font-size: 12px;
}
