/* ── Reset & Base ─────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:    #dd4545;
  --primary-dk: #c03939;
  --secondary:  #86ddf7;
  --sec-dk:     #5bc8ef;
  --white:      #ffffff;
  --bg:         #f5f6f8;
  --card-bg:    #ffffff;
  --border:     #e8e8e8;
  --text:       #1a1a1a;
  --text-mid:   #555555;
  --text-muted: #888888;
  --radius:     10px;
  --radius-sm:  6px;
  --shadow:     0 1px 4px rgba(0,0,0,0.08);
  --shadow-md:  0 2px 10px rgba(0,0,0,0.10);

  --team-red:    #ef4444;
  --team-blue:   #3b82f6;
  --team-yellow: #f59e0b;
  --team-green:  #22c55e;
}

html { font-size: 16px; }

body {
  font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

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

/* ── Login Page ───────────────────────────────────────────────────────────── */

.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--white);
  padding: 1.5rem;
}

.login-container { width: 100%; max-width: 400px; }

.login-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.5rem 2rem;
  box-shadow: var(--shadow-md);
}

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.login-logo {
  width: 64px;
  height: 64px;
  background: var(--primary);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
}

.logo-k {
  font-size: 2rem;
  font-weight: 700;
  color: var(--white);
  line-height: 1;
}

.login-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
}

.login-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  font-weight: 500;
}

.login-form { display: flex; flex-direction: column; gap: 1rem; }

.form-group { display: flex; flex-direction: column; gap: 0.4rem; }

.form-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-mid);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 1rem;
  color: var(--text);
  background: var(--white);
  transition: border-color 0.15s;
  outline: none;
}
.form-input:focus { border-color: var(--primary); }

.error-msg {
  font-size: 0.875rem;
  color: var(--primary);
  font-weight: 500;
  text-align: center;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */

.btn-primary {
  background: var(--primary);
  color: var(--white);
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.75rem 1.25rem;
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.btn-primary:hover:not(:disabled) { background: var(--primary-dk); }
.btn-primary:active:not(:disabled) { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-full { width: 100%; }

.btn-secondary {
  background: var(--secondary);
  color: var(--text);
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.5rem 1rem;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-secondary:hover { background: var(--sec-dk); }

.btn-outline {
  background: transparent;
  color: var(--text-mid);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 1rem;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.btn-outline:hover { border-color: var(--text-mid); color: var(--text); }

.btn-logout {
  background: transparent;
  color: var(--text-muted);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.375rem 0.875rem;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.btn-logout:hover { color: var(--primary); border-color: var(--primary); }

/* ── App Header ───────────────────────────────────────────────────────────── */

.app-body { min-height: 100vh; background: var(--bg); }

.app-header {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.logo-k-sm {
  width: 32px;
  height: 32px;
  background: var(--primary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 700;
  color: var(--white);
}

.header-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text);
}

.header-location {
  flex: 1;
  text-align: center;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--primary);
}

/* ── Tab Nav ──────────────────────────────────────────────────────────────── */

.tab-nav {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tab-btn {
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 0.875rem 1rem;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
  display: flex;
  align-items: center;
  gap: 0.375rem;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

.tab-count {
  background: var(--bg);
  color: var(--text-mid);
  border-radius: 20px;
  padding: 0.1rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  min-width: 1.5rem;
  text-align: center;
}
.tab-btn.active .tab-count {
  background: rgba(221,69,69,0.12);
  color: var(--primary);
}

/* ── Sub-Tab Nav ──────────────────────────────────────────────────────────── */

.sub-tab-nav {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.sub-tab-btn {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  padding: 0.5rem 1rem;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}
.sub-tab-btn:hover { color: var(--text); }
.sub-tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

.sub-tab-content { display: none; }
.sub-tab-content.active { display: block; }

/* ── Tab Content ──────────────────────────────────────────────────────────── */

.tab-content { display: none; }
.tab-content.active { display: block; }

.app-main {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
}

/* ── Loading / Empty States ───────────────────────────────────────────────── */

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 3rem 1rem;
  color: var(--text-muted);
  font-size: 0.9375rem;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 2.5rem 1rem;
  font-size: 0.9375rem;
}

.error-text { color: var(--primary); font-weight: 500; }

/* ── Stats Grid (Overview) ────────────────────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-top: 0.25rem;
}

@media (min-width: 600px) {
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
}

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1rem;
  text-align: center;
  box-shadow: var(--shadow);
  transition: box-shadow 0.15s, transform 0.15s;
}

.stat-card.stat-clickable {
  cursor: pointer;
}
.stat-card.stat-clickable:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.stat-card.stat-clickable:active {
  transform: translateY(0);
}

.stat-number {
  font-size: 2.25rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text);
}
.stat-number.primary-color   { color: var(--primary); }
.stat-number.secondary-color { color: #2ba8d4; }

.stat-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 0.375rem;
}
.stat-label small {
  display: block;
  font-size: 0.7rem;
  text-transform: none;
  letter-spacing: 0;
  margin-top: 0.15rem;
  color: var(--text-mid);
  font-weight: 500;
}

.stat-card.stat-good { border-color: #22c55e33; background: #f0fdf4; }
.stat-card.stat-warn { border-color: #f59e0b33; background: #fffbeb; }

/* ── Controls Bar ─────────────────────────────────────────────────────────── */

.controls-bar {
  display: flex;
  gap: 0.625rem;
  margin-bottom: 0.875rem;
  flex-wrap: wrap;
}

.search-input {
  flex: 1;
  min-width: 180px;
  padding: 0.625rem 0.875rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--white);
  outline: none;
  transition: border-color 0.15s;
}
.search-input:focus { border-color: var(--primary); }

.sort-select {
  padding: 0.625rem 0.75rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--text);
  background: var(--white);
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s;
}
.sort-select:focus { border-color: var(--primary); }

/* ── Card List ────────────────────────────────────────────────────────────── */

.card-list { display: flex; flex-direction: column; gap: 0.5rem; }

/* ── Volunteer Cards ──────────────────────────────────────────────────────── */

.vol-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: box-shadow 0.15s;
}
.vol-card.expanded { box-shadow: var(--shadow-md); }

.vol-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1rem;
  cursor: pointer;
  gap: 0.75rem;
  user-select: none;
}
.vol-header:hover { background: #fafafa; }

.vol-name-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  min-width: 0;
}

.vol-name {
  font-weight: 600;
  font-size: 0.9375rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vol-meta {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex-shrink: 0;
}

.team-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 700;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.5rem;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
}
.badge-return { background: rgba(134,221,247,0.3); color: #1a7a9c; }
.badge-gender { background: var(--bg); color: var(--text-mid); }

.chevron {
  font-size: 0.875rem;
  color: var(--text-muted);
  transition: transform 0.2s;
  margin-left: 0.25rem;
  flex-shrink: 0;
}
.vol-card.expanded .chevron,
.family-card.expanded .chevron,
.allergy-card.expanded .chevron { transform: rotate(180deg); }

/* Volunteer Detail Pane */

.vol-details {
  border-top: 1px solid var(--border);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.detail-grid {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.detail-row {
  display: flex;
  gap: 0.5rem;
  font-size: 0.875rem;
  align-items: baseline;
}

.detail-label {
  font-weight: 600;
  color: var(--text-mid);
  min-width: 80px;
  flex-shrink: 0;
  font-size: 0.8125rem;
}

.detail-value {
  color: var(--text);
  flex: 1;
}

.birthdate-muted {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 400;
}

.text-muted { color: var(--text-muted); }

/* Notes Section */

.notes-section { display: flex; flex-direction: column; gap: 0.5rem; }

.notes-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-mid);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.notes-input {
  width: 100%;
  padding: 0.625rem 0.75rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--text);
  background: var(--white);
  resize: vertical;
  outline: none;
  transition: border-color 0.15s;
  min-height: 72px;
}
.notes-input:focus { border-color: var(--primary); }

.notes-footer {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.sheet-notes {
  flex: 1;
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-style: italic;
}

.btn-save {
  background: var(--primary);
  color: var(--white);
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.4rem 1rem;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  flex-shrink: 0;
}
.btn-save:hover { background: var(--primary-dk); }

.save-status {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--team-green);
}

/* ── Assignment Board ─────────────────────────────────────────────────────── */

/*
  Layout:
  [Unassigned (tall)] | [Snacks]  | [Yellow] [Blue ]
                      | [Games ]  | [Red   ] [Green]
*/

.assign-board {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  overflow-x: auto;
  padding-bottom: 1rem;
  -webkit-overflow-scrolling: touch;
}

/* Left: unassigned column, full-height */
.assign-section-unassigned {
  flex: 0 0 190px;
  min-width: 190px;
}
.assign-section-unassigned .assign-col {
  min-height: 360px;
}

/* Middle: Snacks on top, Games underneath */
.assign-section-roles {
  flex: 0 0 155px;
  min-width: 155px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.assign-section-roles .assign-col {
  min-height: 120px;
  flex: 1;
}

/* Right: 2×2 team grid — looks like one box split into 4 */
.assign-section-teams {
  flex: 0 0 310px;
  min-width: 310px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  background: #d1d5db;
  border-radius: var(--radius);
  overflow: hidden;
  padding: 3px;
}
.assign-section-teams .assign-col {
  border-radius: calc(var(--radius) - 2px);
  min-height: 150px;
}

/* Common column styles */
.assign-col {
  background: var(--bg);
  border: 2px solid transparent;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.assign-col.drag-over {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(221,69,69,0.15);
}

.assign-col-header {
  padding: 0.55rem 0.75rem;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}

.assign-col-count {
  background: rgba(255,255,255,0.28);
  border-radius: 20px;
  padding: 0.1rem 0.45rem;
  font-size: 0.7rem;
  font-weight: 700;
}

.assign-col-body {
  padding: 0.5rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.assign-chip {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.625rem;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: grab;
  user-select: none;
  box-shadow: var(--shadow);
  transition: box-shadow 0.15s, opacity 0.15s;
  line-height: 1.3;
}
.assign-chip:hover { box-shadow: var(--shadow-md); }
.assign-chip.dragging { opacity: 0.3; cursor: grabbing; }

.assign-empty {
  color: var(--text-muted);
  font-size: 0.8rem;
  text-align: center;
  padding: 1rem 0.5rem;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  font-style: italic;
}

/* ── Family Cards ─────────────────────────────────────────────────────────── */

.family-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: box-shadow 0.15s;
}
.family-card.expanded { box-shadow: var(--shadow-md); }

.family-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1rem;
  cursor: pointer;
  gap: 0.75rem;
  user-select: none;
}
.family-header:hover { background: #fafafa; }

.family-name {
  font-weight: 600;
  font-size: 0.9375rem;
  flex: 1;
}

.family-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.kids-count {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
}

.allergy-flag {
  font-size: 0.75rem;
  font-weight: 600;
  color: #b45309;
  background: #fef3c7;
  border: 1px solid #fde68a;
  border-radius: 20px;
  padding: 0.15rem 0.5rem;
}

.family-details {
  border-top: 1px solid var(--border);
  padding: 1rem;
}

.parent-info {
  font-size: 0.875rem;
  color: var(--text-mid);
  margin-bottom: 0.875rem;
  padding: 0.625rem 0.75rem;
  background: var(--bg);
  border-radius: var(--radius-sm);
}

/* Kids Table */

.kids-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.kids-table th {
  text-align: left;
  padding: 0.5rem 0.625rem;
  border-bottom: 2px solid var(--border);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.kids-table td {
  padding: 0.5rem 0.625rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: top;
}
.kids-table tbody tr:last-child td { border-bottom: none; }
.kids-table tr.has-allergy td:first-child {
  border-left: 3px solid #f59e0b;
}

.allergy-text {
  color: #92400e;
  font-weight: 600;
  background: #fef3c7;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-size: 0.8125rem;
}
.no-allergy { color: var(--text-muted); font-size: 0.8125rem; }

/* ── Ages Chart ───────────────────────────────────────────────────────────── */

.ages-chart {
  padding: 1.25rem 0.25rem 0.5rem;
}

.ages-chart-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-mid);
  text-align: center;
  margin-bottom: 1.25rem;
}

/* Bars container — full width, tall */
.age-bars {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  height: 300px;                  /* taller chart */
  padding: 0.5rem 0.25rem 0;
  border-bottom: 2px solid var(--border);
  width: 100%;
}

.age-bar-wrap {
  flex: 1;                        /* even distribution across full width */
  max-width: 90px;
  min-width: 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
}

/* Count sits on top of the bar */
.age-bar-count {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.3rem;
}

.age-bar-track {
  width: 100%;
  background: #eef0f3;
  border-radius: 5px 5px 0 0;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  flex: 1;                        /* fills remaining height in wrap */
}

.age-bar-fill {
  width: 100%;
  background: var(--primary);
  border-radius: 4px 4px 0 0;
  min-height: 6px;
  transition: height 0.4s ease;
}

/* Age label beneath the bar */
.age-bar-age {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text-mid);
  margin-top: 0.4rem;
}

.ages-chart-legend {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

/* ── Allergies Section ────────────────────────────────────────────────────── */

.allergies-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.section-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text);
}

.allergy-actions { display: flex; gap: 0.5rem; }

.allergy-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Expandable allergy card */
.allergy-card {
  background: var(--card-bg);
  border: 1px solid #fde68a;
  border-left: 4px solid #f59e0b;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: box-shadow 0.15s;
}
.allergy-card.expanded { box-shadow: var(--shadow-md); }

.allergy-card-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  cursor: pointer;
  user-select: none;
}
.allergy-card-header:hover { background: #fffbeb; }

.allergy-card-info {
  flex: 1;
  min-width: 0;
}

.allergy-kid-line {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.375rem 0.625rem;
  margin-bottom: 0.2rem;
}

.allergy-kid {
  font-weight: 700;
  font-size: 0.9375rem;
  color: var(--text);
}

.allergy-age {
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-weight: 500;
}

.allergy-family-name {
  font-size: 0.8125rem;
  color: var(--text-mid);
  font-weight: 500;
}

.allergy-detail {
  font-size: 0.875rem;
  font-weight: 600;
  color: #92400e;
}

.allergy-card-detail {
  border-top: 1px solid #fde68a;
  padding: 0.875rem 1rem;
  background: #fffdf5;
}

/* ── Mobile / Desktop Dual Kids Layout ───────────────────────────────────── */

/* Mobile default: stacked cards, no table */
.kids-mobile-list { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 0.25rem; }
.kids-desktop-table { display: none; }

@media (min-width: 640px) {
  .kids-mobile-list  { display: none; }
  .kids-desktop-table { display: table; }
}

/* Individual kid card (mobile) */
.kid-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.625rem 0.75rem;
}
.kid-item.kid-has-allergy {
  border-left: 3px solid #f59e0b;
  background: #fffbeb;
}
.kid-item-name {
  font-weight: 600;
  font-size: 0.9375rem;
  margin-bottom: 0.25rem;
}
.kid-item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 0.75rem;
  font-size: 0.8125rem;
  color: var(--text-mid);
}
.kid-item-allergy { margin-top: 0.375rem; }

/* When family-details opens as flex, keep children stacked */
.family-details { flex-direction: column; }

/* ── Tap-to-Assign Banner (Mobile) ───────────────────────────────────────── */

.assign-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: var(--secondary);
  color: var(--text);
  padding: 0.625rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.75rem;
  font-size: 0.875rem;
  font-weight: 600;
  box-shadow: var(--shadow);
}

.btn-cancel-sm {
  background: transparent;
  border: 1.5px solid rgba(0,0,0,0.18);
  border-radius: var(--radius-sm);
  padding: 0.25rem 0.625rem;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s;
}
.btn-cancel-sm:hover { background: rgba(0,0,0,0.08); }

/* Chip selected state */
.assign-chip.chip-selected {
  background: var(--secondary);
  border-color: var(--sec-dk);
  box-shadow: 0 0 0 2px rgba(134,221,247,0.55);
  font-weight: 700;
}

/* Column headers pulse when a chip is selected — tap to assign */
.assign-col-header.tap-target {
  cursor: pointer;
  animation: tap-pulse 1.4s ease-in-out infinite;
}
@keyframes tap-pulse {
  0%, 100% { filter: brightness(1); }
  50%       { filter: brightness(1.18); }
}

/* ── Allergy Frequency Chart ──────────────────────────────────────────────── */

.allergy-freq-chart { margin-bottom: 1.5rem; }

.af-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-mid);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
}

.af-chart {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.af-row {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.af-label {
  width: 130px;
  min-width: 130px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.af-bar-wrap {
  flex: 1;
  height: 18px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
}

.af-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  min-width: 4px;
  transition: width 0.35s ease;
}

.af-count {
  min-width: 22px;
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text-mid);
}

/* Clickable rows for merge */
.af-row {
  cursor: pointer;
  border-radius: 4px;
  padding: 1px 4px;
  transition: background 0.12s;
}
.af-row:hover { background: var(--bg); }
.af-row.af-row-selected {
  background: rgba(134,221,247,0.35);
  outline: 2px solid var(--sec-dk);
  outline-offset: 1px;
}

/* Subtle hint text shown when nothing is selected */
.af-merge-hint-bar {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  font-style: italic;
}

/* Tags showing what's been merged into a bar */
.af-merge-tags {
  padding-left: calc(130px + 0.625rem);
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: -0.15rem;
  margin-bottom: 0.2rem;
}

.af-merge-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  background: rgba(134,221,247,0.2);
  border: 1px solid var(--sec-dk);
  border-radius: 20px;
  padding: 0.1rem 0.45rem 0.1rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 600;
  color: #1a6f8e;
}

.af-merge-tag-x {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.875rem;
  line-height: 1;
  padding: 0;
  transition: color 0.12s;
}
.af-merge-tag-x:hover { color: var(--primary); }

/* Past-application fill indicator on volunteer detail rows */
.arc-fill-mark {
  display: inline-flex;
  align-items: center;
  background: rgba(134,221,247,0.2);
  color: #1a6f8e;
  border-radius: 4px;
  padding: 0.05rem 0.35rem;
  font-size: 0.68rem;
  font-weight: 700;
  margin-left: 0.3rem;
  vertical-align: middle;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

/* ── Archived Applications ────────────────────────────────────────────────── */

.archived-section {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.archived-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.625rem 0.875rem;
  background: var(--bg);
  cursor: pointer;
  user-select: none;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-mid);
  transition: background 0.15s;
}
.archived-header:hover { background: #e8eaed; }
.archived-header.expanded .chevron { transform: rotate(180deg); }

.archived-body {
  border-top: 1px solid var(--border);
  padding: 0.75rem;
  background: var(--white);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.arc-entry { font-size: 0.8125rem; }

.arc-entry-year {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.2rem;
}

.arc-field {
  color: var(--text);
  font-size: 0.8125rem;
  line-height: 1.6;
}

.arc-tag {
  display: inline-flex;
  align-items: center;
  background: rgba(134,221,247,0.25);
  color: #1a6f8e;
  border-radius: 4px;
  padding: 0.1rem 0.35rem;
  font-size: 0.7rem;
  font-weight: 700;
  margin-right: 0.3rem;
  vertical-align: middle;
}

.arc-name-match {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 400;
  margin-left: 0.25rem;
}

/* Pending name-match section */
.arc-pending-section {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius-sm);
  padding: 0.75rem;
}

.arc-pending-title {
  font-size: 0.8125rem;
  font-weight: 700;
  color: #92400e;
  margin-bottom: 0.625rem;
}

.arc-pending-item {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.5rem 0 0;
  border-top: 1px solid #fde68a;
}
.arc-pending-item:first-of-type { border-top: none; padding-top: 0; }

.arc-pending-info {
  font-size: 0.8125rem;
  color: var(--text);
  line-height: 1.5;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.2rem 0.5rem;
}

.arc-pending-name {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text);
}

.arc-pending-year {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
}

.arc-pending-email {
  font-size: 0.775rem;
  color: var(--text-muted);
  font-style: italic;
}

.arc-pending-btns {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn-arc-yes {
  background: #22c55e;
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.875rem;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-arc-yes:hover { background: #16a34a; }

.btn-arc-no {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.875rem;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.btn-arc-no:hover { background: var(--primary); color: #fff; }

/* ── Allergen Popup Modal ─────────────────────────────────────────────────── */

.allergen-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.allergen-modal {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: 0 8px 40px rgba(0,0,0,0.22);
  width: 100%;
  max-width: 460px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.am-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.25rem 0.75rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.am-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  flex: 1;
}

.am-close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.am-close:hover { background: var(--primary); color: #fff; border-color: var(--primary); }

.am-body {
  padding: 0.875rem 1.25rem;
  overflow-y: auto;
  flex: 1;
}

.am-combine-hint {
  font-size: 0.8125rem;
  color: var(--text-mid);
  font-style: italic;
  margin-bottom: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: rgba(134,221,247,0.15);
  border-left: 3px solid var(--secondary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.am-count {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.5rem;
}

.am-list {
  display: flex;
  flex-direction: column;
}

.am-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}
.am-row:last-child { border-bottom: none; }

.am-child-info {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.15rem 0.4rem;
  flex: 1;
}

.am-child {
  font-weight: 600;
  color: var(--text);
}

.am-age {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.am-family {
  font-size: 0.8rem;
  color: var(--text-mid);
}

.am-allergy-text {
  font-size: 0.8rem;
  font-weight: 600;
  color: #92400e;
  background: #fef3c7;
  border-radius: 4px;
  padding: 0.15rem 0.4rem;
  white-space: nowrap;
  flex-shrink: 0;
  max-width: 40%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.am-empty {
  color: var(--text-muted);
  font-size: 0.875rem;
  text-align: center;
  padding: 1.5rem;
}

.am-footer {
  padding: 0.875rem 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.625rem;
  align-items: center;
  flex-shrink: 0;
}

/* ── Print Styles ─────────────────────────────────────────────────────────── */

@media print {
  .app-header, .tab-nav, .sub-tab-nav, .controls-bar, .allergy-actions,
  .notes-section, .btn-logout { display: none !important; }

  .tab-content, .sub-tab-content { display: block !important; }
  #tab-overview, #tab-volunteers { display: none !important; }
  #tab-kids { display: block !important; }
  #kids-sub-list, #kids-sub-ages { display: none !important; }
  #kids-sub-allergies { display: block !important; }
  .allergy-card-detail { display: block !important; }

  .allergy-card { break-inside: avoid; }
  body { background: white; }
}

/* ── Responsive ───────────────────────────────────────────────────────────── */

@media (max-width: 480px) {
  .login-card { padding: 2rem 1.25rem; }
  .header-title { display: none; }
  .vol-name { font-size: 0.875rem; }
  .stats-grid { gap: 0.75rem; }
  .stat-number { font-size: 1.75rem; }
  .assign-section-unassigned { flex: 0 0 155px; min-width: 155px; }
  .assign-section-roles { flex: 0 0 130px; min-width: 130px; }
  .assign-section-teams { flex: 0 0 260px; min-width: 260px; }
}
