:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --primary: #2563eb;
  --secondary: #0f172a;
  --success: #16a34a;
  --danger: #dc2626;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.page-shell {
  max-width: 860px;
  margin: 0 auto;
  padding: 24px;
}

header.header-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.role-switcher {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.role-switcher label {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
  font-weight: 400;
  margin: 0;
  display: inline;
}

.role-switcher select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  font-size: 0.875rem;
  cursor: pointer;
  width: auto;
  margin: 0;
  font-weight: 500;
}

h1 { margin: 0; font-size: 2rem; }
.subtitle { margin: 4px 0 0; color: var(--muted); }

.card, .panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 18px;
}

.panel { display: none; }
.panel.active { display: block; }
.hidden { display: none !important; }

button, input, select { font: inherit; }

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  cursor: pointer;
  white-space: nowrap;
  gap: 6px;
}

button.primary   { background: var(--primary); color: white; }
button.secondary { background: #e2e8f0; color: var(--secondary); }
button:disabled  { opacity: 0.4; cursor: not-allowed; }

input, select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-top: 6px;
}

label {
  display: block;
  font-weight: 500;
  margin-bottom: 14px;
}

/* ── Toolbar ── */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.toolbar-tabs { display: flex; gap: 6px; flex-wrap: wrap; }

.context-group {
  display: flex;
  flex-direction: column;
  line-height: 1.35;
}

.context-label {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 500;
}

.tab-button {
  background: #f1f5f9;
  color: var(--secondary);
  padding: 10px 16px;
}

.tab-button.active {
  background: var(--primary);
  color: white;
}

/* ── Panel header ── */
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
  gap: 12px;
}

.panel-header h2 { margin: 0 0 4px; }

.date-line {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 500;
}

/* ── Log controls ── */
.log-controls {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.log-controls label {
  flex: 1;
  min-width: 160px;
  margin: 0;
}

/* ── Child card ── */
.child-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px 24px;
  margin-bottom: 14px;
}

.child-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.child-name {
  margin: 0 0 4px;
  font-size: 1.15rem;
}

.child-meta {
  margin: 0;
  font-size: 0.875rem;
  color: var(--muted);
}

.child-timeline {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.not-in-reason-banner {
  margin-top: 10px;
  padding: 8px 12px;
  background: #fef9c3;
  color: #854d0e;
  border-left: 3px solid #eab308;
  border-radius: 4px;
  font-size: 0.85rem;
}

.timeline-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tl-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.tl-value {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

/* ── Status chips ── */
.status-chip {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 99px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

.chip-absent  { background: #f1f5f9; color: var(--muted); }
.chip-entry   { background: #dcfce7; color: #15803d; }
.chip-exited  { background: #dbeafe; color: #1d4ed8; }
.chip-not-in  { background: #fef9c3; color: #854d0e; }

/* ── Attendance table (history) ── */
.attendance-table-wrapper { overflow-x: auto; }

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

.attendance-table th,
.attendance-table td {
  border: 1px solid var(--border);
  padding: 10px 14px;
  text-align: left;
  vertical-align: middle;
}

.attendance-table th {
  background: #f1f5f9;
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
}

/* ── Status messages ── */
.status {
  margin-top: 14px;
  font-size: 0.95rem;
  min-height: 1.2em;
}

.status.error   { color: var(--danger);  }
.status.success { color: var(--success); }
.muted          { color: var(--muted); font-style: italic; }

/* ── Student photo thumbnails ── */
.child-photo {
  width: 52px;
  height: 52px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.child-photo-placeholder {
  width: 52px;
  height: 52px;
  border-radius: 10px;
  background: var(--primary);
  color: white;
  font-weight: 700;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.child-info-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

/* ── Student type badges ── */
.type-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.type-school         { background: #dbeafe; color: #1d4ed8; }
.type-daycare        { background: #fef9c3; color: #854d0e; }
.type-day-and-school { background: #ede9fe; color: #6d28d9; }

/* ── Toolbar actions ── */
.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ── Bell button ── */
.bell-btn {
  position: relative;
  background: #f1f5f9;
  color: var(--secondary);
  padding: 10px 12px;
  font-size: 1.1rem;
  border-radius: 10px;
}

.bell-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  background: #dc2626;
  color: white;
  font-size: 0.6rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 99px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  pointer-events: none;
}

/* ── Notification wrapper & dropdown ── */
.notif-wrapper {
  position: relative;
}

.notif-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 320px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  z-index: 100;
  overflow: hidden;
}

.notif-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}

.notif-title {
  font-weight: 600;
  font-size: 0.9rem;
}

.mark-read-btn {
  background: none;
  border: none;
  padding: 4px 8px;
  font-size: 0.75rem;
  color: var(--primary);
  cursor: pointer;
  border-radius: 6px;
}

.mark-read-btn:hover {
  background: #eff6ff;
}

#notif-list {
  max-height: 360px;
  overflow-y: auto;
}

.notif-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.notif-item:last-child {
  border-bottom: none;
}

.notif-item.unread {
  background: #eff6ff;
}

.notif-text {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 2px;
}

.notif-meta {
  font-size: 0.75rem;
  color: var(--muted);
}

.notif-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 0.875rem;
}

/* ── Responsive ── */
@media (max-width: 600px) {
  .toolbar { flex-direction: column; align-items: flex-start; }
  .panel-header { flex-direction: column; }
  .log-controls { flex-direction: column; align-items: stretch; }
  .child-card-header { flex-direction: column; }
  .notif-dropdown { width: calc(100vw - 48px); right: auto; left: 0; }
}
