:root {
  --bg: #f5f6f8;
  --card-bg: #ffffff;
  --text: #1a1d23;
  --muted: #6b7280;
  --primary: #1d6fd6;
  --primary-dark: #1657ab;
  --border: #dde1e7;
  --danger: #c0362c;
  --success: #1f8a4c;
  --warn: #b8860b;
  --radius: 12px;
}

* { box-sizing: border-box; }

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

.topbar {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  text-decoration: none;
}

.brand-logo {
  height: 40px;
  width: auto;
}

.topnav {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  font-size: 0.9rem;
}

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

.emergency-link {
  color: var(--danger) !important;
  font-weight: 600;
}

.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 1rem;
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.level-card {
  text-align: center;
}

.level-card h1 {
  font-size: 2.5rem;
  margin: 0 0 0.25rem;
}

.muted { color: var(--muted); font-size: 0.9rem; }
.ok { color: var(--success); font-weight: 600; }
.warn { color: var(--warn); font-weight: 600; }
.hint { color: var(--muted); font-size: 0.85rem; margin-top: -0.5rem; }

.button-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.button {
  display: inline-block;
  text-align: center;
  padding: 0.9rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
}

.button-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.button-primary:active { background: var(--primary-dark); }

.button-full {
  display: block;
  width: 100%;
  margin-bottom: 1rem;
}

form {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

label {
  font-weight: 600;
  margin-top: 0.6rem;
  font-size: 0.95rem;
}

label.checkbox {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-weight: 500;
}

label.checkbox input {
  margin-top: 0.2rem;
  flex-shrink: 0;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
textarea {
  padding: 0.75rem;
  font-size: 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  width: 100%;
  background: #fff;
  color: var(--text);
}

fieldset {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  margin-top: 0.6rem;
}

legend {
  font-weight: 700;
  padding: 0 0.4rem;
}

.callout {
  background: #fff8e6;
  border: 1px solid #f0d98a;
  border-radius: 8px;
  padding: 0.75rem;
  margin-top: 0.6rem;
}

button[type="submit"] {
  margin-top: 1rem;
}

.flashes {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
}

.flash {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.flash-error { background: #fdecea; color: var(--danger); border: 1px solid #f3b3ac; }
.flash-success { background: #eaf7ef; color: var(--success); border: 1px solid #a9dcbb; }

.log-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.log-list li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}

.log-list li:last-child { border-bottom: none; }

.admin-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

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

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

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.85rem;
}

th, td {
  padding: 0.5rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

.inline-form {
  display: inline;
}

.link-button {
  background: none;
  border: none;
  color: var(--danger);
  padding: 0;
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
}

.emergency-card h2 { margin-top: 1.25rem; }

.contact-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.receipt-table {
  width: 100%;
  border-collapse: collapse;
}

.receipt-table td {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.receipt-table td:first-child {
  color: var(--muted);
  width: 40%;
  white-space: nowrap;
}

.receipt-table tr:last-child td {
  border-bottom: none;
}

.contact-table td {
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
}

.emergency-list {
  background: #fff8e6;
  border: 1px solid #f0d98a;
  border-radius: 8px;
  padding: 1rem 1.5rem;
}

.footer {
  text-align: center;
  padding: 1.5rem;
  font-size: 0.8rem;
}

.footer a {
  color: var(--muted);
}

@media (min-width: 600px) {
  .topbar {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
}
