:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --bg: #f2f5f9;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --danger: #dc2626;
  --success: #16a34a;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
}
.container.wide { max-width: 1080px; }

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

h1, h2, h3 { margin: 0 0 10px; line-height: 1.25; }
h1 { font-size: 22px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }

/* ---------- кнопки ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, opacity .15s;
  text-align: center;
  user-select: none;
}
.btn:hover { background: var(--primary-dark); }
.btn:active { opacity: .85; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; color: var(--primary); border-color: var(--border); }
.btn.ghost:hover { background: #eff6ff; }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #b91c1c; }
.btn.soft { background: #eef2ff; color: var(--primary); }
.btn.soft:hover { background: #e0e7ff; }
.btn.small { min-height: 38px; padding: 7px 14px; font-size: 14px; }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row .btn { flex: 1; min-width: 120px; }

/* ---------- формы ---------- */
.field { margin-bottom: 14px; }
label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
input[type="text"], input[type="password"], input[type="number"], select, textarea {
  width: 100%;
  min-height: 46px;
  padding: 11px 12px;
  font-size: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
}
textarea { min-height: 90px; resize: vertical; font-family: inherit; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
  border-color: var(--primary);
}

.check { display: flex; align-items: center; gap: 8px; }
.check input { width: 20px; height: 20px; }
.check label { margin: 0; font-weight: 500; }

.error-banner {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  padding: 12px 14px;
  border-radius: 10px;
  margin-bottom: 12px;
  font-size: 14px;
}
.success-banner {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #15803d;
  padding: 12px 14px;
  border-radius: 10px;
  margin-bottom: 12px;
  font-size: 14px;
}

/* ---------- шапка приложения ---------- */
.app-header {
  background: var(--primary);
  color: #fff;
  padding: 14px 16px;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
}
.app-header .inner {
  max-width: 1080px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.app-header .brand { font-size: 18px; font-weight: 700; flex: 1; min-width: 160px; }
.app-header .brand a { color: #fff; }
.app-header nav { display: flex; gap: 4px; flex-wrap: wrap; }
.app-header nav a {
  color: #fff;
  opacity: .9;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
}
.app-header nav a:hover { background: rgba(255,255,255,.15); opacity: 1; }
.app-header nav a.active { background: rgba(255,255,255,.22); opacity: 1; }

/* ---------- герой / приветствие ---------- */
.hero { text-align: center; padding: 26px 10px; }
.hero .logo { font-size: 40px; }
.hero h1 { margin: 8px 0 6px; }
.hero p { color: var(--muted); max-width: 520px; margin: 0 auto 16px; }

/* ---------- списки ---------- */
.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 4px;
  border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 600; font-size: 15px; }
.list-item .sub { color: var(--muted); font-size: 13px; }

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge.published { background: #dcfce7; color: #15803d; }
.badge.draft { background: #f1f5f9; color: #64748b; }

/* ---------- вопросы ---------- */
.question-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  background: #fff;
}
.question-card .q-text { font-weight: 600; font-size: 16px; margin-bottom: 4px; }
.question-card .q-hint { color: var(--muted); font-size: 13px; margin-bottom: 12px; }

.option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.option:hover { border-color: #c7d2fe; }
.option input { width: 20px; height: 20px; flex-shrink: 0; cursor: pointer; }
.option .opt-text { flex: 1; }
.option.selected { border-color: var(--primary); background: #eff6ff; }

/* ---------- редактор опроса ---------- */
.editor-question {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  background: #fff;
}
.editor-question .q-head { display: flex; gap: 8px; align-items: flex-start; }
.editor-question .q-head .num { font-weight: 700; color: var(--muted); padding-top: 12px; }
.editor-question .q-head .q-body { flex: 1; }
.option-edit-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.option-edit-row input { flex: 1; }
.icon-btn {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  min-width: 42px;
  min-height: 42px;
  cursor: pointer;
  font-size: 18px;
  color: var(--muted);
}
.icon-btn:hover { background: #f3f4f6; color: var(--text); }
.icon-btn.danger:hover { color: var(--danger); border-color: var(--danger); }

/* ---------- отчёты ---------- */
.report-q { border-bottom: 1px solid var(--border); padding: 16px 0; }
.report-q:last-child { border-bottom: none; }
.report-q .q-title { font-weight: 600; margin-bottom: 10px; }
.bar-row { margin-bottom: 10px; }
.bar-row .bar-label { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 4px; }
.bar-track { height: 10px; background: #eef2f7; border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--primary); border-radius: 999px; transition: width .3s; }

.answer-chip {
  display: inline-block;
  background: #f1f5f9;
  border-radius: 8px;
  padding: 6px 10px;
  margin: 0 6px 6px 0;
  font-size: 14px;
}

/* ---------- таблицы ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: #f8fafc; font-weight: 600; white-space: nowrap; }
tr:last-child td { border-bottom: none; }

/* ---------- прочее ---------- */
.empty { text-align: center; color: var(--muted); padding: 28px 10px; }
.empty .big { font-size: 34px; margin-bottom: 8px; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.spinner {
  width: 26px; height: 26px; border: 3px solid #dbeafe; border-top-color: var(--primary);
  border-radius: 50%; margin: 30px auto; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: #111827;
  color: #fff;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 14px;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
  max-width: 90vw;
}

@media (min-width: 860px) {
  .container { padding: 24px; }
  .app-header .inner { flex-wrap: nowrap; }
}
