/* ============================================================
   MinDag – style.css (functional first)
   ============================================================ */

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

body {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 15px;
  background: #f5f5f5;
  color: #1a1a1a;
  min-height: 100vh;
}

/* --- Nav --- */
#nav {
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
  position: sticky;
  top: 0;
  z-index: 10;
}
.nav-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 2rem;
  height: 52px;
}
.nav-brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: #2563eb;
}
.nav-links { display: flex; gap: 0.25rem; }
.nav-link {
  text-decoration: none;
  color: #555;
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  font-size: 0.9rem;
}
.nav-link:hover { background: #f0f0f0; color: #1a1a1a; }
.nav-link.active { background: #eff6ff; color: #2563eb; font-weight: 600; }

/* --- Main --- */
#app {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* --- View header --- */
.view-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}
.view-header h1 { font-size: 1.6rem; font-weight: 700; }
.view-header-actions { display: flex; gap: 0.5rem; align-items: center; }
.date-label { font-size: 0.9rem; color: #666; margin-top: 2px; }

/* --- Buttons --- */
.btn-primary {
  background: #2563eb;
  color: #fff;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  white-space: nowrap;
}
.btn-primary:hover { background: #1d4ed8; }
.btn-secondary {
  background: #fff;
  color: #333;
  border: 1px solid #d0d0d0;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
}
.btn-secondary:hover { background: #f5f5f5; }
.btn-danger {
  background: #fff;
  color: #dc2626;
  border: 1px solid #dc2626;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
}
.btn-danger:hover { background: #fef2f2; }
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.82rem; }
.link-btn { background: none; border: none; color: #2563eb; cursor: pointer; font-size: inherit; text-decoration: underline; }

/* --- Card --- */
.card {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 1rem 1.25rem;
}
.mb { margin-bottom: 1.25rem; }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}
.card-header h2 { font-size: 1rem; font-weight: 600; }

/* --- Log summary (today view) --- */
.log-summary { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.log-pill {
  padding: 0.25rem 0.6rem;
  border-radius: 12px;
  font-size: 0.82rem;
  font-weight: 500;
}
.energy-pill { background: #fef3c7; color: #92400e; }
.mood-pill   { background: #dbeafe; color: #1e40af; }
.symptom-pill { background: #fce7f3; color: #9d174d; }
.ovulation-pill { background: #d1fae5; color: #065f46; }
.log-notes { font-size: 0.85rem; color: #555; margin-top: 0.5rem; width: 100%; }
.empty-hint { font-size: 0.9rem; color: #999; }

/* --- Task list --- */
.task-list { display: flex; flex-direction: column; gap: 2px; }

.task-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: #fff;
  border: 1px solid #e8e8e8;
  border-radius: 6px;
  padding: 0.6rem 0.75rem;
}
.task-row:hover { border-color: #c0c0c0; }
.task-row.task-done { opacity: 0.55; }

.task-check {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid #ccc;
  background: #fff;
  cursor: pointer;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #fff;
}
.task-check.checked { background: #2563eb; border-color: #2563eb; }
.task-check:hover { border-color: #2563eb; }

.task-body { flex: 1; min-width: 0; }
.task-body-main { cursor: pointer; }
.task-title { display: block; font-size: 0.92rem; }
.task-row.task-done .task-title { text-decoration: line-through; }

/* Subtask count badge */
.subtask-count {
  display: inline-block;
  font-size: 0.72rem;
  color: #6b7280;
  background: #f3f4f6;
  border-radius: 10px;
  padding: 0.05rem 0.45rem;
  margin-left: 0.4rem;
  vertical-align: middle;
}

/* Subtask list inline under parent */
.subtask-list {
  margin: 0.35rem 0 0.1rem 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  border-left: 2px solid #e5e7eb;
  padding-left: 0.6rem;
}
.subtask-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0;
}
.subtask-row .task-check {
  width: 18px;
  height: 18px;
  font-size: 0.65rem;
}
.subtask-title {
  font-size: 0.85rem;
  cursor: pointer;
  color: #374151;
}
.subtask-row.task-done .subtask-title { text-decoration: line-through; color: #9ca3af; }

/* Add subtask button inline */
.add-subtask-btn {
  background: none;
  border: none;
  color: #9ca3af;
  font-size: 0.78rem;
  cursor: pointer;
  padding: 0.15rem 0;
  margin-top: 0.2rem;
  display: block;
}
.add-subtask-btn:hover { color: #2563eb; }

/* Subtasks section inside modal */
.modal-subtasks {
  border-top: 1px solid #e8e8e8;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
}
.modal-subtasks-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.4rem;
}
.btn-link {
  background: none;
  border: none;
  color: #2563eb;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0;
  font-weight: 500;
}
.btn-link:hover { text-decoration: underline; }
.modal-subtasks-empty { font-size: 0.82rem; color: #9ca3af; }
.modal-subtask-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0;
}
.modal-subtask-row .task-check {
  width: 18px;
  height: 18px;
  font-size: 0.65rem;
}
.modal-subtask-title {
  font-size: 0.88rem;
  cursor: pointer;
  color: #374151;
}
.modal-subtask-row.task-done .modal-subtask-title { text-decoration: line-through; color: #9ca3af; }
.task-notes-preview { display: block; font-size: 0.8rem; color: #777; margin-top: 0.15rem; line-height: 1.3; }
.task-meta { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.3rem; }

.cat-badge {
  font-size: 0.72rem;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.cat-phd                 { background: #dbeafe; color: #1e40af; }
.cat-hus                 { background: #d1fae5; color: #065f46; }
.cat-privat              { background: #fce7f3; color: #9d174d; }
.cat-bestyrelsesarbejde  { background: #fef3c7; color: #92400e; }

.proj-ref     { font-size: 0.78rem; color: #555; }
.due-tag      { font-size: 0.78rem; color: #555; }
.due-tag.overdue { color: #dc2626; font-weight: 600; }
.planned-tag  { font-size: 0.78rem; color: #888; }
.energy-tag   { font-size: 0.72rem; padding: 0.1rem 0.4rem; border-radius: 4px; }
.energy-low    { background: #f0fdf4; color: #166534; }
.energy-medium { background: #fefce8; color: #854d0e; }
.energy-high   { background: #fef2f2; color: #991b1b; }

.pri-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.pri-5 { background: #dc2626; }
.pri-4 { background: #ea580c; }
.pri-3 { background: #ca8a04; }
.pri-2 { background: #2563eb; }
.pri-1 { background: #9ca3af; }

.done-divider {
  font-size: 0.78rem;
  color: #999;
  padding: 0.75rem 0 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* --- Recurring tasks --- */
.recurring-list { display: flex; flex-direction: column; gap: 4px; }

.recurring-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: #fff;
  border: 1px solid #e8e8e8;
  border-radius: 6px;
  padding: 0.65rem 0.75rem;
}
.recurring-row:hover { border-color: #c0c0c0; }
.recurring-paused { opacity: 0.6; }

.recurring-body { flex: 1; min-width: 0; }
.recurring-title { font-size: 0.92rem; font-weight: 500; }
.recurring-meta { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.3rem; align-items: center; }
.recurring-freq { font-size: 0.78rem; color: #555; background: #f3f4f6; padding: 0.1rem 0.45rem; border-radius: 10px; }
.recurring-status { font-size: 0.78rem; }
.recurring-status.active { color: #16a34a; }
.recurring-status.paused { color: #d97706; }

.recurring-actions { display: flex; gap: 0.35rem; }
.btn-icon {
  width: 28px;
  height: 28px;
  border-radius: 5px;
  border: 1px solid #e0e0e0;
  background: #fafafa;
  cursor: pointer;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-icon:hover { background: #f0f0f0; border-color: #bbb; }
.btn-icon-danger:hover { background: #fee2e2; border-color: #fca5a5; color: #dc2626; }

/* --- Projects grid --- */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}
.project-card {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  cursor: pointer;
}
.project-card:hover { border-color: #2563eb; }
.project-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
}
.project-short { font-size: 0.78rem; font-weight: 700; color: #2563eb; text-transform: uppercase; letter-spacing: 0.05em; }
.project-name  { font-size: 0.95rem; font-weight: 600; margin-bottom: 0.25rem; }
.project-journal { font-size: 0.8rem; color: #777; margin-bottom: 0.6rem; }

.status-badge {
  font-size: 0.72rem;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-weight: 600;
}
.status-idea, .status-protocol           { background: #f3f4f6; color: #374151; }
.status-data_access, .status-data_management { background: #fef3c7; color: #92400e; }
.status-analysis                         { background: #dbeafe; color: #1e40af; }
.status-writing                          { background: #ede9fe; color: #5b21b6; }
.status-submitted, .status-under_review  { background: #fce7f3; color: #9d174d; }
.status-published                        { background: #d1fae5; color: #065f46; }

.progress-wrap { display: flex; align-items: center; gap: 0.5rem; margin: 0.6rem 0; }
.progress-track { flex: 1; height: 6px; background: #e5e7eb; border-radius: 3px; overflow: hidden; }
.progress-fill  { height: 100%; background: #2563eb; border-radius: 3px; transition: width 0.3s; }
.progress-label { font-size: 0.78rem; color: #666; min-width: 30px; text-align: right; }

.project-footer { display: flex; gap: 1rem; font-size: 0.78rem; color: #888; }

/* --- Filter bar --- */
.filter-bar { display: flex; gap: 0.75rem; margin-bottom: 1rem; }
.filter-bar select {
  padding: 0.4rem 0.75rem;
  border: 1px solid #d0d0d0;
  border-radius: 6px;
  font-size: 0.88rem;
  background: #fff;
  cursor: pointer;
}

/* --- Daily log list --- */
.log-list { display: flex; flex-direction: column; gap: 2px; }
.log-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: #fff;
  border: 1px solid #e8e8e8;
  border-radius: 6px;
  padding: 0.6rem 1rem;
  cursor: pointer;
}
.log-row:hover { border-color: #c0c0c0; }
.log-row-date { font-size: 0.85rem; color: #444; min-width: 130px; }

.log-bars { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.bar-group { display: flex; align-items: center; gap: 0.4rem; }
.bar-label { font-size: 0.72rem; color: #999; width: 12px; }
.bar-track { flex: 1; height: 6px; background: #e5e7eb; border-radius: 3px; overflow: hidden; max-width: 160px; }
.bar-fill  { height: 100%; border-radius: 3px; }
.energy-fill { background: #f59e0b; }
.mood-fill   { background: #3b82f6; }
.bar-val { font-size: 0.78rem; color: #555; min-width: 14px; }

.log-symptoms { display: flex; gap: 0.35rem; }
.sym-dot { font-size: 0.7rem; color: #ec4899; }
.sym-dot.inactive { color: #e5e7eb; }
.pms-dot { color: #8b5cf6; }
.ov-dot  { color: #10b981; }

/* --- Modal --- */
#modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}
#modal-overlay.hidden { display: none; }
#modal-box {
  background: #fff;
  border-radius: 10px;
  padding: 1.5rem;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}
.modal-header h2 { font-size: 1.1rem; font-weight: 700; }
.modal-close {
  background: none;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  color: #888;
  padding: 0.25rem;
}
.modal-close:hover { color: #333; }

/* --- Forms --- */
form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: #444;
  margin-bottom: 0.9rem;
}
form input, form select, form textarea {
  padding: 0.5rem 0.65rem;
  border: 1px solid #d0d0d0;
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: inherit;
  background: #fff;
  color: #1a1a1a;
}
form input:focus, form select:focus, form textarea:focus {
  outline: none;
  border-color: #2563eb;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid #f0f0f0;
}
.form-actions .btn-danger { margin-right: auto; }
.req { color: #dc2626; }

/* --- Checkboxes --- */
.checkbox-group { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-bottom: 0.9rem; }
.check-label {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.88rem;
  font-weight: normal;
  color: #333;
  cursor: pointer;
  margin-bottom: 0 !important;
}
.check-label input { width: auto; margin: 0; }

/* --- Milestones --- */
.milestones-section { margin-top: 0.5rem; }
.milestones-section h3 { font-size: 0.9rem; font-weight: 600; margin-bottom: 0.5rem; }
.ms-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}
.ms-input { flex: 1; }
.ms-date  { width: 130px; flex-shrink: 0; }
.ms-remove {
  background: none;
  border: none;
  color: #999;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0.25rem;
}
.ms-remove:hover { color: #dc2626; }

/* --- Today layout --- */
.today-layout {
  display: grid;
  grid-template-columns: 1fr 230px;
  gap: 1.25rem;
  align-items: start;
}
.today-main { min-width: 0; }
.today-side { position: sticky; top: 64px; }

/* Overdue banner */
.overdue-banner {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  overflow: hidden;
}
.overdue-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0.85rem;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  color: #c2410c;
}
.overdue-header:hover { background: #fff1e6; }
#overdue-list { padding: 0 0.75rem 0.75rem; }

/* Week strip */
.week-strip { display: flex; flex-direction: column; gap: 1px; }
.ws-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  cursor: pointer;
}
.ws-row:hover { background: #f5f9ff; }
.ws-today { background: #eff6ff; }
.ws-name  { font-size: 0.75rem; color: #888; width: 26px; flex-shrink: 0; }
.ws-num   { font-size: 0.88rem; font-weight: 600; width: 22px; text-align: center; flex-shrink: 0; }
.ws-dots  { display: flex; flex-wrap: wrap; gap: 2px; flex: 1; }
.ws-dot   { width: 7px; height: 7px; border-radius: 50%; }
.ws-count { font-size: 0.7rem; color: #bbb; min-width: 14px; text-align: right; }

/* --- Project detail view --- */
.proj-detail-tasks { display: flex; flex-direction: column; gap: 1rem; }

.ms-section {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  overflow: hidden;
}
.ms-section-done { opacity: 0.65; }

.ms-section-header {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #f0f0f0;
  background: #fafafa;
}
.ms-section-title {
  font-size: 0.92rem;
  font-weight: 600;
  flex: 1;
}
.ms-task-count {
  font-size: 0.78rem;
  color: #999;
  white-space: nowrap;
}

.ms-task-list { padding: 0.4rem 0.75rem 0.75rem; }
.ms-empty { padding: 0.5rem 1rem 0.75rem; }

/* --- Calendar --- */
.cal-list { display: flex; flex-direction: column; gap: 4px; }
.cal-row   { display: flex; align-items: baseline; gap: 0.75rem; padding: 0.35rem 0; border-bottom: 1px solid #f0f0f0; }
.cal-row:last-child { border-bottom: none; }
.cal-time  { font-size: 0.8rem; color: #2563eb; font-weight: 600; min-width: 110px; flex-shrink: 0; }
.cal-title { font-size: 0.9rem; flex: 1; }
.cal-loc   { font-size: 0.78rem; color: #888; }

/* --- Calendar page --- */
.cal-page-layout {
  display: grid;
  grid-template-columns: 1fr 290px;
  gap: 1.25rem;
  align-items: start;
}

/* Month grid */
.month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: #e0e0e0;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  overflow: hidden;
}
.month-day-header {
  background: #f5f5f5;
  text-align: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: #999;
  padding: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.month-day {
  background: #fff;
  padding: 0.3rem 0.35rem;
  min-height: 100px;
  cursor: pointer;
  vertical-align: top;
}
.month-day:hover { background: #f5f9ff; }
.month-day.other-month { background: #fafafa; }
.month-day.other-month .month-day-num { color: #ccc; }
.month-day.is-today .month-day-num {
  background: #2563eb;
  color: #fff;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.month-day.is-selected {
  background: #eff6ff;
  outline: 2px solid #2563eb;
  outline-offset: -1px;
}
.month-day-num {
  font-size: 0.82rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
}
.month-day-items { display: flex; flex-direction: column; gap: 1px; margin-top: 2px; }
.month-day-item {
  font-size: 0.68rem;
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.5;
}
.item-event                      { background: #6366f1; color: #fff; }
.item-task-phd                   { background: #dbeafe; color: #1e40af; }
.item-task-hus                   { background: #d1fae5; color: #065f46; }
.item-task-privat                { background: #fce7f3; color: #9d174d; }
.item-task-bestyrelsesarbejde    { background: #fef3c7; color: #92400e; }
.month-more { font-size: 0.65rem; color: #888; padding: 0.1rem 0.3rem; }

/* Week grid */
.week-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.week-col {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  min-height: 200px;
}
.week-col:hover { border-color: #93c5fd; }
.week-col.is-today { border-color: #2563eb; }
.week-col.is-selected { background: #eff6ff; border-color: #2563eb; }
.week-col-header {
  padding: 0.45rem 0.35rem;
  border-bottom: 1px solid #f0f0f0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}
.week-day-name { font-size: 0.66rem; color: #aaa; text-transform: uppercase; font-weight: 700; }
.week-day-num  { font-size: 0.9rem; font-weight: 600; }
.today-badge {
  background: #2563eb;
  color: #fff;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
}
.week-col-items { padding: 0.3rem; display: flex; flex-direction: column; gap: 2px; }
.week-event {
  font-size: 0.68rem;
  padding: 0.12rem 0.3rem;
  border-radius: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.week-event-time { font-weight: 700; margin-right: 2px; }
.week-task {
  font-size: 0.68rem;
  padding: 0.12rem 0.3rem;
  border-radius: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.week-task:hover { filter: brightness(0.93); }
.cat-week-phd                 { background: #dbeafe; color: #1e40af; }
.cat-week-hus                 { background: #d1fae5; color: #065f46; }
.cat-week-privat              { background: #fce7f3; color: #9d174d; }
.cat-week-bestyrelsesarbejde  { background: #fef3c7; color: #92400e; }

/* Day panel */
.cal-side-panel {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 1rem;
  position: sticky;
  top: 64px;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
}
.cal-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
  gap: 0.5rem;
}
.cal-panel-header h2 { font-size: 0.92rem; font-weight: 600; }
.panel-section { margin-bottom: 1rem; }
.panel-section h3 {
  font-size: 0.7rem;
  color: #aaa;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  margin-bottom: 0.5rem;
}
.panel-event {
  display: flex;
  gap: 0.5rem;
  align-items: baseline;
  padding: 0.3rem 0;
  border-bottom: 1px solid #f5f5f5;
  font-size: 0.85rem;
}
.panel-event:last-child { border-bottom: none; }
.panel-event .cal-time { min-width: 90px; }

/* --- PhD Progress --- */
:root { --gantt-name-w: 110px; }

.phd-position {
  font-size: 0.88rem;
  color: #2563eb;
  font-weight: 600;
  background: #eff6ff;
  padding: 0.3rem 0.75rem;
  border-radius: 20px;
}

.phd-stats-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.phd-stat-card {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 0.75rem 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 90px;
}
.stat-n     { font-size: 1.6rem; font-weight: 700; line-height: 1; }
.stat-label { font-size: 0.75rem; color: #888; }

/* Gantt */
.gantt-wrap { overflow-x: auto; }

.gantt-header-years,
.gantt-header-q {
  display: flex;
  align-items: stretch;
}
.gantt-name-spacer {
  width: var(--gantt-name-w);
  flex-shrink: 0;
}
.gantt-years {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
}
.gantt-year-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.25rem;
  border-left: 1px solid #e0e0e0;
  font-size: 0.8rem;
  font-weight: 700;
  background: #f9fafb;
  line-height: 1.3;
}
.gantt-year-dates { font-size: 0.65rem; color: #aaa; font-weight: 400; }

.gantt-quarters {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(16, 1fr);
}
.gantt-q-cell {
  font-size: 0.6rem;
  color: #bbb;
  text-align: center;
  padding: 0.15rem 0;
  border-left: 1px solid #f0f0f0;
  background: #fafafa;
}

.gantt-rows { padding: 0.25rem 0; }

.gantt-section-header {
  display: flex;
  align-items: center;
  height: 26px;
  margin: 0.4rem 0 0.1rem;
}
.gantt-section-header span {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #6b7280;
  background: #f3f4f6;
  border-radius: 4px;
  padding: 0.1rem 0.5rem;
  margin-left: var(--gantt-name-w);
}

.gantt-row {
  display: flex;
  align-items: center;
  height: 32px;
  cursor: pointer;
}
.gantt-row:hover .gantt-track { background: #f5f9ff; }

.gantt-name {
  width: var(--gantt-name-w);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding-right: 0.5rem;
}
.gantt-short { font-size: 0.78rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.gantt-track {
  flex: 1;
  position: relative;
  height: 22px;
  border-radius: 3px;
  display: flex;
  align-items: center;
}
.gantt-bar {
  position: absolute;
  height: 18px;
  border-radius: 4px;
  overflow: visible;
}
.gantt-fill {
  height: 100%;
  border-radius: 4px 0 0 4px;
  transition: width 0.3s;
}
.gantt-pct {
  position: absolute;
  right: -28px;
  font-size: 0.68rem;
  color: #aaa;
  white-space: nowrap;
}
.gantt-milestone {
  position: absolute;
  top: -6px;
  font-size: 0.6rem;
  color: #888;
  transform: translateX(-50%);
  cursor: default;
  z-index: 2;
}
.gantt-milestone.ms-done { color: #10b981; }

/* Courses */
.course-progress-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.course-list { display: flex; flex-direction: column; gap: 0.35rem; }
.course-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem 0;
  border-bottom: 1px solid #f5f5f5;
}
.course-row:last-child { border-bottom: none; }
.course-ects {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.82rem;
  color: #888;
  flex-shrink: 0;
}
.ects-input {
  width: 52px;
  padding: 0.2rem 0.4rem;
  border: 1px solid #d0d0d0;
  border-radius: 4px;
  font-size: 0.82rem;
  text-align: right;
}

/* --- States --- */
.loading      { color: #999; padding: 2rem; text-align: center; }
.empty-state  { color: #999; padding: 2rem; text-align: center; font-size: 0.9rem; }
.error-state  {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  border-radius: 8px;
  padding: 1.5rem;
  margin: 2rem auto;
  max-width: 500px;
}
.error-state h2 { color: #dc2626; margin-bottom: 0.5rem; }
.error-state pre { font-size: 0.78rem; color: #555; margin-top: 0.75rem; white-space: pre-wrap; }

/* --- AI Assistant --- */
#ai-fab {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #2563eb;
  color: #fff;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
#ai-fab:hover { background: #1d4ed8; }

#ai-panel {
  position: fixed;
  bottom: 5.5rem;
  right: 1.5rem;
  width: 360px;
  max-height: 520px;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.14);
  display: flex;
  flex-direction: column;
  z-index: 900;
  overflow: hidden;
}
@media (max-width: 480px) {
  #ai-panel { right: 0.5rem; left: 0.5rem; width: auto; }
}

.ai-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #f0f0f0;
  background: #f8f9fa;
}
.ai-title { font-weight: 600; font-size: 0.9rem; }
.ai-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  color: #888;
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
}
.ai-close:hover { background: #eee; }

.ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.ai-empty {
  color: #9ca3af;
  font-size: 0.85rem;
  text-align: center;
  padding: 1rem 0;
  line-height: 1.5;
}
.ai-msg { display: flex; }
.ai-msg-user  { justify-content: flex-end; }
.ai-msg-assistant { justify-content: flex-start; }

.ai-msg-bubble {
  max-width: 85%;
  padding: 0.5rem 0.75rem;
  border-radius: 10px;
  font-size: 0.85rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.ai-msg-user .ai-msg-bubble {
  background: #2563eb;
  color: #fff;
  border-bottom-right-radius: 3px;
}
.ai-msg-assistant .ai-msg-bubble {
  background: #f3f4f6;
  color: #111;
  border-bottom-left-radius: 3px;
}
.ai-typing { color: #9ca3af; letter-spacing: 0.1em; }

.ai-input-row {
  display: flex;
  gap: 0.5rem;
  padding: 0.65rem 0.75rem;
  border-top: 1px solid #f0f0f0;
}
.ai-input-row input {
  flex: 1;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 0.45rem 0.65rem;
  font-size: 0.88rem;
  outline: none;
}
.ai-input-row input:focus { border-color: #2563eb; }
.ai-input-row input:disabled { background: #f9f9f9; color: #aaa; }
