/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #F7F8FA;
  --white:       #FFFFFF;
  --primary:     #2596BE;
  --primary-light: #EBF5FB;
  --dark:        #272840;
  --sidebar-bg:     #F2F4F8;
  --sidebar-hover:  #EDF0F5;
  --sidebar-text:   #3D4560;
  --sidebar-muted:  #9BA5BE;
  --sidebar-active: #2596BE;
  --border:      #E2E5EA;
  --text:        #272840;
  --text-muted:  #8A8FAF;
  --done:        #27AE60;
  --in-progress: #2596BE;
  --blocked:     #E05252;
  --overdue:     #F0A500;
  --pending:     #8A8FAF;
  --radius:      12px;
  --shadow:      none;
  --shadow-md:   0 4px 16px rgba(39,40,64,0.06);
  --sidebar-width: 220px;
  --header-h:    60px;
  /* Focus surface — light blue, primary accent */
  --focus-bg:    #F0F7FB;
  --focus-border: #D0E8F4;
  --focus-accent: #2596BE;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
  height: 100vh;
}

/* ── Layout ───────────────────────────────────────────────────────────────── */
#app { display: flex; height: 100vh; }
#app-body { display: flex; flex: 1; overflow: hidden; }

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  padding: 0;
  overflow: hidden;
  border-right: 1px solid #E2E8F0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--header-h);
  padding: 0 22px;
  flex-shrink: 0;
  border-bottom: 1px solid #E2E8F0;
}

.sidebar-logo img { width: 32px; height: 32px; filter: none; }
.sidebar-logo span {
  color: var(--dark);
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.3px;
}

.sidebar-section {
  padding: 20px 20px 6px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--sidebar-muted);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  margin: 1px 8px;
  border-radius: 7px;
  color: var(--sidebar-text);
  cursor: pointer;
  transition: background 0.13s, color 0.13s;
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  border: none;
  background: none;
  width: calc(100% - 16px);
  text-align: left;
}

.nav-item:hover { background: var(--sidebar-hover); color: var(--dark); }

/* Active: left accent bar + light blue fill */
.nav-item.active {
  background: #EBF5FB;
  color: var(--sidebar-active);
  box-shadow: inset 3px 0 0 var(--sidebar-active);
}

/* Gantt sub-wrap — collapsed by default */
.nav-sub-wrap {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.2s ease;
}
.nav-sub-wrap.open { max-height: 52px; }

/* Chevron toggle inside Projects nav-item */
.nav-gantt-toggle {
  margin-left: auto;
  padding: 3px 4px;
  border-radius: 4px;
  line-height: 0;
  opacity: 0.45;
  transition: opacity 0.13s, background 0.13s;
  flex-shrink: 0;
}
.nav-item:hover .nav-gantt-toggle { opacity: 0.8; }
.nav-item.active .nav-gantt-toggle { opacity: 1; }
.nav-gantt-toggle:hover { background: rgba(0,0,0,0.06); opacity: 1 !important; }

/* Gantt sub-item under Projects */
.nav-item.nav-sub {
  padding: 7px 14px 7px 44px !important;
  font-size: 12.5px;
  opacity: 0.75;
  position: relative;
  margin-top: 0;
}
.nav-item.nav-sub::before {
  content: '';
  position: absolute;
  left: 26px;
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 6px;
  border-left: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  opacity: 0.45;
}
.nav-item.nav-sub:hover { opacity: 1; }
.nav-item.nav-sub.active { opacity: 1; }

/* Mobile drawer sub-item */
.drawer-sub {
  padding-left: 52px;
  font-size: 13px;
  opacity: 0.82;
}
.drawer-sub.active { opacity: 1; }

.nav-icon {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  opacity: 0.45;
  transition: opacity 0.13s;
}
.nav-item:hover .nav-icon { opacity: 0.7; }
.nav-item.active .nav-icon { opacity: 1; }

.sidebar-bottom {
  margin-top: auto;
  padding: 12px 8px;
  border-top: 1px solid #E2E8F0;
}

.sidebar-bottom .nav-item { font-size: 12px; color: var(--sidebar-muted); }

/* ── Main area ────────────────────────────────────────────────────────────── */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ── Header ───────────────────────────────────────────────────────────────── */
#header {
  height: var(--header-h);
  background: var(--white);
  border-bottom: 1px solid #E5E7EB;
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  flex-shrink: 0;
}

#page-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--dark);
  flex: 1;
}

.header-actions { display: flex; align-items: center; gap: 8px; }

/* ── Content ──────────────────────────────────────────────────────────────── */
#content {
  flex: 1;
  overflow-y: auto;
  padding: 28px 24px 24px;
}
#content:has(#projects-layout),
#content:has(#team-layout) { padding: 0; overflow: hidden; }
/* Projects layout fills its own scroll context */
#phases-panel { scroll-behavior: smooth; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: #1e7da0; }
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-danger { background: var(--blocked); color: white; }
.btn-danger:hover { background: #c44040; }

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid #E2E8F0;
  padding: 20px;
}

/* ── Status badges ────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-pending    { background: #f0f1f6; color: var(--pending); }
.badge-in_progress { background: var(--primary-light); color: var(--primary); }
.badge-done       { background: #e8f8ef; color: var(--done); }
.badge-blocked    { background: #fdf0f0; color: var(--blocked); }
.badge-on_hold    { background: #fef9ec; color: var(--overdue); }
.badge-cancelled  { background: #f5f5f5; color: #aaa; text-decoration: line-through; }

/* Priority dots */
.prio-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.prio-high   { background: var(--blocked); }
.prio-medium { background: var(--overdue); }
.prio-low    { background: var(--done); }

/* ── Quick Capture ────────────────────────────────────────────────────────── */
.quick-capture {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 16px;
  margin-bottom: 24px;
  transition: border-color 0.15s;
}

.quick-capture:focus-within { border-color: var(--primary); }
.quick-capture input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 14px;
  color: var(--text);
  background: transparent;
}
.quick-capture input::placeholder { color: var(--text-muted); }

/* ── Dashboard v2 ─────────────────────────────────────────────────────────── */
.db-wrap { max-width: 1080px; margin: 0 auto; }

/* Greeting */
.db-greeting {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin-bottom: 22px;
}
.db-greeting-text { font-size: 20px; font-weight: 700; color: var(--text); }
.db-date          { font-size: 13px; color: var(--text-muted); }

/* KPI Strip */
.db-kpi-strip {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 280px;
  gap: 12px;
  margin-bottom: 22px;
}
.db-kpi {
  background: var(--white);
  border: 1px solid #E2E8F0;
  border-radius: var(--radius);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}
.db-kpi-urgent {
  border-color: rgba(224,82,82,0.35);
  background: rgba(224,82,82,0.03);
}
.db-kpi-value {
  font-size: 34px;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 5px;
  letter-spacing: -1px;
}
.db-kpi-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
}
.db-kpi-pulse {
  position: absolute;
  top: 16px; right: 16px;
  width: 8px; height: 8px;
  background: var(--blocked);
  border-radius: 50%;
  animation: kpiPulse 1.8s ease-in-out infinite;
}
@keyframes kpiPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.35; transform: scale(1.5); }
}

/* Main grid */
.db-main-grid {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 20px;
  align-items: start;
}
.db-left  { display: flex; flex-direction: column; gap: 16px; }

/* Today's Focus card — primary blue left accent */
.db-focus-card {
  background: var(--focus-bg);
  border-radius: 14px;
  border: 1px solid var(--focus-border);
  border-left: 3px solid var(--focus-accent);
  padding: 24px 28px;
}
.db-focus-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.db-focus-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #64748B;
  text-transform: uppercase;
}
.db-focus-count { font-size: 11px; color: var(--text-muted); }

.db-focus-task {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid rgba(39,40,64,0.08);
}
.db-focus-task:last-child { border-bottom: none; padding-bottom: 0; }
.db-focus-task.db-focus-done { opacity: 0.45; }

.db-focus-check {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 2px solid rgba(39,40,64,0.2);
  flex-shrink: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, background 0.15s;
  background: var(--white);
}
.db-focus-check:hover  { border-color: var(--primary); background: var(--primary-light); }
.db-focus-check.checked {
  background: var(--done);
  border-color: var(--done);
}
.db-focus-check.checked svg { width: 13px; height: 13px; stroke: #fff; }

.db-focus-info  { flex: 1; min-width: 0; }
.db-focus-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}
.db-focus-done .db-focus-title {
  text-decoration: line-through;
  color: var(--text-muted);
}
.db-focus-meta {
  display: flex;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
}
.db-focus-overdue {
  color: var(--blocked);
  font-weight: 700;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.db-focus-edit {
  background: none; border: none;
  cursor: pointer; padding: 4px;
  color: var(--text-muted);
  opacity: 0;
  transition: opacity 0.15s;
  flex-shrink: 0;
}
.db-focus-task:hover .db-focus-edit { opacity: 1; }

/* Focus card — add button */
.db-focus-add {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(39,40,64,0.06);
  border: 1px solid rgba(39,40,64,0.12);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.db-focus-add:hover { background: rgba(39,40,64,0.1); color: var(--dark); }
.db-focus-add .ic   { width: 11px; height: 11px; }

/* Focus card — priority tag inline */
.db-focus-tag {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
}
.db-focus-critical { color: var(--blocked); }

/* Focus empty state */
.db-focus-empty {
  padding: 22px 0 6px;
}
.db-focus-empty-title {
  display: block;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.db-focus-empty-sub {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  opacity: 0.7;
}

/* Generic section card (upcoming + projects) */
.db-section-card {
  background: var(--white);
  border: 1px solid #E2E8F0;
  border-radius: var(--radius);
  padding: 18px 20px;
}
.db-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748B;
}
.db-section-chip {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 1px 8px;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: 0;
}

/* Next Actions rows */
.db-upcoming-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.db-upcoming-row:last-child { border-bottom: none; padding-bottom: 0; }
.db-upcoming-dot  { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; align-self: flex-start; margin-top: 5px; }
.db-upcoming-body { flex: 1; min-width: 0; }
.db-upcoming-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}
.db-upcoming-meta { font-size: 11px; color: var(--text-muted); }

/* Project progress bars */
.db-proj-item       { margin-bottom: 20px; }
.db-proj-item:last-child { margin-bottom: 0; }
.db-proj-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 7px;
}
.db-proj-name  { font-size: 13px; font-weight: 700; color: var(--text); }
.db-proj-pct   { font-size: 14px; font-weight: 800; }
.db-proj-track {
  height: 7px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 5px;
}
.db-proj-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.7s cubic-bezier(0.4,0,0.2,1);
}
.db-proj-phase { font-size: 11px; color: var(--text-muted); }
.db-empty-sm   { text-align: center; padding: 20px; font-size: 13px; color: var(--text-muted); }

/* Responsive */
@media (max-width: 960px) {
  .db-main-grid { grid-template-columns: 1fr; }
  .db-right      { order: -1; }
}
@media (max-width: 640px) {
  .db-kpi-strip  { grid-template-columns: repeat(2, 1fr); }
  .db-focus-title { font-size: 14px; }
}
/* ── Hamburger button (mobile only) ──────────────────────────────────────── */
#hamburger-btn {
  display: none;
}
@media (max-width: 768px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  #sidebar { display: none; }

  #hamburger-btn {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    margin-left: auto;
    flex-shrink: 0;
  }
  #hamburger-btn span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
    transition: transform 0.2s, opacity 0.2s;
  }
  #hamburger-btn.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  #hamburger-btn.open span:nth-child(2) { opacity: 0; }
  #hamburger-btn.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

  /* Dimmed overlay behind drawer */
  #mobile-nav-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    z-index: 299;
  }
  #mobile-nav-overlay.open { display: block; }

  /* Drawer drops down from top-right */
  #mobile-nav-drawer {
    display: none;
    position: fixed;
    top: var(--header-h);
    right: 0;
    width: 200px;
    background: var(--sidebar-bg);
    border-left: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    border-radius: 0 0 0 12px;
    box-shadow: -4px 4px 20px rgba(39,40,64,0.12);
    z-index: 300;
    flex-direction: column;
    padding: 8px 0;
    animation: drawerIn 0.18s ease;
  }
  #mobile-nav-drawer.open { display: flex; }
  @keyframes drawerIn {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  .drawer-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: none;
    border: none;
    color: var(--sidebar-text);
    font-size: 14px;
    padding: 12px 20px;
    cursor: pointer;
    width: 100%;
    text-align: left;
    transition: background 0.15s, color 0.15s;
  }
  .drawer-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    stroke: currentColor;
    opacity: 0.5;
  }
  .drawer-item:hover { background: var(--sidebar-hover); color: var(--dark); }
  .drawer-item.active {
    color: var(--sidebar-active);
    background: #EBF5FB;
    box-shadow: inset 3px 0 0 var(--sidebar-active);
  }
  .drawer-item.active svg { opacity: 1; }
}

/* ── Donut chart container ────────────────────────────────────────────────── */
.chart-wrap {
  position: relative;
  width: 120px;
  height: 120px;
  margin: 0 auto 12px;
}

.chart-wrap canvas { position: absolute; inset: 0; }

.chart-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.chart-pct { font-size: 22px; font-weight: 800; color: var(--dark); }
.chart-label { font-size: 10px; color: var(--text-muted); margin-top: 1px; }

/* ── Task items ───────────────────────────────────────────────────────────── */
.task-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--bg);
  transition: background 0.1s;
}

.task-item:last-child { border-bottom: none; }

.task-check {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 2px solid var(--border);
  cursor: pointer;
  flex-shrink: 0;
  margin-top: 1px;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
}

.task-check:hover { border-color: var(--primary); background: var(--primary-light); }
.task-check.done { border-color: var(--done); background: var(--done); }
.task-check.done::after { content: '✓'; color: white; font-size: 11px; font-weight: 800; }

.task-info { flex: 1; min-width: 0; }
.task-title { font-size: 13.5px; font-weight: 500; color: var(--text); }
.task-title.done-text { text-decoration: line-through; color: var(--text-muted); }
.task-meta { display: flex; gap: 8px; align-items: center; margin-top: 3px; flex-wrap: wrap; }
.task-deadline { font-size: 11.5px; color: var(--text-muted); }
.task-deadline.overdue { color: var(--blocked); font-weight: 600; }
.task-deadline.due-today { color: var(--overdue); font-weight: 600; }
.deadline-urgent { color: var(--blocked); font-weight: 600; }
.deadline-soon   { color: var(--overdue); font-weight: 600; }
.deadline-ok     { color: var(--done);    font-weight: 600; }
.task-project { font-size: 11px; color: var(--text-muted); background: var(--bg); padding: 1px 7px; border-radius: 10px; }

.task-actions { display: flex; gap: 4px; opacity: 0; transition: opacity 0.15s; }
.task-item:hover .task-actions { opacity: 1; }
.task-action-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 2px 4px;
  border-radius: 4px;
  font-size: 13px;
  transition: color 0.1s;
}
.task-action-btn:hover { color: var(--text); background: var(--bg); }

/* ── Subtasks ─────────────────────────────────────────────────────────────── */
.subtasks-toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 3px;
  margin-top: 4px;
  transition: color 0.1s;
}
.subtasks-toggle:hover { color: var(--primary); }
.subtasks-toggle .arrow { transition: transform 0.2s; font-size: 10px; }
.subtasks-toggle.open .arrow { transform: rotate(90deg); }

.subtasks-list {
  margin-left: 30px;
  margin-top: 4px;
  display: none;
}
.subtasks-list.open { display: block; }

.subtask-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid var(--bg);
}
.subtask-item:last-child { border-bottom: none; }
.subtask-check {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid var(--border);
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s;
  display: flex; align-items: center; justify-content: center;
  background: transparent;
}
.subtask-check:hover { border-color: var(--primary); }
.subtask-check.done { border-color: var(--done); background: var(--done); }
.subtask-check.done::after { content: '✓'; color: white; font-size: 9px; font-weight: 800; }

/* ── Section headers ──────────────────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--dark);
  display: flex;
  align-items: center;
  gap: 8px;
}

.count-chip {
  background: var(--bg);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 20px;
}

/* ── Project cards ────────────────────────────────────────────────────────── */
.project-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s;
}

.project-card:hover { border-color: var(--primary); box-shadow: 0 4px 20px rgba(37,150,190,0.1); }
.project-card-header { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.project-name { font-size: 15px; font-weight: 700; color: var(--dark); flex: 1; }
.project-progress-bar { height: 5px; background: var(--bg); border-radius: 3px; overflow: hidden; margin-top: 8px; }
.project-progress-fill { height: 100%; background: var(--primary); border-radius: 3px; transition: width 0.5s; }

/* ── Projects layout ──────────────────────────────────────────────────────── */
#projects-layout {
  display: flex;
  height: calc(100vh - var(--header-h));
  overflow: hidden;
}

/* Left panel */
.proj-left {
  width: 220px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--white);
  overflow: hidden;
  transition: width 0.25s ease;
}
.proj-left.collapsed { width: 0; pointer-events: none; }
.proj-left-header {
  padding: 16px 14px 10px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-muted);
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}
.proj-left-items { overflow-y: auto; padding: 8px; flex: 1; }

/* Project list item */
.pj-item {
  display: flex;
  align-items: stretch;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 3px;
  overflow: hidden;
  transition: background 0.12s;
  border: 1px solid transparent;
}
.pj-item:hover { background: var(--bg); }
.pj-item.active {
  background: var(--primary-light);
  border-color: rgba(37,150,190,0.2);
}
.pj-item-accent {
  width: 3px;
  flex-shrink: 0;
  border-radius: 3px 0 0 3px;
}
.pj-item-body { flex: 1; padding: 8px 8px 8px 7px; min-width: 0; }
.pj-item-top  { display: flex; align-items: center; gap: 4px; margin-bottom: 3px; }
.pj-item-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.pj-item.active .pj-item-name { color: var(--primary); }
.pj-item-edit {
  background: none; border: none; cursor: pointer;
  opacity: 0; color: var(--text-muted); padding: 2px;
  transition: opacity 0.15s; flex-shrink: 0;
}
.pj-item:hover .pj-item-edit { opacity: 1; }
.pj-item-meta { font-size: 10.5px; color: var(--text-muted); margin-bottom: 4px; }
.pj-item-bar  { height: 3px; background: var(--border); border-radius: 2px; overflow: hidden; }
.pj-item-bar-fill { height: 100%; border-radius: 2px; transition: width 0.4s ease; }

/* Collapse toggle */
.proj-toggle-btn {
  width: 16px;
  flex-shrink: 0;
  background: var(--bg);
  border: none;
  border-right: 1px solid var(--border);
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.15s;
}
.proj-toggle-btn:hover { background: var(--border); color: var(--text); }

/* Right panel */
#phases-panel {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
  background: var(--bg);
}

/* Project detail header */
.pj-detail-header {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.pj-detail-title-row {
  display: flex; align-items: center; gap: 12px; margin-bottom: 10px;
}
.pj-detail-name {
  font-size: 18px; font-weight: 800; color: var(--text);
  letter-spacing: -0.3px; flex: 1;
}
.pj-detail-badge {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.6px; padding: 3px 9px;
  border: 1px solid; border-radius: 20px;
}
.pj-detail-bar-row { display: flex; align-items: center; gap: 10px; }
.pj-detail-track {
  flex: 1; height: 6px; background: var(--bg);
  border-radius: 3px; overflow: hidden;
}
.pj-detail-fill { height: 100%; border-radius: 3px; transition: width 0.6s ease; }
.pj-detail-pct  { font-size: 13px; font-weight: 800; flex-shrink: 0; }
.pj-detail-end  { font-size: 12px; color: var(--text-muted); flex-shrink: 0; }

/* Project Focus card — light surface with dark accent */
.pj-focus-card {
  background: var(--focus-bg);
  border-radius: 12px;
  border: 1px solid var(--focus-border);
  border-left: 4px solid var(--focus-accent);
  padding: 20px 24px;
  margin-bottom: 16px;
  box-shadow: 0 2px 10px rgba(39,40,64,0.06);
}
.pj-focus-header {
  display: flex; align-items: center;
  justify-content: space-between; margin-bottom: 14px;
}
.pj-focus-label {
  font-size: 10px; font-weight: 700;
  letter-spacing: 1.2px; color: var(--text-muted);
  text-transform: uppercase;
}
.pj-focus-count { font-size: 11px; color: var(--text-muted); }

.pj-focus-task {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(39,40,64,0.08);
}
.pj-focus-task:last-child { border-bottom: none; padding-bottom: 0; }

.pj-focus-check {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid rgba(39,40,64,0.2);
  flex-shrink: 0; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  background: var(--white);
  transition: border-color 0.15s, background 0.15s;
}
.pj-focus-check:hover  { border-color: var(--primary); background: var(--primary-light); }
.pj-focus-check.checked { background: var(--done); border-color: var(--done); }
.pj-focus-check.checked svg { width: 12px; height: 12px; stroke: #fff; }

.pj-focus-info  { flex: 1; min-width: 0; }
.pj-focus-title {
  font-size: 14px; font-weight: 600; color: var(--dark);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: 2px;
}
.pj-focus-meta  { display: flex; gap: 6px; font-size: 11px; color: var(--text-muted); }

.pj-focus-empty { padding: 14px 0 2px; }
.pj-focus-empty-title {
  display: block; font-size: 14px; font-weight: 600;
  color: var(--text-muted); margin-bottom: 3px;
}
.pj-focus-empty-sub { display: block; font-size: 11px; color: var(--text-muted); opacity: 0.7; }

/* Actions bar */
.pj-actions-bar {
  display: flex; gap: 8px; margin-bottom: 16px;
}

/* Phase card */
.pj-phase {
  display: flex;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 12px;
  overflow: hidden;
}
.pj-phase-accent { width: 4px; flex-shrink: 0; }
.pj-phase-inner  { flex: 1; min-width: 0; }

.pj-phase-header {
  display: flex; flex-direction: column; gap: 8px;
  padding: 14px 16px 10px;
  background: none; border: none; cursor: pointer;
  width: 100%; text-align: left;
  transition: background 0.12s;
}
.pj-phase-header:hover { background: var(--bg); }

.pj-phase-title-row { display: flex; align-items: center; gap: 10px; }
.pj-phase-arrow { color: var(--text-muted); transition: transform 0.2s; flex-shrink: 0; }
.pj-phase-name  { font-size: 14px; font-weight: 700; color: var(--dark); flex: 1; }
.pj-phase-status {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.5px; padding: 2px 8px;
  border: 1px solid; border-radius: 20px; flex-shrink: 0;
}

.pj-phase-meta-row  { display: flex; align-items: center; gap: 10px; padding-left: 26px; }
.pj-phase-track {
  flex: 1; height: 5px; background: var(--bg);
  border-radius: 3px; overflow: hidden;
}
.pj-phase-fill { height: 100%; border-radius: 3px; transition: width 0.5s ease; }
.pj-phase-pct   { font-size: 11px; font-weight: 700; color: var(--text-muted); flex-shrink: 0; }
.pj-phase-count { font-size: 11px; color: var(--text-muted); flex-shrink: 0; }

.pj-phase-hdr-row { display: flex; align-items: flex-start; }
.pj-phase-hdr-row .pj-phase-header { flex: 1; min-width: 0; }

.pj-phase-actions {
  display: flex; gap: 2px;
  padding: 11px 10px 0 0;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s;
}
.pj-phase:hover .pj-phase-actions { opacity: 1; }

/* Completed phases section */
.pj-done-phases-toggle {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 10px 16px;
  background: none; border: none;
  font-size: 12px; font-weight: 600; color: var(--text-muted);
  cursor: pointer; border-radius: var(--radius);
  transition: background 0.12s;
  margin-bottom: 4px;
}
.pj-done-phases-toggle:hover { background: var(--bg); color: var(--text); }
.pj-done-phases-arrow { transition: transform 0.2s; }

.pj-phase-body { display: none; padding: 0 16px 14px; }
.pj-phase-body.open { display: block; }
.pj-phase-empty {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 0; font-size: 13px; color: var(--text-muted);
}

/* Task row in phase */
.pj-task {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  transition: opacity 0.2s;
}
.pj-task:last-child { border-bottom: none; }
.pj-task-done { opacity: 0.45; }

.pj-task-dot {
  width: 6px; height: 6px; border-radius: 50%;
  flex-shrink: 0; align-self: flex-start; margin-top: 7px;
}
.pj-task-check {
  width: 18px; height: 18px; border-radius: 50%;
  border: 1.5px solid var(--border);
  flex-shrink: 0; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: border-color 0.15s, background 0.15s;
}
.pj-task-check:hover   { border-color: var(--primary); background: var(--primary-light); }
.pj-task-check.done    { border-color: var(--done); background: var(--done); }
.pj-task-check.done::after { content: '✓'; color: white; font-size: 10px; font-weight: 800; }

.pj-task-body  { flex: 1; min-width: 0; }
.pj-task-title { font-size: 13.5px; font-weight: 500; color: var(--text); }
.pj-task-title.done-text { text-decoration: line-through; color: var(--text-muted); }
.pj-task-meta  { display: flex; gap: 6px; align-items: center; margin-top: 2px; font-size: 11px; }

.pj-task-actions { display: flex; gap: 4px; opacity: 0; transition: opacity 0.15s; }
.pj-task:hover .pj-task-actions { opacity: 1; }

/* Completed tasks toggle (Linear-style) */
.pj-completed-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 2px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  border-top: 1px solid var(--border);
  margin-top: 4px;
  transition: color 0.15s;
}
.pj-completed-toggle:hover { color: var(--text); }
.pj-completed-toggle svg { transition: transform 0.2s; flex-shrink: 0; }

.pj-completed-list { display: none; overflow: hidden; }
.pj-completed-list.open { display: block; }

/* ── Gantt v2 ─────────────────────────────────────────────────────────────── */

/* Header controls */
.gantt-select {
  padding: 6px 10px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--white);
  color: var(--text);
  cursor: pointer;
  min-width: 200px;
}
.gantt-view-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 7px;
  overflow: hidden;
  background: var(--white);
}
.gantt-view-btn {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
}
.gantt-view-btn.active { background: var(--primary); color: white; }
.gantt-view-btn:not(.active):hover { background: var(--bg); color: var(--text); }

/* ── Gantt Zoom Toolbar ───────────────────────────────────────────────────── */
.gantt-zoom-bar {
  display: flex;
  align-items: center;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 7px;
  overflow: hidden;
  background: var(--white);
}
.gantt-zoom-step {
  width: 30px;
  height: 32px;
  font-size: 16px;
  font-weight: 400;
  line-height: 1;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  transition: background 0.12s, color 0.12s;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.gantt-zoom-step:hover { background: var(--bg); color: var(--text); }
.gantt-zoom-step:disabled { opacity: 0.3; cursor: default; }
.gantt-zoom-presets {
  display: flex;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}
.gantt-zoom-preset {
  padding: 0 11px;
  height: 32px;
  font-size: 12px;
  font-weight: 600;
  background: none;
  border: none;
  border-right: 1px solid var(--border);
  cursor: pointer;
  color: var(--text-muted);
  transition: background 0.12s, color 0.12s;
  white-space: nowrap;
}
.gantt-zoom-preset:last-child { border-right: none; }
.gantt-zoom-preset.active { background: var(--primary); color: white; }
.gantt-zoom-preset:not(.active):hover { background: var(--bg); color: var(--text); }

/* Selected bar ring */
.gantt-bar-selected {
  outline: 3px solid #fff;
  outline-offset: 2px;
  box-shadow: 0 0 0 5px rgba(37,150,190,0.85), 0 0 12px 2px rgba(37,150,190,0.45);
  z-index: 5;
}

/* Brush-select cursor */
#gantt-scroll.gantt-painting,
#gantt-scroll.gantt-painting * { cursor: crosshair !important; }

/* Selection count badge */
.gantt-sel-badge {
  align-items: center;
  background: var(--primary);
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 0 10px;
  height: 32px;
  border-radius: 7px;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

/* Today jump button */
.gantt-today-btn {
  height: 32px;
  padding: 0 13px;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  background: white;
  border: 1px solid var(--primary);
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  white-space: nowrap;
}
.gantt-today-btn:hover { background: var(--primary); color: white; }

/* Execution focus strip — primary blue accent */
.gantt-focus-card {
  background: var(--focus-bg);
  border-radius: 12px;
  border: 1px solid var(--focus-border);
  border-left: 3px solid var(--focus-accent);
  padding: 14px 22px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 20px;
}
.gantt-focus-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #64748B;
  text-transform: uppercase;
  flex-shrink: 0;
}
.gf-tasks { display: flex; gap: 20px; flex-wrap: wrap; }
.gf-task  { display: flex; align-items: center; gap: 8px; }
.gf-dot   { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.gf-info  { display: flex; align-items: baseline; gap: 6px; }
.gf-title { font-size: 13px; font-weight: 600; color: var(--dark); }
.gf-meta  { font-size: 11px; color: var(--text-muted); }

/* Main Gantt card */
.gantt-card {
  background: var(--white);
  border: 1px solid #E2E8F0;
  border-radius: var(--radius);
  overflow: hidden;
}

/* Header row */
.gantt-header-row {
  display: flex;
  background: var(--white);
  border-bottom: 1px solid #E2E8F0;
}
.gantt-label-col {
  flex-shrink: 0;
  position: sticky;
  left: 0;
  z-index: 10;
  background: var(--white);
  border-right: 1px solid #E2E8F0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  min-height: 40px;
}

/* Phase row */
.gantt-phase-row {
  display: flex;
  border-bottom: 1px solid #E2E8F0;
  background: #FAFBFC;
}
.gantt-phase-row .gantt-label-col {
  background: #FAFBFC;
  min-height: 32px;
}
.gantt-phase-name {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748B;
}
.gantt-phase-chip {
  font-size: 10px;
  background: var(--primary-light);
  color: var(--primary);
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 700;
}

/* Task row */
.gantt-task-row {
  display: flex;
  border-bottom: 1px solid #F1F5F9;
  cursor: pointer;
  transition: background 0.1s;
}
.gantt-task-row .gantt-label-col {
  background: var(--white);
  min-height: 38px;
  position: relative;
  padding-left: 18px;
}
.gantt-task-row:hover .gantt-label-col { background: #F8FAFC; }
.gantt-task-row:hover > div:last-child  { background: #F8FAFC; }
.gantt-task-row.gantt-overdue .gantt-label-col { background: rgba(224,82,82,0.03); }

/* Priority bar — 3px left accent */
.gantt-prio-bar {
  position: absolute;
  left: 0; top: 6px; bottom: 6px;
  width: 3px;
  border-radius: 2px;
}

.gantt-task-label {
  font-size: 12.5px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.gantt-done-label {
  text-decoration: line-through;
  color: var(--text-muted);
}

/* Gantt bar — flat, subtle inset border */
.gantt-bar {
  position: absolute;
  top: 7px;
  height: 24px;
  border-radius: 6px;
  overflow: hidden;
  cursor: grab;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.1);
  transition: filter 0.12s;
  white-space: nowrap;
}
.gantt-bar:hover {
  filter: brightness(0.92);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.16);
}
.gantt-bar.gantt-dragging {
  cursor: grabbing;
  opacity: 0.85;
  transition: none;
  z-index: 10;
}
.gantt-drag-tooltip {
  position: fixed;
  display: none;
  background: var(--dark);
  color: white;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 5px;
  pointer-events: none;
  z-index: 9999;
}
.gantt-bar-done { opacity: 0.55; }

/* Progress fill inside bar */
.gantt-bar-progress {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  background: rgba(255,255,255,0.25);
  pointer-events: none;
}

/* Text inside bar */
.gantt-bar-label {
  position: relative;
  z-index: 1;
  font-size: 11px;
  color: white;
  font-weight: 600;
  padding: 0 8px;
  line-height: 24px;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Task detail panel */
.gantt-detail-panel {
  margin-top: 14px;
  background: var(--white);
  border: 1px solid #E2E8F0;
  border-radius: var(--radius);
  animation: detailSlideIn 0.18s ease;
}
@keyframes detailSlideIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.gantt-detail-inner  { padding: 18px 22px; }
.gantt-detail-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.gantt-detail-title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.gantt-detail-name  { font-size: 15px; font-weight: 700; color: var(--text); }
.gantt-detail-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.gantt-detail-meta {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text-muted);
  flex-wrap: wrap;
  align-items: center;
}
.gantt-detail-meta .ic { margin-right: 3px; }
.gantt-detail-desc {
  margin-top: 10px;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ── To-Do v2 ─────────────────────────────────────────────────────────────── */

/* Quick capture bar */
.td-capture {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 16px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  transition: border-color 0.15s;
}
.td-capture:focus-within { border-color: var(--primary); }
.td-capture-icon { width: 16px; height: 16px; color: var(--text-muted); flex-shrink: 0; }
.td-capture input {
  flex: 1; border: none; outline: none;
  font-size: 14px; color: var(--text); background: transparent;
}
.td-capture input::placeholder { color: var(--text-muted); }

/* Section blocks */
.td-block {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  overflow: hidden;
}
.td-block-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 20px 10px;
  border-bottom: 1px solid var(--border);
}
.td-block-label {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-muted);
  flex: 1;
}
.td-count-chip {
  font-size: 11px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 1px 8px;
  color: var(--text-muted);
}

/* Critical block */
.td-block-critical {
  border-color: rgba(224,82,82,0.3);
  background: rgba(224,82,82,0.03);
}
.td-chip-critical {
  background: rgba(224,82,82,0.1);
  border-color: rgba(224,82,82,0.2);
  color: var(--blocked);
}
.td-tag-critical {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--blocked);
}

/* Today block — light focus surface */
.td-block-today {
  background: var(--focus-bg);
  border-color: var(--focus-border);
  border-left: 4px solid var(--focus-accent);
}
.td-block-today .td-block-header { border-bottom-color: rgba(39,40,64,0.08); }
.td-label-today {
  color: var(--text-muted) !important;
}
.td-chip-today {
  background: rgba(39,40,64,0.07);
  border-color: rgba(39,40,64,0.12);
  color: var(--text-muted);
}

/* Task rows — base */
.td-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 20px;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.td-row:last-child { border-bottom: none; }
.td-row:hover { background: var(--bg); }

/* Critical row */
.td-row-critical:hover { background: rgba(224,82,82,0.04); }

/* Today row — inside focus card */
.td-row-today {
  border-bottom-color: rgba(39,40,64,0.08);
  gap: 14px;
}
.td-row-today:hover { background: rgba(39,40,64,0.04); }
.td-row-today:last-child { border-bottom: none; }

/* Standard checkbox */
.td-check {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  flex-shrink: 0;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  display: flex; align-items: center; justify-content: center;
}
.td-check:hover   { border-color: var(--primary); background: var(--primary-light); }
.td-check.done    { border-color: var(--done); background: var(--done); }
.td-check.done::after { content: '✓'; color: white; font-size: 11px; font-weight: 800; }
.td-check-sm { width: 18px; height: 18px; }

/* Today circle checkbox */
.td-focus-check {
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 2px solid rgba(39,40,64,0.2);
  flex-shrink: 0;
  cursor: pointer;
  background: var(--white);
  transition: border-color 0.15s, background 0.15s;
}
.td-focus-check:hover { border-color: var(--primary); background: var(--primary-light); }
.td-focus-check.done  { background: var(--done); border-color: var(--done); }

/* Priority dot */
.td-prio-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  align-self: flex-start;
  margin-top: 6px;
}

/* Task body */
.td-body  { flex: 1; min-width: 0; }
.td-title {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}
.td-title-today {
  font-size: 15px;
  font-weight: 600;
  color: var(--dark);
}
.td-meta { display: flex; gap: 6px; align-items: center; font-size: 11px; color: var(--text-muted); }
.td-meta-today { color: var(--text-muted); }

/* Actions (hover-reveal) */
.td-actions { display: flex; gap: 2px; opacity: 0; transition: opacity 0.15s; }
.td-row:hover .td-actions { opacity: 1; }
.td-actions-today { opacity: 0; }
.td-row-today:hover .td-actions-today { opacity: 1; }
.td-dark-btn {
  background: none; border: none; cursor: pointer;
  padding: 4px; color: var(--text-muted);
  transition: color 0.15s;
  display: flex; align-items: center;
}
.td-dark-btn:hover { color: var(--dark); }
.td-dark-btn .ic { stroke: currentColor; }

/* Empty state */
.td-empty {
  text-align: center;
  padding: 48px 20px;
}
.td-empty-title {
  display: block;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}
.td-empty-sub {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
}

/* ── Finance v2 ───────────────────────────────────────────────────────────── */

/* Financial Focus — light surface with dark accent */
.fin-focus-card {
  background: var(--focus-bg);
  border-radius: 14px;
  border: 1px solid var(--focus-border);
  border-left: 4px solid var(--focus-accent);
  padding: 18px 24px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 24px;
  box-shadow: 0 2px 10px rgba(39,40,64,0.06);
  flex-wrap: wrap;
}
.fin-focus-label {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.fin-focus-items { display: flex; flex-direction: column; gap: 7px; flex: 1; }
.fin-focus-item  { display: flex; align-items: center; gap: 10px; }
.fin-focus-dot   { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.fin-focus-text  { font-size: 13px; font-weight: 500; color: var(--dark); }
.fin-focus-empty { }
.fin-focus-empty-title { display: block; font-size: 15px; font-weight: 600; color: var(--text-muted); margin-bottom: 3px; }
.fin-focus-empty-sub   { display: block; font-size: 12px; color: var(--text-muted); opacity: 0.7; }

/* KPI strip */
.fin-kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.fin-kpi {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}
.fin-kpi-urgent {
  border-color: rgba(224,82,82,0.3);
  background: rgba(224,82,82,0.03);
}
.fin-kpi-value {
  font-size: 26px;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 5px;
  letter-spacing: -0.5px;
}
.fin-kpi-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

/* Chart card */
.fin-chart-card {
  margin-bottom: 20px;
  padding: 20px 20px 14px;
}
.fin-card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
}
.fin-card-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.fin-card-sub {
  font-size: 11px;
  color: var(--text-muted);
}

/* Monthly breakdown */
.fin-breakdown-card { padding: 0; overflow: hidden; margin-bottom: 20px; }
.fin-breakdown-card .fin-card-header { padding: 16px 20px 12px; border-bottom: 1px solid var(--border); margin-bottom: 0; }

.fin-table-head {
  display: grid;
  grid-template-columns: 160px 1fr 1fr 120px;
  gap: 12px;
  padding: 8px 20px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.fin-th {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
}

/* Month row */
.fin-row {
  display: grid;
  grid-template-columns: 160px 1fr 1fr 120px;
  gap: 12px;
  align-items: center;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.fin-row:last-child { border-bottom: none; }
.fin-row:hover { background: var(--bg); }
.fin-row-current {
  background: rgba(37,150,190,0.04);
  border-left: 3px solid var(--primary);
  padding-left: 17px;
}
.fin-row-actual { }

.fin-col-month  { display: flex; flex-direction: column; gap: 2px; }
.fin-col-rev    { display: flex; flex-direction: column; gap: 1px; }
.fin-col-prof   { display: flex; flex-direction: column; gap: 1px; }
.fin-col-status { }

.fin-month-label { font-size: 13px; font-weight: 700; color: var(--text); }
.fin-current-chip {
  display: inline-block;
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--primary);
  color: white;
  padding: 1px 6px;
  border-radius: 10px;
  width: fit-content;
}
.fin-milestone {
  font-size: 10px;
  color: var(--primary);
  font-weight: 600;
}

.fin-actual-value { font-size: 14px; font-weight: 700; color: var(--text); }
.fin-proj-value   { font-size: 13px; color: var(--text-muted); }
.fin-proj-tag     { font-size: 10px; color: var(--text-muted); font-style: italic; }

/* Status chips */
.fin-status-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 20px;
}
.fin-status-dot    { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.fin-status-green  { background: rgba(39,174,96,0.1);  color: var(--done);    }
.fin-status-yellow { background: rgba(240,165,0,0.1);  color: var(--overdue); }
.fin-status-red    { background: rgba(224,82,82,0.1);  color: var(--blocked); }
.fin-status-pending { background: var(--bg); color: var(--text-muted); }

.fin-empty-row { padding: 24px; text-align: center; color: var(--text-muted); font-size: 13px; }

/* Responsive */
@media (max-width: 900px) {
  .fin-kpi-strip      { grid-template-columns: repeat(2, 1fr); }
  .fin-table-head,
  .fin-row            { grid-template-columns: 120px 1fr 1fr 100px; }
}
@media (max-width: 600px) {
  .fin-kpi-strip      { grid-template-columns: repeat(2, 1fr); }
  .fin-table-head,
  .fin-row            { grid-template-columns: 90px 1fr 1fr; }
  .fin-col-status,
  .fin-th:last-child  { display: none; }
}

/* ── Modal ────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(2px);
  animation: fadeIn 0.15s;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--white);
  border-radius: 12px;
  padding: 28px;
  width: 480px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  animation: slideUp 0.15s;
}

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

.modal-title { font-size: 17px; font-weight: 800; color: var(--dark); margin-bottom: 20px; }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 12px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 5px; }
.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  font-size: 13.5px;
  color: var(--text);
  background: var(--white);
  outline: none;
  transition: border-color 0.15s;
}
.form-control:focus { border-color: var(--primary); }
textarea.form-control { resize: vertical; min-height: 80px; }

.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }

.modal-footer { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* ── Toast ────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--dark);
  color: white;
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  animation: slideToast 0.2s;
  z-index: 9999;
}

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

/* ── Empty state ──────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state .icon { font-size: 40px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ── Divider label ────────────────────────────────────────────────────────── */
.divider-label {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  padding: 12px 0 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.divider-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── Scrollbar ────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Fade task out ────────────────────────────────────────────────────────── */
.task-fade-out {
  animation: fadeOut 0.4s forwards;
}
@keyframes fadeOut {
  to { opacity: 0; transform: translateX(20px); max-height: 0; padding: 0; margin: 0; overflow: hidden; }
}

/* ── Inline icons ─────────────────────────────────────────────────────────── */
.ic {
  width: 13px;
  height: 13px;
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
  position: relative;
  top: -1px;
}
.ic-lg  { width: 28px; height: 28px; top: 0; }
.task-action-btn .ic { width: 13px; height: 13px; }
.btn .ic { width: 13px; height: 13px; }

/* ── Inline edit ──────────────────────────────────────────────────────────── */
.inline-edit {
  border: none;
  border-bottom: 1.5px solid var(--primary);
  outline: none;
  background: transparent;
  font-size: inherit;
  font-weight: inherit;
  color: inherit;
  width: 100%;
  padding: 1px 2px;
}


/* ── Team & Agents View ──────────────────────────────────────────────────── */

/* ── Team layout (mirrors projects-layout) ─────────────────────── */
#team-layout {
  display: flex;
  height: calc(100vh - var(--header-h));
  overflow: hidden;
}
.team-left {
  width: 260px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--white);
  overflow: hidden;
  transition: width 0.25s ease;
}
.team-left.collapsed { width: 0; pointer-events: none; }
.team-left-header {
  padding: 16px 14px 12px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-muted);
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.team-left-inner {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.team-toggle-btn {
  width: 16px;
  flex-shrink: 0;
  background: var(--bg);
  border: none;
  border-right: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.15s;
}
.team-toggle-btn:hover { background: var(--border); color: var(--text); }

.team-right {
  flex: 1;
  background: var(--white);
  overflow-y: auto;
}
.team-section-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #64748B;
  text-transform: uppercase;
  padding: 4px 0 2px;
}
/* Inside the collapsible panel, section labels have horizontal padding */
.team-left-inner .team-section-label { padding: 14px 14px 6px; }
.team-agent-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: none;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.13s;
  margin: 1px 0;
}
.team-agent-card:hover    { background: var(--sidebar-hover); }
.team-agent-card.selected {
  background: #EBF5FB;
  color: var(--primary);
  box-shadow: inset 3px 0 0 var(--primary);
}
.team-agent-card.selected .team-agent-name { color: var(--primary); }
.team-agent-card.dragging  { opacity: 0.4; }
.team-agent-card.drag-over { background: var(--primary-light); box-shadow: inset 3px 0 0 var(--primary); }

.drag-handle {
  color: var(--text-muted); font-size: 16px; cursor: grab;
  padding: 0 2px; flex-shrink: 0; user-select: none;
  opacity: 0; transition: opacity 0.15s;
}
.team-agent-card:hover .drag-handle { opacity: 1; }
.drag-handle:active { cursor: grabbing; }
.team-agent-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--primary); color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.team-agent-avatar-img {
  object-fit: cover; background: var(--border);
}

/* Clickable avatar upload wrapper in detail panel */
.team-avatar-upload {
  position: relative; flex-shrink: 0; cursor: pointer;
  border-radius: 50%; overflow: hidden;
}
.team-avatar-upload .team-agent-avatar,
.team-avatar-upload .team-agent-avatar-img {
  display: block;
}
.team-avatar-overlay {
  position: absolute; inset: 0; border-radius: 50%;
  background: rgba(0,0,0,0.45); color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; opacity: 0; transition: opacity 0.18s;
}
.team-avatar-upload:hover .team-avatar-overlay { opacity: 1; }
.team-agent-name     { font-size: 13px; font-weight: 600; color: var(--text); }
.team-agent-jobtitle { font-size: 11.5px; color: var(--text-muted); margin-top: 1px; }
.team-agent-model    { font-size: 11px; color: var(--text-muted); opacity: 0.7; margin-top: 1px; }
.team-add-btn { width: 100%; justify-content: flex-start; gap: 6px; font-size: 13px; margin-top: 2px; }
.team-left-inner .team-agent-list,
.team-left-inner .team-kb-list { padding: 0 8px; }
.team-left-inner .team-add-btn { padding-left: 14px; padding-right: 14px; }

.team-kb-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 6px; border-bottom: 1px solid var(--border);
  border-radius: 6px; cursor: pointer; transition: background 0.15s;
}
.team-kb-item:last-child { border-bottom: none; }
.team-kb-item:hover { background: var(--focus-bg); }
.team-kb-item.selected { background: var(--primary-light); }
.team-kb-item.selected .team-kb-title { color: var(--primary); }
.team-kb-item.selected .team-kb-icon { color: var(--primary); }
.team-kb-icon { color: var(--text-muted); flex-shrink: 0; }
.team-kb-title { font-size: 13px; font-weight: 600; }
.team-kb-meta  { font-size: 11px; color: var(--text-muted); }

/* Scheduled messages layout */
.sched-label-row {
  font-size: 10px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-muted); margin-bottom: 10px;
}
.sched-grid { display: flex; flex-direction: column; gap: 14px; }
.sched-row { display: flex; align-items: center; gap: 12px; }
.sched-name { font-size: 13px; color: var(--text); font-weight: 500; flex-shrink: 0; }
.sched-right { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.sched-right .team-toggle { margin-left: 0 !important; }

/* Custom time picker */
.tp-wrap { position: relative; display: inline-block; }
.tp-display {
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; user-select: none; width: 105px;
  padding: 6px 10px; gap: 6px;
}
.tp-val { font-size: 13px; font-weight: 600; color: var(--text); letter-spacing: 0.04em; }
.tp-icon { color: var(--text-muted); display: flex; align-items: center; flex-shrink: 0; }
.tp-icon svg { width: 14px; height: 14px; }
.tp-popover {
  display: none; position: fixed; z-index: 9999;
  background: var(--white); border: 1.5px solid var(--border); border-radius: 10px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.1); padding: 8px 6px;
  flex-direction: row; align-items: flex-start; gap: 4px; min-width: 120px;
}
.tp-popover.open { display: flex; }
.tp-col {
  display: flex; flex-direction: column; gap: 1px;
  max-height: 160px; overflow-y: auto; flex: 1;
  scrollbar-width: none;
}
.tp-col::-webkit-scrollbar { display: none; }
.tp-item {
  font-size: 13px; font-weight: 500; color: var(--text);
  padding: 5px 8px; border-radius: 6px; cursor: pointer;
  text-align: center; transition: background 0.1s;
}
.tp-item:hover { background: var(--primary-light); color: var(--primary); }
.tp-item.active { background: var(--primary); color: #fff; font-weight: 600; }
.tp-sep { font-size: 16px; font-weight: 700; color: var(--text-muted); padding: 4px 2px; }

/* Toggle switch */
.team-toggle { position: relative; display: inline-block; width: 36px; height: 20px; flex-shrink: 0; }
.team-toggle input { opacity: 0; width: 0; height: 0; }
.team-toggle-slider {
  position: absolute; inset: 0; background: var(--border);
  border-radius: 20px; cursor: pointer; transition: background 0.2s;
}
.team-toggle-slider::before {
  content: ''; position: absolute;
  width: 14px; height: 14px; left: 3px; bottom: 3px;
  background: white; border-radius: 50%; transition: transform 0.2s;
}
.team-toggle input:checked + .team-toggle-slider { background: var(--primary); }
.team-toggle input:checked + .team-toggle-slider::before { transform: translateX(16px); }

.team-add-doc {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-top: 8px;
  background: var(--white);
}
.team-doc-tabs  { display: flex; gap: 4px; margin-bottom: 10px; }
.team-doc-tab   { padding: 4px 12px; border-radius: 20px; border: 1px solid var(--border); background: none; font-size: 12px; cursor: pointer; color: var(--text-muted); }
.team-doc-tab.active { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }

.team-detail { padding: 24px; }
.team-detail-header {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 24px;
}
.team-detail-avatar {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--primary); color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 20px; flex-shrink: 0;
}
.team-detail-name { font-size: 18px; font-weight: 700; }
.team-empty {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; height: 100%; padding: 40px;
  color: var(--text-muted); text-align: center;
}
.team-field       { margin-bottom: 16px; }
.team-label       { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.4px; }
.team-field-row   { display: flex; gap: 10px; flex-wrap: wrap; }
.team-prompt-textarea { min-height: 160px; font-family: inherit; resize: vertical; line-height: 1.6; }


/* ── Chat Widget (floating FAB + panel) ─────────────────────────────────── */

#chat-widget { position: fixed; bottom: 24px; right: 24px; z-index: 900; }

#chat-fab {
  width: 50px; height: 50px; border-radius: 50%;
  background: var(--primary); color: white; border: none;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 20px rgba(37,150,190,0.4);
  transition: transform 0.2s, box-shadow 0.2s;
}
#chat-fab:hover { transform: scale(1.08); box-shadow: 0 6px 24px rgba(37,150,190,0.5); }
#chat-fab .ic   { width: 22px; height: 22px; }
.chat-badge {
  position: absolute; top: -4px; right: -4px;
  min-width: 18px; height: 18px; padding: 0 4px;
  background: #e05252; color: white;
  border-radius: 20px; font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid white; pointer-events: none;
}

#chat-panel {
  position: fixed; bottom: 86px; right: 24px;
  width: 400px; height: 560px; max-height: calc(100vh - 110px);
  background: var(--white); border-radius: 14px;
  border: 1px solid #E2E8F0;
  box-shadow: 0 10px 25px rgba(0,0,0,0.05), 0 2px 6px rgba(0,0,0,0.03);
  display: flex; flex-direction: column; overflow: hidden;
  transform: scale(0.95) translateY(12px); opacity: 0; pointer-events: none;
  transition: transform 0.2s cubic-bezier(0.34,1.56,0.64,1), opacity 0.15s ease;
}
#chat-panel.chat-panel--open {
  transform: scale(1) translateY(0); opacity: 1; pointer-events: all;
}

.chat-panel-header {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-agent-dropdown {
  flex: 1; display: flex; align-items: center; gap: 4px;
  cursor: pointer; padding: 3px 6px; border-radius: 6px;
  transition: background 0.15s; user-select: none; min-width: 0;
}
.chat-agent-dropdown:hover { background: var(--bg); }
.chat-agent-label {
  font-size: 13px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-agent-chevron { color: var(--text-muted); display: flex; flex-shrink: 0; }
.chat-agent-chevron svg { width: 13px; height: 13px; }
.chat-agent-menu {
  display: none; position: fixed; z-index: 9999;
  background: var(--white); border: 1.5px solid var(--border);
  border-radius: 10px; box-shadow: 0 10px 25px rgba(0,0,0,0.1);
  padding: 5px; min-width: 190px; flex-direction: column; gap: 1px;
}
.chat-agent-menu.open { display: flex; }
.chat-agent-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 10px; border-radius: 7px; cursor: pointer;
  font-size: 13px; font-weight: 500; color: var(--text);
  transition: background 0.1s;
}
.chat-agent-item:hover { background: var(--bg); }
.chat-agent-item.active { color: var(--primary); font-weight: 600; }
.chat-unread-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--blocked); flex-shrink: 0;
}
.chat-icon-btn {
  width: 28px; height: 28px; border-radius: 6px; border: none;
  background: none; cursor: pointer; display: flex; align-items: center;
  justify-content: center; color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
}
.chat-icon-btn:hover { background: var(--bg); color: var(--text); }
.chat-icon-btn .ic   { width: 16px; height: 16px; }

.chat-messages {
  flex: 1; overflow-y: auto; padding: 14px 12px;
  display: flex; flex-direction: column; gap: 10px;
}
.chat-empty {
  color: var(--text-muted); font-size: 13px;
  text-align: center; padding: 20px 0;
  flex: 1; display: flex; align-items: center; justify-content: center;
}
.chat-msg {
  max-width: 84%; padding: 9px 13px;
  font-size: 13.5px; line-height: 1.55;
  border-radius: 14px; word-break: break-word;
  white-space: pre-wrap;
}
.chat-msg-user {
  align-self: flex-end;
  background: var(--primary); color: white;
  border-radius: 14px 14px 3px 14px;
}
.chat-msg-assistant {
  align-self: flex-start;
  background: var(--focus-bg); color: var(--text);
  border-radius: 14px 14px 14px 3px;
}
.chat-msg[data-loading] {
  width: fit-content;
  padding: 10px 16px;
}
.chat-msg-streaming .chat-msg-text:empty::before {
  content: '● ● ●';
  letter-spacing: 3px;
  font-size: 10px;
  color: var(--primary);
  animation: chatDots 1.2s ease-in-out infinite;
  display: inline-block;
}
.chat-msg-streaming .chat-msg-text:not(:empty)::after {
  content: '▋';
  display: inline-block;
  animation: chatBlink 0.8s step-start infinite;
  color: var(--primary); margin-left: 2px;
}
@keyframes chatBlink { 50% { opacity: 0; } }
@keyframes chatDots {
  0%, 100% { opacity: 0.3; }
  50%       { opacity: 1; }
}

.chat-input-row {
  display: flex; gap: 8px; padding: 10px 12px;
  border-top: 1px solid var(--border); flex-shrink: 0;
  align-items: flex-end;
}
#chat-input {
  flex: 1; resize: none; border: 1px solid #E2E8F0;
  border-radius: 10px; padding: 8px 12px; font-size: 13.5px;
  font-family: inherit; outline: none; max-height: 120px;
  overflow-y: auto; line-height: 1.4;
  transition: border-color 0.15s;
}
#chat-input:focus { border-color: var(--primary); }

.chat-send-btn {
  width: 36px; height: 36px; flex-shrink: 0;
  border-radius: 9px; border: none; cursor: pointer;
  background: var(--primary); color: white;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, transform 0.1s;
}
.chat-send-btn:hover    { background: #1d7ea3; }
.chat-send-btn:active   { transform: scale(0.94); }
.chat-send-btn.sending  { opacity: 0.6; cursor: not-allowed; }
.chat-send-btn .ic      { width: 16px; height: 16px; }

/* Tool action pill — shown when agent executes a DB action */
.chat-action-pill {
  align-self: center;
  background: rgba(39, 174, 96, 0.10);
  border: 1px solid rgba(39, 174, 96, 0.25);
  color: #1a7a42;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 500;
  padding: 3px 10px;
  margin: 2px auto;
  max-width: 90%;
  text-align: center;
}

@media (max-width: 480px) {
  #chat-panel { width: calc(100vw - 32px); right: 16px; bottom: 80px; }
  #chat-widget { bottom: 16px; right: 16px; }
}

/* ── Accounts View ─────────────────────────────────────────────────────────── */
.accounts-wrap { display: flex; flex-direction: column; gap: 24px; padding: 16px 20px 20px; max-width: 100%; }

/* ── Unified action bar ───────────────────────────────────── */
.accounts-bar {
  background: var(--white); border: 1px solid #e2e8f0;
  border-radius: 10px; box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  padding: 12px 16px;
}
.accounts-bar-error {
  font-size: 11.5px; color: #b45309; background: #fef9c3;
  border: 1px solid #fde68a; border-radius: 6px;
  padding: 6px 10px; margin-bottom: 10px;
}
.accounts-bar-inner {
  display: flex; align-items: center; gap: 16px;
}

/* Left — search (takes ~45% of bar) */
.accounts-bar-left {
  flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0;
}
.accounts-search-wrap {
  position: relative; display: flex; align-items: center; flex: 1;
}
.accounts-search-icon {
  position: absolute; left: 10px; pointer-events: none; color: #b0bec5;
}
.accounts-search-input {
  width: 100%; height: 36px; padding: 0 30px 0 32px;
  border: 1.5px solid var(--border); border-radius: 8px;
  font-size: 13px; color: var(--text); background: var(--bg);
  outline: none; transition: border-color 0.15s; box-sizing: border-box;
}
.accounts-search-input:focus { border-color: var(--primary); }
.accounts-search-clear {
  position: absolute; right: 8px; background: none; border: none;
  cursor: pointer; padding: 2px; color: var(--text-muted);
  opacity: 0; transition: opacity 0.15s; line-height: 0;
}
.accounts-search-clear:hover { color: var(--text); }
.accounts-count {
  font-size: 11.5px; color: var(--text-muted); white-space: nowrap;
  flex-shrink: 0; padding-left: 2px;
}

/* Divider between left and right */
.accounts-bar-divider {
  width: 1px; height: 28px; background: #e2e8f0; flex-shrink: 0;
}

/* Right — import (constrained, no flex-grow) */
.accounts-bar-right {
  display: flex; align-items: center; gap: 8px; flex-shrink: 0;
}
.accounts-file-label {
  display: flex; align-items: center; gap: 7px;
  border: 1.5px solid var(--border); border-radius: 8px; padding: 0 11px;
  height: 36px; box-sizing: border-box;
  cursor: pointer; font-size: 12.5px; color: var(--text-muted);
  background: var(--bg); transition: border-color 0.15s;
  max-width: 180px; overflow: hidden;
}
.accounts-file-label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.accounts-file-label:hover { border-color: var(--primary); color: var(--text); }
.accounts-upload-status {
  font-size: 11.5px; color: var(--text-muted); white-space: nowrap; max-width: 150px;
  overflow: hidden; text-overflow: ellipsis;
}
/* btn-sm helper — locked to 36px height to match inputs */
.btn-sm { height: 36px; padding: 0 16px; font-size: 12.5px; box-sizing: border-box; }

.accounts-table-wrap {
  background: var(--white); border: 1.5px solid var(--border);
  border-radius: 12px; overflow-x: auto;
}
.accounts-table {
  min-width: 1800px; width: 100%; border-collapse: collapse; font-size: 13px;
}
.accounts-table thead th {
  padding: 10px 14px; text-align: left;
  font-size: 10px; font-weight: 700; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--text-muted);
  background: var(--bg); border-bottom: 1.5px solid var(--border);
  white-space: nowrap;
}
.accounts-table th.acct-num,
.accounts-table td.acct-num { text-align: right; }

.acct-row { cursor: pointer; transition: background 0.12s; }
.acct-row:hover { background: #f0f7fb; }
.acct-row--open { background: #e8f3f9; }
.acct-row td {
  padding: 9px 14px; border-bottom: 1px solid var(--border);
  vertical-align: middle; line-height: 1;
}
/* Ensure badges & links sit on the baseline, not float */
.acct-row td span[style*="border-radius"],
.acct-row td a { vertical-align: middle; }

.acct-name { font-weight: 600; color: var(--text); }
.acct-truncate {
  display: inline-block; max-width: 160px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom;
}
.acct-truncate a { color: var(--primary); text-decoration: none; }
.acct-truncate a:hover { text-decoration: underline; }
.acct-score {
  display: inline-block; background: var(--primary-light); color: var(--primary);
  padding: 1px 7px; border-radius: 20px; font-weight: 600; font-size: 12px;
}

/* Expanded detail row */
.acct-detail-row td { padding: 0; border-bottom: 1px solid var(--border); }
.acct-detail-panel {
  padding: 16px 20px; background: var(--bg);
  display: flex; flex-direction: column; gap: 12px;
}
.acct-detail-grid { display: flex; flex-wrap: wrap; gap: 16px; }
.acct-detail-field { display: flex; flex-direction: column; gap: 2px; min-width: 140px; }
.acct-detail-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-muted); }
.acct-detail-val { font-size: 13px; color: var(--text); }
.acct-mono { font-family: monospace; font-size: 12px; }
.acct-detail-section { display: flex; flex-direction: column; gap: 4px; }
.acct-detail-section-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-muted); }
.acct-detail-text { font-size: 13px; color: var(--text); line-height: 1.6; white-space: pre-wrap; }

/* ── Tier filter pills ────────────────────────────────────────────────────── */
.acct-tier-strip {
  display: flex; align-items: center; gap: 4px; flex-shrink: 0;
}
.acct-tier-pill {
  height: 26px; padding: 0 11px; border-radius: 20px;
  border: 1.5px solid var(--border); background: var(--bg);
  font-size: 11.5px; font-weight: 600; color: var(--text-muted);
  cursor: pointer; transition: all 0.13s; line-height: 1;
}
.acct-tier-pill:hover { border-color: var(--primary); color: var(--primary); }
.acct-tier-pill--active {
  background: var(--primary); border-color: var(--primary);
  color: #fff;
}

/* ── Legend ⓘ button ──────────────────────────────────────────────────────── */
.acct-legend-btn {
  flex-shrink: 0; width: 26px; height: 26px; border-radius: 50%;
  border: 1.5px solid var(--border); background: var(--bg);
  font-size: 13px; color: var(--text-muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.13s; line-height: 1;
}
.acct-legend-btn:hover { border-color: var(--primary); color: var(--primary); }

/* ── Legend popover ──────────────────────────────────────────────────────── */
.acct-legend-pop {
  position: absolute; z-index: 9999;
  background: var(--white); border: 1px solid #e2e8f0;
  border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,0.13);
  width: 400px; max-height: 80vh; overflow-y: auto;
  padding: 16px;
}
.icp-legend-section {
  padding-bottom: 14px; margin-bottom: 14px;
  border-bottom: 1px solid #f0f0f0;
}
.icp-legend-section p { font-size: 12px; color: var(--text-muted); margin: 4px 0 0; line-height: 1.55; }
.icp-legend-title {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--text); margin-bottom: 4px;
}

/* ── View toggle ──────────────────────────────────────────────────────────── */
.acct-view-toggle {
  display: flex; align-items: center;
  border: 1.5px solid var(--border); border-radius: 8px;
  overflow: hidden; flex-shrink: 0;
}
.acct-view-btn {
  height: 34px; padding: 0 14px;
  background: var(--bg); border: none;
  font-size: 12.5px; font-weight: 500; color: var(--text-muted);
  cursor: pointer; transition: all 0.13s; white-space: nowrap;
}
.acct-view-btn + .acct-view-btn { border-left: 1.5px solid var(--border); }
.acct-view-btn:hover { background: #f0f7fb; color: var(--primary); }
.acct-view-btn--active {
  background: var(--primary-light); color: var(--primary); font-weight: 600;
}

/* ── ICP Config Editor ────────────────────────────────────────────────────── */
.icp-editor-wrap {
  display: grid; grid-template-columns: 220px 1fr;
  background: var(--white); border: 1.5px solid var(--border);
  border-radius: 12px; overflow: hidden; min-height: 520px;
}

/* Profiles sidebar */
.icp-profiles-panel {
  background: var(--bg); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.icp-profiles-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 14px 10px; border-bottom: 1px solid var(--border);
}
.icp-profile-list { flex: 1; padding: 8px 0; overflow-y: auto; }
.icp-profile-item {
  display: flex; align-items: center; gap: 6px;
  padding: 9px 14px; cursor: pointer;
  transition: background 0.12s; border-left: 3px solid transparent;
  font-size: 13px; color: var(--text);
}
.icp-profile-item:hover { background: var(--sidebar-hover); }
.icp-profile-item--active {
  border-left-color: var(--primary);
  background: var(--focus-bg); color: var(--primary); font-weight: 600;
}
.icp-profile-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icp-profile-badge {
  font-size: 9.5px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  background: var(--primary); color: #fff; padding: 1px 5px; border-radius: 10px;
  flex-shrink: 0;
}
.icp-profile-delete {
  background: none; border: none; cursor: pointer; font-size: 12px;
  color: var(--text-muted); padding: 2px 4px; border-radius: 4px;
  opacity: 0; transition: opacity 0.12s; flex-shrink: 0;
}
.icp-profile-item:hover .icp-profile-delete { opacity: 1; }
.icp-profile-delete:hover { color: var(--blocked); background: rgba(224,82,82,0.08); }
.icp-profiles-active-hint {
  padding: 10px 14px 14px; font-size: 11.5px; color: var(--text-muted);
  border-top: 1px solid var(--border);
}
.icp-profiles-active-hint strong { color: var(--text); font-weight: 600; }

/* Editor panel */
.icp-editor-panel {
  display: flex; flex-direction: column; overflow: hidden;
}
.icp-editor-content {
  flex: 1; overflow-y: auto; padding: 20px 24px;
  display: flex; flex-direction: column; gap: 20px;
}
.icp-editor-footer {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 24px; border-top: 1px solid var(--border);
  background: var(--bg); flex-shrink: 0;
}

/* Sections */
.icp-section { display: flex; flex-direction: column; gap: 8px; }
.icp-section-label {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--text-muted);
}
.icp-tier-row {
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
}

/* Rule cards */
.icp-rule-card {
  background: var(--bg); border: 1.5px solid var(--border);
  border-radius: 10px; margin-bottom: 8px; overflow: hidden;
}
.icp-rule-header {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  background: var(--white); border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.icp-rule-body {
  padding: 12px 14px;
}

/* Inputs */
.icp-input {
  height: 32px; padding: 0 9px;
  border: 1.5px solid var(--border); border-radius: 7px;
  font-size: 12.5px; color: var(--text); background: var(--white);
  outline: none; transition: border-color 0.13s; box-sizing: border-box;
}
.icp-input:focus { border-color: var(--primary); }
.icp-input:disabled { background: var(--bg); color: var(--text-muted); cursor: not-allowed; }
select.icp-input { cursor: pointer; }
.icp-textarea {
  width: 100%; padding: 7px 9px;
  border: 1.5px solid var(--border); border-radius: 7px;
  font-size: 12px; color: var(--text); background: var(--white);
  resize: vertical; outline: none; box-sizing: border-box;
  transition: border-color 0.13s; font-family: inherit; line-height: 1.5;
}
.icp-textarea:focus { border-color: var(--primary); }
.icp-range-row {
  display: flex; align-items: center; gap: 7px; margin-bottom: 5px;
}
.icp-icon-btn {
  background: none; border: none; cursor: pointer;
  font-size: 12px; color: var(--text-muted); padding: 3px 5px;
  border-radius: 4px; transition: all 0.12s; flex-shrink: 0;
}
.icp-icon-btn:hover { background: rgba(224,82,82,0.1); color: var(--blocked); }
