:root {
  /* layout */
  --radius: 18px;
  --font: Arial, Helvetica, sans-serif;

  /* typography scale — theme-agnostic. Use these tokens instead of literal
     rem values for text-sized elements. Anything below --fs-micro (12.8px)
     is below the readability floor and should be reconsidered. */
  --fs-micro: 0.8rem;    /* 12.8px — captions, gantt cells, eyebrows */
  --fs-small: 0.875rem;  /* 14px   — secondary text: hints, dates, table headers, group labels, detail-panel labels */
  --fs-base:  1rem;      /* 16px   — body default */
  --fs-large: 1.125rem;  /* 18px   — emphasized body, panel h3 */
  --fs-xl:    1.4rem;    /* 22.4px — metric numbers, section titles */

  /* page chrome */
  --bg-app: radial-gradient(circle at top right, rgba(37, 99, 235, 0.18), transparent 25%),
            radial-gradient(circle at bottom left, rgba(30, 64, 175, 0.16), transparent 28%),
            linear-gradient(180deg, #020617 0%, #08101f 100%);
  --bg-topbar: rgba(2, 6, 23, 0.9);
  --bg-sidebar: rgba(15, 23, 42, 0.84);
  --border-chrome: #1e293b;

  /* panels */
  --panel: rgba(15, 23, 42, 0.94);
  --panel-strong: #111c31;
  --panel-soft: rgba(30, 41, 59, 0.5);
  --bg-dialog-form: #0f172a;

  /* inputs & chips */
  --bg-input: #1e293b;
  --bg-chip: rgba(30, 41, 59, 0.9);
  --bg-combobox-list: #1e293b;

  /* borders */
  --border: #334155;
  --border-soft: rgba(51, 65, 85, 0.88);
  --border-dashed: rgba(148, 163, 184, 0.15);

  /* text */
  --text: #f1f5f9;
  --text-inverse: #ffffff;
  --muted: #94a3b8;
  --muted-strong: #cbd5e1;

  /* accent */
  --accent: #2563eb;
  --accent-strong: #3b82f6;
  --accent-soft: rgba(37, 99, 235, 0.16);
  --accent-border: rgba(59, 130, 246, 0.35);
  --accent-hover-bg: rgba(37, 99, 235, 0.12);
  --warn: #f59e0b;

  /* neutral hovers (used for chips, icon buttons, pills) */
  --hover-muted: rgba(148, 163, 184, 0.12);
  --hover-muted-soft: rgba(148, 163, 184, 0.1);
  --hover-muted-strong: rgba(148, 163, 184, 0.15);

  /* danger */
  --danger-bg: rgba(127, 29, 29, 0.16);
  --danger-border: rgba(248, 113, 113, 0.28);
  --danger-text: #fca5a5;
  --danger-bg-hover: rgba(127, 29, 29, 0.3);
  --danger-border-hover: rgba(248, 113, 113, 0.45);
  --danger-text-hover: #fee2e2;

  /* status chips */
  --chip-success-bg: rgba(16, 185, 129, 0.16);
  --chip-success-border: rgba(52, 211, 153, 0.35);
  --chip-success-text: #34d399;
  --chip-warn-bg: rgba(245, 158, 11, 0.14);
  --chip-warn-border: rgba(245, 158, 11, 0.32);
  --chip-warn-text: #fbbf24;

  /* misc */
  --backdrop: rgba(24, 22, 18, 0.45);
  --shadow: 0 24px 60px rgba(2, 6, 23, 0.45);
  --shadow-dropdown: 0 10px 28px rgba(0, 0, 0, 0.45);

  /* chart palette (referenced via getComputedStyle from app.js) */
  --chart-1: #60a5fa;
  --chart-2: #34d399;
  --chart-3: #fbbf24;
  --chart-border: #0f172a;
  --chart-grid: rgba(148, 163, 184, 0.1);

  /* combobox chevron (muted stroke, embedded SVG) */
  --chevron-svg: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='3 5 7 9 11 5'/%3E%3C/svg%3E");
}

:root[data-theme="light"] {
  /* Warm light mode — paper canvas, lighter cards (inverted elevation), warm-tinted shadows. */
  --bg-app: radial-gradient(circle at 25% 15%, rgba(184, 84, 44, 0.025) 0%, transparent 40%),
            radial-gradient(circle at 80% 70%, rgba(184, 168, 140, 0.04) 0%, transparent 50%),
            linear-gradient(180deg, #f6f1e8 0%, #f6f1e8 100%);
  --bg-topbar: rgba(251, 247, 239, 0.95);
  --bg-sidebar: rgba(251, 247, 239, 0.86);
  --border-chrome: #e8dfce;

  /* surfaces — cards LIGHTER than canvas; sunken used for inputs */
  --panel: #fbf7ef;          /* surface */
  --panel-strong: #fffdf7;   /* surface-2 (most elevated) */
  --panel-soft: #fbf7ef;     /* surface, used by project-update / chart cards */
  --bg-dialog-form: #fbf7ef;

  --bg-input: #efe8db;       /* sunken — recessed wells */
  --bg-chip: #fbf7ef;
  --bg-combobox-list: #fffdf7;

  /* borders tinted to cream family */
  --border: #d9cdb6;
  --border-soft: #e8dfce;
  --border-dashed: rgba(139, 129, 116, 0.32);

  /* warm near-black ink, never #000 */
  --text: #2a2520;            /* ink-primary */
  --text-inverse: #fffdf7;
  --muted: #8b8174;           /* ink-tertiary */
  --muted-strong: #5c544a;    /* ink-secondary */

  /* keep BioSheng blue as accent (per the reference's "keep your brand hue" guidance) */
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --accent-soft: rgba(37, 99, 235, 0.08);
  --accent-border: rgba(37, 99, 235, 0.28);
  --accent-hover-bg: rgba(37, 99, 235, 0.06);

  /* warm hovers (cream-tinted, not cool grey) */
  --hover-muted: #f0e9da;
  --hover-muted-soft: #f5efe0;
  --hover-muted-strong: #efe8db;

  /* semantic — muted toward the warm palette */
  --danger-bg: #f2d9ce;
  --danger-border: rgba(164, 66, 44, 0.32);
  --danger-text: #a4422c;
  --danger-bg-hover: #eccdba;
  --danger-border-hover: rgba(164, 66, 44, 0.5);
  --danger-text-hover: #7a3120;

  --chip-success-bg: #e5ead4;
  --chip-success-border: rgba(92, 122, 61, 0.35);
  --chip-success-text: #5c7a3d;
  --chip-warn-bg: #f5e5c8;
  --chip-warn-border: rgba(168, 116, 44, 0.35);
  --chip-warn-text: #a8742c;

  /* backdrop + warm-tinted shadows (rgba(74, 55, 30, ...)) */
  --backdrop: rgba(74, 55, 30, 0.35);
  --shadow: 0 4px 8px rgba(74, 55, 30, 0.07), 0 12px 32px rgba(74, 55, 30, 0.08);
  --shadow-dropdown: 0 2px 4px rgba(74, 55, 30, 0.06), 0 4px 12px rgba(74, 55, 30, 0.06);

  /* charts — warm palette; pie border = surface to slot cleanly into card */
  --chart-1: #2563eb;
  --chart-2: #5c7a3d;
  --chart-3: #a8742c;
  --chart-border: #fbf7ef;
  --chart-grid: rgba(74, 55, 30, 0.08);

  /* chevron with ink-tertiary stroke (#8b8174) */
  --chevron-svg: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14' fill='none' stroke='%238b8174' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='3 5 7 9 11 5'/%3E%3C/svg%3E");
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg-app);
  min-height: 100vh;
}

button,
input,
select,
textarea {
  font: inherit;
}

.hidden,
.sr-only {
  display: none;
}

.app-shell {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  align-items: center;
  padding: 1.2rem 1.6rem;
  border-bottom: 1px solid var(--border-chrome);
  backdrop-filter: blur(18px);
  background: var(--bg-topbar);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 0;
}

.brand-logo-shell {
  width: 140px;
  height: 140px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
}

.brand-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand-block h1 {
  margin: 0;
  font-size: 2rem;
}

.brand-block p {
  margin: 0.25rem 0 0;
  color: var(--muted);
  max-width: 60ch;
  line-height: 1.35;
}

.topbar-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.55rem;
  min-width: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.topbar-user-row {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

/* Logged-in user badge — name + email, sits to the left of Sign out on the user row */
.user-badge {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.2;
  max-width: 240px;
}

.user-badge.hidden {
  display: none;
}

.user-badge .user-badge-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.user-badge .user-badge-email {
  font-size: var(--fs-micro);
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

@media (max-width: 720px) {
  .user-badge {
    border-left: none;
    padding-left: 0;
    max-width: 120px;
  }
  .user-badge .user-badge-email {
    display: none;
  }
}

.theme-toggle {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-chip);
  color: var(--text);
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.language-toggle,
.search-box {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--bg-chip);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.45rem 0.8rem;
}

.language-toggle select,
.search-box input {
  border: none;
  background: transparent;
  outline: none;
  min-width: 0;
  color: var(--text);
}

.search-box input::placeholder {
  color: var(--muted);
}

.search-box input {
  width: min(320px, 38vw);
}

.workspace {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  flex: 1;
  min-height: 0;
}

.sidebar {
  padding: 1.2rem;
  border-right: 1px solid var(--border-chrome);
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.sidebar-section,
.panel-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.sidebar-section {
  padding: 1rem;
}

.sidebar-label,
.panel-label,
.eyebrow {
  margin: 0 0 0.55rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-size: var(--fs-micro);
}

/* Collapse empty eyebrows so they don't leave a margin ghost above the title
   (e.g. on views where viewLabels.X.eyebrow = ""). */
.eyebrow:empty {
  display: none;
}

.filter-stack,
.detail-meta,
.metric-grid,
.summary-grid,
.attachment-list,
.timeline-list,
.contribution-list,
.dashboard-columns {
  display: grid;
  gap: 0.8rem;
}

.filter-stack label,
.form-field {
  display: grid;
  gap: 0.35rem;
}

.form-field span,
.dialog-header h3 {
  color: var(--text);
}

.inline-form-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.6rem;
  align-items: center;
}

.nav-button,
.primary-button,
.secondary-button,
.ghost-button,
.danger-button,
.inline-danger-button {
  border-radius: 14px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: 160ms ease;
}

.nav-button {
  width: 100%;
  text-align: left;
  padding: 0.85rem 0.95rem;
  background: transparent;
  color: var(--text);
  margin-bottom: 0.4rem;
}

.nav-button:hover,
.nav-button.active {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--text);
}

.note-card p:last-child {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.main-panel {
  padding: 1.4rem;
  overflow-y: auto;
  min-height: 0;
}

.sidebar {
  overflow-y: auto;
  min-height: 0;
}

#module-view:not(.hidden) .content-grid {
  align-items: start;
}

#module-view:not(.hidden) .content-grid > .panel-card {
  position: sticky;
  top: 0;
  max-height: calc(100vh - 200px);
  overflow-y: auto;
}

.main-header {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 1rem;
  margin-bottom: 1rem;
}

.main-header h2 {
  margin: 0 0 0.25rem;
  font-size: 1.9rem;
}

.main-header p:last-child {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
  max-width: 72ch;
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button {
  padding: 0.75rem 1rem;
}

.primary-button {
  background: var(--accent);
  color: var(--text-inverse);
}

.primary-button:hover {
  background: var(--accent-strong);
}

.secondary-button,
.ghost-button {
  background: var(--bg-chip);
  border-color: var(--border);
  color: var(--text);
}

.secondary-button:hover,
.ghost-button:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.danger-button,
.inline-danger-button {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--danger-text);
}

.danger-button:hover,
.inline-danger-button:hover {
  background: var(--danger-bg-hover);
  border-color: var(--danger-border-hover);
  color: var(--danger-text-hover);
}

.inline-danger-button {
  padding: 0.45rem 0.7rem;
  font-size: 0.82rem;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
  gap: 1rem;
}

.panel-card {
  padding: 1rem;
}

.panel-card-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 1rem;
  margin-bottom: 0.9rem;
}

.panel-card h3 {
  margin: 0;
  font-size: 1.1rem;
}

.header-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: nowrap;
}

#edit-project-button,
#delete-project-button {
  padding: 0.4rem 0.75rem;
  font-size: 0.82rem;
  border-radius: 10px;
  white-space: nowrap;
}

.count-pill,
.status-chip,
.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  font-size: 0.82rem;
  border: 1px solid var(--border);
  background: var(--bg-chip);
}

.status-chip[data-tone="success"] {
  background: var(--chip-success-bg);
  border-color: var(--chip-success-border);
  color: var(--chip-success-text);
}

.status-chip[data-tone="warn"] {
  background: var(--chip-warn-bg);
  border-color: var(--chip-warn-border);
  color: var(--chip-warn-text);
}

.status-chip[data-tone="neutral"] {
  background: var(--hover-muted);
  color: var(--muted-strong);
}

.table-container {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  padding: 0.8rem 0.65rem;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: top;
  text-align: left;
}

th {
  color: var(--muted);
  font-size: var(--fs-small);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover,
tbody tr.selected {
  background: var(--accent-hover-bg);
}

tbody tr.priority-group-header {
  cursor: default;
  background: transparent;
}

tbody tr.priority-group-header:hover {
  background: transparent;
}

tbody tr.priority-group-header td {
  padding: 0.85rem 0.85rem 0.4rem;
  font-size: var(--fs-small);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--surface-strong, rgba(255, 255, 255, 0.03));
}

tbody tr.priority-group-high td {
  color: #f87171;
}

tbody tr.priority-group-medium td {
  color: #fbbf24;
}

tbody tr.priority-group-low td {
  color: #93c5fd;
}

/* "Last update" column — slightly muted, italic for the dash placeholder */
td.cell-last-update {
  color: var(--text-muted);
  font-size: 0.9rem;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

td.cell-muted {
  color: var(--muted);
  font-style: italic;
  text-align: center;
}

.detail-stack {
  display: grid;
  gap: 1rem;
}

.detail-container,
.timeline-container {
  display: grid;
  gap: 1rem;
}

.summary-grid {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.summary-card,
.metric-card,
.timeline-entry,
.attachment-item,
.contribution-item,
.empty-state {
  border: 1px solid var(--border-soft);
  background: var(--panel-strong);
  border-radius: 16px;
  padding: 0.9rem;
}

.summary-card strong,
.metric-card strong {
  display: block;
  font-size: 1.4rem;
  margin-top: 0.2rem;
}

.dashboard-columns {
  grid-template-columns: 1.2fr 1fr;
}

.metric-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.timeline-entry-header,
.contribution-item-header,
.attachment-item-header {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  align-items: start;
  margin-bottom: 0.45rem;
}

.timeline-entry p,
.contribution-item p,
.attachment-item p,
.empty-state p {
  margin: 0;
  line-height: 1.45;
  color: var(--muted);
}

.detail-meta {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.detail-meta .meta-block {
  border-top: 1px solid var(--border-soft);
  padding-top: 0.75rem;
}

.meta-block strong {
  display: block;
  font-size: var(--fs-small);
  color: var(--muted);
  margin-bottom: 0.3rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tags-wrap {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.view-pane.hidden {
  display: none;
}

.app-dialog {
  width: min(860px, calc(100vw - 2rem));
  border: none;
  padding: 0;
  border-radius: 24px;
  background: transparent;
}

.app-dialog::backdrop {
  background: var(--backdrop);
  backdrop-filter: blur(4px);
}

.form-layout {
  background: var(--bg-dialog-form);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 1rem;
}

.dialog-header,
.dialog-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
  margin: 1rem 0;
}

.form-field input,
.form-field select,
.form-field textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-input);
  padding: 0.7rem 0.8rem;
  outline: none;
  color: var(--text);
}

.form-field input::placeholder,
.form-field textarea::placeholder {
  color: var(--muted);
}

.form-field textarea {
  min-height: 96px;
  resize: vertical;
}

.combobox {
  position: relative;
  width: 100%;
}

.form-field .combobox-input {
  cursor: pointer;
  padding-right: 2.2rem;
  background-image: var(--chevron-svg);
  background-repeat: no-repeat;
  background-position: right 0.9rem center;
  background-size: 14px;
}

.combobox-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 20;
  list-style: none;
  margin: 0;
  padding: 4px 0;
  background: var(--bg-combobox-list);
  border: 1px solid var(--border);
  border-radius: 14px;
  max-height: 240px;
  overflow-y: auto;
  box-shadow: var(--shadow-dropdown);
}

.combobox-list[hidden] {
  display: none;
}

.combobox-option {
  padding: 0.55rem 0.85rem;
  cursor: pointer;
  color: var(--text);
  font-size: 0.95rem;
}

.combobox-option:hover,
.combobox-option.active {
  background: var(--hover-muted-strong);
}

.combobox-empty {
  padding: 0.55rem 0.85rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-style: italic;
}

.form-field.full-width {
  grid-column: 1 / -1;
}

.icon-remove-button {
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-remove-button:hover {
  color: var(--text);
  background: var(--hover-muted);
}

.compact-colleague-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.compact-colleague-item {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.3rem 0.25rem 0.75rem;
  background: var(--hover-muted-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.9rem;
}

.compact-colleague-item .icon-remove-button {
  width: 18px;
  height: 18px;
  font-size: 1rem;
}

.compact-colleague-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-input);
  padding: 0.55rem 0.8rem;
  outline: none;
  color: var(--text);
  font-size: 0.9rem;
}

.compact-colleague-input::placeholder {
  color: var(--muted);
}

.empty-state-inline {
  color: var(--muted);
  font-size: 0.9rem;
}

/* Weekly Summary */

.week-navigator {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.week-navigator button {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  padding: 0.3rem 0.75rem;
  font-size: 0.9rem;
  cursor: pointer;
  line-height: 1;
}

.week-navigator button:hover {
  background: var(--hover-muted);
}

.weekly-summary-section {
  margin-top: 1.2rem;
}

.weekly-summary-section:first-of-type {
  margin-top: 0.5rem;
}

.weekly-summary-section h4 {
  margin: 0 0 0.75rem;
  font-size: var(--fs-small);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border);
}

.project-update-card {
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.9rem 1rem;
  margin-bottom: 0.8rem;
}

.project-update-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.6rem;
}

.project-update-card-header > div {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.project-update-id {
  font-size: var(--fs-small);
  color: var(--muted);
  letter-spacing: 0.02em;
}

.project-update-meta {
  font-size: 0.85rem;
  color: var(--muted-strong);
  margin-top: 0.15rem;
}

.project-update-card .last-update {
  margin: 0 0 0.7rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.contribution-row-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.contribution-row {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.35rem 0;
  border-top: 1px dashed var(--border-dashed);
}

.contribution-row:first-child {
  border-top: none;
  padding-top: 0;
}

.contribution-row-main {
  display: inline-flex;
  align-items: baseline;
  gap: 0.55rem;
  font-size: 0.95rem;
}

.contribution-row-hours {
  color: var(--muted);
  font-size: 0.85rem;
}

.contribution-row-summary {
  color: var(--muted-strong);
  font-size: 0.9rem;
}

/* To-dos */

.todo-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.todo-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.3rem 0;
  border-top: 1px dashed var(--border-dashed);
}

.todo-item:first-child {
  border-top: none;
}

.todo-checkbox {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  accent-color: var(--muted-strong);
  cursor: pointer;
}

.todo-text {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--text);
  font-size: 0.95rem;
}

.todo-item.done .todo-text {
  text-decoration: line-through;
  color: var(--muted);
}

.todo-input {
  margin-top: 0.35rem;
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.45rem 0.7rem;
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
}

.todo-input::placeholder {
  color: var(--muted);
}

/* Read-only form fields (e.g., Project ID in edit mode) */

input.readonly-locked,
input.readonly-locked:focus {
  background: var(--surface-muted, rgba(255, 255, 255, 0.03));
  color: var(--text-muted);
  cursor: not-allowed;
  border-color: var(--border);
}

.form-field-hint {
  display: block;
  margin-top: 0.25rem;
  font-size: var(--fs-small);
  color: var(--text-muted);
  font-style: italic;
}

/* Project history */

.history-add-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.history-add-form input[type="date"] {
  align-self: flex-start;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.45rem 0.7rem;
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
}

.history-add-form textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.4;
  resize: vertical;
  min-height: 75px;
  font-family: inherit;
  outline: none;
}

.history-add-form textarea::placeholder {
  color: var(--muted);
}

.history-add-form button {
  align-self: flex-end;
}

.history-empty {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0;
}

.history-list {
  list-style: none;
  margin: 0.6rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.history-entry {
  padding: 0.55rem 0.75rem;
  background: var(--surface-muted, rgba(255, 255, 255, 0.03));
  border: 1px solid var(--border);
  border-radius: 10px;
}

.history-entry-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.2rem;
}

.history-entry-date {
  font-size: var(--fs-small);
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.history-entry-delete {
  flex-shrink: 0;
}

.history-entry-text {
  margin: 0;
  font-size: 0.93rem;
  color: var(--text);
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Timeline view */

.timeline-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.timeline-filter {
  display: grid;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.timeline-filter select {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-input);
  padding: 0.45rem 0.7rem;
  color: var(--text);
  outline: none;
  font-size: 0.95rem;
}

.timeline-month-label {
  margin: 0 0 1.2rem;
  font-size: 1.4rem;
  font-weight: 500;
}

.timeline-projects {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.timeline-project-block {
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem 1.1rem;
}

.timeline-project-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.7rem;
}

.timeline-project-header > div {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.timeline-entry-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.timeline-entry-row {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  gap: 0.6rem;
  align-items: start;
  padding: 0.4rem 0;
  border-top: 1px dashed var(--border-dashed);
}

.timeline-entry-list > .timeline-entry-row:first-child {
  border-top: none;
  padding-top: 0;
}

.timeline-entry-icon {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.2;
  text-align: center;
}

.timeline-entry-text {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
  color: var(--text);
  font-size: 0.95rem;
}

.timeline-entry-text strong {
  font-weight: 600;
}

.timeline-entry-text p {
  margin: 0;
  color: var(--muted-strong);
  font-size: 0.9rem;
}

.timeline-contribution-bullets {
  list-style: none;
  margin: 0.2rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
  color: var(--muted-strong);
  font-size: 0.9rem;
}

.timeline-contribution-bullets li::before {
  content: "•";
  margin-right: 0.45rem;
  color: var(--muted);
}

.timeline-entry-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.timeline-entry-edit {
  padding: 0.3rem 0.6rem;
  font-size: var(--fs-small);
  border-radius: 10px;
}

.timeline-empty {
  padding: 1rem 0;
}

.timeline-mode-tabs {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-chip);
}

.timeline-mode-tabs button {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  font-size: 0.85rem;
  cursor: pointer;
  line-height: 1;
}

.timeline-mode-tabs button:hover {
  color: var(--text);
}

.timeline-mode-tabs button.active {
  background: var(--accent);
  color: var(--text-inverse);
}

/* Gantt */

.gantt-section {
  margin-bottom: 1rem;
  padding: 1rem 1.1rem 1.2rem;
}

.gantt-section .panel-card-header {
  margin-bottom: 0.6rem;
}

.gantt-grid {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.gantt-row {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  align-items: center;
  gap: 0.5rem;
}

.gantt-row-label {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  font-size: 0.85rem;
  padding: 0.4rem 0.6rem 0.4rem 0;
  cursor: pointer;
  border-radius: 8px;
}

.gantt-row-label:hover {
  background: var(--hover-muted);
}

.gantt-row-label .gantt-row-title {
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gantt-header-label {
  cursor: default;
}

.gantt-header-label:hover {
  background: transparent;
}

.gantt-row-track {
  position: relative;
  height: 30px;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
}

.gantt-header-track {
  height: auto;
  margin-bottom: 0.25rem;
}

.gantt-month-cell {
  border-left: 1px dashed var(--border-dashed);
  height: 100%;
  text-align: center;
  font-size: var(--fs-micro);
  color: var(--muted);
  padding: 0.25rem 0;
  letter-spacing: 0.04em;
}

.gantt-month-cell:first-child {
  border-left: none;
}

.gantt-row + .gantt-row .gantt-month-cell {
  /* keep cells visible behind bars */
}

.gantt-bar {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  height: 20px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 0 0.5rem;
  font-size: 0.75rem;
  color: var(--text-inverse);
  white-space: nowrap;
  overflow: hidden;
  transition: filter 0.15s ease, transform 0.15s ease;
}

.gantt-bar-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
}

.gantt-bar:hover {
  filter: brightness(1.1);
  transform: translateY(-50%) scale(1.01);
}

.gantt-bar[data-type="clinical"] { background-color: var(--chart-1); }
.gantt-bar[data-type="experimental"] { background-color: var(--chart-2); }
.gantt-bar[data-type="software"] { background-color: var(--chart-3); }

.gantt-bar[data-status="Planning"] { opacity: 0.55; }
.gantt-bar[data-status="Paused"] { opacity: 0.45; }
.gantt-bar[data-status="Completed"] { opacity: 0.7; }

.gantt-bar.gantt-bar-open-right {
  -webkit-mask-image: linear-gradient(to right, black 70%, transparent 100%);
  mask-image: linear-gradient(to right, black 70%, transparent 100%);
}

.gantt-bar.gantt-bar-open-left {
  -webkit-mask-image: linear-gradient(to left, black 70%, transparent 100%);
  mask-image: linear-gradient(to left, black 70%, transparent 100%);
}

.gantt-today-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--accent-strong);
  pointer-events: none;
  z-index: 2;
}

.gantt-header-track .gantt-today-line {
  bottom: -0.25rem;
}

.gantt-today-label {
  position: absolute;
  top: -1.1rem;
  left: -1.1rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-strong);
  background: var(--bg-chip);
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  white-space: nowrap;
}

/* Charts */

.chart-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-top: 1rem;
}

.chart-card {
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.9rem 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  min-width: 0;
}

.chart-canvas-wrap {
  position: relative;
  height: 280px;
  width: 100%;
}

.form-section-header {
  grid-column: 1 / -1;
  font-size: var(--fs-small);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding-top: 0.4rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border);
}

@media (max-width: 1100px) {
  .app-shell {
    height: auto;
    min-height: 100vh;
  }

  .workspace,
  .content-grid,
  .dashboard-columns {
    grid-template-columns: 1fr;
  }

  .workspace {
    flex: initial;
    min-height: auto;
  }

  .main-panel,
  .sidebar {
    overflow: visible;
    min-height: auto;
  }

  #module-view:not(.hidden) .content-grid > .panel-card {
    position: static;
    max-height: none;
    overflow: visible;
  }

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border-chrome);
  }
}

@media (max-width: 720px) {
  .topbar,
  .main-header,
  .panel-card-header,
  .dialog-header,
  .dialog-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .search-box input {
    width: 100%;
  }
}

/* Auth screen */

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: var(--bg-app);
}

.auth-screen.hidden {
  display: none;
}

.auth-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-elevated, 0 30px 60px rgba(0, 0, 0, 0.35));
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.auth-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  text-align: center;
}

.auth-logo {
  width: 80px;
  height: 80px;
  object-fit: contain;
}

.auth-header h2 {
  margin: 0;
  font-size: 1.2rem;
  color: var(--text);
}

.auth-subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.auth-tabs {
  display: flex;
  gap: 0.5rem;
  background: var(--surface-muted, rgba(255, 255, 255, 0.04));
  border-radius: 999px;
  padding: 0.25rem;
}

.auth-tab {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.55rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.auth-tab.active {
  background: var(--accent);
  color: var(--accent-contrast, #fff);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.auth-form.hidden {
  display: none;
}

.auth-form .form-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.auth-form .form-field span {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
}

.auth-form input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  background: var(--surface-muted, rgba(255, 255, 255, 0.03));
  border-radius: 12px;
  color: var(--text);
  font-size: 0.95rem;
}

.auth-form input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.auth-hint {
  color: var(--text-muted);
  font-size: var(--fs-small);
}

.auth-error {
  margin: 0;
  padding: 0.5rem 0.75rem;
  background: rgba(220, 38, 38, 0.12);
  border: 1px solid rgba(220, 38, 38, 0.4);
  border-radius: 10px;
  color: #f87171;
  font-size: 0.85rem;
}

.auth-error.hidden {
  display: none;
}

.auth-submit {
  margin-top: 0.25rem;
}

#logout-button {
  font-size: 0.85rem;
  padding: 0.4rem 0.75rem;
}

.app-shell.auth-pending {
  visibility: hidden;
}

/* Role-based visibility — members can't see admin-only controls. */

body.role-member .admin-only {
  display: none !important;
}

/* Archives panel (admin-only) */

.archives-panel {
  margin-top: 1.25rem;
}

.archives-help {
  margin: 0 0 1rem 0;
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.45;
}

.archives-loading,
.archives-error {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.archives-error {
  padding: 0.55rem 0.75rem;
  background: rgba(220, 38, 38, 0.1);
  border: 1px solid rgba(220, 38, 38, 0.3);
  border-radius: 10px;
  color: #f87171;
}

.archives-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.archives-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  background: var(--surface-muted, rgba(255, 255, 255, 0.04));
  border: 1px solid var(--border);
  border-radius: 12px;
}

.archives-row-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.archives-row-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.archives-row-detail {
  font-size: var(--fs-small);
  color: var(--text-muted);
}

.archives-download {
  flex-shrink: 0;
  text-decoration: none;
  font-size: 0.85rem;
}

#archives-generate:disabled,
#archives-restore:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.archives-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}
