/* ==========================================================================
   TaskFlow — design system
   --------------------------------------------------------------------------
   Layered on top of Bootstrap 5. Everything is driven by the custom
   properties in :root so the dark theme is a token swap, not a second
   stylesheet.
   ========================================================================== */

:root {
  /* Brand ramp */
  --tf-indigo: #6366f1;
  --tf-indigo-600: #4f46e5;
  --tf-indigo-050: #eef2ff;
  --tf-blue: #0ea5e9;
  --tf-cyan: #06b6d4;
  --tf-teal: #14b8a6;
  --tf-green: #10b981;
  --tf-amber: #f59e0b;
  --tf-rose: #f43f5e;
  --tf-red: #ef4444;
  --tf-purple: #8b5cf6;
  --tf-slate: #64748b;

  /* Surfaces */
  --tf-bg: #f6f7fb;
  --tf-surface: #ffffff;
  --tf-surface-2: #fbfbfe;
  --tf-surface-3: #f1f3f9;
  --tf-sidebar: #ffffff;
  --tf-border: #e6e8f0;
  --tf-border-strong: #d6d9e6;

  /* Text */
  --tf-text: #1e2235;
  --tf-text-muted: #6b7280;
  --tf-text-subtle: #9aa1b1;

  /* Effects */
  --tf-shadow-xs: 0 1px 2px rgba(24, 28, 50, 0.05);
  --tf-shadow-sm: 0 2px 6px rgba(24, 28, 50, 0.06);
  --tf-shadow: 0 6px 20px rgba(24, 28, 50, 0.08);
  --tf-shadow-lg: 0 18px 45px rgba(24, 28, 50, 0.14);
  --tf-radius: 14px;
  --tf-radius-sm: 10px;
  --tf-radius-lg: 20px;

  /* Layout */
  --tf-sidebar-width: 250px;
  --tf-sidebar-collapsed: 74px;
  --tf-navbar-height: 62px;

  --bs-primary: var(--tf-indigo);
  --bs-primary-rgb: 99, 102, 241;
  --bs-link-color: var(--tf-indigo-600);
  --bs-link-hover-color: #4338ca;
  --bs-body-font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

[data-theme="dark"] {
  --tf-bg: #0e1117;
  --tf-surface: #161a23;
  --tf-surface-2: #1b202b;
  --tf-surface-3: #212734;
  --tf-sidebar: #12151d;
  --tf-border: #262c39;
  --tf-border-strong: #333b4d;
  --tf-text: #e6e9f2;
  --tf-text-muted: #9aa3b6;
  --tf-text-subtle: #6f7891;
  --tf-indigo-050: #1e2340;
  --tf-shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
  --tf-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.45);
  --tf-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  --tf-shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

/* --------------------------------------------------------------------------
   Base
   -------------------------------------------------------------------------- */

body {
  background: var(--tf-bg);
  color: var(--tf-text);
  font-family: var(--bs-body-font-family);
  font-size: 0.9375rem;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6, .fw-display {
  letter-spacing: -0.015em;
  font-weight: 650;
  color: var(--tf-text);
}

a { text-decoration: none; }
a:hover { text-decoration: none; }

.text-muted { color: var(--tf-text-muted) !important; }
.text-subtle { color: var(--tf-text-subtle) !important; }
.tiny { font-size: 0.75rem; }
.mono { font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace; }

::selection { background: rgba(99, 102, 241, 0.22); }

*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--tf-border-strong);
  border-radius: 999px;
  border: 3px solid transparent;
  background-clip: content-box;
}

/* --------------------------------------------------------------------------
   App shell
   -------------------------------------------------------------------------- */

.app-shell { min-height: 100vh; }

.app-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--tf-sidebar-width);
  background: var(--tf-sidebar);
  border-right: 1px solid var(--tf-border);
  display: flex;
  flex-direction: column;
  z-index: 1040;
  transition: width 0.18s ease, transform 0.18s ease;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  height: var(--tf-navbar-height);
  padding: 0 1.15rem;
  border-bottom: 1px solid var(--tf-border);
  flex: 0 0 auto;
}

.app-brand-mark {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--tf-indigo) 0%, #a855f7 100%);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 1.05rem;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.app-brand-text { line-height: 1.1; overflow: hidden; }
.app-brand-text strong { font-size: 1.02rem; letter-spacing: -0.02em; }
.app-brand-text span { font-size: 0.68rem; color: var(--tf-text-subtle); display: block; }

.app-nav {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 0.9rem 0.7rem 1.4rem;
}

.app-nav-label {
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-weight: 700;
  color: var(--tf-text-subtle);
  padding: 0.9rem 0.65rem 0.4rem;
}

.app-nav-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 0.7rem;
  border-radius: var(--tf-radius-sm);
  color: var(--tf-text-muted);
  font-weight: 550;
  margin-bottom: 2px;
  position: relative;
  white-space: nowrap;
  transition: background 0.12s ease, color 0.12s ease;
}

.app-nav-link i:first-child { font-size: 1.02rem; width: 1.25rem; text-align: center; flex: 0 0 auto; }
.app-nav-link:hover { background: var(--tf-surface-3); color: var(--tf-text); }
.app-nav-link.active { background: var(--tf-indigo-050); color: var(--tf-indigo-600); }
[data-theme="dark"] .app-nav-link.active { color: #b4b9ff; }
.app-nav-link.active::before {
  content: "";
  position: absolute;
  left: -0.7rem;
  top: 20%;
  bottom: 20%;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--tf-indigo);
}
.app-nav-link .badge { margin-left: auto; }

.app-sidebar-footer {
  border-top: 1px solid var(--tf-border);
  padding: 0.75rem;
  flex: 0 0 auto;
}

.app-main {
  margin-left: var(--tf-sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin 0.18s ease;
}

.app-navbar {
  height: var(--tf-navbar-height);
  background: color-mix(in srgb, var(--tf-surface) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--tf-border);
  position: sticky;
  top: 0;
  z-index: 1030;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0 1.25rem;
}

.app-content { padding: 1.5rem 1.25rem 3rem; flex: 1 1 auto; }
@media (min-width: 1400px) { .app-content { padding: 1.75rem 2rem 3rem; } }

/* Collapsed sidebar (desktop) */
body.sidebar-collapsed .app-sidebar { width: var(--tf-sidebar-collapsed); }
body.sidebar-collapsed .app-main { margin-left: var(--tf-sidebar-collapsed); }
body.sidebar-collapsed .app-brand-text,
body.sidebar-collapsed .app-nav-label,
body.sidebar-collapsed .app-nav-link span,
body.sidebar-collapsed .app-sidebar-footer .sidebar-user-text { display: none; }
body.sidebar-collapsed .app-nav-link { justify-content: center; }

@media (max-width: 991.98px) {
  .app-sidebar { transform: translateX(-100%); box-shadow: var(--tf-shadow-lg); }
  body.sidebar-open .app-sidebar { transform: translateX(0); }
  .app-main { margin-left: 0; }
  body.sidebar-collapsed .app-main { margin-left: 0; }
  .sidebar-scrim {
    position: fixed; inset: 0; background: rgba(10, 12, 20, 0.45);
    z-index: 1035; display: none;
  }
  body.sidebar-open .sidebar-scrim { display: block; }
}

/* --------------------------------------------------------------------------
   Navbar pieces
   -------------------------------------------------------------------------- */

.navbar-search { position: relative; max-width: 460px; flex: 1 1 auto; }
.navbar-search i {
  position: absolute; left: 0.85rem; top: 50%; transform: translateY(-50%);
  color: var(--tf-text-subtle); pointer-events: none;
}
.navbar-search input {
  padding-left: 2.35rem;
  background: var(--tf-surface-3);
  border: 1px solid transparent;
  border-radius: 999px;
  height: 38px;
  color: var(--tf-text);
}
.navbar-search input:focus {
  background: var(--tf-surface);
  border-color: var(--tf-indigo);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
.navbar-search kbd {
  position: absolute; right: 0.6rem; top: 50%; transform: translateY(-50%);
  font-size: 0.65rem; background: var(--tf-surface); border: 1px solid var(--tf-border);
  border-radius: 5px; padding: 1px 5px; color: var(--tf-text-subtle);
}

.icon-btn {
  width: 38px; height: 38px;
  display: inline-grid; place-items: center;
  border-radius: 50%;
  border: 1px solid transparent;
  background: transparent;
  color: var(--tf-text-muted);
  position: relative;
  transition: background 0.12s ease, color 0.12s ease;
}
.icon-btn:hover { background: var(--tf-surface-3); color: var(--tf-text); }
.icon-btn i { font-size: 1.1rem; }

.notif-dot {
  position: absolute; top: 4px; right: 4px;
  min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 999px; background: var(--tf-red); color: #fff;
  font-size: 0.62rem; font-weight: 700;
  display: grid; place-items: center;
  box-shadow: 0 0 0 2px var(--tf-surface);
}

.dropdown-menu {
  border: 1px solid var(--tf-border);
  border-radius: var(--tf-radius);
  box-shadow: var(--tf-shadow-lg);
  background: var(--tf-surface);
  padding: 0.4rem;
}
.dropdown-item {
  border-radius: var(--tf-radius-sm);
  padding: 0.5rem 0.65rem;
  color: var(--tf-text);
  font-weight: 500;
}
.dropdown-item:hover, .dropdown-item:focus { background: var(--tf-surface-3); color: var(--tf-text); }
.dropdown-header { color: var(--tf-text-subtle); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.07em; font-weight: 700; }
.dropdown-divider { border-color: var(--tf-border); }

.notif-dropdown { width: 380px; max-width: 92vw; padding: 0; }
.notif-list { max-height: 380px; overflow-y: auto; }
.notif-item {
  display: flex; gap: 0.7rem; padding: 0.7rem 0.9rem;
  border-bottom: 1px solid var(--tf-border);
  color: var(--tf-text);
}
.notif-item:last-child { border-bottom: 0; }
.notif-item:hover { background: var(--tf-surface-3); }
.notif-item.is-unread { background: var(--tf-indigo-050); }
.notif-item.is-unread:hover { background: color-mix(in srgb, var(--tf-indigo-050) 80%, var(--tf-surface)); }
.notif-icon {
  width: 34px; height: 34px; flex: 0 0 34px;
  border-radius: 10px; display: grid; place-items: center; font-size: 0.95rem;
}

/* --------------------------------------------------------------------------
   Cards & surfaces
   -------------------------------------------------------------------------- */

.card {
  background: var(--tf-surface);
  border: 1px solid var(--tf-border);
  border-radius: var(--tf-radius);
  box-shadow: var(--tf-shadow-xs);
}
.card-header {
  background: transparent;
  border-bottom: 1px solid var(--tf-border);
  padding: 0.9rem 1.1rem;
  font-weight: 650;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.card-header .card-title { margin: 0; font-size: 0.98rem; font-weight: 650; }
.card-body { padding: 1.1rem; }
.card-footer { background: transparent; border-top: 1px solid var(--tf-border); padding: 0.75rem 1.1rem; }

.card-hover { transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease; }
.card-hover:hover { transform: translateY(-2px); box-shadow: var(--tf-shadow); border-color: var(--tf-border-strong); }

.page-head { margin-bottom: 1.4rem; display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-start; }
.page-head h1 { font-size: 1.45rem; margin: 0; }
.page-head .page-sub { color: var(--tf-text-muted); font-size: 0.875rem; margin-top: 0.15rem; }
.page-head-actions { margin-left: auto; display: flex; gap: 0.5rem; flex-wrap: wrap; }

.breadcrumb { font-size: 0.8rem; margin-bottom: 0.35rem; }
.breadcrumb-item a { color: var(--tf-text-muted); }
.breadcrumb-item.active { color: var(--tf-text-subtle); }

/* Metric tiles */
.stat-tile {
  background: var(--tf-surface);
  border: 1px solid var(--tf-border);
  border-radius: var(--tf-radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--tf-shadow-xs);
  height: 100%;
  position: relative;
  overflow: hidden;
}
.stat-tile .stat-label {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.07em;
  font-weight: 700; color: var(--tf-text-subtle);
}
.stat-tile .stat-value { font-size: 1.85rem; font-weight: 700; line-height: 1.15; letter-spacing: -0.03em; }
.stat-tile .stat-meta { font-size: 0.75rem; color: var(--tf-text-muted); }
.stat-tile .stat-icon {
  position: absolute; top: 0.9rem; right: 0.9rem;
  width: 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center; font-size: 1rem;
}
.stat-tile.accent-primary { border-top: 3px solid var(--tf-indigo); }
.stat-tile.accent-success { border-top: 3px solid var(--tf-green); }
.stat-tile.accent-warning { border-top: 3px solid var(--tf-amber); }
.stat-tile.accent-danger { border-top: 3px solid var(--tf-red); }
.stat-tile.accent-info { border-top: 3px solid var(--tf-blue); }
.stat-tile.accent-purple { border-top: 3px solid var(--tf-purple); }

.soft-primary { background: rgba(99, 102, 241, 0.12); color: var(--tf-indigo-600); }
.soft-success { background: rgba(16, 185, 129, 0.13); color: #047857; }
.soft-warning { background: rgba(245, 158, 11, 0.15); color: #b45309; }
.soft-danger { background: rgba(239, 68, 68, 0.13); color: #b91c1c; }
.soft-info { background: rgba(14, 165, 233, 0.13); color: #0369a1; }
.soft-cyan { background: rgba(6, 182, 212, 0.13); color: #0e7490; }
.soft-purple { background: rgba(139, 92, 246, 0.13); color: #6d28d9; }
.soft-secondary, .soft-slate { background: rgba(100, 116, 139, 0.13); color: #475569; }
.soft-dark { background: rgba(30, 41, 59, 0.12); color: #1e293b; }
.soft-muted { background: rgba(148, 163, 184, 0.16); color: #64748b; }
[data-theme="dark"] [class^="soft-"], [data-theme="dark"] [class*=" soft-"] { color: #dbe1f5; }

/* --------------------------------------------------------------------------
   Badges
   -------------------------------------------------------------------------- */

.badge {
  font-weight: 600;
  font-size: 0.7rem;
  padding: 0.32em 0.66em;
  border-radius: 999px;
  letter-spacing: 0.005em;
  display: inline-flex;
  align-items: center;
  gap: 0.28em;
  vertical-align: middle;
}
.badge i { font-size: 0.85em; }

.badge-primary { background: rgba(99, 102, 241, 0.14); color: #4338ca; }
.badge-success { background: rgba(16, 185, 129, 0.15); color: #047857; }
.badge-warning { background: rgba(245, 158, 11, 0.17); color: #b45309; }
.badge-danger { background: rgba(239, 68, 68, 0.14); color: #b91c1c; }
.badge-info { background: rgba(14, 165, 233, 0.15); color: #0369a1; }
.badge-cyan { background: rgba(6, 182, 212, 0.15); color: #0e7490; }
.badge-purple { background: rgba(139, 92, 246, 0.15); color: #6d28d9; }
.badge-secondary, .badge-slate { background: rgba(100, 116, 139, 0.15); color: #475569; }
.badge-dark { background: rgba(30, 41, 59, 0.14); color: #0f172a; }
.badge-muted { background: rgba(148, 163, 184, 0.2); color: #64748b; }
[data-theme="dark"] .badge { color: #e4e8f6; }
[data-theme="dark"] .badge-primary { background: rgba(99, 102, 241, 0.28); }
[data-theme="dark"] .badge-success { background: rgba(16, 185, 129, 0.26); }
[data-theme="dark"] .badge-warning { background: rgba(245, 158, 11, 0.26); }
[data-theme="dark"] .badge-danger { background: rgba(239, 68, 68, 0.26); }
[data-theme="dark"] .badge-info { background: rgba(14, 165, 233, 0.26); }
[data-theme="dark"] .badge-cyan { background: rgba(6, 182, 212, 0.26); }
[data-theme="dark"] .badge-purple { background: rgba(139, 92, 246, 0.28); }
[data-theme="dark"] .badge-secondary, [data-theme="dark"] .badge-slate { background: rgba(148, 163, 184, 0.22); }
[data-theme="dark"] .badge-dark { background: rgba(226, 232, 240, 0.16); }

.badge-priority.priority-urgent { background: rgba(239, 68, 68, 0.14); color: #b91c1c; }
.badge-priority.priority-high { background: rgba(245, 158, 11, 0.17); color: #b45309; }
.badge-priority.priority-medium { background: rgba(14, 165, 233, 0.14); color: #0369a1; }
.badge-priority.priority-low { background: rgba(100, 116, 139, 0.14); color: #475569; }

.badge-severity { text-transform: uppercase; font-size: 0.63rem; letter-spacing: 0.05em; }
.badge-severity.severity-critical { background: rgba(239, 68, 68, 0.16); color: #991b1b; }
.badge-severity.severity-high { background: rgba(245, 158, 11, 0.18); color: #92400e; }
.badge-severity.severity-medium { background: rgba(14, 165, 233, 0.15); color: #075985; }
.badge-severity.severity-low { background: rgba(100, 116, 139, 0.15); color: #475569; }

.badge-type { background: var(--tf-surface-3); color: var(--tf-text-muted); }
.badge-type.type-bug, .badge-type.type-hotfix { background: rgba(239, 68, 68, 0.12); color: #b91c1c; }
.badge-type.type-feature { background: rgba(99, 102, 241, 0.12); color: #4338ca; }
.badge-type.type-story { background: rgba(16, 185, 129, 0.13); color: #047857; }
.badge-type.type-improvement { background: rgba(14, 165, 233, 0.13); color: #0369a1; }
.badge-type.type-epic { background: rgba(139, 92, 246, 0.14); color: #6d28d9; }

.badge-role.role-super-admin { background: linear-gradient(135deg, #6366f1, #a855f7); color: #fff; }
.badge-role.role-manager { background: rgba(14, 165, 233, 0.16); color: #0369a1; }
.badge-role.role-developer { background: rgba(16, 185, 129, 0.16); color: #047857; }
.badge-role.role-qa { background: rgba(6, 182, 212, 0.16); color: #0e7490; }
.badge-role.role-viewer { background: rgba(100, 116, 139, 0.16); color: #475569; }

.label-chip {
  display: inline-flex; align-items: center; gap: 0.3em;
  font-size: 0.7rem; font-weight: 600;
  padding: 0.22em 0.6em; border-radius: 6px;
  background: var(--tf-surface-3); color: var(--tf-text-muted);
  border: 1px solid var(--tf-border);
}
.label-chip::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--tf-slate);
}
.label-chip.c-rose::before { background: var(--tf-rose); }
.label-chip.c-purple::before { background: var(--tf-purple); }
.label-chip.c-amber::before { background: var(--tf-amber); }
.label-chip.c-green::before { background: var(--tf-green); }
.label-chip.c-blue::before { background: var(--tf-blue); }
.label-chip.c-teal::before { background: var(--tf-teal); }
.label-chip.c-indigo::before { background: var(--tf-indigo); }

/* Tag select (chip multi-select) */
.tag-select { position: relative; }

.tag-select-control {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  min-height: 42px;
  padding: 0.35rem 0.45rem;
  border: 1px solid var(--tf-border-strong);
  border-radius: var(--tf-radius-sm);
  background: var(--tf-surface);
  cursor: text;
}
.tag-select.is-open .tag-select-control {
  border-color: var(--tf-indigo);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.tag-select-input {
  flex: 1 1 90px;
  min-width: 90px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--tf-text);
  font-size: 0.85rem;
  padding: 0.15rem 0.2rem;
}
.tag-select-input::placeholder { color: var(--tf-text-subtle); }

.tag-chip { padding-right: 0.28em; gap: 0.35em; }
.tag-chip-remove {
  border: 0;
  background: transparent;
  color: inherit;
  opacity: 0.55;
  line-height: 1;
  font-size: 1rem;
  padding: 0 0.15em;
  border-radius: 4px;
}
.tag-chip-remove:hover { opacity: 1; background: rgba(0, 0, 0, 0.06); }

.tag-select-menu {
  position: absolute;
  z-index: 1050;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 232px;
  overflow-y: auto;
  padding: 0.3rem;
  background: var(--tf-surface);
  border: 1px solid var(--tf-border);
  border-radius: var(--tf-radius-sm);
  box-shadow: var(--tf-shadow);
}

.tag-select-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.4rem 0.5rem;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--tf-text);
  font-size: 0.83rem;
  font-weight: 550;
  text-align: left;
}
.tag-select-option:hover, .tag-select-option.is-active { background: var(--tf-surface-3); }
.tag-select-empty { padding: 0.5rem; font-size: 0.78rem; color: var(--tf-text-subtle); }

.tag-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--tf-slate); flex: 0 0 8px; }
.tag-dot.c-rose { background: var(--tf-rose); }
.tag-dot.c-purple { background: var(--tf-purple); }
.tag-dot.c-amber { background: var(--tf-amber); }
.tag-dot.c-green { background: var(--tf-green); }
.tag-dot.c-blue { background: var(--tf-blue); }
.tag-dot.c-teal { background: var(--tf-teal); }
.tag-dot.c-indigo { background: var(--tf-indigo); }

.key-chip {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72rem; font-weight: 650;
  color: var(--tf-text-muted);
  background: var(--tf-surface-3);
  border-radius: 6px;
  padding: 0.12em 0.42em;
}

/* --------------------------------------------------------------------------
   Avatars
   -------------------------------------------------------------------------- */

.avatar {
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  font-weight: 650;
  color: #fff;
  overflow: hidden;
  flex: 0 0 auto;
  object-fit: cover;
  position: relative;
  line-height: 1;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.avatar-xs { width: 22px; height: 22px; font-size: 0.6rem; }
.avatar-sm { width: 28px; height: 28px; font-size: 0.68rem; }
.avatar-md { width: 34px; height: 34px; font-size: 0.78rem; }
.avatar-lg { width: 48px; height: 48px; font-size: 1rem; }
.avatar-xl { width: 84px; height: 84px; font-size: 1.7rem; }

.avatar-c0 { background: linear-gradient(135deg, #6366f1, #8b5cf6); }
.avatar-c1 { background: linear-gradient(135deg, #0ea5e9, #06b6d4); }
.avatar-c2 { background: linear-gradient(135deg, #10b981, #14b8a6); }
.avatar-c3 { background: linear-gradient(135deg, #f59e0b, #f97316); }
.avatar-c4 { background: linear-gradient(135deg, #ef4444, #f43f5e); }
.avatar-c5 { background: linear-gradient(135deg, #8b5cf6, #d946ef); }
.avatar-c6 { background: linear-gradient(135deg, #14b8a6, #0ea5e9); }
.avatar-c7 { background: linear-gradient(135deg, #64748b, #475569); }

.avatar-stack { display: inline-flex; align-items: center; }
.avatar-stack .avatar { box-shadow: 0 0 0 2px var(--tf-surface); margin-left: -8px; }
.avatar-stack .avatar:first-child { margin-left: 0; }
.avatar-stack .avatar-more {
  background: var(--tf-surface-3); color: var(--tf-text-muted);
  font-size: 0.65rem; box-shadow: 0 0 0 2px var(--tf-surface);
}

.presence-dot {
  position: absolute; right: -1px; bottom: -1px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--tf-green); box-shadow: 0 0 0 2px var(--tf-surface);
}

/* --------------------------------------------------------------------------
   Buttons, forms, tables
   -------------------------------------------------------------------------- */

.btn { border-radius: var(--tf-radius-sm); font-weight: 600; font-size: 0.875rem; }
.btn-sm { border-radius: 8px; font-size: 0.8rem; }
.btn-primary {
  background: var(--tf-indigo); border-color: var(--tf-indigo);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.28);
}
.btn-primary:hover, .btn-primary:focus { background: var(--tf-indigo-600); border-color: var(--tf-indigo-600); }
.btn-outline-secondary {
  border-color: var(--tf-border-strong); color: var(--tf-text-muted); background: var(--tf-surface);
}
.btn-outline-secondary:hover { background: var(--tf-surface-3); color: var(--tf-text); border-color: var(--tf-border-strong); }
.btn-soft {
  background: var(--tf-surface-3); color: var(--tf-text-muted); border: 1px solid transparent;
}
.btn-soft:hover { background: var(--tf-border); color: var(--tf-text); }

.form-label { font-weight: 600; font-size: 0.8rem; color: var(--tf-text); margin-bottom: 0.3rem; }
.form-control, .form-select {
  border-radius: var(--tf-radius-sm);
  border: 1px solid var(--tf-border-strong);
  background: var(--tf-surface);
  color: var(--tf-text);
  font-size: 0.875rem;
  padding: 0.5rem 0.7rem;
}
.form-control::placeholder { color: var(--tf-text-subtle); }
.form-control:focus, .form-select:focus {
  border-color: var(--tf-indigo);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
  background: var(--tf-surface);
  color: var(--tf-text);
}
.form-text { font-size: 0.75rem; color: var(--tf-text-subtle); }
.form-check-input:checked { background-color: var(--tf-indigo); border-color: var(--tf-indigo); }
.input-group-text { background: var(--tf-surface-3); border-color: var(--tf-border-strong); color: var(--tf-text-muted); }

.form-section {
  border: 1px solid var(--tf-border);
  border-radius: var(--tf-radius);
  padding: 1.1rem;
  margin-bottom: 1.1rem;
  background: var(--tf-surface);
}
.form-section > h6 {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--tf-text-subtle); font-weight: 700; margin-bottom: 0.9rem;
}

.table { color: var(--tf-text); margin-bottom: 0; --bs-table-bg: transparent; }
.table > thead th {
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--tf-text-subtle); font-weight: 700;
  border-bottom: 1px solid var(--tf-border); padding: 0.6rem 0.85rem;
  background: var(--tf-surface-2); white-space: nowrap;
}
.table > tbody td { padding: 0.7rem 0.85rem; border-color: var(--tf-border); vertical-align: middle; }
.table-hover > tbody > tr:hover > * { background: var(--tf-surface-3); }
.table-flush { border-radius: var(--tf-radius); overflow: hidden; }

.progress { background: var(--tf-surface-3); border-radius: 999px; height: 7px; }
.progress-bar { background: var(--tf-indigo); border-radius: 999px; }

.alert { border: 1px solid var(--tf-border); border-radius: var(--tf-radius); font-size: 0.875rem; }
.alert-success { background: rgba(16, 185, 129, 0.1); border-color: rgba(16, 185, 129, 0.3); color: #065f46; }
.alert-danger { background: rgba(239, 68, 68, 0.1); border-color: rgba(239, 68, 68, 0.3); color: #991b1b; }
.alert-warning { background: rgba(245, 158, 11, 0.1); border-color: rgba(245, 158, 11, 0.3); color: #92400e; }
.alert-info { background: rgba(14, 165, 233, 0.1); border-color: rgba(14, 165, 233, 0.3); color: #075985; }
[data-theme="dark"] .alert { color: var(--tf-text); }

.toast-stack { position: fixed; top: calc(var(--tf-navbar-height) + 12px); right: 18px; z-index: 1080; width: 340px; max-width: 92vw; }

.modal-content { border: 1px solid var(--tf-border); border-radius: var(--tf-radius); background: var(--tf-surface); }
.modal-header, .modal-footer { border-color: var(--tf-border); }

.nav-tabs { border-bottom: 1px solid var(--tf-border); gap: 0.15rem; }
.nav-tabs .nav-link {
  border: 0; border-bottom: 2px solid transparent;
  color: var(--tf-text-muted); font-weight: 600; font-size: 0.875rem;
  padding: 0.6rem 0.9rem; border-radius: 0;
}
.nav-tabs .nav-link:hover { color: var(--tf-text); border-bottom-color: var(--tf-border-strong); }
.nav-tabs .nav-link.active {
  color: var(--tf-indigo-600); background: transparent; border-bottom-color: var(--tf-indigo);
}

.pagination { --bs-pagination-color: var(--tf-text-muted); }
.page-link {
  border-color: var(--tf-border); background: var(--tf-surface);
  color: var(--tf-text-muted); border-radius: 8px; margin: 0 2px; font-size: 0.85rem;
}
.page-item.active .page-link { background: var(--tf-indigo); border-color: var(--tf-indigo); color: #fff; }
.page-item.disabled .page-link { background: var(--tf-surface-2); color: var(--tf-text-subtle); }

/* --------------------------------------------------------------------------
   Filter bar
   -------------------------------------------------------------------------- */

.filter-bar {
  background: var(--tf-surface);
  border: 1px solid var(--tf-border);
  border-radius: var(--tf-radius);
  padding: 0.85rem 1rem;
  margin-bottom: 1.1rem;
  box-shadow: var(--tf-shadow-xs);
}
.filter-bar label { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--tf-text-subtle); margin-bottom: 0.2rem; }
.filter-bar .form-control, .filter-bar .form-select { font-size: 0.82rem; padding: 0.4rem 0.6rem; }

/* Auto-fitting grid: fields keep a legible minimum width and wrap instead of
   being squeezed until their labels and values clip. */
.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  gap: 0.6rem 0.7rem;
  align-items: end;
}
.filter-grid > .filter-actions {
  display: flex;
  gap: 0.5rem;
  grid-column: 1 / -1;
}
@media (min-width: 992px) {
  .filter-grid > .filter-actions { grid-column: auto; }
}
.filter-field { min-width: 0; }
.filter-field > label { display: block; }
.filter-field .form-control, .filter-field .form-select { width: 100%; }

/* Compact multi-select: fixed-height summary button + checkbox popover */
.check-dropdown { position: relative; }

.check-dropdown-toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  padding: 0.4rem 0.6rem;
  font-size: 0.82rem;
  text-align: left;
  color: var(--tf-text);
  background: var(--tf-surface);
  border: 1px solid var(--tf-border-strong);
  border-radius: var(--tf-radius-sm);
}
.check-dropdown-toggle > .truncate { flex: 1 1 auto; }
.check-dropdown-toggle > i { font-size: 0.7rem; color: var(--tf-text-subtle); flex: 0 0 auto; }
.check-dropdown-toggle:hover { border-color: var(--tf-slate); }
.check-dropdown.is-open .check-dropdown-toggle {
  border-color: var(--tf-indigo);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
.check-dropdown:not(.has-selection) .check-dropdown-toggle > .truncate { color: var(--tf-text-subtle); }
.check-dropdown.has-selection .check-dropdown-toggle {
  border-color: var(--tf-indigo);
  background: var(--tf-indigo-050);
  font-weight: 600;
}

.check-dropdown-menu {
  position: absolute;
  z-index: 1055;
  top: calc(100% + 4px);
  left: 0;
  min-width: 100%;
  width: max-content;
  max-width: 260px;
  padding: 0.4rem;
  background: var(--tf-surface);
  border: 1px solid var(--tf-border);
  border-radius: var(--tf-radius-sm);
  box-shadow: var(--tf-shadow);
}
.check-dropdown-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0 0.35rem 0.35rem;
  margin-bottom: 0.25rem;
  border-bottom: 1px solid var(--tf-border);
}
.check-dropdown-options { max-height: 244px; overflow-y: auto; }
.check-dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.32rem 0.4rem;
  border-radius: 7px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.check-dropdown-item:hover { background: var(--tf-surface-3); }
.check-dropdown-item input { margin: 0; flex: 0 0 auto; }
/* Auto-applying bar: dim the controls while the new query is in flight so a
   second change isn't made against stale results. */
.filter-bar.is-filtering { opacity: 0.65; pointer-events: none; }
.filter-busy { display: inline-flex; align-items: center; color: var(--tf-indigo); }
.filter-busy .spinner-border { width: 1rem; height: 1rem; border-width: 2px; }

.filter-chip {
  display: inline-flex; align-items: center; gap: 0.35rem;
  background: var(--tf-indigo-050); color: var(--tf-indigo-600);
  border-radius: 999px; padding: 0.2rem 0.6rem; font-size: 0.74rem; font-weight: 600;
}

.segmented {
  display: inline-flex; background: var(--tf-surface-3);
  border-radius: 999px; padding: 3px; gap: 2px;
}
.segmented a {
  padding: 0.32rem 0.85rem; border-radius: 999px;
  font-size: 0.8rem; font-weight: 600; color: var(--tf-text-muted);
}
.segmented a.active { background: var(--tf-surface); color: var(--tf-text); box-shadow: var(--tf-shadow-xs); }

/* --------------------------------------------------------------------------
   Kanban board
   -------------------------------------------------------------------------- */

.board-wrap {
  display: flex;
  gap: 0.85rem;
  overflow-x: auto;
  padding-bottom: 1.2rem;
  align-items: flex-start;
  scroll-snap-type: x proximity;
}

.board-column {
  flex: 0 0 302px;
  max-width: 302px;
  background: var(--tf-surface-2);
  border: 1px solid var(--tf-border);
  border-radius: var(--tf-radius);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - var(--tf-navbar-height) - 130px);
  scroll-snap-align: start;
}
.board-column.is-over { border-color: var(--tf-indigo); background: var(--tf-indigo-050); }

.board-column-head {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.7rem 0.85rem;
  border-bottom: 1px solid var(--tf-border);
  font-size: 0.78rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--tf-text-muted);
  position: sticky; top: 0;
  background: var(--tf-surface-2);
  border-radius: var(--tf-radius) var(--tf-radius) 0 0;
  z-index: 2;
}
.board-column-head .count {
  margin-left: auto; background: var(--tf-surface-3); color: var(--tf-text-muted);
  border-radius: 999px; padding: 0.05rem 0.45rem; font-size: 0.7rem;
}

.board-column-body {
  padding: 0.6rem;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 90px;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.board-column-foot { padding: 0.5rem 0.6rem 0.6rem; }

.task-card {
  background: var(--tf-surface);
  border: 1px solid var(--tf-border);
  border-radius: var(--tf-radius-sm);
  padding: 0.7rem 0.75rem;
  box-shadow: var(--tf-shadow-xs);
  display: block;
  color: var(--tf-text);
  cursor: grab;
  transition: box-shadow 0.14s ease, transform 0.14s ease, border-color 0.14s ease;
  border-left: 3px solid var(--tf-border-strong);
}
.task-card:hover { box-shadow: var(--tf-shadow-sm); border-color: var(--tf-border-strong); transform: translateY(-1px); color: var(--tf-text); }
.task-card.dragging { opacity: 0.45; transform: rotate(1.2deg) scale(0.99); cursor: grabbing; }
.task-card.pulse { animation: tf-pulse 0.7s ease; }
@keyframes tf-pulse {
  0% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.5); }
  100% { box-shadow: 0 0 0 12px rgba(99, 102, 241, 0); }
}

.task-card.p-urgent { border-left-color: var(--tf-red); }
.task-card.p-high { border-left-color: var(--tf-amber); }
.task-card.p-medium { border-left-color: var(--tf-blue); }
.task-card.p-low { border-left-color: var(--tf-slate); }

.task-card-title { font-size: 0.86rem; font-weight: 600; line-height: 1.35; margin: 0.35rem 0 0.5rem; }
.task-card-meta { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; font-size: 0.72rem; color: var(--tf-text-subtle); }
.task-card-foot { display: flex; align-items: center; gap: 0.45rem; margin-top: 0.55rem; }

.drop-placeholder {
  border: 2px dashed var(--tf-indigo);
  border-radius: var(--tf-radius-sm);
  height: 60px;
  background: rgba(99, 102, 241, 0.06);
}

/* --------------------------------------------------------------------------
   Task detail
   -------------------------------------------------------------------------- */

.detail-key { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--tf-text-subtle); font-weight: 650; }
.detail-title { font-size: 1.35rem; line-height: 1.3; }

.pipeline {
  display: flex; align-items: center; gap: 2px; flex-wrap: wrap;
  padding: 0.5rem 0; font-size: 0.68rem;
}
.pipeline-step {
  padding: 0.2rem 0.6rem; border-radius: 999px;
  background: var(--tf-surface-3); color: var(--tf-text-subtle); font-weight: 600;
  white-space: nowrap;
}
.pipeline-step.done { background: rgba(16, 185, 129, 0.14); color: #047857; }
.pipeline-step.current { background: var(--tf-indigo); color: #fff; box-shadow: 0 2px 8px rgba(99, 102, 241, 0.35); }

.prose { font-size: 0.9rem; line-height: 1.65; white-space: pre-wrap; word-wrap: break-word; color: var(--tf-text); }
.prose:empty::after { content: "No description provided."; color: var(--tf-text-subtle); font-style: italic; }
.mention { background: var(--tf-indigo-050); color: var(--tf-indigo-600); border-radius: 5px; padding: 0 3px; font-weight: 600; }

.field-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0.9rem 1.2rem; }
.field-item .field-label {
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.07em;
  font-weight: 700; color: var(--tf-text-subtle); margin-bottom: 0.2rem;
}
.field-item .field-value { font-size: 0.86rem; font-weight: 550; }

.repro-block {
  background: var(--tf-surface-2);
  border: 1px solid var(--tf-border);
  border-left: 3px solid var(--tf-red);
  border-radius: var(--tf-radius-sm);
  padding: 0.75rem 0.9rem;
  font-size: 0.85rem;
  white-space: pre-wrap;
  line-height: 1.6;
}

/* Timeline */
.timeline { position: relative; padding-left: 1.6rem; }
.timeline::before {
  content: ""; position: absolute; left: 0.52rem; top: 0.4rem; bottom: 0.4rem;
  width: 2px; background: var(--tf-border);
}
.timeline-item { position: relative; padding-bottom: 1.05rem; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-dot {
  position: absolute; left: -1.6rem; top: 0.05rem;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--tf-surface); border: 1px solid var(--tf-border);
  display: grid; place-items: center; font-size: 0.65rem; color: var(--tf-text-muted);
}
.timeline-body { font-size: 0.82rem; }
.timeline-body .actor { font-weight: 650; }
.timeline-time { font-size: 0.72rem; color: var(--tf-text-subtle); }

/* Comments */
.comment {
  display: flex; gap: 0.75rem; padding: 0.85rem 0;
  border-bottom: 1px solid var(--tf-border);
}
.comment:last-child { border-bottom: 0; }
.comment-body-wrap { flex: 1 1 auto; min-width: 0; }
.comment-head { display: flex; align-items: center; gap: 0.45rem; flex-wrap: wrap; font-size: 0.8rem; }
.comment-text { font-size: 0.875rem; line-height: 1.6; white-space: pre-wrap; margin-top: 0.25rem; word-wrap: break-word; }
.comment-actions { display: flex; gap: 0.6rem; margin-top: 0.4rem; font-size: 0.74rem; }
.comment-actions button, .comment-actions a {
  background: none; border: 0; padding: 0; color: var(--tf-text-subtle); font-weight: 600;
}
.comment-actions button:hover, .comment-actions a:hover { color: var(--tf-indigo-600); }
.comment.is-pinned {
  background: rgba(245, 158, 11, 0.06);
  border-left: 3px solid var(--tf-amber);
  border-radius: var(--tf-radius-sm);
  padding-left: 0.75rem;
}
.comment-replies { margin-top: 0.8rem; padding-left: 1rem; border-left: 2px solid var(--tf-border); }

/* Attachments & video */
.attachment-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 0.8rem; }
.attachment-tile {
  border: 1px solid var(--tf-border); border-radius: var(--tf-radius-sm);
  overflow: hidden; background: var(--tf-surface); position: relative;
}
.attachment-tile .thumb {
  height: 110px; display: grid; place-items: center;
  background: var(--tf-surface-3); overflow: hidden; font-size: 1.8rem; color: var(--tf-text-subtle);
}
.attachment-tile .thumb img { width: 100%; height: 100%; object-fit: cover; }
.attachment-tile .meta { padding: 0.55rem 0.65rem; font-size: 0.75rem; }
.attachment-tile .meta .name { font-weight: 650; word-break: break-all; }

.video-card { border: 1px solid var(--tf-border); border-radius: var(--tf-radius); overflow: hidden; background: var(--tf-surface); }
.video-card video { width: 100%; display: block; background: #000; max-height: 340px; }

.dropzone {
  border: 2px dashed var(--tf-border-strong);
  border-radius: var(--tf-radius);
  padding: 1.25rem;
  text-align: center;
  color: var(--tf-text-muted);
  background: var(--tf-surface-2);
  transition: border-color 0.14s ease, background 0.14s ease;
}
.dropzone.is-dragover { border-color: var(--tf-indigo); background: var(--tf-indigo-050); }

/* --------------------------------------------------------------------------
   Empty states, auth, misc
   -------------------------------------------------------------------------- */

.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--tf-text-muted); }
.empty-state .empty-icon {
  width: 56px; height: 56px; border-radius: 16px;
  background: var(--tf-surface-3); color: var(--tf-text-subtle);
  display: grid; place-items: center; font-size: 1.5rem; margin: 0 auto 0.9rem;
}
.empty-state h6 { color: var(--tf-text); font-size: 0.95rem; }

.auth-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr;
  background: var(--tf-bg);
}
@media (min-width: 992px) { .auth-page { grid-template-columns: 1.05fr 1fr; } }
.auth-aside {
  display: none;
  padding: 3rem;
  color: #fff;
  background:
    radial-gradient(900px 500px at 15% 20%, rgba(255, 255, 255, 0.16), transparent 60%),
    linear-gradient(135deg, #4f46e5 0%, #6366f1 45%, #a855f7 100%);
  flex-direction: column;
  justify-content: center;
}
@media (min-width: 992px) { .auth-aside { display: flex; } }
.auth-aside h2 { color: #fff; font-size: 2rem; letter-spacing: -0.03em; }
.auth-aside ul { list-style: none; padding: 0; margin: 1.6rem 0 0; }
.auth-aside li { display: flex; gap: 0.7rem; align-items: flex-start; margin-bottom: 0.85rem; opacity: 0.95; }
.auth-form-wrap { display: grid; place-items: center; padding: 2rem 1.25rem; }
.auth-card { width: 100%; max-width: 420px; }

.project-icon {
  width: 42px; height: 42px; border-radius: 12px;
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 1rem;
  flex: 0 0 auto; overflow: hidden;
}
.project-icon img { width: 100%; height: 100%; object-fit: cover; }
.pc-indigo { background: linear-gradient(135deg, #6366f1, #8b5cf6); }
.pc-blue { background: linear-gradient(135deg, #0ea5e9, #3b82f6); }
.pc-teal { background: linear-gradient(135deg, #14b8a6, #0ea5e9); }
.pc-green { background: linear-gradient(135deg, #10b981, #22c55e); }
.pc-amber { background: linear-gradient(135deg, #f59e0b, #f97316); }
.pc-rose { background: linear-gradient(135deg, #f43f5e, #ec4899); }
.pc-purple { background: linear-gradient(135deg, #8b5cf6, #d946ef); }
.pc-slate { background: linear-gradient(135deg, #64748b, #475569); }

.chart-wrap { position: relative; height: 260px; }
.chart-wrap.tall { height: 320px; }
.chart-wrap.short { height: 190px; }

.list-row {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.6rem 0; border-bottom: 1px solid var(--tf-border);
  color: var(--tf-text);
}
.list-row:last-child { border-bottom: 0; }
.list-row:hover { color: var(--tf-text); }
.list-row .grow { flex: 1 1 auto; min-width: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.meter { height: 6px; background: var(--tf-surface-3); border-radius: 999px; overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 999px; background: var(--tf-indigo); }

.sticky-side { position: sticky; top: calc(var(--tf-navbar-height) + 1rem); }

.error-page { min-height: 70vh; display: grid; place-items: center; text-align: center; }
.error-code { font-size: 4.5rem; font-weight: 750; letter-spacing: -0.05em; color: var(--tf-indigo); line-height: 1; }

/* Print — reports go straight to PDF */
@media print {
  .app-sidebar, .app-navbar, .page-head-actions, .filter-bar, .no-print { display: none !important; }
  .app-main { margin-left: 0; }
  .card { box-shadow: none; break-inside: avoid; }
}
