/* ===== Base / tokens ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f6f8fc;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --brand: #1d4ed8;
  --brand-2: #0ea5e9;
  --success: #16a34a;
  --danger: #dc3545;
  --shadow: 0 10px 30px rgba(2, 6, 23, 0.08);
  --radius: 16px;
}

body {
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  line-height: 1.55;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.container {
  width: min(980px, 100%);
  margin: 0 auto;
  padding: 0 16px;
}

/* ===== Header / footer ===== */
.site-header {
  color: #fff;
  background: linear-gradient(120deg, var(--brand), var(--brand-2));
  padding: 18px 0;
}

/* Legacy admin header (keeps older admin.html looking good) */
body > header:not(.site-header) {
  color: #fff;
  background: linear-gradient(120deg, var(--brand), var(--brand-2));
  padding: 18px 16px;
  text-align: center;
}

body > header:not(.site-header) h1 {
  font-size: 1.1rem;
  letter-spacing: 0.2px;
  margin-bottom: 10px;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.site-header h1 {
  font-size: 1.1rem;
  letter-spacing: 0.2px;
  margin-bottom: 4px;
}

.subtitle {
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.9rem;
}

.top-actions { display: flex; gap: 8px; }

.link-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  text-decoration: none;
  font-size: 0.95rem;
  white-space: nowrap;
}

.link-pill:hover { background: rgba(255, 255, 255, 0.22); }

.site-footer {
  margin-top: 18px;
  padding: 18px 0;
  color: var(--muted);
}

.footer-inner { text-align: center; }

/* Admin nav */
.admin-nav {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}

.admin-nav button {
  width: auto;
  padding: 0.5rem 0.75rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  cursor: pointer;
  font-size: 0.95rem;
}

.admin-nav button.active {
  background: rgba(255, 255, 255, 0.92);
  color: #0b3d91;
  border-color: rgba(255, 255, 255, 0.92);
}

.admin-section {
  display: none;
}

.admin-section.active {
  display: block;
}

.btn {
  display: inline-block;
  padding: 0.5rem 0.75rem;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

.btn-danger {
  background: #dc3545;
  color: #fff;
}

.btn-secondary {
  background: #6c757d;
  color: #fff;
}

.btn-primary {
  background: #007bff;
  color: #fff;
}

.inline-input {
  width: 7rem;
  max-width: 100%;
  padding: 0.4rem;
  border: 1px solid #ccc;
  border-radius: 4px;
}

main { flex: 1; padding: 18px 0; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header {
  padding: 16px 16px 10px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(29,78,216,0.06), rgba(255,255,255,0));
}

.card-header h2 {
  font-size: 1.05rem;
  margin-bottom: 6px;
}

.hint { color: var(--muted); font-size: 0.92rem; }

.form { padding: 16px; }

fieldset {
  border: 1px solid var(--border);
  margin-bottom: 14px;
  padding: 12px;
  border-radius: 14px;
  background: #fff;
}

legend {
  font-weight: 700;
  padding: 0 6px;
  color: #0b2a6b;
}

label { display: block; }
label span { display: block; font-size: 0.9rem; color: var(--muted); margin-bottom: 6px; }

input[type="text"],
input[type="number"],
input[type="search"] {
  width: 100%;
  padding: 12px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  outline: none;
  font-size: 1rem;
  background: #fff;
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="search"]:focus {
  border-color: rgba(29, 78, 216, 0.55);
  box-shadow: 0 0 0 4px rgba(29, 78, 216, 0.12);
}

.grid { display: grid; gap: 12px; }
.grid.two { grid-template-columns: 1fr; }
.span-2 { grid-column: span 1; }

@media (min-width: 740px) {
  .site-header h1 { font-size: 1.25rem; }
  .grid.two { grid-template-columns: 1fr 1fr; }
  .span-2 { grid-column: span 2; }
}

button,
.btn {
  font-family: inherit;
}

button.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 14px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(120deg, #16a34a, #22c55e);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
}

button.primary:hover { filter: brightness(0.98); }

.message {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px dashed var(--border);
  color: var(--muted);
}

/* ===== Ward selector (cards) ===== */
.ward-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 10px 0 8px;
}

.ward-toolbar .search { flex: 1; }
.ward-toolbar .selected { color: var(--muted); font-size: 0.95rem; white-space: nowrap; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 12px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(29, 78, 216, 0.06);
  color: #0b2a6b;
  font-size: 0.92rem;
}

.chip button {
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
}

.ward-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr;
}

@media (min-width: 560px) {
  .ward-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 920px) {
  .ward-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.ward-card {
  position: relative;
  display: block;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px 12px;
  background: #fff;
  cursor: pointer;
  transition: transform 0.06s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.ward-card:hover {
  border-color: rgba(29, 78, 216, 0.35);
  box-shadow: 0 12px 25px rgba(2, 6, 23, 0.07);
}

.ward-card:active { transform: translateY(1px); }

.ward-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.ward-title {
  font-weight: 800;
  margin-bottom: 8px;
  font-size: 1.0rem;
}

.ward-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 0.92rem;
  color: var(--muted);
  background: #fff;
}

.badge strong { color: var(--text); }

.status {
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.85rem;
  border: 1px solid var(--border);
  color: var(--muted);
  background: rgba(2, 6, 23, 0.02);
}

.status.ok { color: #0b2a6b; background: rgba(14, 165, 233, 0.10); border-color: rgba(14, 165, 233, 0.22); }
.status.full { color: #7c2d12; background: rgba(234, 88, 12, 0.10); border-color: rgba(234, 88, 12, 0.25); }

.ward-card.selected {
  border-color: rgba(29, 78, 216, 0.75);
  box-shadow: 0 14px 28px rgba(29, 78, 216, 0.12);
  background: linear-gradient(180deg, rgba(29,78,216,0.06), rgba(255,255,255,0));
}

.ward-card.selected::after {
  content: '✓';
  position: absolute;
  top: 10px;
  right: 10px;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: rgba(29, 78, 216, 0.12);
  color: #0b2a6b;
  border: 1px solid rgba(29, 78, 216, 0.25);
  font-weight: 900;
}

/* Table styling */
table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
}

th, td {
  border: 1px solid #ddd;
  padding: 0.5rem;
  text-align: left;
}

th {
  background-color: #f2f2f2;
}

tr:nth-child(even) {
  background-color: #f9f9f9;
}

@media (min-width: 600px) {
  /* keep legacy styles compatibility */
}