/*
 * Mission Control — Design System
 * Golden source of truth for all dashboard sections (Tasks, KB, Ideas)
 * 
 * Decisions:
 *   Font: Helvetica Neue (system, no CDN dependency)
 *   Color: Electric Blue #2563eb
 *   Scale: Medium (16px body, 44px stats)
 *   Source: proposal-3-golden.html (2026-02-18)
 *
 * Usage: @import url('./design-system.css');
 * Change tokens here → changes everywhere.
 */

/* ========================================
   DATE PICKER (inlined from date-picker.css)
   ======================================== */
/* ========================================
   DATE PICKER COMPONENT
   Based on Aria's UX Research (doc_0fa0fa2858fc)
   Pattern: Preset chips + calendar popup
   Library: react-day-picker (headless CSS)
   ======================================== */

/* --- Container --- */
.date-picker {
  position: relative;
  display: inline-flex;
  flex-direction: column;
}

.date-picker--block {
  display: flex;
  width: 100%;
}

/* --- Trigger Button --- */
.date-picker-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  min-width: 160px;
  padding: 0 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-family: var(--font-body);
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.1s ease, box-shadow 0.1s ease;
  outline: none;
  text-align: left;
  white-space: nowrap;
}

.date-picker-trigger:hover {
  border-color: var(--accent-light);
}

.date-picker-trigger:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}

.date-picker-trigger[aria-expanded="true"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}

.date-picker-trigger--error {
  border-color: var(--error);
}

.date-picker-trigger--error:focus-visible {
  box-shadow: 0 0 0 3px var(--error-bg);
}

.date-picker-trigger:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: var(--surface-subtle);
}

.date-picker-trigger-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.date-picker-trigger-placeholder {
  color: var(--dim);
}

.date-picker-trigger-icon {
  flex-shrink: 0;
  font-size: 16px;
  color: var(--dim);
  transition: color 0.1s ease;
}

.date-picker-trigger:hover .date-picker-trigger-icon {
  color: var(--accent);
}

/* --- Clear Button --- */
.date-picker-clear {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--dim);
  font-size: 12px;
  cursor: pointer;
  transition: color 0.1s ease, background 0.1s ease;
}

.date-picker-clear:hover {
  color: var(--text);
  background: var(--surface-hover);
}

/* --- Range display --- */
.date-picker-trigger--range {
  min-width: 240px;
}

/* --- Popup (Desktop) --- */
.date-picker-popup {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 1000;
  display: flex;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity 150ms ease-out, transform 150ms ease-out;
}

.date-picker-popup[data-open="true"],
.date-picker-popup.open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* --- Backdrop (optional overlay) --- */
.date-picker-backdrop {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: transparent;
}

/* --- Preset Sidebar --- */
.date-picker-presets {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px;
  width: 140px;
  border-right: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}

.date-picker-preset {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  border: none;
  border-radius: calc(var(--radius-sm) - 2px);
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-body);
  cursor: pointer;
  transition: background 0.1s ease, color 0.1s ease;
  text-align: left;
  white-space: nowrap;
}

.date-picker-preset:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.date-picker-preset.active {
  background: var(--accent-bg);
  color: var(--accent);
  font-weight: 600;
}

.date-picker-preset:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* --- Calendar Container --- */
.date-picker-calendar {
  padding: 16px;
  min-width: 300px;
}

/* Popup with presets: total ~620px */
.date-picker-popup--with-presets .date-picker-calendar {
  min-width: 460px;
}

/* --- Calendar Navigation --- */
.date-picker-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.date-picker-nav-title {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.date-picker-nav-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius-sm) - 2px);
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.1s ease;
}

.date-picker-nav-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-bg);
}

.date-picker-nav-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.date-picker-nav-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  pointer-events: none;
}

/* --- Weekday Headers --- */
.date-picker-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin-bottom: 4px;
}

.date-picker-weekday {
  font-size: 11px;
  font-weight: 700;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-align: center;
  padding: 4px 0;
}

/* --- Calendar Grid --- */
.date-picker-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

/* --- Calendar Cells --- */
.date-picker-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: calc(var(--radius-sm) - 2px);
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-body);
  cursor: pointer;
  transition: background 0.1s ease, color 0.1s ease;
  position: relative;
  outline: none;
}

.date-picker-cell:hover {
  background: var(--surface-hover);
}

.date-picker-cell:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* Today */
.date-picker-cell--today {
  font-weight: 700;
  color: var(--accent);
}

.date-picker-cell--today::after {
  content: '';
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
}

/* Selected */
.date-picker-cell--selected {
  background: var(--accent);
  color: var(--text-inverse);
  font-weight: 600;
  transition: background 200ms ease-out;
}

.date-picker-cell--selected:hover {
  background: var(--accent-strong);
}

.date-picker-cell--selected::after {
  display: none;
}

/* Range selection */
.date-picker-cell--range-start {
  background: var(--accent);
  color: var(--text-inverse);
  border-radius: calc(var(--radius-sm) - 2px) 0 0 calc(var(--radius-sm) - 2px);
}

.date-picker-cell--range-end {
  background: var(--accent);
  color: var(--text-inverse);
  border-radius: 0 calc(var(--radius-sm) - 2px) calc(var(--radius-sm) - 2px) 0;
}

.date-picker-cell--range-middle {
  background: var(--accent-bg);
  color: var(--accent);
  border-radius: 0;
}

.date-picker-cell--range-middle:hover {
  background: var(--accent-bg);
  filter: brightness(0.95);
}

/* Disabled */
.date-picker-cell--disabled {
  color: var(--dim);
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

/* Outside month */
.date-picker-cell--outside {
  color: var(--dim);
  opacity: 0.4;
}

/* --- Error State --- */
.date-picker--error .date-picker-trigger {
  border-color: var(--error);
}

.date-picker-error-msg {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: 12px;
  color: var(--error);
  font-weight: 500;
  margin-top: 4px;
}

/* --- Loading State --- */
.date-picker--loading .date-picker-calendar {
  position: relative;
}

.date-picker--loading .date-picker-grid {
  opacity: 0.4;
  pointer-events: none;
}

.date-picker-loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.date-picker-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: date-picker-spin 0.6s linear infinite;
}

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

/* --- Footer (Apply/Cancel for ranges) --- */
.date-picker-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

/* --- Responsive: Mobile Bottom Sheet --- */

/* --- High Contrast Mode --- */
@media (forced-colors: active) {
  .date-picker-trigger {
    border: 2px solid ButtonText;
  }

  .date-picker-cell--selected {
    background: Highlight;
    color: HighlightText;
    forced-color-adjust: none;
  }

  .date-picker-cell:focus-visible {
    outline: 2px solid Highlight;
  }
}

/* --- RTL Support --- */
[dir="rtl"] .date-picker-presets {
  border-right: none;
  border-left: 1px solid var(--border);
}

[dir="rtl"] .date-picker-popup {
  left: auto;
  right: 0;
}

[dir="rtl"] .date-picker-cell--range-start {
  border-radius: 0 calc(var(--radius-sm) - 2px) calc(var(--radius-sm) - 2px) 0;
}

[dir="rtl"] .date-picker-cell--range-end {
  border-radius: calc(var(--radius-sm) - 2px) 0 0 calc(var(--radius-sm) - 2px);
}

/* --- react-day-picker Integration Classes --- */
/* Map react-day-picker's default classes to our design tokens */
.rdp-root {
  --rdp-accent-color: var(--accent);
  --rdp-accent-background-color: var(--accent-bg);
}

.rdp-day { composes: date-picker-cell; }
.rdp-day_today { composes: date-picker-cell--today; }
.rdp-day_selected { composes: date-picker-cell--selected; }
.rdp-day_disabled { composes: date-picker-cell--disabled; }
.rdp-day_outside { composes: date-picker-cell--outside; }
.rdp-day_range_start { composes: date-picker-cell--range-start; }
.rdp-day_range_end { composes: date-picker-cell--range-end; }
.rdp-day_range_middle { composes: date-picker-cell--range-middle; }


/* ========================================
   PRINT STYLES - Simplified with JavaScript Control
   ======================================== */

@media print {
  /* Hide UI elements that shouldn't print */
  .sidebar,
  .bottom-nav,
  .app-header,
  .fab,
  .skip-link,
  .kb-detail-header,
  .kb-doc-search-bar,
  .kb-detail-toc,
  .code-copy-btn,
  .toolbar-btn {
    display: none !important;
  }

  /* Global container reset for print */
  html, 
  body, 
  #root,
  .app-shell,
  .main,
  .kb-view {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    background: white !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  /* Modal optimization when print-ready class is present */
  .kb-detail-overlay.print-ready {
    position: static !important;
    background: white !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    z-index: auto !important;
  }

  .kb-detail-overlay.print-ready .kb-detail-panel {
    display: block !important;
    position: static !important;
    background: white !important;
    height: auto !important;
    overflow: visible !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    box-shadow: none !important;
    width: 100% !important;
    flex: none !important;
  }

  .kb-detail-overlay.print-ready .kb-detail-body-wrapper {
    display: block !important;
    height: auto !important;
    overflow: visible !important;
    flex: none !important;
  }

  .kb-detail-overlay.print-ready .kb-detail-main {
    display: block !important;
    background: white !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    padding: 20px !important;
    margin: 0 !important;
    border: none !important;
    box-shadow: none !important;
    width: 100% !important;
    flex: none !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif !important;
    font-size: 12pt !important;
    line-height: 1.4 !important;
    color: black !important;
  }

  /* Professional Typography Hierarchy */
  .kb-detail-overlay.print-ready .kb-detail-main h1 { 
    font-size: 20pt !important; margin: 0 0 12pt 0 !important; font-weight: 700 !important;
    page-break-after: avoid !important; color: #2c3e50 !important;
  }
  .kb-detail-overlay.print-ready .kb-detail-main h2 { 
    font-size: 16pt !important; margin: 16pt 0 10pt 0 !important; font-weight: 600 !important;
    page-break-after: avoid !important; color: #34495e !important;
  }
  .kb-detail-overlay.print-ready .kb-detail-main h3 { 
    font-size: 14pt !important; margin: 12pt 0 8pt 0 !important; font-weight: 600 !important;
    page-break-after: avoid !important; color: #34495e !important;
  }
  .kb-detail-overlay.print-ready .kb-detail-main h4,
  .kb-detail-overlay.print-ready .kb-detail-main h5,
  .kb-detail-overlay.print-ready .kb-detail-main h6 { 
    font-size: 12pt !important; margin: 10pt 0 6pt 0 !important; font-weight: 600 !important;
    page-break-after: avoid !important; color: #34495e !important;
  }

  /* Content formatting */
  .kb-detail-overlay.print-ready .kb-detail-main p { 
    margin: 0 0 8pt 0 !important; page-break-inside: avoid !important; text-align: justify !important;
  }
  .kb-detail-overlay.print-ready .kb-detail-main pre {
    background: #f8f9fa !important; border: 1px solid #dee2e6 !important;
    border-left: 3px solid #007bff !important; padding: 8pt !important;
    margin: 8pt 0 !important; page-break-inside: avoid !important;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace !important;
    font-size: 10pt !important; overflow: visible !important; white-space: pre-wrap !important;
  }
  .kb-detail-overlay.print-ready .kb-detail-main code {
    background: #f1f3f5 !important; padding: 1pt 3pt !important;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace !important; font-size: 10pt !important;
  }
  .kb-detail-overlay.print-ready .kb-detail-main table {
    border-collapse: collapse !important; width: 100% !important;
    margin: 8pt 0 !important; page-break-inside: avoid !important;
  }
  .kb-detail-overlay.print-ready .kb-detail-main th,
  .kb-detail-overlay.print-ready .kb-detail-main td {
    border: 1px solid #dee2e6 !important; padding: 6pt 8pt !important;
    text-align: left !important; font-size: 11pt !important;
  }
  .kb-detail-overlay.print-ready .kb-detail-main th {
    background: #f8f9fa !important; font-weight: 600 !important;
  }
  .kb-detail-overlay.print-ready .kb-detail-main ul,
  .kb-detail-overlay.print-ready .kb-detail-main ol {
    margin: 6pt 0 !important; padding-left: 20pt !important;
  }
  .kb-detail-overlay.print-ready .kb-detail-main li {
    margin: 0 0 3pt 0 !important; line-height: 1.3 !important;
  }
  .kb-detail-overlay.print-ready .kb-detail-main blockquote {
    border-left: 4px solid #007bff !important; padding-left: 12pt !important;
    margin: 8pt 0 !important; color: #6c757d !important;
    font-style: italic !important; page-break-inside: avoid !important;
  }
  .kb-detail-overlay.print-ready .kb-detail-main img {
    max-width: 100% !important; height: auto !important;
    page-break-inside: avoid !important; display: block !important; margin: 8pt auto !important;
  }

  /* Remove visual effects */
  * {
    box-shadow: none !important; border-radius: 0 !important;
    text-shadow: none !important; background-image: none !important;
  }
}

/* ========================================
   1. TOKENS (Design Variables)
   ======================================== */

:root {
  /* Colors — Background */
  --bg: #e8edf7;
  --card: #ffffff;
  --border: rgba(12, 24, 44, 0.1);

  /* Colors — Sidebar */
  --sidebar-bg: #08111f;
  --sidebar-text: #88a0c4;
  --sidebar-active: rgba(56, 189, 248, 0.15);

  /* Colors — Text */
  --text: #0f172a;
  --muted: #475569;
  --dim: #64748b;

  /* Colors — Primary */
  --accent: #0ea5e9;
  --accent-light: #38bdf8;
  --accent-strong: #0284c7;
  --accent-bg: rgba(14, 165, 233, 0.14);

  /* Colors — Secondary */
  --cyan: #06b6d4;
  --cyan-bg: rgba(6,182,212,0.08);
  --purple: #a855f7;
  --purple-bg: rgba(168,85,247,0.15);
  --orange: #f97316;
  --orange-bg: rgba(249,115,22,0.15);

  /* Colors — Semantic */
  --success: #10b981;
  --success-strong: #059669;
  --success-bg: rgba(16,185,129,0.08);
  --success-border: rgba(16,185,129,0.3);
  --warning: #f59e0b;
  --warning-strong: #d97706;
  --warning-bg: rgba(245,158,11,0.08);
  --warning-border: rgba(245,158,11,0.3);
  --error: #f43f5e;
  --error-strong: #dc2626;
  --error-bg: rgba(244,63,94,0.08);
  --error-border: rgba(244,63,94,0.3);
  --neutral-bg: rgba(100,116,139,0.08);
  --overlay: rgba(15,23,42,0.6);
  --overlay-soft: rgba(15,23,42,0.1);
  --surface-subtle: #eef6ff;
  --text-inverse: #ffffff;
  --sidebar-border: rgba(255,255,255,0.08);
  --sidebar-hover: rgba(255,255,255,0.06);
  --sidebar-strong: #e7f0ff;

  /* Color aliases used by app sections */
  --surface: var(--card);
  --surface-hover: var(--neutral-bg);
  --text-secondary: var(--muted);
  --text-muted: var(--muted);
  --accent-muted: var(--accent-bg);
  --priority-urgent: var(--error);
  --priority-high: var(--warning);
  --priority-medium: var(--accent);
  --priority-low: var(--dim);

  /* Agent signature colors */
  --agent-nix: #06b6d4;
  --agent-byte: #a855f7;
  --agent-scout: #10b981;
  --agent-sentinel: #ef4444;
  --agent-quill: #f59e0b;
  --agent-cipher: #3b82f6;
  --agent-pixel: #ec4899;
  --agent-aria: #8b5cf6;
  --agent-vinyl: #f97316;

  /* Radius */
  --radius: 8px;
  --radius-md: 6px;
  --radius-sm: 4px;

  /* Shadows */
  --shadow: 0 4px 20px rgba(8, 17, 31, 0.08);
  --shadow-lg: 0 12px 40px rgba(8, 17, 31, 0.18);

  /* Typography */
  --font-display: 'Helvetica Neue', Helvetica, Arial, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-heading: 'Helvetica Neue', Helvetica, Arial, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-body: 'Helvetica Neue', Helvetica, Arial, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
  --font-sm: 13px;
  --font-ui: 14px;
  --font-modal-title: 18px;
  --font-label: 12px;
  --font-section-label: 11px;
  --font-micro: 10px;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --space-3xl: 64px;
  --space-gap: 20px;       /* gap entre cards del mismo grupo */
  --space-section: 40px;   /* margen entre secciones del dashboard */
}

:root.dark {
  /* Backgrounds — Night Operations */
  --bg: #0a0e17;
  --card: #0f1520;
  --card-elevated: #141c2b;
  --border: rgba(56, 189, 248, 0.08);

  --sidebar-bg: #060a12;
  --sidebar-text: #8b9dc3;
  --sidebar-active: rgba(56, 189, 248, 0.15);

  --text: #e8edf5;
  --muted: #8b9dc3;
  --dim: #4a5568;

  /* Primary accent — Cyan */
  --accent: #38bdf8;
  --accent-light: #7dd3fc;
  --accent-strong: #0ea5e9;
  --accent-bg: rgba(56, 189, 248, 0.1);
  --accent-glow: 0 0 20px rgba(56, 189, 248, 0.15);

  --cyan: #22d3ee;
  --cyan-bg: rgba(34,211,238,0.12);
  --purple: #c084fc;
  --purple-bg: rgba(192,132,252,0.14);
  --orange: #fb923c;
  --orange-bg: rgba(251,146,60,0.14);

  /* Signal colors */
  --success: #4ade80;
  --success-strong: #22c55e;
  --success-bg: rgba(74,222,128,0.12);
  --success-border: rgba(74,222,128,0.3);
  --warning: #fbbf24;
  --warning-strong: #f59e0b;
  --warning-bg: rgba(251,191,36,0.12);
  --warning-border: rgba(251,191,36,0.3);
  --error: #f87171;
  --error-strong: #ef4444;
  --error-bg: rgba(248,113,113,0.12);
  --error-border: rgba(248,113,113,0.3);
  --neutral-bg: rgba(148,163,184,0.1);
  --overlay: rgba(2,6,23,0.85);
  --overlay-soft: rgba(2,6,23,0.4);
  --surface-subtle: rgba(56, 189, 248, 0.04);
  --text-inverse: #ffffff;
  --sidebar-border: rgba(56, 189, 248, 0.06);
  --sidebar-hover: rgba(56, 189, 248, 0.08);
  --sidebar-strong: #e8edf5;

  --surface: var(--card);
  --surface-hover: var(--neutral-bg);
  --text-secondary: var(--muted);
  --text-muted: var(--muted);
  --accent-muted: var(--accent-bg);
  --priority-urgent: var(--error);
  --priority-high: var(--warning);
  --priority-medium: var(--accent);
  --priority-low: var(--dim);

  --shadow: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.6);

  /* Agent signature colors */
  --agent-nix: #38bdf8;
  --agent-byte: #a78bfa;
  --agent-scout: #34d399;
  --agent-sentinel: #f87171;
  --agent-quill: #fbbf24;
  --agent-cipher: #60a5fa;
  --agent-pixel: #f472b6;
  --agent-aria: #c084fc;
  --agent-vinyl: #fb923c;
}

/* ========================================
   2. RESET & BASE
   ======================================== */

* { margin: 0; padding: 0; box-sizing: border-box; }
html, #root {
  overflow-x: hidden;
  overflow-y: hidden;
}

body {
  overflow-x: hidden;
  overflow-y: auto;
}

html, body, #root {
  min-height: 100vh;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  font-size: 16px;
  line-height: 1.65;
}

:focus-visible {
  outline: 2px solid var(--accent-light);
  outline-offset: 2px;
}

/* ========================================
   3. LAYOUT — Sidebar
   ======================================== */

.sidebar {
  width: 220px;
  background: var(--sidebar-bg);
  padding: 28px 16px;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 10;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.sidebar-logo {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-inverse);
  padding: 0 12px 32px;
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: -0.02em;
}
.sidebar-logo span { font-size: 20px; }
.sidebar-logo-icon { width: 20px; height: 20px; flex-shrink: 0; display: block; margin-top: 2px; }

.sidebar-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--sidebar-text);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 20px 12px 10px;
  opacity: 0.7;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  text-decoration: none;
  font-weight: 500;
  font-size: 13px;
  transition: all 0.2s;
}
.sidebar-nav a:hover { background: var(--sidebar-hover); color: var(--sidebar-strong); }
.sidebar-nav a.active { background: var(--sidebar-active); color: var(--text-inverse); }
.sidebar-nav a .icon { width: 18px; text-align: center; font-size: 15px; }

.agent-nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border-left: 2px solid transparent;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}

.agent-nav-item:hover {
  background: var(--sidebar-hover);
  transform: translateX(2px);
}

.agent-nav-item.has-work {
  border-left-color: var(--agent-color);
}

.agent-emoji {
  font-size: 14px;
}

.agent-nav-item .agent-name {
  font-size: 12px;
  color: var(--sidebar-strong);
  flex: 1;
}

.agent-nav-item .task-count {
  font-size: 11px;
  opacity: 0.85;
  font-family: var(--font-display);
}

@keyframes sidebarPulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

.sidebar-bottom {
  margin-top: auto;
  border-top: 1px solid var(--sidebar-border);
  padding-top: 16px;
}
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 8px 12px; }
.sidebar-user-av {
  width: 32px; height: 32px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--cyan));
  display: flex; align-items: center; justify-content: center;
  color: var(--text-inverse); font-weight: 700; font-size: 12px;
}
.sidebar-user-info { flex: 1; }
.sidebar-user-name { color: var(--sidebar-strong); font-size: 13px; font-weight: 600; }
.sidebar-user-role { color: var(--sidebar-text); font-size: 11px; }

/* ========================================
   4. LAYOUT — Main & Topbar
   ======================================== */

.main {
  margin-left: 220px;
  flex: 1;
  height: 100vh;
  overflow-y: scroll;
  overflow-x: hidden;
  scrollbar-gutter: stable;
}

.topbar {
  padding: 24px 40px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar-title {
  font-family: var(--font-heading);
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.topbar-search {
  display: flex;
  align-items: center;
  background: var(--card);
  border: none;
  border-radius: var(--radius-md);
  padding: 10px 18px;
  gap: 10px;
  width: 320px;
  box-shadow: var(--shadow);
}
.topbar-search input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 13px;
  color: var(--text);
  flex: 1;
  font-family: var(--font-body);
  font-weight: 400;
}
.topbar-search input::placeholder { color: var(--dim); }

.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-icon {
  width: 38px; height: 38px;
  border-radius: var(--radius-sm);
  background: var(--card);
  border: none;
  box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 16px;
  color: var(--text);
  font-family: inherit;
  position: relative;
}
.topbar-icon:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}
.topbar-icon .dot {
  width: 8px; height: 8px;
  background: var(--error);
  border-radius: 50%;
  position: absolute; top: 6px; right: 6px;
  border: 2px solid var(--bg);
  animation: sidebarPulse 1.5s ease-in-out infinite;
}

/* Topbar theme toggle */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  background: color-mix(in srgb, var(--card) 88%, transparent);
  backdrop-filter: blur(6px);
  cursor: pointer;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--bg) 70%, #000000 25%);
  font-family: var(--font-body);
}

.theme-toggle:hover {
  border-color: var(--accent);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.theme-toggle[data-mode="dark"] {
  background: color-mix(in srgb, var(--accent) 18%, var(--card));
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}

.theme-icon {
  font-size: 14px;
  line-height: 1;
}

.theme-toggle-label {
  font-size: 13px;
  font-weight: 700;
}


.content { 
  padding: 32px 40px; 
  overflow: visible;
}
.content--narrow { max-width: 1000px; }

/* ── Layout utility: stack vertical de secciones con spacing uniforme ──
   Usar como contenedor raíz de cualquier vista. El gap controla el spacing;
   los hijos NO deben tener margin-bottom propio. */
.page-stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-section);
}

.page-stack > * {
  margin-bottom: 0 !important;
}

/* Shared section layout for full-height routed views */
.section-viewport {
  height: auto;
  overflow: visible;
}

.section-scroll {
  height: auto;
  overflow-y: visible;
}

.section-scroll--stable {
  scrollbar-gutter: auto;
}

.tasks-view,
.ideas-view,
.kb-view,
.ds-view {
  overflow: visible;
}

/* ========================================
   5. COMPONENTS — Section Title
   ======================================== */

.section-title {
  font-family: var(--font-heading);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 16px;
}

/* ========================================
   6. COMPONENTS — Stat Cards
   ======================================== */

.stat-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-gap);
  margin-bottom: var(--space-section);
}
.stat-cards--3 { grid-template-columns: repeat(3, 1fr); }
.stat-cards--2 { grid-template-columns: repeat(2, 1fr); }
.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
  min-height: 120px;
}
.stat-card--compact {
  border: 1px solid var(--border);
  border-left-width: 3px;
  padding: var(--space-md) 20px;
  min-height: 90px;
}
.stat-card--compact .value { font-size: 28px; }
.stat-card--compact .label { margin-bottom: var(--space-sm); }
.stat-card .label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
}
.stat-card .value {
  font-family: var(--font-display, var(--font-heading));
  font-size: 44px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.stat-card .sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
  font-weight: 500;
}
.stat-card .value.accent { color: var(--accent); }
.stat-card .value.cyan { color: var(--cyan); }
.stat-card .value.green { color: var(--success); }

/* ========================================
   7. COMPONENTS — Tabs
   ======================================== */

.tabs {
  display: inline-flex;
  background: var(--card);
  border-radius: var(--radius-md);
  padding: 4px;
  margin-bottom: var(--space-section);
  box-shadow: var(--shadow);
}
.tab {
  border: none;
  background: transparent;
  padding: 8px 24px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font-body);
}
.tab.active { background: var(--accent); color: var(--text-inverse); }

/* ========================================
   8. COMPONENTS — Table
   ======================================== */

.table-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: var(--space-section);
}
.table-top {
  padding: 20px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.table-top span {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 15px;
}

table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  padding: 12px 28px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border-bottom: 1px solid var(--border);
}
td {
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
}
tr:last-child td { border-bottom: none; }
tr:hover { background: var(--surface-subtle); }

.assignee { display: flex; align-items: center; gap: 10px; }
.assignee-av {
  width: 26px; height: 26px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
}

/* ========================================
   9. COMPONENTS — Badges
   ======================================== */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
}
.badge-success { background: var(--success-bg); color: var(--success-strong); }
.badge-warning { background: var(--warning-bg); color: var(--warning-strong); }
.badge-danger { background: var(--error-bg); color: var(--error); }
.badge-neutral { background: var(--neutral-bg); color: var(--muted); }
.badge-info { background: var(--accent-bg); color: var(--accent); }
.badge-cyan { background: var(--cyan-bg); color: var(--cyan); }
.badge-status-todo { background: var(--neutral-bg); color: var(--muted); }
.badge-status-assigned { background: var(--accent-bg); color: var(--accent); }
.badge-status-in_progress { background: var(--warning-bg); color: var(--warning-strong); }
.badge-status-done { background: var(--success-bg); color: var(--success-strong); }
.badge-priority-urgent { background: var(--error-bg); color: var(--error); }
.badge-priority-high { background: var(--warning-bg); color: var(--warning-strong); }
.badge-priority-medium { background: var(--accent-bg); color: var(--accent); }
.badge-priority-low { background: var(--neutral-bg); color: var(--muted); }

.priority-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.priority-urgent { background: var(--error); }
.priority-high { background: var(--warning); }
.priority-medium { background: var(--accent); }
.priority-low { background: var(--dim); }

/* ========================================
   10. COMPONENTS — Buttons
   ======================================== */

.btn-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: var(--space-section); }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 22px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
  transition: all 0.2s;
}
.clear-filters {
  padding: 6px 12px;
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid var(--error-border);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary { background: var(--accent); color: var(--text-inverse); }
.btn-primary:hover { background: var(--accent-strong); }
.btn-secondary { background: var(--card); color: var(--text); box-shadow: var(--shadow); }
.btn-secondary:hover { background: var(--surface-subtle); }
.btn-ghost { background: transparent; color: var(--accent); }
.btn-ghost:hover { background: var(--accent-bg); }
.btn-danger { background: var(--error); color: var(--text-inverse); }

.badge-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: var(--space-section); }

/* ========================================
   11. COMPONENTS — Search + Filters
   ======================================== */

.search-section {
  margin-bottom: var(--space-lg);
}

.search-box {
  display: flex;
  gap: var(--space-sm);
  background: var(--card);
  border-radius: var(--radius-md);
  padding: 12px var(--space-md);
  box-shadow: var(--shadow);
}

.search-box input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 16px;
  outline: none;
}

.search-box input::placeholder { color: var(--dim); }
.search-box button:active { transform: scale(0.97); }

.filters-row {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
  margin-top: 12px;
  align-items: center;
}

.filters-row select,
.filters-row input[type="date"] {
  padding: var(--space-sm) 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.filters-row select:focus,
.filters-row input[type="date"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}

.result-count {
  font-size: 13px;
  color: var(--dim);
}

/* ========================================
   12. COMPONENTS — Content Cards (KB & Ideas)
   ======================================== */

.cards-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-gap);
  margin-bottom: var(--space-section);
}

.kb-card, .idea-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: border-color .2s, box-shadow .2s, transform .15s;
}
.kb-card:hover {
  border-color: var(--accent);
  box-shadow: 0 8px 32px var(--accent-bg);
  transform: translateY(-2px);
}
.kb-card .kb-title, .idea-card .idea-title {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 6px;
  letter-spacing: -0.01em;
}
.kb-card .kb-meta, .idea-card .idea-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  font-size: 12px;
  color: var(--dim);
  margin-bottom: 12px;
}
.idea-card .idea-description {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.idea-card .idea-date { font-size: 11px; color: var(--dim); margin-top: 8px; }
.idea-card .idea-actions { display: flex; gap: var(--space-sm); margin-top: 12px; }
.idea-card .idea-actions button {
  padding: 6px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .15s;
}
.idea-card .idea-actions button:hover { transform: scale(1.05); }
.idea-card .idea-actions button.approve { background: var(--success-bg); color: var(--success); border-color: var(--success-border); }
.idea-card .idea-actions button.reject { background: var(--error-bg); color: var(--error); border-color: var(--error-border); }
.idea-card .idea-actions button.defer { background: var(--warning-bg); color: var(--warning-strong); border-color: var(--warning-border); }
.kb-card .kb-preview {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.7;
  margin-bottom: 14px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.kb-card .kb-date { font-size: 11px; color: var(--dim); margin-top: 8px; }
.kb-card .score { color: var(--warning-strong); background: var(--warning-bg); padding: 3px 10px; border-radius: 8px; font-size: 12px; font-weight: 600; }
.kb-tags, .idea-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.kb-tag {
  background: var(--bg);
  color: var(--muted);
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
}

/* ========================================
   13. COMPONENTS — Search Bar
   ======================================== */

.search-bar {
  display: flex;
  align-items: center;
  background: var(--card);
  border-radius: var(--radius-md);
  padding: 12px 20px;
  gap: 12px;
  margin-bottom: var(--space-section);
  max-width: 480px;
  box-shadow: var(--shadow);
}
.search-bar input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 14px;
  color: var(--text);
  flex: 1;
  font-family: var(--font-body);
}
.search-bar input::placeholder { color: var(--dim); }
.search-bar .shortcut {
  background: var(--bg);
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 11px;
  color: var(--dim);
  font-weight: 600;
}

/* ========================================
   14. COMPONENTS — Content Body (Markdown)
   ======================================== */

.content-body, .kb-content-body {
  background: var(--bg);
  padding: 28px 32px;
  border-radius: var(--radius);
  font-size: 16px;
  line-height: 1.65;
  color: var(--muted);
  overflow-y: auto;
  position: relative;
  font-family: var(--font-body);
  letter-spacing: 0.01em;
  font-weight: 400;
}

.content-body h1, .content-body h2, .content-body h3, .content-body h4,
.kb-content-body h1, .kb-content-body h2, .kb-content-body h3, .kb-content-body h4 {
  color: var(--text);
  margin-top: 1.8em;
  margin-bottom: .8em;
  line-height: 1.3;
  scroll-margin-top: 16px;
  font-weight: 700;
  font-family: var(--font-heading);
}

.content-body h1, .kb-content-body h1 {
  font-size: 1.5em;
  border-bottom: 1px solid var(--border);
  padding-bottom: .5em;
}

.content-body h2, .kb-content-body h2 {
  font-size: 1.25em;
  border-bottom: 1px solid var(--border);
  padding-bottom: .3em;
}

.content-body h3, .kb-content-body h3 { font-size: 1.1em; }
.content-body p, .kb-content-body p { margin: .8em 0; }
.content-body ul, .content-body ol, .kb-content-body ul, .kb-content-body ol { padding-left: 1.5em; margin: .8em 0; }
.content-body li, .kb-content-body li { margin: .3em 0; }

.content-body code, .kb-content-body code {
  background: var(--card);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font-mono);
  border: 1px solid var(--border);
}

.content-body pre, .kb-content-body pre {
  background: var(--card);
  padding: 16px 20px;
  border-radius: var(--radius-md);
  overflow-x: auto;
  margin: 1.2em 0;
  border: 1px solid var(--border);
  position: relative;
  font-family: var(--font-mono);
}

.content-body pre code, .kb-content-body pre code { background: none; padding: 0; font-size: 14px; border: none; }

.content-body blockquote, .kb-content-body blockquote {
  border-left: 3px solid var(--accent-light);
  margin: 1.2em 0;
  padding: .8em 1.2em;
  color: var(--dim);
  background: var(--card);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.content-body table, .kb-content-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.2em 0;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.content-body th, .content-body td, .kb-content-body th, .kb-content-body td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.content-body th, .kb-content-body th {
  background: var(--card);
  font-weight: 600;
  color: var(--text);
  font-family: var(--font-heading);
}

.content-body a, .kb-content-body a { color: var(--accent-light); text-decoration: none; }
.content-body a:hover, .kb-content-body a:hover { text-decoration: underline; }
.content-body hr, .kb-content-body hr { border: none; border-top: 1px solid var(--border); margin: 2em 0; }
.content-body img, .kb-content-body img { max-width: 100%; border-radius: var(--radius-sm); }
.content-body.raw-mode, .kb-content-body.raw-mode { white-space: pre-wrap; font-family: var(--font-body); font-size: 14px; }

/* ========================================
   14. COMPONENTS — Modal + Overlay
   ======================================== */

.overlay-backdrop {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  overflow-y: auto;
}
.overlay-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.overlay-panel--narrow { max-width: 600px; }
.overlay-panel--wide { max-width: 900px; }
.overlay-panel-header,
.overlay-panel-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px var(--space-lg);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.overlay-panel-actions {
  justify-content: flex-end;
  gap: var(--space-md);
  border-bottom: none;
  border-top: 1px solid var(--border);
}
.overlay-panel-body { padding: var(--space-lg); }

.modal-showcase { margin-bottom: var(--space-section); }
.modal-backdrop {
  background: var(--overlay-soft);
  border-radius: var(--radius);
  padding: 40px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  backdrop-filter: blur(4px);
}
.modal {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
}
.modal-header {
  padding: 24px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
}
.modal-close {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--bg);
  cursor: pointer;
  font-size: 16px;
  color: var(--muted);
  display: flex; align-items: center; justify-content: center;
}
.modal-body { padding: 0 28px 24px; }
.modal-body p {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.7;
  margin-bottom: 12px;
}
.modal-body p strong { color: var(--text); }
.modal-footer {
  padding: 16px 28px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ========================================
   15. COMPONENTS — Toast
   ======================================== */

.toast {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 24px;
  box-shadow: var(--shadow-lg);
  margin-bottom: var(--space-section);
}
.toast--fixed { position: fixed; bottom: var(--space-lg); right: var(--space-lg); z-index: 200; }
.toast--success { border-color: var(--success); color: var(--success-strong); background: var(--success-bg); }
.toast--error { border-color: var(--error); color: var(--error); background: var(--error-bg); }
.toast-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--success);
}

/* ========================================
   16. COMPONENTS — Empty State
   ======================================== */

.empty-state {
  background: var(--card);
  border-radius: var(--radius);
  padding: var(--space-3xl) 40px;
  text-align: center;
  box-shadow: var(--shadow);
  margin-bottom: var(--space-section);
}
.empty-state .empty-icon { font-size: 56px; margin-bottom: 16px; }
.empty-state .empty-title {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
}
.empty-state .empty-hint { font-size: 14px; color: var(--muted); }

/* ========================================
   17. COMPONENTS — Toolbar
   ======================================== */

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px var(--space-lg);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.toolbar-spacer {
  flex: 1;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.toolbar-label {
  font-size: 12px;
  color: var(--dim);
  white-space: nowrap;
}

.toolbar-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted);
  cursor: pointer;
  min-width: 36px;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all 0.15s;
}

.toolbar-btn:hover {
  border-color: var(--accent);
  color: var(--text);
  background: var(--surface-subtle);
}

.toolbar-btn.active {
  background: var(--accent-bg);
  border-color: var(--accent-light);
  color: var(--accent-light);
}

.toolbar-btn:disabled {
  opacity: 0.3;
  cursor: default;
  pointer-events: none;
}

/* ========================================
   18. COMPONENTS — Forms
   ======================================== */

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.form-input,
.form-select,
.form-textarea {
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-family: var(--font-body);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}

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

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

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-md);
}

.form-error {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: 12px;
  color: var(--error);
  font-weight: 500;
}

/* ========================================
   18. COMPONENTS — View Toggle
   ======================================== */

.view-toggle {
  display: flex;
  gap: 2px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
  width: fit-content;
}

.view-toggle-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: calc(var(--radius-sm) - 2px);
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all 0.2s;
}

.view-toggle-btn:hover {
  color: var(--text);
  background: var(--surface-subtle);
}

.view-toggle-btn.active {
  background: var(--accent);
  color: var(--text-inverse);
}

.view-toggle-icon {
  font-size: 14px;
}

/* ========================================
   19. COMPONENTS — FAB (Floating Action Button)
   ======================================== */

.fab {
  position: fixed;
  bottom: var(--space-lg);
  right: var(--space-lg);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--text-inverse);
  border: none;
  font-size: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  z-index: 50;
  transition: transform 0.15s, background 0.15s;
}

.fab:hover {
  transform: scale(1.1);
  background: var(--accent-strong);
}

.fab-icon {
  line-height: 1;
}

/* ========================================
   20. RESPONSIVE
   ======================================== */


/* ========================================
   SKELETON LOADING
   ======================================== */
@keyframes skeleton-shimmer {
  0% { background-position: -200px 0; }
  100% { background-position: calc(200px + 100%) 0; }
}

.skeleton-line {
  background: linear-gradient(90deg, var(--border) 25%, var(--surface-subtle, var(--card)) 50%, var(--border) 75%);
  background-size: 200px 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

.skeleton-value {
  height: 28px;
  width: 48px;
  margin-bottom: 4px;
}

.skeleton-text {
  height: 12px;
  width: 80%;
}

.skeleton-text--short {
  width: 40%;
}

.skeleton-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.skeleton-card .skeleton-title {
  height: 16px;
  width: 60%;
}

.skeleton-card .skeleton-meta {
  display: flex;
  gap: 8px;
}

.skeleton-card .skeleton-badge {
  height: 20px;
  width: 60px;
  border-radius: 10px;
}

.skeleton-card .skeleton-snippet {
  height: 12px;
  width: 90%;
}

.skeleton-card .skeleton-snippet:last-child {
  width: 70%;
}

.skeleton-bar {
  background: var(--surface-subtle);
  border-radius: 4px;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
}

.skeleton-badge {
  height: 20px;
  width: 60px;
  border-radius: 10px;
}

/* Skeleton Utility Classes */
.skeleton-text--h10 { height: 10px; }
.skeleton-text--h12 { height: 12px; }
.skeleton-text--h20 { height: 20px; }
.skeleton-text--w50 { width: 50px; }
.skeleton-text--w60 { width: 60%; }
.skeleton-text--w70 { width: 70%; }
.skeleton-text--mt6 { margin-top: 6px; }

/* Stat Card Color Modifiers */
.stat-card--accent { border-left-color: var(--accent); }
.stat-card--warning { border-left-color: var(--warning); }
.stat-card--success { border-left-color: var(--success); }

.text-warning { color: var(--warning); }
.text-dim { color: var(--dim); }

/* ========================================
   21. COMPONENTS — Date Picker 🆕
   Based on Aria's UX Research (Pattern 1: Preset chips + Calendar popup)
   Compatible with react-day-picker (headless CSS approach)
   Imported at top of file per CSS @import requirements.
   ======================================== */

/* ========================================
   22. AGENT COLOR SYSTEM
   ======================================== */

:root {
  --agent-nix: #0ea5e9;
  --agent-byte: #8b5cf6;
  --agent-scout: #10b981;
  --agent-sentinel: #ef4444;
  --agent-quill: #d97706;
  --agent-cipher: #3b82f6;
  --agent-pixel: #ec4899;
  --agent-aria: #a855f7;
  --agent-vinyl: #f97316;
}

/* Agent-aware utility classes */
.agent-nix { --agent-color: var(--agent-nix); }
.agent-byte { --agent-color: var(--agent-byte); }
.agent-scout { --agent-color: var(--agent-scout); }
.agent-sentinel { --agent-color: var(--agent-sentinel); }
.agent-quill { --agent-color: var(--agent-quill); }
.agent-cipher { --agent-color: var(--agent-cipher); }
.agent-pixel { --agent-color: var(--agent-pixel); }
.agent-aria { --agent-color: var(--agent-aria); }
.agent-vinyl { --agent-color: var(--agent-vinyl); }

/* ========================================
   23. COMMAND CENTER ENHANCEMENTS
   ======================================== */

/* Stat values — instrument readings */
.stat-card .value {
  font-family: var(--font-display, var(--font-heading));
  font-variant-numeric: tabular-nums;
}

/* Agent pulse animation */
@keyframes agent-pulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--agent-color, var(--accent)); }
  50% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--agent-color, var(--accent)) 20%, transparent); }
}

.agent-active {
  animation: agent-pulse 2s infinite;
}

/* Agent nav items in sidebar */
.agent-nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  font-size: 13px;
  color: var(--sidebar-text);
}

.agent-nav-item:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-strong);
}

.agent-nav-item .agent-emoji {
  font-size: 14px;
  width: 18px;
  text-align: center;
}

.agent-nav-item .agent-name {
  flex: 1;
  font-weight: 500;
}

.agent-nav-item .task-count {
  font-size: 11px;
  color: var(--agent-color, var(--dim));
  font-family: var(--font-display);
}

.agent-nav-item.has-work {
  color: var(--sidebar-strong);
}

.agent-nav-item.has-work::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 18px;
  background: var(--agent-color, var(--accent));
  border-radius: 0 2px 2px 0;
}

/* Task card agent color border */
.task-card[data-agent] {
  border-left: 3px solid var(--agent-color, var(--border));
}

.task-card .agent-indicator {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  background: color-mix(in srgb, var(--agent-color, var(--accent)) 15%, transparent);
  flex-shrink: 0;
}

/* Agent fleet grid */
.agent-fleet {
  margin-bottom: var(--space-lg);
}

.agent-fleet h3 {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: var(--space-md);
}

.fleet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-sm);
}

.agent-fleet-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
  transition: all 0.15s;
  cursor: pointer;
  text-align: center;
}

.agent-fleet-card:hover {
  border-color: var(--agent-color, var(--accent));
  background: color-mix(in srgb, var(--agent-color, var(--accent)) 5%, var(--card));
}

.agent-fleet-card.busy {
  border-color: var(--agent-color, var(--accent));
  box-shadow: 0 0 0 1px var(--agent-color, var(--accent));
}

.agent-fleet-card .fleet-emoji {
  font-size: 24px;
}

.agent-fleet-card .fleet-name {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.agent-fleet-card .fleet-tasks {
  font-family: var(--font-display);
  font-size: 11px;
  color: var(--agent-color, var(--dim));
}

.agent-fleet-card .fleet-status {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--dim);
}

.agent-fleet-card .fleet-status.busy {
  color: var(--success);
}

/* Mission status bar */
.mission-status-bar {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-lg);
}

.mission-status-bar .stats-row {
  display: flex;
  align-items: center;
  gap: var(--space-xl);
}

.mission-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.mission-stat .stat-label {
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--dim);
}

.mission-stat .stat-value {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: var(--text);
}

.mission-stat .stat-value.accent { color: var(--accent); }
.mission-stat .stat-value.green { color: var(--success); }

.mission-progress {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mission-progress .progress-label {
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--dim);
  display: flex;
  justify-content: space-between;
}

.mission-progress .progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.mission-progress .progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.5s ease;
}

/* Mission Briefing card */
.mission-briefing {
  padding: var(--space-md) var(--space-lg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(120deg, var(--card) 0%, color-mix(in srgb, var(--card) 76%, var(--accent) 24%) 100%);
  box-shadow: var(--shadow);
}

.mission-briefing-title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-light);
}

.mission-briefing-sub {
  color: var(--muted);
  font-size: 13px;
  margin-top: 6px;
}

.haiku-text {
  font-style: italic;
  font-size: 14px;
  line-height: 1.6;
  transition: opacity 0.5s ease;
}

.haiku-visible { opacity: 1; }
.haiku-hidden  { opacity: 0; }

/* Alert block — inline status banners */
.alert-success,
.alert-error {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: var(--space-sm);
}
.alert-success {
  background: var(--surface-subtle);
  border: 1px solid var(--success-border);
  color: var(--success);
}
.alert-error {
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  color: var(--error);
}
.alert-error button {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--error);
  cursor: pointer;
  font-size: 18px;
  min-width: 32px;
  min-height: 32px;
  border-radius: var(--radius-sm);
}

/* Activity summary — compact key-value grid */
.activity-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-sm);
}

.activity-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-sm) var(--space-md);
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.activity-label {
  font-size: 12px;
  color: var(--dim);
}

.activity-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  font-family: var(--font-display);
}

/* Active operations panel */
.operations-alerts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-lg);
}

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

.ops-panel-header {
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.ops-panel-header .count {
  background: var(--accent-bg);
  color: var(--accent);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-family: var(--font-display);
}

.ops-panel-body {
  padding: var(--space-sm);
  max-height: 300px;
  overflow-y: auto;
}

.ops-task-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  transition: background 0.15s;
  cursor: pointer;
}

.ops-task-item:hover {
  background: var(--surface-subtle);
}

.ops-task-item .ops-agent {
  font-size: 14px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--agent-color, var(--accent)) 12%, transparent);
  flex-shrink: 0;
}

.ops-task-item .ops-title {
  flex: 1;
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ops-task-item .ops-status {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  color: var(--warning);
  font-family: var(--font-display);
}

/* Recent completions */
.recent-completions {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.recent-completions .completions-header {
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.recent-completions .completion-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-lg);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.recent-completions .completion-item:last-child {
  border-bottom: none;
}

.recent-completions .completion-check {
  color: var(--success);
  font-size: 14px;
}

.recent-completions .completion-title {
  flex: 1;
  color: var(--muted);
}

.recent-completions .completion-time {
  font-size: 11px;
  color: var(--dim);
  font-family: var(--font-display);
}

/* Connection status dot */
.connection-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  display: inline-block;
}

.connection-dot.disconnected {
  background: var(--error);
}

/* Task transition animation */
.task-card {
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s, opacity 0.3s;
}

.task-card:hover {
  border-color: var(--agent-color, var(--border));
}

/* Keyboard navigation highlight */
.task-card--selected {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}


/* ── Claude Widget ── */
.claude-widget { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); padding: 20px 24px; position: relative; overflow: hidden; margin-bottom: var(--space-lg); }
.claude-widget::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px; background: linear-gradient(90deg, var(--accent), var(--cyan)); }
.cw-row { display: flex; align-items: center; gap: 28px; }
.cw-gauge { display: flex; align-items: baseline; gap: 3px; flex-shrink: 0; }
.cw-gauge-num { font-family: var(--font-display); font-size: 40px; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -0.03em; }
.cw-gauge-pct { font-size: 16px; color: var(--muted); font-weight: 600; }
.cw-bar-section { flex: 1; min-width: 0; }
.cw-bar-label { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.cw-bar-title { font-size: 12px; font-weight: 700; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.cw-status-badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 6px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.cw-status--ok { background: var(--success-bg); color: var(--success-strong); }
.cw-status--warn { background: var(--warning-bg); color: var(--warning-strong); }
.cw-status--danger { background: var(--error-bg); color: var(--error-strong); }
.cw-bar { height: 8px; background: var(--neutral-bg); border-radius: 4px; position: relative; overflow: visible; }
.cw-bar-fill { height: 100%; border-radius: 4px; max-width: 100%; transition: width 0.5s ease; }
.cw-bar-fill--ok { background: linear-gradient(90deg, var(--success), var(--cyan)); }
.cw-bar-fill--warn { background: linear-gradient(90deg, var(--warning), var(--orange)); }
.cw-bar-fill--danger { background: linear-gradient(90deg, var(--error), var(--orange)); }
.cw-bar-marker { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text); opacity: 0.25; border-radius: 1px; }
.cw-sep { width: 1px; height: 40px; background: var(--border); flex-shrink: 0; }
.cw-metrics { display: flex; gap: 24px; flex-shrink: 0; }
.cw-metric { text-align: center; }
.cw-metric-val { font-family: var(--font-display); font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); }
.cw-metric-val--ok { color: var(--success); }
.cw-metric-val--warn { color: var(--warning); }
.cw-metric-val--danger { color: var(--error); }
.cw-metric-label { font-size: 10px; color: var(--dim); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; margin-top: 2px; }
.cw-countdown { text-align: center; flex-shrink: 0; }
.cw-countdown-val { font-family: var(--font-display); font-size: 18px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.cw-countdown-label { font-size: 10px; color: var(--dim); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; margin-top: 2px; }
.cw-gauge { cursor: pointer; }
.cw-gauge:hover .cw-gauge-edit { opacity: 1; }
.cw-gauge-edit { font-size: 13px; color: var(--dim); opacity: 0; margin-left: 4px; transition: opacity 0.15s; }
.cw-gauge-input { width: 64px; font-family: var(--font-display); font-size: 40px; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -0.03em; background: transparent; border: none; border-bottom: 2px solid var(--accent); color: var(--text); outline: none; padding: 0; }
/* ─── Fleet Card (link-style agent card with colored left border) ─── */
.fleet-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--agent-color, var(--accent));
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  text-decoration: none;
  color: var(--text);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.2s ease;
}
.fleet-card:hover {
  transform: translateX(2px);
  box-shadow: var(--shadow);
}
.fleet-card--active {
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--agent-color) 30%, transparent);
  animation: fleetPulse 1.8s ease-in-out infinite;
}
.fleet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
}
.fleet-total {
  color: var(--dim);
  font-family: var(--font-display);
}
.fleet-metrics {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
}
@keyframes fleetPulse {
  0%, 100% { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--agent-color) 25%, transparent); }
  50% { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--agent-color) 60%, transparent); }
}

/* ─── Module Card (link card with icon + title + description) ─── */
.dashboard-modules {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}
.dashboard-module-card {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: 10px 12px;
  background: var(--card);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.2s;
}
.dashboard-module-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
  border-color: var(--accent-bg);
}
.dashboard-module-icon {
  font-size: 20px;
  flex-shrink: 0;
}
.dashboard-module-info {
  flex: 1;
}
.dashboard-module-title {
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 2px;
}
.dashboard-module-desc {
  font-size: 11px;
  color: var(--muted);
}

/* ─── Accessibility utilities ─── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

/* ─── Priority Badge (text badge with semantic colors) ─── */
.priority-badge {
  font-size: var(--font-section-label);
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
}
.priority-badge.urgent { background: var(--error-bg); color: var(--error); }
.priority-badge.high   { background: var(--warning-bg); color: var(--warning-strong); }
.priority-badge.medium { background: var(--accent-bg); color: var(--accent); }
.priority-badge.low    { background: var(--neutral-bg); color: var(--muted); }

/* ─── Agent Indicator (circular avatar) ─── */
.agent-indicator {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  background: color-mix(in srgb, var(--agent-color, var(--accent)) 25%, transparent);
  border: 1px solid color-mix(in srgb, var(--agent-color, var(--accent)) 55%, transparent);
}
.agent-indicator-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--agent-color, var(--dim));
}

/* ─── Agent Card (status card with colored left border + metrics) ─── */
.agent-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--agent-color, var(--accent));
  border-radius: var(--radius-md);
  padding: var(--space-md);
  transition: transform 0.15s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.agent-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.agent-card:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--accent-bg), var(--shadow);
}
.agent-card--active {
  border-color: color-mix(in srgb, var(--agent-color) 70%, var(--border));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--agent-color) 30%, transparent);
}
.agent-card--drop-target {
  border-color: var(--success);
  background: var(--success-bg);
}
.agent-name {
  font-size: var(--font-ui);
  font-weight: 700;
  margin-bottom: var(--space-sm);
  display: flex;
  align-items: center;
  gap: 6px;
}
.agent-metrics { display: flex; gap: var(--space-md); }
.agent-label {
  font-size: var(--font-section-label);
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}
.agent-value {
  font-size: var(--font-modal-title);
  font-weight: 800;
  font-family: var(--font-display);
  color: var(--text);
}
.agent-value--active { color: var(--agent-color, var(--accent)); }
.working-indicator { display: inline-flex; align-items: center; margin-left: 4px; }
.working-dots { display: flex; gap: 3px; }
.working-dots .dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--agent-color, var(--accent));
  animation: dotPulse 1.2s ease-in-out infinite;
}
.working-dots .dot:nth-child(2) { animation-delay: 0.2s; }
.working-dots .dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes dotPulse {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1); }
}

/* ─── Task Card ─── */
@keyframes taskCardIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes livePulse {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--agent-color) 50%, transparent); }
  70%  { box-shadow: 0 0 0 7px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
.task-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--agent-color, var(--border));
  border-radius: var(--radius-md);
  padding: 16px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  animation: taskCardIn 0.22s ease both;
}
.task-card:hover {
  box-shadow: var(--shadow);
  border-color: color-mix(in srgb, var(--agent-color) 30%, var(--border));
  transform: translateY(-2px);
}
.task-card:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-bg), var(--shadow);
}
.task-card--selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-bg); }
.task-card--draggable { cursor: grab; }
.task-card--dragging { opacity: 0.5; }
.task-card--overlay { box-shadow: var(--shadow-lg); transform: rotate(2deg); }
.task-card--live { position: relative; }
.task-card--live::after {
  content: '';
  position: absolute;
  top: 8px;
  right: 8px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--agent-color, var(--success));
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--agent-color) 45%, transparent);
  animation: livePulse 1.5s ease-out infinite;
}
.task-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: var(--space-xs);
}
.task-title {
  flex: 1;
  font-size: var(--font-ui);
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}
.task-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.task-time { font-size: var(--font-section-label); color: var(--dim); white-space: nowrap; }
.task-edit-btn {
  border: none;
  background: transparent;
  color: var(--dim);
  font-size: var(--font-ui);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  transition: all 0.15s;
  opacity: 0;
}
.task-card:hover .task-edit-btn { opacity: 1; }
.task-edit-btn:hover { color: var(--accent); background: var(--accent-bg); }
.task-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: var(--space-xs);
  flex-wrap: wrap;
}
.task-agents { display: flex; align-items: center; gap: 4px; }
.task-assignee {
  font-size: var(--font-label);
  color: var(--muted);
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.task-collaborators { display: flex; align-items: center; gap: 2px; }
.collab-separator { font-size: var(--font-section-label); color: var(--dim); }
.collaborator-badge { font-size: var(--font-section-label); color: var(--dim); }
.task-description {
  font-size: var(--font-label);
  color: var(--muted);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: var(--space-xs);
}
.task-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.task-tag {
  font-size: var(--font-micro);
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--surface-subtle);
  color: var(--dim);
}
.task-skeleton {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
}

/* ── Hamburger button (mobile only) ── */
.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 44px;
  height: 44px;
  padding: 10px;
  border: none;
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
}
.hamburger span {
  display: block;
  height: 2px;
  background: var(--text);
  border-radius: 1px;
  transition: transform 0.2s, opacity 0.2s;
}

/* ── Mobile Drawer ── */
.drawer-backdrop {
  display: none;
}
.drawer {
  display: none;
}

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

  .hamburger {
    display: flex;
  }

  .main {
    margin-left: 0;
    padding-bottom: 0;
  }

  /* Drawer backdrop */
  .drawer-backdrop {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 200;
    animation: drawerFadeIn 0.2s ease;
  }

  @keyframes drawerFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
  }

  /* Drawer panel */
  .drawer {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    max-width: 85vw;
    background: var(--sidebar-bg);
    z-index: 201;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .drawer--open {
    transform: translateX(0);
  }

  .drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 16px 12px;
    flex-shrink: 0;
  }
  .drawer-header .sidebar-logo {
    padding: 0;
  }
  .drawer-close {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--sidebar-hover);
    color: var(--sidebar-text);
    border-radius: var(--radius-sm);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .drawer-close:hover {
    background: var(--sidebar-active);
    color: var(--text-inverse);
  }

  .drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 0 16px 16px;
  }

  .drawer .sidebar-nav a,
  .drawer .agent-nav-item {
    padding: 12px 12px;
    min-height: 44px;
  }

  .topbar {
    padding: 16px 16px 0;
  }

  .topbar-title {
    font-size: 20px;
  }

  .topbar-search {
    display: none;
  }

  .topbar-right {
    gap: 8px;
  }

  .theme-toggle,
  .topbar-icon,
  .modal-close {
    min-width: 44px;
    min-height: 44px;
  }

  .theme-toggle {
    padding: 10px 12px;
  }

  .theme-toggle-label {
    display: none;
  }

  .content {
    padding: 16px 12px;
  }

  .page-stack {
    gap: 12px;
    padding: 0 12px;
  }

  .stat-cards,
  .stat-cards--3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stat-cards--3 > .stat-card:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }

  .stat-card {
    padding: 16px;
    border-radius: 0;
  }

  .stat-card .value {
    font-size: 28px;
  }

  .stat-card .label {
    font-size: 11px;
  }

  .table-card {
    border-radius: 0;
  }

  .table-top {
    padding: 14px 16px;
  }

  .table-top span {
    font-size: 14px;
  }

  .table-card table {
    display: block;
    width: 100%;
  }

  .table-card thead {
    display: none;
  }

  .table-card tbody {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 0 16px 16px;
  }

  .table-card tr {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
  }

  .table-card td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 2px 0;
    border-bottom: none;
    font-size: 13px;
  }

  .table-card td::before {
    content: attr(data-label);
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
  }

  .table-card td[colspan] {
    display: block;
  }

  .table-card td[colspan]::before {
    content: none;
  }

  .dashboard-panels,
  .usage-grid-two,
  .kb-stats-bar,
  .usage-detail-stats {
    grid-template-columns: 1fr;
  }

  .tabs {
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
  }

  .services-page .tab {
    scroll-snap-align: start;
    flex-shrink: 0;
  }

  .kanban-board,
  .kanban {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    overflow-x: visible;
  }

  .kanban-column,
  .task-column {
    min-width: unset;
    width: 100%;
  }

  .overlay-panel,
  .modal,
  .task-modal-panel,
  .kb-detail-panel {
    width: 100vw;
    max-width: 100vw !important;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }

  .overlay-backdrop,
  .task-modal-overlay,
  .kb-detail-overlay {
    padding: 0;
  }

  .overlay-panel-header,
  .overlay-panel-body,
  .overlay-panel-actions {
    padding-left: 16px;
    padding-right: 16px;
  }

  .kb-detail-toc {
    display: none !important;
  }

  .kb-detail-main {
    padding: 16px;
  }

  /* ─── Usage Widgets (Claude / OpenAI) ─── */
  .claude-widget { padding: 14px 16px; }

  .cw-row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-rows: auto auto;
    gap: 10px 12px;
    align-items: center;
  }

  .cw-gauge { grid-column: 1; grid-row: 1; }
  .cw-gauge-num { font-size: 28px; }
  .cw-gauge-pct { font-size: 12px; }

  .cw-bar-section { grid-column: 2; grid-row: 1 / 3; }
  .cw-bar-title { font-size: 11px; }
  .cw-status-badge { font-size: 9px; padding: 2px 6px; }

  .cw-countdown { grid-column: 3; grid-row: 1; }
  .cw-countdown-val { font-size: 14px; }
  .cw-countdown-label { font-size: 8px; }

  .cw-metrics {
    grid-column: 1 / -1;
    grid-row: 2;
    display: flex;
    justify-content: space-around;
    gap: 8px;
    border-top: 1px solid var(--border);
    padding-top: 10px;
  }

  .cw-metric-val { font-size: 13px; }
  .cw-metric-label { font-size: 8px; }
  .cw-sep { display: none; }

  /* ─── KB Search Box ─── */
  .search-box.kb-search-box {
    flex-wrap: wrap;
    gap: 8px;
  }

  .search-box.kb-search-box input {
    flex: 1 1 100%;
    min-width: 0;
  }

  .search-box.kb-search-box .btn {
    flex-shrink: 0;
  }

  .search-box.kb-search-box .kb-toggle-label {
    font-size: 12px;
    flex-shrink: 0;
  }

  /* ─── Byte's mobile improvements ─── */
  .stat-cards--3 {
    grid-template-columns: 1fr;
  }

  .stat-card .value {
    font-size: 24px;
  }

  .topbar-icon {
    width: 32px;
    height: 32px;
  }

  .topbar {
    padding: 12px 12px 0;
  }

  .content {
    padding: 12px 8px;
  }

  .mission-briefing {
    padding: 12px 14px;
  }

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

  .fleet-card,
  .agent-card {
    padding: 8px 10px;
  }

  .operations-alerts {
    grid-template-columns: 1fr;
  }

  .activity-summary {
    grid-template-columns: 1fr;
  }

  .tabs .tab {
    scroll-snap-align: start;
    flex-shrink: 0;
  }
}
