:root {
  --bg: #111318;
  --card: #1c1f26;
  --card-2: #23272f;
  --text: #f2f3f5;
  --text-dim: #9aa0ab;
  --accent: #3b82f6;
  --border: #2b2f38;
  --today: #ff453a;
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", Segoe UI, Roboto, sans-serif;
  overscroll-behavior-y: none;
}

#app { max-width: 640px; margin: 0 auto; padding-bottom: 40px; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--bg);
  padding: 12px 16px 4px;
  border-bottom: 1px solid var(--border);
}

.tabs { display: flex; gap: 6px; background: var(--card); border-radius: 10px; padding: 4px; }
.tab-btn {
  flex: 1; padding: 8px 0; border: none; background: transparent; color: var(--text-dim);
  font-size: 14px; font-weight: 600; border-radius: 8px; cursor: pointer;
}
.tab-btn.active { background: var(--accent); color: white; }

.tab-panel { display: none; padding: 16px; }
.tab-panel.active { display: block; }

.calendar-header, .panel-header {
  display: flex; align-items: center; justify-content: space-between;
  margin: 8px 0 12px;
}
.calendar-header h1, .panel-header h1 { font-size: 22px; margin: 0; text-transform: capitalize; }
.nav-btn {
  background: var(--card); border: none; color: var(--text); font-size: 20px;
  width: 36px; height: 36px; border-radius: 50%; cursor: pointer;
}

.weekdays { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; color: var(--text-dim); font-size: 12px; margin-bottom: 4px; }

.calendar-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px;
  touch-action: pan-y;
}
.day-cell {
  background: var(--card); border-radius: 10px; height: 76px; padding: 6px 4px;
  cursor: pointer; position: relative; display: flex; flex-direction: column; gap: 3px;
  border: 1px solid transparent; overflow: hidden;
}
.day-cell.empty { background: transparent; cursor: default; }
.day-cell.selecting { cursor: pointer; }
.day-cell.selected-multi { border-color: var(--accent); background: #1a2c4d; }
.day-cell .day-num {
  font-size: 13px; font-weight: 600; width: 22px; height: 22px; display: flex;
  align-items: center; justify-content: center; border-radius: 50%;
}
.day-cell.today .day-num { background: var(--today); color: white; }
.day-cell .chip {
  font-size: 9.5px; padding: 1.5px 4px; border-radius: 4px; color: white;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.today-btn {
  margin-top: 16px; width: 100%; padding: 10px; border-radius: 10px; border: none;
  background: var(--card); color: var(--accent); font-weight: 600; font-size: 14px; cursor: pointer;
}

.calendar-toolbar { display: flex; gap: 8px; margin-bottom: 10px; }
.toolbar-btn {
  flex: 1; padding: 9px; border-radius: 10px; border: none; font-size: 13px; font-weight: 600;
  background: var(--card); color: var(--text-dim); cursor: pointer;
}
.toolbar-btn.active { background: var(--accent); color: white; }

.multi-select-bar {
  position: sticky; bottom: 0; display: flex; align-items: center; gap: 10px;
  background: var(--card-2); border-radius: 12px; padding: 10px 14px; margin-top: 12px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.4);
}
.multi-select-bar.hidden { display: none; }
.multi-select-bar .count { flex: 1; font-size: 13.5px; color: var(--text-dim); }

.day-cell .multi-check {
  display: none; position: absolute; top: 4px; right: 4px; width: 16px; height: 16px; border-radius: 50%;
  border: 1.5px solid var(--text-dim); background: transparent;
}
.calendar-grid.multi-select-active .day-cell:not(.empty) .multi-check { display: block; }
.day-cell.selected-multi .multi-check { background: var(--accent); border-color: var(--accent); }

.primary-btn {
  background: var(--accent); color: white; border: none; padding: 9px 14px;
  border-radius: 10px; font-weight: 600; font-size: 14px; cursor: pointer;
}
.secondary-btn {
  background: var(--card-2); color: var(--text); border: none; padding: 9px 14px;
  border-radius: 10px; font-weight: 600; font-size: 14px; cursor: pointer;
}

.schools-list { display: flex; flex-direction: column; gap: 10px; }
.school-card {
  background: var(--card); border-radius: var(--radius); padding: 12px 14px;
  display: flex; align-items: center; gap: 12px;
}
.school-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.school-info { flex: 1; min-width: 0; }
.school-name { font-weight: 600; font-size: 15px; }
.school-meta { font-size: 12.5px; color: var(--text-dim); margin-top: 2px; }
.school-issr { font-size: 12.5px; color: var(--accent); margin-top: 2px; font-weight: 600; }
.school-actions { display: flex; gap: 6px; }
.icon-btn {
  background: var(--card-2); border: none; color: var(--text-dim); border-radius: 8px;
  width: 30px; height: 30px; cursor: pointer; font-size: 14px;
}
.school-status-warning { color: #f5a623; font-size: 12px; margin-top: 2px; }

.recap-summary {
  background: var(--card); border-radius: var(--radius); padding: 16px; display: flex;
  justify-content: space-around; text-align: center; margin-bottom: 14px;
}
.recap-summary .metric-value { font-size: 22px; font-weight: 700; }
.recap-summary .metric-label { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

.recap-by-ecole { display: flex; flex-direction: column; gap: 8px; }
.recap-row {
  background: var(--card); border-radius: 10px; padding: 10px 14px;
  display: flex; align-items: center; gap: 10px; font-size: 14px;
}
.recap-row .rname { flex: 1; }
.recap-row .rdays { color: var(--text-dim); font-size: 12.5px; }
.recap-row .ramount { font-weight: 700; color: var(--accent); }

/* Modals */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55);
  display: flex; align-items: flex-end; justify-content: center; z-index: 100;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--card); width: 100%; max-width: 640px; border-radius: 20px 20px 0 0;
  padding: 20px; max-height: 85vh; overflow-y: auto;
}
.modal h2 { margin: 0 0 12px; font-size: 18px; text-transform: capitalize; }
.modal label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 10px; }
.modal input, .modal select {
  width: 100%; margin-top: 4px; padding: 10px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--card-2); color: var(--text); font-size: 15px;
}
.modal input[type="color"] { padding: 2px; height: 38px; }
.form-row { display: flex; gap: 10px; }
.form-row label { flex: 1; }
.modal-label { font-size: 13px; color: var(--text-dim); margin: 10px 0 6px; }
.field-hint { font-size: 11.5px; color: var(--text-dim); margin-top: -6px; margin-bottom: 10px; }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.modal-actions button { flex: 1; }

.segmented { display: flex; gap: 6px; }
.segmented-btn {
  flex: 1; padding: 10px 4px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--card-2); color: var(--text); font-size: 13px; cursor: pointer;
}
.segmented-btn.selected { background: var(--accent); border-color: var(--accent); color: white; }

.issr-preview { margin-top: 10px; font-size: 13px; color: var(--text-dim); }
.issr-preview strong { color: var(--accent); }

.existing-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.existing-item {
  display: flex; align-items: center; gap: 10px; background: var(--card-2);
  border-radius: 10px; padding: 8px 10px; font-size: 13.5px;
}
.existing-item .del-btn { margin-left: auto; background: none; border: none; color: #ff453a; font-size: 14px; cursor: pointer; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #23272f; color: white; padding: 10px 18px; border-radius: 10px;
  font-size: 13.5px; z-index: 200; box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
.toast.hidden { display: none; }
.toast.error { background: #4a1d1d; color: #ff8a80; }
