/* ==========================================================================
   PMS - Components: buttons, inputs, cards, badges, modals, toasts, tables,
   dropdowns, kanban, gantt, calendar pieces.
   ========================================================================== */

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--bg-subtle);
  color: var(--text);
  font-weight: 600;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
  white-space: nowrap;
  user-select: none;
}

.btn:hover { background: var(--bg-hover); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

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

.btn-ghost { background: transparent; border-color: var(--border); }
.btn-ghost:hover { background: var(--bg-hover); }

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

.btn-soft-danger { background: var(--danger-soft); color: var(--danger); }
.btn-soft-danger:hover { filter: brightness(0.95); }

.btn-sm { padding: 4px 10px; font-size: 0.82rem; }
.btn-icon { padding: 6px; border-radius: var(--radius-sm); width: 30px; height: 30px; align-items: center; justify-content: center; }
.btn-block { width: 100%; justify-content: center; }

/* ---------- Inputs ---------- */
.field { display: flex; flex-direction: column; gap: 5px; margin-block-end: var(--space-3); }
.field > label { font-size: 0.82rem; font-weight: 600; color: var(--text-muted); }
.field .hint { font-size: 0.75rem; color: var(--text-faint); }

.input,
.select,
.textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.textarea { resize: vertical; min-height: 80px; }

.input.invalid, .select.invalid, .textarea.invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
}

.checkbox-row { display: flex; align-items: center; gap: 8px; }

/* A date range box in the filter bar. The label sits above the input rather than
   beside it so four ranges can sit in one row without the labels truncating, and
   the pair reads as one field instead of two unrelated boxes. */
.date-filter {
  display: flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1.2;
}
.date-filter-label {
  font-size: 0.68rem;
  color: var(--text-faint);
  white-space: nowrap;
}
.date-filter .input { padding: 4px 6px; font-size: 0.78rem; }

/* ---------- Cards ---------- */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.card-header {
  padding: var(--space-4);
  border-block-end: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.card-body { padding: var(--space-4); }
.card-title { font-weight: 700; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}
.badge .badge-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; opacity: 0.8; }
/* Blocked is a status, not a footnote: it is drawn like the other status pills
    (dot + label) and carries the weight of the row, so the status a task is
    really in is the first thing read. */
.badge-blocked {
  color: var(--warning);
  background: var(--warning-soft);
  border: 1px solid var(--warning);
  font-size: 0.74rem;
  font-weight: 700;
  padding: 2px 8px;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- KPI ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-4);
}

.kpi-card { padding: var(--space-4); }
.kpi-card .kpi-value { font-size: 1.9rem; font-weight: 800; margin-block-start: 4px; }
.kpi-card .kpi-label { font-size: 0.82rem; color: var(--text-muted); font-weight: 600; }
.kpi-card .kpi-sub { font-size: 0.78rem; color: var(--text-faint); margin-block-start: 4px; }
.kpi-value.danger { color: var(--danger); }
.kpi-value.ok { color: var(--success); }

/* ---------- Progress bar ---------- */
.progress-track {
  height: 10px;
  border-radius: 999px;
  background: var(--bg-subtle);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--brand-grad);
  transition: width 0.3s ease;
}
.progress-label { font-size: 0.75rem; color: var(--text-muted); font-weight: 600; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: var(--z-modal);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 6vh var(--space-4);
  overflow-y: auto;
  animation: fadeIn 0.12s ease;
}

.modal {
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 640px;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.16s ease;
  display: flex;
  flex-direction: column;
  max-height: 88vh;
}

.modal.modal-lg { max-width: 860px; }
.modal.modal-sm { max-width: 420px; }

.modal-header {
  padding: var(--space-4) var(--space-5);
  border-block-end: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.modal-title { font-weight: 700; font-size: 1.05rem; }

.modal-close {
  margin-inline-start: auto;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}
.modal-close:hover { background: var(--bg-hover); color: var(--text); }

.modal-body { padding: var(--space-5); overflow-y: auto; }
/* explains an action that is deliberately not offered (see modal.js `note`) */
.modal-note {
  padding: var(--space-2) var(--space-5);
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--bg-subtle);
  border-block-start: 1px solid var(--border);
}
.modal-footer {
  padding: var(--space-3) var(--space-5);
  border-block-start: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  flex-wrap: wrap;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ---------- Toast ---------- */
#toast-root {
  position: fixed;
  inset-inline-end: var(--space-4);
  inset-block-end: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  z-index: var(--z-toast);
  max-width: 360px;
}

.toast {
  background: var(--bg-elevated);
  color: var(--text);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  display: flex;
  gap: 10px;
  align-items: flex-start;
  animation: slideIn 0.16s ease;
}

.toast-success { border-inline-start: 4px solid var(--success); }
.toast-error { border-inline-start: 4px solid var(--danger); }
.toast-info { border-inline-start: 4px solid var(--info); }
.toast-warning { border-inline-start: 4px solid var(--warning); }

@keyframes slideIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Tables ---------- */
.tbl-wrap { overflow: auto; border-radius: var(--radius-md); }
table.tbl {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-elevated);
}
.tbl thead th {
  position: sticky;
  top: 0;
  background: var(--bg-subtle);
  text-align: start;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  padding: 10px 12px;
  border-block-end: 1px solid var(--border);
  white-space: nowrap;
  z-index: 2;
}
.tbl th.sortable { cursor: pointer; }
.tbl th.sortable:hover { color: var(--text); }
.tbl th .sort-arrow { opacity: 0.4; }
.tbl th.sort-asc .sort-arrow, .tbl th.sort-desc .sort-arrow { opacity: 1; }

.tbl tbody td {
  padding: 8px 12px;
  border-block-end: 1px solid var(--border);
  vertical-align: middle;
}
.tbl tbody tr:hover { background: var(--bg-hover); }
.tbl tbody tr.selected { background: var(--primary-soft); }

.tbl .col-check { width: 36px; }

/* Grouping row */
.tbl .group-row td {
  background: var(--bg-subtle);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ---------- Dropdown ---------- */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  position: absolute;
  inset-block-start: calc(100% + 6px);
  inset-inline-start: 0;
  min-width: 180px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 6px;
  z-index: var(--z-dropdown);
  display: none;
}

.dropdown-menu.open { display: block; animation: fadeIn 0.1s ease; }
.dropdown-menu.align-end { inset-inline-start: auto; inset-inline-end: 0; }

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: start;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text);
}
.dropdown-item:hover { background: var(--bg-hover); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-header {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  padding: 6px 12px 2px;
}

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  gap: 2px;
  border-block-end: 1px solid var(--border);
  overflow-x: auto;
}
.tab {
  padding: 10px 16px;
  font-weight: 600;
  color: var(--text-muted);
  border-block-end: 2px solid transparent;
  white-space: nowrap;
  cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-block-end-color: var(--primary); }

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-block-end: var(--space-4);
}
.toolbar .grow { flex: 1; }

/* ---------- Forms / grid ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--space-4); }
.form-grid .field-full { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

/* ---------- Chips (tags) ---------- */
.chip {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-muted);
}
.chip.removable { display: inline-flex; align-items: center; gap: 5px; }
.chip .chip-x { cursor: pointer; color: var(--text-faint); }
.chip .chip-x:hover { color: var(--danger); }
.chip-meeting { cursor: pointer; border-color: var(--primary); color: var(--primary); }
.chip-meeting:hover { background: var(--primary-soft); }

/* ---------- Create-a-person popup (inline, inside any editor) ---------- */
.control-with-create { display: flex; flex-direction: column; gap: var(--space-1); }
.person-create { position: relative; }
.person-create > .btn { align-self: flex-start; }
.person-create-panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-block-start: var(--space-2);
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-inline-start: 3px solid var(--primary);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-sm);
  max-width: 320px;
}
.person-create-title { font-weight: 700; font-size: 0.85rem; }
.person-create-error { font-size: 0.75rem; }

/* ---------- Task-to-task link picker ---------- */
.link-picker { display: flex; flex-direction: column; gap: var(--space-2); }
.link-picker .input-sm { font-size: 0.85rem; padding: 6px 10px; }
.link-results { display: flex; flex-direction: column; gap: 2px; max-height: 168px; overflow: auto; }
.link-result {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.85rem;
}
.link-result:hover { background: var(--primary-soft); }

/* ---------- Avatar ---------- */
.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.72rem;
  color: #fff;
  flex: 0 0 28px;
  user-select: none;
}
.avatar-lg { width: 44px; height: 44px; font-size: 1rem; flex: 0 0 44px; }

/* ---------- Empty state ---------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-6);
  text-align: center;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 2.6rem; opacity: 0.5; }

/* ---------- Kanban ---------- */
.kanban-board {
  display: flex;
  gap: var(--space-4);
  overflow-x: auto;
  align-items: flex-start;
  padding-block-end: var(--space-4);
}
.kanban-col {
  flex: 0 0 300px;
  background: var(--bg-subtle);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 220px);
  min-height: 120px;
}
.kanban-col.drag-over { outline: 2px dashed var(--primary); }
.kanban-col-header {
  padding: 10px 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  border-block-end: 1px solid var(--border);
}
.kanban-col-header .count {
  background: var(--bg-elevated);
  border-radius: 999px;
  font-size: 0.72rem;
  padding: 1px 8px;
  color: var(--text-muted);
}
.kanban-body {
  padding: var(--space-2);
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.kanban-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  box-shadow: var(--shadow-sm);
  cursor: grab;
  transition: box-shadow var(--transition);
  user-select: none;
}
.kanban-card:hover { box-shadow: var(--shadow-md); }
.kanban-card.dragging { opacity: 0.45; }
.kanban-card .kc-title { font-weight: 600; margin-block-end: 6px; }
.kanban-card .kc-meta { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-block-start: 8px; }

/* ---------- Gantt ---------- */
/* The chart lays itself out left to right even in an RTL page: a timeline whose
   scale runs the other way reads backwards, and physical `left` offsets (which
   every bar and arrow is placed with) would stop lining up. The text inside the
   cells keeps its own base direction, so an Arabic title still shapes correctly. */
.gantt-root { overflow: auto; direction: ltr; }
.gantt-wrap { position: relative; min-width: 100%; }
.gantt-header { position: sticky; top: 0; }
.gantt-body { position: relative; }
.gantt-row {
  display: flex;
  align-items: center;
  border-block-end: 1px solid var(--border);
}
/* One width for the header and every row, so the timeline can never start at a
   different x per row. The value is pushed in from JS, next to the geometry that
   depends on it. */
.gantt-root { --gantt-label-w: 260px; }
.gantt-label-col {
  flex: 0 0 var(--gantt-label-w, 260px);
  flex-shrink: 0;
  /* Column, not row: the title sits above the date range. As a row the two sat
     side by side, and because a nowrap flex item refuses to shrink below its own
     text width, a long title pushed the dates out and spilled past the divider
     into the timeline - which is what made the column look ragged row to row. */
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 1px;
  overflow: hidden;
  padding-inline-end: var(--space-3);
}
/* Title and its markers share one line: the title gives up the space it needs,
   the markers never wrap, and the cell stays exactly two lines tall. */
.gantt-label-head {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
/* min-width:0 lets the ellipsis actually engage inside the fixed-width cell. */
.gantt-label-col > * { min-width: 0; max-width: 100%; }
.gantt-label-head > * { min-width: 0; }
.gantt-label-title {
  display: block;
  flex: 1 1 auto;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-weight: 600;
  unicode-bidi: plaintext;
}
.gantt-label-head > .badge, .gantt-label-head > .dep-marker { flex: 0 0 auto; }
.gantt-label-dates {
  display: block;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 0.7rem; line-height: 1.2;
}
.gantt-time-col { position: relative; flex: 1; height: 100%; }
.gantt-bar {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  height: 22px;
  border-radius: 6px;
  cursor: grab;
  display: flex;
  align-items: center;
  padding-inline: 8px;
  font-size: 0.7rem;
  color: #fff;
  overflow: hidden;
  /* Long titles fade out with an ellipsis instead of being sliced mid-letter. */
  white-space: nowrap;
  text-overflow: ellipsis;
  user-select: none;
}
.gantt-bar > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gantt-row-sub .gantt-label-col { color: var(--text-muted); }
.gantt-bar-sub { opacity: 0.55; }
.gantt-bar.resizing { cursor: ew-resize; }
.gantt-gridline { position: absolute; top: 0; bottom: 0; background: var(--border); width: 1px; opacity: 0.6; }
  .gantt-monthline { opacity: 1; background: var(--text-faint); }
  .gantt-month-label { pointer-events: none; border-inline-end: 1px solid var(--border); background: var(--bg-subtle); }
  .gantt-day-label { position: absolute; font-size: 0.6rem; color: var(--text-faint); text-align: center; min-width: 24px; pointer-events: none; }
  .gantt-today { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--danger); z-index: 3; }
/* Sits over the time column, so its left edge is set in JS next to the geometry
   that places the bars. No inset here: stretching the box across the whole chart
   desynced it from the bars it is supposed to point at. */
.gantt-links { position: absolute; top: 0; left: 0; pointer-events: none; z-index: 2; }
/* No marker-end here: every dependency path now sets its own per-type arrow as
   an attribute, and a CSS marker-end would override all of them with one
   default arrowhead. */
.gantt-links path { stroke: var(--text-faint); stroke-width: 1.5; fill: none; }

/* ---------- Calendar ---------- */
.calendar-toolbar { display: flex; gap: var(--space-2); align-items: center; margin-block-end: var(--space-3); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); border-radius: var(--radius-md); overflow: hidden; background: var(--bg-elevated); border: 1px solid var(--border); }
.cal-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); background: var(--bg-subtle); font-size: 0.75rem; font-weight: 700; color: var(--text-muted); }
.cal-weekdays div { padding: 8px 10px; text-align: center; border-block-end: 1px solid var(--border); }
.cal-day {
  min-height: 110px;
  padding: 6px;
  border-block-end: 1px solid var(--border);
  border-inline-end: 1px solid var(--border);
  position: relative;
}
.cal-day.today { background: var(--primary-soft); }
.cal-day.outside { background: var(--bg-subtle); color: var(--text-faint); }
.cal-day-num { font-size: 0.78rem; font-weight: 700; margin-block-end: 4px; }
.cal-task {
  display: block;
  font-size: 0.72rem;
  padding: 2px 6px;
  border-radius: 4px;
  margin-block-end: 2px;
  color: #fff;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Tree ---------- */
.tree { list-style: none; }
.tree ul { list-style: none; padding-inline-start: 22px; }
.tree-node { display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: var(--radius-sm); }
.tree-node:hover { background: var(--bg-hover); }
.tree-node.selected { background: var(--primary-soft); }
.tree-toggle {
  width: 20px;
  text-align: center;
  cursor: pointer;
  color: var(--text-faint);
  flex: 0 0 20px;
  transition: transform 0.12s ease;
}
.tree-node.collapsed > .tree-toggle { transform: rotate(-90deg); }
.tree-node.collapsed + ul { display: none; }

/* ---------- Pages / headers ---------- */
.page-header { display: flex; align-items: center; gap: var(--space-3); margin-block-end: var(--space-5); flex-wrap: wrap; }
.page-header h1 { font-size: 1.4rem; }
.page-header .actions { margin-inline-start: auto; display: flex; gap: var(--space-2); }

.section-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  font-weight: 700;
  margin-block: var(--space-4) var(--space-2);
}

/* ---------- Detail lists ---------- */
.detail-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--space-2) var(--space-4); }
.detail-item .dl-label { font-size: 0.72rem; color: var(--text-faint); text-transform: uppercase; }
.detail-item .dl-value { font-weight: 600; }

/* ---------- Segmented control ---------- */
.segmented { display: inline-flex; background: var(--bg-subtle); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 3px; gap: 2px; }
.segmented button { padding: 5px 14px; border-radius: var(--radius-sm); font-size: 0.85rem; font-weight: 600; color: var(--text-muted); }
.segmented button.active { background: var(--bg-elevated); color: var(--primary); box-shadow: var(--shadow-sm); }

/* ---------- Misc layout blocks ---------- */
.stack { display: flex; flex-direction: column; gap: var(--space-3); }
.row-gap { display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
/* The people grid is capped at 3 per row (it used auto-fit, so a wide window
   fitted 4+ people per row). minmax(0, 1fr) stops a long name from forcing the
   column wider. It narrows to 2 then 1 on smaller windows. */
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-4); }
@media (max-width: 1100px) { .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .grid-3 { grid-template-columns: 1fr; } }
@media (max-width: 720px) { .grid-2 { grid-template-columns: 1fr; } }

/* Tag input */
.tag-input { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-elevated); }
.tag-input input { border: none; outline: none; flex: 1; min-width: 100px; background: transparent; }

/* checklist */
.checklist-item { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.checklist-item.done label { text-decoration: line-through; color: var(--text-faint); }

/* activity log */
.activity-item { display: flex; gap: 10px; padding: 6px 0; font-size: 0.85rem; }
.activity-item .when { color: var(--text-faint); font-size: 0.72rem; }

/* comments */
.comment-item { display: flex; gap: 10px; padding: 8px 0; }

/* settings sidebar layout */
.settings-layout { display: flex; gap: var(--space-5); align-items: flex-start; }
.settings-nav { flex: 0 0 220px; display: flex; flex-direction: column; gap: 2px; }
.settings-body { flex: 1; min-width: 0; }
@media (max-width: 720px) { .settings-layout { flex-direction: column; } .settings-nav { flex-direction: row; flex-wrap: wrap; } }

/* ---------- Loading / network box ----------
   Shown while a cloud sync is in flight and the connection is slow or the
   device is offline, so the UI never looks frozen on a bad network. */
@keyframes spin { to { transform: rotate(360deg); } }

#loading-box {
  position: fixed;
  inset-inline-start: var(--space-4);
  inset-block-end: var(--space-4);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  max-width: min(340px, calc(100vw - var(--space-6)));
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
  border-inline-start: 4px solid var(--info);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  z-index: var(--z-loading);
  font-size: 0.85rem;
  animation: slideIn 0.16s ease;
}
#loading-box.is-hidden { display: none; }

#loading-box .spinner {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  border: 2px solid var(--border);
  border-block-start-color: var(--info);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
#loading-box .status-dot { display: none; }

#loading-box.is-slow { border-inline-start-color: var(--warning); }
#loading-box.is-slow .spinner { border-block-start-color: var(--warning); animation-duration: 1.15s; }

#loading-box.is-offline .spinner { display: none; }
#loading-box.is-offline .status-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--warning);
}
/* ---------- Self-diagnosis (an app that cannot show itself must say so) ---------- */
.blank-report {
  position: fixed;
  inset: 0;
  z-index: 4000;
  background: var(--bg);
  color: var(--text);
  overflow: auto;
  text-align: start;
}
.blank-report ul { margin: 0; padding-inline-start: var(--space-5); }
#error-note {
  display: none;
  position: fixed;
  inset-block-end: 0;
  inset-inline: 0;
  z-index: 4100;
  max-height: 6.5rem;
  overflow: auto;
  padding: var(--space-2) var(--space-3);
  background: var(--danger);
  color: #fff;
  font-size: .72rem;
  font-family: var(--font-sans);

  direction: ltr;
  text-align: start;
}
#error-note.is-on { display: block; }

/* ---------- brand logo (one file per theme) ----------
   Both images are in the DOM; the theme decides which one is shown, so no
   reload is needed when the user switches between light and dark. */
[data-theme="dark"] .brand-logo-img img:nth-child(1),
[data-theme="dark"] .auth-logo img:nth-child(1) { display: none !important; }
[data-theme="dark"] .brand-logo-img img:nth-child(2),
[data-theme="dark"] .auth-logo img:nth-child(2) { display: block !important; }

/* ---------- Attachments (file links: Drive + plain links) ---------- */
.attach-rows { display: flex; flex-direction: column; gap: 8px; }
.attach-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
}
.attach-row-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr);
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
}
.attach-row-side { display: flex; gap: 6px; align-items: center; flex: 0 0 auto; }
.attach-row-side .select { min-width: 118px; }
@media (max-width: 640px) {
  .attach-row { flex-direction: column; }
  .attach-row-main { grid-template-columns: 1fr; width: 100%; }
  .attach-row-side { width: 100%; }
  .attach-row-side .select { flex: 1 1 auto; }
}
.attach-list { gap: 6px; }
.attach-row-view {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.attach-row-view:hover { background: var(--bg-subtle); }
.attach-icon { font-size: 1.1rem; flex: 0 0 auto; }
.attach-main { flex: 1 1 auto; min-width: 0; }
.attach-name { font-weight: 600; color: var(--primary); text-decoration: none; }
.attach-name:hover { text-decoration: underline; }
.meeting-attach-chip { font-size: .75rem; }

/* Creator line: leads the meeting card, above the date and title */
.meeting-byline {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-block-end: 8px;
  padding-block-end: 8px;
  border-block-end: 1px dashed var(--border);
  font-size: .84rem;
}
.meeting-by-avatar {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
  font-size: .78rem;
}
.meeting-by-label { color: var(--text-muted); margin-inline-end: 5px; }

/* Creator chip: a small avatar + name, shown next to a task (table cell and
   kanban card) so "who made this" is readable at a glance. */
.chip-creator {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  font-size: .75rem;
}
.chip-creator .cc-avatar {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
  font-size: .7rem;
}
.chip-creator .cc-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.kc-meta-by { margin-block-end: 4px; }

/* a quiet note explaining a narrowed view (e.g. a member's own scope) */
.scope-note {
  margin-block: var(--space-2) var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-inline-start: 3px solid var(--info);
  border-radius: var(--radius-sm);
  background: var(--info-soft);
  color: var(--text-muted);
  font-size: .84rem;
}

/* ==========================================================================
   The task network: typed links, waiting, and the critical path.

   One set of marks, shared by the table, kanban, gantt and calendar, so a
   task looks the same wherever it is read. Colour alone never carries the
   meaning: every mark has a glyph and a word in it, because the critical path
   has to survive a greyscale printout and a red-green colour blind reader.
   ========================================================================== */

.dep-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  font-size: .7rem;
  line-height: 1.6;
  white-space: nowrap;
}

.dep-chip .dep-glyph { font-weight: 700; }
.dep-chip .dep-type { color: var(--text-muted); }
.dep-chip .dep-lag { font-variant-numeric: tabular-nums; color: var(--text-faint); }

/* Each type gets its own hue so a row of links can be read at a glance, and its
   own glyph so the hue is never the only clue. */
.dep-type-FS { border-color: var(--primary); }
.dep-type-FS .dep-glyph { color: var(--primary); }
.dep-type-SS { border-color: var(--info); }
.dep-type-SS .dep-glyph { color: var(--info); }
.dep-type-FF { border-color: var(--warning); }
.dep-type-FF .dep-glyph { color: var(--warning); }
.dep-type-SF { border-color: var(--purple); }
.dep-type-SF .dep-glyph { color: var(--purple); }

/* a link whose predecessor is finished is settled; one whose dates break it is
   not yet true */
.dep-chip.dep-done { opacity: .62; }
.dep-chip.dep-done .dep-glyph { text-decoration: line-through; }
.dep-chip.dep-broken {
  border-color: var(--danger);
  background: var(--danger-soft);
}
.dep-chip.dep-broken .dep-glyph { color: var(--danger); }

.dep-summary { display: inline-flex; gap: 4px; align-items: center; flex-wrap: wrap; }

.dep-marker {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: .68rem;
  line-height: 1.6;
  white-space: nowrap;
  border: 1px solid transparent;
}

.dep-marker-critical {
  color: var(--danger);
  border-color: var(--danger);
  background: var(--danger-soft);
  font-weight: 600;
}
.dep-marker-blocked {
  color: var(--warning);
  border-color: var(--warning);
  background: var(--warning-soft);
}
.dep-marker-slack {
  color: var(--text-faint);
  border-color: var(--border);
  font-variant-numeric: tabular-nums;
}

/* The dependency picker in the task editor: one row per link, wrapping on its
   own so a long list never grows a dialog past the screen. */
.dep-rows { display: flex; flex-direction: column; gap: 12px; margin-block-end: 10px; }
.dep-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1.5fr) auto;
  gap: 8px; align-items: end; padding: 12px; border: 1px solid var(--border); border-radius: 8px; }
.dep-control { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.dep-label { font-size: 12px; font-weight: 600; }
.dep-row .select, .dep-row .input { width: 100%; min-width: 0; }
.dep-explanation { grid-column: 1 / -1; }
.dep-task-name { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
button.dep-chip { cursor: pointer; font: inherit; }
@media (max-width: 640px) {
  .dep-row { grid-template-columns: minmax(0, 1fr) 84px auto; }
  .dep-task-control, .dep-type-control { grid-column: 1 / -1; }
}

/* Critical is marked twice on purpose: a tint to catch the eye while scanning
   and a hard edge so the row still reads when the tint is lost in a print or a
   screenshot. */
.vt-row.is-critical {
  background: var(--danger-soft);
  /* The edge is marked with an inset shadow, which cannot be a logical
     property, so the RTL side is corrected in rtl.css rather than being left
     pointing the wrong way in Arabic. */
  box-shadow: inset 3px 0 0 var(--danger);
}
.vt-row.is-critical .vt-td:first-child { font-weight: 600; }

.kanban-card.is-critical {
  border-color: var(--danger);
  box-shadow: inset 0 0 0 1px var(--danger);
}
.kanban-card.is-blocked { border-inline-start: 4px solid var(--warning); }

/* A day cell has no room to print the network, so the marks sit in the corner
   of the pill. The critical diamond is drawn, not coloured, because the pill's
   own background is already the status colour. */
.cal-task.is-critical {
  box-shadow: 0 0 0 2px var(--danger);
}
.cal-task-marks {
  margin-inline-start: auto;
  padding-inline-start: 4px;
  font-size: .6rem;
  line-height: 1;
  white-space: nowrap;
}
.cal-mark-critical { color: var(--danger); }
.cal-mark-blocked { color: var(--warning); }

/* Gantt: a critical bar keeps its own status colour - the band still has to be
   readable - and is ringed instead. */
.gantt-bar.is-critical {
  box-shadow: 0 0 0 2px var(--danger);
}
.gantt-bar.is-blocked::after {
  content: "\1F512";
  position: absolute;
  inset-inline-end: -7px;
  top: -6px;
  font-size: .7rem;
}
.gantt-label-col.is-critical .gantt-label-title { color: var(--danger); font-weight: 600; }

/* Link arrows, one weight per type so the gantt reads without its legend. */
.gantt-links path.dep-FS { stroke: var(--primary); stroke-width: 2; }
.gantt-links path.dep-SS { stroke: var(--info); stroke-width: 2; stroke-dasharray: 5 3; }
.gantt-links path.dep-FF { stroke: var(--warning); stroke-width: 2; stroke-dasharray: 8 3; }
.gantt-links path.dep-SF { stroke: var(--purple); stroke-width: 2; stroke-dasharray: 2 3; }
.gantt-links path.dep-broken { stroke: var(--danger); }
.gantt-links path.dep-critical { stroke-width: 3; }

.gantt-legend {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
  font-size: .72rem;
  color: var(--text-muted);
}

.sync-conflict-card { padding: 12px; margin-block-end: 10px; }
.sync-conflict-value { white-space: pre-wrap; overflow-wrap: anywhere; }

/* Keep task names visible while the dated timeline scrolls independently. */
.gantt-root { max-height: 65vh; }
.gantt-header { z-index: 7; }
.gantt-label-col { position: sticky; left: 0; z-index: 4; background: var(--bg-elevated); }
.gantt-header .gantt-label-col { z-index: 8; background: var(--bg-subtle); }
.gantt-row:hover .gantt-label-col, .gantt-row:hover .gantt-time-col { background-color: var(--bg-subtle); }
button.gantt-label-title { border: 0; background: transparent; color: inherit; font: inherit; text-align: start; cursor: pointer; padding: 0; }
.gantt-label-title:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.gantt-unscheduled { display: block; padding: 10px 12px; font-size: .8rem; }
.gantt-summary { margin-block: 8px; font-size: .85rem; }
.gantt-filters { padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--bg-elevated); }
[dir="rtl"] .gantt-label-col { direction: rtl; }
@media (max-width: 640px) {
  .gantt-root { max-height: 60vh; }
  .gantt-filters .input, .gantt-filters select { max-width: 100%; }
}

.gantt-filters > .filter-multi { width: auto; flex: 1 1 150px; min-width: 130px; }
.gantt-filters > .input { flex: 1 1 180px; }
@media (max-width: 640px) {
  .gantt-filters > .filter-multi { flex-basis: 130px; min-width: 0; }
}
.gantt-label-head > .gantt-label-title { flex: 1 1 auto; min-width: 80px; }
.gantt-label-head > .dep-marker { max-width: 72px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
