:root {
  color-scheme: light;
  --bg: #f6f7fb;
  --card: #ffffff;
  --line: #d9e0ea;
  --text: #1f2937;
  --muted: #64748b;
  --accent: #7c3aed;
  --accent-soft: #ede9fe;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --bad: #b91c1c;
  --bad-soft: #fee2e2;
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  /* строгая тема держит ровный фон (background: var(--bg) !important) —
     фиолетовый градиент здесь всё равно не рисовался */
  background: var(--bg);
  color: var(--text);
}
.page {
  max-width: 1600px;
  margin: 0 auto;
  padding: 28px 20px 40px;
}
.hero,
.filters,
.stats,
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 18px 35px rgba(15, 23, 42, 0.08);
}
.hero {
  padding: 24px 28px;
  margin-bottom: 20px;
}
.hero h1 {
  margin: 0 0 8px;
  font-size: 30px;
  line-height: 1.1;
}
.hero p {
  margin: 0;
  color: var(--muted);
  max-width: 980px;
  line-height: 1.55;
}
.filters {
  padding: 18px;
  margin-bottom: 20px;
}
.filters form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  align-items: end;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
.field input,
.field select {
  width: 100%;
  min-height: 46px;
  border-radius: 12px;
  border: 1px solid var(--line);
  padding: 0 13px;
  font-size: 15px;
  color: var(--text);
  background: #fff;
}
.actions {
  display: flex;
  gap: 12px;
  align-items: center;
  grid-column: 1 / -1;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid transparent;
  text-decoration: none;
  font-weight: 700;
  cursor: pointer;
  font-size: 15px;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-secondary { background: transparent; border-color: var(--line); color: var(--text); }
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  padding: 16px;
  margin-bottom: 20px;
}
.stat {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(248,250,252,0.96));
  color: var(--text);
  font: inherit;
  text-align: left;
  width: 100%;
}
.stat-button {
  cursor: pointer;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}
.stat-button:hover,
.stat-button.is-active {
  border-color: rgba(124, 58, 237, 0.42);
  box-shadow: inset 0 0 0 1px rgba(124, 58, 237, 0.12), 0 10px 22px rgba(124, 58, 237, 0.10);
  background: linear-gradient(180deg, rgba(237,233,254,0.95), rgba(255,255,255,0.98));
}
.stat-button:focus-visible {
  outline: 3px solid rgba(124, 58, 237, 0.28);
  outline-offset: 2px;
}
.stat-label {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
  font-weight: 700;
}
.stat-value {
  /* размер и насыщенность цифры задаёт строгая тема (30px/800) — держим
     единый вид плиток во всех отчётах, здесь только отступ под подпись */
  margin-bottom: 6px;
}
.stat-sub {
  font-size: 12px;
  color: var(--muted);
}
.panel {
  overflow: hidden;
}
.section-gap {
  height: 20px;
}
.analysis-note {
  padding: 14px 20px 0;
  color: var(--muted);
  line-height: 1.5;
}
.ai-report {
  margin: 14px 20px 18px;
}
.ai-report[hidden] {
  display: none;
}
.ai-report-title {
  margin: 0 0 12px;
  font-size: 15px;
  line-height: 1.35;
  font-weight: 850;
  color: var(--text);
}
.ai-focus-grid {
  display: grid;
  grid-template-columns: minmax(240px, 1.1fr) minmax(220px, 1fr) minmax(220px, 1fr) minmax(240px, 1fr);
  gap: 12px;
}
.ai-focus-card {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fafc;
  overflow-wrap: anywhere;
}
.ai-focus-card.is-warn {
  background: #fff7ed;
  border-color: rgba(180, 83, 9, 0.22);
}
.ai-focus-card.is-ok {
  background: #f0fdf4;
  border-color: rgba(21, 128, 61, 0.18);
}
.ai-focus-card h3 {
  margin: 0 0 6px;
  color: #475569;
  font-size: 12px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.ai-focus-card ul {
  margin: 0;
  padding-left: 18px;
  color: var(--text);
  line-height: 1.38;
}
.ai-focus-card li + li {
  margin-top: 4px;
}
.ai-big-value {
  font-size: 24px;
  line-height: 1;
  font-weight: 850;
  color: var(--text);
  margin: 4px 0 6px;
}
.ai-card-title {
  font-weight: 850;
  line-height: 1.3;
}
.ai-manager-list {
  display: grid;
  gap: 8px;
}
.ai-manager {
  min-width: 0;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.28);
}
.ai-manager:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}
.ai-manager-name {
  font-weight: 800;
  line-height: 1.25;
}
.ai-metrics {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}
.ai-risks-line {
  margin-top: 10px;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
}
.panel-head h2 {
  margin: 0;
  font-size: 18px;
}
.meta {
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}
.error {
  display: none;
  margin-bottom: 16px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--bad-soft);
  color: var(--bad);
  border: 1px solid rgba(185, 28, 28, 0.18);
}
.table-wrap {
  overflow: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1320px;
}
th,
td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
th {
  background: #f8fafc;
  color: #57708f;
  font-size: 12px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
td a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 700;
}
td a:hover {
  text-decoration: underline;
}
.question {
  max-width: 420px;
  white-space: pre-wrap;
  line-height: 1.45;
}
.muted {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}
.badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-bad { background: var(--bad-soft); color: var(--bad); }
.empty-row td,
.loading-row td {
  color: var(--muted);
  padding-top: 20px;
  padding-bottom: 20px;
}
@media (max-width: 1100px) {
  .filters form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ai-focus-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .page { padding: 18px 12px 28px; }
  .hero,
  .filters,
  .stats,
  .panel { border-radius: 14px; }
  .hero h1 { font-size: 24px; }
  .filters form,
  .stats { grid-template-columns: 1fr; }
  .ai-focus-grid { grid-template-columns: 1fr; }
  .panel-head { flex-direction: column; align-items: flex-start; }
  .meta { text-align: left; }
}
