/* ============================================================
   TASKFLOW — Design System
   ============================================================ */

/* --- Tokens --- */
:root {
  --brand:        #2563eb;
  --brand-dark:   #1d4ed8;
  --brand-light:  #eff6ff;
  --surface:      #ffffff;
  --surface-2:    #f8fafc;
  --surface-3:    #f1f5f9;
  --border:       #e2e8f0;
  --text-primary: #0f172a;
  /* Secondary/muted darkened for WCAG AA contrast on light surfaces */
  --text-secondary:#475569;
  --text-muted:   #64748b;
  --success:      #16a34a;
  --success-bg:   #f0fdf4;
  --success-border:#bbf7d0;
  --danger:       #dc2626;
  --danger-bg:    #fef2f2;
  --danger-border:#fecaca;
  --warning:      #d97706;
  --warning-bg:   #fffbeb;
  --radius-sm:    6px;
  --radius:       10px;
  --radius-lg:    16px;
  --shadow-sm:    0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow:       0 4px 6px -1px rgba(0,0,0,.08), 0 2px 4px -2px rgba(0,0,0,.05);
  --shadow-lg:    0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -4px rgba(0,0,0,.05);
  --sidebar-w:    240px;
  --topbar-h:     60px;
  --font:         'Inter', 'Segoe UI', system-ui, sans-serif;
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; }

body {
  font-family: var(--font);
  background: var(--surface-2);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Accessibility — skip link, screen-reader-only, focus rings */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 10000;
  padding: .75rem 1rem;
  background: var(--brand);
  color: #fff;
  font-weight: 600;
  border-radius: var(--radius-sm);
}
.skip-link:focus {
  left: 1rem;
  top: 1rem;
  outline: 3px solid #fff;
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

:focus { outline: none; }
:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 2px;
}
.btn-primary:focus-visible,
.btn-secondary:focus-visible,
.btn-danger:focus-visible,
.sidebar-link:focus-visible,
.topbar-icon-btn:focus-visible,
.sidebar-toggle:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 2px;
}

/* ============================================================
   AUTH LAYOUT — Full-screen background image + right form card
   ============================================================ */
.auth-shell {
  min-height: 100vh;
  width: 100%;
  position: relative;
  display: flex;
  align-items: stretch;
  background: url('/static/i/background-main.png') center center / cover no-repeat;
}

/* Subtle dark overlay so the form card pops */
.auth-shell::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(10, 20, 50, 0.45);
  z-index: 0;
}

/* Brand logo pinned top-left over the image */
.auth-brand-overlay {
  position: absolute;
  top: 2rem;
  left: 2.5rem;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.auth-brand-overlay .logo-icon {
  width: 38px; height: 38px;
  background: rgba(255,255,255,.15);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,.2);
}

.auth-brand-overlay .logo-icon .material-icons { color: #fff; font-size: 22px; }
.auth-brand-overlay span { font-size: 1.2rem; font-weight: 700; color: #fff; letter-spacing: -.2px; }

/* Spacer pushes form card to the right */
.auth-spacer { flex: 1; z-index: 1; }

/* Right form panel */
.auth-form-panel {
  position: relative;
  z-index: 1;
  width: 420px;
  min-height: 100vh;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 2.5rem 2rem;
  overflow-y: auto;
  box-shadow: -8px 0 40px rgba(0,0,0,.25);
}

.auth-form-box {
  width: 100%;
  max-width: 360px;
}

.auth-form-box .auth-form-header {
  margin-bottom: 2rem;
}

.auth-form-box .auth-form-header h2 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -.3px;
}

.auth-form-box .auth-form-header p {
  color: var(--text-secondary);
  margin-top: .35rem;
  font-size: .875rem;
}

/* Mobile: stack vertically, hide spacer */
@media (max-width: 640px) {
  .auth-shell { background-position: center top; }
  .auth-spacer { display: none; }
  .auth-form-panel {
    width: 100%;
    min-height: 100vh;
    box-shadow: none;
    background: rgba(255,255,255,.97);
  }
}

/* ============================================================
   FORM COMPONENTS
   ============================================================ */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: .4rem;
}

.input-wrap {
  position: relative;
}

.input-wrap .input-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 18px;
  pointer-events: none;
}

.input-wrap input {
  width: 100%;
  padding: .65rem .75rem .65rem 2.5rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .95rem;
  font-family: var(--font);
  color: var(--text-primary);
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}

.input-wrap input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

.input-wrap input::placeholder { color: var(--text-muted); }

/* Input without icon */
.form-group input:not(.input-wrap input) {
  width: 100%;
  padding: .65rem .75rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .95rem;
  font-family: var(--font);
  color: var(--text-primary);
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}

.form-group input:not(.input-wrap input):focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

/* Buttons */
.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: .7rem 1.25rem;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: .95rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: background .15s, transform .1s, box-shadow .15s;
  box-shadow: 0 1px 3px rgba(37,99,235,.3);
}

.btn-primary:hover { background: var(--brand-dark); box-shadow: 0 4px 12px rgba(37,99,235,.35); }
.btn-primary:active { transform: translateY(1px); }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: .55rem 1rem;
  background: var(--surface);
  color: var(--text-primary);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: background .15s, border-color .15s;
}

.btn-secondary:hover { background: var(--surface-3); border-color: #cbd5e1; text-decoration: none; }

.btn-danger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: .55rem 1rem;
  background: var(--danger-bg);
  color: var(--danger);
  border: 1.5px solid var(--danger-border);
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: background .15s;
}

.btn-danger:hover { background: #fee2e2; }

/* Alerts */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: .75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  margin-bottom: 1.25rem;
  border: 1px solid transparent;
}

.alert .material-icons { font-size: 18px; flex-shrink: 0; margin-top: 1px; }

.alert-success { background: var(--success-bg); color: var(--success); border-color: var(--success-border); }
.alert-danger  { background: var(--danger-bg);  color: var(--danger);  border-color: var(--danger-border); }
.alert-warning { background: var(--warning-bg); color: var(--warning); border-color: #fde68a; }

/* Form footer links */
.auth-form-footer {
  margin-top: 1.5rem;
  text-align: center;
  font-size: .875rem;
  color: var(--text-secondary);
}

.auth-form-footer a { color: var(--brand); font-weight: 500; }
.auth-form-footer a:hover { text-decoration: underline; }

.auth-form-divider {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin: 1.25rem 0;
  color: var(--text-muted);
  font-size: .8rem;
}

.auth-form-divider::before,
.auth-form-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ============================================================
   APP SHELL — Sidebar + Topbar
   ============================================================ */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--text-primary);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform .25s ease;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
  text-decoration: none;
}

.sidebar-logo .logo-icon {
  width: 34px; height: 34px;
  background: var(--brand);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.sidebar-logo .logo-icon .material-icons { color: #fff; font-size: 20px; }
.sidebar-logo span { font-size: 1.05rem; font-weight: 700; color: #fff; letter-spacing: -.2px; }

.sidebar-nav {
  flex: 1;
  padding: .75rem 0;
  overflow-y: auto;
}

.sidebar-section-label {
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255,255,255,.3);
  padding: .75rem 1.25rem .35rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: .55rem 1.25rem;
  color: rgba(255,255,255,.65);
  font-size: .875rem;
  font-weight: 500;
  border-radius: 0;
  transition: background .15s, color .15s;
  text-decoration: none;
  position: relative;
}

.sidebar-link .material-icons { font-size: 19px; flex-shrink: 0; }

.sidebar-link:hover {
  background: rgba(255,255,255,.07);
  color: #fff;
  text-decoration: none;
}

.sidebar-link.active {
  background: rgba(37,99,235,.25);
  color: #fff;
}

.sidebar-link.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--brand);
  border-radius: 0 2px 2px 0;
}

.sidebar-footer {
  padding: .75rem;
  border-top: 1px solid rgba(255,255,255,.08);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: .6rem .75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .15s;
}

.sidebar-user:hover { background: rgba(255,255,255,.07); }

.sidebar-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--brand);
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { font-size: .8rem; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: .7rem; color: rgba(255,255,255,.45); }

/* Main content area */
.main-area {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Topbar */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.75rem;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left { display: flex; align-items: center; gap: 1rem; }

.topbar-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.topbar-right { display: flex; align-items: center; gap: .75rem; }

.org-switcher {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .3rem .6rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.org-switcher-icon { font-size: 17px; color: var(--text-muted); }
.org-switcher-select {
  border: none;
  background: transparent;
  font-family: var(--font);
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-primary);
  outline: none;
  cursor: pointer;
  max-width: 160px;
}

.topbar-icon-btn {
  width: 44px; height: 44px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  transition: background .15s, border-color .15s;
  position: relative;
}

.topbar-icon-btn:hover { background: var(--surface-3); border-color: #cbd5e1; }
.topbar-icon-btn .material-icons { font-size: 19px; }

.topbar-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--brand);
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
}

/* Real uploaded avatar images reuse the sizing/shape of the initials
   circles above (.sidebar-avatar / .topbar-avatar / .profile-avatar-lg)
   and just add cropping + a border. */
.avatar-img {
  object-fit: cover;
  border: 1px solid var(--border);
}

.profile-avatar-lg {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: var(--brand);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.avatar-uploader {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: .5rem;
}

.avatar-uploader-actions {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

/* Page content */
.page-content {
  padding: 1.75rem;
  flex: 1;
}

.page-header {
  margin-bottom: 1.5rem;
}

.page-header h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -.3px;
}

.page-header p {
  color: var(--text-secondary);
  font-size: .875rem;
  margin-top: .25rem;
}

/* ============================================================
   CARDS & STAT TILES
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.card-body { padding: 1.25rem; }
.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header h3 { font-size: .95rem; font-weight: 600; color: var(--text-primary); }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
}

.stat-icon {
  width: 42px; height: 42px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.stat-icon .material-icons { font-size: 22px; }
.stat-icon.blue   { background: #eff6ff; color: var(--brand); }
.stat-icon.green  { background: #f0fdf4; color: var(--success); }
.stat-icon.orange { background: #fff7ed; color: #ea580c; }
.stat-icon.purple { background: #faf5ff; color: #7c3aed; }

.stat-info { flex: 1; }
.stat-value { font-size: 1.6rem; font-weight: 700; color: var(--text-primary); line-height: 1; }
.stat-label { font-size: .78rem; color: var(--text-secondary); margin-top: .3rem; font-weight: 500; }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-secondary);
}

.empty-state .material-icons { font-size: 48px; color: var(--text-muted); margin-bottom: .75rem; }
.empty-state h4 { font-size: 1rem; font-weight: 600; color: var(--text-primary); margin-bottom: .35rem; }
.empty-state p { font-size: .875rem; }

/* ============================================================
   MOBILE SIDEBAR TOGGLE
   ============================================================ */
.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 4px;
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
}

.sidebar-toggle .material-icons { font-size: 24px; }

@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-area { margin-left: 0; }
  .sidebar-toggle { display: flex; }
  .sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 99;
  }
  .sidebar-overlay.open { display: block; }
}

/* ============================================================
   TOTP SETUP
   ============================================================ */
.recovery-codes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .4rem;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  font-family: 'Courier New', monospace;
  font-size: .85rem;
  color: var(--text-primary);
  margin: .75rem 0;
}

.setup-step {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  align-items: flex-start;
}

.step-number {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--brand-light);
  color: var(--brand);
  font-size: .8rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.step-content { flex: 1; }
.step-content h4 { font-size: .9rem; font-weight: 600; margin-bottom: .35rem; }
.step-content p  { font-size: .85rem; color: var(--text-secondary); }

/* ============================================================
   UTILITIES
   ============================================================ */
.text-muted    { color: var(--text-muted); }
.text-secondary{ color: var(--text-secondary); }
.text-sm       { font-size: .875rem; }
.text-xs       { font-size: .75rem; }
.font-semibold { font-weight: 600; }
.mt-1 { margin-top: .25rem; }
.mt-2 { margin-top: .5rem; }
.mt-3 { margin-top: .75rem; }
.mt-4 { margin-top: 1rem; }
.mb-1 { margin-bottom: .25rem; }
.mb-2 { margin-bottom: .5rem; }
.mb-3 { margin-bottom: .75rem; }
.mb-4 { margin-bottom: 1rem; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: .5rem; }
.gap-3 { gap: .75rem; }
.w-full { width: 100%; }

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: .2rem .6rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .2px;
}

.badge-success { background: var(--success-bg);  color: var(--success); border: 1px solid var(--success-border); }
.badge-danger  { background: var(--danger-bg);   color: var(--danger);  border: 1px solid var(--danger-border); }
.badge-warning { background: var(--warning-bg);  color: var(--warning); border: 1px solid #fde68a; }
.badge-neutral { background: var(--surface-3);   color: var(--text-secondary); border: 1px solid var(--border); }
.badge-role    { background: var(--brand-light);  color: var(--brand);  border: 1px solid #bfdbfe; }

/* Project status badges — one per db.ProjectStatus enum value */
.badge-status-active    { background: var(--success-bg);  color: var(--success);        border: 1px solid var(--success-border); }
.badge-status-on_hold   { background: var(--warning-bg);  color: var(--warning);        border: 1px solid #fde68a; }
.badge-status-completed { background: var(--brand-light); color: var(--brand);          border: 1px solid #bfdbfe; }
.badge-status-archived  { background: var(--surface-3);   color: var(--text-secondary); border: 1px solid var(--border); }

/* ============================================================
   PROJECTS — member chips & activity feed
   ============================================================ */
.member-chip {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .5rem .6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.member-chip + .member-chip { margin-top: .5rem; }
.member-chip-info { flex: 1; min-width: 0; }
.member-chip-name { font-size: .85rem; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member-chip-email { font-size: .72rem; color: var(--text-muted); }

.follower-chip {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .4rem 0;
  border-bottom: 1px solid var(--border);
}
.follower-chip:last-child { border-bottom: none; }
.follower-chip-info { flex: 1; min-width: 0; }
.follower-chip-name { font-size: .82rem; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.follower-chip-email { font-size: .7rem; color: var(--text-muted); }

.activity-feed { list-style: none; }

.activity-item {
  display: flex;
  gap: .75rem;
  padding: .6rem 0;
  border-bottom: 1px solid var(--border);
}

.activity-item:last-child { border-bottom: none; }

.activity-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--brand);
  margin-top: .45rem;
  flex-shrink: 0;
}

.activity-item-body { flex: 1; min-width: 0; }
.activity-item-message { font-size: .85rem; color: var(--text-primary); }
.activity-item-meta { font-size: .72rem; color: var(--text-muted); margin-top: .15rem; }

/* ============================================================
   TASKS (MVP4)
   ============================================================ */

/* Task status badges — one per db.TaskStatus enum value. Prefixed
   differently from .badge-status-* (project statuses) even though the
   value strings never collide, to keep the two enums visually distinct
   in markup. */
.badge-task-todo        { background: var(--surface-3);   color: var(--text-secondary); border: 1px solid var(--border); }
.badge-task-in_progress { background: var(--brand-light); color: var(--brand);          border: 1px solid #bfdbfe; }
.badge-task-in_review   { background: var(--warning-bg);  color: var(--warning);        border: 1px solid #fde68a; }
.badge-task-done        { background: var(--success-bg);  color: var(--success);        border: 1px solid var(--success-border); }

/* Priority badges — one per db.TaskPriority enum value. */
.badge-priority-low    { background: var(--surface-3);  color: var(--text-secondary); border: 1px solid var(--border); }
.badge-priority-medium { background: var(--brand-light); color: var(--brand);          border: 1px solid #bfdbfe; }
.badge-priority-high   { background: var(--warning-bg);  color: var(--warning);        border: 1px solid #fde68a; }
.badge-priority-urgent { background: var(--danger-bg);   color: var(--danger);         border: 1px solid var(--danger-border); }

.label-chip {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .15rem .55rem;
  border-radius: 999px;
  font-size: .7rem;
  font-weight: 600;
  background: var(--surface-3);
  border: 1px solid var(--border);
}

.label-chip-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.label-chip-remove { border: none; background: none; cursor: pointer; color: var(--text-muted); font-size: .8rem; line-height: 1; padding: 0; margin-left: .1rem; }
.label-chip-remove:hover { color: var(--danger); }

.task-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  margin-bottom: 1rem;
}

.task-filter-bar select,
.task-filter-bar input {
  padding: .45rem .65rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .82rem;
  font-family: var(--font);
  background: var(--surface);
  color: var(--text-primary);
  outline: none;
}

.task-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem .6rem;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
}

.task-row:last-child { border-bottom: none; }
.task-row:hover { background: var(--surface-2); }
.task-row-title { flex: 1; min-width: 0; font-size: .88rem; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-row-meta { font-size: .72rem; color: var(--text-muted); }
.task-row-due { font-size: .72rem; color: var(--text-muted); white-space: nowrap; }
.task-row-due.overdue { color: var(--danger); font-weight: 600; }

.subtask-row {
  padding: .5rem .6rem .5rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: .6rem;
}
.subtask-row:last-child { border-bottom: none; }

.comment-item { padding: .75rem 0; border-bottom: 1px solid var(--border); }
.comment-item:last-child { border-bottom: none; }
.comment-item-header { display: flex; align-items: baseline; gap: .5rem; margin-bottom: .25rem; }
.comment-item-author { font-size: .82rem; font-weight: 600; color: var(--text-primary); }
.comment-item-meta { font-size: .7rem; color: var(--text-muted); }
.comment-item-body { font-size: .85rem; color: var(--text-primary); white-space: pre-wrap; }

/* --- Notification bell (MVP5) --- */
.notif-bell { position: relative; }
.notif-badge {
  position: absolute;
  top: -4px; right: -4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: .62rem;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}
.notif-badge:empty { display: none; }

.notif-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: min(340px, 90vw);
  max-height: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 50;
  overflow: hidden;
  flex-direction: column;
}
.notif-dropdown.open { display: flex; }

.notif-dropdown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: .85rem;
  font-weight: 700;
  color: var(--text-primary);
}
.notif-mark-all-btn {
  border: none;
  background: none;
  color: var(--brand);
  font-size: .72rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}
.notif-mark-all-btn:hover { text-decoration: underline; }

#notif-dropdown-list { overflow-y: auto; max-height: 340px; }

.notif-empty { padding: 1.5rem 1rem; text-align: center; font-size: .82rem; color: var(--text-muted); }

.notif-items { list-style: none; margin: 0; padding: 0; }
.notif-item { border-bottom: 1px solid var(--border); }
.notif-item:last-child { border-bottom: none; }
.notif-item.unread { background: var(--brand-light); }
.notif-item-link {
  display: flex;
  flex-direction: column;
  gap: .2rem;
  padding: .7rem 1rem;
  text-decoration: none;
  color: inherit;
}
.notif-item-link:hover { background: var(--surface-3); }
.notif-item-message { font-size: .82rem; color: var(--text-primary); }
.notif-item-time { font-size: .68rem; color: var(--text-muted); }

.notif-view-all {
  display: block;
  text-align: center;
  padding: .6rem;
  font-size: .78rem;
  font-weight: 600;
  color: var(--brand);
  text-decoration: none;
  border-top: 1px solid var(--border);
}
.notif-view-all:hover { background: var(--surface-2); }

/* ============================================================
   LAYOUT GRIDS / TABLES (responsive)
   ============================================================ */
.layout-grid {
  display: grid;
  gap: 1rem;
  align-items: start;
}
.layout-grid--split { grid-template-columns: 1.4fr 1fr; }
.layout-grid--equal { grid-template-columns: 1fr 1fr; }

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

@media (max-width: 768px) {
  .layout-grid--split,
  .layout-grid--equal {
    grid-template-columns: 1fr;
  }

  .topbar-right {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: .5rem;
  }

  .org-switcher {
    max-width: 100%;
  }
  .org-switcher-select {
    max-width: 140px;
  }

  .page-content {
    padding: 1rem;
  }

  .auth-brand-overlay {
    top: 1rem;
    left: 1rem;
  }

  .auth-form-panel {
    width: 100%;
    max-width: none;
  }

  .auth-form-box {
    padding: 1.25rem;
  }

  .recovery-codes {
    grid-template-columns: 1fr;
  }
}

/* === CSP: migrated from inline styles === */
.data-table { width: 100%; border-collapse: collapse; }
.data-table-head-row { border-bottom: 1px solid var(--border); background: var(--surface-2); }
.row-border { border-bottom: 1px solid var(--border); }
.th-cell {
  padding: .75rem 1.25rem;
  text-align: left;
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .5px;
}
.th-cell--sm { padding: .65rem 1rem; font-size: .72rem; letter-spacing: 0; }
.th-cell--right { text-align: right; }
.td-cell { padding: .75rem 1.25rem; }
.td-cell--loose { padding: .85rem 1.25rem; }
.td-cell--body { font-size: .85rem; }
.td-muted { font-size: .8rem; color: var(--text-muted); }
.td-strong { font-weight: 600; font-size: .875rem; }
.td-top { vertical-align: top; }
.td-min-220 { min-width: 220px; }
.td-empty { padding: 3rem; text-align: center; color: var(--text-muted); }
.td-empty--sm { padding: 2rem; }
.page-header-row { display: flex; align-items: center; justify-content: space-between; }
.stack { display: flex; flex-direction: column; }
.stack--sm { gap: .6rem; }
.stack--md { gap: 1rem; }
.inline-row { display: flex; align-items: center; gap: .75rem; }
.inline-row--click { gap: .5rem; cursor: pointer; }
.inline-gap { display: flex; gap: .5rem; }
.inline-gap--tight { gap: .4rem; }
.inline-gap--lg { gap: .75rem; }
.inline-chip-row { display: inline-flex; gap: .35rem; align-items: center; }
.filter-row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: end; }
.spread-row { display: flex; justify-content: space-between; gap: 1rem; }
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.panel-sm { max-width: 560px; }
.panel-md { max-width: 640px; }
.panel-lg { max-width: 900px; }
.panel-center { margin: 0 auto; }
.filter-field { margin: 0; min-width: 220px; }
.flex-1 { flex: 1; }
.flex-min-180 { min-width: 180px; }
.p-0 { padding: 0; }
.p-1 { padding: .25rem; }
.p-5 { padding: 1.25rem; }
.mt-1b { margin-top: .35rem; }
.mt-5 { margin-top: 1.5rem; }
.mb-0 { margin-bottom: 0; }
.mb-1b { margin-bottom: .35rem; }
.mb-2b { margin-bottom: .4rem; }
.chip-gap { margin: 0 .3rem .3rem 0; }
.justify-center { justify-content: center; }
.no-underline { text-decoration: none; }
.link-quiet { text-decoration: none; color: inherit; }
.text-brand { color: var(--brand); }
.text-danger { color: var(--danger); }
.text-right { text-align: right; }
.hidden { display: none !important; }
.inline { display: inline; }
.cursor-pointer { cursor: pointer; }
.border-top { border-top: 1px solid var(--border); }
.section-divider { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.icon-xs { font-size: 16px; }
.icon-sm { font-size: 17px; }
.icon-md { font-size: 18px; }
.icon-xl { font-size: 32px; }
.text-85 { font-size: .85rem; }
.text-82 { font-size: .82rem; }
.text-78 { font-size: .78rem; }
.text-name { font-weight: 600; font-size: .875rem; }
.stat-value { font-size: 1.75rem; font-weight: 700; }
.error-page { text-align: center; padding: 2rem 0; }
.error-title { font-size: 1.75rem; font-weight: 700; color: var(--text-primary); line-height: 1.2; }
.error-message { color: var(--text-secondary); margin: .75rem 0 2rem; }
.error-icon-wrap {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.25rem;
}
.otp-input { letter-spacing: .2em; font-size: 1.1rem; }
.nowrap { white-space: nowrap; }
.btn-auto { width: auto; padding: .6rem 1.25rem; }
.btn-auto--md { padding: .65rem 1.25rem; }
.btn-auto--lg { padding: .65rem 1.5rem; }
.btn-inline { width: auto; display: inline-flex; }
.btn-xs { font-size: .72rem; padding: .3rem .6rem; }
.btn-sm { font-size: .8rem; padding: .35rem .75rem; }
.btn-sm--pad { padding: .4rem .85rem; }
.field {
  width: 100%;
  padding: .65rem .75rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .95rem;
  font-family: var(--font);
  background: var(--surface);
  color: var(--text-primary);
  outline: none;
}
.field--area { resize: vertical; }
.field--sm { padding: .6rem .7rem; font-size: .88rem; }
.field--xs { padding: .55rem .6rem; font-size: .85rem; }
.field--tiny { padding: .4rem .5rem; font-size: .78rem; }
.field--inline { width: auto; flex: 1; padding: .5rem .6rem; font-size: .85rem; }
.field--pill {
  width: auto;
  padding: .3rem .6rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
}
.field--compact { width: auto; padding: .35rem .5rem; font-size: .8rem; }
.def-label { padding: .6rem 0; font-size: .8rem; color: var(--text-secondary); }
.def-label--w { width: 40%; }
.def-value { padding: .6rem 0; font-size: .875rem; }
.def-value--med { font-weight: 500; }
.def-cell { padding: .6rem 0; }
.avatar-sm { width: 34px; height: 34px; font-size: .8rem; }
.avatar-xs { width: 30px; height: 30px; font-size: .72rem; }
.avatar-brand { background: var(--brand); }
.totp-qr-wrap { margin-top: 1rem; text-align: center; }
.totp-qr { border: 4px solid var(--border); border-radius: var(--radius-sm); }
.code-chip {
  background: var(--surface-3);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: .8rem;
}
.card-top-radius { border-radius: var(--radius) var(--radius) 0 0; }

.inline-row--wrap { flex-wrap: wrap; }
.inline-gap--md { gap: 1rem; }
.inline-gap--wrap { flex-wrap: wrap; align-items: center; }
.mb-3b { margin-bottom: .75rem; }
.pre-wrap { white-space: pre-wrap; color: var(--text-primary); font-size: .9rem; }
.section-divider--row {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: .75rem;
  align-items: center;
  flex-wrap: wrap;
}
.field--select-sm {
  width: auto;
  padding: .4rem .6rem;
  font-size: .82rem;
}
.field--select {
  width: auto;
  padding: .5rem .6rem;
  font-size: .85rem;
}
.subtask-title { flex: 1; font-size: .85rem; font-weight: 600; }
.th-pad { padding: .65rem 1rem; }
.td-att { padding: .7rem 1rem; font-size: .85rem; }
.td-att--muted { padding: .7rem 1rem; font-size: .8rem; color: var(--text-muted); }
.td-att--strong { padding: .7rem 1rem; font-size: .85rem; font-weight: 600; }
.td-att--right { padding: .7rem 1rem; text-align: right; white-space: nowrap; }
.btn-xxs { font-size: .78rem; padding: .3rem .65rem; }
.btn-micro { font-size: .7rem; padding: .25rem .5rem; }
.icon-15 { font-size: 15px; }
.avatar-xxs { width: 28px; height: 28px; font-size: .7rem; }
.btn-auto--sm { width: auto; padding: .55rem 1.1rem; }
.field--file { flex: 1; min-width: 200px; font-size: .85rem; font-family: var(--font); }
.field--color {
  width: 2.4rem;
  padding: 0;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
}
.field--area-sm {
  width: 100%;
  padding: .6rem .7rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .85rem;
  font-family: var(--font);
  background: var(--surface);
  color: var(--text-primary);
  outline: none;
  resize: vertical;
}
.field--area-md {
  width: 100%;
  padding: .65rem .75rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-family: var(--font);
  background: var(--surface);
  color: var(--text-primary);
  outline: none;
  resize: vertical;
}
.items-center { align-items: center; }

/* Analytics (MVP 8) */
.form-grid { display: grid; gap: 1rem; }
.form-grid--2 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.chart-wrap { position: relative; height: 240px; }
.chart-wrap--wide { height: 280px; }
.badge-health-healthy { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }
.badge-health-needs_attention { background: var(--warning-bg); color: var(--warning); border: 1px solid #fde68a; }
.badge-health-at_risk { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger-border); }
.row-warn { background: var(--warning-bg); }
.activity-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .85rem; }
.activity-list li { padding-bottom: .75rem; border-bottom: 1px solid var(--border); }
.activity-list li:last-child { border-bottom: 0; padding-bottom: 0; }
.activity-meta { font-size: .8rem; color: var(--text-muted); margin-bottom: .2rem; }
.analytics-project-card { text-decoration: none; color: inherit; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.mb-3 { margin-bottom: .75rem; }
