/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #f5f6fa;
  --surface:   #ffffff;
  --border:    #e0e3eb;
  --text:      #2d3748;
  --text-dim:  #718096;
  --primary:   #4f46e5;
  --primary-hover: #4338ca;
  --danger:    #e53e3e;
  --success:   #38a169;
  --warning:   #d69e2e;
  --tag-tareas: #eb4d4b;
  --tag-estudio: #6c5ce7;
  --tag-proyectos: #00b894;
  --radius:    8px;
  --shadow:    0 1px 3px rgba(0,0,0,.08);
  --shadow-lg: 0 4px 12px rgba(0,0,0,.1);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 14px;
}

/* ===== HEADER ===== */
.app-header {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 24px;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.app-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
}
.app-nav {
  display: flex;
  gap: 4px;
  height: 100%;
  align-items: flex-end;
}
.nav-tab {
  padding: 8px 16px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius) var(--radius) 0 0;
  transition: all .15s;
}
.nav-tab:hover { color: var(--text); background: var(--bg); }
.nav-tab.active { color: var(--primary); background: var(--bg); font-weight: 600; }

/* ===== MAIN ===== */
.app-main { padding: 24px; max-width: 1400px; margin: 0 auto; }
.app-main.dashboard-mode { padding: 0; max-width: none; overflow: hidden; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ===== DASHBOARD ===== */
.dashboard {
  display: grid;
  grid-template-columns: 2fr 1fr;
  height: calc(100vh - 56px);
  overflow: hidden;
  background: var(--bg);
}

.dashboard-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
  border-right: 1px solid var(--border);
}
.dashboard-panel:last-child { border-right: none; }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
  gap: 12px;
}
.panel-header h2 { font-size: 15px; font-weight: 600; }
.panel-date { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.panel-actions { display: flex; gap: 6px; align-items: center; }

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  background: var(--bg);
}

/* Checklist section labels */
.checklist-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--text-dim);
  padding: 10px 2px 6px;
}
.checklist-section-label:first-child { padding-top: 2px; }

/* Checklist task items */
.checklist-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 14px;
  margin-bottom: 8px;
  transition: opacity .2s, border-color .15s;
  cursor: default;
}
.checklist-item:hover { border-color: #c7cadb; }
.checklist-item.done { opacity: 0.4; }

.check-btn {
  width: 26px;
  height: 26px;
  min-width: 26px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--success);
  font-weight: 700;
  transition: all .15s;
  padding: 0;
}
.check-btn:hover { border-color: var(--success); background: #f0fff4; }
.check-btn.checked { background: var(--success); border-color: var(--success); color: #fff; }

.checklist-info { flex: 1; min-width: 0; }
.checklist-concepto {
  font-size: 14px;
  font-weight: 500;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.checklist-deadline {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 3px;
  display: inline-block;
}
.checklist-deadline.urgent { color: var(--danger); font-weight: 600; }
.checklist-deadline.soon   { color: var(--warning); font-weight: 600; }

.checklist-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}
.prio-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  background: var(--bg);
  color: var(--text-dim);
}
.prio-badge[data-prio="5"] { background: #fff0f0; color: var(--danger); }
.prio-badge[data-prio="4"] { background: #fff7e0; color: var(--warning); }
.prio-badge[data-prio="3"] { background: #eef0ff; color: var(--primary); }
.checklist-eta { font-size: 11px; color: var(--text-dim); }

/* Upcoming events */
.upcoming-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
  padding: 10px 13px;
  margin-bottom: 8px;
}
.upcoming-date {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-dim);
}
.upcoming-date.today { color: var(--primary); }
.upcoming-date.tomorrow { color: var(--warning); }
.upcoming-title { font-size: 13px; font-weight: 500; margin-top: 3px; }
.upcoming-time { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.upcoming-countdown {
  display: inline-block;
  margin-top: 5px;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 8px;
  background: var(--bg);
  color: var(--text-dim);
}
.upcoming-countdown.urgent { background: #fff0f0; color: var(--danger); }

/* Mobile: stack panels */
@media (max-width: 700px) {
  .dashboard {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
    height: calc(100dvh - 56px);
  }
  .dashboard-panel { border-right: none; border-bottom: 1px solid var(--border); }
  .dashboard-panel:last-child { border-bottom: none; }
}

/* ===== BUTTONS ===== */
.btn {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
}
.btn:hover { background: var(--bg); border-color: #ccc; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--bg); color: var(--text); }
.btn-small { padding: 4px 10px; font-size: 12px; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: #fff0f0; }

/* ===== TOOLBARS ===== */
.calendar-toolbar, .tasks-toolbar, .stats-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.toolbar-group { display: flex; align-items: center; gap: 8px; }
.week-label { font-weight: 600; font-size: 15px; min-width: 180px; text-align: center; }
.toggle-label {
  display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 13px; color: var(--text-dim);
}
.toggle-label input { accent-color: var(--primary); }

/* ===== CALENDAR GRID ===== */
.calendar-grid-wrapper { overflow-x: auto; }
.calendar-grid {
  display: grid;
  min-width: 700px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.grid-header {
  display: contents;
}
.grid-header-cell {
  padding: 8px 4px;
  text-align: center;
  font-weight: 600;
  font-size: 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  color: var(--text-dim);
}
.grid-header-cell:first-child {
  width: 70px;
  background: var(--surface);
}
.grid-row { display: contents; }
.grid-time {
  padding: 0 4px;
  font-size: 11px;
  color: var(--text-dim);
  text-align: right;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-height: 30px;
}
.grid-cell {
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  min-height: 30px;
  background: var(--surface);
  cursor: pointer;
  transition: background .1s;
  padding: 2px;
  position: relative;
}
.grid-cell:hover { background: #f0f1ff; }
.grid-cell.today-col { background: #fafafe; }

/* Event blocks in cells */
.cell-event {
  padding: 2px 5px;
  margin: 1px 0;
  border-radius: 3px;
  font-size: 10px;
  color: #fff;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: auto;
  box-shadow: 0 1px 2px rgba(0,0,0,.15);
  user-select: none;
}
.cell-event[data-type="Fixed"] { border-left: 3px solid rgba(255,255,255,.5); }

/* Event blocks in grid cells */
.cell-event {
  padding: 2px 4px;
  margin: 1px 0;
  border-radius: 3px;
  font-size: 10px;
  color: #fff;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cell-event[data-type="Tareas"] { background: var(--tag-tareas); }
.cell-event[data-type="Estudio"] { background: var(--tag-estudio); }
.cell-event[data-type="Proyectos"] { background: var(--tag-proyectos); }
.cell-event[data-type="Fixed"] { background: #636e72; }

/* Span multiple rows (merged cells) */
.cell-event.span-2 { min-height: 62px; }
.cell-event.span-3 { min-height: 94px; }
.cell-event.span-4 { min-height: 126px; }

/* ===== LEGEND ===== */
.calendar-legend {
  display: flex; gap: 16px; margin-top: 12px; flex-wrap: wrap;
  font-size: 12px; color: var(--text-dim);
}
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-dot { width: 12px; height: 12px; border-radius: 3px; }

/* ===== TASKS ===== */
.task-form-wrapper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.task-form h3 { margin-bottom: 16px; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--text-dim); }
.form-group input, .form-group select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  background: var(--bg);
}
.form-actions { display: flex; gap: 8px; }
.inline-form { display: flex; gap: 8px; align-items: flex-end; }
.inline-form .form-group { min-width: 160px; }

/* Task list */
.task-list { display: flex; flex-direction: column; gap: 4px; }
.task-row {
  display: grid;
  grid-template-columns: 32px 1fr 120px 50px 50px 50px 80px 80px 100px;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  align-items: center;
  transition: background .1s;
}
.task-row:hover { background: #fafbff; }
.task-row.completed { opacity: .5; text-decoration: line-through; }
.task-prio {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%;
  font-weight: 700; font-size: 13px; color: #fff;
}
.task-prio[data-prio="1"] { background: var(--danger); }
.task-prio[data-prio="2"] { background: var(--warning); }
.task-prio[data-prio="3"] { background: var(--success); }
.task-prio[data-prio="4"] { background: var(--primary); }
.task-prio[data-prio="5"] { background: #2d3748; }
.task-actions { display: flex; gap: 4px; }
.task-actions .btn { padding: 4px 8px; font-size: 12px; }
.progress-bar {
  height: 6px; border-radius: 3px; background: var(--bg); overflow: hidden;
}
.progress-bar-fill { height: 100%; background: var(--success); border-radius: 3px; transition: width .2s; }

/* ===== SUBJECTS ===== */
.subjects-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.subjects-form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.subjects-form-card h3 { margin-bottom: 16px; font-size: 15px; }
.subjects-table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.subjects-table-card h3 { margin-bottom: 16px; font-size: 15px; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--text-dim); padding: 4px 8px; border-bottom: 2px solid var(--border); }
.data-table td { padding: 8px; border-bottom: 1px solid var(--border); font-size: 13px; }
.data-table tr:hover td { background: var(--bg); }

/* ===== STATS ===== */
.stats-content { margin-top: 16px; }
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.stats-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.stats-card h3 { font-size: 15px; margin-bottom: 12px; }
.stats-card table { width: 100%; border-collapse: collapse; }
.stats-card th { text-align: left; font-size: 11px; color: var(--text-dim); padding: 4px 8px; }
.stats-card td { padding: 6px 8px; border-bottom: 1px solid var(--border); }
.stats-total {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 20px;
}
.stats-total-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}
.stats-total-card .value { font-size: 32px; font-weight: 700; }
.stats-total-card .label { font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.stats-total-card .value.tareas { color: var(--tag-tareas); }
.stats-total-card .value.estudio { color: var(--tag-estudio); }
.stats-total-card .value.proyectos { color: var(--tag-proyectos); }

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  border-radius: var(--radius);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  transition: opacity .3s;
  z-index: 1000;
  pointer-events: none;
}
.toast.show { opacity: 1; }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--surface);
  border-radius: 12px;
  width: 400px;
  max-width: 90vw;
  box-shadow: var(--shadow-lg);
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; }
.modal-close {
  border: none; background: none; font-size: 20px; cursor: pointer; color: var(--text-dim);
}
.modal-body { padding: 20px; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; padding: 40px; color: var(--text-dim); }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .app-header { flex-wrap: wrap; height: auto; padding: 12px 16px; gap: 8px; }
  .app-main { padding: 16px; }
  .subjects-layout { grid-template-columns: 1fr; }
  .settings-layout { grid-template-columns: 1fr; }
  .settings-card-wide { grid-column: auto; }
  .task-row { grid-template-columns: 32px 1fr 60px 40px 40px 60px; }
  .task-row > :nth-child(7),
  .task-row > :nth-child(8) { display: none; }
  .stats-total { grid-template-columns: 1fr; }
}

/* ===== SPINNER ===== */
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== LOADING OVERLAY ===== */
.loading-overlay {
  position: absolute; inset: 0;
  background: rgba(255,255,255,.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
  border-radius: var(--radius);
}

/* ===== AUTH SCREEN ===== */
#auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 32px 40px;
  width: 100%;
  max-width: 380px;
}
.auth-title { font-size: 22px; font-weight: 700; text-align: center; margin-bottom: 20px; color: var(--primary); }
.auth-tabs { display: flex; gap: 4px; margin-bottom: 20px; background: var(--bg); border-radius: var(--radius); padding: 4px; }
.auth-tab { flex: 1; padding: 6px; border: none; background: none; border-radius: 6px; cursor: pointer; font-size: 14px; color: var(--text-dim); font-weight: 500; }
.auth-tab.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); }
.auth-error { color: var(--danger); font-size: 13px; margin-top: 8px; min-height: 18px; }

/* ===== HEADER USER ===== */
.header-user { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.header-email { font-size: 13px; color: var(--text-dim); }

/* ===== SETTINGS ===== */
.settings-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; padding: 20px; }
.settings-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.settings-card h3 { font-size: 15px; font-weight: 600; margin-bottom: 10px; }
.settings-card-wide { grid-column: 1 / 3; }
.settings-status { font-size: 13px; color: var(--text-dim); }
.settings-hint { font-size: 12px; color: var(--text-dim); line-height: 1.5; }
.settings-hint a { color: var(--primary); }
.settings-hint code { background: var(--bg); padding: 1px 4px; border-radius: 3px; font-size: 11px; }
.loading-overlay .spinner { width: 32px; height: 32px; border-width: 3px; }

/* ===== INLINE TABLE EDITING ===== */
.inline-input {
  padding: 3px 7px;
  border: 1px solid var(--primary);
  border-radius: 5px;
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
  outline: none;
}
.row-actions { white-space: nowrap; }

/* ===== SCHEDULE MODAL ===== */
.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px 28px;
  min-width: 300px;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.modal-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}
.modal-option {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.875rem;
  flex-wrap: wrap;
}
.modal-option input[type="radio"] { accent-color: var(--primary); cursor: pointer; }
.modal-hint { color: var(--text-muted); font-size: 0.8rem; }
.modal-date-input {
  margin-left: 4px;
  padding: 3px 7px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 0.85rem;
}
.modal-date-input:disabled { opacity: 0.4; cursor: not-allowed; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

/* ===== INFO BUTTON ===== */
.info-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1.5px solid var(--primary);
  background: transparent;
  color: var(--primary);
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
  vertical-align: middle;
  margin-left: 6px;
  line-height: 1;
  padding: 0;
  transition: background 0.15s, color 0.15s;
}
.info-btn:hover { background: var(--primary); color: #fff; }

/* ===== GOOGLE CALENDAR GUIDE MODAL ===== */
.guide-box {
  max-width: 520px;
  width: 94vw;
  max-height: 85vh;
  overflow-y: auto;
  gap: 0;
  padding: 20px 24px 20px;
}
.guide-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.guide-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.3rem;
  cursor: pointer;
  line-height: 1;
  padding: 0 2px;
}
.guide-close:hover { color: var(--text); }
.guide-steps {
  margin: 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.55;
}
.guide-steps li strong { color: var(--text); }
.guide-steps a { color: var(--primary); text-decoration: none; }
.guide-steps a:hover { text-decoration: underline; }
.guide-steps code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 0.8rem;
  color: var(--text);
}
.guide-sub {
  margin: 6px 0 0 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  list-style: disc;
}
.guide-warn {
  color: #e07a3a;
  font-weight: 600;
}
.guide-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 18px;
}

/* ===== SETTINGS EXTRAS ===== */

.sched-days { display: flex; flex-direction: column; gap: 6px; }
.sched-day-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.sched-day-row:last-child { border-bottom: none; }
.sched-day-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  min-width: 110px;
  font-size: 13px;
  font-weight: 500;
  padding-top: 3px;
}
.sched-day-toggle input[type="checkbox"] { accent-color: var(--primary); width: 14px; height: 14px; cursor: pointer; }
.sched-intervals {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
}
.sched-interval {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 7px;
}
.sched-interval input[type="time"] {
  border: none;
  background: transparent;
  font-size: 13px;
  color: var(--text);
  padding: 0;
  width: 80px;
}
.sched-sep { color: var(--text-dim); font-size: 12px; }
.btn-add-interval {
  align-self: flex-start;
  margin-top: 2px;
  white-space: nowrap;
}

.cal-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 28px;
}
.cal-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px 10px 3px 12px;
  font-size: 12px;
  font-weight: 500;
}
.cal-chip-del {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1;
  padding: 0 1px;
}
.cal-chip-del:hover { color: var(--danger); }
.cal-add-row { display: flex; gap: 6px; align-items: center; }

.study-intensity-grid { display: flex; flex-direction: column; gap: 8px; }
.study-intensity-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.study-intensity-label { min-width: 100px; color: var(--text-dim); }
.study-intensity-unit { color: var(--text-dim); font-size: 12px; }

/* ===== CLEAR SCHEDULE MODAL ===== */
.modal-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}
.clear-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--text);
}
.clear-toggle input[type="checkbox"] { accent-color: var(--primary); width: 15px; height: 15px; cursor: pointer; }

/* ===== PASSWORD VISIBILITY TOGGLE ===== */
.pw-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.pw-input-wrap input {
  width: 100%;
  padding-right: 36px;
}
.pw-toggle {
  position: absolute;
  right: 6px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
  font-size: 16px;
  color: var(--text-dim);
  line-height: 1;
  display: flex;
  align-items: center;
}
.pw-toggle:hover { color: var(--text); }
.settings-card h4 { font-size: 13px; font-weight: 600; color: var(--text-dim); }

/* ===== CHECKUP TAB ===== */
.checkup-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  padding: 20px;
  align-items: start;
}
@media (max-width: 860px) {
  .checkup-layout { grid-template-columns: 1fr; }
}
.checkup-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.checkup-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}
.checkup-heading {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 2px;
}
.checkup-date-label {
  font-size: 12px;
  color: var(--text-dim);
}
.checkup-add-form {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  padding: 10px 12px;
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.checkup-add-form input[type="text"],
.checkup-add-form select {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
}
.checkup-add-form input[type="text"] { flex: 1; min-width: 120px; }

/* Item grid */
.checkup-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.cu-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.cu-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.cu-card-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.cu-type-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 20px;
  margin-left: 6px;
}
.cu-badge-num   { background: #dbeafe; color: #1d4ed8; }
.cu-badge-bool  { background: #dcfce7; color: #15803d; }
.cu-badge-hour  { background: #fef9c3; color: #a16207; }
.cu-badge-count { background: #fce7f3; color: #be185d; }
.cu-delete {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-dim);
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
}
.cu-delete:hover { color: var(--danger); }

/* Num input */
.cu-num-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.cu-slider {
  flex: 1;
  accent-color: var(--primary);
  cursor: pointer;
  height: 4px;
}
.cu-num-val {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
  min-width: 26px;
  text-align: center;
}
.cu-num-ends {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 2px;
}

/* Bool toggle */
.cu-bool-row { display: flex; align-items: center; gap: 10px; }
.cu-toggle-wrap {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.cu-toggle-wrap input { opacity: 0; width: 0; height: 0; position: absolute; }
.cu-toggle-track {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s;
}
.cu-toggle-wrap input:checked ~ .cu-toggle-track { background: var(--primary); }
.cu-toggle-track::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 3px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: left 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.cu-toggle-wrap input:checked ~ .cu-toggle-track::after { left: 23px; }
.cu-bool-label {
  font-size: 13px;
  color: var(--text-dim);
}

/* Hour input */
.cu-hour-row { display: flex; flex-direction: column; gap: 8px; }
.cu-hour-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.cu-hour-custom {
  display: flex;
  align-items: center;
  gap: 5px;
}
.cu-custom-time {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  width: 110px;
}
.cu-hour-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-height: 24px;
}
.cu-hour-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2px 6px 2px 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
}
.cu-hour-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1;
  padding: 0 1px;
  display: flex;
  align-items: center;
}
.cu-hour-remove:hover { color: var(--danger); }

/* Count input */
.cu-count-row { display: flex; align-items: center; gap: 14px; }
.cu-count-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--primary);
  background: transparent;
  color: var(--primary);
  font-size: 22px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  line-height: 1;
}
.cu-count-btn:hover { background: var(--primary); color: #fff; }
.cu-count-sub { border-color: var(--danger); color: var(--danger); }
.cu-count-sub:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.cu-count-val {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
  min-width: 36px;
  text-align: center;
}
.cu-count-unit { font-size: 12px; color: var(--text-dim); }

/* History */
.checkup-history-wrap { overflow-y: auto; max-height: 600px; }
.cu-history-day { margin-bottom: 16px; }
.cu-history-day-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.cu-history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.cu-history-table td {
  padding: 4px 8px;
  vertical-align: top;
}
.cu-history-table td:first-child {
  font-weight: 600;
  color: var(--text);
  width: 40%;
}
.cu-history-table td:last-child { color: var(--text-dim); }
.cu-committed-at {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 4px;
  text-align: right;
}
.cu-badge-event { background: #ede9fe; color: #6d28d9; }
.cu-hist-done    { color: var(--success); font-weight: 600; font-size: 12px; }
.cu-hist-notdone { color: var(--danger);  font-weight: 600; font-size: 12px; }
.cu-hist-ts {
  font-size: 10px;
  color: var(--text-dim);
  margin-left: 6px;
  font-weight: 400;
}
.cu-hist-time {
  font-size: 10px;
  color: var(--text-dim);
  margin-left: 4px;
}
.cu-hist-name { width: 50%; }

/* History edit/delete/add controls */
.cu-history-day-label { display: flex; align-items: center; justify-content: space-between; }
.hist-add-btns { display: flex; gap: 4px; }
.cu-history-table { table-layout: fixed; }
.cu-history-table td:last-child { color: inherit; }
.hist-val-cell { color: var(--text-dim); }
.hist-act-cell {
  width: 64px;
  white-space: nowrap;
  text-align: right;
  vertical-align: middle;
  padding-right: 0 !important;
}
.hist-act-cell .btn {
  padding: 1px 5px;
  font-size: 11px;
  opacity: 0.4;
  min-width: 0;
}
.hist-act-cell .btn:hover { opacity: 1; }
.hist-add-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 6px 2px 10px;
  flex-wrap: wrap;
  border-bottom: 1px dashed var(--border);
  margin-bottom: 6px;
}
.hist-fl {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 600;
}
.hist-fl input, .hist-fl select { font-size: 12px; }
.hist-edit-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  padding: 6px 4px;
  background: var(--bg);
  border-radius: var(--radius);
}
.hist-val-wrap { display: contents; }
