/* Стили пресейл-контура. Без внешних CDN: контур закрытый, шрифты системные. */

:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --border: #dfe4ec;
  --text: #16202e;
  --muted: #6b7785;
  --accent: #1f5fd0;
  --accent-dark: #17489c;
  --ok: #1a7f4b;
  --warn: #a86a00;
  --danger: #c0392b;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 30, 54, .06), 0 4px 12px rgba(16, 30, 54, .04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* --- Шапка --- */

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 24px;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand { font-weight: 650; color: var(--text); text-decoration: none; white-space: nowrap; }

.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }

.nav a {
  padding: 6px 12px;
  border-radius: 6px;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}

.nav a:hover { background: var(--bg); color: var(--text); }
.nav a.active { background: #eaf1fd; color: var(--accent-dark); font-weight: 550; }

.user-box { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.user-name { color: var(--muted); }
.logout { color: var(--muted); text-decoration: none; }
.logout:hover { color: var(--danger); }

/* --- Сетка страницы --- */

.page { flex: 1; width: 100%; max-width: 1220px; margin: 0 auto; padding: 24px; }
.page.narrow-page { max-width: 560px; }

h1 { font-size: 24px; margin: 0 0 4px; }
h2 { font-size: 18px; margin: 28px 0 12px; }
h3 { font-size: 15px; margin: 20px 0 8px; }

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.subtitle { color: var(--muted); margin: 0; }
.muted { color: var(--muted); }
.center { text-align: center; }

/* --- Карточки --- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.card.narrow { max-width: 460px; margin: 60px auto; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

/* --- Плитки показателей --- */

.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.stat-value { font-size: 26px; font-weight: 650; line-height: 1.2; }
.stat-label { color: var(--muted); font-size: 13px; margin-top: 4px; }
.stat-value.ok { color: var(--ok); }
.stat-value.warn { color: var(--warn); }
.stat-value.danger { color: var(--danger); }

/* --- Таблицы --- */

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }

th {
  text-align: left;
  font-weight: 550;
  color: var(--muted);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td { padding: 9px 10px; border-bottom: 1px solid #eef1f6; vertical-align: top; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tfoot td { font-weight: 600; border-top: 2px solid var(--border); }

/* --- Значки --- */

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 12px;
  background: #eef1f6;
  color: var(--muted);
  white-space: nowrap;
}

.badge.ok { background: #e4f5ec; color: var(--ok); }
.badge.warn { background: #fdf1dd; color: var(--warn); }
.badge.danger { background: #fbe9e7; color: var(--danger); }
.badge.accent { background: #eaf1fd; color: var(--accent-dark); }

/* --- Формы --- */

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font: inherit;
  background: var(--surface);
  color: var(--text);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 95, 208, .12);
}

textarea { min-height: 90px; resize: vertical; }
input.code, textarea.code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }

.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row > * { flex: 1; min-width: 180px; }

.checkline { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.checkline input { width: auto; }

/* --- Кнопки --- */

.btn {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 7px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 550;
  text-decoration: none;
  cursor: pointer;
}

.btn:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn.secondary:hover { background: var(--bg); }
.btn.danger { background: var(--danger); border-color: var(--danger); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* --- Уведомления --- */

.alert { padding: 12px 14px; border-radius: 8px; margin-bottom: 16px; border: 1px solid; }
.alert-error { background: #fbe9e7; border-color: #f3c4bd; color: #8e2b1f; }
.alert-notice { background: #e4f5ec; border-color: #b9e2cc; color: #145f38; }
.alert-warn { background: #fdf1dd; border-color: #f0d9ac; color: #7d4f00; }
.alert ul { margin: 6px 0 0; padding-left: 18px; }

/* --- Мелочи --- */

.error-code { font-size: 48px; margin: 0 0 8px; }
.list-reset { list-style: none; padding: 0; margin: 0; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.divider { height: 1px; background: var(--border); margin: 20px 0; border: none; }
.empty { padding: 32px; text-align: center; color: var(--muted); }

.footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

/* --- Публичная анкета: отдельная, более просторная вёрстка --- */

.survey-page { max-width: 720px; margin: 0 auto; padding: 32px 20px 60px; }
.survey-head { margin-bottom: 24px; }
.progress { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; margin: 16px 0 4px; }
.progress > span { display: block; height: 100%; background: var(--accent); transition: width .2s; }
.question { padding: 18px 0; border-bottom: 1px solid #eef1f6; }
.question:last-of-type { border-bottom: none; }
.question .qtext { font-weight: 550; margin-bottom: 6px; }
.question .qhint { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.scale-row { display: flex; gap: 8px; flex-wrap: wrap; }
.scale-row label { display: flex; align-items: center; gap: 4px; }

@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 16px; gap: 12px; }
  .page { padding: 16px; }
}
