/* ───────── Context headers ───────── */
.context{ 
  display:flex;
  align-items:baseline;
  justify-content:space-between;
  border-bottom:1px solid var(--border);
  padding:8px 4px;
  margin-bottom:8px;
  flex-wrap:wrap;
  row-gap:6px;
}
.context-inline{ align-items:center; gap:8px; flex-wrap:wrap; }
.context-name{ font-size:18px; font-weight:700 }
.context .muted{ color:var(--muted) }
.context-meta{ display:flex; align-items:center; gap:10px; }
.clear-notifications-btn{
  border:none;
  background:none;
  color:var(--highlight);
  cursor:pointer;
  padding:4px 6px;
  font-weight:600;
  border-radius:8px;
}
.clear-notifications-btn:hover,
.clear-notifications-btn:focus-visible{
  color:var(--text-strong);
  background:var(--bg-weak);
  outline:none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.panel-title-group{ display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.panel-title-group .inline{ margin-left:0; }

/* Project sidebar list */
.sidebar-title{ font-size:14px; font-weight:700; margin-bottom:8px }
.project-list{ list-style:none; margin:0; padding:0; display:grid; gap:8px }
.project-link{
  display:block; padding:10px 12px; border:1px solid var(--border); border-radius:8px;
  color:var(--text); background:var(--card)
}
.project-link:hover{ background:var(--accent-2) }
.project-link.active{ background:#154a54; border-color:#2c6b75 }

/* Task table & cards */
.task-table{ width:100%; border-collapse:separate; border-spacing:0 6px; min-width:min(680px, 100%); }
.task-table th{ font-size:12px; text-align:left; color:var(--muted) }
.task-table td, .task-table th{ padding:6px 8px }
.task-table td{ vertical-align:top; }
.task-table .due-col {
  width: 100px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.task-table .status-col {
  width: 105px;
  white-space: nowrap;
}
.task-table .status-col .badge {
  display: inline-flex;
  justify-content: center;
  width: 100%;
}
/* Only main task rows get the card treatment */
.cards .card,
.task-row {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 8px;
}

/* row status accents still piggyback on .row */
.row {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
}
.row::before {
  content:"";
  position:absolute;
  left:0;
  top:0;
  bottom:0;
  width:6px;
  background: var(--border);
}

.status-pending::before            { background:#8b97a31a; }
.status-awaiting_approval::before  { background:#f1b84a; }
.status-in_review::before          { background:#7aa7ff; }
.status-approved::before           { background:#5bc37a; }
.status-late::before               { background:#e45a6b; }
.status-warn::before               { background:#f3c25d; }
.status-in_progress::before        { background:#1f8a7026; }
.status-pushed_back::before        { background:#6570a81f; }
.status-changes_requested::before  { background:#e58b5a; }

.status-ok{    box-shadow: inset 0 0 0 2px rgba(31,138,112,.15) }
.status-in_progress{ box-shadow: inset 0 0 0 2px rgba(31,138,112,.12) }
.status-warn{  box-shadow: inset 0 0 0 2px rgba(138,111,31,.25) }
.status-late{  box-shadow: inset 0 0 0 2px rgba(138,31,43,.25) }
.status-pending{box-shadow: inset 0 0 0 2px rgba(203,213,209,.15) }
.status-pushed_back{ box-shadow: inset 0 0 0 2px rgba(101,112,168,.18) }
.card.status-approved{ border-color:#5bc37a; box-shadow: inset 0 0 0 2px #5bc37a33 }

.card-title{ font-weight:700; margin-bottom:4px }
.card-meta{ font-size:12px; color:var(--muted); margin:2px 0 }
.task-title{ font-weight:700; line-height:1.3 }
.task-sub{ font-size:12px }
.task-heading{ display:flex; justify-content:space-between; align-items:flex-start; gap:.5rem; }
.task-tags{ display:flex; gap:.35rem; flex-wrap:wrap; }
.task-description{ font-size:12px; color:var(--muted); margin-top:2px; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; }
.task-meta{ display:flex; flex-wrap:wrap; gap:.75rem; font-size:12px; color:var(--muted); margin-top:4px; }
.task-meta-item{ display:inline-flex; align-items:center; gap:4px; white-space:nowrap; }
.task-pill{ display:inline-flex; align-items:center; gap:4px; border:1px solid var(--border); border-radius:999px; padding:2px 8px; font-size:11px; background:var(--panel); color:var(--text); text-transform:none; }
.task-pill.subtle{ color:var(--muted); font-weight:500; }
.task-pill.warn{ background:#3b241a; border-color:#4d2f20; color:#ffbe9a; }
.task-assignees,
.task-approval-flow{ display:flex; align-items:center; flex-wrap:wrap; gap:6px; }
.task-approval-flow{ max-width:100%; min-width:0; }
.task-approval-flow{ font-size:12px; color:var(--muted); }
.task-actions{
  display:grid;
  grid-auto-flow:column;
  grid-template-rows:repeat(2,auto);
  grid-auto-columns:max-content;
  column-gap:6px;
  row-gap:6px;
  justify-content:flex-end;
  padding-bottom:2px;
}
.project-label{
  display:inline-block;
  max-width:120px;
  overflow:hidden;
  text-overflow:ellipsis;
  vertical-align:bottom;
}
.task-table .project-col,
.task-table .dept-col,
.task-table .assignment-col,
.task-table .priority-col{
  width:1%;
  white-space:nowrap;
}
.task-table .task-main-col{
  width:100%;
}
.task-table .task-actions-col{
  width:30%;
  min-width:240px;
}
.badge{
  display:inline-block; padding:2px 6px; border:1px solid var(--border);
  border-radius:999px; background:transparent; font-size:12px; margin-right:4px; color:var(--text)
}
.badge { border-color: transparent; }
.status-awaiting_approval .badge  { background:#3a2f16; color:#ffd979; }
.status-in_review .badge          { background:#1e2c46; color:#a9c7ff; }
.status-approved .badge           { background:#1c3a2a; color:#9fe2b4; }
.status-changes_requested .badge  { background:#3b241a; color:#ffbe9a; }
.status-late .badge               { background:#3a1c22; color:#ff9aa9; }
.status-delayed .badge            { background:#3c0a12; color:#ffd9e0; }
.status-pushed_back .badge        { background:#1f2438; color:#c8d1ff; }

.badge-pending{        border-color:#455; }
.badge-awaiting_approval{ border-color:#8a6; background:rgba(120,180,130,.08) }
.badge-in_review{      border-color:#caa; background:rgba(210,160,160,.08) }
.badge-approved{       border-color:#5bc37a; background:rgba(91,195,122,.12) }
.badge-changes_requested{ border-color:#e6b04a; background:rgba(230,176,74,.12) }
.badge-late{           border-color:#d55; background:rgba(213,85,85,.10) }
.badge-delayed{        border-color:#7f0c1c; background:rgba(127,12,28,.22); color:#ffe3e6 }
.badge-warn{           border-color:#d7a93a; background:rgba(215,169,58,.10) }
.badge-in_progress{    border-color:#1f8a70; background:rgba(31,138,112,.12) }
.badge-pushed_back{    border-color:#7c8bd1; background:rgba(124,139,209,.12) }

.row.status-awaiting_approval{ box-shadow: inset 0 0 0 2px rgba(120,180,130,.20); }
.row.status-in_review{         box-shadow: inset 0 0 0 2px rgba(210,160,160,.20); }
.row.status-approved{          box-shadow: inset 0 0 0 2px rgba(91,195,122,.25); }
.row.status-changes_requested{ box-shadow: inset 0 0 0 2px rgba(230,176,74,.25); }
.row.status-pushed_back{       box-shadow: inset 0 0 0 2px rgba(124,139,209,.25); }
.row.status-delayed{           box-shadow: inset 0 0 0 2px rgba(127,12,28,.40); }

.pill{ display:inline-block; padding:2px 8px; border-radius:999px; border:1px solid var(--border); margin-left:6px }
.pill-attn{ background:#2b3b2f; border-color:#4c6d50 }
.chip.warn{ border-color:#e6b04a; }

.task-table .row:hover { box-shadow: 0 6px 18px rgba(0,0,0,.18); transform: translateY(-1px); transition: .15s ease; }
.inline{ display:inline-grid; grid-auto-flow:column; gap:6px; margin-left:8px }

/* Progress bar */
.progress{
  height:6px; background:#0a2024; border-radius:999px; margin-top:4px;
  overflow:hidden; border:1px solid var(--border)
}
.progress__bar{ height:100%; background:var(--highlight) }

/* Rewards pill */
.rewards{
  display:flex; gap:.5rem; align-items:center; padding:.25rem .5rem;
  border:1px solid var(--border); border-radius:999px; background:var(--card);
}
.rewards__label{ font-weight:600 }
.rewards__points{ font-variant-numeric: tabular-nums }
.rewards.pulse{ box-shadow:0 0 0 6px rgba(255,213,74,0.2); transition:box-shadow .6s ease }

/* Performance scorecard */
.performance-panel{
  margin-top:.5rem;
  border:1px solid var(--border);
  border-radius:.9rem;
  padding:.75rem .9rem;
  background:linear-gradient(135deg, rgba(255,213,74,0.12), rgba(73,142,255,0.06));
  box-shadow:0 10px 22px rgba(0,0,0,0.22);
  display:grid;
  gap:.6rem;
}
.performance-header{
  display:flex;
  justify-content:space-between;
  gap:.65rem;
  align-items:flex-start;
}
.performance-title{ display:flex; align-items:center; gap:.35rem; }
.score-help-btn{
  border:1px solid var(--border);
  background:rgba(255,255,255,0.08);
  color:var(--text,#eaeaea);
  border-radius:50%;
  width:1.65rem;
  height:1.65rem;
  line-height:1.65rem;
  display:grid;
  place-items:center;
  font-weight:800;
  font-size:.95rem;
  cursor:pointer;
  transition:background .15s ease, transform .15s ease;
}
.score-help-btn:hover{ background:rgba(255,255,255,0.16); transform:translateY(-1px); }
.eyebrow{ text-transform:uppercase; letter-spacing:.08em; font-size:11px; color:var(--muted); font-weight:700 }
.score-total-row{ display:flex; align-items:baseline; gap:.35rem; }
.score-total{ font-size:1.9rem; font-weight:800; line-height:1; }
.score-unit{ color:var(--muted); font-weight:600; }
.score-rank{
  background:rgba(0,0,0,0.2);
  border:1px solid var(--border);
  border-radius:999px;
  padding:.1rem .6rem;
  font-size:12px;
  font-weight:700;
  color:var(--text);
  cursor:pointer;
  transition:background .15s ease, transform .15s ease;
}
.score-rank:hover, .score-rank:focus-visible{
  background:rgba(255,255,255,0.12);
  transform:translateY(-1px);
}
.score-rank:focus-visible{ outline:2px solid var(--accent,#5bc37a); outline-offset:2px; }
.score-chip{
  background:#ffd54a;
  color:#1b1b1b;
  border-radius:999px;
  padding:.25rem .65rem;
  font-weight:700;
  box-shadow:0 8px 20px rgba(255,213,74,0.22);
}
.score-header-actions{ display:flex; gap:.6rem; align-items:flex-start; justify-content:flex-end; flex-wrap:wrap; }
.score-month-picker{ display:flex; flex-direction:column; gap:.25rem; align-items:flex-end; }
.score-month-select{ min-width: 170px; }
.score-month-note{ font-size:.85rem; color:var(--muted); text-align:right; }
.performance-bars{ display:grid; gap:.35rem; }
.performance-bar{ display:grid; grid-template-columns:1fr auto; align-items:center; gap:.4rem; }
.performance-bar.subtle .bar-track{ opacity:.7 }
.bar-label{ font-weight:600; font-size:.92rem; }
.bar-track{ position:relative; height:8px; background:rgba(255,255,255,0.12); border-radius:999px; overflow:hidden; }
.bar-track span{ position:absolute; inset:0; background:linear-gradient(90deg, #ffd54a, #7cc4ff); }
.bar-value{ font-weight:700; font-variant-numeric:tabular-nums; font-size:.95rem; }
.performance-metrics{ display:grid; grid-template-columns:repeat(3,1fr); gap:.3rem; }
.metric{ padding:.45rem .5rem; border-radius:.6rem; background:rgba(255,255,255,0.04); border:1px solid rgba(255,255,255,0.08);
}
.metric.warn{ border-color:rgba(231,102,79,0.35); color:#f7b199; }
.metric-value{ font-weight:700; font-size:1rem; }
.metric-label{ color:var(--muted); font-size:.82rem; }
.points-help-list{ margin:8px 0 0; padding-left:1.1rem; display:grid; gap:.35rem; }
.leaderboard-stage{ position:relative; margin:0 -8px 12px; height:72px; overflow:hidden; border-radius:14px; background:linear-gradient(120deg, rgba(255,213,74,0.24), rgba(124,196,255,0.18), rgba(132,94,247,0.22)); box-shadow:0 12px 50px rgba(124,196,255,0.16); border:1px solid rgba(255,255,255,0.1); }
.leaderboard-aurora{ position:absolute; inset:0; background:radial-gradient(circle at 15% 30%, rgba(255,255,255,0.3), transparent 35%), radial-gradient(circle at 85% 20%, rgba(255,255,255,0.22), transparent 30%), radial-gradient(circle at 60% 80%, rgba(255,255,255,0.18), transparent 32%); filter:blur(18px); animation: auroraPulse 8s ease-in-out infinite; }
.leaderboard-orbs{ position:absolute; inset:0; display:flex; justify-content:space-between; align-items:center; padding:0 12px; }
.leaderboard-orbs span{ width:12px; height:12px; border-radius:999px; background:radial-gradient(circle, #fff, rgba(255,255,255,0.4)); animation: floatUp 6s ease-in-out infinite; }
.leaderboard-orbs span:nth-child(2){ animation-delay:1.2s; width:16px; height:16px; }
.leaderboard-orbs span:nth-child(3){ animation-delay:2s; }
.leaderboard-list{ list-style:none; padding:0; margin:8px 0 0; display:grid; gap:10px; position:relative; }
.leaderboard-row{
  position:relative;
  display:grid;
  grid-template-columns:auto 1fr auto auto;
  gap:8px 10px;
  align-items:center;
  padding:12px 14px;
  border-radius:14px;
  background:linear-gradient(135deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
  border:1px solid rgba(255,255,255,0.12);
  box-shadow:0 14px 32px rgba(0,0,0,0.18);
  overflow:hidden;
  transition:transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.leaderboard-row::before{ content:""; position:absolute; inset:-1px; background:linear-gradient(120deg, rgba(255,213,74,0.35), rgba(124,196,255,0.2), rgba(132,94,247,0.25)); opacity:0; transition:opacity .2s ease; z-index:0; filter:blur(0); }
.leaderboard-row::after{ content:""; position:absolute; inset:0; background:linear-gradient(120deg, rgba(255,255,255,0.18), rgba(255,255,255,0)); opacity:0; transform:translateX(-30%); transition:opacity .25s ease, transform .35s ease; }
.leaderboard-row:hover{ transform:translateY(-3px) scale(1.01); box-shadow:0 18px 46px rgba(0,0,0,0.22); border-color:rgba(255,255,255,0.32); }
.leaderboard-row:hover::before{ opacity:0.28; }
.leaderboard-row:hover::after{ opacity:0.28; transform:translateX(0); }
.leaderboard-row.is-me{ border-color:#ffd54a; box-shadow:0 18px 48px rgba(255,213,74,0.28); }
.leaderboard-row.is-me::before{ opacity:.35; }
.leaderboard-rank{ font-weight:800; font-size:1.1rem; background:linear-gradient(120deg,#ffd54a,#7cc4ff,#845ef7); -webkit-background-clip:text; color:transparent; }
.leaderboard-name{ font-weight:700; position:relative; z-index:1; }
.leaderboard-points, .leaderboard-quality{ font-weight:700; font-variant-numeric:tabular-nums; color:var(--muted); position:relative; z-index:1; }
.leaderboard-row:nth-child(1){ transform:translateY(-1px); border-color:rgba(255,213,74,0.6); box-shadow:0 20px 52px rgba(255,213,74,0.3); }
.leaderboard-row:nth-child(1) .leaderboard-rank{ font-size:1.25rem; }
.leaderboard-row:nth-child(2){ border-color:rgba(124,196,255,0.45); }
.leaderboard-row:nth-child(3){ border-color:rgba(132,94,247,0.45); }
.leaderboard-row:nth-child(n+4){ opacity:0.96; }
.leaderboard-row:nth-child(n+1){ animation: riseIn .35s ease forwards; }

@keyframes auroraPulse{
  0%,100%{ transform:translateX(0); opacity:.9; }
  50%{ transform:translateX(-8%); opacity:1; }
}

@keyframes floatUp{
  0%,100%{ transform:translateY(0); opacity:.8; }
  50%{ transform:translateY(-6px); opacity:1; }
}

@keyframes riseIn{
  from{ opacity:0; transform:translateY(10px); }
  to{ opacity:1; transform:translateY(0); }
}
/* Files */
.file-list{ list-style:none; margin:0; padding:0; display:grid; gap:8px }
.file-item{ border:1px solid var(--border); border-radius:8px; padding:8px; background:var(--card) }
.file-name{ font-weight:600 }
.file-meta{ font-size:12px; color:var(--muted) }
.upload-form{ display:grid; gap:8px }

/* Approvals widget */
.approvals{
  margin:.75rem 0 1rem;
  border:1px solid var(--border);
  border-radius:.75rem;
  padding:.5rem .75rem;
  background:var(--card);
}
.approvals summary{ cursor:pointer; font-weight:600 }
.approval-card{
  border:1px solid var(--border); border-radius:.6rem;
  padding:.6rem .75rem; margin:.5rem 0; background:var(--panel);
}
.approval-title{ font-weight:600; margin-bottom:.25rem }
.approval-actions{ display:flex; gap:.5rem; margin-top:.5rem }
.approval-note{
  margin-top:.5rem;
  border:1px dashed var(--border);
  border-radius:.5rem;
  padding:.5rem .6rem;
  font-size:.9rem;
  color:var(--muted);
  background:rgba(255,255,255,.02);
  white-space:pre-wrap;
}
.task-approval-note{ margin-top:.35rem; }
.task-delay-note{
  margin-top:.35rem;
  padding:.45rem .55rem;
  border-radius:.55rem;
  border:1px solid rgba(127,12,28,.5);
  background:rgba(60,10,18,.35);
  color:#ffdfe0;
}
.task-delay-note .muted{ color:#f7bcc2; }

.table-scroll{
  width:100%;
  overflow-x:auto;
  -webkit-overflow-scrolling:touch;
}
.table-scroll table{ margin:0; }

.tabs-row{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  margin:8px 0 4px;
}

.chips-row{ display:none; gap:6px; flex-wrap:wrap; margin:4px 0 10px; }

.chat-body{ display:flex; flex-direction:column; gap:.5rem; }
.chat-header{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:.75rem;
  padding-bottom:.35rem;
}
.chat-meta{ color:var(--muted); font-size:.85rem; margin-top:2px; }
.chat-header-actions{ display:flex; gap:.4rem; }
.chat-panel .panel-body{ display:flex; flex-direction:column; gap:.75rem; min-height:0; }
.chat-panel .chat-window{
  border:1px solid var(--border);
  border-radius:.75rem;
  background:linear-gradient(135deg, rgba(26, 37, 44, .85), rgba(13, 15, 18, .9));
  box-shadow:inset 0 1px 0 rgba(255,255,255,.04);
  padding:.6rem;
  min-height:150px;
}
.chat-panel .chat-window:empty::before{
  content:"Ask what's due, blocked, or coming up…";
  color:var(--muted);
  font-style:italic;
}
.chat-panel .chat-form{ align-items:center; }
.chat-panel .chat-form input[type="text"]{
  background:var(--panel);
  border-radius:.6rem;
  padding:.55rem .75rem;
}
.chat-panel .chat-form button{ flex:0 0 auto; }
.chat-hint strong{ color:var(--text); }

.task-table.compact td, .task-table.compact th { padding:6px 8px; }
.chip.danger { border-color:#e45a6b; color:#ffb9c2; }
.input-error { outline: 2px solid #e6b04a; }
.field-error { color:#e6b04a; }

.sidebar-tabs-header .tabs-row{ margin:0; }
.notification-list{ display:flex; flex-direction:column; gap:10px; }
.notification-card{
  border:1px solid var(--border);
  border-radius:10px;
  padding:10px 12px;
  background:var(--card);
  display:flex;
  flex-direction:column;
  gap:6px;
}
.notification-heading{ display:flex; justify-content:space-between; align-items:flex-start; gap:8px; }
.notification-task-title{ font-weight:600; }
.notification-task-meta{ font-size:.8rem; color:var(--muted); }
.notification-summary{ font-size:.95rem; line-height:1.3; }
.notification-note{
  font-size:.9rem;
  color:var(--muted);
  border-left:2px solid var(--border);
  padding-left:8px;
}
.notification-actions{ display:flex; gap:8px; flex-wrap:wrap; margin-top:4px; }
.notification-time{ font-size:.8rem; color:var(--muted); white-space:nowrap; }

/* Buttons / chips */
.btn, .btn-outline, .chip{
  padding:.4rem .65rem; border-radius:.45rem; cursor:pointer;
  display:inline-flex; align-items:center; gap:.35rem; font:inherit;
}
.chip-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.chip-reset { font-size: 12px; padding: 6px 10px; }
.icon-btn{
  border:1px solid var(--border,#2a2a2a);
  background:var(--card,#181818);
  color:var(--text,#eaeaea);
  border-radius:10px;
  padding:.35rem .55rem;
  line-height:1;
  cursor:pointer;
}
.btn{ border:1px solid var(--accent); background:var(--accent); color:var(--text) }
.btn:hover{ filter:brightness(1.05) }
.btn-outline{ background:transparent; color:var(--text); border:1px solid var(--border) }
.chip{ background:transparent; border:1px solid var(--border); color:var(--text) }
.chip.success{ border-color:#5bc37a }

/* Visual highlight */
.card.glow{ outline:3px solid var(--highlight); box-shadow:0 0 0 6px rgba(255,213,74,.15) }

/* Chat (dock content) */
#chatDock .chat-window{
  height:240px; overflow:auto; border:1px solid var(--border);
  border-radius:.5rem; padding:.5rem; background:var(--card); margin-bottom:.5rem;
}
.chat-msg{ padding:.35rem .5rem; margin:.25rem 0; border-radius:.35rem }
.chat-msg.user{ background:#153b44 }
.chat-msg.assistant{ background:#122a30 }
.chat-form{ display:flex; gap:.5rem }
.chat-form input[type="text"]{
  flex:1; background:var(--card); color:var(--text);
  border:1px solid var(--border); border-radius:.4rem; padding:.45rem .5rem;
}
.chat-hint{ color:var(--muted); font-size:.9rem; margin-top:.25rem }

/* Issues list */
.issue-list{ display:grid; gap:.6rem }
.issue-card{
  border:1px solid var(--border); border-radius:.6rem;
  background:var(--card); padding:.55rem .65rem;
  opacity:.95; /* slightly subtler than task cards */
}
.issue-head{
  display:flex;
  align-items:flex-start;
  gap:.75rem;
}
.issue-title{
  font-weight:600;
  display:flex;
  gap:.55rem;
  flex:1;
  align-items:flex-start;
  flex-wrap:wrap;
}
.issue-summary{ line-height:1.3; }
.issue-meta{
  color:var(--muted);
  font-size:.85rem;
  display:flex;
  flex-wrap:wrap;
  gap:.35rem;
  margin-top:.35rem;
}
.issue-actions{
  display:flex;
  flex-wrap:wrap;
  justify-content:flex-end;
  gap:.35rem;
}
.issue-card .btn,
.issue-card .chip{
  padding:.35rem .6rem;
}

/* Modals (approval / create) */
.modal-backdrop{
  position:fixed; inset:0; background:rgba(0,0,0,.4);
  display:none; align-items:center; justify-content:center; z-index:1000;
}
.modal-backdrop.show,
.modal-backdrop:not(.hidden) { display:flex }
.modal-layer { align-items: center; justify-content: center; background: rgba(0,0,0,.4); }
body.modal-open{ overflow:hidden }

.modal{ 
  background:var(--panel); border:1px solid var(--border);
  border-radius:12px; padding:16px; width:min(520px, 92vw); color:var(--text);
}

.inline-detail{
  border:1px solid var(--border);
  border-radius:12px;
  padding:12px;
  margin-bottom:12px;
  background:var(--card);
  box-shadow:0 6px 18px rgba(0,0,0,.08);
}
.inline-detail:empty{ display:none; }
.inline-detail[hidden]{ display:none; }

.modal.inline-modal{
  position:static;
  inset:auto;
  width:100%;
  max-width:none;
  box-shadow:none;
  padding:0;
}
.modal.inline-modal .modal-body{ max-height:none; }
.modal.inline-modal .modal-header{ border-bottom:1px solid var(--border); }

.modal-panel{
  width:min(640px, 94vw);
  max-height:90vh;
  overflow:auto;
  box-shadow:0 18px 48px rgba(0,0,0,.35);
}
.modal-scroll-body{
  max-height:70vh;
  overflow:auto;
}
.modal-row{ display:grid; gap:.5rem; margin:.5rem 0 }

/* Link popover inside task rows */
.link-popover.hidden{ display:none }
.popover-title{ font-weight:600; margin-bottom:.25rem }

/* ───────── Auth / Login ───────── */
.auth-shell{
  min-height:calc(100vh - 88px);
  display:grid; place-items:center;
}

.auth-card{
  width:min(560px, 92vw);
  background:linear-gradient(180deg, rgba(31,111,122,.18), transparent) var(--panel);
  border:1px solid var(--border);
  border-radius:16px;
  padding:20px;
  box-shadow:0 12px 30px rgba(0,0,0,.18), inset 0 1px 0 rgba(255,255,255,.03);
}

.auth-head{ text-align:center; margin-bottom:14px }
.auth-badge{
  width:44px; height:44px; border-radius:12px;
  display:inline-grid; place-items:center;
  background:var(--accent); color:var(--text); font-weight:800; letter-spacing:.5px;
  box-shadow:0 6px 16px rgba(31,111,122,.35);
  margin-bottom:8px;
}
.auth-title{ margin:0; font-size:22px; font-weight:800 }
.auth-sub{ margin:.25rem 0 0; color:var(--muted) }

.auth-form{ margin-top:14px; display:grid; gap:10px }
.auth-label{ font-weight:600; font-size:14px }

.input{
  width:100%;
  padding:.6rem .7rem;
  border-radius:10px;
  border:1px solid var(--border);
  background:var(--card);
  color:var(--text);
  outline:none;
}
.input:focus{ border-color:var(--accent); box-shadow:0 0 0 2px rgba(31,111,122,.25) }

.auth-actions{ display:flex; justify-content:flex-end; gap:.5rem; margin-top:2px }

.auth-quick{ margin-top:14px }
.auth-quick-head{ font-weight:700; font-size:13px; color:var(--muted); margin-bottom:6px }
.chip-grid{ display:flex; flex-wrap:wrap; gap:6px }
.chip-grid .chip{ border-radius:999px; padding:.35rem .7rem }
/* Login card styles (inherits theme variables) */
.login-card{
  width: min(520px, 92vw);
  padding: 16px;
}

/* ───────── Responsive tweaks ───────── */
@media (max-width: 1024px){
  .context{ flex-direction:column; align-items:flex-start; gap:4px; }
  .inline{ justify-self:start; }
}

@media (max-width: 720px){
  .approval-actions{ flex-wrap:wrap; }
  .chat-form{ flex-direction:column; }
  .chat-form button{ width:100%; justify-content:center; }
}

/* Profile avatars */
.avatar-row{
  display:flex;
  align-items:center;
  gap:12px;
  flex-wrap:wrap;
}

.avatar-preview{
  width:72px;
  height:72px;
  border-radius:50%;
  overflow:hidden;
  background:var(--panel);
  border:1px solid var(--border);
  display:grid;
  place-items:center;
}

.avatar-preview img{
  width:100%;
  height:100%;
  object-fit:cover;
}

.avatar-fallback{
  font-size:24px;
  font-weight:700;
  color:var(--muted);
}

.user-chip-list{ display:flex; gap:6px; flex-wrap:wrap; align-items:center; }
.task-approval-flow .user-chip-list{
  flex-wrap:wrap;
  max-width:100%;
  overflow:hidden;
}
.user-chip{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:.25rem .6rem;
  border-radius:999px;
  border:1px solid var(--border);
  background:var(--panel);
  font-weight:600;
}

.user-chip.small{ padding:2px 8px; gap:6px; font-weight:500; }

.user-chip__avatar{
  width:28px;
  height:28px;
  border-radius:50%;
  background:var(--card);
  border:1px solid var(--border);
  display:grid;
  place-items:center;
  overflow:hidden;
}

.user-chip.small .user-chip__avatar{ width:22px; height:22px; }

.user-chip__avatar img{
  width:100%;
  height:100%;
  object-fit:cover;
}

.user-chip__initial{ font-size:12px; color:var(--muted); }

.login-title{
  font-size: 20px;
  font-weight: 700;
  margin-bottom: .25rem;
}
.login-subtitle{
  color: var(--muted);
  margin-bottom: .75rem;
}
.login-form{
  display: grid;
  gap: .5rem;
}
.login-input{
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: .5rem;
  padding: .6rem .7rem;
}
.login-actions{
  display: flex;
  justify-content: flex-end;
  gap: .5rem;
  margin-top: .5rem;
}

/* Hide chat UI when body.no-chat is present */
body.no-chat #chatDock,
body.no-chat .chat-panel{ display: none !important; }
.modal-backdrop.hidden { display: none; }
.modal-backdrop.show { display: flex; align-items: center; justify-content: center; }
.chat-msg.typing {
  opacity: 0.6;
  font-style: italic;
}
/* Popout container */
.chat-popout {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: 380px;
  max-height: 70vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 8px;
  padding: 12px;
  background: var(--panel, #141414);
  border: 1px solid var(--border, #2a2a2a);
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(0,0,0,.25);
  z-index: 9999;
}
.chat-popout .chat-popout-handle {
  cursor: move;
  font-weight: 700;
  user-select: none;
  display: flex; align-items: center; justify-content: space-between;
}
.chat-popout .chat-window { min-height: 180px; overflow: auto; }

/* Inline + popout chat bubbles */
.chat-window { overflow: auto; }
.chat-msg { padding: .5rem .75rem; margin: .25rem 0; border-radius: .5rem; }
.chat-msg.user       { background: var(--chip, #1f1f1f); }
.chat-msg.assistant  { background: var(--card, #181818); }
.chat-msg.typing     { opacity: .7; font-style: italic }

/* Popout / dock buttons */
.chat-popout-toggle{
  border:1px solid var(--border, #2a2a2a);
  background:transparent;
  color:var(--muted);
  border-radius:.4rem;
  padding:.2rem .55rem;
  font-size:.85rem;
  cursor:pointer;
  transition:color .2s ease, border-color .2s ease, background .2s ease;
}
.chat-popout-toggle:hover{
  color:var(--text);
  border-color:var(--text);
  background:rgba(255,255,255,.05);
}


.user-picker { position: relative; display: grid; gap: .5rem; }
.picker-results { border: 1px solid var(--line); border-radius: 8px; max-height: 200px; overflow:auto; display:none; background: var(--panel); }
.picker-results.show { display:block; }
.picker-results .item { padding:.5rem .75rem; cursor:pointer; }
.picker-results .item:hover { background: var(--hover); }
.picker-selected { display:flex; flex-wrap:wrap; gap:.4rem; }
.picker-selected .chip { background: var(--chip); border-radius: 999px; padding:.2rem .6rem; cursor:pointer; }

.modal-backdrop{
  position:fixed; inset:0; 
  background:rgba(0,0,0,.5);
  align-items:center; justify-content:center; 
  z-index:1000;
}

/* State classes only */
.modal-backdrop.hidden { display: none; }
.modal-backdrop.show   { display: flex; }
.user-picker { 
  position: relative; 
  display: grid; 
  gap: .5rem; 
}

.picker-results {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  max-height: 240px;
  overflow: auto;
  display: none;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  z-index: 3200;            /* sits above the modal content */
  box-shadow: 0 8px 24px rgba(0,0,0,.3);
}

.picker-results.show { display: block; }
.picker-results .item { padding:.5rem .75rem; cursor:pointer; }
.picker-results .item:hover { background: var(--hover); }
#modalUserPicker .picker-results .item {
  padding: .4rem .5rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
#modalUserPicker .picker-results .item[data-active="1"] {
  outline: 2px solid var(--accent, #5bc37a);
  outline-offset: -2px;
}
#modalUserPicker .picker-results .item[data-checked="1"]::after {
  content: "✓";
  float: right;
  opacity: .8;
}
#upResults .item {
  position: relative;
  padding: 6px 10px;
  padding-right: 2.25rem;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.15s;
}
#upResults .item:hover, #upResults .item[data-active="1"] {
  background: var(--hover, rgba(255,255,255,.05));
}
#upResults .item[data-checked="1"]::after {
  content: "✓";
  position: absolute;
  right: .75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--accent, #5bc37a);
  font-weight: 700;
}
#upChosen .chip {
  background: var(--accent-bg, rgba(91,195,122,.15));
  border: 1px solid var(--accent, #5bc37a);
}
/* user picker polish */
#upResults .item {
  display: flex;
  align-items: center;
}
#upResults .item:hover,
#upResults .item[data-active="1"] {
  background: var(--hover, rgba(255,255,255,.05));
}
#upResults .item[data-checked="1"]::after {
  content: "✓";
  font-weight: 700;
  opacity: .9;
}
#upResults .up-user {
  display: flex;
  align-items: center;
  gap: .75rem;
  width: 100%;
}
#upResults .up-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--border, #333);
  flex-shrink: 0;
}
#upResults .up-avatar--fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: var(--accent, #5bc37a);
  background: rgba(91,195,122,.15);
}
#upResults .up-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  min-width: 0;
}
#upResults .up-title {
  font-weight: 600;
  color: var(--text, #fff);
}
#upResults .up-subtitle {
  font-size: .85rem;
  color: var(--muted, rgba(255,255,255,.7));
  margin-top: 2px;
  word-break: break-all;
}
#modalUserPicker #upSearch {
  max-height: 42px;
}
#upChosen {
  gap: .5rem;
}
#upChosen .chip {
  background: var(--accent-bg, rgba(91,195,122,.15));
  border: 1px solid var(--accent, #5bc37a);
}
#modalUserPicker {
  position: fixed;
  inset: 0;
  padding: 0;
  margin: 0;
  display: block;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: 40000; /* sits above other dialogs and their backdrops */
  background: transparent;
  width: auto;
  border: none;
  color: inherit;
}
#modalUserPicker::backdrop {
  background: transparent;
  backdrop-filter: none;
}
#modalUserPicker.is-open,
#modalUserPicker[open] {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  display: block; /* force visibility even if user agent hides popovers */
}
#modalUserPicker .modal-body {
  position: absolute;
  top: var(--up-top, 86px);
  left: var(--up-left, 50%);
  width: var(--up-width, min(420px, 94vw));
  max-height: min(70vh, 640px);
  background: var(--panel, #111);
  border: 1px solid var(--border, #333);
  border-radius: 14px;
  box-shadow: 0 16px 48px rgba(0,0,0,.35), 0 0 0 1px rgba(255,255,255,.03);
  overflow: hidden;
  pointer-events: auto;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-columns: 1fr;
  opacity: 0;
  transform: translateY(6px) scale(.995);
  transition: opacity .14s ease, transform .16s ease;
}
#modalUserPicker.is-open .modal-body,
#modalUserPicker[open] .modal-body {
  opacity: 1;
  transform: translateY(0) scale(1);
}
#modalUserPicker .modal-scroll { display: grid; grid-template-columns: 1fr; }
#modalUserPicker .modal-header {
  border-bottom: 1px solid var(--border, #333);
  background: linear-gradient(180deg, rgba(255,255,255,.02), transparent);
}
#modalUserPicker .modal-scroll {
  padding: 14px 16px;
  max-height: 100%;
}
#modalUserPicker .modal-actions {
  border-top: 1px solid var(--border, #333);
  background: var(--panel, #111);
}
/* ───────── Project sidebar list ───────── */
.project-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

/* .project-list .nav-item { /* click target is the link; keep li simple */  */

.project-list .nav-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .45rem .6rem;
  border: 1px solid var(--border, #444);
  border-radius: 10px;
  text-decoration: none;
  color: var(--fg, #ddd);
  background: var(--panel, #111);
  transition: border-color .12s ease, background .12s ease, transform .04s ease;
}

.project-list .nav-link:hover {
  background: rgba(255,255,255,.03);
  border-color: var(--border-strong, #666);
}

.project-list .nav-link.active {
  border-color: #5bc37a;
  box-shadow: 0 0 0 1px rgba(91,195,122,.35) inset;
  background: rgba(91,195,122,.06);
}

.project-list .nav-link:active { transform: translateY(1px); }

.project-list .nav-link-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Count pill matches your existing visual language */
.pill.pill-count {
  margin-left: .5rem;
  padding: 0 .5rem;
  min-width: 1.5rem;
  text-align: center;
  border-radius: 999px;
  border: 1px solid var(--border, #444);
  background: #222;
  color: var(--fg, #ddd);
  font-size: 12px;
  line-height: 20px;
}

.project-list .nav-link.active .pill.pill-count {
  border-color: #5bc37a;
  background: rgba(91,195,122,.12);
}


td.prio { width: 28px; text-align: center; }
.prio-dot { display:inline-block; width:10px; height:10px; border-radius:50%; border:1px solid var(--border); }
.prio-1 { background:#d9534f; }   /* high */
.prio-2 { background:#f0ad4e; }
.prio-3 { background:#5bc0de; }
.prio-4 { background:#5cb85c; }
.prio-5 { background:#999; }      /* low */

.details-row > td { background:#101010; border-top:1px solid #2a2a2a; padding: 10px 12px; }
.details-grid { display:grid; grid-template-columns: 1fr 1fr; gap:12px; }
.details-col { border:1px solid var(--border); border-radius:10px; padding:10px; background:#0b0b0b; }
.details-col h4 { margin:0 0 6px; font-size:13px; opacity:.9 }
.comment { padding:8px; border-bottom:1px dashed #2a2a2a; }
.comment:last-child { border-bottom:0; }
.timeline-item { font-size:12px; border-left:2px solid #333; padding-left:8px; margin:6px 0; }
.small-input { width: 90px; }
.modal.two-pane .modal-body { display:flex; gap:16px; width:min(1100px, 96vw); }
.modal.two-pane .pane-left { flex: 2 1 auto; min-width: 480px; }
.modal.two-pane .pane-right { flex: 1 0 360px; max-width: 420px; border-left:1px solid var(--border); padding-left:12px; }
.modal .grid { display:grid; grid-template-columns: 1fr 1fr; gap:12px; }
.modal .grid label { display:flex; flex-direction:column; gap:6px; }
.tabs{display:flex; gap:6px; margin-bottom:8px}
.tabs button.active{background:var(--panel-strong)}
.tab-body [data-tabpanel]{display:block}
.tab-body [data-tabpanel][hidden]{display:none}
/* ─────────────────────────────────────────────────────────────────────────────
   Dialog polish (for <dialog class="modal ...">) + shared modal surface
   ──────────────────────────────────────────────────────────────────────────── */
dialog.modal::backdrop {
  background: rgba(0,0,0,.4);
  backdrop-filter: none;
}

.dialog-fallback-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  backdrop-filter: none;
  display: none;
  z-index: 1990;
}
.dialog-fallback-backdrop.show { display: block; }

dialog.modal,
.modal-surface {
  /* Padding scales with viewport so short/tall viewports keep usable space */
  --modal-pad-x: clamp(12px, 3vw, 18px);
  --modal-pad-y: clamp(12px, 2.5vh, 18px);

  padding: 0;                 /* let inner container handle spacing */
  border: 1px solid var(--border,#2a2a2a);
  border-radius: 14px;
  background: var(--panel,#121212);
  color: var(--text,#eaeaea);
  box-shadow: 0 20px 60px rgba(0,0,0,.45), 0 0 0 1px rgba(255,255,255,.02) inset;
  width: min(1120px, 96vw);
  max-height: min(88vh, 980px);
  overflow: hidden;           /* keep header/footer pinned */
}

dialog.modal {
  position: fixed;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  z-index: 2000;
}
#modalUserPicker[data-inline="1"] {
  transform: none;
  inset: 0;
}
dialog.modal[open] { display: block; }
dialog.modal:not([open]) { display: none; }

/* Shared interior scaffold */
dialog.modal .modal-body,
.modal-surface .modal-body {
  display: grid;
  grid-template-rows: auto 1fr auto; /* header / scroll / actions */
  gap: 0;
  padding: 0;
  width: 100%;
  height: 100%;
}

/* Header */
dialog.modal .modal-header,
.modal-surface .modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: var(--modal-pad-y) var(--modal-pad-x);
  border-bottom: 1px solid var(--border,#2a2a2a);
  background: linear-gradient(180deg, rgba(255,255,255,.02), transparent);
}
dialog.modal .modal-title,
.modal-surface .modal-title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: .2px;
}
dialog.modal .icon-btn,
.modal-surface .icon-btn {
  border: 1px solid var(--border,#2a2a2a);
  background: var(--card,#181818);
  color: var(--text,#eaeaea);
  border-radius: 10px;
  padding: .35rem .55rem;
  line-height: 1;
  cursor: pointer;
}

/* Scroll region */
dialog.modal .modal-scroll,
.modal-surface .modal-scroll {
  overflow: auto;
  min-height: 0;             /* allow the scroll area to shrink on short viewports */
  padding: calc(var(--modal-pad-y) - 2px) var(--modal-pad-x) calc(var(--modal-pad-y) + 2px);
}

/* Footer (sticky) */
dialog.modal .modal-actions,
.modal-surface .modal-actions {
  display: flex;
  gap: .5rem;
  justify-content: flex-end;
  padding: calc(var(--modal-pad-y) - 4px) var(--modal-pad-x);
  border-top: 1px solid var(--border,#2a2a2a);
  background: linear-gradient(0deg, rgba(255,255,255,.02), transparent);
}

/* Two-pane layout */
.modal-surface.two-pane .modal-scroll,
dialog.modal.two-pane .modal-scroll {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 16px;
}
.modal-surface .pane-left,
.modal-surface .pane-right,
dialog.modal .pane-left,
dialog.modal .pane-right {
  min-height: 0; /* allow scrolling children */
  display: grid;
  align-content: start;
  gap: 12px;
}

/* Right pane tabs */
.tabs {
  display: flex;
  gap: 6px;
  position: sticky; top: 0;
  padding-bottom: 6px; margin-bottom: 8px;
  background: linear-gradient(180deg, var(--panel,#121212), rgba(0,0,0,0));
  z-index: 1;
}
.tabs button {
  border: 1px solid var(--border,#2a2a2a);
  background: var(--card,#171717);
  color: var(--text,#eaeaea);
  border-radius: 999px;
  padding: .35rem .65rem;
  font-size: 12px;
  cursor: pointer;
}
.tabs button.active {
  box-shadow: 0 0 0 1px rgba(91,195,122,.35) inset;
  border-color: #5bc37a;
  background: rgba(91,195,122,.10);
}

/* Thread/timeline/time sections look consistent */
.thread.list, .timeline, .list {
  display: grid; gap: 8px;
  border: 1px solid var(--border,#2a2a2a);
  border-radius: 10px;
  padding: 10px;
  background: var(--card,#181818);
}
.comment { padding: 8px; border-bottom: 1px dashed #2a2a2a; }
.comment:last-child { border-bottom: 0; }
.timeline-item {
  font-size: 12px; line-height: 1.35;
  padding-left: 10px; border-left: 2px solid #333;
}

/* Form grid on left */
.modal-surface .grid,
dialog.modal .grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.modal-surface .grid label,
dialog.modal .grid label {
  display: grid; gap: 6px;
  font-size: 12px; font-weight: 600; color: var(--muted,#a8b3b6);
}
.modal-surface input,
.modal-surface select,
.modal-surface textarea,
dialog.modal input, dialog.modal select, dialog.modal textarea {
  width: 100%;
  padding: .55rem .65rem;
  border-radius: 10px;
  border: 1px solid var(--border,#2a2a2a);
  background: var(--card,#181818);
  color: var(--text,#eaeaea);
  outline: none;
}
.modal-surface input:focus,
.modal-surface select:focus,
.modal-surface textarea:focus,
dialog.modal input:focus,
dialog.modal select:focus,
dialog.modal textarea:focus {
  border-color: #5bc37a;
  box-shadow: 0 0 0 2px rgba(91,195,122,.20);
}

/* Buttons */
.modal-surface .btn.primary,
dialog.modal .btn.primary {
  border: 1px solid #5bc37a;
  background: #5bc37a;
  color: #0f1a12;
  font-weight: 700;
}
.modal-surface .btn.primary:hover,
dialog.modal .btn.primary:hover { filter: brightness(1.05); }

.modal-surface .btn-outline,
dialog.modal .btn-outline {
  border: 1px solid var(--border,#2a2a2a);
  background: transparent;
  color: var(--text,#eaeaea);
}

/* Small helpers */
.mono { font-variant-numeric: tabular-nums; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.muted { color: var(--muted,#9aa6a9); }
.task-sub { color: var(--muted,#93a0a3); }

/* Responsive collapse: stack the panes below 920px */
@media (max-width: 920px) {
  dialog.modal.two-pane { width: min(96vw, 720px); }
  dialog.modal.two-pane .modal-scroll { grid-template-columns: 1fr; }
}

/* Mini time dialog size */
#modalTime.modal { width: min(460px, 92vw); }
#modalTime .row { display: grid; gap: 8px; margin: 8px 0; }
/* Bigger canvas + taller viewport */
dialog.modal {
  width: min(1280px, 98vw);
  max-height: 92vh;
}

/* Wider two-pane split */
dialog.modal.two-pane .modal-scroll {
  grid-template-columns: 1.8fr 1.2fr;
}

/* Footer buttons inline & compact */
.modal-surface .modal-actions,
dialog.modal .modal-actions {
  gap: .4rem;
  padding: 10px 14px;
}
.modal-surface .btn.primary,
.modal-surface .btn-outline,
dialog.modal .btn.primary,
dialog.modal .btn-outline {
  padding: .4rem .7rem;
  border-radius: 10px;
  font-weight: 700;
  line-height: 1.15;
}



/* ── Dialog scale & scaffold (freshened, consistent) ─────────────────── */
.modal.modal-surface::backdrop,
dialog.modal::backdrop {
  background: rgba(0,0,0,.4);
  backdrop-filter: none;
}
dialog.modal,
.modal.modal-surface {
  --modal-max-width: min(840px, 96vw);
  --modal-max-height: min(90vh, 980px);
  --modal-pad-x: clamp(14px, 3.2vw, 22px);
  --modal-pad-y: clamp(12px, 2.8vh, 18px);

  padding: 0;
  border: 1px solid var(--border,#2a2a2a);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255,255,255,.02), rgba(0,0,0,.08)) var(--panel,#121212);
  color: var(--text,#eaeaea);
  box-shadow: 0 22px 65px rgba(0,0,0,.45), 0 0 0 1px rgba(255,255,255,.02) inset;
  width: var(--modal-max-width);
  max-width: var(--modal-max-width);
  max-height: var(--modal-max-height);
  overflow: hidden;
}
dialog.modal,
.modal.modal-surface {
  position: fixed;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  z-index: 2000;
}
dialog.modal .modal-body,
.modal.modal-surface .modal-body {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto; /* header | scroll | footer */
  width: 100%;
  height: 100%;
  max-height: var(--modal-max-height);
}
dialog.modal .modal-scroll,
.modal.modal-surface .modal-scroll {
  overflow: auto;
  padding: calc(var(--modal-pad-y) - 2px) var(--modal-pad-x) calc(var(--modal-pad-y) + 4px);
}

dialog.modal.three-pane,
.modal.modal-surface.three-pane {
  --modal-max-width: min(1200px, 98vw);
  min-height: min(88vh, 900px);
}

.modal.modal-surface,
dialog.modal { display: none; }
.modal.modal-surface[open],
.modal.modal-surface.is-open,
dialog.modal[open] { display: block; }

.modal.modal-surface.modal-fallback,
dialog.modal.modal-fallback {
  position: fixed;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  /* Ensure fallback dialogs sit above the shared backdrop */
  z-index: 2000;
  margin: 0;
  display: grid;
  width: var(--modal-max-width, min(840px, 96vw));
  max-height: var(--modal-max-height, min(90vh, 980px));
  z-index: 2000;
}

/* Inline editor footer for task/issue dialogs */
.editor-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .5rem;
  padding: 10px 14px;
  background: var(--panel, #121212);
  border-top: 1px solid var(--border, #2a2a2a);
  border-radius: 0 0 12px 12px;
}

.modal-actions.editor-actions {
  justify-content: flex-end;
}

.modal-actions.editor-actions .editor-bar {
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

.editor-bar.hidden { display: none; }

/* ── Three-pane layout: Form | History+Time | Comments ─────────────── */
dialog.modal.three-pane .modal-scroll {
  display: grid;
  grid-template-columns: minmax(360px, 1.6fr) minmax(340px, 1fr) minmax(340px, 1fr);
  gap: 16px;
  max-height: calc(88vh - 48px);
}
.pane-left, .pane-mid, .pane-right { min-height: 0; display: grid; align-content: start; gap: 10px; }
.pane-title { margin: 0 0 6px; font-size: 18px; font-weight: 800; letter-spacing: .2px; }
.pane-subtitle { margin: 0; font-size: 13px; font-weight: 700; opacity: .9; }

/* Left form grid */
.modal-surface .grid,
dialog.modal .grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.modal-surface .grid label { display: grid; gap: 6px; font-size: 12px; font-weight: 600; color: var(--muted,#9aa6a9); }
.modal-surface input, .modal-surface select, .modal-surface textarea, dialog.modal input, dialog.modal select, dialog.modal textarea {
  width: 100%; padding: .55rem .65rem; border-radius: 10px;
  border: 1px solid var(--border,#2a2a2a); background: var(--card,#181818); color: var(--text,#eaeaea);
}
.modal-surface input:focus, .modal-surface select:focus, .modal-surface textarea:focus, dialog.modal input:focus, dialog.modal select:focus, dialog.modal textarea:focus {
  border-color: #5bc37a; box-shadow: 0 0 0 2px rgba(91,195,122,.20);
}

/* Middle: timeline + time */
.timeline, .list, .thread.list {
  display: grid; gap: 8px; border: 1px solid var(--border,#2a2a2a);
  border-radius: 10px; padding: 10px; background: var(--card,#181818);
}
.timeline-item { font-size: 12px; line-height: 1.35; padding-left: 10px; border-left: 2px solid #333; }
.divider { height: 1px; background: var(--border,#2a2a2a); opacity: .75; margin: 6px 0; }
.time-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

/* Right: comments composer sticks to bottom visually */
.composer { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 8px; }

/* Floating global action bar (outside dialogs) */
.actionbar {
  position: fixed; right: 20px; bottom: 20px; z-index: 20000;
  display: flex; gap: .5rem; padding: 10px 12px;
  background: var(--panel,#121212); color: var(--text,#eaeaea);
  border: 1px solid var(--border,#2a2a2a); border-radius: 12px;
  box-shadow: 0 12px 30px rgba(0,0,0,.28);
}
.actionbar.hidden { display: none; }
.actionbar .btn.primary {
  border: 1px solid #5bc37a; background: #5bc37a; color: #0f1a12; font-weight: 700;
}
.actionbar .btn-outline {
  border: 1px solid var(--border,#2a2a2a); background: transparent; color: var(--text,#eaeaea);
}

/* Mini time modal */
#modalTime.modal.mini { width: min(520px, 94vw); max-height: 60vh; }
#modalTime .mini-scroll { padding-top: 18px; }
#modalTime .row { display: grid; gap: 8px; margin: 10px 0; }

/* Responsive: collapse panes on small screens */
@media (max-width: 1100px) {
  dialog.modal.three-pane .modal-scroll { grid-template-columns: 1fr; }
  .actionbar { left: 50%; right: auto; transform: translateX(-50%); }
}
@media (max-width: 900px) {
  dialog.modal.three-pane { width: min(98vw, 100%); }
}
#modalSyncCsv .chip { border-radius: 10px; }
/* Make Automations dialog larger/taller */
#modalAutomations.modal {
  width: min(1280px, 98vw);
  max-height: 90vh;
}

/* Slim footer bar + compact buttons */
.modal-actions--slim {
  padding: 10px 14px;
  gap: .4rem;
}
.modal-actions--slim .btn,
.modal-actions--slim .btn-outline,
.modal-actions--slim .chip {
  padding: .35rem .6rem;
  border-radius: 10px;
  line-height: 1.1;
  font-weight: 700;
}

/* Card-y list items for automations */
#modalAutomations #autoList .row {
  padding:10px; border-radius:10px; border:1px solid var(--border); background:var(--card);
}
#modalAutomations #autoList .row + .row { margin-top:8px; }

/* Ensure the User Picker sits above any <dialog> */
dialog.modal { z-index: 2000; }
dialog.modal::backdrop { z-index: 1990; }
#modalUserPicker { z-index: 40000; }

/* User picker sizing */
#modalUserPicker {
  width: var(--up-width, min(420px, 96vw));
  max-height: min(72vh, 540px);
  margin: 0;
  transform: none;
}
#modalUserPicker .modal-scroll { padding: 10px var(--modal-pad-x); }
#modalUserPicker[data-inline="1"] {
  position: absolute;
  inset: var(--up-top, 0) auto auto var(--up-left, 0);
}
#modalUserPicker[data-fullscreen="1"] {
  position: fixed;
  inset: 0;
  width: 100vw;
  max-width: 100vw;
  height: 100vh;
  max-height: 100vh;
  border-radius: 0;
}
#modalUserPicker[data-fullscreen="1"] .modal-body {
  grid-template-rows: auto 1fr auto;
  height: 100%;
}
#modalUserPicker[data-fullscreen="1"] .modal-scroll { max-height: none; }

/* Mobile-friendly modal & header tweaks */
@media (max-width: 900px) {
  dialog.modal,
  .modal-surface { width: min(98vw, 100%); max-height: 92vh; }
  dialog.modal .modal-scroll,
  .modal-surface .modal-scroll { padding: calc(var(--modal-pad-y) - 2px) var(--modal-pad-x) calc(var(--modal-pad-y) + 2px); }
  dialog.modal .grid,
  .modal-surface .grid { grid-template-columns: 1fr; }
  dialog.modal .composer { grid-template-columns: 1fr; }
}

/* Short viewport handling (e.g., landscape phones/tablets) */
@media (max-height: 620px) {
  .modal-layer { align-items: flex-start; padding: 8px 0 12px; }
  dialog.modal,
  .modal-surface {
    width: min(98vw, 100%);
    max-height: calc(100vh - 12px);
    --modal-pad-x: clamp(10px, 2.5vw, 16px);
    --modal-pad-y: clamp(10px, 2vh, 14px);
  }
  dialog.modal.three-pane { min-height: auto; }
  dialog.modal .modal-body,
  .modal-surface .modal-body { grid-template-rows: auto minmax(0, 1fr) auto; }
  dialog.modal .modal-header,
  .modal-surface .modal-header,
  dialog.modal .modal-actions,
  .modal-surface .modal-actions { padding: 10px 12px; }
  dialog.modal .modal-title,
  .modal-surface .modal-title { font-size: 16px; }
  dialog.modal .modal-scroll,
  .modal-surface .modal-scroll { padding: calc(var(--modal-pad-y) - 2px) var(--modal-pad-x) calc(var(--modal-pad-y) + 2px); }
}

/* Landscape handling: keep breathing room while preventing overflow */
@media screen and (orientation: landscape) {
  .modal-layer { align-items: center; padding: 6px 0 10px; }
  dialog.modal,
  .modal-surface {
    width: min(98vw, 1120px);
    max-width: min(98vw, 1120px);
    max-height: min(90vh, 880px);
    margin: 0;
    border-radius: 14px;
  }
  dialog.modal .modal-body,
  .modal-surface .modal-body { grid-template-rows: auto minmax(0, 1fr) auto; }
  dialog.modal .modal-scroll,
  .modal-surface .modal-scroll { max-height: none; }
}

#modalIssue.modal,
#simpleIssueDialog.modal {
  --modal-max-width: min(760px, 96vw);
  --modal-max-height: min(88vh, 860px);
}

#modalIssue .modal-scroll,
#simpleIssueDialog .modal-scroll {
  display: grid;
  gap: 12px;
}

#modalIssue .modal-actions,
#simpleIssueDialog .modal-actions {
  position: sticky;
  bottom: 0;
  background: linear-gradient(180deg, rgba(0,0,0,.02), var(--panel,#121212));
  box-shadow: 0 -6px 18px rgba(0,0,0,.35);
}

@media (max-width: 720px) {
  .editor-bar {
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    border-radius: 0;
    box-shadow: 0 -6px 20px rgba(0,0,0,.35);
    z-index: 2100;
  }
  dialog.modal.three-pane .modal-scroll { grid-template-columns: 1fr; }
  #modalIssue.modal,
  #simpleIssueDialog.modal {
    --modal-max-width: min(96vw, 620px);
    --modal-max-height: min(88vh, 760px);
  }
}

@media (max-width: 640px) {
  .task-header { flex-direction: column; align-items: stretch; }
  .task-header__meta { width: 100%; }
  .task-header__actions { width: 100%; }
  .task-header__actions .btn { width: 100%; text-align: center; }
  #modalIssue.modal,
  #simpleIssueDialog.modal {
    --modal-max-width: min(96vw, 560px);
    --modal-max-height: min(88vh, 700px);
  }
  #modalIssue .modal-body,
  #simpleIssueDialog .modal-body {
    grid-template-rows: auto 1fr auto;
  }
  #modalIssue .modal-scroll,
  #simpleIssueDialog .modal-scroll {
    padding: 12px;
    display: grid;
    gap: 10px;
  }
  #modalIssue .grid { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  #modalPointsHelp.modal,
  #modalLeaderboard.modal {
    width: 100%;
    max-width: 100%;
    max-height: 92vh;
    margin: 8px;
    border-radius: 12px;
  }
  #modalPointsHelp .modal-body,
  #modalLeaderboard .modal-body {
    height: auto;
    grid-template-rows: auto 1fr auto;
  }
  #modalPointsHelp .modal-scroll,
  #modalLeaderboard .modal-scroll {
    max-height: none;
    padding: 14px 12px;
  }
  #modalLeaderboard .leaderboard-stage { display: none; }
  .leaderboard-row {
    grid-template-columns: auto 1fr;
    align-items: start;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px;
  }
  .leaderboard-points, .leaderboard-quality { justify-self: start; }
}
/* Automations layout */
.auto-layout {
  display: grid;
  grid-template-columns: 280px 1fr; /* list | editor */
  gap: 16px;
  min-height: 420px;
}

/* When editing: make the editor span full width and hide sidebars */
.auto-layout.wide .auto-editor {
  grid-column: 1 / -1;
}
.auto-layout.wide .auto-list-pane,
.auto-layout.wide .auto-side {
  display: none;
}
  .tab-btn {
    border: 1px solid var(--border);
    background: var(--panel);
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
  }
  .tab-btn.active { outline: 2px solid var(--border-strong, #666); }
  .chips-row { display: flex; }
  .chip-toggle {
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 2px 10px;
    cursor: pointer;
    user-select: none;
  }
  .chip-toggle[data-on="1"] {
    background: rgba(91,195,122,.12);
    border-color: #5bc37a;
  }

  /* Tabs */
  .tabs-row { display:flex; gap:8px; flex-wrap:wrap; margin:8px 0 4px; }
  .tab-btn{
    padding:6px 10px;
  border:1px solid var(--border);
  border-radius:8px;
  background:var(--panel);
  color:var(--fg);
  font-weight:600;
  cursor:pointer;
}
  .tab-btn:hover{ background:var(--panel-2, rgba(255,255,255,.02)); }

  .pill-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding: 6px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
  }

  .pill-tab {
    border-radius: 999px;
    padding: 6px 12px;
    background: transparent;
    border: 1px solid transparent;
    font-weight: 700;
    transition: background .15s ease, border-color .15s ease, color .15s ease;
  }

  .pill-tab.active {
    background: var(--card);
    border-color: var(--border);
    box-shadow: 0 1px 0 rgba(0,0,0,.1);
  }

  .task-view-switcher { display:flex; flex-direction: column; gap:6px; align-items: flex-start; }
  .task-view-label { font-size: 11px; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }
.tab-btn.active{
  background:var(--accent-weak, #2b3b2f);
  border-color:var(--accent-weak-border, #4c6d50);
  color:var(--fg, #ddd);
}

.chat-proposals .chip {
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel);
  cursor: pointer;
}

/* --- Guided tour primitives --- */
.tour-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  z-index: 9998;
}
.tour-highlight {
  position: absolute; border-radius: 10px; box-shadow: 0 0 0 9999px rgba(0,0,0,.55);
  outline: 2px solid #7aa2ff; transition: all .15s ease;
  z-index: 9999; pointer-events: none; /* highlight is “hole” effect via huge shadow */
}
.tour-tooltip {
  position: absolute; z-index: 10000; max-width: 420px;
  background: var(--panel, #1e1f26); color: var(--fg, #eee);
  border: 1px solid var(--border, #3a3c46); border-radius: 10px; padding: 12px 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,.3);
}
.tour-tooltip h4 { margin: 0 0 6px; font-size: 15px; }
.tour-tooltip p  { margin: 0 0 10px; opacity: .9; }
.tour-tooltip .row { display:flex; gap:8px; justify-content:flex-end; }
.tour-tooltip .btn {
  border:1px solid var(--border,#3a3c46); background:transparent; color:inherit;
  padding:.35rem .6rem; border-radius:8px; cursor:pointer;
}
.tour-tooltip .btn.primary { background:#6aa6ff; border-color:#6aa6ff; color:#081126; }
@media (max-width:600px){
  .tour-tooltip{ max-width: calc(100vw - 24px); }
}
.tour-overlay { pointer-events: none; }
/* soften locked rows */
.row.status-awaiting_approval,
.row.status-in_review,
.row.status-approved {
  opacity: .72;
}
.row.status-awaiting_approval .chip,
.row.status-in_review .chip,
.row.status-approved .chip {
  pointer-events: none;
  opacity: .7;
}

/* Allow reopen on approved rows */
.row.status-approved [data-action="reopen_task"] {
  pointer-events: auto;
  opacity: 1;
}

/* BUT: still allow Log issue + Approve */
.row.status-awaiting_approval [data-action="log_issue"],
.row.status-in_review [data-action="log_issue"],
.row.status-awaiting_approval [data-action="approve"],
.row.status-in_review [data-action="approve"] {
  pointer-events: auto;
  opacity: 1;
}
.hidden {
  display: none !important;
}

/* Inline issue strip under task rows */
.task-issue-row > td {
  border-top: none;
  padding-top: 0;
  padding-bottom: 4px;
}

.task-issue-box {
  margin-left: 10px;              /* slight indent under main card */
  margin-top: 2px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px dashed var(--border);
  background: #101010;
  font-size: 12px;
  color: var(--muted,#9aa6a9);
}

.task-issue-header {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: baseline;
  margin-bottom: 2px;
}

.task-issue-count {
  font-weight: 600;
  color: var(--text,#eaeaea);
}

.task-issue-meta {
  font-size: 11px;
  opacity: .85;
}

.task-issue-summary {
  font-size: 12px;
  line-height: 1.35;
  color: var(--muted,#9aa6a9);
}
/* Inline issues strip under task titles */
.task-issues {
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid rgba(255,255,255,.04); /* thin grey-ish line */
}

.task-issue-line {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--muted, #9aa6a9);
  padding: 2px 0;
}

.task-issue-line .issue-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #555;
  flex-shrink: 0;
}

.task-issue-line .issue-code {
  font-weight: 600;
  opacity: .9;
}

.task-issue-line .issue-summary {
  flex: 1 1 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-issue-line .issue-meta {
  flex-shrink: 0;
  opacity: .85;
}

.task-issue-line .issue-status-pill {
  flex-shrink: 0;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid var(--border, #333);
  font-size: 10px;
  text-transform: capitalize;
}

/* A hint of color but still very muted */
.task-issue-line.status-open .issue-status-pill {
  border-color: #f3c25d;
}
.task-issue-line.status-resolved .issue-status-pill {
  border-color: #5bc37a;
  opacity: .85;
}
/* Issues row under a task */
.task-issues-row > td {
  border-top: none;
  padding: 0 8px 6px;
}

/* keep it visually closer to the row above */
.task-issues-row + .row {
  margin-top: 0;
}

/* Container: slim, slightly indented sub-card */
.task-issues-inline {
  margin-top: 2px;
  margin-left: 10px;                 /* indent under main title column */
  padding: 5px 8px;
  border-radius: 8px;
  border: 1px solid var(--border, #2a2a2a);
  background: #0b0b0b;              /* or var(--card) if you want it lighter */
}

/* One thin line per issue */
.task-issue-inline {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--muted, #9aa6a9);
  padding: 1px 0;
}

.task-issue-inline + .task-issue-inline {
  margin-top: 1px;
}

.task-issue-inline .issue-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #555;
  flex-shrink: 0;
}

.task-issue-inline .issue-code {
  font-weight: 600;
  opacity: .9;
}

.task-issue-inline .issue-summary {
  flex: 1 1 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-issue-inline .issue-meta {
  flex-shrink: 0;
  opacity: .85;
}

.task-issue-inline .issue-status-pill {
  flex-shrink: 0;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid var(--border, #333);
  font-size: 10px;
  text-transform: capitalize;
}

/* Very subtle status hints */
.task-issue-inline.status-open .issue-status-pill {
  border-color: #f3c25d;
}

.task-issue-inline.status-resolved .issue-status-pill {
  border-color: #5bc37a;
}
.task-table th.sortable {
  cursor: pointer;
  white-space: nowrap;
  position: relative;
  user-select: none;
}

.task-table th.sortable::after {
  content: '⇅';
  font-size: 10px;
  opacity: 0.3;
  margin-left: 4px;
}

.task-table th.sortable.sort-asc::after {
  content: '▲';
  opacity: 0.8;
}

.task-table th.sortable.sort-desc::after {
  content: '▼';
  opacity: 0.8;
}

  .task-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
  }

  .task-topbar { flex-wrap: wrap; gap: 16px; }
  .task-topbar__primary { flex: 1; min-width: 280px; display: flex; flex-direction: column; gap: 10px; }
  .task-topbar__aside {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    align-items: start;
    min-width: 320px;
  }

  .task-header__titles { display: flex; flex-direction: column; gap: 6px; }
  .task-header__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; color: var(--muted); }
  .task-header__stat { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); }
  .task-header__stat strong { font-size: 14px; color: var(--text); }
  .task-header__toggle { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); color: var(--text); }
  .task-header__approvals { display: inline-flex; align-items: center; gap: 6px; margin-left: 0; }
  .task-header__actions { display: flex; align-items: flex-start; justify-content: flex-end; gap: 8px; }
  .task-header__actions .btn { white-space: nowrap; }

  .task-filter-summary {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
    margin-top: 2px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--panel);
  }

  .task-filter-summary__row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
  }

  .task-filter-summary__meta {
    justify-content: space-between;
  }

  .task-filter-summary__meta-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
  }

  .task-filter-summary__controls {
    justify-content: space-between;
    gap: 16px;
  }

  .task-filter-summary__filters {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    flex: 1;
    min-width: 240px;
  }

  .task-filter-chips {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    font-size: 12px;
  }

  .task-filter-chips .chip-ghost {
    border-radius: 999px;
    padding: 6px 10px;
    background: var(--card);
  }

  .task-filter-select {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 220px;
    color: var(--muted);
    font-size: 12px;
  }

  .task-filter-select__label {
    font-weight: 600;
  }

  .task-filter-select__input {
    color: inherit;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 10px;
    min-height: 36px;
  }

  .task-toolbar {
    padding: 12px 16px 8px;
    background: var(--panel);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    border-radius: 12px;
    margin-top: 6px;
  }

  .task-filters-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: inherit;
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease;
  }

.task-filters-toggle:hover,
.task-filters-toggle:focus-visible {
  border-color: var(--highlight, #5bc37a);
  background: rgba(91,195,122,.06);
}

.task-filters-toggle__chevron {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform .15s ease;
  margin-bottom: 1px;
}

.task-filters-toggle.collapsed .task-filters-toggle__chevron {
  transform: rotate(-135deg);
}

#taskFiltersPanel[hidden] {
  display: none;
}

.task-filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px 12px;
  align-items: end;
}

.task-filter-field { display: flex; flex-direction: column; gap: 6px; }
.task-filter-label { font-size: 11px; color: var(--muted); letter-spacing: .01em; text-transform: uppercase; }
.task-filter-input {
  width: 100%;
  box-sizing: border-box;
  font-size: 12px;
  padding: 8px 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.task-filter-input:focus {
  border-color: var(--highlight);
  outline: none;
  box-shadow: 0 0 0 2px rgba(91,195,122,.25);
}

.task-filter-date-range {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.task-filter-date { min-height: 36px; }
.task-issues-row td {
  padding-top: 4px;
  padding-bottom: 4px;
  /* background: #0b0b0b; */
  border-top: 1px solid #222;
}

.task-issues-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.task-issue-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid #333;
  font-size: 11px;
  /* background: #111; */
  color: #ddd;
}

.task-issue-inline .issue-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #f66;
}

.task-issue-inline .issue-code {
  opacity: 0.85;
}

.task-issue-inline .issue-status-pill {
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid #555;
  font-size: 10px;
  text-transform: lowercase;
  opacity: 0.8;
}
.task-issues-row td {
  padding-top: 4px;
  padding-bottom: 4px;
  /* background: #0b0b0b; */
  border-top: 1px solid #222;
}

.task-issues-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.task-issue-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid #333;
  font-size: 11px;
  /* background: #111; */
  color: #ddd;
}

.task-issue-inline .issue-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #f66;
}
/* Issues row visually “attached” to card above */
.task-issues-row > td {
  padding-top: 0;
  padding-bottom: 6px;
  background: transparent;       /* no black rectangle */
  border-top: none;              /* no hard line between task + issues */
}

/* Container: a subtle inset strip, but not its own card */
.task-issues-inline {
  margin-top: -4px;              /* tuck closer to the main row */
  margin-left: 16px;             /* slight indent under title */
  padding-top: 4px;
  padding-bottom: 2px;
  border-top: 1px solid rgba(255,255,255,.06);  /* light divider only */
  border-radius: 0;
  background: transparent;       /* remove #0b0b0b square */
}

/* Each issue as a tiny pill */
.task-issue-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid #333;
  font-size: 11px;
  background: #111;              /* still a small darker pill */
  color: #ddd;
}

.task-issue-inline + .task-issue-inline {
  margin-left: 4px;
  margin-top: 2px;
}

.task-issue-inline .issue-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #f66;
  flex-shrink: 0;
}

.task-issue-inline .issue-summary {
  max-width: 260px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-issue-inline .issue-status-pill {
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid #555;
  font-size: 10px;
  text-transform: lowercase;
  opacity: 0.85;
}
.task-issue-inline {
  cursor: pointer;
}

.task-issue-inline:hover {
  border-color: #5bc37a;
  background: #151a15;
}

.project-new-bar {
  margin-bottom: 8px;
}

.project-new-form {
  display: flex;
  gap: 4px;
  align-items: center;
}

.project-new-form .input-sm {
  flex: 1;
  padding: .25rem .4rem;
  font-size: 12px;
}

.btn-sm {
  padding: .25rem .5rem;
  font-size: 12px;
  border-radius: 8px;
}

/* Admin dropdown */
.admin-menu {
  position: relative;
}

.admin-menu .has-caret::after {
  content: "▾";
  margin-left: 6px;
  font-size: 11px;
  opacity: .8;
}

.admin-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 220px;
  padding: 8px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.28);
  display: none;
  z-index: 20;
}

.admin-menu-panel.open {
  display: grid;
  gap: 4px;
}

.admin-menu-item {
  width: 100%;
  text-align: left;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  padding: 8px 10px;
  color: inherit;
  text-decoration: none;
}

.admin-menu-item:hover,
.admin-menu-item:focus-visible {
  border-color: var(--border);
  background: rgba(255, 255, 255, 0.04);
}

/* Points config modal */
.points-config-intro {
  margin-bottom: 12px;
  color: var(--muted);
}

.points-config-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}

@media (min-width: 880px) {
  .points-config-grid { grid-template-columns: repeat(2, minmax(320px, 1fr)); }
}

.points-config-section {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: var(--card);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.points-config-section h4 {
  margin: 0 0 6px;
}

.points-config-section p {
  margin: 0 0 10px;
  color: var(--muted);
}

.points-field {
  display: grid;
  grid-template-columns: 1fr 86px;
  gap: 10px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.points-field:last-child {
  border-bottom: none;
}

.points-field label {
  display: block;
  font-weight: 600;
}

.points-field .field-note {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.points-field .range-wrap {
  display: grid;
  gap: 6px;
}

.points-field input[type="range"] {
  width: 100%;
  accent-color: var(--highlight);
}

.points-field input[type="number"] {
  width: 86px;
  padding: 6px 8px;
}

/* Points history */
.points-history {
  display: grid;
  gap: 12px;
}

.points-history-empty {
  margin: 4px 0;
  color: var(--muted);
}

.points-history-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}

.points-history-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--card);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
  display: grid;
  gap: 6px;
}

.points-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.points-history-delta {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.points-history-delta.positive { color: var(--success); }
.points-history-delta.negative { color: var(--warn); }

.points-history-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  color: var(--muted);
  font-size: 12px;
}

.points-history-note {
  margin: 0;
}

.points-field .field-value {
  font-weight: 600;
  color: var(--highlight);
}

#modalPointsConfig .modal-scroll {
  max-height: min(72vh, 760px);
}

.toast-notification {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(520px, 96vw);
  min-width: 320px;
  background: rgba(0, 0, 0, 1);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
  overflow: hidden;
  transform: translateY(120%);
  opacity: 0;
  transition: transform 220ms ease, opacity 220ms ease;
  z-index: 40;
}

.toast-notification.show {
  transform: translateY(0);
  opacity: 1;
}

.toast-glow {
  height: 6px;
  background: linear-gradient(90deg, var(--highlight), #ff8f70, #ffd54f);
  animation: toast-glow 6s linear infinite;
}

  .toast-body {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    align-items: center;
    padding: 14px 16px;
  }

.toast-text {
  display: grid;
  gap: 6px;
}

.toast-title {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.01em;
}

.toast-meta {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
  word-break: break-word;
}

.toast-summary {
  font-size: 14px;
  line-height: 1.5;
}

.toast-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.toast-actions .btn-ghost {
  padding: 6px 12px;
  background: var(--bg-weak);
  border-radius: 10px;
  border: 1px solid var(--border-strong);
}

.toast-actions .btn-ghost:hover {
  background: var(--bg);
  border-color: var(--highlight);
  color: var(--text-strong);
  box-shadow: 0 0 0 3px rgba(106, 191, 255, 0.18);
}

.toast-actions .icon-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  border-radius: 8px;
  width: 34px;
  height: 34px;
}

.toast-actions .icon-btn:hover {
  color: var(--text);
  background: var(--bg-weak);
}

@keyframes toast-glow {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* Project feed */
.project-grid-view { display:grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
.project-card { border:1px solid var(--border); border-radius:12px; padding:14px; background: var(--panel); display:flex; flex-direction:column; gap:10px; }
.project-card__header { display:flex; justify-content:space-between; gap:10px; align-items:flex-start; }
.project-title { display:flex; gap:10px; align-items:flex-start; }
.project-name { font-weight:700; }
.project-client { color: var(--muted); font-size:13px; }
.project-meta { color: var(--muted); font-size:13px; text-align:right; }
.project-card__stats { display:grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap:10px; font-size:14px; }
.project-card__actions { display:flex; gap:8px; flex-wrap:wrap; }
.project-bar { display:grid; grid-template-columns: auto 1fr auto; align-items:center; gap:8px; font-size:14px; }
.project-bar__track { position:relative; background: var(--border); border-radius:999px; height:8px; overflow:hidden; }
.project-bar__track span { position:absolute; inset:0; background: linear-gradient(90deg, #6ddf98, #70b8ff); border-radius:999px; }
.project-bar__label { color: var(--muted); font-size:13px; }
.project-bar__value { text-align:right; font-variant-numeric: tabular-nums; font-size:13px; color: var(--muted); }
.traffic { width:12px; height:12px; border-radius:50%; display:inline-block; margin-right:4px; border:1px solid var(--border); }
.traffic-good { background:#1f9d55; }
.traffic-warn { background:#e6b04a; }
.traffic-bad { background:#e85d75; }
.traffic-muted { background:var(--border); }
.project-timeline-view { display:flex; flex-direction:column; gap:16px; }
.timeline-section { border:1px solid var(--border-strong); border-radius:14px; padding:16px; background: linear-gradient(180deg, rgba(255,255,255,.12), rgba(255,255,255,.08)); display:flex; flex-direction:column; gap:12px; box-shadow:0 12px 36px rgba(0,0,0,.18); }
.timeline-section header { display:flex; justify-content:space-between; align-items:center; gap:10px; }
.timeline-track { position:relative; min-height:220px; border:1px solid var(--border-strong); border-radius:14px; padding:16px; overflow-x:auto; background: radial-gradient(circle at 16% 24%, rgba(112,184,255,.12), transparent 34%), radial-gradient(circle at 82% 62%, rgba(144,223,152,.12), transparent 30%), #f6fff7; box-shadow:inset 0 1px 0 rgba(255,255,255,.2); }
.timeline-axis { position:relative; min-width:900px; height:4px; margin:10px 0 18px; border-radius:999px; box-shadow:0 6px 20px rgba(0,0,0,.25); background: linear-gradient(90deg, rgba(255,255,255,.2), rgba(255,255,255,.14)); background-image: linear-gradient(90deg, transparent, transparent), repeating-linear-gradient(90deg, rgba(255,255,255,.12), rgba(255,255,255,.12) 1px, transparent 1px, transparent 80px); background-size: 100% 4px, 100% 4px; background-repeat: no-repeat; }
.timeline-axis::before, .timeline-axis::after { content:""; position:absolute; top:-8px; width:2px; height:20px; border-radius:2px; background: var(--border-strong); }
.timeline-axis::before { left:0; box-shadow:0 0 0 4px rgba(112,184,255,.08); }
.timeline-axis::after { right:0; box-shadow:0 0 0 4px rgba(109,223,152,.08); }
.timeline-bars { position:relative; min-width:900px; }
.timeline-bars::before { content:""; position:absolute; inset:0; border-radius:12px; pointer-events:none; background: linear-gradient(90deg, rgba(255,255,255,.04) 0%, transparent 18%, transparent 82%, rgba(255,255,255,.04) 100%); }
.timeline-bar { position:absolute; top:0; height:56px; border-radius:16px; padding:10px 12px; background: linear-gradient(135deg, rgba(112, 184, 255, .26), rgba(109, 223, 152, .3)); border:1px solid var(--border-strong); box-shadow:0 8px 26px rgba(0,0,0,.26); color: var(--text); }
.timeline-bar .project-name { font-weight:700; font-size:15px; letter-spacing:.01em; }
.timeline-bar .muted { font-size:13px; }
.timeline-bar:focus-visible { outline:2px solid var(--highlight, #6bbfff); outline-offset:3px; }
.timeline-tab-view { display:flex; flex-direction:column; gap:14px; height:100%; }
.timeline-stack { display:flex; flex-direction:column; gap:14px; }
.resource-timeline { display:flex; flex-direction:column; gap:10px; height:100%; }
.timeline-visual { width:100%; min-height:320px; flex:1 1 auto; }
.timeline-label { display:flex; flex-direction:column; gap:2px; }
.timeline-label .muted { font-size:12px; }
.timeline-section { height:100%; }

#projectsView, #resourcesView, #combinedView { min-height:0; }

.vis-item.status-in_progress, .timeline-bar.status-in_progress { background: linear-gradient(135deg, rgba(109,223,152,.32), rgba(87,196,255,.32)); border-color: var(--highlight, #5bc37a); }
.vis-item.status-delayed, .timeline-bar.status-delayed { background: linear-gradient(135deg, rgba(255,176,77,.32), rgba(255,124,124,.28)); border-color: #e28a44; }
.vis-item.status-late, .timeline-bar.status-late, .vis-item.status-warn, .timeline-bar.status-warn { background: linear-gradient(135deg, rgba(255,124,124,.32), rgba(255,94,94,.28)); border-color: #d9534f; }
.vis-item.status-pending, .timeline-bar.status-pending { background: linear-gradient(135deg, rgba(112,184,255,.22), rgba(109,223,152,.22)); border-color: var(--border-strong); }
.vis-item.status-awaiting_approval, .vis-item.status-in_review, .vis-item.status-changes_requested { background: linear-gradient(135deg, rgba(255,214,102,.26), rgba(255,176,77,.24)); border-color: #d2a045; }
.resource-axis { display:flex; justify-content:space-between; color: var(--muted); font-size:12px; padding:0 6px; }
.resource-row { display:grid; grid-template-columns:210px 1fr; gap:10px; align-items:flex-start; }
.resource-row__label { font-weight:700; color: var(--muted-strong); }
.resource-row__scroller { position:relative; overflow-x:auto; }
.resource-row__track { position:relative; border:1px dashed var(--border); border-radius:10px; padding:14px; background: var(--bg-weak); min-height:60px; min-width:960px; }
.resource-row__track::before { content:""; position:absolute; left:14px; right:14px; top:50%; height:1px; background: var(--border-strong); opacity:.35; }
.resource-chip { position:absolute; height:32px; padding:6px 10px; border-radius:12px; font-size:13px; border:1px solid var(--border-strong); background: linear-gradient(90deg, rgba(255,255,255,.12), rgba(112, 184, 255, .2)); box-shadow:0 4px 12px rgba(0,0,0,.18); white-space:nowrap; }
.project-detail { position:fixed; inset:0; display:none; align-items:center; justify-content:center; z-index:2000; }
.project-detail.is-open { display:flex; }
.project-detail__backdrop { position:absolute; inset:0; background:rgba(0,0,0,.55); backdrop-filter: blur(2px); }
.project-detail__panel { position:relative; width:min(1100px, 94vw); max-height:90vh; overflow:auto; border-radius:16px; background: var(--bg); border:1px solid var(--border-strong); box-shadow:0 20px 70px rgba(0,0,0,.45); padding:18px; display:flex; flex-direction:column; gap:14px; transform: scale(.96) translateY(10px); opacity:0; transition: transform .2s ease, opacity .2s ease; }
.project-detail.is-open .project-detail__panel { transform: scale(1) translateY(0); opacity:1; }
.project-detail__header { display:flex; justify-content:space-between; align-items:flex-start; gap:10px; }
.project-detail__header-actions { display:flex; gap:8px; align-items:center; }
.project-detail__meta { display:grid; grid-template-columns: repeat(auto-fit, minmax(180px,1fr)); gap:10px; padding:12px; border:1px solid var(--border); border-radius:12px; background: var(--bg-weak); }
.project-detail__meta .muted { font-size:13px; }
.project-detail__timelines { display:grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap:12px; }
.project-detail__timeline-block { display:flex; flex-direction:column; gap:8px; }
.project-detail__timeline-title { font-weight:700; font-size:14px; color: var(--muted); }
.project-detail__list { border:1px solid var(--border); border-radius:12px; padding:12px; display:grid; gap:10px; background: var(--panel); }
.project-detail__item { border:1px solid var(--border); border-radius:10px; padding:10px; display:grid; grid-template-columns: 1fr auto; gap:6px; background: var(--bg-weak); }
.project-detail__item .muted { font-size:13px; }
.project-detail__item .chip { justify-self:flex-start; }
.toast-lite { position:fixed; bottom:16px; right:16px; background: var(--panel); border:1px solid var(--border); border-radius:10px; padding:10px 12px; box-shadow:0 4px 30px rgba(0,0,0,.4); z-index:9999; }

/* Org chart */
.org-chart-grid { display:flex; flex-direction:column; gap:12px; }
.org-dept-card { border:1px solid var(--border); border-radius:12px; padding:12px; background: var(--panel); display:flex; flex-direction:column; gap:10px; }
.org-dept-header { display:flex; justify-content:space-between; align-items:flex-start; gap:10px; }
.org-dept-name { font-weight:700; font-size:16px; }
.org-dept-meta { color: var(--muted); font-size:13px; }
.org-meta-row { display:flex; gap:10px; align-items:center; flex-wrap:wrap; }
.org-chip-row { display:flex; gap:6px; flex-wrap:wrap; }
.org-members-grid { display:grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap:10px; }
.org-member-card { border:1px solid var(--border); border-radius:10px; padding:10px; background: var(--bg-weak); display:flex; flex-direction:column; gap:6px; }
.org-member-heading { display:flex; justify-content:space-between; align-items:flex-start; gap:8px; }
.org-member-name { font-weight:600; }
.org-member-username { color: var(--muted); font-size:13px; }
.org-member-roles { color: var(--muted); font-size:12px; }
.org-member-meta { font-size:12px; color: var(--text); line-height:1.4; }

.org-graph-modal .modal-body { gap: 0; }
.org-graph-legend { display:flex; flex-wrap:wrap; gap:10px; align-items:center; margin-bottom:10px; font-size:14px; }
.org-graph-chip { display:inline-flex; align-items:center; gap:6px; padding:6px 10px; border-radius:10px; border:1px solid var(--border); background: var(--bg-weak); }
.org-graph-swatch { width:14px; height:14px; border-radius:50%; border:1px solid var(--border-strong, var(--border)); }
.org-graph-shell { border:1px solid var(--border); border-radius:12px; padding:8px; background: var(--bg-weak); min-height:320px; position:relative; }
.org-graph-status { position:absolute; inset:12px; display:flex; align-items:center; justify-content:center; color: var(--muted); font-size:14px; text-align:center; padding:12px; border:1px dashed var(--border); border-radius:10px; background: rgba(0,0,0,.25); }
.org-graph-svg { width:100%; height:100%; min-height:320px; display:block; }
.org-graph-edge { stroke: rgba(120, 176, 255, .65); stroke-width:2; fill:none; stroke-linecap:round; }
.org-graph-node { fill: var(--panel); stroke: var(--border); stroke-width:2; filter: drop-shadow(0 8px 24px rgba(0,0,0,.35)); }
.org-graph-node text { fill: var(--text); font-size:13px; font-weight:600; }
.org-graph-node .org-graph-sub { fill: var(--muted); font-size:11px; font-weight:500; }
.org-graph-node .org-graph-dept { font-size:11px; font-weight:600; letter-spacing:.01em; }
.org-graph-pip { stroke: rgba(255,255,255,.25); stroke-width:1.5; }
