:root {
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f5f7fb;
  --card: #ffffff;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --ok: #059669;
  --warn: #d97706;
  --danger: #dc2626;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px -12px rgba(15, 23, 42, .18);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { width: min(1080px, 100% - 32px); margin: 0 auto; }
.narrow { width: min(720px, 100% - 24px); }

.topbar {
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 0; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  color: #fff; font-weight: 700; font-size: 13px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text small { color: var(--muted); font-size: 11px; }
.nav { display: flex; align-items: center; gap: 14px; font-size: 14px; flex-wrap: wrap; }

main.wrap { padding: 22px 0 40px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.card h2, .card h3 { margin-top: 0; }
.card-tight { padding: 14px; }

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

.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.stat .value { font-size: 24px; font-weight: 700; }
.stat .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }

label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
input, select, textarea {
  width: 100%; padding: 9px 11px; font-size: 14px; font-family: inherit;
  border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(37, 99, 235, .35); border-color: var(--accent); }
.field { margin-bottom: 12px; }
.hint { color: var(--muted); font-size: 12px; margin-top: 4px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px; font-size: 14px; font-weight: 600; font-family: inherit;
  border: 1px solid transparent; border-radius: 10px; background: var(--accent);
  color: #fff; cursor: pointer;
}
.btn:hover { background: var(--accent-dark); text-decoration: none; }
.btn-secondary { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-secondary:hover { background: #f8fafc; }
.btn-ok { background: var(--ok); }
.btn-warn { background: var(--warn); }
.btn-danger { background: var(--danger); }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.btn-lg { padding: 13px 22px; font-size: 16px; width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row-between { display: flex; gap: 12px; justify-content: space-between; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
tbody tr:hover { background: #f8fafc; }
.table-scroll { overflow-x: auto; }

.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; border: 1px solid transparent;
}
.badge-ok { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.badge-warn { background: #fffbeb; color: #b45309; border-color: #fde68a; }
.badge-danger { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.badge-info { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.badge-muted { background: #f1f5f9; color: #475569; border-color: #e2e8f0; }

.flash { padding: 11px 14px; border-radius: 10px; margin-bottom: 14px; font-size: 14px; border: 1px solid; }
.flash-success { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.flash-error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.flash-info { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }

.footer { border-top: 1px solid var(--line); background: #fff; padding: 16px 0 26px; }
.footer p { color: var(--muted); font-size: 12px; margin: 0; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.center { text-align: center; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }

.progress { height: 8px; border-radius: 999px; background: #e2e8f0; overflow: hidden; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), #7c3aed); }

/* respondent flow */
body.respondent { background: #f8fafc; }
.respondent-card { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 20px; box-shadow: var(--shadow); }
.question-block { margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1px dashed var(--line); }
.question-block:last-of-type { border-bottom: none; }
.question-text { font-weight: 600; margin: 0 0 10px; }
.option {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 11px 13px; border: 1px solid var(--line); border-radius: 11px;
  margin-bottom: 8px; cursor: pointer; background: #fff; font-size: 14px;
}
.option:hover { border-color: #bfdbfe; background: #f8fbff; }
.option input { width: auto; margin-top: 3px; }
.option.is-selected { border-color: var(--accent); background: #eff6ff; }
.step-list { list-style: none; padding: 0; margin: 0; }
.step-list li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.step-list li:last-child { border-bottom: none; }

.qr-box { text-align: center; }
.qr-box img { width: 190px; height: 190px; image-rendering: pixelated; border: 1px solid var(--line); border-radius: 12px; background: #fff; padding: 8px; }

.chart { width: 100%; border: 1px solid var(--line); border-radius: 12px; background: #fff; }

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

.scale-row { display: grid; grid-template-columns: 1fr 2.2fr auto; gap: 10px; align-items: center; margin-bottom: 9px; font-size: 13px; }
.scale-bar { height: 10px; border-radius: 999px; background: #e2e8f0; overflow: hidden; }
.scale-bar > span { display: block; height: 100%; }

@media (max-width: 560px) {
  .topbar-inner { flex-direction: column; align-items: flex-start; }
  .stat .value { font-size: 20px; }
}

.matrix-lead { background: #eff6ff; }
th.matrix-lead { background: #dbeafe; }
