:root {
  --brand-navy: #081E3E;
  --brand-navy-2: #13325F;
  --brand-green: #7FBD41;
  --brand-green-dark: #5A9429;
  --flow: #8944AB;          /* TalosFlow product purple (talos-brand/talos-tokens.css) */
  --flow-rgb: 137, 68, 171;
  --bg: #f3f5f8;
  --panel: #ffffff;
  --border: #e1e6ee;
  --half-hour-line: #c9d1dc; /* dashed, so it still reads softer than --border */
  --text: #0f1d33;
  --text-dim: #5d6a7e;
  --heading: var(--brand-navy);
  --accent: var(--brand-navy-2);
  --accent-hover: var(--brand-navy);
  --today: var(--brand-green-dark);
  --weekend: #eef1f6;
  --bc: #24508f;
  --crm: #f59e0b;
  --manual: #6b7280;
  --unassigned-bg: #fffbea;
  --row-h: 46px;
  --label-w: 210px;
  --shadow-sm: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.05);
  --shadow-md: 0 8px 24px rgba(16,24,40,.12), 0 2px 6px rgba(16,24,40,.06);
  --tasks-panel-w: 360px; /* user-resizable, see wirePanelResizers */
  --planned-h: 280px;     /* user-resizable, see wirePanelResizers */
  --setup-panel-w: 360px; /* user-resizable, see wirePanelResizers */
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 14px;
}
button, input, select, textarea { font-family: inherit; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible {
  outline: 2px solid var(--flow); outline-offset: 1px;
}

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

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: var(--panel);
  border-bottom: 3px solid var(--brand-green);
  flex-wrap: wrap;
}
.topbar h1 { font-size: 16px; margin: 0 12px 0 0; font-weight: 700; white-space: nowrap; }
.topbar h1.brand { display: flex; align-items: center; gap: 12px; color: var(--heading); letter-spacing: -.01em; }
.topbar h1.brand img { height: 38px; width: auto; display: block; }
.topbar h1.brand span { font-size: 17px; font-weight: 600; padding-left: 12px; border-left: 2px solid var(--brand-green); line-height: 1.2; }
.topbar .spacer { flex: 1; }
.topbar button, .topbar select {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
}
.topbar button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.topbar button { transition: filter .1s ease, box-shadow .1s ease, transform .05s ease; }
.topbar button:hover { filter: brightness(0.97); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.topbar button:active { transform: translateY(1px); }
.topbar button.primary:hover { filter: none; background: var(--accent-hover); border-color: var(--accent-hover); }
.topbar { box-shadow: var(--shadow-sm); }
.status-pill {
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--unassigned-bg);
  color: #92600a;
  border: 1px solid #f1d9a0;
}
.status-pill.ok { background: #eef7e5; color: #3f6f1a; border-color: #cfe6b5; }
.status-pill.err { background: #fdecec; color: #b32424; border-color: #f3bcbc; }

/* ---------- Legend ---------- */
.sch-legend { display: flex; gap: 14px; align-items: center; font-size: 12px; color: var(--text-dim); }
.dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 5px; vertical-align: -1px; flex-shrink: 0; }

/* ---------- Board ---------- */
.board-scroll { flex: 1; overflow: auto; position: relative; }
/* No forced min-width: 100% here — once non-working days/hours are hidden
   (see visibleColumns in app.js), the board is often genuinely narrower
   than the scroll area, and stretching it anyway just left a blank
   header-colored box hanging off the end of it. Sizing purely to content
   means a narrow view just leaves plain background to its right, same as
   any other calendar app's week view. */
.board { width: max-content; }

.timeline-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.timeline-header .label-col {
  width: var(--label-w);
  flex-shrink: 0;
  position: sticky;
  left: 0;
  background: var(--panel);
  z-index: 6;
  border-right: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 10px;
  font-weight: 600;
  color: var(--text-dim);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.day-col {
  width: 92px; /* fallback only — renderBoard sets the fitted width inline (see fitUnitWidth) */
  flex-shrink: 0;
  text-align: center;
  padding: 8px 0 6px;
  border-right: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 12px;
}
.day-col.weekend { background: var(--weekend); }
.day-col.hour-col { font-size: 11px; padding: 8px 0 6px; }
.day-col .dow { font-weight: 600; color: var(--text); }
.day-col.is-today { color: var(--today); font-weight: 700; }

.sch-row {
  display: flex;
  border-bottom: 1px solid var(--border);
  min-height: var(--row-h);
}
.sch-row .label-col {
  width: var(--label-w);
  flex-shrink: 0;
  position: sticky;
  left: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px 0 10px;
  z-index: 3;
  font-weight: 500;
}

.resource-name-wrap { display: flex; align-items: center; overflow: hidden; min-width: 0; }
.resource-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 7px; flex-shrink: 0; }
.resource-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-actions { display: flex; gap: 4px; opacity: 0; transition: opacity .1s; }
.sch-row:hover .row-actions { opacity: 1; }
.icon-btn {
  border: none; background: transparent; cursor: pointer; color: var(--text-dim);
  font-size: 13px; padding: 2px 5px; border-radius: 5px;
  transition: background-color .15s ease, color .15s ease;
}
.icon-btn:hover { background: var(--weekend); color: var(--text); }

.sch-timeline {
  position: relative;
  flex: 1;
  background-image: repeating-linear-gradient(
    to right, transparent 0, transparent 91px, var(--border) 91px, var(--border) 92px
  );
}
.sch-timeline.drop-hover { background-color: rgba(var(--flow-rgb), .07); }
/* Hour view: a faded, dashed line at each :30, halfway between the solid
   hour lines. The mask chops the solid gradient line into dashes. */
.sch-timeline.half-hour-grid::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: repeating-linear-gradient(to right,
    transparent 0, transparent calc(var(--unit-w) / 2 - 1px),
    var(--half-hour-line) calc(var(--unit-w) / 2 - 1px), var(--half-hour-line) calc(var(--unit-w) / 2),
    transparent calc(var(--unit-w) / 2), transparent var(--unit-w));
  -webkit-mask-image: repeating-linear-gradient(to bottom, #000 0, #000 4px, transparent 4px, transparent 8px);
  mask-image: repeating-linear-gradient(to bottom, #000 0, #000 4px, transparent 4px, transparent 8px);
}
.drop-preview {
  position: absolute; top: 4px; height: 30px; border-radius: 8px;
  background: rgba(var(--flow-rgb), .16); border: 2px dashed var(--flow);
  pointer-events: none; z-index: 5;
  /* glides between snap positions instead of jumping column to column */
  transition: left .09s ease-out, width .09s ease-out;
  animation: previewIn .12s ease-out;
}
@keyframes previewIn { from { opacity: 0; } to { opacity: 1; } }
.drag-ghost {
  position: fixed; top: 0; left: 0; transform: translate(14px, -50%);
  background: var(--accent); color: #fff; padding: 5px 10px; border-radius: 8px;
  font-size: 12.5px; font-weight: 600; white-space: nowrap; max-width: 240px;
  overflow: hidden; text-overflow: ellipsis; pointer-events: none; z-index: 60;
  box-shadow: 0 4px 14px rgba(0,0,0,.35);
  animation: ghostIn .14s ease-out;
}
@keyframes ghostIn {
  from { opacity: 0; transform: translate(14px, -50%) scale(.85); }
  to { opacity: 1; transform: translate(14px, -50%); }
}
.board.no-weekend .day-col.weekend { background: none; }
.today-line {
  position: absolute; top: 0; bottom: 0; width: 2px; background: var(--today); z-index: 2; pointer-events: none;
}
/* Day views: today's whole column, tinted (see renderRow) */
.today-col {
  position: absolute; top: 0; bottom: 0; z-index: 0; pointer-events: none;
  background: rgba(127,189,65,.09);
  border-left: 2px solid var(--today);
}
/* Start time at the front of a day-view chip (see renderBar) */
.bar .bar-time {
  flex-shrink: 0; margin-right: 6px; font-size: 11px; font-weight: 600;
  opacity: .85; font-variant-numeric: tabular-nums;
}

/* ---------- Outlook events (read-only lane under the bars) ---------- */
.busy-block {
  position: absolute; height: 18px; z-index: 1; box-sizing: border-box;
  display: flex; align-items: center; padding: 0 6px;
  font-size: 11px; line-height: 1; color: var(--text-dim);
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  background: repeating-linear-gradient(45deg, rgba(100,116,139,.16) 0 6px, rgba(100,116,139,.08) 6px 12px);
  border-left: 2px solid rgba(100,116,139,.5);
  cursor: default; user-select: none;
}
.busy-block.busy-tentative { opacity: .6; }
.busy-block.busy-oof { background: repeating-linear-gradient(45deg, rgba(168,85,247,.18) 0 6px, rgba(168,85,247,.08) 6px 12px); border-left-color: rgba(168,85,247,.6); }

/* ---------- Task bars ---------- */
.bar {
  position: absolute;
  top: 6px;
  height: calc(var(--row-h) - 12px);
  border-radius: 8px;
  padding: 0 8px;
  display: flex;
  align-items: center;
  font-size: 12.5px;
  color: #fff;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  cursor: grab;
  box-shadow: 0 1px 2px rgba(0,0,0,.15);
  border: 1px solid rgba(0,0,0,.08);
  user-select: none;
  transition: box-shadow .12s ease, transform .12s ease;
}
.bar:hover { box-shadow: 0 3px 8px rgba(0,0,0,.22); transform: translateY(-1px); }
.bar:active { cursor: grabbing; }
.bar.dragging { opacity: .55; }
.bar.source-bc { background: var(--bc); }
.bar.source-crm { background: var(--crm); }
.bar.source-manual { background: var(--manual); }
.bar.historical { opacity: .55; background-image: repeating-linear-gradient(45deg, rgba(255,255,255,.15) 0 6px, transparent 6px 12px); }
.bar.past-due { outline: 2px dashed #b45309; outline-offset: 1px; }
.bar.bar-highlight { animation: barHighlight 1.6s ease; z-index: 10; }
@keyframes barHighlight {
  0%, 100% { box-shadow: 0 1px 2px rgba(0,0,0,.15); outline: 2px solid transparent; }
  15%, 60% { box-shadow: 0 0 0 4px rgba(var(--flow-rgb), .35), 0 3px 10px rgba(0,0,0,.25); outline: 2px solid var(--accent); }
}
/* overflow:visible so the corner nudge buttons below can protrude past the
   bar's own edges instead of being clipped by its normal overflow:hidden */
.bar.bar-selected { outline: 2px solid var(--accent); box-shadow: 0 0 0 3px rgba(var(--flow-rgb), .25), 0 3px 10px rgba(0,0,0,.25); z-index: 9; overflow: visible; }
.bar .bar-title { overflow: hidden; text-overflow: ellipsis; }
.bar-nudge-btn {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 22px; height: 22px; border-radius: 50%; border: 1px solid rgba(0,0,0,.15);
  background: var(--accent); color: #fff; font-size: 13px; line-height: 1;
  display: flex; align-items: center; justify-content: center; cursor: ew-resize;
  padding: 0; z-index: 11; box-shadow: 0 1px 4px rgba(0,0,0,.45); touch-action: none;
}
.bar-nudge-btn:hover { filter: brightness(1.15); transform: translateY(-50%) scale(1.08); }
.bar-nudge-left { left: -12px; }
.bar-nudge-right { right: -12px; }
.bar.resizing { transition: none; } /* no easing lag while a handle is being dragged live */

/* ---------- Modal ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(20,22,30,.35);
  display: flex; align-items: center; justify-content: center; z-index: 50;
  animation: overlayIn .12s ease;
}
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }
.sch-modal {
  background: var(--panel); border-radius: 12px; width: 420px; max-width: 92vw;
  padding: 18px 20px; box-shadow: var(--shadow-md), 0 20px 48px rgba(16,24,40,.18);
  animation: modalIn .14s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(.97) translateY(4px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
/* Closing — see closeOverlay in app.js, which removes it on animationend */
.overlay.closing { animation: overlayOut .14s ease forwards; pointer-events: none; }
.overlay.closing .sch-modal { animation: modalOut .14s ease forwards; }
@keyframes overlayOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes modalOut {
  from { opacity: 1; transform: scale(1) translateY(0); }
  to { opacity: 0; transform: scale(.97) translateY(4px); }
}
.sch-modal h2 { margin: 0 0 12px; font-size: 15px; }
.sch-modal .row-field { margin-bottom: 10px; font-size: 13px; }
.sch-modal .row-field label { display: block; color: var(--text-dim); font-size: 11px; text-transform: uppercase; margin-bottom: 3px; }
.sch-modal textarea { resize: vertical; font-family: inherit; }
.sch-modal input, .sch-modal select, .sch-modal textarea {
  width: 100%; padding: 7px 8px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px;
}
.sch-modal .duration-row { display: flex; gap: 8px; }
.sch-modal .duration-row input { width: 90px; flex: none; }
.sch-modal .duration-row select { flex: 1; }
.sch-modal .field-hint { color: var(--text-dim); font-size: 11.5px; text-transform: none; display: inline; margin-bottom: 0; }
.sch-modal .row-field.field-hint { display: block; margin-bottom: 10px; line-height: 1.45; background: var(--unassigned-bg); border: 1px solid #f1d9a0; border-radius: 8px; padding: 8px 10px; color: #92600a; }
.sch-modal .actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 14px; }
.sch-modal .actions button.danger { margin-right: auto; background: #fdecec; color: #b32424; border-color: #f3bcbc; }
.sch-modal a.source-link { font-size: 12px; }

/* ---------- Bar right-click menu ---------- */
.context-menu {
  position: fixed; z-index: 60; min-width: 190px; padding: 4px;
  background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: var(--shadow-md), 0 10px 28px rgba(16,24,40,.18); font-size: 13px;
  transform-origin: top left; animation: menuIn .12s ease-out;
}
@keyframes menuIn {
  from { opacity: 0; transform: scale(.94) translateY(-3px); }
  to { opacity: 1; transform: none; }
}
.context-menu-item {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 10px;
  background: transparent; border: none; border-radius: 6px; color: inherit; font: inherit;
  text-align: left; cursor: pointer;
}
.context-menu-item:hover:not(:disabled) { background: var(--weekend); }
.context-menu-item:disabled { opacity: .5; cursor: default; }
.context-menu-item.checked { font-weight: 600; }
.context-menu-label { flex: 1; }
.context-menu-check { color: var(--text-dim); }
.context-menu-swatch { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.context-menu-sep { height: 1px; margin: 4px 2px; background: var(--border); }
.context-menu-heading { padding: 4px 10px 2px; font-size: 11px; text-transform: uppercase; color: var(--text-dim); }

/* ---------- Debug panel ---------- */
.debug-toggle {
  position: fixed; right: 14px; bottom: 14px; z-index: 40;
  width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--panel); cursor: pointer; font-size: 14px;
}
.debug-panel {
  position: fixed; right: 14px; bottom: 54px; width: 420px; max-height: 60vh; overflow: auto;
  background: #10131a; color: #d7e0ea; font-family: ui-monospace, Consolas, monospace; font-size: 11.5px;
  border-radius: 8px; padding: 10px 12px; z-index: 40; box-shadow: 0 10px 30px rgba(0,0,0,.3);
  white-space: pre-wrap;
}
.debug-panel h3 { margin: 8px 0 4px; color: var(--brand-green); font-size: 12px; }
.debug-inspect { display: flex; gap: 6px; margin-bottom: 8px; }
.debug-inspect input {
  flex: 1; min-width: 0; padding: 5px 7px; border-radius: 5px; border: 1px solid #2a3040;
  background: #1a1f2b; color: #d7e0ea; font-size: 11.5px;
}
.debug-inspect button {
  flex: none; padding: 5px 10px; border-radius: 5px; border: 1px solid #2a3040;
  background: #2a3040; color: #d7e0ea; font-size: 11.5px; cursor: pointer;
}
.debug-provision {
  display: flex; align-items: center; gap: 8px; margin-bottom: 10px;
  padding-bottom: 8px; border-bottom: 1px solid #2a3040;
}
.debug-provision button {
  flex: none; padding: 5px 10px; border-radius: 5px; border: 1px solid #2a3040;
  background: #2a3040; color: #d7e0ea; font-size: 11.5px; cursor: pointer;
}
.debug-provision .field-hint { color: #8a94a6; font-size: 10.5px; }

.empty-hint { padding: 32px 24px; color: var(--text-dim); font-size: 13px; text-align: center; }

/* ---------- Side panels (Tasks, Setup) — slide in from the left, only one open at a time ---------- */
.side-panel {
  position: fixed; top: 0; left: 0; bottom: 0; width: 360px;
  background: var(--panel); border-right: 1px solid var(--border);
  border-radius: 0 14px 14px 0;
  z-index: 45; overflow-y: auto; padding: 14px;
  box-shadow: var(--shadow-md);
  transform: translateX(-100%);
  transition: transform .2s ease;
}
.side-panel.open { transform: translateX(0); }
.side-panel.setup-panel { width: var(--setup-panel-w); }
.tasks-panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.tasks-panel-header > strong, .bottom-panel-header > strong {
  color: var(--heading); font-size: 14.5px; font-weight: 700;
  padding-left: 9px; border-left: 3px solid var(--flow);
}
.tasks-search {
  width: 100%; padding: 7px 9px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; margin-bottom: 10px;
}
.tasks-panel-filters { display: flex; gap: 8px; margin-bottom: 10px; }
.tasks-panel-filters .tasks-search { width: auto; flex: 1 1 auto; margin-bottom: 0; }
.tasks-panel-filters select,
.bottom-panel-header select {
  padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 12px; color: var(--text); background: var(--panel); flex-shrink: 0;
}
/* margin-right: auto keeps the type filter beside the caption, pushing only the ✕ to the far right */
.bottom-panel-header select { margin: 0 auto 0 12px; }
.tab-row { display: flex; gap: 6px; margin-bottom: 12px; }
.tab-btn {
  border: 1px solid var(--border); background: var(--panel); border-radius: 8px;
  padding: 4px 10px; font-size: 12px; cursor: pointer; color: var(--text);
  transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}
.tab-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.task-row {
  padding: 8px 6px; border-bottom: 1px solid var(--border); cursor: grab; border-radius: 8px; user-select: none;
  transition: background-color .15s ease, box-shadow .15s ease;
}
.task-row:hover { background: rgba(var(--flow-rgb), .08); }
.task-row.dragging { opacity: .45; }

/* Push the board over/up (instead of covering it) while a side panel — or
   the bottom Planned/Assigned panel — is open */
#app { transition: margin-left .2s ease, margin-bottom .2s ease; }
body.panel-open #app { margin-left: 360px; }
body.setup-open #app { margin-left: var(--setup-panel-w); }
body.planned-open #app { margin-left: var(--tasks-panel-w); margin-bottom: var(--planned-h); }
.task-row-top { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; }
.task-row-top .bar-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex-shrink: 1; min-width: 0; }
.task-row-meta { font-size: 11.5px; color: var(--text-dim); margin-top: 2px; margin-left: 16px; }
.task-row-meta .needs-resource { color: #92600a; }
.task-row-meta .past-due-flag { color: #b45309; font-weight: 600; }
.task-row-desc {
  font-size: 12px; color: var(--text); margin-top: 3px; margin-left: 16px; white-space: pre-line;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.task-row.task-row-past-due { background: #fdf6ec; border-left: 3px solid #b45309; padding-left: 3px; }

/* ---------- Bulk selection (see tasksPanelState.selectedIds / bulkDeleteSelected) ---------- */
.task-row-select { display: flex; align-items: center; flex-shrink: 0; cursor: pointer; }
.task-row-select input[type="checkbox"] { margin: 0; cursor: pointer; }
.task-row.task-row-selected { background: rgba(var(--flow-rgb), .12); }
.bulk-actions {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px; padding: 6px 8px;
  background: var(--weekend); border-radius: 8px; font-size: 12px; font-weight: 600;
  color: var(--text); flex-shrink: 0;
}
.bulk-actions span { flex: 1; }
.bulk-delete-btn, .bulk-clear-btn {
  border: 1px solid var(--border); border-radius: 8px; padding: 4px 9px; font-size: 11.5px;
  cursor: pointer; background: var(--panel); color: var(--text); transition: background-color .15s ease;
}
.bulk-delete-btn { border-color: #e2b8b8; color: #a3342e; }
.bulk-delete-btn:hover { background: #fdecea; }
.bulk-clear-btn:hover { background: var(--weekend); }

.progress-badge {
  flex-shrink: 0; background: #e9eef6; color: var(--brand-navy-2); border: 1px solid #c9d4e6;
  border-radius: 999px; padding: 1px 7px; font-size: 10.5px; font-weight: 600; white-space: nowrap;
}
.status-pill {
  flex-shrink: 0; color: #fff; border-radius: 999px; padding: 1px 8px;
  font-size: 10.5px; font-weight: 600; white-space: nowrap;
}

/* ---------- Tasks panel: grouped by source ---------- */
.task-section { margin-bottom: 10px; }
.task-section-header {
  display: flex; align-items: center; gap: 4px; cursor: pointer;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
  color: var(--text-dim); border-left: 3px solid var(--border);
  padding: 4px 0 4px 8px; margin-bottom: 4px; border-radius: 4px;
}
.task-section-header:hover { background: var(--weekend); }
.task-section-header.collapsed { margin-bottom: 0; }
.task-section-count {
  margin-left: 4px; background: var(--weekend); color: var(--text-dim);
  border-radius: 999px; padding: 0 6px; font-size: 10.5px; font-weight: 600;
}
.planned-badge {
  flex-shrink: 0; background: #eef7e5; color: #3f6f1a; border: 1px solid #cfe6b5;
  border-radius: 999px; padding: 1px 7px; font-size: 10.5px; font-weight: 600; white-space: nowrap;
}
.task-subsection-label {
  font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em;
  color: var(--text-dim); padding: 6px 0 3px 8px;
}

/* ---------- Tasks panel: grouped occurrences (see taskGroupHtml) — one
   header row standing in for every block of the same source task, click
   to drill down into the individual occurrences below it. ---------- */
.task-group-header { cursor: pointer; }
.group-chevron { width: 10px; flex-shrink: 0; color: var(--text-dim); font-size: 10px; }
.task-group-children { margin: 2px 0 4px 12px; border-left: 2px solid var(--border); padding-left: 8px; }
/* only on the render right after it's clicked open — see justExpandedGroup in app.js */
.task-group-children.just-expanded { animation: groupIn .18s ease-out; }
@keyframes groupIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}
.task-row-in-group { padding-top: 6px; padding-bottom: 6px; }

/* ---------- Tasks panel: Open Tasks (left-docked) and Planned/Assigned
   (bottom-docked, see .bottom-panel below) are two SEPARATE panels that
   open/close together — matching the Business Central Jobs Planning
   Board's own layout, where Open Tasks sits top-left and Planned Tasks is
   its own full-width tab at the bottom, rather than one panel stacked
   inside the other. Open Tasks stops short of the full viewport height
   (see the bottom: value below) so it doesn't run underneath the bottom
   panel. The panel itself switches from the generic .side-panel's own
   scrolling to a fixed flex column, so its height is spent on the list
   below the header/search instead. ---------- */
.side-panel.tasks-panel { display: flex; flex-direction: column; overflow: hidden; bottom: var(--planned-h); width: var(--tasks-panel-w); }
.tasks-panel-header, .tasks-search, .tasks-panel-filters { flex-shrink: 0; }
.task-pane-count {
  margin-left: 6px; background: var(--weekend); color: var(--text-dim);
  border-radius: 999px; padding: 0 7px; font-size: 11px; font-weight: 600;
}
.task-pane-list {
  flex: 1; min-height: 0; overflow-y: auto; padding: 6px 4px;
}

/* ---------- Planned/Assigned — its own bottom-docked panel, full width,
   sliding up from the bottom of the screen like a drawer — mirrors where
   the BC Jobs Planning Board puts its "Planned Tasks" tab. Opens/closes in
   lockstep with Open Tasks (see togglePanel) even though it's a separate
   element positioned independently. ---------- */
.bottom-panel {
  position: fixed; left: 0; right: 0; bottom: 0; height: var(--planned-h);
  background: var(--panel); border-top: 1px solid var(--border);
  border-radius: 14px 14px 0 0;
  z-index: 44; padding: 12px 14px;
  box-shadow: var(--shadow-md);
  transform: translateY(100%);
  transition: transform .2s ease;
  display: flex; flex-direction: column;
}
.bottom-panel.open { transform: translateY(0); }

/* ---------- Resize handles for Open Tasks (drag its right edge) and
   Planned/Assigned (drag its top edge). Separate fixed elements rather than
   children of the panels, since the panels re-render via innerHTML. Only
   shown while the Tasks panels are open (body.planned-open). ---------- */
.panel-resize-handle { position: fixed; z-index: 47; display: none; background: transparent; transition: background-color .15s ease; }
body.planned-open .panel-resize-x, body.planned-open .panel-resize-y, body.setup-open .panel-resize-setup { display: block; }
.panel-resize-handle:hover, .panel-resize-handle.active { background: rgba(var(--flow-rgb), .55); }
.panel-resize-x { top: 0; bottom: var(--planned-h); left: calc(var(--tasks-panel-w) - 3px); width: 6px; cursor: ew-resize; }
.panel-resize-y { left: 0; right: 0; bottom: calc(var(--planned-h) - 3px); height: 6px; cursor: ns-resize; }
.panel-resize-setup { top: 0; bottom: 0; left: calc(var(--setup-panel-w) - 3px); width: 6px; cursor: ew-resize; }
/* No slide animations while dragging, so the panels track the pointer */
body.panel-resizing, body.panel-resizing * { user-select: none; }
body.panel-resizing #app, body.panel-resizing .side-panel, body.panel-resizing .bottom-panel { transition: none; }
body.panel-resizing.resizing-x { cursor: ew-resize; }
body.panel-resizing.resizing-y { cursor: ns-resize; }
.bottom-panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; flex-shrink: 0; }
.bottom-panel-list { flex: 1; min-height: 0; overflow-y: auto; padding: 2px; }
/* Planned/Assigned rows no longer support drag (see wireTaskListRows'
   dragDisabled option — dragging an already-placed block from the list is
   pointless since it's already on the board) — a plain pointer cursor
   instead of the grab cursor still used for the draggable Open Tasks rows. */
.bottom-panel .task-row { cursor: pointer; }

/* ---------- Setup panel — Resources & Settings tabs ---------- */
.setup-resource-row {
  display: flex; align-items: center; gap: 6px; padding: 7px 0;
  border-bottom: 1px solid var(--border);
}
.setup-resource-row.add-row {
  border-bottom: 2px solid var(--border); padding-bottom: 12px; margin-bottom: 8px;
}
.setup-resource-row input[type="text"], .setup-resource-row input:not([type]) { min-width: 0; }
.res-name-input { flex: 1.3; min-width: 0; padding: 6px 7px; border: 1px solid var(--border); border-radius: 8px; font-size: 12.5px; }
.res-email-input, #new-res-email { flex: 1.4; min-width: 0; padding: 6px 7px; border: 1px solid var(--border); border-radius: 8px; font-size: 12.5px; }
.res-color-input, #new-res-color { width: 30px; height: 28px; padding: 2px; border: 1px solid var(--border); border-radius: 8px; flex: none; cursor: pointer; }
#new-res-name { flex: 1.3; min-width: 0; padding: 6px 7px; border: 1px solid var(--border); border-radius: 8px; font-size: 12.5px; }
#add-res-btn { flex: none; padding: 6px 10px; font-size: 12px; }
.setup-resource-row input:disabled { background: var(--bg-2, #f3f4f6); color: var(--text-2, #6b7280); cursor: not-allowed; }

.settings-form { display: flex; flex-direction: column; gap: 16px; }
.settings-row label { display: block; font-size: 12.5px; font-weight: 500; margin-bottom: 5px; }
.settings-row select {
  width: 100%; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px;
}
.settings-row label input[type="checkbox"] { margin-right: 6px; font-weight: normal; vertical-align: -1px; }
.colors-row .color-swatches { display: flex; gap: 14px; }
.colors-row .color-swatches span {
  display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-dim);
}
.colors-row .color-swatches input[type="color"] { width: 30px; height: 26px; padding: 2px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }

/* ---------- Setup panel — per-resource Privileges checkboxes ---------- */
.setup-resource-item { border-bottom: 1px solid var(--border); }
.setup-resource-item .setup-resource-row { border-bottom: none; }
.setup-resource-privileges { display: flex; gap: 14px; padding: 0 0 8px 2px; }
.setup-resource-privileges.add-row-privileges { padding-bottom: 12px; margin-bottom: 8px; border-bottom: 2px solid var(--border); }
.setup-resource-sync { display: flex; padding: 0 0 8px 2px; }
.setup-bulk-row { padding-bottom: 12px; margin-bottom: 8px; border-bottom: 2px solid var(--border); }
.icon-btn-text {
  border: 1px solid var(--border); background: var(--panel); border-radius: 8px;
  padding: 5px 10px; font-size: 12px; cursor: pointer; color: var(--text);
  transition: background-color .15s ease, border-color .15s ease;
}
.icon-btn-text:hover { background: var(--weekend); }
.icon-btn-text:disabled { opacity: .6; cursor: default; }
.priv-check { display: inline-flex !important; align-items: center; gap: 4px; font-size: 12px; font-weight: normal !important; margin: 0 !important; cursor: pointer; }
.priv-check input[type="checkbox"] { margin: 0; }

.working-days-row { display: flex; flex-wrap: wrap; gap: 12px; }
.day-check { display: inline-flex !important; align-items: center; gap: 4px; font-size: 12.5px; font-weight: normal !important; margin: 0 !important; cursor: pointer; }
.day-check input[type="checkbox"] { margin: 0; }
.working-hours-row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.working-hours-row input[type="number"] { width: 60px; padding: 6px 7px; border: 1px solid var(--border); border-radius: 8px; font-size: 12.5px; }

/* ---------- Setup panel — Connection settings (admin-only, advanced) ---------- */
.connection-settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; margin-top: 8px; }
.connection-settings-grid label { font-size: 12px; font-weight: 500; }
.connection-settings-grid label.wide-field { grid-column: 1 / -1; }
.connection-settings-grid input { width: 100%; margin-top: 4px; padding: 6px 7px; border: 1px solid var(--border); border-radius: 8px; font-size: 12.5px; box-sizing: border-box; }
.connection-settings-grid textarea { width: 100%; margin-top: 4px; padding: 6px 7px; border: 1px solid var(--border); border-radius: 8px; font-size: 11.5px; font-family: ui-monospace, monospace; box-sizing: border-box; resize: vertical; }
.connection-settings-grid .field-hint { display: block; font-weight: 400; color: var(--text-dim); font-size: 10.5px; margin: 2px 0; }
.connection-settings-actions { display: flex; gap: 8px; margin-top: 12px; }


.hidden-task-list { max-height: 180px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; }
.hidden-task-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px 8px; border-bottom: 1px solid var(--border); font-size: 12.5px;
}
.hidden-task-row:last-child { border-bottom: none; }
.hidden-task-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden-task-row .unhide-btn { flex-shrink: 0; border: 1px solid var(--border); padding: 2px 8px; border-radius: 5px; }

/* Reduced motion (OS setting) — settle everything instantly. app.js skips
   its own bar/board animations the same way (see motionOk). */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* ============================================================================
   Night mode — <html data-theme="dark">, set by applyTheme() in app.js (and
   before first paint by the inline script in index.html). Mostly just
   swaps the palette tokens above; the rules after that only cover the few
   spots that use hard-coded light colors instead of tokens.
   ============================================================================ */
:root[data-theme="dark"] {
  color-scheme: dark; /* native form controls + scrollbars go dark too */
  --bg: #1f2023;
  --panel: #2b2c30;
  --border: #404248;
  --half-hour-line: #54575e;
  --text: #ececee;
  --text-dim: #a6a9b0;
  --heading: #ffffff;
  --accent: #9455BD;
  --flow: #B07AD9;
  --flow-rgb: 176, 122, 217;
  --accent-hover: #A066C8;
  --today: var(--brand-green);
  --weekend: #34353a;
  --unassigned-bg: #3a3322;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.3), 0 1px 3px rgba(0,0,0,.2);
  --shadow-md: 0 8px 24px rgba(0,0,0,.4), 0 2px 6px rgba(0,0,0,.25);
}
/* The logo's navy lettering disappears on a dark bar — sit it on a light chip */
:root[data-theme="dark"] .topbar h1.brand img { background: #fff; border-radius: 8px; padding: 3px 6px; box-sizing: content-box; height: 32px; }
:root[data-theme="dark"] input:not([type="checkbox"]):not([type="radio"]):not([type="color"]),
:root[data-theme="dark"] select,
:root[data-theme="dark"] textarea { background: #242528; color: var(--text); border-color: var(--border); }
:root[data-theme="dark"] .setup-resource-row input:disabled { background: #26272a; color: var(--text-dim); }
:root[data-theme="dark"] .overlay { background: rgba(0,0,0,.45); }
:root[data-theme="dark"] .sch-timeline.drop-hover { background-color: rgba(var(--flow-rgb), .10); }
:root[data-theme="dark"] .task-row.task-row-selected { background: rgba(var(--flow-rgb), .2); }
:root[data-theme="dark"] .bar.bar-selected { box-shadow: 0 0 0 3px rgba(var(--flow-rgb), .35), 0 3px 10px rgba(0,0,0,.5); }

/* Warning / past-due tints */
:root[data-theme="dark"] .status-pill { color: #f2c46b; border-color: #6a5a36; }
:root[data-theme="dark"] .sch-modal .row-field.field-hint { border-color: #6a5a36; color: #f2c46b; }
:root[data-theme="dark"] .task-row-meta .needs-resource { color: #f2c46b; }
:root[data-theme="dark"] .task-row-meta .past-due-flag { color: #f59e4b; }
:root[data-theme="dark"] .task-row.task-row-past-due { background: #3a2e22; border-left-color: #f59e4b; }
:root[data-theme="dark"] .bar.past-due { outline-color: #f59e4b; }

/* Success / error / info badges */
:root[data-theme="dark"] .status-pill.ok,
:root[data-theme="dark"] .planned-badge { background: #2c3a26; color: #b2de8a; border-color: #4a6340; }
:root[data-theme="dark"] .status-pill.err { background: #45292a; color: #f3a9a9; border-color: #6e3b3c; }
:root[data-theme="dark"] .progress-badge { background: #2c3547; color: #b3c6e6; border-color: #465877; }
:root[data-theme="dark"] .sch-modal .actions button.danger,
:root[data-theme="dark"] .bulk-delete-btn { background: #45292a; color: #f3a9a9; border-color: #6e3b3c; }
:root[data-theme="dark"] .bulk-delete-btn:hover { background: #553234; }

/* The follow-up status pill in task-list rows reuses .status-pill with an inline color — keep its text white */
:root[data-theme="dark"] .task-row .status-pill { color: #fff; border-color: transparent; }
