:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #e2e5ea;
  --text: #1c2126;
  --muted: #6b7280;
  --primary: #2f6feb;
  --primary-dark: #1f4fb8;
  --danger: #d9463c;
  --not-assigned: #8e5fd6;
  --not-started: #9aa3af;
  --in-progress: #2f6feb;
  --blocked: #d9463c;
  --done: #23a35a;
  --not-assigned-bg: #f1ebfa;
  --not-started-bg: #eef0f2;
  --in-progress-bg: #e8f0fe;
  --blocked-bg: #fdeceb;
  --done-bg: #e6f7ed;
  --nav-active-bg: #eaf1ff;
  --track-bg: #eef0f3;
  --row-hover: #fafbfc;
  --priority-low: #9aa3af;
  --priority-medium: #2f6feb;
  --priority-high: #e08a1e;
  --priority-urgent: #d9463c;
  --milestone: #b8860b;
  --event: #0f766e;
  --radius: 10px;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14171c;
  --surface: #1c2027;
  --border: #2c313a;
  --text: #e6e8eb;
  --muted: #9aa3af;
  --primary: #4c8dff;
  --primary-dark: #6ba1ff;
  --danger: #ff6b61;
  --not-assigned: #b18cf0;
  --not-started: #8b93a1;
  --in-progress: #4c8dff;
  --blocked: #ff6b61;
  --done: #35c07a;
  --not-assigned-bg: rgba(177, 140, 240, 0.15);
  --not-started-bg: rgba(139, 147, 161, 0.15);
  --in-progress-bg: rgba(76, 141, 255, 0.15);
  --blocked-bg: rgba(255, 107, 97, 0.15);
  --done-bg: rgba(53, 192, 122, 0.15);
  --nav-active-bg: rgba(76, 141, 255, 0.18);
  --track-bg: #262b33;
  --row-hover: rgba(255, 255, 255, 0.03);
  --priority-low: #8b93a1;
  --priority-medium: #4c8dff;
  --priority-high: #e5a03d;
  --priority-urgent: #ff6b61;
  --milestone: #d4af37;
  --event: #2dd4bf;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { font-weight: 700; font-size: 16px; }

.user-chip {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  font-size: 13px; font-weight: 600; white-space: nowrap;
  padding: 5px 10px; border-radius: 999px;
  background: var(--nav-active-bg); color: var(--primary);
}
.user-chip .user-role {
  font-size: 11px; font-weight: 400; color: var(--muted); text-transform: capitalize;
}

.topbar nav { display: flex; gap: 4px; flex: 1; }

.topbar nav a {
  padding: 8px 14px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
}

.topbar nav a:hover { background: var(--bg); color: var(--text); }
.topbar nav a.active { background: var(--nav-active-bg); color: var(--primary); }

.content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px;
}

/* Embed mode: the page is rendered inside a modal iframe (?embed=1) — hide
   the site chrome so only the page's own content shows. */
body.embedded .topbar {
  display: none;
}
body.embedded .content {
  padding: 8px 14px 20px;
}
body.embedded .embed-hide {
  display: none !important;
}

h1 { font-size: 22px; margin: 0 0 20px; }
h2 { font-size: 16px; margin: 0 0 12px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: var(--primary);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--primary-dark); }
.btn-outline { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-outline:hover { background: var(--nav-active-bg); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #b8352c; }
.btn-small { padding: 4px 10px; font-size: 12px; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

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

.card .value { font-size: 28px; font-weight: 700; }
.card .label { color: var(--muted); font-size: 13px; margin-top: 4px; }

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

.status-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
}
.status-Not-Assigned { background: var(--not-assigned); }
.status-Not-Started { background: var(--not-started); }
.status-In-Progress { background: var(--in-progress); }
.status-Blocked { background: var(--blocked); }
.status-Done { background: var(--done); }

.priority-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
}
.priority-Low { background: var(--priority-low); }
.priority-Medium { background: var(--priority-medium); }
.priority-High { background: var(--priority-high); }
.priority-Urgent { background: var(--priority-urgent); }

.research-status-pill, .research-outcome-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
}
.research-status-Proposed { background: var(--not-started); }
.research-status-Exploring { background: var(--in-progress); }
.research-status-On-Hold { background: var(--priority-high); }
.research-status-Concluded { background: var(--done); }
.research-outcome-Adopted { background: var(--done); }
.research-outcome-Rejected { background: var(--danger); }
.research-outcome-Needs-More-Work { background: var(--priority-high); }

.critical-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #fff;
  background: var(--danger);
  white-space: nowrap;
}

.recurring-badge, .off-hours-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #fff;
  white-space: nowrap;
}
.recurring-badge { background: #6b46c1; }
.off-hours-badge { background: #b45309; }

.effort-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.effort-badge.effort-within { background: var(--done-bg); color: var(--done); }
.effort-badge.effort-over { background: var(--blocked-bg); color: var(--blocked); }

.weekly-report-page {
  display: grid;
  gap: 16px;
}

/* Keep oversized report content (notably Project Updates Tape) from widening
   the entire page; horizontal scrolling should happen inside .table-scroll. */
.weekly-report-page > *,
.weekly-report-page .panel,
.weekly-report-page .weekly-grid > * {
  min-width: 0;
}

.weekly-report-page .table-scroll {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}

.weekly-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
}

.weekly-subtitle {
  margin: -8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.weekly-range {
  font-weight: 700;
  color: var(--primary);
  background: var(--nav-active-bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  white-space: nowrap;
}

.weekly-hero-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.weekly-range-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 8px;
}

.weekly-range-field {
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}

.weekly-range-field span {
  font-weight: 600;
}

.weekly-range-field input[type="date"] {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
}

.weekly-hero-actions .weekly-range {
  align-self: center;
}

.weekly-kpis {
  margin-bottom: 0;
}

.weekly-subtabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.weekly-grid {
  display: grid;
  gap: 16px;
}

.weekly-grid.two-col {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.weekly-stack {
  display: grid;
  gap: 10px;
}

.weekly-bar-row {
  display: grid;
  grid-template-columns: minmax(170px, 1.5fr) minmax(160px, 3fr) auto;
  align-items: center;
  gap: 10px;
}

.weekly-bar-label {
  font-size: 13px;
  color: var(--text);
}

.weekly-bar-track {
  background: var(--track-bg);
  border-radius: 999px;
  height: 11px;
  overflow: hidden;
}

.weekly-bar-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--primary);
}

.weekly-bar-fill.tone-primary { background: var(--primary); }
.weekly-bar-fill.tone-good { background: var(--done); }
.weekly-bar-fill.tone-risk { background: var(--danger); }

.weekly-bar-value {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.weekly-table td,
.weekly-table th {
  font-size: 12.5px;
  vertical-align: top;
}

.weekly-table td:not(:first-child),
.weekly-table th:not(:first-child) {
  text-align: center;
}

.weekly-alert {
  color: #c62828;
  font-weight: 700;
}

.weekly-standout {
  background: color-mix(in srgb, var(--priority-high) 22%, var(--surface));
  font-weight: 700;
}

.weekly-subhead {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 0 0 8px;
}

.weekly-mini-table {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}

.weekly-mini-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
}

.weekly-mini-row.tone-good {
  background: var(--done-bg);
  border-color: color-mix(in srgb, var(--done) 30%, var(--border));
}

.weekly-mini-row.tone-risk {
  background: var(--blocked-bg);
  border-color: color-mix(in srgb, var(--danger) 25%, var(--border));
}

.weekly-heatmap td {
  min-width: 70px;
  font-variant-numeric: tabular-nums;
}

.weekly-tape-table th,
.weekly-tape-table td {
  min-width: 130px;
}

.table-scroll .weekly-tape-table {
  table-layout: auto;
  width: max-content;
  min-width: 100%;
}

.weekly-tape-table th:nth-child(1),
.weekly-tape-table td:nth-child(1) {
  min-width: 180px;
}

.weekly-tape-table th:nth-child(2),
.weekly-tape-table td:nth-child(2) {
  min-width: 180px;
}

.weekly-tape-table th:nth-child(n + 4),
.weekly-tape-table td:nth-child(n + 4) {
  width: 720px;
  min-width: 720px;
}

.weekly-tape-table th:nth-child(3),
.weekly-tape-table td:nth-child(3) {
  min-width: 110px;
}

.tape-cell-empty {
  color: var(--muted);
  text-align: center;
  font-weight: 700;
}

.tape-cell-active {
  text-align: left;
  background: color-mix(in srgb, var(--primary) 9%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--primary) 20%, var(--border));
  border-radius: 8px;
  padding: 6px 8px;
}

.tape-count {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 2px;
}

.tape-snippet {
  font-size: 11px;
  color: var(--text);
  line-height: 1.25;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 700px) {
  .weekly-hero {
    flex-direction: column;
    align-items: flex-start;
  }

  .weekly-range {
    white-space: normal;
  }

  .weekly-hero-actions {
    width: 100%;
    justify-content: space-between;
  }

  .weekly-bar-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .weekly-bar-value {
    justify-self: end;
  }
}

.tag-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--border);
  white-space: nowrap;
  margin: 0 4px 4px 0;
}
.tag-pill.removable { display: inline-flex; align-items: center; gap: 4px; margin: 2px 4px 2px 0; }
.tag-pill .tag-remove {
  background: none; border: none; padding: 0; margin: 0; color: var(--muted); font-size: 13px;
  line-height: 1; cursor: pointer;
}
.tag-pill .tag-remove:hover { color: var(--danger); }

.tag-picker { position: relative; }
.tag-picker-chips {
  display: flex; flex-wrap: wrap; align-items: center; gap: 2px;
  padding: 4px 6px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); min-height: 30px;
}
.tag-picker-input {
  flex: 1; min-width: 70px; border: none; outline: none; padding: 3px 2px;
  font-size: 13px; background: transparent; color: var(--text);
}
.tag-picker-dropdown {
  position: absolute; top: 100%; left: 0; right: 0; margin-top: 2px; z-index: 20;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12); max-height: 160px; overflow-y: auto;
}
.tag-picker-option { padding: 7px 10px; font-size: 13px; cursor: pointer; }
.tag-picker-option:hover { background: var(--bg); }

/* Multi-select dropdown: a closed control naming the current picks, opening a
   checkbox list. Used for the Team managed column on Settings. The menu is
   positioned in VIEWPORT coordinates (position: fixed) because its cells live
   inside .table-scroll-y, whose overflow would clip an absolutely positioned
   one — settings.html places it and closes it on scroll. */
.ms-picker { position: relative; }
.ms-toggle {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  width: 100%; padding: 5px 8px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); color: var(--text); font-size: 13px; font-family: inherit;
  cursor: pointer; text-align: left;
}
.ms-toggle:hover { border-color: var(--primary); }
.ms-picker.ms-open .ms-toggle { border-color: var(--primary); }
.ms-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-label.ms-empty { color: var(--muted); }
.ms-caret { color: var(--muted); font-size: 10px; flex-shrink: 0; }
.ms-menu {
  position: fixed; z-index: 60; min-width: 180px; max-height: 220px; overflow-y: auto;
  padding: 4px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: 0 6px 16px rgba(0,0,0,0.16);
}
.ms-option {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px;
  font-size: 13px; border-radius: 6px; cursor: pointer; white-space: nowrap;
}
.ms-option:hover { background: var(--bg); }
.ms-option input { margin: 0; cursor: pointer; width: auto; }

.workload-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.workload-name { width: 110px; font-size: 13px; font-weight: 600; flex-shrink: 0; }
.workload-bar {
  flex: 1;
  display: flex;
  height: 18px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--track-bg);
}
.workload-bar span { height: 100%; }
.workload-total { width: 48px; text-align: right; font-size: 12px; color: var(--muted); flex-shrink: 0; }

.legend { display: flex; gap: 16px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

.task-link { color: var(--text); text-decoration: none; font-weight: 500; }
.task-link:hover { color: var(--primary); text-decoration: underline; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.02em; white-space: nowrap; }
tr:hover td { background: var(--row-hover); }

.table-scroll { overflow-x: auto; }
.table-scroll table { min-width: 1280px; table-layout: fixed; }

/* Vertically scrollable table body with a pinned header — used by the User
   Accounts list once it grows past ~7 rows. max-height ≈ header + 7 rows. */
.table-scroll-y { max-height: 396px; overflow-y: auto; }
.table-scroll-y table { margin: 0; }
.table-scroll-y thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface);
  box-shadow: inset 0 -1px 0 var(--border);
}

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar select, .toolbar input[type=text] {
  padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; background: var(--surface); color: var(--text);
}
.toolbar .spacer { flex: 1; }

td select, td input[type=text], td input[type=date] {
  padding: 5px 6px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; width: 100%; background: var(--surface); color: var(--text);
}
.col-task { width: 200px; }
.col-narrow { width: 90px; }
.col-tags { width: 220px; }

th.sortable-th { cursor: pointer; user-select: none; }
th.sortable-th:hover { color: var(--text); }
th.sortable-th .sort-arrow { color: var(--primary); margin-left: 3px; }

.overdue { color: var(--danger); font-weight: 600; }

.empty-state { color: var(--muted); text-align: center; padding: 30px; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.35);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
/* While any modal is open, freeze the page behind it (toggled from app.js by
   observing .modal-backdrop visibility) so the background can't scroll. The
   viewport scroll container is the root <html>, so the lock must sit there —
   overflow:hidden on <body> alone doesn't stop page scroll. */
html.modal-open, html.modal-open body { overflow: hidden; }
.modal {
  background: var(--surface); border-radius: var(--radius); padding: 24px; width: 420px; max-width: 92vw;
}
.modal.modal-lg { width: 640px; }
/* Full task editor hosted in the modal (openTaskPageModal) — near-fullscreen
   for comfortable reading; the plain task-list modal stays modal-lg sized. */
.modal.modal-page { width: min(1180px, 96vw); }
.modal.modal-page .modal-scroll { max-height: 82vh; }
.modal h2 { margin-bottom: 16px; }
.modal label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 4px; }
.modal input, .modal select, .modal textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px;
  background: var(--surface); color: var(--text);
}
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.modal-actions .spacer { flex: 1; }
.modal-scroll { max-height: 420px; overflow-y: auto; overflow-x: auto; }

.markdown-body { font-size: 14px; line-height: 1.6; }
.markdown-body h1, .markdown-body h2, .markdown-body h3,
.markdown-body h4, .markdown-body h5, .markdown-body h6 { margin: 18px 0 8px; line-height: 1.3; }
.markdown-body h1:first-child, .markdown-body h2:first-child, .markdown-body h3:first-child { margin-top: 0; }
.markdown-body p { margin: 0 0 12px; }
.markdown-body ul, .markdown-body ol { margin: 0 0 12px; padding-left: 24px; }
.markdown-body li { margin-bottom: 4px; }
.markdown-body code { background: var(--bg); padding: 1px 5px; border-radius: 4px; font-size: 13px; }
.markdown-body pre { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; overflow-x: auto; margin: 0 0 12px; }
.markdown-body pre code { background: none; padding: 0; }
.markdown-body blockquote { border-left: 3px solid var(--border); margin: 0 0 12px; padding: 2px 12px; color: var(--muted); }
.markdown-body a { color: var(--primary); }

.hidden { display: none !important; }

.notes-list { max-height: 260px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.note-item { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
.note-body { font-size: 13px; white-space: pre-wrap; word-break: break-word; margin-bottom: 6px; }
.note-meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); }
.note-hours {
  display: inline-block; background: var(--primary); color: #fff; border-radius: 999px;
  font-size: 10px; font-weight: 700; padding: 1px 7px; white-space: nowrap;
}
/* With an hours chip present, keep the timestamp beside it (left) rather than
   letting space-between float it to the middle. */
.note-hours + span { margin-right: auto; }
.note-delete {
  background: none; border: none; color: var(--muted); font-size: 16px; line-height: 1; cursor: pointer; padding: 0 2px;
}
.note-delete:hover { color: var(--danger); }

.notes-btn {
  background: none; border: 1px solid var(--border); color: var(--muted);
  border-radius: 6px; font-size: 12px; padding: 4px 9px; cursor: pointer; white-space: nowrap;
}
.notes-btn:hover { border-color: var(--primary); color: var(--primary); }
.notes-btn .notes-count {
  display: inline-block; background: var(--primary); color: #fff; border-radius: 999px;
  font-size: 10px; font-weight: 700; padding: 1px 6px; margin-left: 5px;
}

/* ---- Comment threads (task + progress-update replies) ----
   Comments are attributed and role-badged, unlike the anonymous .note-item —
   a worker needs to see at a glance that their manager wrote this. */
.comment-list { display: flex; flex-direction: column; gap: 8px; }
.comment-item {
  background: var(--bg); border: 1px solid var(--border);
  border-left: 3px solid var(--border); border-radius: 8px; padding: 8px 10px;
}
.comment-item.from-supervisor { border-left-color: var(--primary); }
.comment-head {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; margin-bottom: 5px;
}
.comment-author { font-weight: 600; }
.comment-role {
  display: inline-block; background: var(--nav-active-bg); color: var(--primary);
  border-radius: 999px; font-size: 10px; font-weight: 700;
  padding: 1px 7px; text-transform: capitalize; white-space: nowrap;
}
.comment-time { color: var(--muted); font-size: 11px; margin-left: auto; }
.comment-body { font-size: 13px; white-space: pre-wrap; word-break: break-word; }
/* Replies to one progress update, tucked under it. */
.comment-replies { margin: 8px 0 0 14px; padding-left: 10px; border-left: 2px solid var(--border); }
.comment-reply-toggle { margin-top: 8px; }
.comment-form { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.comment-form textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; background: var(--surface); color: var(--text); font-family: inherit;
}
.comment-form .modal-actions { justify-content: flex-start; margin: 0; }

/* ---- Notification bell (topbar) ---- */
.bell-wrap { position: relative; flex-shrink: 0; }
.bell-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; padding: 0; position: relative;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--muted); cursor: pointer;
}
.bell-btn:hover { border-color: var(--primary); color: var(--primary); }
.bell-btn svg { width: 18px; height: 18px; }
.bell-badge {
  position: absolute; top: -6px; right: -6px; min-width: 17px; height: 17px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 4px; border-radius: 999px; background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 700; line-height: 1;
}
.bell-panel {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 60;
  width: 340px; max-width: calc(100vw - 24px);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18);
}
.bell-panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 13px;
}
.bell-list { max-height: 60vh; overflow-y: auto; }
.bell-item {
  display: block; width: 100%; text-align: left; padding: 10px 12px;
  border: none; border-bottom: 1px solid var(--border);
  background: none; color: var(--text); cursor: pointer; font-family: inherit;
}
.bell-item:last-child { border-bottom: none; }
.bell-item:hover { background: var(--bg); }
.bell-item.unread { background: var(--nav-active-bg); }
.bell-item-title { font-size: 13px; font-weight: 600; margin-bottom: 3px; }
.bell-item-body {
  font-size: 12px; color: var(--muted); white-space: pre-wrap; word-break: break-word;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.bell-item-time { font-size: 11px; color: var(--muted); margin-top: 4px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; padding: 0; flex-shrink: 0;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); color: var(--muted); cursor: pointer;
}
.icon-btn:hover { border-color: var(--primary); color: var(--primary); }
.icon-btn svg { width: 14px; height: 14px; }
.icon-btn.icon-btn-active { border-color: var(--primary); color: var(--primary); background: var(--nav-active-bg); }

.field-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 20px; }
.field-grid .full { grid-column: 1 / -1; }
.field-grid label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.field-grid input, .field-grid select, .field-grid textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px;
  background: var(--surface); color: var(--text); font-family: inherit;
}

.attachment-list { display: flex; flex-direction: column; gap: 8px; }
.attachment-item {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px;
}
.attachment-item .name { font-size: 13px; font-weight: 500; word-break: break-all; }
.attachment-item .meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.attachment-item .actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

.kanban-board {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 24px;
}
.kanban-column {
  flex: 1 1 240px;
  min-width: 240px;
  max-width: 320px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 4px solid var(--status-color, var(--border));
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  max-height: 65vh;
}
.kanban-column-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--status-bg, var(--bg));
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
  border-radius: 6px 6px 0 0;
}
.kanban-column-header .count {
  background: var(--status-color, var(--muted));
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
}
.kanban-cards {
  flex: 1;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  min-height: 80px;
  transition: background 0.1s;
}
.kanban-cards.drag-over { background: var(--nav-active-bg); }
.kanban-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--status-color, var(--border));
  border-radius: 8px;
  padding: 10px 12px;
  cursor: grab;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.kanban-card:active { cursor: grabbing; }
.kanban-card.dragging { opacity: 0.4; }
.kanban-card .task-name { font-size: 13px; font-weight: 600; margin-bottom: 8px; line-height: 1.3; }
.kanban-card a.task-name:hover { color: var(--primary); text-decoration: underline; }
.kanban-card .meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.kanban-card .tag { background: var(--bg); padding: 2px 7px; border-radius: 5px; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kanban-card .deadline.overdue { color: var(--danger); font-weight: 600; }
.kanban-card .notes-btn { margin-top: 8px; padding: 3px 8px; font-size: 11px; }

.member-grid, .project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.member-card, .project-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.member-card h3, .project-card h3 { margin: 0 0 4px; font-size: 15px; }
.member-card .role, .project-card .subtitle { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.member-card .skills, .project-card .description { font-size: 12px; color: var(--muted); margin-bottom: 12px; }
.member-card .stat-row, .project-card .stat-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.member-card .stat, .project-card .stat { font-size: 12px; padding: 3px 8px; border-radius: 6px; background: var(--bg); }
.project-card .stat-row:last-child { margin-bottom: 0; }
.focus-line { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.focus-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  padding: 4px 10px 4px 8px;
  border-radius: 999px;
  white-space: nowrap;
  color: var(--muted);
  background: color-mix(in srgb, var(--primary) 8%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--primary) 20%, var(--border));
}
.focus-chip strong { color: var(--text); font-weight: 600; }
.focus-chip .focus-label { color: var(--muted); }
.focus-chip .focus-count {
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  color: var(--primary);
  font-weight: 600;
  padding-left: 4px;
  border-left: 1px solid color-mix(in srgb, var(--primary) 25%, var(--border));
}

.calendar-title { font-weight: 600; font-size: 16px; min-width: 160px; text-align: center; }
.calendar-daynames { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 6px; }
.calendar-daynames div { text-align: center; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.02em; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); grid-auto-rows: minmax(96px, auto); gap: 6px; }
.calendar-cell {
  border: 1px solid var(--border); border-radius: 8px; padding: 6px;
  background: var(--bg); display: flex; flex-direction: column; gap: 4px; overflow: hidden;
}
.calendar-cell.other-month { opacity: 0.45; }
.calendar-cell.today { border-color: var(--primary); border-width: 2px; }
.calendar-date { font-size: 12px; font-weight: 600; color: var(--muted); }
.calendar-cell.today .calendar-date { color: var(--primary); }
.calendar-tasks { display: flex; flex-direction: column; gap: 3px; }
.calendar-task-chip {
  font-size: 11px; padding: 2px 6px; border-radius: 5px; color: #fff; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.calendar-more-chip {
  font-size: 11px; padding: 2px 6px; border-radius: 5px; cursor: pointer;
  text-align: center; font-weight: 600; color: var(--muted); background: var(--row-hover);
}
.calendar-more-chip:hover { color: var(--text); background: var(--border); }

.calendar-milestones { display: flex; flex-direction: column; gap: 3px; }
.calendar-milestone-chip {
  font-size: 11px; padding: 2px 6px; border-radius: 5px; cursor: pointer; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--milestone); background: color-mix(in srgb, var(--milestone) 16%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--milestone) 40%, var(--surface));
}

.calendar-events { display: flex; flex-direction: column; gap: 3px; }
#events-calendar-grid .calendar-cell { cursor: pointer; }
#events-calendar-grid .calendar-cell:hover { background: var(--row-hover); }
.calendar-event-chip {
  font-size: 11px; padding: 2px 6px; border-radius: 5px; cursor: pointer; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--event); background: color-mix(in srgb, var(--event) 14%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--event) 40%, var(--surface));
}

.event-attendees {
  display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 4px 0 2px;
}
.event-attendees label {
  display: flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 400; margin: 0;
}

.view-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* The timeline scrolls as one surface — both axes on .gantt-scroll, so the day
   header and the bars can never drift out of alignment. Each day column gets a
   guaranteed width (--gantt-days-w = days × day width, set per month by
   renderGanttChart) instead of being squeezed into the panel, so a full month
   stays readable and overflows sideways; the canvas still fills the panel when
   there's room to spare. The label column sticks to the left and the day
   header to the top, so a bar deep in the chart still says which row and which
   day it belongs to. */
.gantt-scroll { --gantt-label-w: 220px; overflow: auto; max-height: 620px; position: relative; }
.gantt-canvas { width: max(100%, calc(var(--gantt-label-w) + var(--gantt-days-w, 0px))); }
.gantt-header {
  display: flex; padding-bottom: 4px; position: sticky; top: 0; z-index: 4; background: var(--surface);
}
.gantt-header-label {
  width: var(--gantt-label-w); flex-shrink: 0; position: sticky; left: 0; z-index: 5;
  background: var(--surface);
}
/* Two header rows over one set of day columns: the month band, then the days.
   The month widths are the same day-column arithmetic the bars use, so the
   label above a bar always names the month the bar is actually in. */
.gantt-header-cols { flex: 1; min-width: 0; }
.gantt-header-months { display: flex; height: 15px; }
.gantt-header-month {
  font-size: 10px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase;
  color: var(--muted); padding-left: 5px; box-sizing: border-box; overflow: hidden;
  white-space: nowrap; border-left: 1px solid var(--muted);
}
.gantt-header-month:first-child { border-left: none; }
.gantt-header-days { flex: 1; display: flex; position: relative; height: 18px; }
.gantt-header-day {
  flex: 1; text-align: center; font-size: 10px; color: var(--muted);
}
/* Only the numbered days carry a rule — one per column would be a smear at
   this many months. */
.gantt-header-day.labelled { border-left: 1px solid var(--border); }
.gantt-header-day.month-start { border-left: 1px solid var(--muted); }
.gantt-header-day:first-child { border-left: none; }
.gantt-body { display: flex; flex-direction: column; gap: 3px; }
.gantt-row { display: flex; align-items: center; gap: 0; min-height: 30px; }
.gantt-label {
  width: var(--gantt-label-w); flex-shrink: 0; font-size: 12px; padding-right: 10px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
  position: sticky; left: 0; z-index: 3; background: var(--surface);
}
.gantt-label .muted { color: var(--muted); font-size: 11px; }
.gantt-track {
  flex: 1; position: relative; height: 22px; background: var(--track-bg); border-radius: 4px;
}
.gantt-bar {
  position: absolute; top: 2px; bottom: 2px; border-radius: 4px; cursor: pointer;
  min-width: 4px; box-sizing: border-box;
}
.gantt-bar:not([data-href]) { cursor: default; }
.gantt-bar.at-risk { box-shadow: inset 0 0 0 2px var(--danger); }
.gantt-bar.clipped-start::before {
  content: "\25c4"; position: absolute; left: 2px; top: 50%; transform: translateY(-50%);
  font-size: 9px; color: rgba(255,255,255,0.85);
}
/* Mirror of clipped-start: the span carries on past the last month shown. */
.gantt-bar.clipped-end::after {
  content: "\25ba"; position: absolute; right: 2px; top: 50%; transform: translateY(-50%);
  font-size: 9px; color: rgba(255,255,255,0.85);
}
.gantt-today-line { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--danger); z-index: 2; }
.gantt-today-label {
  position: absolute; top: -1px; left: 4px; z-index: 3; white-space: nowrap;
  font-size: 10px; font-weight: 700; line-height: 1.4; color: #fff;
  background: var(--danger); padding: 0 5px; border-radius: 3px;
}
.gantt-milestone-line {
  position: absolute; top: 0; bottom: 0; width: 2px; background: var(--milestone); z-index: 1; cursor: pointer;
}
/* Where each month starts, so a bar can be read against the month band above. */
.gantt-month-line {
  position: absolute; top: 0; bottom: 0; width: 1px; background: var(--border); z-index: 0;
}
.gantt-empty-row { min-height: 30px; }

.gantt-milestone-legend { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.gantt-milestone-badge {
  font-size: 11px; padding: 3px 8px; border-radius: 5px; cursor: pointer; font-weight: 600;
  color: var(--milestone); background: color-mix(in srgb, var(--milestone) 16%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--milestone) 40%, var(--surface));
}
.gantt-milestone-badge .muted { font-weight: 400; }

.timeline-chart {
  display: flex; align-items: flex-end; gap: 6px; overflow-x: auto; padding-bottom: 4px;
}
.timeline-bucket { display: flex; flex-direction: column; align-items: center; flex-shrink: 0; min-width: 30px; }
.timeline-bars { display: flex; align-items: flex-end; gap: 3px; height: 140px; }
.timeline-bar { width: 11px; border-radius: 3px 3px 0 0; min-height: 2px; }
.timeline-bar.created { background: var(--primary); }
.timeline-bar.completed { background: var(--done); }
.timeline-label { font-size: 10px; color: var(--muted); margin-top: 6px; white-space: nowrap; }

.metrics-note { font-size: 12px; color: var(--muted); margin: -6px 0 14px; }

.breakdown-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.breakdown-label { width: 110px; font-size: 13px; font-weight: 600; flex-shrink: 0; }
.breakdown-bar-track { flex: 1; height: 18px; border-radius: 6px; overflow: hidden; background: var(--track-bg); }
.breakdown-bar-fill { height: 100%; }
.breakdown-count { width: 30px; text-align: right; font-size: 12px; color: var(--muted); }

.mini-table { width: 100%; font-size: 13px; border-collapse: collapse; }
.mini-table th, .mini-table td { text-align: left; padding: 7px 6px; border-bottom: 1px solid var(--border); }
.mini-table th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; }
.mini-table td.num { text-align: right; }

.upload-drop-zone { border: 2px dashed var(--border); border-radius: 8px; padding: 18px 16px; text-align: center; cursor: pointer; color: var(--muted); font-size: 13px; transition: border-color .15s, background .15s; user-select: none; margin-top: 14px; }
.upload-drop-zone:hover, .upload-drop-zone.drag-over { border-color: var(--primary); background: rgba(47,111,235,.06); color: var(--text); }
.upload-drop-zone.drag-over { background: rgba(47,111,235,.12); }
.upload-status { font-size: 12px; color: var(--muted); margin-top: 8px; min-height: 18px; }
