/* SymDoctor - Multi-Theme Design System */

/* ==========================================================================
   CSS Variables & Theme System
   ========================================================================== */

:root {
  /* Sidebar */
  --sidebar-width: 200px;

  /* Status colors (shared across themes) */
  --status-created: #6b7280;
  --status-analyzing: #0078d4;
  --status-analyzed: #10b981;
  --status-fixing: #f59e0b;
  --status-testing: #8b5cf6;
  --status-fixed: #059669;
  --status-blocked: #d97706;
  --status-completed: #22c55e;
  --status-failed: #ef4444;

  /* Danger */
  --danger: #ef4444;
  --danger-hover: #dc2626;
}

/* ==========================================================================
   Theme: VS Code Dark (default)
   ========================================================================== */

[data-theme="vscode-dark"] {
  --bg-primary: #1e1e1e;
  --bg-secondary: #252526;
  --bg-card: #2d2d2d;
  --bg-card-light: #383838;
  --bg-card-hover: #3c3c3c;
  --bg-sidebar: #252526;
  --text-primary: #cccccc;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --accent: #0078d4;
  --accent-hover: #1084d8;
  --accent-light: rgba(0, 120, 212, 0.15);
  --border: #3c3c3c;
  --border-light: #4b5563;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
  --radius: 6px;
  --radius-sm: 4px;
  --radius-lg: 8px;
}

/* ==========================================================================
   Theme: VS Code Light
   ========================================================================== */

[data-theme="vscode-light"] {
  --bg-primary: #ffffff;
  --bg-secondary: #f3f3f3;
  --bg-card: #ffffff;
  --bg-card-light: #fafbfc;
  --bg-card-hover: #f5f5f5;
  --bg-sidebar: #f3f3f3;
  --text-primary: #1f1f1f;
  --text-secondary: #4b5563;
  --text-muted: #9ca3af;
  --accent: #0078d4;
  --accent-hover: #005a9e;
  --accent-light: rgba(0, 120, 212, 0.1);
  --border: #e5e7eb;
  --border-light: #d1d5db;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --radius: 6px;
  --radius-sm: 4px;
  --radius-lg: 8px;
}

/* ==========================================================================
   Theme: Material Dark
   ========================================================================== */

[data-theme="material-dark"] {
  --bg-primary: #121212;
  --bg-secondary: #1e1e1e;
  --bg-card: #1e1e1e;
  --bg-card-light: #2a2a2a;
  --bg-card-hover: #2c2c2c;
  --bg-sidebar: #1e1e1e;
  --text-primary: #e0e0e0;
  --text-secondary: #a0a0a0;
  --text-muted: #707070;
  --accent: #bb86fc;
  --accent-hover: #9a67ea;
  --accent-light: rgba(187, 134, 252, 0.15);
  --border: #2c2c2c;
  --border-light: #3c3c3c;
  --shadow: 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.4), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;

  /* Material overrides */
  --status-analyzing: #bb86fc;
}

/* ==========================================================================
   Theme: Material Light
   ========================================================================== */

[data-theme="material-light"] {
  --bg-primary: #fafafa;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-card-light: #fefefe;
  --bg-card-hover: #f5f5f5;
  --bg-sidebar: #ffffff;
  --text-primary: #212121;
  --text-secondary: #616161;
  --text-muted: #9e9e9e;
  --accent: #6200ee;
  --accent-hover: #3700b3;
  --accent-light: rgba(98, 0, 238, 0.1);
  --border: #e0e0e0;
  --border-light: #bdbdbd;
  --shadow: 0 2px 4px rgba(0, 0, 0, 0.1), 0 4px 8px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.1), 0 16px 32px rgba(0, 0, 0, 0.1);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;

  /* Material overrides */
  --status-analyzing: #6200ee;
}

/* ==========================================================================
   Theme: Flat Dark
   ========================================================================== */

[data-theme="flat-dark"] {
  --bg-primary: #2c3e50;
  --bg-secondary: #34495e;
  --bg-card: #34495e;
  --bg-card-light: #3d566e;
  --bg-card-hover: #3d566e;
  --bg-sidebar: #2c3e50;
  --text-primary: #ecf0f1;
  --text-secondary: #bdc3c7;
  --text-muted: #95a5a6;
  --accent: #3498db;
  --accent-hover: #2980b9;
  --accent-light: rgba(52, 152, 219, 0.2);
  --border: #3d566e;
  --border-light: #4a6278;
  --shadow: none;
  --shadow-lg: none;
  --radius: 4px;
  --radius-sm: 2px;
  --radius-lg: 6px;

  /* Flat overrides */
  --status-analyzing: #3498db;
  --status-analyzed: #2ecc71;
  --status-fixing: #f39c12;
  --status-testing: #9b59b6;
  --status-fixed: #059669;
  --status-blocked: #d97706;
  --status-completed: #27ae60;
  --status-failed: #e74c3c;
  --danger: #e74c3c;
  --danger-hover: #c0392b;
}

/* ==========================================================================
   Theme: Flat Light
   ========================================================================== */

[data-theme="flat-light"] {
  --bg-primary: #ecf0f1;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-card-light: #f8f9fa;
  --bg-card-hover: #f8f9fa;
  --bg-sidebar: #ffffff;
  --text-primary: #2c3e50;
  --text-secondary: #7f8c8d;
  --text-muted: #95a5a6;
  --accent: #3498db;
  --accent-hover: #2980b9;
  --accent-light: rgba(52, 152, 219, 0.15);
  --border: #dfe6e9;
  --border-light: #b2bec3;
  --shadow: none;
  --shadow-lg: none;
  --radius: 4px;
  --radius-sm: 2px;
  --radius-lg: 6px;

  /* Flat overrides */
  --status-analyzing: #3498db;
  --status-analyzed: #2ecc71;
  --status-fixing: #f39c12;
  --status-testing: #9b59b6;
  --status-fixed: #059669;
  --status-blocked: #d97706;
  --status-completed: #27ae60;
  --status-failed: #e74c3c;
  --danger: #e74c3c;
  --danger-hover: #c0392b;
}

/* ==========================================================================
   Base Styles
   ========================================================================== */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 14px;
  scroll-behavior: smooth;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  height: 100vh;
  overflow: hidden;
}

/* ==========================================================================
   App Layout (VS Code style)
   ========================================================================== */

.app-container {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  font-weight: 600;
  font-size: 0.875rem;
}

.sidebar-brand img {
  height: 32px;
  width: auto;
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0;
}

.sidebar-nav {
  list-style: none;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 1rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 0.8125rem;
  text-decoration: none;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.sidebar-nav-item:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  text-decoration: none;
}

.sidebar-nav-item.active {
  background: var(--accent-light);
  color: var(--accent);
}

.sidebar-nav-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.sidebar-divider {
  height: 1px;
  background: var(--border);
  margin: 0.5rem 1rem;
}


/* Main Content Area */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
  overflow: hidden;
  margin-left: var(--sidebar-width);
}

/* Theme toggle (mobile) */
.theme-toggle {
  background: transparent;
  border: none;
  padding: 0.5rem;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  border-radius: var(--radius-sm);
}

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

.theme-toggle svg {
  width: 18px;
  height: 18px;
}

/* Main Content */
main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1.5rem;
  background: var(--bg-primary);
  min-height: 0; /* Important for flex scrolling */
}

.container {
  max-width: 1100px;
  margin: 0 auto;
}

/* ==========================================================================
   Typography
   ========================================================================== */

h1, h2, h3, h4, h5, h6 {
  color: var(--text-primary);
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 0.5rem;
}

h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.125rem; }
h4 { font-size: 1rem; }

p {
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

small {
  color: var(--text-muted);
  font-size: 0.8125rem;
}

code {
  background: var(--bg-card);
  padding: 0.125rem 0.375rem;
  border-radius: 3px;
  font-size: 0.8125rem;
  font-family: 'SF Mono', Monaco, 'Courier New', monospace;
  color: var(--accent);
}

pre {
  background: var(--bg-card);
  padding: 1rem;
  border-radius: var(--radius);
  overflow-x: auto;
  border: 1px solid var(--border);
}

pre code {
  background: transparent;
  padding: 0;
  color: var(--text-primary);
}

/* ==========================================================================
   Cards
   ========================================================================== */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.card.card-light {
  background: var(--bg-card-light, rgba(255, 255, 255, 0.06));
  border-color: var(--border-light);
}

.card.card-light .card-header {
  background: rgba(255, 255, 255, 0.04);
  border-bottom-color: var(--border-light);
}

.card.card-light .card-body {
  background: transparent;
}

.card-header {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}

.card-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0;
}

.card-body {
  padding: 1rem;
}

.card-footer {
  padding: 1rem;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ==========================================================================
   Tables
   ========================================================================== */

.table-container {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 0.2rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.table th {
  font-weight: 500;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: var(--bg-secondary);
}

.table tbody tr {
  transition: background 0.15s ease;
}

.table tbody tr:hover {
  background: var(--bg-card-hover);
}

.table td {
  font-size: 1.125rem;
}

.table td a {
  color: var(--text-primary);
}

.table td a:hover {
  color: var(--accent);
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 0.8125rem;
  cursor: pointer;
  transition: all 0.15s ease;
  border: none;
  text-decoration: none;
}

.btn:hover {
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover {
  background: var(--accent-hover);
  color: white;
}

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

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

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover {
  background: var(--danger-hover);
  color: white;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
}

.btn-outline:hover {
  background: var(--accent);
  color: white;
}

.btn-sm {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
}

.btn-lg {
  padding: 0.625rem 1.25rem;
  font-size: 0.875rem;
}

.btn:disabled,
.btn[aria-busy="true"] {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ==========================================================================
   Status Badges
   ========================================================================== */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.1875rem 0.5rem;
  border-radius: 3px;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.badge-created {
  background: rgba(107, 114, 128, 0.2);
  color: var(--status-created);
}

.badge-analyzing {
  background: rgba(0, 120, 212, 0.2);
  color: var(--status-analyzing);
}

.badge-analyzed {
  background: rgba(16, 185, 129, 0.2);
  color: var(--status-analyzed);
}

.badge-fixing {
  background: rgba(245, 158, 11, 0.2);
  color: var(--status-fixing);
}

.badge-testing {
  background: rgba(139, 92, 246, 0.2);
  color: var(--status-testing);
}

.badge-fixed {
  background: rgba(5, 150, 105, 0.2);
  color: var(--status-fixed);
}

.badge-blocked {
  background: rgba(217, 119, 6, 0.2);
  color: var(--status-blocked);
}

.badge-completed {
  background: rgba(34, 197, 94, 0.2);
  color: var(--status-completed);
}

.badge-failed {
  background: rgba(239, 68, 68, 0.2);
  color: var(--status-failed);
}

/* Ticket type badges */
.badge-bug {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

.badge-feature {
  background: rgba(139, 92, 246, 0.15);
  color: #8b5cf6;
}

.badge-task {
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
}

.badge-chore {
  background: rgba(245, 158, 11, 0.15);
  color: #d97706;
}

/* ==========================================================================
   Feature Progress
   ========================================================================== */

.feature-progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.feature-progress-bar-container {
  background: var(--bg-secondary);
  border-radius: 6px;
  height: 10px;
  overflow: hidden;
  margin: 0.75rem 0;
}

.feature-progress-bar-fill {
  height: 100%;
  border-radius: 6px;
  background: var(--status-completed);
  transition: width 0.5s ease;
}

.feature-progress-stats {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.feature-progress-stat {
  text-align: center;
}

.feature-progress-stat-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.feature-progress-stat-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.wave-section {
  margin-bottom: 1rem;
}

.wave-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
  cursor: pointer;
  user-select: none;
}

.wave-header h4 {
  margin: 0;
  font-size: 0.9rem;
}

.wave-header .wave-badge {
  font-size: 0.65rem;
}

.wave-tickets {
  padding-left: 0.5rem;
}

.wave-ticket-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

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

.wave-ticket-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wave-ticket-title a {
  color: var(--text-primary);
}

.wave-ticket-title a:hover {
  color: var(--accent);
}

/* Feature compact progress (for dashboard) */
.feature-compact {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.feature-compact:last-child {
  border-bottom: none;
}

.feature-compact-info {
  flex: 1;
  min-width: 0;
}

.feature-compact-title {
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.feature-compact-title a {
  color: inherit;
}

.feature-compact-title a:hover {
  color: var(--accent);
}

.feature-compact-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.feature-compact-progress {
  width: 120px;
  flex-shrink: 0;
}

.feature-compact-bar {
  height: 6px;
  background: var(--bg-secondary);
  border-radius: 3px;
  overflow: hidden;
}

.feature-compact-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--status-completed);
  transition: width 0.3s ease;
}

.feature-compact-pct {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-align: right;
  margin-top: 0.125rem;
}

/* ==========================================================================
   Forms
   ========================================================================== */

.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  margin-bottom: 0.375rem;
  font-weight: 500;
  font-size: 0.8125rem;
  color: var(--text-primary);
}

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.875rem;
  transition: all 0.15s ease;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  outline: none;
  border-color: var(--accent);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-muted);
}

.form-textarea {
  min-height: 100px;
  resize: vertical;
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239ca3af'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  background-size: 1rem;
  padding-right: 2rem;
}

/* ==========================================================================
   Page Header
   ========================================================================== */

.page-header {
  margin-bottom: 1.5rem;
}

.page-header h1 {
  margin-bottom: 0.25rem;
}

.page-header p {
  color: var(--text-muted);
  margin-bottom: 0;
  font-size: 0.875rem;
}

.page-header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
}

/* ==========================================================================
   Breadcrumb
   ========================================================================== */

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  list-style: none;
  margin-bottom: 1rem;
  font-size: 0.8125rem;
}

.breadcrumb li {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.breadcrumb li:not(:last-child)::after {
  content: '/';
  color: var(--text-muted);
}

.breadcrumb a {
  color: var(--text-muted);
}

.breadcrumb a:hover {
  color: var(--accent);
}

.breadcrumb li:last-child {
  color: var(--text-primary);
}

/* ==========================================================================
   Timeline (Ticket Detail)
   ========================================================================== */

.timeline {
  position: relative;
}

.timeline-item {
  position: relative;
  padding: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
}

.timeline-item.user-message {
  border-left: 3px solid var(--accent);
}

.timeline-item.assistant-message {
  border-left: 3px solid var(--status-analyzed);
  background: var(--bg-secondary);
}

.timeline-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.timeline-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  background: var(--accent-light);
}

.timeline-meta {
  flex: 1;
}

.timeline-author {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.8125rem;
}

.timeline-time {
  font-size: 0.6875rem;
  color: var(--text-muted);
}

.timeline-content {
  color: var(--text-secondary);
  font-size: 0.875rem;
  line-height: 1.6;
}

.timeline-actions {
  padding: 1rem;
  background: var(--bg-secondary);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
  text-align: center;
}

/* ==========================================================================
   Stream Output
   ========================================================================== */

.stream-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
}

.stream-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

.stream-output {
  padding: 0.75rem 1rem;
  font-family: 'SF Mono', Monaco, 'Courier New', monospace;
  font-size: 0.8125rem;
  white-space: pre-wrap;
  word-wrap: break-word;
  max-height: 350px;
  overflow-y: auto;
  color: var(--text-secondary);
}

.stream-output .conversation-text {
  font-weight: 600;
  color: var(--text-primary);
}

.stream-output .action-line {
  color: var(--text-muted);
  font-style: italic;
}

/* ==========================================================================
   Statistics Grid
   ========================================================================== */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.75rem;
}

.stat-item {
  text-align: center;
  padding: 0.75rem;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
}

.stat-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.125rem;
}

/* ==========================================================================
   Empty State
   ========================================================================== */

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  background: var(--bg-card);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.empty-state-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  opacity: 0.5;
}

.empty-state h3 {
  margin-bottom: 0.375rem;
  font-size: 1rem;
}

.empty-state p {
  color: var(--text-muted);
  margin-bottom: 1rem;
  font-size: 0.875rem;
}

/* ==========================================================================
   Danger Zone
   ========================================================================== */

.danger-zone {
  margin-top: 1.5rem;
  padding: 1rem;
  background: rgba(239, 68, 68, 0.05);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: var(--radius);
}

.danger-zone summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--danger);
}

.danger-zone[open] summary {
  margin-bottom: 0.75rem;
}

/* ==========================================================================
   Markdown Content
   ========================================================================== */

.markdown-content {
  color: var(--text-secondary);
  line-height: 1.6;
}

.markdown-content h1,
.markdown-content h2,
.markdown-content h3 {
  margin-top: 1.25rem;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.markdown-content h1 { font-size: 1.25rem; }
.markdown-content h2 { font-size: 1.125rem; }
.markdown-content h3 { font-size: 1rem; }

.markdown-content p {
  margin-bottom: 0.75rem;
}

.markdown-content ul,
.markdown-content ol {
  margin-bottom: 0.75rem;
  padding-left: 1.25rem;
}

.markdown-content li {
  margin-bottom: 0.375rem;
}

.markdown-content pre {
  margin: 0.75rem 0;
}

.markdown-content code {
  font-size: 0.8125rem;
}

.markdown-content blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 0.75rem;
  margin: 0.75rem 0;
  color: var(--text-muted);
  font-style: italic;
}

/* ==========================================================================
   Modal/Dialog
   ========================================================================== */

dialog.modal {
  padding: 0;
  margin: auto;
  border: none;
  border-radius: var(--radius);
  background: var(--bg-card);
  box-shadow: var(--shadow-lg);
}

dialog.modal::backdrop {
  background: rgba(0, 0, 0, 0.5);
}

.dir-item {
  cursor: pointer;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s ease;
  font-size: 0.875rem;
}

.dir-item:hover {
  background: var(--bg-card-hover);
}

.git-indicator {
  background: var(--accent);
  color: white;
  padding: 0.375rem 0.5rem;
  margin-bottom: 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
}

/* ==========================================================================
   HTMX Loading States
   ========================================================================== */

.htmx-request {
  opacity: 0.7;
  pointer-events: none;
}

.htmx-indicator {
  display: none;
}

.htmx-request .htmx-indicator {
  display: inline;
}

/* Loading spinner */
[aria-busy="true"]::before {
  content: '';
  display: inline-block;
  width: 0.875em;
  height: 0.875em;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-right: 0.375rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ==========================================================================
   Utilities
   ========================================================================== */

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--status-completed); }
.text-danger { color: var(--danger); }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }

.hidden { display: none; }

/* ==========================================================================
   Responsive
   ========================================================================== */

/* Mobile Header */
.mobile-header {
  display: none;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1rem;
  align-items: center;
  justify-content: space-between;
}

.mobile-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-primary);
  font-weight: 600;
  font-size: 0.875rem;
}

.mobile-brand img {
  height: 26px;
  width: auto;
}

.mobile-header-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* Mobile nav */
.mobile-nav {
  display: none;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 0 1rem 0.5rem;
}

.mobile-nav-links {
  display: flex;
  gap: 0.25rem;
  list-style: none;
  overflow-x: auto;
}

.mobile-nav-links a {
  padding: 0.375rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.8125rem;
  white-space: nowrap;
}

.mobile-nav-links a:hover {
  background: var(--accent-light);
  color: var(--accent);
  text-decoration: none;
}

@media (max-width: 768px) {
  .sidebar {
    display: none;
  }

  .main-wrapper {
    margin-left: 0;
  }

  .mobile-header {
    display: flex;
  }

  .mobile-nav {
    display: block;
  }

  main {
    padding: 1rem;
  }

  .page-header-actions {
    flex-direction: column;
    align-items: stretch;
  }

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

  h1 { font-size: 1.25rem; }
  h2 { font-size: 1.125rem; }
}

/* ==========================================================================
   Sidebar User Section
   ========================================================================== */

.sidebar-user {
  margin-top: auto;
  padding: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.sidebar-user-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}

.sidebar-user-name {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-badge {
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  background: var(--accent-light);
  padding: 0.125rem 0.375rem;
  border-radius: var(--radius-sm);
  width: fit-content;
}

.sidebar-logout-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.sidebar-logout-btn:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: white;
}

.sidebar-logout-btn svg {
  width: 18px;
  height: 18px;
}

/* Ensure sidebar-content can flex properly */
.sidebar-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow-y: auto;
}
