:root {
  --brand-primary: #635bff;
  --brand-secondary: #22c7b8;
  --brand-glow: rgba(99, 91, 255, 0.28);
  --bg-app: #16171f;
  --bg-sidebar: #1c1d27;
  --bg-panel: #212330;
  --bg-raised: #262838;
  --bg-hover: #2c2e40;
  --bg-active: #343752;
  --bg-input: #191a23;
  --border: #32354a;
  --border-soft: #2a2c3d;
  --text: #e8e9f0;
  --text-dim: #9b9eb3;
  --text-faint: #6b6e85;
  --accent: #756cff;
  --accent-hover: #8b84ff;
  --accent-soft: rgba(117, 108, 255, 0.17);
  --green: #22c55e;
  --yellow: #f59e0b;
  --red: #ef4444;
  --orange: #f97316;
  --blue: #3b82f6;
  --pink: #ec4899;
  --teal: #14b8a6;
  --urgent: #ff5959;
  --high: #ffb648;
  --normal: #5ea0ff;
  --low: #b4b8c9;
  --radius: 8px;
  --radius-sm: 5px;
  --shadow: 0 10px 34px rgba(0, 0, 0, 0.5);
  --font: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg-app);
  color: var(--text);
  font-size: 14px;
  overflow: hidden;
}
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; font-size: 13px; color: var(--text); }
a { color: var(--accent); text-decoration: none; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, a:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--brand-secondary); outline-offset: 2px; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #343750; border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- boot ---------- */
.boot-splash { height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; }
.boot-logo { filter: drop-shadow(0 10px 24px var(--brand-glow)); }
.boot-name { font-weight: 800; font-size: 20px; letter-spacing: -0.3px; }
.boot-spinner { width: 26px; height: 26px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- auth ---------- */
.auth-wrap { height: 100vh; display: flex; align-items: center; justify-content: center; background: radial-gradient(1000px 600px at 20% 10%, var(--brand-glow), transparent 60%), radial-gradient(900px 500px at 85% 90%, rgba(34,199,184,0.10), transparent 55%), var(--bg-app); overflow: auto; }
.auth-card { width: 400px; max-width: calc(100vw - 32px); background: var(--bg-panel); border: 1px solid var(--border); border-radius: 14px; padding: 34px; box-shadow: var(--shadow); }
.auth-logo { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 8px; font-size: 21px; font-weight: 800; letter-spacing: -0.4px; }
.brand-mark { display: block; width: 100%; height: 100%; flex-shrink: 0; filter: drop-shadow(0 5px 12px var(--brand-glow)); }
.auth-sub { text-align: center; color: var(--text-dim); margin-bottom: 26px; font-size: 13px; }
.auth-field { margin-bottom: 14px; }
.auth-field label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 6px; font-weight: 600; }
.auth-error { background: rgba(239, 68, 68, 0.12); border: 1px solid rgba(239,68,68,0.4); color: #fca5a5; padding: 9px 12px; border-radius: var(--radius-sm); margin-bottom: 14px; font-size: 12.5px; }
.auth-switch { text-align: center; margin-top: 18px; color: var(--text-dim); font-size: 13px; }
.auth-switch a { cursor: pointer; font-weight: 600; }
.auth-badge { display:inline-block; margin-top: 18px; width: 100%; text-align:center; font-size: 11.5px; color: var(--text-faint); }

/* ---------- inputs & buttons ---------- */
.input, .textarea, .select {
  width: 100%; background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 9px 11px; color: var(--text); outline: none;
}
.input:focus, .textarea:focus, .select:focus { border-color: var(--accent); }
.textarea { resize: vertical; min-height: 70px; }
.select option { background: var(--bg-panel); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  background: var(--accent); color: #fff; border: none; border-radius: var(--radius-sm);
  padding: 9px 16px; font-size: 13px; font-weight: 600; transition: background 0.15s;
}
.btn:hover { background: var(--accent-hover); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.secondary { background: var(--bg-raised); color: var(--text); border: 1px solid var(--border); }
.btn.secondary:hover { background: var(--bg-hover); }
.btn.danger { background: var(--red); }
.btn.danger:hover { background: #dc2626; }
.btn.ghost { background: transparent; color: var(--text-dim); border: 1px solid transparent; }
.btn.ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn.block { width: 100%; }
.icon-btn { background: transparent; border: none; color: var(--text-dim); border-radius: var(--radius-sm); padding: 6px; display: inline-flex; align-items: center; justify-content: center; }
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }

/* ---------- layout ---------- */
.layout { display: flex; height: 100vh; overflow: hidden; }
.sidebar { width: 264px; min-width: 264px; background: var(--bg-sidebar); border-right: 1px solid var(--border-soft); display: flex; flex-direction: column; overflow: hidden; }
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

/* sidebar */
.ws-header { padding: 12px 14px; display: flex; align-items: center; gap: 10px; cursor: pointer; border-bottom: 1px solid var(--border-soft); }
.ws-logo { width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center; color: #fff; flex-shrink: 0; box-shadow: 0 5px 14px var(--brand-glow); }
.ws-logo svg { width: 22px; height: 22px; }
.ws-name { font-weight: 700; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.ws-plan { font-size: 10px; background: linear-gradient(90deg,var(--brand-primary),var(--brand-secondary)); padding: 2px 7px; border-radius: 20px; font-weight: 700; color: #fff; }
.sidebar-nav { padding: 8px; display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); color: var(--text-dim); cursor: pointer; font-weight: 600; font-size: 13px; border: none; background: none; width: 100%; text-align: left; }
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-hover); }
.nav-item svg { flex-shrink: 0; }
.nav-badge { margin-left: auto; background: var(--accent); color: #fff; border-radius: 20px; font-size: 10px; padding: 1px 7px; font-weight: 700; }
.sidebar-tree { flex: 1; overflow-y: auto; padding: 4px 8px 16px; }
.tree-section { margin-top: 6px; }
.tree-row { display: flex; align-items: center; gap: 6px; padding: 5px 8px; border-radius: var(--radius-sm); cursor: pointer; color: var(--text); font-size: 13px; position: relative; }
.tree-row:hover { background: var(--bg-hover); }
.tree-row.active { background: var(--accent-soft); }
.tree-row .chev { transition: transform 0.15s; color: var(--text-faint); display: flex; }
.tree-row .chev.open { transform: rotate(90deg); }
.tree-dot { width: 9px; height: 9px; border-radius: 3px; flex-shrink: 0; }
.tree-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.tree-count { color: var(--text-faint); font-size: 11px; }
.tree-actions { display: none; gap: 2px; }
.tree-row:hover .tree-actions { display: flex; }
.tree-children { margin-left: 16px; border-left: 1px solid var(--border-soft); padding-left: 4px; }
.tree-add { display: flex; align-items: center; gap: 6px; color: var(--text-faint); font-size: 12px; padding: 6px 10px; cursor: pointer; border-radius: var(--radius-sm); }
.tree-add:hover { color: var(--text); background: var(--bg-hover); }
.sidebar-footer { border-top: 1px solid var(--border-soft); padding: 8px; }
.me-row { display: flex; align-items: center; gap: 9px; padding: 7px 8px; border-radius: var(--radius-sm); cursor: pointer; }
.me-row:hover { background: var(--bg-hover); }
.me-name { font-size: 12.5px; font-weight: 600; }
.me-role { font-size: 10.5px; color: var(--text-faint); }

/* avatar */
.avatar { border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; flex-shrink: 0; font-size: 11px; }
.avatar-stack { display: flex; }
.avatar-stack .avatar { margin-left: -5px; border: 2px solid var(--bg-panel); }
.avatar-stack .avatar:first-child { margin-left: 0; }

/* topbar */
.topbar { height: 52px; min-height: 52px; border-bottom: 1px solid var(--border-soft); display: flex; align-items: center; gap: 10px; padding: 0 16px; background: var(--bg-panel); }
.crumb { display: flex; align-items: center; gap: 7px; font-weight: 600; font-size: 14px; min-width: 0; }
.crumb .dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.crumb .sep { color: var(--text-faint); font-weight: 400; }
.crumb .part { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; color: var(--text-dim); }
.crumb .part:hover { color: var(--text); }
.crumb .part.current { color: var(--text); cursor: default; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.search-trigger { display: flex; align-items: center; gap: 8px; background: var(--bg-input); border: 1px solid var(--border); color: var(--text-faint); padding: 6px 12px; border-radius: var(--radius-sm); font-size: 12.5px; min-width: 200px; cursor: pointer; }
.search-trigger:hover { border-color: var(--accent); }
.search-trigger kbd { margin-left: auto; background: var(--bg-raised); border: 1px solid var(--border); border-radius: 4px; padding: 0 5px; font-size: 10px; }
.bell-btn { position: relative; }
.bell-dot { position: absolute; top: 3px; right: 3px; width: 8px; height: 8px; background: var(--red); border-radius: 50%; border: 2px solid var(--bg-panel); }

/* view header */
.view-header { display: flex; align-items: center; gap: 4px; padding: 8px 16px 0; background: var(--bg-panel); flex-wrap: wrap; }
.view-tab { display: flex; align-items: center; gap: 6px; padding: 8px 13px; border-radius: 8px 8px 0 0; color: var(--text-dim); font-size: 13px; font-weight: 600; cursor: pointer; border: none; background: none; border-bottom: 2px solid transparent; }
.view-tab:hover { color: var(--text); background: var(--bg-hover); }
.view-tab.active { color: var(--text); border-bottom-color: var(--accent); }
.view-tab.add { color: var(--text-faint); }
.view-toolbar { display: flex; align-items: center; gap: 8px; padding: 10px 16px; background: var(--bg-panel); border-bottom: 1px solid var(--border-soft); flex-wrap: wrap; }
.toolbar-btn { display: inline-flex; align-items: center; gap: 6px; background: var(--bg-raised); border: 1px solid var(--border); color: var(--text-dim); padding: 5px 11px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.toolbar-btn:hover { color: var(--text); border-color: var(--accent); }
.toolbar-btn.on { background: var(--accent-soft); color: #c4b8fd; border-color: var(--accent); }
.toolbar-spacer { flex: 1; }
.view-body { flex: 1; overflow: auto; background: var(--bg-app); position: relative; }

/* ---------- badges ---------- */
.status-pill { display: inline-flex; align-items: center; justify-content: center; padding: 3px 10px; border-radius: 4px; font-size: 11px; font-weight: 700; color: #fff; cursor: pointer; white-space: nowrap; border: none; min-width: 86px; }
.status-pill:hover { filter: brightness(1.12); }
.prio { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 22px; border-radius: 4px; cursor: pointer; border: none; background: transparent; }
.prio:hover { background: var(--bg-hover); }
.prio.p1 svg { color: var(--urgent); } .prio.p2 svg { color: var(--high); }
.prio.p3 svg { color: var(--normal); } .prio.p4 svg { color: var(--low); }
.prio.none { color: var(--text-faint); }
.tag-chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 4px; font-size: 10.5px; font-weight: 700; color: #fff; cursor: pointer; border: none; }
.due-chip { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--text-dim); background: var(--bg-raised); padding: 3px 8px; border-radius: 4px; cursor: pointer; border: 1px solid transparent; white-space: nowrap; }
.due-chip:hover { border-color: var(--border); }
.due-chip.overdue { color: #fca5a5; background: rgba(239,68,68,0.12); }
.due-chip.soon { color: #fcd34d; background: rgba(245,158,11,0.10); }
.due-chip.done { color: var(--text-faint); }

/* ---------- list view ---------- */
.list-view { padding-bottom: 60px; }
.group-header { display: flex; align-items: center; gap: 8px; padding: 9px 18px; background: var(--bg-panel); border-bottom: 1px solid var(--border-soft); position: sticky; top: 0; z-index: 5; cursor: pointer; }
.group-title { font-weight: 700; font-size: 13px; display: flex; align-items: center; gap: 8px; }
.group-count { color: var(--text-faint); font-weight: 600; font-size: 11.5px; background: var(--bg-raised); border-radius: 20px; padding: 1px 8px; }
.group-meta { margin-left: auto; display: flex; gap: 10px; color: var(--text-faint); font-size: 11px; align-items:center; }
.task-row { display: flex; align-items: center; gap: 10px; padding: 0 18px; height: 42px; border-bottom: 1px solid var(--border-soft); background: var(--bg-app); cursor: pointer; }
.task-row:hover { background: var(--bg-panel); }
.task-row.dragging { opacity: 0.5; }
.task-row.drop-before { box-shadow: inset 0 2px 0 var(--accent); }
.task-row.drop-after { box-shadow: inset 0 -2px 0 var(--accent); }
.task-check { width: 17px; height: 17px; border-radius: 50%; border: 2px solid var(--text-faint); flex-shrink: 0; background: transparent; display:flex; align-items:center; justify-content:center; color:transparent; }
.task-check:hover { border-color: var(--green); }
.task-check.done { background: var(--green); border-color: var(--green); color: #fff; }
.task-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13.5px; min-width: 0; }
.task-name.done { text-decoration: line-through; color: var(--text-faint); }
.task-id { color: var(--text-faint); font-size: 11px; font-weight: 600; flex-shrink: 0; }
.task-tags { display: flex; gap: 4px; flex-shrink: 0; max-width: 180px; overflow: hidden; }
.task-fields { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.subtask-toggle { display: inline-flex; align-items: center; gap: 3px; color: var(--text-faint); font-size: 11px; background: var(--bg-raised); border-radius: 4px; padding: 2px 6px; border: none; }
.subtask-toggle:hover { color: var(--text); }
.subtask-row .task-name { padding-left: 22px; color: var(--text-dim); }
.add-task-row { display: flex; align-items: center; gap: 8px; padding: 8px 18px; color: var(--text-faint); cursor: pointer; font-size: 13px; border-bottom: 1px solid var(--border-soft); }
.add-task-row:hover { color: var(--accent); }
.inline-task-input { flex: 1; background: transparent; border: none; outline: none; color: var(--text); font-size: 13.5px; }

/* ---------- board ---------- */
.board { display: flex; gap: 12px; padding: 14px 16px; align-items: flex-start; min-height: 100%; overflow-x: auto; }
.board-col { width: 280px; min-width: 280px; background: var(--bg-panel); border-radius: 10px; display: flex; flex-direction: column; max-height: calc(100vh - 190px); }
.board-col.drag-over { outline: 2px dashed var(--accent); outline-offset: -2px; }
.board-col.drop-unavailable { opacity: .45; }
.board-col-head { display: flex; align-items: center; gap: 8px; padding: 11px 12px 8px; font-weight: 700; font-size: 12.5px; }
.board-col-head .cnt { color: var(--text-faint); font-weight: 600; }
.board-col-body { overflow-y: auto; padding: 4px 8px 8px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.board-card { background: var(--bg-raised); border: 1px solid var(--border-soft); border-radius: 8px; padding: 10px 12px; cursor: pointer; }
.board-card:hover { border-color: var(--border); background: var(--bg-hover); }
.board-card.dragging { opacity: 0.4; }
.board-card .bc-title { font-size: 13px; line-height: 1.35; margin-bottom: 8px; word-break: break-word; }
.board-card .bc-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.board-card .bc-id { color: var(--text-faint); font-size: 10.5px; font-weight: 700; }
.board-add { padding: 6px 12px 10px; color: var(--text-faint); font-size: 12.5px; cursor: pointer; border-radius: 6px; }
.board-add:hover { color: var(--accent); }
.board-card[draggable="true"] { touch-action: pan-y; }
.board-ghost { position: fixed; z-index: 300; pointer-events: none; opacity: 0.94; transform: rotate(1.5deg) scale(1.02); box-shadow: var(--shadow); margin: 0; }
body.board-touch-dragging { user-select: none; -webkit-user-select: none; }
body.board-touch-dragging .board, body.board-touch-dragging .board-col-body { overflow: hidden !important; }

/* ---------- calendar ---------- */
.calendar { padding: 14px 16px; }
.cal-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.cal-title { font-size: 16px; font-weight: 800; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); border: 1px solid var(--border-soft); border-radius: 10px; overflow: hidden; background: var(--bg-panel); }
.cal-dow { padding: 8px; text-align: center; font-size: 11px; font-weight: 700; color: var(--text-faint); background: var(--bg-raised); border-bottom: 1px solid var(--border-soft); }
.cal-cell { min-height: 104px; border-right: 1px solid var(--border-soft); border-bottom: 1px solid var(--border-soft); padding: 6px; display: flex; flex-direction: column; gap: 4px; }
.cal-cell:nth-child(7n) { border-right: none; }
.cal-cell.out { background: rgba(0,0,0,0.16); }
.cal-cell.today .cal-daynum { background: var(--accent); color: #fff; }
.cal-daynum { font-size: 11px; font-weight: 700; color: var(--text-dim); width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; border-radius: 50%; }
.cal-task { font-size: 10.5px; padding: 2px 6px; border-radius: 4px; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; font-weight: 600; }
.cal-more { font-size: 10px; color: var(--text-faint); padding: 0 6px; }

/* ---------- table ---------- */
.table-view { padding: 14px 16px; }
.table-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.table-scroll { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; background: var(--bg-panel); border-radius: 10px; overflow: hidden; }
.data-table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-faint); padding: 10px 12px; background: var(--bg-raised); border-bottom: 1px solid var(--border); white-space: nowrap; cursor:pointer; user-select:none; }
.data-table th:hover { color: var(--text); }
.data-table td { padding: 8px 12px; border-bottom: 1px solid var(--border-soft); font-size: 13px; vertical-align: middle; }
.data-table tr:hover td { background: var(--bg-hover); }
.data-table tr { cursor: pointer; }

/* custom-field cells in the table view */
.cf-chip { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 700; color: #fff; margin: 1px 2px 1px 0; white-space: nowrap; }
.cf-multi { display: inline-flex; flex-wrap: wrap; gap: 3px; }
.cf-check { font-weight: 800; }
.cf-check.on { color: var(--green); }
.cf-progress { display: inline-flex; align-items: center; gap: 6px; }
.progress-mini { display: inline-block; width: 54px; height: 7px; border-radius: 4px; background: var(--bg-hover); overflow: hidden; }
.progress-fill { display: block; height: 100%; background: var(--green); border-radius: 4px; }
.cf-rating { color: var(--yellow); letter-spacing: 1px; font-size: 12px; }

/* gantt */
.gantt-toolbar { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border-soft); }
.gantt-field { display: inline-flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--text-faint); font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; }
.gantt-date { width: 150px; }
.gantt-scale { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.gantt-scale button { background: var(--bg-input); color: var(--text-dim); border: none; padding: 8px 14px; font-size: 12px; font-weight: 700; cursor: pointer; }
.gantt-scale button.active { background: var(--accent); color: #fff; }
.gantt-presets { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.gantt-info { font-size: 12px; color: var(--text-dim); font-weight: 600; }
.gantt-hour-hint { font-size: 11px; color: var(--text-faint); }
.gantt-summary { padding: 8px 16px; font-size: 11.5px; color: var(--text-faint); }
.gantt { padding: 0 16px 14px; overflow-x: auto; }
.gantt-row { display: flex; align-items: center; height: 36px; border-bottom: 1px solid var(--border-soft); min-width: 900px; }
.gantt-label { width: 240px; min-width: 240px; padding-right: 12px; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.gantt-track { flex: 1; position: relative; height: 100%; }
.gantt-bar { position: absolute; top: 8px; height: 20px; background: var(--accent); border-radius: 5px; min-width: 8px; cursor: pointer; opacity: 0.92; display: flex; align-items: center; overflow: hidden; }
.gantt-bar:hover { opacity: 1; }
.gantt-bar.dragging { opacity: 1; box-shadow: 0 0 0 2px var(--accent-hover); cursor: grabbing; z-index: 5; }
.gantt-bar.clip-l { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.gantt-bar.clip-r { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.gantt-bar.point { min-width: 12px; }
.gantt-bar-name { font-size: 10.5px; font-weight: 700; color: #fff; padding: 0 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; text-shadow: 0 1px 2px rgba(0,0,0,0.4); }
.gantt-handle { position: absolute; top: 0; width: 7px; height: 100%; cursor: ew-resize; }
.gantt-handle.left { left: 0; border-top-left-radius: 5px; border-bottom-left-radius: 5px; }
.gantt-handle.right { right: 0; border-top-right-radius: 5px; border-bottom-right-radius: 5px; }
.gantt-handle:hover { background: rgba(255,255,255,0.35); }
.gantt-now { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--red); opacity: 0.75; pointer-events: none; z-index: 4; }
.gantt-head { display: flex; min-width: 900px; border-bottom: 1px solid var(--border); position: sticky; top: 0; }
.gantt-head .gantt-label { font-weight: 700; color: var(--text-faint); font-size: 11px; text-transform: uppercase; }
.gantt-head .gantt-track { display: flex; }
.gantt-day { flex: 1; text-align: center; font-size: 10px; color: var(--text-faint); padding: 8px 0; border-left: 1px solid var(--border-soft); min-width: 0; overflow: hidden; white-space: nowrap; }
.gantt-day.weekend { background: rgba(0,0,0,0.15); }

/* rich-text table size picker */
.table-picker { padding: 8px; }
.table-picker-grid { display: grid; grid-template-columns: repeat(8, 16px); grid-auto-rows: 16px; gap: 3px; }
.table-picker-cell { width: 16px; height: 16px; border: 1px solid var(--border); border-radius: 3px; background: var(--bg-input); cursor: pointer; }
.table-picker-cell.on { background: var(--accent); border-color: var(--accent-hover); }
.table-picker-label { margin-top: 8px; font-size: 12px; color: var(--text-dim); text-align: center; font-weight: 600; }
.dd-item.disabled { opacity: 0.5; cursor: default; }

/* ---------- task pane ---------- */
.pane-overlay { position: fixed; inset: 0; background: rgba(10, 10, 16, 0.55); z-index: 60; display: flex; justify-content: flex-end; animation: fadeIn 0.15s; }
@keyframes fadeIn { from { opacity: 0; } }
.task-pane { width: 720px; max-width: 96vw; height: 100%; background: var(--bg-panel); border-left: 1px solid var(--border); display: flex; flex-direction: column; animation: slideIn 0.18s ease-out; overflow: hidden; }
@keyframes slideIn { from { transform: translateX(40px); opacity: 0.6; } }
.pane-head { display: flex; align-items: center; gap: 10px; padding: 12px 18px; border-bottom: 1px solid var(--border-soft); }
.pane-head .task-id { font-size: 12px; }
.pane-title-input { flex: 1; background: transparent; border: none; outline: none; color: var(--text); font-size: 17px; font-weight: 700; }
.pane-body { flex: 1; overflow-y: auto; display: flex; }
.pane-main { flex: 1; padding: 18px 20px; min-width: 0; }
.pane-side { width: 232px; min-width: 232px; border-left: 1px solid var(--border-soft); padding: 16px 14px; display: flex; flex-direction: column; gap: 13px; overflow-y: auto; }
.side-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-faint); font-weight: 700; margin-bottom: 5px; }
.side-value { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.desc-editor { min-height: 110px; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; font-size: 13.5px; line-height: 1.55; outline: none; }
.desc-editor:empty:before { content: attr(data-placeholder); color: var(--text-faint); }
.desc-editor p { margin-bottom: 6px; }
.desc-toolbar { display: flex; gap: 4px; margin-bottom: 8px; }
.desc-toolbar button { background: var(--bg-raised); border: 1px solid var(--border); color: var(--text-dim); border-radius: 4px; padding: 3px 9px; font-size: 12px; }
.desc-toolbar button:hover { color: var(--text); }
.mention { color: #a5b4fc; background: var(--accent-soft); padding: 1px 5px; border-radius: 4px; font-weight: 600; }

.pane-section { margin-top: 22px; }
.pane-section-head { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-dim); margin-bottom: 10px; }
.pane-section-head .add-link { margin-left: auto; color: var(--accent); cursor: pointer; text-transform: none; letter-spacing: 0; font-weight: 600; font-size: 12px; background: none; border: none; }

.subtask-row-pane { display: flex; align-items: center; gap: 9px; padding: 7px 8px; border-radius: 6px; cursor: pointer; }
.subtask-row-pane:hover { background: var(--bg-hover); }
.subtask-name { flex: 1; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.subtask-name.done { text-decoration: line-through; color: var(--text-faint); }

.checklist-block { background: var(--bg-raised); border: 1px solid var(--border-soft); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; }
.checklist-head { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 13px; margin-bottom: 4px; }
.checklist-progress { flex: 1; height: 4px; background: var(--bg-input); border-radius: 3px; overflow: hidden; max-width: 120px; }
.checklist-progress div { height: 100%; background: var(--accent); }
.check-item { display: flex; align-items: center; gap: 9px; padding: 4px 2px; font-size: 13px; }
.check-box { width: 15px; height: 15px; border-radius: 4px; border: 2px solid var(--text-faint); background: transparent; flex-shrink: 0; display: flex; align-items: center; justify-content: center; color: transparent; }
.check-box.checked { background: var(--accent); border-color: var(--accent); color: #fff; }
.check-item.done .check-name { text-decoration: line-through; color: var(--text-faint); }
.check-name { flex: 1; }

.dep-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; background: var(--bg-raised); border-radius: 6px; margin-bottom: 6px; font-size: 12.5px; }
.dep-type { font-size: 10px; font-weight: 800; text-transform: uppercase; padding: 2px 6px; border-radius: 4px; }
.dep-type.waiting_on { background: rgba(245,158,11,0.15); color: #fbbf24; }
.dep-type.blocks { background: rgba(239,68,68,0.15); color: #f87171; }

.comment { display: flex; gap: 10px; margin-bottom: 14px; }
.comment-body { flex: 1; min-width: 0; }
.comment-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 3px; flex-wrap: wrap; }
.comment-author { font-weight: 700; font-size: 12.5px; }
.comment-time { color: var(--text-faint); font-size: 11px; }
.comment-text { font-size: 13px; line-height: 1.5; color: var(--text); background: var(--bg-raised); padding: 9px 12px; border-radius: 4px 10px 10px 10px; word-break: break-word; }
.comment-text.system { background: transparent; border: 1px dashed var(--border); color: var(--text-dim); font-style: italic; }
.comment-actions { display: flex; gap: 10px; margin-top: 4px; flex-wrap: wrap; }
.comment-actions button { background: none; border: none; color: var(--text-faint); font-size: 11px; cursor: pointer; }
.comment-actions button:hover { color: var(--accent); }
.comment-actions button.message-starred { color: #e3aa36; }
.comment.message-jump-highlight .comment-text { outline: 2px solid #e3aa36; outline-offset: 2px; }
.starred-message-list { display: flex; flex-direction: column; gap: 10px; }
.starred-message-card { padding: 10px 14px; border: 1px solid var(--border-soft); border-radius: 10px; background: var(--bg-raised); }
.starred-message-open { display: block; width: 100%; padding: 2px 0 8px; border: 0; background: transparent; text-align: left; color: var(--text); cursor: pointer; }
.starred-message-open:hover .starred-message-title, .starred-message-open:focus-visible .starred-message-title { color: var(--accent); }
.starred-message-open:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.starred-message-title { font-weight: 750; margin-bottom: 3px; }
.starred-message-excerpt { margin: 8px 0; color: var(--text); font-size: 13px; line-height: 1.45; overflow-wrap: anywhere; }
.comment-input-wrap { display: flex; gap: 10px; }
.comment-input { flex: 1; min-width: 0; overflow-wrap: break-word; background: var(--bg-input); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; min-height: 42px; outline: none; font-size: 13px; color: var(--text); }
.comment-input:focus { border-color: var(--accent); }

.activity-row { display: flex; gap: 10px; padding: 5px 0; font-size: 12.5px; color: var(--text-dim); align-items: baseline; }
.activity-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--border); flex-shrink: 0; position: relative; top: -1px; }
.activity-time { margin-left: auto; color: var(--text-faint); font-size: 11px; white-space: nowrap; }

.time-row { display: flex; align-items: center; gap: 10px; padding: 6px 8px; background: var(--bg-raised); border-radius: 6px; margin-bottom: 6px; font-size: 12.5px; }
.time-dur { font-weight: 700; color: #a5b4fc; }
.timer-live { display: inline-flex; align-items: center; gap: 8px; background: rgba(34,197,94,0.12); border: 1px solid rgba(34,197,94,0.4); color: #4ade80; border-radius: 20px; padding: 4px 12px; font-size: 12px; font-weight: 700; }
.attach-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: var(--bg-raised); border-radius: 6px; margin-bottom: 6px; font-size: 12.5px; }
.attach-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.cf-row { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; }
.cf-name { width: 105px; min-width: 105px; font-size: 11.5px; color: var(--text-dim); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cf-value { flex: 1; }
.cf-value .input, .cf-value .select { padding: 5px 8px; font-size: 12px; }
.progress-bar { height: 7px; background: var(--bg-input); border-radius: 4px; overflow: hidden; flex: 1; }
.progress-bar div { height: 100%; background: var(--accent); }
.rating-stars { display: flex; gap: 2px; }
.rating-stars span { color: var(--text-faint); cursor: pointer; font-size: 15px; }
.rating-stars span.on { color: #fbbf24; }

/* ---------- dropdowns & popovers ---------- */
.dropdown-backdrop { position: fixed; inset: 0; z-index: 120; }
.dropdown { position: fixed; z-index: 121; background: var(--bg-raised); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); padding: 6px; min-width: 190px; max-height: 340px; overflow-y: auto; }
.dd-item { display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 10px; border-radius: 6px; background: none; border: none; color: var(--text); font-size: 13px; text-align: left; cursor: pointer; }
.dd-item:hover { background: var(--bg-hover); }
.dd-item.active { background: var(--accent-soft); }
.dd-item .check { margin-left: auto; color: var(--accent); display: flex; }
.dd-item.danger { color: #f87171; }
.dd-sep { height: 1px; background: var(--border); margin: 5px 4px; }
.dd-label { font-size: 10.5px; text-transform: uppercase; color: var(--text-faint); font-weight: 800; padding: 6px 10px 4px; letter-spacing: 0.5px; }
.dd-search { width: calc(100% - 8px); margin: 2px 4px 6px; background: var(--bg-input); border: 1px solid var(--border); border-radius: 6px; padding: 7px 9px; outline: none; color: var(--text); font-size: 12.5px; }
.color-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; padding: 6px; }
.color-swatch { width: 22px; height: 22px; border-radius: 6px; cursor: pointer; border: 2px solid transparent; }
.color-swatch.sel { border-color: #fff; }
.date-pop { padding: 10px; }
.date-pop input { margin-bottom: 8px; }

/* ---------- modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(10,10,16,0.6); z-index: 90; display: flex; align-items: center; justify-content: center; animation: fadeIn 0.12s; }
.modal { background: var(--bg-panel); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); width: 480px; max-width: calc(100vw - 32px); max-height: calc(100vh - 64px); display: flex; flex-direction: column; }
.modal.wide { width: 720px; }
.modal-head { display: flex; align-items: center; padding: 16px 20px 12px; }
.modal-title { font-size: 16px; font-weight: 800; flex: 1; }
.modal-body { padding: 6px 20px 16px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 20px 18px; }
.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 12px; font-weight: 600; color: var(--text-dim); margin-bottom: 6px; }

/* ---------- toast ---------- */
#toast-root { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--bg-raised); border: 1px solid var(--border); color: var(--text); padding: 10px 18px; border-radius: 8px; box-shadow: var(--shadow); font-size: 13px; animation: toastIn 0.18s; max-width: 480px; }
.toast.error { border-color: rgba(239,68,68,0.5); background: #3a1f27; }
.toast.success { border-color: rgba(34,197,94,0.4); }
@keyframes toastIn { from { transform: translateY(8px); opacity: 0; } }

/* ---------- notifications ---------- */
.notif-panel { width: 380px; max-height: 480px; }
.notif-item { display: flex; gap: 10px; padding: 10px; border-radius: 8px; cursor: pointer; align-items: flex-start; }
.notif-item:hover { background: var(--bg-hover); }
.notif-item.unread { background: var(--accent-soft); }
.notif-text { flex: 1; font-size: 12.5px; line-height: 1.4; }
.notif-time { color: var(--text-faint); font-size: 10.5px; margin-top: 3px; }

/* ---------- search modal ---------- */
.search-modal { width: 640px; max-width: calc(100vw - 32px); align-self: flex-start; margin-top: 10vh; }
.search-input-row { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border-soft); }
.search-input-row input { flex: 1; background: none; border: none; outline: none; color: var(--text); font-size: 15px; }
.search-results { max-height: 52vh; overflow-y: auto; padding: 8px; }
.sr-group { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-faint); font-weight: 800; padding: 8px 10px 4px; }
.sr-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.sr-item:hover, .sr-item.sel { background: var(--bg-hover); }
.sr-title { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sr-sub { font-size: 11px; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- pages (dashboard/settings) ---------- */
.page { padding: 20px 24px; overflow-y: auto; flex: 1; }
.page-title { font-size: 19px; font-weight: 800; margin-bottom: 4px; }
.page-sub { color: var(--text-dim); font-size: 13px; margin-bottom: 20px; }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.widget { background: var(--bg-panel); border: 1px solid var(--border-soft); border-radius: 12px; padding: 16px; }
.widget h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-dim); margin-bottom: 12px; }
.big-num { font-size: 30px; font-weight: 800; }
.big-num small { font-size: 13px; color: var(--text-faint); font-weight: 600; }
.stat-row { display: flex; align-items: center; gap: 9px; padding: 4px 0; font-size: 12.5px; }
.stat-row .bar { flex: 1; height: 6px; background: var(--bg-input); border-radius: 4px; overflow: hidden; }
.stat-row .bar div { height: 100%; border-radius: 4px; }
.stat-num { color: var(--text-dim); min-width: 24px; text-align: right; }
.legend-dot { width: 9px; height: 9px; border-radius: 3px; flex-shrink: 0; }

.settings-layout { display: flex; gap: 0; flex: 1; overflow: hidden; }
.settings-nav { width: 220px; min-width: 220px; border-right: 1px solid var(--border-soft); padding: 16px 10px; overflow-y: auto; background: var(--bg-panel); }
.chat-rail { width: 250px; min-width: 250px; }
.settings-content { flex: 1; overflow-y: auto; padding: 22px 26px; }
.set-card { background: var(--bg-panel); border: 1px solid var(--border-soft); border-radius: 12px; padding: 18px; margin-bottom: 16px; max-width: 860px; }
.set-card h3 { font-size: 14px; font-weight: 800; margin-bottom: 4px; }
.set-card .sub { color: var(--text-dim); font-size: 12px; margin-bottom: 14px; }
.member-row { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--border-soft); }
.member-row:last-child { border-bottom: none; }
.member-info { flex: 1; min-width: 0; }
.member-name { font-weight: 700; font-size: 13px; }
.member-email { color: var(--text-faint); font-size: 11.5px; }
.role-pill { font-size: 10.5px; font-weight: 800; text-transform: uppercase; padding: 3px 9px; border-radius: 20px; background: var(--bg-raised); color: var(--text-dim); border: 1px solid var(--border); cursor: pointer; }
.status-editor-row { display: flex; align-items: center; gap: 9px; padding: 7px 4px; border-bottom: 1px solid var(--border-soft); }
.status-swatch { width: 14px; height: 14px; border-radius: 4px; cursor: pointer; flex-shrink: 0; }
.mini-table { width: 100%; border-collapse: collapse; }
.mini-table th { text-align: left; color: var(--text-faint); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.5px; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.mini-table td { padding: 8px; border-bottom: 1px solid var(--border-soft); font-size: 12.5px; }
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 60px 20px; color: var(--text-faint); text-align: center; }
.empty-state .big { font-size: 15px; font-weight: 700; color: var(--text-dim); }

/* automations builder */
.auto-card { background: var(--bg-raised); border: 1px solid var(--border-soft); border-radius: 10px; padding: 14px; margin-bottom: 10px; }
.auto-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.auto-name { font-weight: 700; font-size: 13.5px; flex: 1; }
.auto-desc { font-size: 12px; color: var(--text-dim); line-height: 1.5; }
.auto-desc b { color: #c4b8fd; }
.switch { position: relative; width: 34px; height: 19px; background: var(--bg-input); border-radius: 20px; border: 1px solid var(--border); cursor: pointer; flex-shrink: 0; }
.switch.on { background: var(--accent); border-color: var(--accent); }
.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; background: #fff; border-radius: 50%; transition: left 0.15s; }
.switch.on::after { left: 17px; }

.rule-line { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.rule-word { color: var(--text-dim); font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; }
.rule-select { background: var(--bg-input); border: 1px solid var(--border); color: #c4b8fd; border-radius: 6px; padding: 5px 9px; font-size: 12.5px; font-weight: 600; outline: none; }

/* trash */
.trash-row { display: flex; align-items: center; gap: 12px; padding: 9px 6px; border-bottom: 1px solid var(--border-soft); font-size: 13px; }
.trash-row .grow { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* misc */
.row-flex { display: flex; align-items: center; gap: 8px; }
.spacer { flex: 1; }
.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.small { font-size: 11.5px; }
.mt8 { margin-top: 8px; } .mt16 { margin-top: 16px; } .mb8 { margin-bottom: 8px; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.ai-chip { background: linear-gradient(90deg, rgba(123,104,238,0.2), rgba(59,130,246,0.2)); border: 1px solid rgba(123,104,238,0.4); color: #c4b8fd; font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 20px; display: inline-flex; gap: 5px; align-items: center; cursor: pointer; }
.divider { height: 1px; background: var(--border-soft); margin: 12px 0; }

/* ---------- mention kinds ---------- */
.mention[data-task] { color: #2dd4bf; background: rgba(20, 184, 166, 0.16); }
.mention { color: #a5b4fc; background: var(--accent-soft); padding: 1px 5px; border-radius: 4px; font-weight: 600; }
[data-theme="light"] .mention { color: #5b4bd6; }
[data-theme="light"] .mention[data-task] { color: #0f766e; }
[data-theme="sepia"] .mention { color: #8a5a2b; }
[data-theme="sepia"] .mention[data-task] { color: #206a5e; }

/* ---------- chat mention badge ---------- */
.mention-at { color: var(--accent); font-weight: 800; font-size: 12px; margin-left: 2px; }
[data-theme="light"] .mention-at { color: #5b4bd6; }

/* ---------- non-working days & holidays (calendar / gantt) ---------- */
.cal-cell.nonworking { background: rgba(120, 120, 140, 0.07); }
.cal-cell.holiday { background: rgba(239, 68, 68, 0.07); }
.cal-holiday { font-size: 9.5px; color: #f87171; font-weight: 700; padding: 1px 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gantt-day.nonworking { background: rgba(120, 120, 140, 0.14); }
.gantt-day.holiday { background: rgba(239, 68, 68, 0.16); color: #f87171; }

/* ---------- themes ---------- */
[data-theme="light"] {
  --brand-primary: #554de8;
  --brand-secondary: #087f75;
  --brand-glow: rgba(85, 77, 232, 0.18);
  --bg-app: #f2f3f8;
  --bg-sidebar: #ffffff;
  --bg-panel: #ffffff;
  --bg-raised: #eef0f7;
  --bg-hover: #e5e8f2;
  --bg-active: #dcdff0;
  --bg-input: #f7f8fc;
  --border: #d5d9e5;
  --border-soft: #e3e6ef;
  --text: #23263a;
  --text-dim: #5c6175;
  --text-faint: #8b90a3;
  --accent: #554de8;
  --accent-hover: #443cc8;
  --accent-soft: rgba(85, 77, 232, 0.12);
  --shadow: 0 10px 30px rgba(35, 45, 90, 0.14);
}
[data-theme="light"] .status-pill { color: #fff; }
[data-theme="light"] .btn { color: #fff; }
[data-theme="light"] .auth-wrap { background: radial-gradient(1000px 600px at 20% 10%, rgba(108,92,231,0.10), transparent 60%), var(--bg-app); }
[data-theme="light"] .comment-text { background: var(--bg-raised); }
[data-theme="light"] .toast { background: #2c2f42; color: #f4f5fa; border-color: #2c2f42; }

[data-theme="midnight"] {
  --brand-primary: #7898ff;
  --brand-secondary: #2dd4bf;
  --brand-glow: rgba(120, 152, 255, 0.25);
  --bg-app: #0d1322;
  --bg-sidebar: #101830;
  --bg-panel: #131c33;
  --bg-raised: #1a2542;
  --bg-hover: #213056;
  --bg-active: #293a66;
  --bg-input: #0b1120;
  --border: #2b3a5e;
  --border-soft: #223052;
  --text: #dfe7f6;
  --text-dim: #97a4c2;
  --text-faint: #67748f;
  --accent: #7898ff;
  --accent-hover: #9aafff;
  --accent-soft: rgba(120, 152, 255, 0.17);
  --shadow: 0 12px 34px rgba(2, 6, 18, 0.6);
}
[data-theme="midnight"] .btn { color: #0b1120; }
[data-theme="midnight"] .mention { color: #b8d4ff; }

[data-theme="sepia"] {
  --brand-primary: #7153a6;
  --brand-secondary: #257d72;
  --brand-glow: rgba(113, 83, 166, 0.18);
  --bg-app: #efe6d3;
  --bg-sidebar: #e9dcc2;
  --bg-panel: #f7efdd;
  --bg-raised: #eee2c9;
  --bg-hover: #e6d8ba;
  --bg-active: #ddccaa;
  --bg-input: #fbf5e8;
  --border: #d3c19c;
  --border-soft: #e0d1b1;
  --text: #3c3324;
  --text-dim: #6e6249;
  --text-faint: #95886b;
  --accent: #7153a6;
  --accent-hover: #5d438d;
  --accent-soft: rgba(113, 83, 166, 0.14);
  --green: #4c7a34;
  --yellow: #a4791c;
  --red: #b0413e;
  --blue: #46688f;
  --shadow: 0 10px 30px rgba(90, 70, 40, 0.22);
}
[data-theme="sepia"] .btn { color: #fbf5e8; }
[data-theme="sepia"] .status-pill { color: #fff; }
[data-theme="sepia"] .comment-text { background: var(--bg-raised); }

/* ---------- theme picker ---------- */
.theme-card { display: flex; gap: 12px; align-items: center; border: 2px solid var(--border-soft); border-radius: 10px; padding: 12px; margin-bottom: 10px; cursor: pointer; max-width: 460px; }
.theme-card:hover { border-color: var(--border); }
.theme-card.selected { border-color: var(--accent); background: var(--accent-soft); }
.theme-swatch { width: 56px; height: 40px; border-radius: 8px; flex-shrink: 0; border: 1px solid rgba(128,128,128,0.35); }
.theme-name { font-weight: 800; font-size: 13.5px; }
.theme-desc { font-size: 11.5px; color: var(--text-dim); }

/* ---------- work schedule ---------- */
.day-toggle { display: inline-flex; flex-direction: column; align-items: center; gap: 5px; padding: 9px 6px; border-radius: 9px; border: 1px solid var(--border); cursor: pointer; min-width: 58px; background: var(--bg-raised); }
.day-toggle.on { border-color: var(--accent); background: var(--accent-soft); }
.day-toggle b { font-size: 11.5px; }
.day-toggle span { font-size: 9.5px; color: var(--text-faint); }

/* ---------- mention autocomplete ---------- */
.mention-popup { position: fixed; z-index: 130; width: 290px; max-height: 300px; overflow-y: auto; background: var(--bg-raised); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); padding: 6px; }
.mention-item { display: flex; align-items: center; gap: 9px; padding: 7px 9px; border-radius: 7px; cursor: pointer; }
.mention-item.sel { background: var(--accent-soft); }
.mention-item-name { font-size: 12.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mention-item-sub { font-size: 10.5px; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seniority-chip { display: inline-flex; align-items: center; justify-content: center; font-size: 9px; font-weight: 800; letter-spacing: 0.3px; padding: 1px 6px; border-radius: 20px; background: var(--bg-active); color: var(--text-dim); border: 1px solid var(--border); text-transform: uppercase; }

/* ---------- rich text content: lists & tables stay on screen ---------- */
.desc-editor ul, .desc-editor ol, .comment-text ul, .comment-text ol { margin: 4px 0 8px 0; padding-inline-start: 22px; }
.desc-editor li, .comment-text li { margin-bottom: 3px; }
.desc-editor, .comment-text { overflow-wrap: anywhere; word-break: break-word; }
.desc-editor table, .comment-text table { border-collapse: collapse; width: 100%; max-width: 100%; margin: 8px 0; table-layout: fixed; }
.desc-editor td, .comment-text td, .desc-editor th, .comment-text th { border: 1px solid var(--border); padding: 6px 8px; font-size: 12.5px; overflow-wrap: anywhere; min-width: 40px; }
.desc-editor th, .comment-text th { background: var(--bg-raised); font-weight: 800; }
.desc-editor img, .comment-text img { max-width: 100%; }

/* ---------- task pane: center (focus) mode ---------- */
.pane-overlay.centered { justify-content: center; align-items: center; padding: 3vh 2vw; }
.pane-overlay.centered .task-pane { width: min(1150px, 96vw); height: 94vh; border-radius: 14px; border: 1px solid var(--border); box-shadow: var(--shadow); animation: popIn 0.16s ease-out; }
@keyframes popIn { from { transform: scale(0.98); opacity: 0.4; } }
.pane-mode-btn { display: inline-flex; align-items: center; gap: 5px; }

/* ---------- chat attachments ---------- */
.msg-attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.msg-attach { display: flex; align-items: center; gap: 8px; background: var(--bg-panel); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; font-size: 12px; max-width: 280px; }
.msg-attach img { max-width: 220px; max-height: 160px; border-radius: 6px; display: block; }
.msg-attach .name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attach-btn { position: relative; }

/* ---------- analytics ---------- */
.analytics-table { width: 100%; border-collapse: collapse; }
.analytics-table th { text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-faint); padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; cursor: pointer; user-select: none; }
.analytics-table th:hover { color: var(--text); }
.analytics-table td { padding: 9px 10px; border-bottom: 1px solid var(--border-soft); font-size: 12.5px; vertical-align: top; }
.analytics-table tr.expandable { cursor: pointer; }
.analytics-table tr.expandable:hover td { background: var(--bg-hover); }
.idx-pill { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 800; }
.idx-good { background: rgba(34, 197, 94, 0.15); color: #4ade80; }
.idx-warn { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.idx-bad { background: rgba(239, 68, 68, 0.16); color: #f87171; }
.detail-panel { background: var(--bg-raised); border: 1px solid var(--border-soft); border-radius: 10px; padding: 14px; margin: 6px 0 14px; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.flag-row { display: flex; gap: 8px; align-items: baseline; padding: 4px 0; font-size: 12px; border-bottom: 1px dashed var(--border-soft); }
.flag-row .when { margin-left: auto; color: var(--text-faint); font-size: 10.5px; white-space: nowrap; }
.reopen-flag { color: #f87171; font-weight: 700; }

/* ---------- responsive ---------- */
.table-scroll { overflow-x: auto; width: 100%; }
@media (max-width: 1100px) {
  .pane-side { width: 200px; min-width: 200px; }
  .search-trigger { min-width: 130px; }
}
@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 70; transform: translateX(-105%); transition: transform 0.18s ease; box-shadow: var(--shadow); }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .hamburger { display: inline-flex !important; }
  .task-pane { width: 100vw; max-width: 100vw; }
  .pane-body { flex-direction: column; }
  .pane-side { width: 100%; min-width: 0; border-left: none; border-top: 1px solid var(--border-soft); flex-direction: row; flex-wrap: wrap; gap: 14px; }
  .pane-side > div { min-width: 140px; }
  .settings-layout { flex-direction: column; overflow-y: auto; }
  .settings-nav { width: 100%; min-width: 0; display: flex; gap: 4px; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--border-soft); padding: 8px; }
  .settings-nav .nav-item { white-space: nowrap; width: auto; }
  .settings-content { padding: 14px; }
  .chat-page { flex-direction: column; }
  .chat-rail { width: 100%; min-width: 0; flex: 0 0 auto; max-height: 190px; display: block; border-right: none; border-bottom: 1px solid var(--border-soft); overflow-y: auto; }
  .board-col { width: 240px; min-width: 240px; }
  .search-trigger { min-width: 44px; }
  .search-trigger span:not(.icon-wrap), .search-trigger kbd { display: none; }
  /* wide tables (members, finance P&L, employee lists) scroll inside their card
     instead of squeezing columns into unreadable slivers */
  .set-card, .widget, .fin-items { overflow-x: auto; }
  .set-card table, .widget table { min-width: max-content; }
}
@media (max-width: 640px) {
  .modal { width: calc(100vw - 20px); }
  .topbar { gap: 6px; padding: 0 10px; }
  .crumb .part { max-width: 110px; }
  .view-toolbar { gap: 6px; }
  .toolbar-btn { padding: 4px 8px; font-size: 11px; }
  .page { padding: 14px 12px; }
  .cal-cell { min-height: 70px; }
  .task-row { padding: 0 10px; gap: 6px; }
  .task-tags { display: none; }
  .auth-card { padding: 22px; }
  .chat-rail { max-height: 150px; }
  .fin-controls { gap: 8px; }
  .fin-date { width: 130px; }
  .finance-page { padding: 14px 12px; }
}
.hamburger { display: none; }


/* ---------- finance (owner-only pricing & cost analytics) ---------- */
.finance-page { padding: 18px 22px; }
.fin-controls { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.fin-field { display: inline-flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--text-faint); font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; }
.fin-date { width: 150px; }
.fin-presets { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.fin-currency { font-size: 12px; font-weight: 800; color: var(--text-dim); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 6px 10px; background: var(--bg-raised); }
.fin-body { padding-bottom: 30px; }
.fin-items { margin-top: 6px; }
.fin-cat { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 700; background: var(--bg-active); color: var(--text-dim); text-transform: capitalize; }
.fin-cat.cat-salary { background: rgba(123,104,238,0.22); color: #a99cf5; }
.fin-cat.cat-server { background: rgba(20,184,166,0.18); color: #2dd4bf; }
.fin-cat.cat-marketing { background: rgba(236,72,153,0.18); color: #f472b6; }
.fin-status { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.4px; }
.fin-status.active { color: var(--green); }
.fin-status.stopped { color: var(--text-faint); }
tr.fin-stopped td { opacity: 0.5; background: rgba(120,120,140,0.06); }
tr.fin-separator td { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-faint); background: var(--bg-raised); padding: 6px 12px; border-bottom: 1px solid var(--border-soft); }
.fin-stop-reason { font-size: 11px; color: var(--text-faint); font-style: italic; margin-top: 3px; }
.fin-alloc-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.alloc-chip { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; background: var(--accent-soft); color: var(--text); white-space: nowrap; }
.alloc-chip.unallocated { background: var(--bg-active); color: var(--text-faint); }
.fin-detail { padding: 10px 4px; }
.fin-detail-row td { background: var(--bg-panel); cursor: default; }
tr.fin-expanded td { background: var(--bg-hover); }
.fin-timeline { border-left: 2px solid var(--border); margin: 4px 0 10px 6px; padding-left: 14px; }
.fin-timeline-row { display: flex; align-items: baseline; gap: 10px; padding: 5px 0; border-bottom: 1px dashed var(--border-soft); font-size: 12.5px; flex-wrap: wrap; }
.fin-timeline-date { font-weight: 700; color: var(--text-dim); min-width: 84px; }
.fin-timeline-row.fin-superseded { opacity: 0.75; }
.fin-timeline-row.fin-stopped { opacity: 0.5; }
.fin-pl { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-dim); align-items: center; }
.fin-org-row td { background: var(--bg-raised); }
.fin-total-row td { background: var(--bg-active); border-top: 2px solid var(--border); }
.fin-audit { display: flex; flex-direction: column; gap: 6px; }
.fin-audit-row { display: flex; align-items: baseline; gap: 12px; background: var(--bg-panel); border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 9px 13px; font-size: 12.5px; }
.fin-action { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.5px; padding: 2px 8px; border-radius: 20px; background: var(--bg-active); color: var(--text-dim); min-width: 78px; text-align: center; }
.fin-action.act-created { background: rgba(34,197,94,0.16); color: #4ade80; }
.fin-action.act-stopped { background: rgba(239,68,68,0.16); color: #f87171; }
.fin-action.act-resumed { background: rgba(59,130,246,0.16); color: #60a5fa; }
.fin-action.act-superseded { background: rgba(245,158,11,0.16); color: #fbbf24; }
.fin-space { border: 1px solid var(--border-soft); }

/* ---------- line chart ---------- */
.chart-wrap { margin-top: 10px; }
.line-chart text { font-size: 10px; fill: var(--text-faint); font-family: inherit; }
.chart-legend { display: flex; gap: 16px; margin-top: 8px; flex-wrap: wrap; }
.chart-legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-dim); font-weight: 600; }
.chart-legend-swatch { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.fin-good { color: var(--green); font-weight: 700; }
.fin-bad { color: var(--red); font-weight: 700; }
.fin-tone-good { color: var(--green); }
.fin-tone-bad { color: var(--red); }
.fin-tone-neutral { color: var(--text); }
.small.mt8.over { color: var(--red); font-weight: 700; }

/* ---------- finance round 2: charts, hours, down time ---------- */
.fin-charts-row { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-start; }
.fin-charts-row > .widget { flex: 1; min-width: 300px; }
.fin-charts-row > div { min-width: 240px; }
.fin-mode-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.fin-mode-toggle button { background: var(--bg-input); color: var(--text-dim); border: none; padding: 6px 12px; font-size: 12px; font-weight: 700; cursor: pointer; }
.fin-mode-toggle button.active { background: var(--accent); color: #fff; }
.pie-wrap { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 6px 0; }
.pie-chart { flex-shrink: 0; }
.pie-slice { stroke: var(--bg-panel); stroke-width: 1.5; }
.pie-legend { display: flex; flex-direction: column; gap: 5px; min-width: 140px; }
.pie-legend-item { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-dim); }
.pie-legend-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-transform: capitalize; }
.pie-legend-value { font-weight: 700; color: var(--text); white-space: nowrap; }
.pie-empty { padding: 18px 6px; }
.bar-chart-wrap { padding: 6px 0; }
.bar-chart text { font-size: 10px; fill: var(--text-faint); font-family: inherit; }
.alloc-chip.hours { background: var(--bg-active); }
.alloc-chip.downtime { background: rgba(239,68,68,0.14); color: #fca5a5; }
.alloc-chip.raci { background: rgba(123,104,238,0.16); color: #c4b5fd; }
.raci-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; font-size: 9.5px; font-weight: 800; letter-spacing: 0.4px; padding: 1px 5px; border-radius: 20px; border: 1px solid var(--border); background: var(--bg-active); color: var(--text-dim); text-transform: uppercase; vertical-align: middle; }
.raci-badge.raci-responsible { background: rgba(34,197,94,0.14); color: #86efac; border-color: rgba(34,197,94,0.35); }
.raci-badge.raci-accountable { background: rgba(123,104,238,0.18); color: #c4b5fd; border-color: rgba(123,104,238,0.4); }
.raci-badge.raci-consulted { background: rgba(245,158,11,0.14); color: #fcd34d; border-color: rgba(245,158,11,0.35); }
.raci-badge.raci-informed { background: rgba(59,130,246,0.14); color: #93c5fd; border-color: rgba(59,130,246,0.35); }
tr.fin-down-row td { background: rgba(239,68,68,0.05); }

/* Flexible containers must be allowed to shrink inside the viewport. */
.layout { height: 100dvh; }
#page-content, .chat-page, .chat-main, .settings-layout, .settings-content { min-height: 0; min-width: 0; }
.chat-main > .pane-head, .chat-main > :last-child { flex-shrink: 0; }
.comment-body, .comment-input, .docs-content, .widget { min-width: 0; }
.comment-text, .notif-text, .desc-editor { overflow-wrap: anywhere; }
.comment-text img, .desc-editor img { max-width: 100%; height: auto; }
.comment-text pre, .desc-editor pre { max-width: 100%; overflow-x: auto; }
.dropdown { max-width: calc(100vw - 16px); max-height: min(480px, calc(100dvh - 16px)); }
.sidebar-scrim, .chat-conversations { display: none; }
.sound-setting { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--border-soft); }
.sound-setting label { cursor: pointer; gap: 10px; }
.sound-setting input { width: 18px; height: 18px; accent-color: var(--accent); }

@media (max-width: 900px) {
  body.sidebar-open .sidebar-scrim { display: block; position: fixed; inset: 0; z-index: 69; background: rgba(0,0,0,.5); border: 0; }
  .sidebar { width: min(300px, 85vw); min-width: 0; }
  .docs-page { flex-direction: column; }
  .docs-page .docs-tree, .docs-page .docs-content { width: 100% !important; min-width: 0 !important; flex: auto !important; }
  .docs-tree { max-height: 32dvh; overflow-y: auto; }
  .chat-conversations { display: flex; flex-shrink: 0; justify-content: flex-start; border-radius: 0; padding: 10px 14px; border-bottom: 1px solid var(--border-soft); }
  .chat-page .chat-rail { max-height: none; flex: 1; }
  .chat-page:not(.chat-room-open) .chat-main { display: none !important; }
  .chat-page.chat-room-open .chat-rail { display: none; }
  .chat-page.chat-show-conversations .chat-rail { display: block; }
  .chat-page.chat-show-conversations .chat-main { display: none !important; }
  .pane-overlay.centered { padding: 0; }
  .pane-overlay.centered .task-pane { width: 100%; max-width: 100%; height: 100dvh; border-radius: 0; }
  .pane-body > .pane-main, .pane-body > .pane-side { flex: 0 0 auto; overflow: visible; }
  .settings-nav { flex-shrink: 0; }
}

@media (max-width: 640px) {
  .topbar { padding-top: env(safe-area-inset-top); height: auto; min-height: 52px; }
  .topbar-right { gap: 2px; flex-shrink: 0; }
  .topbar .ai-chip { display: none; }
  .topbar .search-trigger { min-width: 36px; width: 36px; padding: 8px; }
  .topbar .search-label, .topbar .search-trigger kbd { display: none; }
  .topbar .crumb { flex: 1; overflow: hidden; font-size: 12px; }
  .topbar .crumb .part:not(.current), .topbar .crumb .sep { display: none; }
  .topbar .crumb .part.current { max-width: none; }
  #timer-chips { max-width: 96px; overflow-x: auto; }
  .timer-live { flex-shrink: 0; }
  .dash-grid { grid-template-columns: minmax(0, 1fr); }
  .page, .settings-content, .finance-page { padding: 14px 12px; }
  .page-title { font-size: 18px; }
  .page-sub { margin-bottom: 14px; }
  .widget, .set-card { padding: 12px; max-width: 100%; }
  .fin-charts-row > div { min-width: 0 !important; width: 100%; flex-basis: 100% !important; }
  .row-flex { flex-wrap: wrap; }
  .settings-content .input, .settings-content .select { max-width: 100%; }
  .status-editor-row, .member-row { flex-wrap: wrap; }
  .member-info { min-width: 140px; }
  .sound-setting { align-items: flex-start; flex-direction: column; gap: 8px; }
  .modal { max-width: calc(100vw - 16px); max-height: calc(100dvh - 24px); }
  .modal-head, .modal-foot { padding: 12px; flex-wrap: wrap; }
  .modal-body { padding: 8px 12px; }
  .modal-foot .btn { flex: 1; }
  .pane-head { padding: 10px; flex-wrap: wrap; gap: 6px; }
  .pane-title-input { min-width: 140px; font-size: 16px; }
  .pane-main, .pane-side { padding: 12px; }
  .pane-mode-btn { display: none; }
  .chat-main .comment-input-wrap { flex-wrap: wrap; }
  .chat-main .comment-input-wrap > .comment-input { flex: 1 1 calc(100% - 44px); max-height: 24dvh; overflow-y: auto; }
  .chat-main .comment-input-wrap > div:last-child { flex-direction: row !important; flex-wrap: wrap; width: 100%; justify-content: flex-end; }
  .chat-main > :last-child { padding: 8px 12px max(8px, env(safe-area-inset-bottom)) !important; }
  .comment-head, .comment-actions { flex-wrap: wrap; }
  .comment-actions { opacity: 1; }
  .msg-attachments, .msg-attach { max-width: 100%; }
  .msg-attach .name { overflow: hidden; text-overflow: ellipsis; }
  .view-header { flex-wrap: nowrap; overflow-x: auto; flex-shrink: 0; }
  .view-tab { flex-shrink: 0; }
  .view-toolbar { padding: 8px; }
  .task-row { display: grid; grid-template-columns: 20px minmax(0, 1fr); grid-template-areas: 'check name' '. id' '. fields'; height: auto; padding: 10px; gap: 5px 8px; }
  .task-row > .task-check { grid-area: check; }
  .task-row > .task-title-wrap { grid-area: name; }
  .task-row > .task-id { grid-area: id; }
  .task-row > .task-fields { grid-area: fields; min-width: 0; flex-wrap: wrap; gap: 6px; }
  .task-row .task-name { white-space: normal; overflow-wrap: anywhere; line-height: 1.4; }
  .cal-head { flex-wrap: wrap; gap: 6px; }
  .cal-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .cal-cell { padding: 2px; min-width: 0; }
  .cal-task { padding: 3px 2px; font-size: 9px; }
  .cal-dow { padding: 6px 0; }
  input.input, textarea.input, select.select, [contenteditable="true"] { font-size: 16px; }
}

@media (pointer: coarse) {
  .icon-btn, .toolbar-btn, .nav-item, .tree-row, .btn { min-height: 40px; }
  .tree-actions { opacity: 1; }
  .comment-actions button { min-height: 36px; padding: 6px; }
}
