/* ==========================================================================
   MICRODOSE STUDIO / LINEAR STYLE TIMELINE ROADMAP
   Inspired by Kamil Bachanek for Microdose Studio (Dribbble)
   ========================================================================== */

:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Neutrals & Surfaces */
  --bg-page: #F4F5F7;
  --bg-surface: #FFFFFF;
  --bg-surface-subtle: #F9FAFB;
  --bg-surface-muted: #F3F4F6;

  --border-light: #F1F2F4;
  --border-subtle: #E5E7EB;
  --border-strong: #D1D5DB;

  /* Typography Colors */
  --text-main: #111827;
  --text-secondary: #4B5563;
  --text-muted: #6B7280;
  --text-subtle: #9CA3AF;
  --text-inverse: #FFFFFF;

  /* Signature Accents & Gradients */
  --primary-indigo: #4F46E5;
  --primary-purple: #9333EA;
  --primary-pink: #F43F5E;
  --gradient-featured: linear-gradient(135deg, #5B5BF7 0%, #D960B8 52%, #F39E60 100%);
  --gradient-glow: 0 8px 24px -4px rgba(91, 91, 247, 0.4);

  /* Elevation Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-card: 0 2px 10px rgba(0, 0, 0, 0.04);
  --shadow-elevated: 0 10px 30px -5px rgba(0, 0, 0, 0.08);
  --shadow-popover: 0 12px 36px -4px rgba(0, 0, 0, 0.12);

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --radius-2xl: 24px;
  --radius-full: 9999px;

  --sidebar-w: 236px;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font-sans);
  background-color: var(--bg-page);
  color: var(--text-main);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Accessibility Skip Link */
.skip-link {
  position: absolute;
  top: -40px;
  left: 1rem;
  background: var(--text-main);
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  z-index: 1000;
  text-decoration: none;
  font-weight: 600;
  transition: top 150ms ease;
}
.skip-link:focus {
  top: 1rem;
}

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

/* ==========================================================================
   APP SHELL / LAYOUT (Rounded Master Container)
   ========================================================================== */
.app-layout {
  display: flex;
  min-height: 100vh;
  background-color: var(--bg-page);
  padding: 12px;
  gap: 12px;
}

/* Sidebar */
.app-sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  padding: 1.125rem 0.875rem 1rem;
  flex-shrink: 0;
  transition: margin-left 220ms cubic-bezier(0.4, 0, 0.2, 1);
}

.app-sidebar.is-collapsed {
  margin-left: calc(-1 * (var(--sidebar-w) + 16px));
}

.sidebar-header {
  padding: 0 0.375rem 1rem;
  border-bottom: 1px solid var(--border-light);
}

.workspace-badge {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.workspace-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #111827 0%, #374151 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.workspace-avatar-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4F46E5, #F43F5E);
}

.workspace-info {
  display: flex;
  flex-direction: column;
}

.workspace-name {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

.workspace-tag {
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text-muted);
}

.workspace-domain {
  font-size: 0.75rem;
  color: var(--text-subtle);
  line-height: 1.2;
}

/* Nav Lists */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding-top: 1rem;
  flex: 1 1 auto;
}

.nav-section-title {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-subtle);
  padding: 0 0.5rem 0.375rem;
}

.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.4375rem 0.625rem;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-weight: 500;
  text-decoration: none;
  transition: all 120ms ease;
}

.nav-item:hover {
  background-color: var(--bg-surface-muted);
  color: var(--text-main);
}

.nav-item.is-active {
  background-color: var(--bg-surface-muted);
  color: var(--text-main);
  font-weight: 600;
}

.nav-item.is-active .nav-icon {
  color: var(--primary-indigo);
}

.nav-item .nav-icon {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.nav-item:hover .nav-icon {
  color: var(--text-main);
}

.nav-badge {
  margin-left: auto;
  background-color: #EF4444;
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 700;
  padding: 0.0625rem 0.375rem;
  border-radius: var(--radius-full);
}

.nav-chevron {
  width: 14px;
  height: 14px;
  margin-left: auto;
  color: var(--text-subtle);
}

.nav-sublist {
  list-style: none;
  margin: 2px 0 0;
  padding: 0 0 0 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-subitem {
  font-size: 0.8125rem;
  padding: 0.375rem 0.625rem;
}

.nav-subdot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background-color: var(--text-subtle);
}

.nav-subitem.is-active {
  background-color: var(--bg-surface-muted);
  color: var(--text-main);
  font-weight: 600;
}

.nav-subitem.is-active .nav-subdot {
  background-color: var(--primary-indigo);
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.2);
}

/* Sidebar Footer & User Profile */
.sidebar-footer {
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.user-profile-card {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem;
  border-radius: var(--radius-lg);
  background-color: var(--bg-surface-subtle);
}

.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366F1, #EC4899);
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-details {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.user-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.2;
}

.user-role {
  font-size: 0.6875rem;
  color: var(--text-muted);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==========================================================================
   MAIN APP WORKSPACE
   ========================================================================== */
.app-main {
  flex: 1 1 auto;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* Topbar */
.main-topbar {
  height: 58px;
  padding: 0 1.5rem;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-shrink: 0;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.btn-sidebar-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background-color: var(--bg-surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 120ms ease;
}

.btn-sidebar-toggle:hover {
  background-color: var(--bg-surface-muted);
  color: var(--text-main);
}

.btn-sidebar-toggle .lucide {
  width: 16px;
  height: 16px;
}

.breadcrumb-trail {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.breadcrumb-sep {
  color: var(--text-subtle);
}

.breadcrumb-current {
  color: var(--text-main);
  font-weight: 600;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Modern Search Box */
.search-box-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 240px;
}

.search-box-wrap .search-box-icon {
  position: absolute;
  left: 0.75rem;
  width: 15px;
  height: 15px;
  color: var(--text-subtle);
  pointer-events: none;
}

.search-box-wrap input[type="search"] {
  width: 100%;
  height: 36px;
  padding: 0 2.25rem 0 2.125rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-surface-subtle);
  font-family: inherit;
  font-size: 0.8125rem;
  color: var(--text-main);
  outline: none;
  transition: all 120ms ease;
}

.search-box-wrap input[type="search"]:focus {
  background-color: var(--bg-surface);
  border-color: var(--primary-indigo);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.search-kbd {
  position: absolute;
  right: 0.625rem;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text-subtle);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  padding: 0.0625rem 0.3125rem;
  border-radius: 4px;
  pointer-events: none;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Button Variants */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: all 120ms ease;
}

.btn-ghost {
  height: 36px;
  padding: 0 0.75rem;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background-color: var(--bg-surface-muted);
  color: var(--text-main);
}

.btn-ghost .lucide {
  width: 15px;
  height: 15px;
}

.btn-ghost-pill {
  height: 34px;
  padding: 0 0.875rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-surface);
  color: var(--text-main);
}

.btn-ghost-pill:hover {
  background-color: var(--bg-surface-subtle);
  border-color: var(--border-strong);
}

.btn-ghost-pill .lucide {
  width: 14px;
  height: 14px;
  color: var(--text-muted);
}

/* Signature Solid Dark Pill Button (+ Project) */
.btn-dark-pill {
  height: 36px;
  padding: 0 1.125rem;
  border-radius: var(--radius-full);
  background-color: #111827;
  color: #FFFFFF;
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.btn-dark-pill:hover {
  background-color: #000000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
  transform: translateY(-1px);
}

.btn-dark-pill:active {
  transform: translateY(0);
}

.btn-dark-pill .lucide {
  width: 15px;
  height: 15px;
}

/* ==========================================================================
   TIMELINE HERO SECTION
   ========================================================================== */
.timeline-hero {
  padding: 1.25rem 1.75rem 1rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  flex-shrink: 0;
}

.hero-left {
  max-width: 680px;
}

.hero-title {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text-main);
  line-height: 1.2;
}

.hero-desc {
  margin: 0.375rem 0 0;
  font-size: 0.84rem;
  line-height: 1.45;
  color: var(--text-muted);
}

.hero-right {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  flex-shrink: 0;
}

/* Team Avatar Stack */
.team-avatar-stack {
  display: flex;
  align-items: center;
}

.team-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6875rem;
  font-weight: 700;
  margin-left: -7px;
  cursor: default;
  transition: transform 120ms ease;
}

.team-avatar:first-child {
  margin-left: 0;
}

.team-avatar:hover {
  transform: translateY(-2px);
  z-index: 10;
}

.team-avatar.av-1 { background-color: #EEF2FF; color: #4F46E5; }
.team-avatar.av-2 { background-color: #FEF3C7; color: #D97706; }
.team-avatar.av-3 { background-color: #ECFDF5; color: #059669; }
.team-avatar.av-4 { background-color: #FCE7F3; color: #DB2777; }

.team-avatar-more {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--bg-surface);
  background-color: var(--bg-surface-muted);
  color: var(--text-muted);
  font-size: 0.6875rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: -7px;
}

/* iOS Style Switch */
.toggle-control {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
}

.toggle-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.toggle-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle-switch {
  width: 36px;
  height: 20px;
  border-radius: var(--radius-full);
  background-color: var(--border-strong);
  position: relative;
  transition: background-color 150ms ease;
}

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background-color: #FFFFFF;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: transform 150ms ease;
}

.toggle-control input:checked + .toggle-switch {
  background-color: #111827;
}

.toggle-control input:checked + .toggle-switch::after {
  transform: translateX(16px);
}

/* Popover Anchors */
.popover-anchor {
  position: relative;
}

.dropdown-popover {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 60;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-popover);
  padding: 0.875rem 1rem;
  min-width: 240px;
  animation: popoverFade 120ms ease;
}

@keyframes popoverFade {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.popover-header {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text-main);
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.btn-text-action {
  background: transparent;
  border: none;
  color: var(--primary-indigo);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}

.popover-body {
  padding-top: 0.625rem;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.popover-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.modern-select {
  width: 100%;
  height: 34px;
  padding: 0 0.625rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-surface);
  font-family: inherit;
  font-size: 0.8125rem;
  color: var(--text-main);
  outline: none;
}

.modern-select:focus {
  border-color: var(--primary-indigo);
}

.btn-ghost-sm {
  width: 100%;
  height: 32px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-surface-subtle);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-main);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  cursor: pointer;
}

.btn-ghost-sm:hover {
  background-color: var(--bg-surface-muted);
}

.filter-active-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--primary-indigo);
  margin-left: 0.125rem;
}

/* ==========================================================================
   SECONDARY TIMELINE TOOLBAR (Segmented Tabs & Stepper)
   ========================================================================== */
.timeline-toolbar {
  padding: 0.625rem 1.75rem 0.875rem;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-shrink: 0;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Segmented Pill Tabs */
.segmented-control {
  display: inline-flex;
  align-items: center;
  background-color: var(--bg-surface-muted);
  border-radius: var(--radius-full);
  padding: 3px;
  gap: 2px;
}

.segmented-tab {
  border: none;
  background: transparent;
  padding: 0.3125rem 0.875rem;
  border-radius: var(--radius-full);
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 120ms ease;
  user-select: none;
}

.segmented-tab:hover {
  color: var(--text-main);
}

.segmented-tab.is-active {
  background-color: #FFFFFF;
  color: var(--text-main);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* Date Range Stepper */
.date-stepper-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 0.1875rem 0.5rem;
}

.btn-stepper-nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  border-radius: 50%;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 100ms ease;
}

.btn-stepper-nav:hover {
  background-color: var(--bg-surface-muted);
  color: var(--text-main);
}

.btn-stepper-nav .lucide {
  width: 14px;
  height: 14px;
}

.stepper-range-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3125rem;
  padding: 0.1875rem 0.5rem;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  transition: background-color 120ms ease;
}

.stepper-range-btn:hover {
  background-color: var(--bg-surface-muted);
}

.stepper-caret {
  width: 13px;
  height: 13px;
  color: var(--text-muted);
}

.date-picker-popover {
  min-width: 300px;
  max-width: 330px;
}

.week-year-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  padding-bottom: 0.375rem;
  border-bottom: 1px solid var(--border-light);
}

.week-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
  max-height: 200px;
  overflow-y: auto;
  padding: 2px;
}

.week-btn {
  height: 30px;
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-surface);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  transition: all 100ms ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.week-btn:hover {
  background-color: var(--bg-surface-muted);
  border-color: var(--border-strong);
}

.week-btn.is-active {
  background-color: #111827;
  border-color: #111827;
  color: #FFFFFF;
}

.week-preview-text {
  font-size: 0.6875rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 0.5rem;
  padding-top: 0.375rem;
  border-top: 1px dashed var(--border-light);
  min-height: 20px;
}

.picker-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.375rem;
  margin-top: 0.25rem;
}

.picker-grid-2 {
  grid-template-columns: repeat(2, 1fr);
}

.picker-btn {
  height: 34px;
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-surface);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  transition: all 120ms ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.picker-btn:hover {
  background-color: var(--bg-surface-muted);
  border-color: var(--border-strong);
}

.picker-btn.is-active {
  background-color: #111827;
  border-color: #111827;
  color: #FFFFFF;
}

.picker-custom-row {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border-light);
}

.picker-custom-row input[type="date"] {
  height: 34px;
  font-size: 0.8125rem;
}

/* Today Button with Pulsing Dot */
.btn-today-jump {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
}

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--primary-indigo);
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.2);
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.project-stat-badge {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  background-color: var(--bg-surface-subtle);
  border: 1px solid var(--border-subtle);
  padding: 0.25rem 0.625rem;
  border-radius: var(--radius-full);
}

/* ==========================================================================
   TIMELINE CANVAS & CALENDAR RULER
   ========================================================================== */
.timeline-viewport {
  flex: 1 1 auto;
  overflow-x: auto;
  overflow-y: auto;
  background-color: #FFFFFF;
  position: relative;
}

.timeline-canvas {
  position: relative;
  min-width: 100%;
}

/* Calendar Ruler Row */
.calendar-ruler-row {
  display: flex;
  border-bottom: 1px solid var(--border-light);
  background-color: #FAFAFA;
  position: sticky;
  top: 0;
  z-index: 25;
}

.ruler-sidebar-cell {
  position: sticky;
  left: 0;
  z-index: 30;
  width: 180px;
  min-width: 180px;
  background-color: #FAFAFA;
  border-right: 1px solid var(--border-light);
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
}

.ruler-sidebar-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-subtle);
}

.calendar-ruler-track {
  position: relative;
  height: 52px;
  flex-grow: 1;
}

.calendar-tick {
  position: absolute;
  top: 0;
  bottom: 0;
  border-left: 1px solid var(--border-light);
  padding: 0.375rem 0.5rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  pointer-events: none;
}

.calendar-tick-major {
  border-left: 1.5px solid var(--border-subtle);
}

.calendar-tick-label {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  line-height: 1.2;
}

.calendar-tick-sub {
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  line-height: 1.2;
}

/* Today Indicator Line & Pin */
.today-marker {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background-color: var(--primary-indigo);
  z-index: 15;
  pointer-events: none;
}

.calendar-ruler-track .today-marker {
  z-index: 28;
}

.today-marker-badge {
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--primary-indigo);
  color: #FFFFFF;
  font-size: 0.6875rem;
  font-weight: 700;
  padding: 0.125rem 0.5rem;
  border-radius: var(--radius-full);
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.4);
  pointer-events: auto;
  cursor: default;
}

/* ==========================================================================
   TRACK SWIMLANES & LANES
   ========================================================================== */
.track-section {
  border-bottom: 1px solid var(--border-light);
}

.track-section:last-child {
  border-bottom: none;
}

.track-body {
  display: flex;
  align-items: stretch;
}

.track-sticky-sidebar {
  position: sticky;
  left: 0;
  z-index: 20;
  width: 180px;
  min-width: 180px;
  background-color: #FFFFFF;
  border-right: 1px solid var(--border-light);
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  flex-shrink: 0;
}

.track-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-track-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: var(--text-subtle);
  cursor: pointer;
  transition: transform 150ms ease;
}

.btn-track-toggle:hover {
  background-color: var(--bg-surface-muted);
  color: var(--text-main);
}

.btn-track-toggle .lucide {
  width: 14px;
  height: 14px;
}

.track-section.is-collapsed .btn-track-toggle {
  transform: rotate(-90deg);
}

.track-badge-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.track-badge-main { background-color: var(--primary-indigo); }
.track-badge-fast { background-color: #0284C7; }

.track-sticky-sidebar h2 {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
}

.track-counter-pill {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-muted);
  background-color: var(--bg-surface-muted);
  padding: 0.0625rem 0.375rem;
  border-radius: var(--radius-full);
  margin-left: auto;
}

.track-section.is-collapsed .track-lanes {
  display: none;
}

.track-section.is-collapsed .track-sticky-sidebar {
  padding: 0.625rem 1.25rem;
}

.track-lanes {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.lane-row {
  position: relative;
  min-height: 72px;
  border-bottom: 1px solid #F9FAFB;
  display: flex;
  align-items: center;
  background-image: linear-gradient(to right, rgba(0, 0, 0, 0.025) 1px, transparent 1px);
  transition: background-color 120ms ease;
}

.lane-row:hover {
  background-color: rgba(91, 91, 247, 0.02);
}

.lane-row:last-child {
  border-bottom: none;
}

/* ==========================================================================
   MICRODOSE FLOATING CARDS (THE HERO ELEMENT)
   ========================================================================== */
.timeline-card {
  position: absolute;
  min-height: 52px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0.875rem;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  border: 1px solid var(--border-subtle);
  background-color: #FFFFFF;
  box-shadow: var(--shadow-card);
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
  overflow: hidden;
  user-select: none;
}

.timeline-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-elevated);
  z-index: 20;
}

.timeline-card:focus-visible {
  outline: 2px solid var(--primary-indigo);
  outline-offset: 2px;
  z-index: 25;
}

/* Left Section: Title & Subtitle */
.card-content-left {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1 1 auto;
  will-change: transform;
}

.card-content-left.is-stuck {
  border-left: 3px solid var(--card-status-color, #6366F1);
  padding-left: 8px;
  border-radius: 1px;
}

.card-title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.25;
}

.card-subtext {
  font-size: 0.6875rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: 2px;
  line-height: 1.2;
}

/* Right Section: Avatars & Menu */
.card-content-right {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
  margin-left: auto;
}

.card-avatars {
  display: flex;
  align-items: center;
}

.card-dev-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.5625rem;
  font-weight: 700;
  margin-left: -5px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.card-dev-avatar:first-child {
  margin-left: 0;
}

.card-menu-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border: none;
  background: transparent;
  color: var(--text-subtle);
  border-radius: 4px;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 120ms ease;
}

.timeline-card:hover .card-menu-btn {
  opacity: 1;
  color: inherit;
}

.card-menu-btn .lucide {
  width: 13px;
  height: 13px;
}

/* Consistent Modern Card Styling for All Statuses */
.timeline-card.status-started {
  border-left: 3px solid #6366F1;
  --card-status-color: #6366F1;
}

.timeline-card.status-planned,
.timeline-card.status-new {
  border-left: 3px solid #3B82F6;
  --card-status-color: #3B82F6;
}

.timeline-card.status-testing,
.timeline-card.status-rolling-out {
  border-left: 3px solid #10B981;
  --card-status-color: #10B981;
}

.timeline-card.status-evaluate {
  border-left: 3px solid #F59E0B;
  --card-status-color: #F59E0B;
}

.timeline-card.status-on-hold {
  border-left: 3px solid #F43F5E;
  --card-status-color: #F43F5E;
}

.timeline-card.status-archived,
.timeline-card.status-finished {
  background-color: #FAFAFA;
  border-color: #E5E7EB;
  border-left: 3px solid #9CA3AF;
  --card-status-color: #9CA3AF;
  opacity: 0.85;
}

/* Adaptive Compact Card for Narrow Widths (< 180px) */
.timeline-card.is-narrow {
  padding: 0.3125rem 0.5rem;
}

.timeline-card.is-narrow .card-subtext {
  display: none;
}

.timeline-card.is-narrow .card-menu-btn {
  display: none;
}

/* ==========================================================================
   RICH FLOATING TOOLTIP
   ========================================================================== */
.roadmap-tooltip {
  position: fixed;
  z-index: 1000;
  width: 320px;
  max-width: calc(100vw - 2rem);
  background-color: #FFFFFF;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-popover);
  padding: 0.875rem 1rem;
  pointer-events: none;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 140ms ease, transform 140ms ease;
  color: var(--text-main);
  font-size: 0.8125rem;
  line-height: 1.4;
}

.roadmap-tooltip.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.tooltip-title {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0 0 0.375rem;
  line-height: 1.3;
}

.tooltip-badges {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.tooltip-chip {
  font-size: 0.6875rem;
  font-weight: 700;
  padding: 0.125rem 0.5rem;
  border-radius: var(--radius-full);
  background-color: var(--bg-surface-muted);
  color: var(--text-main);
}

.tooltip-grid {
  display: flex;
  flex-direction: column;
  gap: 0.3125rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border-light);
}

.tooltip-row {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.tooltip-label {
  color: var(--text-muted);
  font-weight: 500;
}

.tooltip-value {
  color: var(--text-main);
  font-weight: 600;
  text-align: right;
}

.tooltip-desc {
  margin: 0.5rem 0 0;
  padding-top: 0.375rem;
  border-top: 1px dashed var(--border-light);
  color: var(--text-secondary);
  font-style: italic;
}

/* ==========================================================================
   MODAL DIALOG (PROJECT CREATE / EDIT)
   ========================================================================== */
dialog#project-dialog {
  width: min(640px, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  padding: 0;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-2xl);
  background-color: #FFFFFF;
  color: var(--text-main);
  box-shadow: var(--shadow-popover);
}

dialog::backdrop {
  background-color: rgba(17, 24, 39, 0.45);
  backdrop-filter: blur(4px);
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-light);
}

.dialog-header h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
}

.btn-dialog-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.btn-dialog-close:hover {
  background-color: var(--bg-surface-muted);
  color: var(--text-main);
}

#project-form {
  padding: 1.5rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.form-field-full {
  grid-column: 1 / -1;
}

.form-field label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-main);
}

.field-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

input[type="text"],
input[type="date"],
input[type="number"],
select,
textarea {
  min-height: 40px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background-color: #FFFFFF;
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--text-main);
  outline: none;
  transition: all 120ms ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary-indigo);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-error {
  margin: 1rem 0 0;
  padding: 0.625rem 0.875rem;
  background-color: #FEF2F2;
  border: 1px solid #FCA5A5;
  border-radius: var(--radius-md);
  color: #B91C1C;
  font-size: 0.8125rem;
}

.dialog-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-light);
}

.dialog-footer-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: auto;
}

.btn-secondary {
  height: 38px;
  padding: 0 1rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
  background-color: #FFFFFF;
  color: var(--text-main);
  font-weight: 600;
}

.btn-secondary:hover {
  background-color: var(--bg-surface-subtle);
}

.btn-danger {
  height: 38px;
  padding: 0 1rem;
  border-radius: var(--radius-full);
  border: 1px solid #FCA5A5;
  background-color: #FEF2F2;
  color: #DC2626;
  font-weight: 600;
}

.btn-danger:hover {
  background-color: #FEE2E2;
}

/* Empty Page Placeholder */
.empty-page-container {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 1.5rem;
  text-align: center;
}

.empty-page-icon {
  width: 48px;
  height: 48px;
  color: var(--text-subtle);
  margin-bottom: 1rem;
}

.empty-page-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-main);
  margin: 0 0 0.5rem;
}

.empty-page-desc {
  font-size: 0.875rem;
  color: var(--text-secondary);
  max-width: 380px;
  margin: 0;
}

/* ==========================================================================
   AUTHENTICATION & RBAC STYLES
   ========================================================================== */
.btn-google-login {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.5rem 0.75rem;
  background-color: #ffffff;
  color: #1e293b;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
}

.btn-google-login:hover {
  background-color: #f8fafc;
  border-color: #cbd5e1;
}

.google-icon {
  flex-shrink: 0;
}

.btn-icon-tiny {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  transition: color var(--transition-fast);
}

.btn-icon-tiny:hover {
  color: var(--status-critical);
  background-color: var(--bg-surface-hover);
}

.user-role-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.125rem 0.375rem;
  border-radius: 9999px;
  width: fit-content;
  margin-top: 2px;
}

.role-pill {
  display: inline-flex;
  align-items: center;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.2rem 0.5rem;
  border-radius: 9999px;
}

.role-pill-admin {
  background-color: #EEF2FF;
  color: #4F46E5;
  border: 1px solid #C7D2FE;
}

.role-pill-editor {
  background-color: #ECFDF5;
  color: #059669;
  border: 1px solid #A7F3D0;
}

.role-pill-viewer {
  background-color: #F1F5F9;
  color: #475569;
  border: 1px solid #E2E8F0;
}

/* User Management Dialog */
.users-dialog {
  max-width: 680px;
}

.users-dialog-desc {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.roles-legend-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  background-color: var(--bg-surface-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 0.75rem;
  margin-bottom: 1.25rem;
}

.role-legend-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.role-legend-desc {
  font-size: 0.6875rem;
  color: var(--text-secondary);
  line-height: 1.3;
}

.users-table-wrap {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 1rem;
  max-height: 280px;
  overflow-y: auto;
}

.users-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
  text-align: left;
}

.users-table th {
  background-color: var(--bg-surface-subtle);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.75rem;
  padding: 0.625rem 0.875rem;
  border-bottom: 1px solid var(--border-subtle);
}

.users-table td {
  padding: 0.625rem 0.875rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-main);
  vertical-align: middle;
}

.users-table tr:last-child td {
  border-bottom: none;
}

.users-table select {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-surface);
}

.add-user-bar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.75rem;
}

.add-user-bar .form-input {
  flex: 2;
  font-size: 0.8125rem;
  padding: 0.4rem 0.625rem;
}

.add-user-bar .form-select {
  flex: 1;
  font-size: 0.8125rem;
  padding: 0.4rem 0.625rem;
}

/* View Only Badge in dialog */
.view-only-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  background-color: #FEF3C7;
  color: #92400E;
  padding: 0.25rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.6875rem;
  font-weight: 600;
  margin-left: 0.5rem;
}

/* ==========================================================================
   RESPONSIVE QUERIES
   ========================================================================== */
@media (max-width: 1024px) {
  .app-sidebar {
    position: fixed;
    top: 12px;
    bottom: 12px;
    left: 12px;
    z-index: 100;
    box-shadow: var(--shadow-popover);
  }
}
