/* ==========================================================================
   ArchiDocs Portal - Architectural Documentation & Project Management System
   Modern Architectural Studio UI / UX Design
   ========================================================================== */

:root {
  /* Color Palette - Modern Architectural Studio Slate & Indigo Theme */
  --bg-main: #0b0f17;
  --bg-sidebar: #0f172a;
  --bg-card: #1e293b;
  --bg-card-hover: #24344d;
  --bg-card-subtle: rgba(30, 41, 59, 0.7);
  --bg-input: #0f172a;
  
  --border-subtle: #334155;
  --border-focus: #6366f1;
  --border-hover: #475569;
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --accent-primary: #4f46e5;
  --accent-primary-hover: #4338ca;
  --accent-primary-light: rgba(99, 102, 241, 0.15);
  
  --status-completed: #10b981;
  --status-completed-bg: rgba(16, 185, 129, 0.15);
  --status-completed-border: rgba(16, 185, 129, 0.3);
  
  --status-inprogress: #38bdf8;
  --status-inprogress-bg: rgba(56, 189, 248, 0.15);
  --status-inprogress-border: rgba(56, 189, 248, 0.3);
  
  --status-pending: #f59e0b;
  --status-pending-bg: rgba(245, 158, 11, 0.15);
  --status-pending-border: rgba(245, 158, 11, 0.3);
  
  --status-na: #64748b;
  --status-na-bg: rgba(100, 116, 139, 0.15);
  --status-na-border: rgba(100, 116, 139, 0.3);

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.25);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --font-family: 'Noto Sans Georgian', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light Theme Variables */
[data-theme="light"] {
  --bg-main: #f8fafc;
  --bg-sidebar: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --bg-card-subtle: rgba(241, 245, 249, 0.8);
  --bg-input: #f8fafc;
  
  --border-subtle: #e2e8f0;
  --border-focus: #4f46e5;
  --border-hover: #cbd5e1;
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  
  --accent-primary: #4f46e5;
  --accent-primary-hover: #4338ca;
  --accent-primary-light: rgba(79, 70, 229, 0.08);

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
  --shadow-glow: 0 0 20px rgba(79, 70, 229, 0.15);
}

/* Reset & Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* App Container */
.app-container {
  display: flex;
  width: 100vw;
  min-height: 100vh;
  position: relative;
}

/* ==========================================================================
   Sidebar Navigation
   ========================================================================== */
.sidebar {
  width: 320px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100vh;
  position: sticky;
  top: 0;
  z-index: 40;
  transition: var(--transition);
}

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

.logo-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--text-primary);
}

.alpha-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  max-width: 190px;
}

.alpha-logo-img {
  height: 36px;
  width: auto;
  max-width: 175px;
  object-fit: contain;
  transition: var(--transition);
}

[data-theme="dark"] .alpha-logo-img {
  filter: brightness(0) invert(1);
}

[data-theme="light"] .alpha-logo-img {
  filter: brightness(0) invert(0.08);
}

.sidebar-actions {
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
  text-decoration: none;
}

.btn-primary {
  background-color: var(--accent-primary);
  color: #ffffff;
  box-shadow: 0 2px 4px rgba(79, 70, 229, 0.3);
}

.btn-primary:hover {
  background-color: var(--accent-primary-hover);
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.4);
  transform: translateY(-1px);
}

.btn-secondary {
  background-color: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--border-subtle);
}

.btn-secondary:hover {
  background-color: var(--bg-card-hover);
  border-color: var(--border-hover);
}

.btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
}

.btn-share {
  background: var(--accent-primary);
  color: #ffffff;
  border: none;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}

.btn-share:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(6, 182, 212, 0.4);
}

/* ==========================================================================
   Live Cloud Sync & Collaboration Badge
   ========================================================================== */
.live-sync-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.8rem;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  color: var(--text-secondary);
  transition: var(--transition);
  user-select: none;
}

.live-sync-badge:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.live-sync-badge.connected {
  border-color: rgba(16, 185, 129, 0.3);
  background: rgba(16, 185, 129, 0.08);
  color: var(--status-completed);
}

.live-sync-badge.syncing {
  border-color: rgba(245, 158, 11, 0.3);
  background: rgba(245, 158, 11, 0.08);
  color: #f59e0b;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background-color: var(--status-completed);
  box-shadow: 0 0 8px var(--status-completed);
  display: inline-block;
  animation: pulseGreen 2s infinite ease-in-out;
}

.live-dot.yellow {
  background-color: #f59e0b;
  box-shadow: 0 0 8px #f59e0b;
  animation: pulseYellow 1s infinite ease-in-out;
}

.live-dot.gray {
  background-color: #64748b;
  box-shadow: none;
  animation: none;
}

@keyframes pulseGreen {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.3); opacity: 1; box-shadow: 0 0 12px #10b981; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

@keyframes pulseYellow {
  0% { transform: scale(0.95); opacity: 0.7; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.7; }
}

.pulse-update {
  animation: flashHighlight 0.8s ease;
}

@keyframes flashHighlight {
  0% { background: rgba(79, 70, 229, 0.4); }
  100% { background: rgba(16, 185, 129, 0.08); }
}

.room-share-box {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.9rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.room-share-link {
  font-size: 0.85rem;
  font-family: monospace;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.btn-icon {
  padding: 0.5rem;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.btn-icon:hover {
  background-color: var(--bg-card-hover);
  color: var(--text-primary);
}

.search-input-wrapper {
  position: relative;
  width: 100%;
}

.search-input-wrapper svg {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  width: 16px;
  height: 16px;
}

.search-input {
  width: 100%;
  padding: 0.6rem 0.75rem 0.6rem 2.25rem;
  background-color: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-family: inherit;
  transition: var(--transition);
}

.sidebar-project-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.35rem;
  padding: 0.4rem 1.25rem 0.2rem 1.25rem;
}

.proj-tab-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  padding: 0.45rem 0.3rem;
  border-radius: var(--radius-md);
  font-size: 0.75rem;
  font-weight: 700;
  font-family: inherit;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
}

.proj-tab-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.proj-tab-btn.active {
  background: var(--accent-primary-light);
  border-color: rgba(99, 102, 241, 0.4);
  color: var(--accent-primary);
}

.proj-tab-btn.active#tabBtnTrash {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.35);
  color: #ef4444;
}

.proj-tab-btn.active#tabBtnArchived {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.35);
  color: #f59e0b;
}

.tab-badge {
  font-size: 0.68rem;
  padding: 0.05rem 0.35rem;
  border-radius: var(--radius-full);
  background: rgba(148, 163, 184, 0.15);
  color: inherit;
}

.sidebar-section-title {
  padding: 0.5rem 1.25rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ==========================================================================
   Project Status Banners (Archive & Trash)
   ========================================================================== */
.project-status-banner {
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-md);
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.project-status-banner.archived {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #f59e0b;
}

.project-status-banner.trash {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #ef4444;
}

.status-banner-info {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.875rem;
  font-weight: 700;
}

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

.project-item.archived-item {
  border-left: 3px solid #f59e0b;
}

.project-item.trash-item {
  border-left: 3px solid #ef4444;
  opacity: 0.85;
}

.projects-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.project-item {
  padding: 0.75rem 0.85rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  position: relative;
}

.project-item:hover {
  background-color: var(--bg-card);
  border-color: var(--border-subtle);
}

.project-item.active {
  background-color: var(--accent-primary-light);
  border-color: rgba(99, 102, 241, 0.4);
}

.project-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.project-item-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.project-item-code {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.project-item-progress-bar {
  width: 100%;
  height: 4px;
  background: var(--border-subtle);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-top: 0.2rem;
}

.project-item-progress-fill {
  height: 100%;
  background: var(--accent-primary);
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
}

.project-item-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ==========================================================================
   Main Workspace Area
   ========================================================================== */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-y: auto;
  background-color: var(--bg-main);
}

/* Top Navigation Bar */
.top-navbar {
  height: 64px;
  padding: 0 2rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--bg-card-subtle);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 30;
}

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

.mobile-toggle-btn {
  display: none;
}

.project-breadcrumbs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.project-breadcrumbs .current-project-name {
  font-weight: 700;
  color: var(--text-primary);
}

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

/* Content Body */
.workspace-body {
  padding: 2rem;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* Project Overview Hero Card */
.project-hero-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}

.project-hero-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--accent-primary);
}

.project-hero-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.project-hero-title-group {
  flex: 1;
  min-width: 280px;
}

.project-hero-title-group h2 {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-bottom: 0.4rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.project-badge-type {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  background: var(--accent-primary-light);
  color: var(--accent-primary);
  border-radius: var(--radius-full);
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.project-hero-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-subtle);
}

.meta-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.meta-item-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.meta-item-value {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* Statistics & Progress Overview */
.stats-overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: var(--transition);
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-hover);
  box-shadow: var(--shadow-sm);
}

.stat-icon-wrapper {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon-wrapper.blue { background: rgba(56, 189, 248, 0.15); color: #38bdf8; }
.stat-icon-wrapper.green { background: rgba(16, 185, 129, 0.15); color: #10b981; }
.stat-icon-wrapper.amber { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.stat-icon-wrapper.indigo { background: rgba(99, 102, 241, 0.15); color: #818cf8; }

.stat-info h4 {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
}

.stat-info span {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* Overall Progress Card */
.overall-progress-box {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.progress-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
}

.progress-percentage {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--accent-primary);
}

.progress-bar-container {
  width: 100%;
  height: 10px;
  background-color: var(--border-subtle);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}

.progress-bar-fill {
  height: 100%;
  background: var(--accent-primary);
  border-radius: var(--radius-full);
  transition: width 0.4s ease-out;
}

/* Stage Navigation Tabs & Filters */
.stages-filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 0.75rem;
}

.filter-pills {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.filter-pill {
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius-full);
  font-size: 0.825rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  transition: var(--transition);
}

.filter-pill:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.filter-pill.active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #ffffff;
}

.search-task-input {
  max-width: 260px;
}

/* ==========================================================================
   Documentation Stages / Sections
   ========================================================================== */
.stages-wrapper {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.stage-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.stage-card:hover {
  border-color: var(--border-hover);
}

.stage-card-header {
  padding: 1.25rem 1.5rem;
  background: var(--bg-card-subtle);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}

.stage-card-header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.stage-icon-badge {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-primary-light);
  color: var(--accent-primary);
}

.stage-title-info h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.stage-title-info p {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.stage-card-header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.stage-progress-badge {
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.stage-progress-badge.completed {
  background: var(--status-completed-bg);
  border-color: var(--status-completed-border);
  color: var(--status-completed);
}

.collapse-arrow {
  transition: transform 0.25s ease;
  color: var(--text-muted);
}

.stage-card.collapsed .collapse-arrow {
  transform: rotate(-90deg);
}

.stage-card.collapsed .stage-items-container,
.stage-card.collapsed .stage-card-actions {
  display: none;
}

/* Stage Items Checklist Table / List */
.stage-items-container {
  display: flex;
  flex-direction: column;
}

.stage-item-row {
  padding: 0.9rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  transition: var(--transition);
}

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

.stage-item-row:hover {
  background-color: var(--bg-card-hover);
}

.stage-item-row.completed {
  background-color: rgba(16, 185, 129, 0.03);
}

.stage-item-row.completed .item-title {
  color: var(--text-secondary);
  text-decoration: line-through;
  text-decoration-color: var(--status-completed);
}

.stage-item-row.na {
  opacity: 0.6;
}

.stage-item-left {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex: 1;
  min-width: 0;
}

/* Custom Styled Checkbox */
.custom-checkbox-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.custom-checkbox-wrapper input {
  opacity: 0;
  position: absolute;
  width: 0;
  height: 0;
}

.custom-checkbox {
  width: 22px;
  height: 22px;
  border: 2px solid var(--border-hover);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  background: var(--bg-input);
}

.custom-checkbox-wrapper input:checked + .custom-checkbox {
  background: var(--status-completed);
  border-color: var(--status-completed);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.4);
}

.custom-checkbox svg {
  display: none;
  color: #ffffff;
  width: 14px;
  height: 14px;
}

.custom-checkbox-wrapper input:checked + .custom-checkbox svg {
  display: block;
}

.item-details {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  flex: 1;
}

.item-title {
  font-size: 0.925rem;
  font-weight: 600;
  color: var(--text-primary);
  transition: var(--transition);
}

.item-note-preview {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-style: italic;
}

.stage-item-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

/* Status Selector Select Element */
.status-select {
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-md);
  font-size: 0.78rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-input);
  color: var(--text-primary);
  transition: var(--transition);
}

.status-select.completed {
  background: var(--status-completed-bg);
  border-color: var(--status-completed-border);
  color: var(--status-completed);
}

.status-select.inprogress {
  background: var(--status-inprogress-bg);
  border-color: var(--status-inprogress-border);
  color: var(--status-inprogress);
}

.status-select.pending {
  background: var(--status-pending-bg);
  border-color: var(--status-pending-border);
  color: var(--status-pending);
}

.status-select.na {
  background: var(--status-na-bg);
  border-color: var(--status-na-border);
  color: var(--status-na);
}

.stage-card-actions {
  padding: 0.75rem 1.5rem;
  background: var(--bg-card-subtle);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ==========================================================================
   Modals & Dialogs
   ========================================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  padding: 1.5rem;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.95);
  transition: transform 0.25s ease;
}

.modal-overlay.active .modal-card {
  transform: scale(1);
}

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

.modal-header h3 {
  font-size: 1.2rem;
  font-weight: 700;
}

.modal-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  max-height: 70vh;
  overflow-y: auto;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-control {
  width: 100%;
  padding: 0.65rem 0.85rem;
  background-color: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: inherit;
  transition: var(--transition);
}

.form-control:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  background: var(--bg-card-subtle);
}

/* ==========================================================================
   Template Picker & Restore Styles
   ========================================================================== */
.template-picker-section {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.9rem;
}

.modal-section-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-primary);
}

.modal-section-divider {
  position: relative;
  text-align: center;
  margin: 1.1rem 0 0.85rem 0;
}

.modal-section-divider::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--border-subtle);
}

.modal-section-divider span {
  position: relative;
  background: var(--bg-card);
  padding: 0 0.75rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
}

.template-items-picker {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-height: 220px;
  overflow-y: auto;
  padding-right: 4px;
}

.template-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  gap: 0.5rem;
  transition: var(--transition);
}

.template-item-row:hover {
  border-color: var(--border-hover);
  background: var(--bg-card-hover);
}

.template-item-row.missing {
  border-left: 3px solid #f59e0b;
}

.template-item-row.existing {
  opacity: 0.65;
  background: transparent;
  border-style: dashed;
}

.template-item-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

.template-item-badge {
  font-size: 0.72rem;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-full);
  background: rgba(16, 185, 129, 0.1);
  color: var(--status-completed);
  font-weight: 600;
}

/* ==========================================================================
   File Attachments & Dropzone Styles
   ========================================================================== */
.file-dropzone {
  border: 2px dashed var(--border-subtle);
  background: var(--bg-input);
  border-radius: var(--radius-md);
  padding: 1.5rem 1rem;
  text-align: center;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  transition: var(--transition);
}

.file-dropzone:hover, .file-dropzone.dragover {
  border-color: var(--accent-primary);
  background: var(--accent-primary-light);
}

.dropzone-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  background: var(--bg-card);
  color: var(--accent-primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.dropzone-text {
  display: flex;
  flex-direction: column;
  font-size: 0.875rem;
}

.attached-files-container {
  display: flex;
  flex-direction: column;
}

.attached-files-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 240px;
  overflow-y: auto;
  padding-right: 4px;
}

.attached-file-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.85rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  gap: 0.75rem;
  transition: var(--transition);
}

.attached-file-row:hover {
  border-color: var(--border-hover);
  background: var(--bg-card-hover);
}

.attached-file-info {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex: 1;
  min-width: 0;
}

.attached-file-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.attached-file-size {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.attached-file-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

/* Inline Attachment Chips in Checklist Items */
.item-attachments-preview {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-top: 0.3rem;
}

.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  max-width: 220px;
}

.file-chip:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  background: var(--accent-primary-light);
}

.file-chip-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Toast Notification */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 110;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  padding: 0.75rem 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-left: 4px solid var(--accent-primary);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  animation: slideInRight 0.3s ease;
}

.toast.success {
  border-left-color: var(--status-completed);
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  text-align: center;
  gap: 1rem;
}

.empty-state-icon {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-full);
  background: var(--accent-primary-light);
  color: var(--accent-primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-state h3 {
  font-size: 1.25rem;
  font-weight: 700;
}

.empty-state p {
  color: var(--text-secondary);
  max-width: 400px;
  font-size: 0.9rem;
}

/* ==========================================================================
   Print / Export Styling (PDF Output)
   ========================================================================== */
@media print {
  body {
    background-color: #ffffff !important;
    color: #000000 !important;
  }

  .sidebar,
  .top-navbar,
  .btn,
  .stage-card-actions,
  .btn-icon,
  .filter-pills,
  .search-input-wrapper,
  .modal-overlay,
  .toast-container {
    display: none !important;
  }

  .main-content {
    overflow: visible !important;
  }

  .workspace-body {
    padding: 0 !important;
    max-width: 100% !important;
  }

  .project-hero-card {
    border: 1px solid #cbd5e1 !important;
    background: #f8fafc !important;
    box-shadow: none !important;
    page-break-inside: avoid;
    margin-bottom: 1.5rem;
  }

  .stage-card {
    border: 1px solid #cbd5e1 !important;
    box-shadow: none !important;
    margin-bottom: 1.5rem;
    page-break-inside: avoid;
  }

  .stage-card-header {
    background: #f1f5f9 !important;
  }

  .stage-item-row {
    border-bottom: 1px solid #e2e8f0 !important;
  }

  .status-select {
    border: none !important;
    appearance: none;
    -webkit-appearance: none;
    font-weight: bold;
  }
}

/* ==========================================================================
   Mobile & Responsive Optimizations
   ========================================================================== */

/* Mobile Backdrop Overlay */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 45;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.sidebar-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.mobile-sidebar-close {
  display: none;
}

/* Tablet & Mobile Screens (<= 900px) */
@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    left: -320px;
    top: 0;
    bottom: 0;
    z-index: 50;
    box-shadow: var(--shadow-lg);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateX(0);
  }

  .sidebar.open {
    transform: translateX(320px);
  }

  .mobile-toggle-btn {
    display: inline-flex;
    width: 38px;
    height: 38px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    background: var(--bg-card);
  }

  .mobile-sidebar-close {
    display: inline-flex;
  }

  .workspace-body {
    padding: 1.25rem;
    gap: 1.25rem;
  }
}

/* Mobile Phone Screens (<= 640px) */
@media (max-width: 640px) {
  /* Prevent horizontal overflow */
  html, body {
    overflow-x: hidden;
    width: 100%;
  }

  .app-container {
    width: 100%;
    overflow-x: hidden;
  }

  .main-content {
    width: 100%;
    min-width: 0;
  }

  /* Compact Navbar */
  .top-navbar {
    height: 56px;
    padding: 0 0.75rem;
    gap: 0.5rem;
  }

  .project-breadcrumbs {
    display: none; /* Hide long breadcrumbs on small mobile */
  }

  .nav-right {
    gap: 0.35rem;
  }

  .live-sync-badge {
    padding: 0.25rem 0.55rem;
    font-size: 0.72rem;
  }

  .live-sync-badge b {
    display: none; /* Show dot + "Live Sync" only on small mobile */
  }

  .btn-sm {
    padding: 0.35rem 0.55rem;
    font-size: 0.75rem;
  }

  /* Compact Workspace Body */
  .workspace-body {
    padding: 0.85rem 0.65rem;
    gap: 1rem;
  }

  /* Hero Card */
  .project-hero-card {
    padding: 1.1rem 1rem;
    border-radius: var(--radius-md);
  }

  .project-hero-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 1rem;
  }

  .project-hero-title-group h2 {
    font-size: 1.25rem;
    flex-wrap: wrap;
    gap: 0.4rem;
  }

  .project-hero-header > div:last-child {
    width: 100%;
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) auto !important;
    gap: 0.35rem !important;
  }

  .project-hero-header > div:last-child .btn {
    width: 100%;
    padding: 0.4rem 0.3rem;
    font-size: 0.75rem;
    justify-content: center;
  }

  .project-hero-meta-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    padding-top: 0.75rem;
  }

  .meta-item-label {
    font-size: 0.7rem;
  }

  .meta-item-value {
    font-size: 0.85rem;
  }

  /* Stats Grid: 2 Columns on Mobile */
  .stats-overview-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
  }

  .stat-card {
    padding: 0.85rem 0.75rem;
    gap: 0.65rem;
    border-radius: var(--radius-md);
  }

  .stat-icon-wrapper {
    width: 36px;
    height: 36px;
  }

  .stat-icon-wrapper svg {
    width: 18px;
    height: 18px;
  }

  .stat-info h4 {
    font-size: 1.15rem;
  }

  .stat-info span {
    font-size: 0.72rem;
  }

  /* Overall Progress Box */
  .overall-progress-box {
    padding: 1rem;
    border-radius: var(--radius-md);
  }

  .progress-header h3 {
    font-size: 0.95rem;
  }

  /* Filter & Search Bar */
  .stages-filter-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    padding-bottom: 0.5rem;
  }

  .filter-pills {
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .filter-pills::-webkit-scrollbar {
    display: none;
  }

  .filter-pill {
    padding: 0.35rem 0.75rem;
    font-size: 0.78rem;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .stages-filter-bar > div:last-child {
    width: 100%;
    display: flex;
    gap: 0.5rem;
  }

  .search-task-input {
    max-width: none;
    flex: 1;
  }

  /* Stage Card */
  .stage-card {
    border-radius: var(--radius-md);
  }

  .stage-card-header {
    padding: 0.85rem 0.9rem;
    gap: 0.5rem;
  }

  .stage-card-header-left {
    gap: 0.65rem;
    min-width: 0;
  }

  .stage-icon-badge {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
  }

  .stage-icon-badge svg {
    width: 16px;
    height: 16px;
  }

  .stage-title-info {
    min-width: 0;
  }

  .stage-title-info h3 {
    font-size: 0.92rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .stage-title-info p {
    font-size: 0.72rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .stage-progress-badge {
    font-size: 0.72rem;
    padding: 0.2rem 0.5rem;
  }

  /* Stage Item Row (Mobile Optimized Stack Layout) */
  .stage-item-row {
    padding: 0.85rem 0.9rem;
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
  }

  .stage-item-left {
    width: 100%;
    gap: 0.75rem;
  }

  .custom-checkbox {
    width: 24px;
    height: 24px;
  }

  .item-title {
    font-size: 0.88rem;
    line-height: 1.35;
  }

  .stage-item-right {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-left: 2rem; /* Align under title text */
    gap: 0.5rem;
  }

  .status-select {
    flex: 1;
    max-width: 170px;
    padding: 0.35rem 0.5rem;
    font-size: 0.78rem;
  }

  .stage-card-actions {
    padding: 0.75rem 0.9rem;
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .stage-card-actions > .btn {
    width: 100%;
    justify-content: center;
  }

  .stage-card-actions > div:last-child {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    width: 100%;
    gap: 0.5rem;
  }

  .stage-card-actions > div:last-child .btn {
    width: 100%;
    justify-content: center;
  }

  /* Mobile Modals (Bottom Sheet Style) */
  .modal-overlay {
    padding: 0;
    align-items: flex-end;
  }

  .modal-card {
    max-width: 100%;
    width: 100%;
    border-radius: 20px 20px 0 0;
    max-height: 85vh;
    animation: slideUpModal 0.25s ease-out;
  }

  @keyframes slideUpModal {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }

  .modal-body {
    padding: 1.1rem;
    gap: 1rem;
  }

  /* Set 16px font size on mobile inputs to prevent iOS auto-zoom */
  .form-control,
  .search-input,
  .status-select {
    font-size: 16px !important;
  }

  .modal-footer {
    padding: 0.85rem 1.1rem;
  }

  /* Mobile Toast */
  .toast-container {
    bottom: 1rem;
    right: 1rem;
    left: 1rem;
  }

  .toast {
    width: 100%;
    font-size: 0.825rem;
    padding: 0.65rem 1rem;
  }
}

/* ==========================================================================
   In-App Document & Image Viewer Styles (Seamless Portal Experience)
   ========================================================================== */
.doc-viewer-overlay {
  z-index: 120;
  backdrop-filter: blur(8px);
  background-color: rgba(5, 8, 16, 0.85);
  padding: 1.5rem;
}

.doc-viewer-modal-card {
  width: 95vw;
  max-width: 1300px;
  height: 90vh;
  max-height: 920px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.7);
  overflow: hidden;
  animation: modalPop 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.doc-viewer-header {
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-card-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-shrink: 0;
}

.doc-viewer-title-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  flex: 1;
}

.doc-viewer-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.doc-viewer-meta h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 450px;
}

.doc-viewer-badge {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.doc-viewer-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.image-zoom-controls {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--bg-input);
  padding: 0.2rem 0.4rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.zoom-level-text {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-primary);
  min-width: 42px;
  text-align: center;
}

.doc-viewer-body {
  flex: 1;
  position: relative;
  background: #080c14;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.doc-viewer-iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: #ffffff;
}

.image-viewer-container {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  user-select: none;
  cursor: grab;
  touch-action: none;
  background: #060911;
}

.image-viewer-container.grabbing {
  cursor: grabbing !important;
}

.image-viewer-img {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  transform-origin: center center;
  transition: transform 0.04s ease-out;
  pointer-events: none;
}

.file-viewer-fallback {
  text-align: center;
  padding: 2.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  max-width: 480px;
}

.fallback-icon {
  font-size: 3.5rem;
}

.file-viewer-fallback h3 {
  font-size: 1.1rem;
  color: var(--text-primary);
  word-break: break-word;
}

.file-viewer-fallback p {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Fullscreen mode for viewer */
.doc-viewer-modal-card.fullscreen {
  width: 100vw !important;
  max-width: 100vw !important;
  height: 100vh !important;
  max-height: 100vh !important;
  border-radius: 0 !important;
  border: none !important;
}


/* ==========================================================================
   v2 Design Refresh
   - softer surfaces, clearer hierarchy, calmer accent, better small-screen layout
   ========================================================================== */
:root {
  --bg-main: #0a0e16;
  --bg-sidebar: #0d121c;
  --bg-card: #151c2b;
  --bg-card-hover: #1b2438;
  --bg-input: #0d121c;
  --border-subtle: #232d42;
  --border-hover: #364260;
  --accent-primary: #6366f1;
  --accent-primary-hover: #5558e6;
  --accent-primary-light: rgba(99, 102, 241, 0.14);
  --client: #f59e0b;
  --client-bg: rgba(245, 158, 11, 0.12);
  --studio: #818cf8;
  --studio-bg: rgba(129, 140, 248, 0.12);
  --radius-md: 12px;
  --radius-lg: 18px;
}
[data-theme="light"] {
  --bg-main: #f4f6fb;
  --bg-sidebar: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f3f5fa;
  --bg-input: #f4f6fb;
  --border-subtle: #e3e8f2;
  --border-hover: #cdd5e5;
  --client: #b45309;
  --client-bg: rgba(245, 158, 11, 0.14);
  --studio: #4f46e5;
  --studio-bg: rgba(79, 70, 229, 0.09);
}

body { -webkit-font-smoothing: antialiased; }

/* Buttons */
.btn { white-space: nowrap; border-radius: 10px; font-weight: 600; letter-spacing: 0; }
.btn-primary { background: linear-gradient(180deg, #6d70f5, #5b5ee8); box-shadow: 0 1px 0 rgba(255,255,255,.12) inset, 0 4px 14px -4px rgba(99,102,241,.55); }
.btn-primary:hover { background: linear-gradient(180deg, #7578f7, #6366f1); }
.btn-secondary { background: var(--bg-card); border: 1px solid var(--border-subtle); }
.btn-secondary:hover { background: var(--bg-card-hover); border-color: var(--border-hover); }
.btn:focus-visible, .btn-icon:focus-visible, .live-sync-badge:focus-visible, .filter-pill:focus-visible { outline: 2px solid var(--accent-primary); outline-offset: 2px; }

/* Sidebar */
.sidebar { border-right: 1px solid var(--border-subtle); }
.sidebar-project-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; margin: 0 1rem; background: var(--bg-input); border: 1px solid var(--border-subtle); border-radius: 12px; }
.proj-tab-btn { white-space: nowrap; justify-content: center; gap: 4px; padding: 0.45rem 0.25rem; font-size: 0.74rem; border: 0; border-radius: 9px; flex-direction: row; }
.proj-tab-btn .tab-badge { font-size: 0.66rem; padding: 0 5px; }

/* Top navbar */
.top-navbar { background: color-mix(in srgb, var(--bg-main) 82%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border-subtle); }
.nav-right { flex-wrap: nowrap; }
.live-sync-badge { max-width: 300px; white-space: nowrap; }
.live-sync-badge > span:last-child { overflow: hidden; text-overflow: ellipsis; }
.live-sync-badge.warn { border-color: rgba(245,158,11,.35); background: rgba(245,158,11,.1); color: #f59e0b; }
.live-sync-badge.offline { border-color: rgba(239,68,68,.3); background: rgba(239,68,68,.08); color: #f87171; }
.live-sync-badge.pulse-update { box-shadow: 0 0 0 4px rgba(99,102,241,.25); }

/* Hero */
.project-hero-card { border-radius: var(--radius-lg); padding: 1.6rem 1.75rem; background: linear-gradient(160deg, var(--bg-card), color-mix(in srgb, var(--bg-card) 88%, var(--accent-primary) 12%)); }
.project-hero-header { align-items: flex-start; gap: 1.25rem; flex-wrap: wrap; }
.project-hero-title-group { flex: 1 1 320px; min-width: 0; }
.project-hero-title-group h2 { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; font-size: 1.65rem; line-height: 1.25; margin-bottom: .35rem; word-break: break-word; }
.project-badge-type { font-size: .72rem; font-weight: 600; padding: .2rem .65rem; border-radius: 99px; white-space: normal; line-height: 1.3; }
.project-hero-header > div:last-child { flex: 0 1 auto; }
.project-hero-meta-grid { gap: 1rem 1.5rem; }
.meta-item-value { overflow-wrap: anywhere; }

/* Stats */
.stats-overview-grid { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 1rem; }
.stat-card { border-radius: var(--radius-lg); padding: 1.1rem 1.25rem; }
.stat-info h4 { font-size: 1.75rem; line-height: 1.1; }
.stat-info span { display: block; font-size: .8rem; line-height: 1.3; }
.stat-card.attention { border-color: rgba(245,158,11,.45); background: linear-gradient(160deg, var(--bg-card), rgba(245,158,11,.08)); }
.stat-card.attention .stat-icon-wrapper { background: var(--client-bg); color: var(--client); }
.stat-card.attention .stat-info h4 { color: var(--client); }

.overall-progress-box { border-radius: var(--radius-lg); }
.progress-bar-container { height: 10px; }

/* Filter bar */
.stages-filter-bar { flex-wrap: wrap; gap: .75rem; }
.filter-pills { flex-wrap: wrap; gap: .4rem; }
.filter-pill { white-space: nowrap; }
.filter-pill.client.active { background: var(--client-bg); color: var(--client); border-color: rgba(245,158,11,.45); }
.stages-filter-bar .btn { white-space: nowrap; }

/* Stage cards & rows */
.stage-card { border-radius: var(--radius-lg); }
.stage-item-row { align-items: flex-start; gap: .75rem; padding: .8rem 1.25rem; flex-wrap: wrap; }
.stage-item-left { flex: 1 1 280px; min-width: 0; }
.item-title { overflow-wrap: anywhere; }
.stage-item-right { flex: 0 0 auto; flex-wrap: wrap; justify-content: flex-end; gap: .4rem; }
.status-select { min-width: 150px; }

.owner-chip { border: 1px solid transparent; border-radius: 99px; padding: .28rem .7rem; font: inherit; font-size: .72rem; font-weight: 700; cursor: pointer; white-space: nowrap; transition: var(--transition); }
.owner-chip.client { background: var(--client-bg); color: var(--client); border-color: rgba(245,158,11,.35); }
.owner-chip.studio { background: var(--studio-bg); color: var(--studio); border-color: rgba(129,140,248,.25); }
.owner-chip:hover { transform: translateY(-1px); filter: brightness(1.1); }

/* Export modal */
.export-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; }
.export-chip { border: 1px solid var(--border-subtle); border-radius: 12px; padding: .7rem .8rem; display: flex; flex-direction: column; gap: 2px; background: var(--bg-input); }
.export-chip b { font-size: 1.5rem; line-height: 1.1; }
.export-chip span { font-size: .72rem; color: var(--text-secondary); line-height: 1.3; }
.export-chip.client { border-color: rgba(245,158,11,.4); } .export-chip.client b { color: var(--client); }
.export-chip.studio b { color: var(--studio); }
.export-chip.done b { color: var(--status-completed); }
.export-options { display: grid; gap: .5rem; }
.export-option { display: flex; align-items: center; gap: .85rem; text-align: left; width: 100%; padding: .75rem .9rem; border-radius: 12px; border: 1px solid var(--border-subtle); background: var(--bg-card); color: var(--text-primary); font: inherit; cursor: pointer; transition: var(--transition); }
.export-option:hover { border-color: var(--accent-primary); background: var(--accent-primary-light); transform: translateY(-1px); }
.export-option b { display: block; font-size: .9rem; }
.export-option small { display: block; color: var(--text-secondary); font-size: .76rem; margin-top: 1px; }
.export-option-icon { font-size: 1.4rem; width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--bg-input); flex: 0 0 auto; }

/* Sync health box */
.sync-health { display: flex; flex-direction: column; gap: .25rem; padding: .8rem .95rem; border-radius: 12px; border: 1px solid var(--border-subtle); font-size: .82rem; line-height: 1.45; }
.sync-health b { font-size: .88rem; }
.sync-health span { color: var(--text-secondary); }
.sync-health.ok { border-color: rgba(16,185,129,.4); background: rgba(16,185,129,.08); }
.sync-health.warn { border-color: rgba(245,158,11,.45); background: rgba(245,158,11,.1); }
.sync-health.bad { border-color: rgba(239,68,68,.4); background: rgba(239,68,68,.08); }

/* Toasts */
.toast { border-radius: 12px; box-shadow: var(--shadow-lg); }

@media (max-width: 900px) {
  .hide-sm { display: none; }
}
@media (max-width: 640px) {
  .project-hero-header { flex-direction: column; flex-wrap: nowrap; gap: .75rem; }
  .project-hero-title-group { flex: 0 0 auto; width: 100%; }
  .project-hero-header > div:last-child { display: flex !important; flex-wrap: wrap; gap: .4rem !important; width: 100%; }
  .project-hero-header > div:last-child .btn { width: auto; flex: 0 0 auto; }
  .live-sync-badge { max-width: 150px; }
  .nav-right { min-width: 0; }
  .stats-overview-grid { grid-template-columns: 1fr 1fr; gap: .6rem; }
  .stat-card { padding: .8rem; gap: .6rem; flex-direction: column; align-items: flex-start; }
  .export-summary { grid-template-columns: 1fr; }
  .stage-item-row { padding: .75rem .85rem; flex-direction: column; flex-wrap: nowrap; }
  .stage-item-left { flex: 0 0 auto; width: 100%; }
  .stage-item-right { flex: 0 0 auto; width: 100%; justify-content: flex-start; padding-left: 2.1rem; }
  .status-select { min-width: 0; flex: 1 1 140px; }
  .project-hero-card { padding: 1.1rem 1rem; }
}

/* Print: the app view (client report has its own printable page) */
@media print {
  .owner-chip, .stat-card { break-inside: avoid; }
}
.status-select { font-size: .8rem; }

/* ---- v2.1 polish ---- */
.stage-title-info { min-width: 0; flex: 1; }
.stage-mini-bar { height: 4px; border-radius: 99px; background: var(--border-subtle); margin-top: .55rem; max-width: 320px; overflow: hidden; }
.stage-mini-bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent-primary), #38bdf8); transition: width .4s ease; }
.stage-card.stage-done { border-color: rgba(16,185,129,.35); }
.stage-card.stage-done .stage-mini-bar i { background: var(--status-completed); }
.stage-card.stage-done .stage-icon-badge { background: var(--status-completed-bg); color: var(--status-completed); }
.stage-card-header { transition: background .2s; }
.stage-card-header:hover { background: var(--bg-card-hover); }
.stage-card-header-right { gap: .5rem; }
.stage-export-btn { opacity: .65; }
.stage-card-header:hover .stage-export-btn, .stage-export-btn:focus-visible { opacity: 1; color: var(--accent-primary); }
.stage-item-row { position: relative; }
.stage-item-row::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: transparent; transition: background .2s; }
.stage-item-row:hover::before { background: var(--accent-primary); }
.stage-item-row.completed::before { background: var(--status-completed); opacity: .6; }
.stage-card-actions { background: color-mix(in srgb, var(--bg-card) 92%, var(--bg-main) 8%); }

/* sticky filter bar */
.stages-filter-bar { position: sticky; top: 0; z-index: 20; padding: .7rem 0; background: color-mix(in srgb, var(--bg-main) 90%, transparent); backdrop-filter: blur(10px); }

/* hero meta as tiles */
.project-hero-meta-grid { border-top: 0; padding-top: 0; margin-top: 1.1rem; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.meta-item { background: var(--bg-input); border: 1px solid var(--border-subtle); border-radius: 12px; padding: .7rem .9rem; gap: .15rem; }
.meta-item-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; }

.sidebar .project-item, .project-list-item { border-radius: 12px; }
.progress-percentage { font-size: 1.9rem; font-weight: 800; background: linear-gradient(90deg, var(--accent-primary), #38bdf8); -webkit-background-clip: text; background-clip: text; color: transparent; }
.toast { border-left: 3px solid var(--accent-primary); }
.toast.success { border-left-color: var(--status-completed); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 99px; border: 2px solid transparent; background-clip: content-box; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ==========================================================================
   Alpha Note + flat (gradient-free) refinement
   ========================================================================== */
.btn-primary, .btn-primary:hover { background-image: none; }
.btn-primary { background: var(--accent-primary); box-shadow: none; }
.btn-primary:hover { background: var(--accent-primary-hover); }
.project-hero-card { background: var(--bg-card); }
.project-hero-card::before { background: var(--accent-primary); }
.stat-card.attention { background: var(--bg-card); }
.progress-bar-fill, .stage-mini-bar i, .stage-card .progress-bar-fill { background: var(--accent-primary); }
.stage-card.stage-done .stage-mini-bar i { background: var(--status-completed); }
.progress-percentage { background: none; -webkit-background-clip: initial; background-clip: initial; color: var(--accent-primary); }
.kpi-bar i, .bar i { background-image: none; }

/* view switcher */
.view-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin: 1rem 1rem 0; padding: 4px; background: var(--bg-input); border: 1px solid var(--border-subtle); border-radius: 12px; }
.view-switch-btn { border: 0; background: transparent; color: var(--text-secondary); font: inherit; font-size: .8rem; font-weight: 600; padding: .55rem .4rem; border-radius: 9px; cursor: pointer; white-space: nowrap; transition: var(--transition); }
.view-switch-btn:hover { color: var(--text-primary); }
.view-switch-btn.active { background: var(--bg-card); color: var(--text-primary); box-shadow: var(--shadow-sm); }

.notes-sidebar { display: none; flex-direction: column; flex: 1; min-height: 0; }
.notes-mode .notes-sidebar { display: flex; }
.notes-mode .sidebar > .sidebar-actions, .notes-mode .sidebar-project-tabs, .notes-mode .sidebar-section-title, .notes-mode #projectsList, .notes-mode #navExportBtn { display: none !important; }
.notes-nav { display: flex; flex-direction: column; gap: 2px; padding: 0 1rem 1rem; overflow-y: auto; }
.notes-nav-title { margin: 1rem .5rem .35rem; font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); font-weight: 700; }
.notes-nav-item { display: flex; justify-content: space-between; gap: .5rem; align-items: center; text-align: left; border: 0; background: transparent; color: var(--text-secondary); font: inherit; font-size: .84rem; padding: .5rem .7rem; border-radius: 9px; cursor: pointer; transition: var(--transition); }
.notes-nav-item span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notes-nav-item:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.notes-nav-item.active { background: var(--accent-primary-light); color: var(--accent-primary); font-weight: 600; }
.notes-nav-count { font-size: .72rem; opacity: .8; }

.notes-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; padding-bottom: 1.25rem; border-bottom: 1px solid var(--border-subtle); }
.notes-title { font-size: 1.7rem; font-weight: 800; letter-spacing: -.01em; }
.notes-sub { color: var(--text-secondary); font-size: .88rem; margin-top: .2rem; }
.notes-tools { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.notes-grid { columns: 3 270px; column-gap: 1rem; margin-top: 1.25rem; }
.note-card { break-inside: avoid; margin-bottom: 1rem; background: var(--bg-card); border: 1px solid var(--border-subtle); border-left: 3px solid var(--note-c); border-radius: 14px; padding: 1rem 1.1rem; cursor: pointer; transition: var(--transition); display: block; }
.note-card:hover, .note-card:focus-visible { border-color: var(--border-hover); border-left-color: var(--note-c); transform: translateY(-2px); box-shadow: var(--shadow-md); outline: none; }
.note-card header { display: flex; justify-content: space-between; align-items: flex-start; gap: .5rem; }
.note-card h3 { font-size: .98rem; font-weight: 700; line-height: 1.35; overflow-wrap: anywhere; }
.note-pin { border: 0; background: transparent; cursor: pointer; font-size: .85rem; opacity: .25; filter: grayscale(1); padding: 2px; transition: var(--transition); }
.note-card:hover .note-pin { opacity: .6; }
.note-pin.on { opacity: 1; filter: none; }
.note-body { margin-top: .5rem; color: var(--text-secondary); font-size: .86rem; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 8; -webkit-box-orient: vertical; overflow: hidden; }
.note-card footer { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; margin-top: .8rem; }
.note-tag, .note-proj { font-size: .7rem; padding: .12rem .5rem; border-radius: 99px; background: var(--bg-input); border: 1px solid var(--border-subtle); color: var(--text-secondary); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-date { margin-left: auto; font-size: .7rem; color: var(--text-muted); }

.note-title-input { font-size: 1.1rem; font-weight: 700; }
.note-editor-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; align-items: end; }
.note-swatches { display: flex; gap: .5rem; padding: .25rem 0; }
.note-swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid transparent; background: var(--c); cursor: pointer; padding: 0; outline-offset: 2px; transition: var(--transition); }
.note-swatch.active { border-color: var(--text-primary); transform: scale(1.1); }
.note-pin-toggle { display: flex; align-items: center; gap: .5rem; font-size: .88rem; color: var(--text-secondary); cursor: pointer; padding-bottom: .4rem; }
@media (max-width: 640px) { .note-editor-row { grid-template-columns: 1fr; } .notes-tools { width: 100%; } .notes-tools .search-input-wrapper { flex: 1 1 100%; } .notes-title { font-size: 1.4rem; } }
@media (min-width: 1100px) { .notes-tools { flex-wrap: nowrap; } }

/* ==========================================================================
   Alpha Note board (open-world mood board)
   ========================================================================== */
.main-content.board-mode { height: 100vh; min-height: 0; overflow: hidden; }
.workspace-body.board-mode { padding: 0; max-width: none; margin: 0; gap: 0; flex: 1; min-height: 0; position: relative; }
.note-thumb { display: block; width: calc(100% + 2.2rem); margin: -1rem -1.1rem .7rem; max-width: none; border-radius: 11px 11px 0 0; }
.note-image-box { display: flex; align-items: center; gap: .75rem; }
.note-image-box img { max-height: 120px; max-width: 60%; border-radius: 10px; border: 1px solid var(--border-subtle); }

.board {
  position: absolute; inset: 0; overflow: hidden; cursor: grab; outline: none; touch-action: none; user-select: none;
  background-color: var(--bg-main);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='28' height='28'><circle cx='14' cy='14' r='1.3' fill='%238b95ad' fill-opacity='.35'/></svg>");
  background-size: 28px 28px;
}
.board.panning { cursor: grabbing; }
.board.linking, .board.linking * { cursor: crosshair !important; }
.board.dropping::after { content: ""; position: absolute; inset: 10px; border: 2px dashed var(--accent-primary); border-radius: 18px; pointer-events: none; }
.board-drop { display: none; }
.board-world { position: absolute; left: 0; top: 0; width: 0; height: 0; transform-origin: 0 0; will-change: transform; }
.board.animating .board-world { transition: transform .45s cubic-bezier(.3,.8,.3,1); }
.board.animating { transition: background-position .45s cubic-bezier(.3,.8,.3,1), background-size .45s cubic-bezier(.3,.8,.3,1); }

.board-origin { position: absolute; left: 0; top: 0; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--text-muted); pointer-events: none; font-size: .68rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.board-origin svg { padding: 8px; box-sizing: content-box; border-radius: 50%; border: 1.5px dashed var(--border-hover); background: var(--bg-card); }

.board-links { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.bl-line { fill: none; stroke: var(--accent-primary); stroke-width: 2; stroke-linecap: round; opacity: .75; }
.bl-hit { fill: none; stroke: transparent; stroke-width: 16; pointer-events: stroke; }
.bl-end { fill: var(--accent-primary); }
.bl-temp { fill: none; stroke: var(--accent-primary); stroke-width: 2; stroke-dasharray: 6 5; }
.bl .link-del { opacity: 0; pointer-events: all; cursor: pointer; transition: opacity .15s; }
.bl .link-del circle { fill: var(--bg-card); stroke: #ef4444; stroke-width: 1.5; }
.bl .link-del path { stroke: #ef4444; stroke-width: 1.8; stroke-linecap: round; }
.bl:hover .link-del, .bl .link-del:hover { opacity: 1; }
.bl:hover .bl-line { stroke-width: 3; opacity: 1; }

.board-notes { position: absolute; left: 0; top: 0; }
.board-note {
  position: absolute; background: var(--bg-card); border: 1px solid var(--border-subtle); border-top: 3px solid var(--note-c);
  border-radius: 12px; box-shadow: var(--shadow-md); cursor: grab; min-width: 120px; transition: box-shadow .15s, border-color .15s;
}
.board-note:hover { border-color: var(--border-hover); border-top-color: var(--note-c); box-shadow: var(--shadow-lg); }
.board-note.dragging { cursor: grabbing; box-shadow: var(--shadow-lg); z-index: 5; }
.board-note.link-target { outline: 2px solid var(--accent-primary); outline-offset: 3px; }
.board-note.has-img { padding: 0; overflow: visible; }
.board-note img { display: block; width: 100%; border-radius: 9px 9px 0 0; pointer-events: none; }
.board-note.has-img:not(:has(.bn-body)) img { border-radius: 9px; }
.bn-body { padding: .75rem .9rem .85rem; max-height: 340px; overflow: hidden; }
.bn-body h4 { font-size: .95rem; font-weight: 700; line-height: 1.35; overflow-wrap: anywhere; }
.bn-body p { margin-top: .35rem; font-size: .84rem; color: var(--text-secondary); line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.bn-tags { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .55rem; }
.bn-tags span { font-size: .68rem; padding: .08rem .45rem; border-radius: 99px; background: var(--bg-input); border: 1px solid var(--border-subtle); color: var(--text-secondary); }
.bn-actions { position: absolute; top: 6px; right: 6px; display: flex; gap: 2px; opacity: 0; transition: opacity .15s; }
.board-note:hover .bn-actions { opacity: 1; }
.bn-actions button { border: 0; background: var(--bg-card); color: var(--text-secondary); border-radius: 7px; width: 26px; height: 26px; cursor: pointer; font-size: .8rem; box-shadow: var(--shadow-sm); border: 1px solid var(--border-subtle); }
.bn-actions button:hover { color: var(--accent-primary); }
.board-note.pinned::after { content: "📌"; position: absolute; top: -10px; left: 8px; font-size: .85rem; pointer-events: none; }
.bn-port { position: absolute; right: -9px; top: 50%; width: 16px; height: 16px; margin-top: -8px; border-radius: 50%; background: var(--bg-card); border: 2px solid var(--accent-primary); cursor: crosshair; opacity: 0; transition: opacity .15s, transform .15s; }
.board-note:hover .bn-port, .board.linking .bn-port { opacity: 1; }
.bn-port:hover { transform: scale(1.25); background: var(--accent-primary); }
.bn-resize { position: absolute; right: 2px; bottom: 2px; width: 14px; height: 14px; cursor: nwse-resize; opacity: 0; transition: opacity .15s; border-right: 2px solid var(--text-muted); border-bottom: 2px solid var(--text-muted); border-bottom-right-radius: 4px; }
.board-note:hover .bn-resize { opacity: .8; }

.board-hud { position: absolute; z-index: 10; display: flex; gap: .5rem; align-items: center; }
.board-hud-top { top: 14px; left: 14px; right: 14px; flex-wrap: wrap; pointer-events: none; }
.board-hud-top > * { pointer-events: auto; }
.board-search { width: 200px; }
.board-hud-bl { left: 14px; bottom: 14px; }
.board-home-btn { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--border-subtle); background: var(--bg-card); color: var(--text-secondary); display: grid; place-items: center; cursor: pointer; box-shadow: var(--shadow-md); transition: var(--transition); }
.board-home-btn:hover { color: var(--accent-primary); border-color: var(--accent-primary); }
.board-home-btn.away { color: var(--accent-primary); border-color: var(--accent-primary); }
.board-zoom { display: flex; align-items: center; background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: 12px; box-shadow: var(--shadow-md); height: 40px; }
.board-zoom button { width: 36px; height: 100%; border: 0; background: transparent; color: var(--text-primary); font-size: 1.1rem; cursor: pointer; }
.board-zoom button:hover { color: var(--accent-primary); }
.board-zoom-label { min-width: 46px; text-align: center; font-size: .78rem; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.board-hint { position: absolute; right: 14px; bottom: 14px; max-width: 360px; text-align: right; font-size: .7rem; line-height: 1.5; color: var(--text-muted); pointer-events: none; }
.board-empty { position: absolute; left: 50%; top: 50%; transform: translate(-50%, 70px); text-align: center; display: flex; flex-direction: column; gap: .25rem; color: var(--text-secondary); pointer-events: none; font-size: .85rem; }
.board-empty b { color: var(--text-primary); font-size: 1rem; }
@media (max-width: 640px) {
  .board-hint { display: none; }
  .board-search { width: 100%; order: 5; }
  /* no hover on touch: the selected note shows its controls */
  .board-note.selected .bn-port, .board-note.selected .bn-actions, .board-note.selected .bn-resize { opacity: 1; }
}

/* ---- board v2: selection, minimap, context menu, checklists ---- */
.board-note.selected { border-color: var(--accent-primary); box-shadow: 0 0 0 2px var(--accent-primary), var(--shadow-lg); }
.board-marquee { display: none; position: absolute; z-index: 9; border: 1px solid var(--accent-primary); background: var(--accent-primary-light); border-radius: 4px; pointer-events: none; }
.board-hud-sep { width: 1px; height: 22px; background: var(--border-subtle); margin: 0 .15rem; }
.board-icon-btn { min-width: 34px; font-size: 1rem; }
.board-icon-btn:disabled { opacity: .35; cursor: default; }
.bl-arrow { fill: var(--accent-primary); }
.board-minimap { position: absolute; right: 14px; bottom: 14px; width: 170px; height: 120px; background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: 12px; box-shadow: var(--shadow-md); overflow: hidden; cursor: pointer; z-index: 10; }
.board-minimap svg { width: 100%; height: 100%; display: block; }
.mm-note { fill: var(--text-muted); opacity: .55; }
.mm-origin { fill: none; stroke: var(--accent-primary); stroke-width: 2; vector-effect: non-scaling-stroke; }
.mm-view { fill: var(--accent-primary-light); stroke: var(--accent-primary); }
.board-hint { right: auto; left: 50%; transform: translateX(-50%); bottom: 12px; text-align: center; max-width: min(620px, calc(100% - 520px)); }
.bn-progress { margin-left: .5rem; font-size: .68rem; font-weight: 700; color: var(--text-muted); }
.bn-text { display: flex; flex-direction: column; gap: 2px; margin-top: .35rem; }
.bn-line { font-size: .84rem; color: var(--text-secondary); line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.bn-gap { height: .45rem; }
.bn-check { display: flex; align-items: flex-start; gap: .5rem; font-size: .86rem; line-height: 1.45; cursor: pointer; }
.bn-check input { margin-top: 3px; accent-color: var(--accent-primary); cursor: pointer; flex: 0 0 auto; }
.bn-check.done span { text-decoration: line-through; color: var(--text-muted); }
.board-ctx { position: fixed; z-index: 400; min-width: 210px; padding: 5px; background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: 12px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; }
.board-ctx button { border: 0; background: transparent; color: var(--text-primary); text-align: left; font: inherit; font-size: .84rem; padding: .5rem .7rem; border-radius: 8px; cursor: pointer; }
.board-ctx button:hover { background: var(--bg-card-hover); }
.board-ctx .danger { color: #ef4444; }
.ctx-colors { display: flex; gap: .45rem; padding: .5rem .7rem; }
.ctx-colors span { width: 18px; height: 18px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; }
.ctx-colors span:hover { border-color: var(--text-primary); }
.bn-actions { gap: 3px; }
@media (max-width: 900px) { .board-minimap { width: 120px; height: 84px; } .board-hint { display: none; } }

/* ---- due dates, dashboard, command palette ---- */
.item-meta-chips { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .3rem; }
.meta-chip { font-size: .7rem; font-weight: 600; padding: .12rem .55rem; border-radius: 99px; background: var(--bg-input); border: 1px solid var(--border-subtle); color: var(--text-secondary); white-space: nowrap; }
.meta-chip.due.overdue { background: rgba(239,68,68,.12); border-color: rgba(239,68,68,.4); color: #ef4444; }
.meta-chip.due.soon { background: var(--client-bg); border-color: rgba(245,158,11,.4); color: var(--client); }
.filter-pill.overdue.active { background: rgba(239,68,68,.12); color: #ef4444; border-color: rgba(239,68,68,.4); }
.view-switch { grid-template-columns: repeat(3, 1fr); }
.view-switch-btn { font-size: .72rem; padding: .5rem .2rem; }
.stat-card.danger { border-color: rgba(239,68,68,.45); }
.stat-card.danger h4 { color: #ef4444; }
.dash-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; }
.dash-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; }
.dash-panel { background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); padding: 1.25rem 1.4rem; display: flex; flex-direction: column; gap: .5rem; min-width: 0; }
.dash-panel.dash-wide { grid-column: 1 / -1; }
.dash-panel h3 { font-size: .95rem; margin-bottom: .35rem; }
.dash-empty { color: var(--text-muted); font-size: .85rem; }
.dash-table { display: flex; flex-direction: column; }
.dash-tr { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(120px, 1.4fr) 90px 90px; gap: 1rem; align-items: center; padding: .7rem .5rem; border: 0; border-bottom: 1px solid var(--border-subtle); background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; border-radius: 8px; }
.dash-tr:not(.dash-th):hover { background: var(--bg-card-hover); }
.dash-th { cursor: default; font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); font-weight: 700; padding-top: 0; }
.dash-name { display: flex; flex-direction: column; min-width: 0; }
.dash-name b, .dash-name small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-name small { color: var(--text-muted); font-size: .76rem; }
.dash-prog { position: relative; height: 22px; background: var(--bg-input); border-radius: 99px; overflow: hidden; border: 1px solid var(--border-subtle); }
.dash-prog i { position: absolute; inset: 0 auto 0 0; background: var(--accent-primary); opacity: .85; }
.dash-prog em { position: absolute; inset: 0; display: grid; place-items: center; font-style: normal; font-size: .7rem; font-weight: 700; color: var(--text-primary); }
.dash-num { text-align: center; font-weight: 700; color: var(--text-muted); }
.dash-num.warn { color: var(--client); } .dash-num.bad { color: #ef4444; }
.dash-item { display: flex; gap: .75rem; align-items: center; padding: .55rem .4rem; border: 0; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; border-radius: 8px; }
.dash-item:hover { background: var(--bg-card-hover); }
.dash-item-t { display: flex; flex-direction: column; min-width: 0; }
.dash-item-t b { font-size: .86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-item-t small { color: var(--text-muted); font-size: .72rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-person { display: grid; grid-template-columns: 130px 1fr 28px; gap: .75rem; align-items: center; font-size: .85rem; }
.dash-bar { height: 8px; background: var(--bg-input); border-radius: 99px; overflow: hidden; }
.dash-bar i { display: block; height: 100%; background: var(--accent-primary); border-radius: inherit; }
@media (max-width: 900px) { .dash-grid { grid-template-columns: 1fr; } .dash-tr { grid-template-columns: minmax(0, 2fr) 90px 56px 56px; gap: .5rem; } .dash-person { grid-template-columns: 90px 1fr 24px; } }

.palette-overlay { align-items: flex-start; padding-top: 12vh; z-index: 500; }
.palette-card { width: 100%; max-width: 580px; background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: 16px; box-shadow: var(--shadow-lg); overflow: hidden; }
.palette-input { width: 100%; border: 0; border-bottom: 1px solid var(--border-subtle); background: transparent; color: var(--text-primary); font: inherit; font-size: 1rem; padding: 1rem 1.25rem; outline: none; }
.palette-list { max-height: 50vh; overflow-y: auto; padding: 6px; }
.palette-item { display: flex; justify-content: space-between; gap: 1rem; width: 100%; border: 0; background: transparent; color: var(--text-primary); font: inherit; font-size: .9rem; padding: .6rem .8rem; border-radius: 9px; cursor: pointer; text-align: left; }
.palette-item small { color: var(--text-muted); font-size: .72rem; white-space: nowrap; }
.palette-item.active, .palette-item:hover { background: var(--accent-primary-light); color: var(--accent-primary); }
.palette-empty { padding: 1.2rem; text-align: center; color: var(--text-muted); font-size: .88rem; }
.palette-foot { padding: .5rem 1rem; border-top: 1px solid var(--border-subtle); font-size: .7rem; color: var(--text-muted); }
.sync-health-extra { margin-top: .35rem; padding-top: .35rem; border-top: 1px dashed var(--border-subtle); font-size: .78rem; }
.dash-mode #navExportBtn { display: none !important; }
.main-content.board-mode { height: 100vh; height: 100dvh; }

/* ---- review fixes: toasts, mobile board HUD, mobile dashboard ---- */
.toast-container { left: 50%; right: auto; transform: translateX(-50%); align-items: center; bottom: 1.2rem; max-width: min(520px, calc(100vw - 2rem)); pointer-events: none; }
.toast { pointer-events: auto; transition: opacity .25s ease, transform .25s ease; }
.toast.error { border-left-color: #ef4444; }
@media (max-width: 640px) {
  .toast-container { left: 1rem; right: 1rem; transform: none; max-width: none; }
  .hud-label { display: none; }
  .board-hud-top { gap: .35rem; top: 10px; left: 10px; right: 10px; }
  .board-hud-top .btn { padding: .4rem .55rem; }
  .board-search { display: none; }
  .board-hud-sep { display: none; }
  .board-hud-bl { left: 10px; bottom: 10px; }
  .dash-th { display: none; }
  .dash-tr { grid-template-columns: 1fr auto auto; grid-template-areas: "name name name" "prog client over"; row-gap: .5rem; padding: .85rem .5rem; }
  .dash-tr .dash-name { grid-area: name; }
  .dash-tr .dash-prog { grid-area: prog; }
  .dash-tr .dash-num:nth-child(3) { grid-area: client; }
  .dash-tr .dash-num:nth-child(4) { grid-area: over; }
  .dash-num::before { content: attr(data-l); font-size: .66rem; font-weight: 600; color: var(--text-muted); margin-right: .25rem; }
}
