/* StudyBuddy — Reusable components */

/* ========== Cards ========== */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  border: 1px solid var(--border);
  padding: 20px;
  transition: box-shadow var(--transition);
}

.card:hover { box-shadow: var(--card-shadow-hover); }

.insight-card { cursor: pointer; }
.insight-card .card-header[role="button"] { cursor: pointer; }
.insight-card .card-header[role="button"]:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 4px;
  border-radius: 4px;
}

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

.card-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-heading);
}

.card-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.card-icon.blue { background: #DBEAFE; color: #2563EB; }
.card-icon.green { background: #DCFCE7; color: #16A34A; }
.card-icon.purple { background: #EDE9FE; color: #7C3AED; }
.card-icon.orange { background: #FFEDD5; color: #EA580C; }
.card-icon.teal { background: #CCFBF1; color: #0D9488; }
.card-icon.pink { background: #FCE7F3; color: #DB2777; }
.card-icon.red { background: #FEE2E2; color: #DC2626; }

.view-all {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--primary);
  white-space: nowrap;
}
.view-all:hover { text-decoration: underline; }

/* ========== Stat Cards ========== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  border: 1px solid var(--border);
  padding: 18px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  transition: transform var(--transition), box-shadow var(--transition);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--card-shadow-hover);
  color: inherit;
}
.stat-card[role="button"][aria-pressed="true"] {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.12);
}
.stat-card[role="button"]:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.28);
  outline-offset: 2px;
}

.stat-card .stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stat-card .stat-icon.blue { background: #DBEAFE; color: #2563EB; }
.stat-card .stat-icon.purple { background: #EDE9FE; color: #7C3AED; }
.stat-card .stat-icon.green { background: #DCFCE7; color: #16A34A; }
.stat-card .stat-icon.orange { background: #FFEDD5; color: #EA580C; }
.stat-card .stat-icon.red { background: #FEE2E2; color: #DC2626; }
.stat-card .stat-icon.teal { background: #CCFBF1; color: #0D9488; }

.stat-card .stat-body { flex: 1; min-width: 0; }
.stat-card .stat-label {
  font-size: 12.5px;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 2px;
}
.stat-card .stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-heading);
  line-height: 1.1;
}
.stat-card .stat-delta {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 11.5px;
  font-weight: 600;
  margin-top: 4px;
}
.stat-card .stat-delta.up { color: var(--success); }
.stat-card .stat-delta.down { color: var(--danger); }
.stat-card .stat-arrow {
  color: var(--text-muted);
  margin-left: auto;
  align-self: center;
}

/* ========== Buttons ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 13.5px;
  border: none;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  white-space: nowrap;
  text-decoration: none;
}
.btn:active { transform: scale(0.98); }
.btn svg, .btn i { width: 16px; height: 16px; }

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-hover); color: #fff; }

.btn-outline {
  background: var(--card-bg);
  color: var(--primary);
  border: 1.5px solid var(--primary);
}
.btn-outline:hover { background: var(--primary-soft); }

.btn-ghost {
  background: transparent;
  color: var(--text-body);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--page-bg); }

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-sm { padding: 7px 12px; font-size: 12.5px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn-lg { padding: 13px 22px; font-size: 15px; border-radius: 12px; }

.btn.loading { pointer-events: none; opacity: 0.75; }
.btn .spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ========== Badges / Pills ========== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-upcoming, .badge-info { background: var(--info-bg); color: var(--info); }
.badge-overdue, .badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-completed, .badge-success { background: var(--success-bg); color: var(--success); }
.badge-pending, .badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-progress { background: var(--info-bg); color: var(--info); }
.badge-verified { background: var(--success-bg); color: var(--success); }

.subject-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
}
.subject-tag.math, .subject-tag.ias { background: #DBEAFE; color: #2563EB; }
.subject-tag.science, .subject-tag.iaslab { background: #DCFCE7; color: #16A34A; }
.subject-tag.english, .subject-tag.sysad { background: #EDE9FE; color: #7C3AED; }
.subject-tag.cs, .subject-tag.capstone { background: #FFEDD5; color: #EA580C; }
.subject-tag.filipino, .subject-tag.sia { background: #CCFBF1; color: #0D9488; }
.subject-tag.history, .subject-tag.xplat { background: #FCE7F3; color: #E11D48; }

.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot.math, .dot.ias { background: var(--ias); }
.dot.science, .dot.iaslab { background: var(--iaslab); }
.dot.english, .dot.sysad { background: var(--sysad); }
.dot.cs, .dot.capstone { background: var(--capstone); }
.dot.filipino, .dot.sia { background: var(--sia); }
.dot.history, .dot.xplat { background: var(--xplat); }

/* ========== Progress Bar ========== */
.progress-bar {
  height: 7px;
  background: #E2E8F0;
  border-radius: 999px;
  overflow: hidden;
  width: 100%;
}
.progress-bar .fill {
  height: 100%;
  border-radius: 999px;
  transition: width 400ms ease;
}
.progress-bar .fill.math, .progress-bar .fill.ias { background: var(--ias); }
.progress-bar .fill.science, .progress-bar .fill.iaslab { background: var(--iaslab); }
.progress-bar .fill.english, .progress-bar .fill.sysad { background: var(--sysad); }
.progress-bar .fill.cs, .progress-bar .fill.capstone { background: var(--capstone); }
.progress-bar .fill.filipino, .progress-bar .fill.sia { background: var(--sia); }
.progress-bar .fill.history, .progress-bar .fill.xplat { background: var(--xplat); }
.progress-bar .fill.blue { background: var(--primary); }
.progress-bar .fill.green { background: var(--success); }
.progress-bar .fill.purple { background: #7C3AED; }
.progress-bar .fill.orange { background: var(--cs); }

.progress-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.progress-row .progress-bar { flex: 1; }
.progress-pct {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-body);
  min-width: 36px;
  text-align: right;
}

/* ========== Tables ========== */
.table-wrap { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table th {
  text-align: left;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  font-size: 13.5px;
  color: var(--text-body);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr {
  transition: background var(--transition);
}
.data-table tbody tr:hover { background: var(--page-bg); }

.cell-title {
  display: flex;
  align-items: center;
  gap: 12px;
}
.cell-title .cell-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.cell-title .title { font-weight: 600; color: var(--text-heading); font-size: 13.5px; }
.cell-title .subtitle { font-size: 12px; color: var(--text-muted); }

/* ========== Checkbox ========== */
.check-line {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 12px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-heading);
  cursor: pointer;
}
.check-line input {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  flex-shrink: 0;
}
.check-line span { flex: 1; min-width: 0; }
.check-line + .subtitle { display: block; margin-top: 8px; }
.custom-check {
  position: relative;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
.custom-check input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  z-index: 1;
  margin: 0;
}
.custom-check .box {
  width: 18px;
  height: 18px;
  border: 2px solid #CBD5E1;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  background: var(--card-bg);
}
.custom-check input:checked + .box {
  background: var(--primary);
  border-color: var(--primary);
}
.custom-check input:checked + .box::after {
  content: '';
  width: 5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) translate(-1px, -1px);
}
.custom-check input:indeterminate + .box {
  background: var(--primary);
  border-color: var(--primary);
}
.custom-check input:indeterminate + .box::after {
  content: '';
  width: 8px;
  height: 2px;
  border: 0;
  border-radius: 1px;
  background: #fff;
}

/* ========== Filter Tabs ========== */
.filter-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  background: var(--card-bg);
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--border);
  width: fit-content;
  margin-bottom: 16px;
}
.filter-tab {
  padding: 8px 14px;
  border-radius: 8px;
  border: none;
  background: transparent;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.filter-tab:hover { color: var(--text-heading); background: var(--page-bg); }
.filter-tab.active {
  background: var(--primary);
  color: #fff;
}
.filter-tab .count {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(0,0,0,0.06);
}
.filter-tab.active .count { background: rgba(255,255,255,0.25); }

/* ========== Quick Actions ========== */
.qa-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.qa-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 10px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 12px;
  color: var(--text-heading);
  text-align: center;
  transition: transform var(--transition), box-shadow var(--transition);
  text-decoration: none;
}
.qa-btn:hover { transform: translateY(-2px); color: var(--text-heading); }
.qa-btn.blue { background: #EFF6FF; color: #1E40AF; }
.qa-btn.purple { background: #F5F3FF; color: #5B21B6; }
.qa-btn.green { background: #F0FDF4; color: #166534; }
.qa-btn.orange { background: #FFF7ED; color: #9A3412; }
.qa-btn.teal { background: #F0FDFA; color: #115E59; }
.qa-btn svg { width: 20px; height: 20px; }

/* ========== List Items ========== */
.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
  cursor: pointer;
}
.list-item-link { color: inherit; text-decoration: none; }
.list-item:last-child { border-bottom: none; }
.list-item:hover { background: var(--page-bg); margin: 0 -8px; padding-left: 8px; padding-right: 8px; border-radius: 8px; }
.list-item-link:focus-visible,
.cal-day[role="button"]:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.28);
  outline-offset: -2px;
  border-radius: 8px;
}
.list-item[role="button"]:focus-visible {
  position: relative;
  outline: 3px solid rgba(37, 99, 235, 0.28);
  outline-offset: -2px;
  border-radius: 8px;
}

.list-item .item-meta { flex: 1; min-width: 0; }
.list-item .item-title {
  font-weight: 600;
  color: var(--text-heading);
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-item .item-sub {
  font-size: 12px;
  color: var(--text-muted);
}
.list-item .chevron { color: var(--text-muted); flex-shrink: 0; }

/* ========== Modal ========== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 30, 61, 0.45);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition), visibility var(--transition);
}
.modal-backdrop.open {
  opacity: 1;
  visibility: visible;
}
.modal {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0,0,0,0.15);
  transform: translateY(12px) scale(0.98);
  transition: transform var(--transition);
}
.modal-backdrop.open .modal {
  transform: translateY(0) scale(1);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
}
.modal-header h3 { font-size: 18px; }
.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 6px;
  border-radius: 8px;
}
.modal-close:hover { background: var(--page-bg); color: var(--text-heading); }
.modal-body { padding: 20px 24px; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 0 24px 24px;
}
.delete-confirm-modal { max-width: 440px; }
.delete-confirm-description {
  margin-bottom: 14px;
  color: var(--text-body);
  font-size: 13px;
  line-height: 1.5;
}
.delete-confirm-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--page-bg);
}
.delete-confirm-icon {
  display: flex;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  background: #FEE2E2;
  color: #DC2626;
}
.delete-confirm-item strong {
  color: var(--text-heading);
  font-size: 13px;
  overflow-wrap: anywhere;
}
.delete-confirm-warning {
  margin-top: 12px;
  color: var(--danger);
  font-size: 12px;
}

/* ========== Forms ========== */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-heading);
  margin-bottom: 6px;
}
.form-control {
  width: 100%;
  height: 44px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 0 14px;
  outline: none;
  color: var(--text-heading);
  background: var(--card-bg);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
textarea.form-control {
  height: auto;
  min-height: 90px;
  padding: 12px 14px;
  resize: vertical;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.input-icon-wrap {
  position: relative;
}
.input-icon-wrap .form-control { padding-left: 42px; }
.input-icon-wrap.has-password-toggle .form-control { padding-right: 44px; }
.input-icon-wrap .input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  width: 18px; height: 18px;
  pointer-events: none;
}
.input-icon-wrap .input-action {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
}
.input-icon-wrap .input-action:focus-visible {
  outline: 2px solid rgba(37, 99, 235, 0.4);
  outline-offset: 1px;
  border-radius: 6px;
}
.color-picker {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.color-swatch {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform var(--transition);
}
.color-swatch:hover { transform: scale(1.1); }
.color-swatch.selected { border-color: var(--text-heading); box-shadow: 0 0 0 2px var(--card-bg), 0 0 0 4px currentColor; }

/* ========== Toast ========== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--card-bg);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 280px;
  font-weight: 500;
  font-size: 13.5px;
  color: var(--text-heading);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  animation: toastIn 250ms ease;
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ========== Action Menu ========== */
.action-menu-wrap { position: relative; }
.action-menu-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 6px;
  border-radius: 6px;
}
.action-menu-btn:hover { background: var(--page-bg); color: var(--text-heading); }
.action-dropdown {
  position: absolute;
  right: 0;
  top: 100%;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.1);
  min-width: 160px;
  z-index: 20;
  padding: 6px;
  display: none;
}
.action-dropdown.open { display: block; }
.action-dropdown button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-body);
  text-align: left;
}
.action-dropdown button:hover { background: var(--page-bg); }
.action-dropdown button.danger { color: var(--danger); }
.student-app .action-dropdown {
  border-radius: 14px;
  min-width: 184px;
  padding: 8px;
}
.student-app .action-dropdown button {
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
}
.student-app .action-dropdown button.danger:hover { background: var(--danger-bg); }
.student-app .action-dropdown button svg { width: 18px; height: 18px; }
.student-app .btn-ghost.danger { color: var(--danger); }
.student-app .btn-ghost.danger:hover { background: var(--danger-bg); border-color: transparent; }

/* ========== Pagination ========== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.pagination-info { font-size: 12.5px; color: var(--text-muted); }
.pagination-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}
.page-btn {
  min-width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 12.5px;
  color: var(--text-body);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.page-btn:hover { background: var(--page-bg); }
.page-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ========== Donut / Charts ========== */
.donut-wrap {
  display: flex;
  align-items: center;
  gap: 16px;
}
.donut {
  position: relative;
  width: 100px;
  height: 100px;
  flex-shrink: 0;
}
.donut svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.donut .center-label {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: var(--text-heading);
  line-height: 1.2;
}
.donut .center-label small {
  font-size: 9px;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 2px;
}
.donut-legend { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.donut-legend-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.donut-legend-row .lbl {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 500;
}
.donut-legend-row .lbl span:first-child { color: var(--text-body); }
.donut-legend-row .lbl span:last-child { color: var(--text-heading); font-weight: 600; }

.bar-chart {
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  gap: 12px;
  height: 180px;
  padding-top: 24px;
}
.bar-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: 1;
  height: 100%;
  justify-content: flex-end;
}
.bar-col .bar-val {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-heading);
}
.bar-col .bar {
  width: 100%;
  max-width: 36px;
  border-radius: 8px 8px 4px 4px;
  transition: height 500ms ease;
}
.bar-col .bar-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.line-chart-wrap {
  position: relative;
  width: 100%;
  height: 220px;
}
.line-chart-wrap svg { width: 100%; height: 100%; }
.chart-tooltip {
  position: absolute;
  background: var(--text-heading);
  color: #fff;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 11.5px;
  font-weight: 600;
  pointer-events: none;
  white-space: nowrap;
  transform: translate(-50%, -120%);
}

/* ========== Calendar ========== */
.cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.cal-nav h4 { font-size: 15px; }
.cal-nav-btns { display: flex; gap: 4px; }
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.cal-full {
  width: 100%;
  min-width: 0;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}
.cal-full > * { min-width: 0; }
.cal-dow {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 6px 0;
}
.cal-day {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 4px 2px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-body);
  cursor: pointer;
  position: relative;
  transition: background var(--transition);
  min-height: 36px;
}
.cal-day[role="button"] { cursor: pointer; }
.cal-day:not([role="button"]) { cursor: default; }
.cal-day[role="button"]:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.28);
  outline-offset: -2px;
}
.cal-day:hover { background: var(--page-bg); }
.cal-day.other { color: var(--text-muted); opacity: 0.5; }
.cal-day.today .day-num {
  background: var(--primary);
  color: #fff;
  width: 24px; height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cal-day .day-dots {
  display: flex;
  gap: 2px;
  margin-top: 2px;
}
.cal-day .day-dots span {
  width: 4px; height: 4px;
  border-radius: 50%;
}

.cal-full .cal-day {
  aspect-ratio: auto;
  min-height: 90px;
  align-items: stretch;
  min-width: 0;
  overflow: hidden;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.cal-full .cal-day .day-num { font-weight: 600; margin-bottom: 4px; }
.cal-full .cal-day[role="button"]:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.3);
  outline-offset: -2px;
}
.cal-event-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  margin-bottom: 2px;
  overflow: hidden;
}
.cal-event-chip .dot { flex: 0 0 6px; }
.cal-event-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cal-event-chip.math, .cal-event-chip.ias { background: #DBEAFE; color: #1E40AF; }
.cal-event-chip.science, .cal-event-chip.iaslab { background: #DCFCE7; color: #166534; }
.cal-event-chip.english, .cal-event-chip.sysad { background: #EDE9FE; color: #5B21B6; }
.cal-event-chip.cs, .cal-event-chip.capstone { background: #FFEDD5; color: #9A3412; }
.cal-event-chip.filipino, .cal-event-chip.sia { background: #CCFBF1; color: #115E59; }
.cal-event-chip.history, .cal-event-chip.xplat { background: #FCE7F3; color: #9F1239; }
.cal-event-chip.task { background: #FEF3C7; color: #92400E; }

.view-toggle {
  display: flex;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}
.view-toggle button {
  padding: 7px 14px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition);
}
.view-toggle button.active {
  background: var(--primary);
  color: #fff;
}

/* ========== Tip Card ========== */
.tip-card {
  background: linear-gradient(135deg, #EFF6FF 0%, #DBEAFE 100%);
  border-radius: var(--radius);
  padding: 16px;
  border: 1px solid #BFDBFE;
}
:root[data-theme="dark"] .tip-card {
  background: linear-gradient(135deg, var(--card-bg) 0%, var(--info-bg) 100%);
  border-color: var(--border);
}
.tip-card .tip-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--card-bg);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
}
.tip-card p {
  font-size: 13px;
  color: var(--text-body);
  font-style: italic;
  line-height: 1.5;
}
.tip-card .tip-footer {
  margin-top: 10px;
  font-size: 11.5px;
  color: var(--text-muted);
  font-style: normal;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ========== Settings Tabs ========== */
.settings-layout {
  display: grid;
  grid-template-columns: 220px 1fr var(--right-col);
  gap: 24px;
  align-items: start;
}
.settings-nav {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.settings-nav button {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-weight: 500;
  font-size: 13px;
  color: var(--text-body);
  cursor: pointer;
  text-align: left;
  transition: all var(--transition);
}
.settings-nav button:hover { background: var(--page-bg); }
.settings-nav button.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}
.settings-panel { display: none; }
.settings-panel.active { display: block; }

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  gap: 12px;
}
.settings-row:last-child { border-bottom: none; }
.settings-row .row-label { font-weight: 600; color: var(--text-heading); font-size: 13.5px; }
.settings-row .row-value { color: var(--text-muted); font-size: 13px; margin-top: 2px; }
.settings-row .chevron { color: var(--text-muted); }

.verified-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--success-bg);
  border-radius: 10px;
  color: var(--success);
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 16px;
}

.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-switch .slider {
  position: absolute;
  inset: 0;
  background: #CBD5E1;
  border-radius: 999px;
  cursor: pointer;
  transition: background var(--transition);
}
.toggle-switch .slider::before {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--transition);
}
.toggle-switch input:checked + .slider { background: var(--primary); }
.toggle-switch input:checked + .slider::before { transform: translateX(20px); }

@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .settings-layout { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .form-row { grid-template-columns: 1fr; }
  .cal-full .cal-day { min-height: 60px; }

  .card { padding: 14px; }
  .stat-card { gap: 9px; padding: 12px; }
  .stat-card .stat-icon { width: 36px; height: 36px; border-radius: 10px; }
  .stat-card .stat-value { font-size: 22px; }
  .filter-tabs { width: 100%; flex-wrap: wrap; }
  .filter-tab { flex: 1 1 auto; justify-content: center; padding: 8px 10px; }
  .btn { padding: 9px 12px; white-space: normal; text-align: center; }
  .form-control { font-size: 16px; }
  .table-wrap {
    max-width: 100%;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
  }
  .modal-backdrop { align-items: flex-end; padding: 8px; }
  .modal {
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
    border-radius: 16px 16px 10px 10px;
  }
  .modal-header { padding: 16px 16px 0; }
  .modal-body { padding: 16px; }
  .modal-footer { flex-wrap: wrap; padding: 0 16px 16px; }
  .modal-footer .btn { flex: 1 1 120px; }
  .connected-row { align-items: flex-start; flex-wrap: wrap; padding: 12px; }
  .connected-row .conn-info { flex: 1 1 calc(100% - 60px); min-width: 0; }
  .connected-row > .btn { width: 100%; }
}

@media (max-width: 380px) {
  .stat-grid { grid-template-columns: 1fr; }
  .header-actions { gap: 2px; }
  .card { padding: 12px; }
}
