/* =========================================================
   Marketing Tasks — Refined Design System v2
   Apple-inspired with Linear/Notion-level polish
   ========================================================= */

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  /* === Surfaces === */
  --bg: #FAFAFB;
  --bg-elevated: #FFFFFF;
  --bg-secondary: #F4F4F6;
  --bg-tertiary: #EBEBEE;
  --bg-hover: rgba(0, 0, 0, 0.035);
  --bg-active: rgba(0, 0, 0, 0.06);
  --bg-overlay: rgba(20, 20, 24, 0.32);
  --bg-glass: rgba(252, 252, 253, 0.78);
  --bg-sidebar: #F7F7F8;

  /* === Text === */
  --text-primary: #1d1d1f;
  --text-secondary: #5d5d63;
  --text-tertiary: #8e8e93;
  --text-quaternary: #b8b8bf;

  /* === Accent === */
  --accent: #0071E3;
  --accent-hover: #005FBE;
  --accent-light: rgba(0, 113, 227, 0.08);
  --accent-light-2: rgba(0, 113, 227, 0.14);

  /* === Semantic === */
  --success: #30B948;
  --success-bg: rgba(48, 185, 72, 0.1);
  --warning: #F59E0B;
  --warning-bg: rgba(245, 158, 11, 0.1);
  --danger: #E11D48;
  --danger-bg: rgba(225, 29, 72, 0.08);
  --purple: #8B5CF6;
  --pink: #EC4899;

  /* === Status === */
  --status-todo: #94949A;
  --status-progress: #0071E3;
  --status-blocked: #E11D48;
  --status-review: #F59E0B;
  --status-done: #30B948;

  /* === Priority === */
  --priority-urgent: #E11D48;
  --priority-high: #F59E0B;
  --priority-medium: #0071E3;
  --priority-low: #94949A;

  /* === Borders === */
  --border: rgba(0, 0, 0, 0.06);
  --border-strong: rgba(0, 0, 0, 0.1);
  --border-focus: rgba(0, 113, 227, 0.4);

  /* === Shadows === */
  --shadow-xs: 0 1px 1px rgba(0, 0, 0, 0.02);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04), 0 1px 1px rgba(0, 0, 0, 0.02);
  --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.04), 0 2px 4px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 12px 24px rgba(0, 0, 0, 0.06), 0 4px 8px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 24px 48px rgba(0, 0, 0, 0.10), 0 8px 16px rgba(0, 0, 0, 0.06);
  --shadow-2xl: 0 32px 64px rgba(0, 0, 0, 0.14), 0 12px 24px rgba(0, 0, 0, 0.08);
  --shadow-focus: 0 0 0 3px rgba(0, 113, 227, 0.18);

  /* === Radii === */
  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 18px;
  --r-2xl: 22px;
  --r-full: 9999px;

  /* === Spacing === */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px;
  --s-6: 24px; --s-8: 32px; --s-10: 40px; --s-12: 48px;

  /* === Typography === */
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Inter', 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'SF Mono', 'JetBrains Mono', Menlo, monospace;

  /* === Motion === */
  --ease-out: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
  --tx-fast: 120ms var(--ease-smooth);
  --tx: 200ms var(--ease-smooth);

  /* === AI gradient === */
  --ai-gradient: linear-gradient(135deg, #8B5CF6 0%, #EC4899 100%);
  --ai-gradient-soft: linear-gradient(135deg, rgba(139, 92, 246, 0.08) 0%, rgba(236, 72, 153, 0.08) 100%);
}

html, body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  height: 100%;
  letter-spacing: -0.005em;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; font-size: inherit; }
input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

::selection { background: var(--accent-light-2); color: var(--text-primary); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, 0.12); border-radius: 5px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: rgba(0, 0, 0, 0.2); background-clip: padding-box; }

/* =========================================================
   AUTH PAGE
   ========================================================= */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 20% 20%, rgba(0, 113, 227, 0.08) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(139, 92, 246, 0.06) 0%, transparent 50%),
    linear-gradient(180deg, #FAFAFB 0%, #F0F0F4 100%);
  padding: var(--s-5);
  position: relative;
  overflow: hidden;
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-elevated);
  border-radius: var(--r-2xl);
  padding: 44px 36px;
  box-shadow: var(--shadow-2xl);
  border: 1px solid var(--border);
}
.auth-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 28px;
}
.auth-logo-mark {
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, #0071E3 0%, #00B7FF 100%);
  border-radius: 14px;
  position: relative;
  box-shadow: 0 8px 24px rgba(0, 113, 227, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
.auth-logo-mark::after {
  content: '';
  position: absolute;
  inset: 14px;
  background: white;
  clip-path: polygon(0 50%, 35% 80%, 100% 15%, 90% 5%, 35% 60%, 10% 40%);
}
.auth-card h1 {
  font-size: 26px;
  font-weight: 600;
  text-align: center;
  letter-spacing: -0.025em;
}
.auth-subtitle {
  text-align: center;
  color: var(--text-secondary);
  margin-top: 6px;
  margin-bottom: 32px;
  font-size: 14px;
}

/* =========================================================
   FORMS
   ========================================================= */
.form-group { margin-bottom: var(--s-4); }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg-secondary);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  font-size: 15px;
  transition: var(--tx-fast);
  outline: none;
  color: var(--text-primary);
}
.form-group input:hover, .form-group textarea:hover, .form-group select:hover {
  background: var(--bg-tertiary);
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
  background: var(--bg-elevated);
  border-color: var(--accent);
  box-shadow: var(--shadow-focus);
}
.form-group textarea { resize: vertical; min-height: 80px; font-family: inherit; line-height: 1.5; }
.form-error {
  background: var(--danger-bg);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: var(--r-md);
  font-size: 13px;
  margin-bottom: var(--s-3);
  border: 1px solid rgba(225, 29, 72, 0.2);
}

/* =========================================================
   BUTTONS
   ========================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: 500;
  transition: var(--tx-fast);
  white-space: nowrap;
  letter-spacing: -0.005em;
  user-select: none;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: scale(0.97); }

.btn-primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 1px 2px rgba(0, 113, 227, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  box-shadow: 0 2px 8px rgba(0, 113, 227, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}
.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
}
.btn-secondary:hover:not(:disabled) { background: var(--bg-tertiary); }
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover:not(:disabled) { background: var(--bg-hover); color: var(--text-primary); }
.btn-danger {
  background: transparent;
  color: var(--danger);
}
.btn-danger:hover:not(:disabled) { background: var(--danger-bg); }
.btn-full { width: 100%; padding: 13px 16px; font-size: 15px; }
.btn-sm { padding: 6px 10px; font-size: 12.5px; border-radius: var(--r-sm); }
.btn-icon-only { padding: 7px; }
.btn-icon-only svg { width: 14px; height: 14px; }

/* =========================================================
   APP LAYOUT
   ========================================================= */
.app {
  display: grid;
  grid-template-columns: 248px 1fr;
  height: 100vh;
}

/* === Sidebar === */
.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 24px;
}
.brand-mark {
  width: 30px;
  height: 30px;
  background: linear-gradient(135deg, #0071E3 0%, #00B7FF 100%);
  border-radius: 8px;
  flex-shrink: 0;
  position: relative;
  box-shadow: 0 2px 6px rgba(0, 113, 227, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
.brand-mark::after {
  content: '';
  position: absolute;
  inset: 7px;
  background: white;
  clip-path: polygon(0 50%, 35% 80%, 100% 15%, 90% 5%, 35% 60%, 10% 40%);
}
.brand-name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.nav-section {
  padding: 14px 10px 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--r-sm);
  font-size: 13.5px;
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--tx-fast);
  margin-bottom: 1px;
  user-select: none;
  position: relative;
}
.nav-item:hover { background: var(--bg-hover); }
.nav-item.active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 500;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 7px;
  bottom: 7px;
  width: 3px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}
.nav-item .nav-label { display: flex; align-items: center; gap: 10px; min-width: 0; }
.nav-item .nav-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  opacity: 0.85;
}
.nav-item .nav-icon svg { width: 16px; height: 16px; }
.nav-item .nav-count {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-tertiary);
  padding: 0 6px;
  min-width: 20px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.nav-item.active .nav-count {
  background: var(--accent);
  color: white;
  border-radius: var(--r-full);
}
.nav-item.has-warn .nav-count { color: var(--warning); }
.nav-item.has-danger .nav-count { color: var(--danger); }

.nav-item.nav-ai { background: var(--ai-gradient-soft); margin-top: 4px; }
.nav-item.nav-ai:hover {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.14) 0%, rgba(236, 72, 153, 0.14) 100%);
}
.nav-item.nav-ai .nav-icon { color: var(--purple); opacity: 1; }

.sidebar-bottom { margin-top: auto; padding-top: var(--s-4); }
.user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: var(--tx-fast);
}
.user-pill:hover { background: var(--bg-hover); }

/* === Main === */
.main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

/* === Topbar === */
.topbar {
  height: 56px;
  background: var(--bg-glass);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 0 var(--s-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  flex-shrink: 0;
  z-index: 10;
}
.topbar-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.015em;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

.search {
  position: relative;
  flex: 1;
  max-width: 320px;
}
.search input {
  width: 100%;
  padding: 7px 14px 7px 34px;
  background: var(--bg-secondary);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  font-size: 13.5px;
  outline: none;
  transition: var(--tx-fast);
}
.search input::placeholder { color: var(--text-tertiary); }
.search input:hover { background: var(--bg-tertiary); }
.search input:focus {
  background: var(--bg-elevated);
  border-color: var(--border-focus);
  box-shadow: var(--shadow-focus);
}
.search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--text-tertiary);
  pointer-events: none;
}
.search-icon svg { width: 14px; height: 14px; display: block; }

/* Safety net: any SVG without explicit size defaults to 16px so it can never balloon */
svg:not([width]):not([height]) { width: 16px; height: 16px; }

/* === Content === */
.content {
  flex: 1;
  overflow-y: auto;
  padding: var(--s-6) var(--s-8);
}
@media (max-width: 1100px) { .content { padding: var(--s-5) var(--s-6); } }

/* =========================================================
   STAT CARDS
   ========================================================= */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--s-3);
  margin-bottom: var(--s-6);
}
.stat-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-4) var(--s-5);
  transition: var(--tx);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.stat-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}
.stat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
}
.stat-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}
.stat-icon {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm);
  background: var(--icon-bg, var(--bg-secondary));
  color: var(--icon-color, var(--text-secondary));
}
.stat-icon svg { width: 14px; height: 14px; }
.stat-card.active .stat-icon { --icon-bg: var(--accent-light); --icon-color: var(--accent); }
.stat-card.done .stat-icon { --icon-bg: var(--success-bg); --icon-color: var(--success); }
.stat-card.overdue .stat-icon { --icon-bg: var(--danger-bg); --icon-color: var(--danger); }
.stat-card.struggling .stat-icon { --icon-bg: var(--warning-bg); --icon-color: var(--warning); }
.stat-value {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.025em;
  margin-top: 6px;
  font-feature-settings: 'tnum';
}

/* =========================================================
   QUICK ADD
   ========================================================= */
.quick-add {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-2);
  margin-bottom: var(--s-4);
  display: flex;
  align-items: center;
  gap: var(--s-2);
  transition: var(--tx);
  box-shadow: var(--shadow-xs);
}
.quick-add:hover { box-shadow: var(--shadow-sm); border-color: var(--border-strong); }
.quick-add:focus-within {
  border-color: var(--accent);
  box-shadow: var(--shadow-focus);
}
.quick-add-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15);
}
.quick-add-icon svg { width: 16px; height: 16px; }
.quick-add input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  padding: 8px 4px;
  font-size: 14.5px;
}
.quick-add input::placeholder { color: var(--text-tertiary); }
.quick-add-hint {
  font-size: 11px;
  color: var(--text-tertiary);
  padding-right: 10px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.kbd {
  display: inline-flex;
  align-items: center;
  font-family: var(--font);
  font-size: 10.5px;
  background: var(--bg-tertiary);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  font-weight: 500;
}

/* =========================================================
   SECTION HEADER + SEGMENTED CONTROL
   ========================================================= */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--s-3);
}
.section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.section-actions {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

.segmented {
  display: inline-flex;
  background: var(--bg-secondary);
  padding: 2px;
  border-radius: var(--r-sm);
  gap: 1px;
}
.segmented button {
  padding: 5px 10px;
  font-size: 12.5px;
  color: var(--text-secondary);
  border-radius: 6px;
  font-weight: 500;
  transition: var(--tx-fast);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.segmented button.on {
  background: var(--bg-elevated);
  color: var(--text-primary);
  box-shadow: var(--shadow-xs);
}
.segmented button:hover:not(.on) { color: var(--text-primary); }
.segmented svg { width: 13px; height: 13px; }

/* =========================================================
   TASK LIST
   ========================================================= */
.task-list {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}
.task-row {
  display: grid;
  grid-template-columns: 24px 1fr auto auto auto auto;
  gap: var(--s-4);
  align-items: center;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--tx-fast);
  position: relative;
}
.task-row:last-child { border-bottom: none; }
.task-row:hover { background: var(--bg-hover); }
.task-row.struggling::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--warning);
}

.task-checkbox {
  width: 20px;
  height: 20px;
  border: 1.5px solid var(--text-quaternary);
  border-radius: var(--r-full);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--tx-fast);
  flex-shrink: 0;
}
.task-checkbox:hover {
  border-color: var(--accent);
  background: var(--accent-light);
}
.task-checkbox.done {
  background: var(--success);
  border-color: var(--success);
}
.task-checkbox.done::after {
  content: '';
  width: 9px;
  height: 5px;
  border-left: 1.5px solid white;
  border-bottom: 1.5px solid white;
  transform: rotate(-45deg) translateY(-1px);
}

.task-title-wrap { min-width: 0; }
.task-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.task-row.done-row .task-title {
  text-decoration: line-through;
  color: var(--text-tertiary);
}
.task-meta {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 3px;
  display: flex;
  align-items: center;
  gap: var(--s-2);
}
.task-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.task-meta-item svg { width: 11px; height: 11px; }
.task-meta .dot {
  color: var(--text-quaternary);
  font-size: 6px;
}

.priority-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-secondary);
  text-transform: capitalize;
}
.priority-dot {
  width: 7px;
  height: 7px;
  border-radius: var(--r-full);
}
.priority-urgent .priority-dot { background: var(--priority-urgent); box-shadow: 0 0 0 2px rgba(225, 29, 72, 0.15); }
.priority-high .priority-dot { background: var(--priority-high); }
.priority-medium .priority-dot { background: var(--priority-medium); }
.priority-low .priority-dot { background: var(--priority-low); }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 500;
  padding: 2px 9px;
  border-radius: var(--r-full);
}
.status-pill::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}
.status-todo { background: rgba(148, 148, 154, 0.12); color: #6b6b71; }
.status-in_progress { background: var(--accent-light); color: var(--accent); }
.status-blocked { background: var(--danger-bg); color: var(--danger); }
.status-review { background: var(--warning-bg); color: #B57509; }
.status-done { background: var(--success-bg); color: #1F8E33; }

.assignee-avatar {
  width: 26px;
  height: 26px;
  border-radius: var(--r-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10.5px;
  font-weight: 600;
  color: white;
  flex-shrink: 0;
  box-shadow: inset 0 -1px 1px rgba(0, 0, 0, 0.08);
}

.task-due {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  font-feature-settings: 'tnum';
}
.task-due.overdue { color: var(--danger); font-weight: 500; }
.task-due.soon { color: var(--warning); font-weight: 500; }

.struggling-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: var(--warning-bg);
  color: #B57509;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: var(--r-full);
}
.struggling-badge svg { width: 10px; height: 10px; }

/* =========================================================
   KANBAN
   ========================================================= */
.board {
  display: grid;
  grid-template-columns: repeat(5, minmax(260px, 1fr));
  gap: var(--s-3);
  align-items: start;
  overflow-x: auto;
  padding-bottom: var(--s-3);
}
.board-column {
  background: var(--bg-secondary);
  border-radius: var(--r-lg);
  padding: var(--s-3);
  min-height: 200px;
}
.board-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--s-3);
  padding: 0 4px;
}
.board-col-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
}
.board-col-title::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--col-color, var(--text-tertiary));
}
.board-col-count {
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 500;
  background: var(--bg-elevated);
  padding: 1px 7px;
  border-radius: var(--r-full);
}
.board-col-todo .board-col-title::before { background: var(--status-todo); }
.board-col-in_progress .board-col-title::before { background: var(--status-progress); }
.board-col-blocked .board-col-title::before { background: var(--status-blocked); }
.board-col-review .board-col-title::before { background: var(--status-review); }
.board-col-done .board-col-title::before { background: var(--status-done); }

.board-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-3);
  margin-bottom: 8px;
  cursor: pointer;
  transition: var(--tx-fast);
  box-shadow: var(--shadow-xs);
}
.board-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}
.board-card.struggling { border-left: 3px solid var(--warning); padding-left: 10px; }
.board-card-title {
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.4;
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.board-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
}
.board-card-left {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-width: 0;
}
.board-card-due {
  font-size: 11.5px;
  color: var(--text-tertiary);
  white-space: nowrap;
}
.board-card-due.overdue { color: var(--danger); font-weight: 500; }
.board-card-due.soon { color: var(--warning); }
.board-empty {
  font-size: 12px;
  color: var(--text-quaternary);
  text-align: center;
  padding: 20px 10px;
  font-style: italic;
}

/* =========================================================
   EMPTY STATE
   ========================================================= */
.empty {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-secondary);
}
.empty-illustration {
  width: 80px;
  height: 80px;
  margin: 0 auto var(--s-4);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  border-radius: 50%;
  color: var(--text-tertiary);
}
.empty-illustration svg { width: 36px; height: 36px; }
.empty-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
  letter-spacing: -0.01em;
}
.empty-sub { font-size: 13px; color: var(--text-tertiary); }

/* =========================================================
   FAB
   ========================================================= */
.fab {
  position: fixed;
  bottom: var(--s-8);
  right: var(--s-8);
  width: 52px;
  height: 52px;
  border-radius: var(--r-full);
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 113, 227, 0.3), 0 12px 32px rgba(0, 113, 227, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  cursor: pointer;
  transition: var(--tx);
  z-index: 100;
}
.fab svg { width: 22px; height: 22px; }
.fab:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 6px 16px rgba(0, 113, 227, 0.35), 0 16px 40px rgba(0, 113, 227, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
.fab:active { transform: scale(0.95); }

/* =========================================================
   MODAL
   ========================================================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(8px) saturate(140%);
  -webkit-backdrop-filter: blur(8px) saturate(140%);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 80px 20px 20px;
  z-index: 200;
  overflow-y: auto;
  animation: fadeIn 200ms var(--ease-smooth);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp {
  from { transform: translateY(16px) scale(0.98); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}
@keyframes slideRight {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.modal {
  background: var(--bg-elevated);
  border-radius: var(--r-2xl);
  max-width: 640px;
  width: 100%;
  box-shadow: var(--shadow-2xl);
  animation: slideUp 280ms var(--ease-out);
  overflow: hidden;
  border: 1px solid var(--border);
}
.modal-header {
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
}
.modal-title {
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: -0.015em;
}
.modal-close {
  width: 28px;
  height: 28px;
  border-radius: var(--r-full);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  transition: var(--tx-fast);
}
.modal-close:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.modal-close svg { width: 14px; height: 14px; }
.modal-body {
  padding: var(--s-5) var(--s-6);
  max-height: calc(100vh - 220px);
  overflow-y: auto;
}
.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: var(--s-2);
  background: var(--bg-secondary);
}

/* Quick task modal */
.modal.modal-quick { max-width: 540px; }
.quick-title-input {
  font-size: 17px;
  font-weight: 500;
  width: 100%;
  border: none;
  outline: none;
  padding: 6px 0;
  background: transparent;
  letter-spacing: -0.015em;
}
.quick-title-input::placeholder { color: var(--text-tertiary); font-weight: 400; }

.quick-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: var(--s-4);
}
.quick-option {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  background: var(--bg-secondary);
  border-radius: var(--r-full);
  font-size: 12.5px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--tx-fast);
  border: 1px solid transparent;
}
.quick-option:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.quick-option.set {
  background: var(--accent-light);
  color: var(--accent);
  border-color: rgba(0, 113, 227, 0.2);
}
.quick-option svg { width: 13px; height: 13px; }
.quick-option select,
.quick-option input {
  background: transparent;
  border: none;
  outline: none;
  color: inherit;
  font-size: inherit;
  padding: 0;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

/* =========================================================
   TASK DETAIL — slide-in panel
   ========================================================= */
.detail-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 24, 0.2);
  backdrop-filter: blur(2px);
  z-index: 190;
  animation: fadeIn 200ms var(--ease-smooth);
}
.detail-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 720px;
  max-width: calc(100vw - 60px);
  background: var(--bg-elevated);
  z-index: 200;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-2xl);
  animation: slideRight 320ms var(--ease-out);
  border-left: 1px solid var(--border);
}
.detail-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  flex-shrink: 0;
}
.detail-id {
  font-size: 12px;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
}
.detail-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.detail-body {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: 1fr 240px;
}
.detail-main {
  padding: var(--s-6);
  overflow-y: auto;
  min-width: 0;
}
.detail-side {
  background: var(--bg-secondary);
  padding: var(--s-5);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  overflow-y: auto;
}

.detail-title {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.025em;
  border: none;
  outline: none;
  width: 100%;
  background: transparent;
  padding: 4px 8px;
  margin: 0 -8px var(--s-2);
  border-radius: var(--r-sm);
  transition: var(--tx-fast);
  line-height: 1.25;
}
.detail-title:hover { background: var(--bg-secondary); }
.detail-title:focus { background: var(--bg-secondary); box-shadow: var(--shadow-focus); }

.detail-description {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  border: none;
  outline: none;
  width: 100%;
  background: transparent;
  padding: 8px;
  margin: 0 -8px var(--s-5);
  resize: none;
  min-height: 80px;
  font-family: inherit;
  border-radius: var(--r-sm);
  transition: var(--tx-fast);
}
.detail-description::placeholder { color: var(--text-tertiary); }
.detail-description:hover { background: var(--bg-secondary); }
.detail-description:focus { background: var(--bg-secondary); box-shadow: var(--shadow-focus); }

.side-field { font-size: 12px; }
.side-field-label {
  font-weight: 500;
  color: var(--text-tertiary);
  margin-bottom: 5px;
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.side-field-value {
  background: var(--bg-elevated);
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  padding: 7px 10px;
  font-size: 13px;
  outline: none;
  transition: var(--tx-fast);
  width: 100%;
  cursor: pointer;
  color: var(--text-primary);
}
.side-field-value:hover { border-color: var(--border-strong); }
.side-field-value:focus { border-color: var(--accent); box-shadow: var(--shadow-focus); }
select.side-field-value {
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%238e8e93' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6.5L8 10.5l4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 14px;
  padding-right: 28px;
}

.side-meta {
  font-size: 11.5px;
  color: var(--text-tertiary);
  padding-top: var(--s-3);
  border-top: 1px solid var(--border);
  line-height: 1.7;
}
.side-meta-row {
  display: flex;
  justify-content: space-between;
  gap: var(--s-2);
  margin-bottom: 4px;
}
.side-meta-label { color: var(--text-tertiary); }
.side-meta-value { color: var(--text-secondary); font-weight: 500; }

.side-struggling {
  background: var(--warning-bg);
  border: 1px solid rgba(245, 158, 11, 0.2);
  border-radius: var(--r-sm);
  padding: 8px 10px;
  font-size: 12px;
  color: #B57509;
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin-top: var(--s-3);
  line-height: 1.4;
}
.side-struggling svg { width: 14px; height: 14px; flex-shrink: 0; margin-top: 1px; }

/* Discussion */
.discussion-section {
  margin-top: var(--s-6);
  padding-top: var(--s-5);
  border-top: 1px solid var(--border);
}
.discussion-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--s-4);
}
.discussion-title {
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}
.discussion-count {
  font-size: 12px;
  color: var(--text-tertiary);
  background: var(--bg-secondary);
  padding: 1px 7px;
  border-radius: var(--r-full);
  font-weight: 500;
}

.ai-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: var(--s-4);
  padding: 8px 10px;
  background: var(--ai-gradient-soft);
  border-radius: var(--r-md);
  border: 1px solid rgba(139, 92, 246, 0.12);
}
.ai-actions-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--purple);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-right: 4px;
}
.ai-actions-label svg { width: 12px; height: 12px; }
.ai-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(139, 92, 246, 0.18);
  border-radius: var(--r-full);
  font-size: 12px;
  color: var(--purple);
  font-weight: 500;
  cursor: pointer;
  transition: var(--tx-fast);
}
.ai-btn:hover {
  background: white;
  border-color: rgba(139, 92, 246, 0.35);
  box-shadow: 0 1px 4px rgba(139, 92, 246, 0.15);
}
.ai-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.ai-btn svg { width: 12px; height: 12px; }

/* Comments */
.comment {
  display: flex;
  gap: 10px;
  margin-bottom: var(--s-4);
}
.comment-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--r-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
  box-shadow: inset 0 -1px 1px rgba(0, 0, 0, 0.08);
}
.comment-avatar.ai-avatar {
  background: var(--ai-gradient);
  font-size: 14px;
}
.comment-body { flex: 1; min-width: 0; }
.comment-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  margin-bottom: 4px;
}
.comment-author { font-weight: 600; color: var(--text-primary); }
.comment-time { color: var(--text-tertiary); }
.comment-text {
  background: var(--bg-secondary);
  padding: 10px 14px;
  border-radius: var(--r-md);
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.comment-text.ai {
  background: var(--ai-gradient-soft);
  border: 1px solid rgba(139, 92, 246, 0.15);
}
.ai-label {
  font-size: 9.5px;
  font-weight: 700;
  color: var(--purple);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: rgba(139, 92, 246, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
}

.comment-form {
  display: flex;
  gap: 10px;
  margin-top: var(--s-4);
  align-items: flex-end;
}
.comment-form textarea {
  flex: 1;
  padding: 10px 12px;
  background: var(--bg-secondary);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  font-size: 14px;
  outline: none;
  resize: vertical;
  min-height: 44px;
  max-height: 200px;
  font-family: inherit;
  transition: var(--tx-fast);
  line-height: 1.5;
}
.comment-form textarea:focus {
  background: var(--bg-elevated);
  border-color: var(--accent);
  box-shadow: var(--shadow-focus);
}

/* =========================================================
   NOTIFICATIONS
   ========================================================= */
.notif-btn {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: var(--r-full);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  transition: var(--tx-fast);
}
.notif-btn:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.notif-btn svg { width: 16px; height: 16px; }
.notif-badge {
  position: absolute;
  top: 5px;
  right: 6px;
  width: 9px;
  height: 9px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid var(--bg-elevated);
}

.notif-panel {
  position: fixed;
  top: 60px;
  right: 24px;
  width: 380px;
  max-height: 520px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  z-index: 150;
  animation: slideUp 240ms var(--ease-out);
}
.notif-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.notif-list { overflow-y: auto; flex: 1; }
.notif-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: var(--tx-fast);
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.notif-item:hover { background: var(--bg-hover); }
.notif-item.unread { background: var(--accent-light); }
.notif-item.unread:hover { background: var(--accent-light-2); }
.notif-item:last-child { border-bottom: none; }
.notif-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: 7px;
  flex-shrink: 0;
}
.notif-item:not(.unread) .notif-dot { visibility: hidden; }
.notif-item-body { flex: 1; min-width: 0; }
.notif-item-title {
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 2px;
}
.notif-item-msg {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.notif-item-time {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 4px;
}

/* Report modal */
.report-content {
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-primary);
  padding: var(--s-5);
  background: var(--ai-gradient-soft);
  border-radius: var(--r-md);
  border: 1px solid rgba(139, 92, 246, 0.15);
  min-height: 200px;
}
.report-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--purple);
  font-size: 14px;
  min-height: 200px;
}

/* =========================================================
   TOAST
   ========================================================= */
.toast-stack {
  position: fixed;
  bottom: var(--s-6);
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}
.toast {
  background: rgba(28, 28, 30, 0.94);
  color: white;
  padding: 11px 18px;
  border-radius: var(--r-full);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-xl);
  animation: slideUp 240ms var(--ease-out);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}
.toast svg { width: 14px; height: 14px; }
.toast.success { background: rgba(48, 185, 72, 0.96); }
.toast.error { background: rgba(225, 29, 72, 0.96); }

/* Spinner */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-bottom-color: transparent;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}
.spinner-lg { width: 22px; height: 22px; border-width: 2.5px; }
@keyframes spin { to { transform: rotate(360deg); } }

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.ai-shimmer {
  background: linear-gradient(90deg, var(--purple) 0%, var(--pink) 50%, var(--purple) 100%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: shimmer 2s linear infinite;
}

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 960px) {
  .app { grid-template-columns: 64px 1fr; }
  .sidebar { padding: var(--s-3) 8px; }
  .brand-name, .label-text, .nav-section, .nav-count, .user-pill .user-info { display: none; }
  .nav-item { justify-content: center; padding: 9px; }
  .nav-item.active::before { display: none; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .topbar { padding: 0 var(--s-4); }
  .topbar-title { display: none; }
  .content { padding: var(--s-4); }
  .detail-body { grid-template-columns: 1fr; }
  .detail-side { border-left: none; border-top: 1px solid var(--border); }
  .detail-panel { width: 100%; max-width: 100%; }
  .board { grid-template-columns: repeat(5, 280px); }
}
@media (max-width: 600px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .stat-value { font-size: 22px; }
  .task-row { grid-template-columns: 22px 1fr auto; gap: 10px; padding: 10px 14px; }
  .task-row .priority-badge, .task-row .status-pill, .task-row .assignee-avatar { display: none; }
  .fab { bottom: var(--s-5); right: var(--s-5); width: 48px; height: 48px; }
  .notif-panel { right: 12px; left: 12px; width: auto; }
}