:root {
  --accent: #c8102e;
  --accent-dark: #9c0c23;
  --ink: #1f2328;
  --muted: #6b7280;
  --bg: #f5f6f8;
  --card: #ffffff;
  --border: #e4e6eb;
  --success: #1a7f37;
  --success-bg: #e9f7ee;
  --radius: 10px;
}

* { box-sizing: border-box; }

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

.topbar {
  background: var(--accent);
  color: #fff;
  padding: 18px 24px;
}

.topbar-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.topbar h1 {
  font-size: 1.25rem;
  margin: 0;
}

.topbar .subtitle {
  font-size: 0.85rem;
  opacity: 0.9;
}

.topbar a {
  color: #fff;
  text-decoration: none;
  font-size: 0.9rem;
  border: 1px solid rgba(255,255,255,0.6);
  padding: 6px 12px;
  border-radius: 6px;
}

.topbar a:hover { background: rgba(255,255,255,0.15); }

.container {
  max-width: 720px;
  margin: 32px auto;
  padding: 0 20px;
}

.container.wide { max-width: 1100px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 20px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

h2 { margin-top: 0; }

.field {
  margin-bottom: 18px;
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 0.92rem;
}

.hint { color: var(--muted); font-size: 0.82rem; margin-top: 4px; }

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
input[type="number"],
select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  background: #fff;
  color: var(--ink);
}

input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(200,16,46,0.12);
}

.radio-group {
  display: flex;
  gap: 20px;
}

.radio-group label {
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}

fieldset {
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 16px;
  margin: 0 0 18px;
}

legend {
  font-weight: 700;
  padding: 0 6px;
  font-size: 0.9rem;
}

button, .btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 11px 22px;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

button:hover, .btn:hover { background: var(--accent-dark); }

.btn.secondary {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--border);
}

.btn.secondary:hover { background: #f0f1f3; }

.btn.danger { background: #b42318; }
.btn.danger:hover { background: #8f1b13; }

.btn.small { padding: 6px 12px; font-size: 0.82rem; }

.error {
  background: #fdecea;
  border: 1px solid #f5b5ab;
  color: #8f1b13;
  padding: 12px 14px;
  border-radius: 8px;
  margin-bottom: 18px;
  font-size: 0.9rem;
}

.error ul { margin: 4px 0 0 18px; padding: 0; }

.success-box {
  background: var(--success-bg);
  border: 1px solid #b7e4c7;
  color: var(--success);
  padding: 18px;
  border-radius: 8px;
  margin-bottom: 18px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.stat-card .value {
  font-size: 1.8rem;
  font-weight: 700;
}

.stat-card .label {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 2px;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.toolbar .actions { display: flex; gap: 10px; flex-wrap: wrap; }

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: 0.86rem;
}

thead th {
  background: #fafafa;
  text-align: left;
  padding: 10px 10px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

tbody tr.selected-row {
  background: var(--success-bg);
}

tbody tr:hover { background: #fbfbfc; }

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
}

.badge.yes { background: var(--success-bg); color: var(--success); }
.badge.no { background: #f1f2f4; color: var(--muted); }
.badge.selected { background: #1a7f37; color: #fff; }

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

table { border: none; border-radius: 0; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}

.modal-backdrop.open { display: flex; }

.modal {
  background: #fff;
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal h3 { margin-top: 0; }

.footer-note {
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
  margin: 30px 0;
}

.login-wrap {
  max-width: 380px;
  margin: 80px auto;
}

.inline-form { display: inline; }
