:root {
  --bg: #f6f7fb;
  --text: #172033;
  --muted: #667085;
  --primary: #1f4ed8;
  --primary-dark: #173fb1;
  --border: #d9deea;
  --card: #ffffff;
  --danger-bg: #fff1f0;
  --danger: #b42318;
  --warn-bg: #fff8e6;
  --warn: #92400e;
  --success-bg: #ecfdf3;
  --success: #067647;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.45;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.topbar {
  display: flex;
  gap: 24px;
  align-items: center;
  justify-content: space-between;
  padding: 14px 26px;
  background: #111827;
  color: #fff;
}
.brand { color: #fff; font-size: 20px; font-weight: 800; letter-spacing: .2px; }
.brand:hover { text-decoration: none; }
.topbar nav { display: flex; gap: 14px; flex: 1; }
.topbar nav a { color: #e5e7eb; font-weight: 600; }
.user-box { display: flex; align-items: center; gap: 10px; }
.user-box small { color: #cbd5e1; display: block; }
.container { width: min(1220px, calc(100% - 32px)); margin: 28px auto; }
.page-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; }
h1, h2, h3, h4 { margin-top: 0; }
.lead { font-size: 18px; color: var(--muted); max-width: 720px; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 8px 28px rgba(17, 24, 39, .05);
  margin-bottom: 18px;
}
.grid { display: grid; gap: 16px; }
.stats { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 20px; }
.stats .card span { display: block; color: var(--muted); }
.stats .card strong { display: block; font-size: 34px; margin-top: 6px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.form { display: grid; gap: 14px; }
.form.wide { max-width: 760px; }
.form.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form.compact label:nth-child(4), .form.compact label:last-of-type { grid-column: 1 / -1; }
label { display: grid; gap: 6px; font-weight: 700; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  background: #fff;
}
textarea { resize: vertical; }
button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
}
button:hover, .button:hover { background: var(--primary-dark); text-decoration: none; }
button.secondary, .button.secondary { background: #e5e7eb; color: #111827; }
button.secondary:hover, .button.secondary:hover { background: #d1d5db; }
.link-button { background: transparent; padding: 0; color: #fff; font-weight: 600; }
.link-button:hover { background: transparent; text-decoration: underline; }
.inline-form { display: flex; align-items: center; gap: 8px; }
.inline-form input[type="date"] { width: 155px; }
.actions { min-width: 260px; }
.button-row { display: flex; gap: 10px; }
.notice, .warning, .success, .error {
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 18px;
  font-weight: 700;
}
.notice { background: #eef4ff; color: #183b8f; border: 1px solid #c7d7fe; }
.warning { background: var(--warn-bg); color: var(--warn); border: 1px solid #fedf89; }
.success { background: var(--success-bg); color: var(--success); border: 1px solid #abefc6; }
.error { background: var(--danger-bg); color: var(--danger); border: 1px solid #fecdca; }
.login-panel { display: grid; grid-template-columns: 1.4fr .8fr; gap: 28px; align-items: start; margin-top: 50px; }
.demo-box { margin-top: 24px; background: #fff; border: 1px dashed var(--border); border-radius: 14px; padding: 16px; }
code { background: #eef2ff; padding: 2px 6px; border-radius: 6px; }
.hint { color: var(--muted); font-size: 14px; }
.radio { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.radio input { width: auto; }
fieldset { border: 1px solid var(--border); border-radius: 12px; padding: 12px; }
.badge { display: inline-flex; align-items: center; background: #e0e7ff; color: #1e3a8a; border-radius: 999px; padding: 3px 8px; font-size: 12px; font-weight: 800; margin-right: 4px; }
.badge.muted { background: #f2f4f7; color: #475467; }
.question h3 { margin: 12px 0 6px; }
.question-head { display: flex; justify-content: space-between; gap: 12px; }
.evidence-box { background: #f8fafc; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin: 12px 0; }
.answer-form { display: grid; grid-template-columns: minmax(180px, 260px) 1fr auto; gap: 12px; align-items: end; }
.answer-form .hint { grid-column: 1 / -1; margin: 0; }
.evidence-list { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 12px; }
ul { padding-left: 22px; }
@media (max-width: 900px) {
  .topbar, .page-header, .answer-form, .login-panel { display: block; }
  .topbar nav { margin: 12px 0; flex-wrap: wrap; }
  .stats, .form.compact { grid-template-columns: 1fr; }
  .form.compact label:nth-child(4), .form.compact label:last-of-type { grid-column: auto; }
  .user-box { justify-content: space-between; }
}
.button-row form { margin: 0; }
.badge.danger { background: #fee4e2; color: #b42318; }
.small-strong { font-size: 18px !important; word-break: break-word; }
.analytics-stats .card small, .stats .card small { color: var(--muted); display: block; margin-top: 4px; }
.card table { display: block; overflow-x: auto; }
.card table thead, .card table tbody, .card table tr { width: 100%; }
.stacked-actions { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.checkbox-row input { width: auto; }
legend { font-weight: 800; color: var(--primary); padding: 0 6px; }

.version-badge { font-size: 0.75rem; opacity: 0.65; margin-left: 0.5rem; align-self: center; }

.report-cover .stats .card { box-shadow: none; }
.compact-table th, .compact-table td { font-size: 13px; padding: 8px 6px; }
.report-header { align-items: center; }
@media print {
  body { background: #fff; font-size: 11px; }
  .topbar, .no-print, .notice { display: none !important; }
  .container { width: 100%; margin: 0; }
  .card { box-shadow: none; border: 1px solid #cbd5e1; break-inside: avoid; page-break-inside: avoid; }
  .page-break { break-before: page; page-break-before: always; }
  a { color: #111827; text-decoration: none; }
  .stats { grid-template-columns: repeat(4, 1fr); }
  table { font-size: 10px; }
  th, td { padding: 5px 4px; }
  .badge { border: 1px solid #cbd5e1; }
}
.code-box { background: #f8fafc; border: 1px solid var(--border); border-radius: 12px; padding: 16px; margin: 16px 0; }
.code-box code { display: inline-block; font-size: 18px; word-break: break-all; margin-top: 8px; }
