/* ==================== CSS VARIABLES ==================== */
:root {
  /* Background */
  --bg-base: #09090b;
  --bg-surface: #18181b;
  --bg-elevated: #27272a;
  --bg-hover: #3f3f46;
  --bg-selected: #1a2e1a;

  /* Borders */
  --border: #27272a;
  --border-hover: #3f3f46;

  /* Text */
  --text-primary: #fafafa;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;

  /* Accent (green) */
  --accent: #22c55e;
  --accent-hover: #16a34a;
  --accent-muted: rgba(34, 197, 94, 0.15);
  --accent-glow: rgba(34, 197, 94, 0.25);

  /* Semantic */
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --purple: #a855f7;

  /* Sizing */
  --card-radius: 12px;
  --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
  --card-shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.5);
  --sidebar-width: 240px;
  --sidebar-collapsed-width: 68px;

  /* Chart */
  --chart-grid: rgba(255, 255, 255, 0.1);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
}

/* ==================== LIGHT THEME ==================== */
[data-theme="light"] {
  --bg-base: #eef0f2;
  --bg-surface: #f6f7f8;
  --bg-elevated: #e6e8eb;
  --bg-hover: #d8dbe0;
  --bg-selected: #d4ead8;
  --border: #d5d8dc;
  --border-hover: #b8bcc2;
  --text-primary: #1a1d23;
  --text-secondary: #3d4350;
  --text-muted: #7c818c;
  --accent: #16a34a;
  --accent-hover: #15803d;
  --accent-muted: rgba(22, 163, 74, 0.12);
  --accent-glow: rgba(22, 163, 74, 0.2);
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --info: #2563eb;
  --purple: #9333ea;
  --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.08);
  --card-shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.14);
  --chart-grid: rgba(0, 0, 0, 0.1);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg-base: #eef0f2;
    --bg-surface: #f6f7f8;
    --bg-elevated: #e6e8eb;
    --bg-hover: #d8dbe0;
    --bg-selected: #d4ead8;
    --border: #d5d8dc;
    --border-hover: #b8bcc2;
    --text-primary: #1a1d23;
    --text-secondary: #3d4350;
    --text-muted: #7c818c;
    --accent: #16a34a;
    --accent-hover: #15803d;
    --accent-muted: rgba(22, 163, 74, 0.12);
    --accent-glow: rgba(22, 163, 74, 0.2);
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --info: #2563eb;
    --purple: #9333ea;
    --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.08);
    --card-shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.14);
    --chart-grid: rgba(0, 0, 0, 0.1);
  }
}

/* ==================== RESET & BASE ==================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-base);
  color: var(--text-secondary);
  min-height: 100vh;
}

.app {
  display: flex;
  flex-direction: row;
  height: 100vh;
}

/* ==================== SIDEBAR ==================== */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: width var(--transition-normal), min-width var(--transition-normal);
  overflow: hidden;
  z-index: 50;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
  min-width: var(--sidebar-collapsed-width);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
  min-height: 64px;
}

.sidebar-logo {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  flex-shrink: 0;
}

.sidebar-brand-text {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  transition: opacity var(--transition-normal);
}

.sidebar.collapsed .sidebar-brand-text {
  opacity: 0;
  width: 0;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0.75rem 0.5rem;
  flex: 1;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.85rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--transition-fast);
  white-space: nowrap;
  text-align: left;
  width: 100%;
}

.sidebar-nav-item:hover {
  background: var(--bg-elevated);
  color: var(--text-secondary);
}

.sidebar-nav-item.active {
  background: var(--accent-muted);
  color: var(--accent);
  font-weight: 600;
}

.sidebar-nav-item.active .nav-icon {
  filter: none;
}

.nav-icon {
  font-size: 1.15rem;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.nav-label {
  overflow: hidden;
  transition: opacity var(--transition-normal);
}

.sidebar.collapsed .nav-label {
  opacity: 0;
  width: 0;
}

.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0.5rem;
  border-top: 1px solid var(--border);
  margin-top: auto;
}

.sidebar-collapse-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.85rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.875rem;
  transition: all var(--transition-fast);
  white-space: nowrap;
  text-align: left;
  width: 100%;
}

.sidebar-collapse-btn:hover {
  background: var(--bg-elevated);
  color: var(--text-secondary);
}

.sidebar.collapsed .sidebar-collapse-btn .nav-icon {
  transform: rotate(180deg);
}

/* ==================== CONTENT AREA ==================== */
.content-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  min-width: 0;
}

/* ==================== STATS BAR ==================== */
.stats-bar {
  display: flex;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  align-items: stretch;
}

.stat {
  --stat-color: var(--text-muted);
  background: var(--bg-elevated);
  padding: 0.75rem 1.5rem;
  border-radius: var(--card-radius);
  text-align: center;
  min-width: 100px;
  transition: all var(--transition-fast);
  border-top: 3px solid transparent;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.25rem;
}

.stat-value {
  display: block;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.stat-label-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

.stat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--stat-color);
  flex-shrink: 0;
}

.stat-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* Total stat — hero treatment */
.stat.stat-total {
  --stat-color: var(--accent);
  min-width: 110px;
  background: var(--accent-muted);
  border-top-color: var(--accent);
}
.stat.stat-total .stat-value {
  font-size: 1.6rem;
  color: var(--accent);
}

/* Per-status colors */
.stat.unreviewed { --stat-color: var(--warning); }
.stat.reviewed   { --stat-color: var(--text-muted); }
.stat.pursuing   { --stat-color: var(--success); }
.stat.watchlist  { --stat-color: var(--info); }
.stat.staged     { --stat-color: var(--warning); }
.stat.archived   { --stat-color: var(--purple); }
.stat.deadline   { --stat-color: var(--danger); }

/* Clickable interaction */
.stat.clickable {
  cursor: pointer;
  transition: transform var(--transition-fast), background var(--transition-fast),
              box-shadow var(--transition-fast), border-top-color var(--transition-fast);
}

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

/* Active/selected state */
.stat.clickable.active {
  border-top-color: var(--stat-color);
  box-shadow: 0 0 0 1px var(--stat-color), 0 2px 8px rgba(0, 0, 0, 0.2);
}
.stat.clickable.active .stat-value {
  color: var(--stat-color);
}

/* ==================== CONTROLS ==================== */
.controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.5rem;
  background: var(--bg-surface);
  gap: 1rem;
  flex-wrap: wrap;
}

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

/* ==================== BUTTONS ==================== */
.btn {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border-hover);
  border-radius: 8px;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--transition-fast);
}

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

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
  font-weight: 600;
}

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

.btn-success {
  background: var(--success);
  border-color: var(--success);
  color: #000;
}

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.btn-warning {
  background: var(--warning);
  border-color: var(--warning);
  color: #000;
}

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

/* ==================== INPUTS ==================== */
select, input[type="text"], input[type="number"] {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border-hover);
  border-radius: 8px;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: 0.875rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

select:focus, input[type="text"]:focus, input[type="number"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

input[type="text"] {
  width: 250px;
}

/* ==================== FILTERS ==================== */
.filters-panel {
  background: var(--bg-surface);
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.filter-row {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.filter-group label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.filter-group select {
  min-width: 180px;
}

.filter-group input[type="date"],
.filter-group input.flatpickr-input {
  padding: 0.5rem;
  border: 1px solid var(--border-hover);
  border-radius: 8px;
  background: var(--bg-base);
  color: var(--text-secondary);
  font-size: 0.875rem;
  min-width: 150px;
  cursor: pointer;
}

.filter-group input[type="date"]:focus,
.filter-group input.flatpickr-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.filter-group.date-range {
  min-width: auto;
}

.filter-group input[type="text"] {
  padding: 0.5rem;
  border: 1px solid var(--border-hover);
  border-radius: 8px;
  background: var(--bg-base);
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.filter-group input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

/* Multi-select checkbox groups */
.multi-select-row {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
}

.multi-select-group {
  min-width: 200px;
  max-width: 280px;
}

.multi-select-group > label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 180px;
  overflow-y: auto;
  padding: 0.5rem;
  background: var(--bg-base);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem !important;
  color: var(--text-secondary) !important;
  text-transform: none !important;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 4px;
  transition: background var(--transition-fast);
}

.checkbox-group label:hover {
  background: var(--bg-elevated);
}

.checkbox-group input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

.btn-link {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.7rem;
  padding: 0;
  text-decoration: underline;
}

.btn-link:hover {
  color: var(--accent-hover);
}

.btn-small {
  padding: 0.4rem 0.6rem;
  font-size: 0.8rem;
}

/* ==================== DROPDOWN ==================== */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-toggle {
  cursor: pointer;
}

.dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-hover);
  border-radius: var(--card-radius);
  min-width: 220px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  z-index: 100;
  margin-top: 0.25rem;
  overflow: hidden;
}

.dropdown-menu.show {
  display: block;
}

.dropdown-item {
  padding: 0.7rem 1rem;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.9rem;
  transition: background var(--transition-fast);
}

.dropdown-item:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 0.25rem 0;
}

.full-width {
  width: 100%;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  font-style: italic;
}

/* ==================== DOCUMENT PICKER ==================== */
.doc-picker-actions {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.doc-list {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 1rem;
}

.doc-item {
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition-fast);
}

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

.doc-item:hover {
  background: var(--bg-surface);
}

.doc-item label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
}

.doc-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--accent);
}

.doc-icon {
  font-size: 1.25rem;
}

.doc-name {
  flex: 1;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.doc-type {
  background: var(--bg-elevated);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.doc-status-bar {
  padding: 0.6rem 1rem;
  background: rgba(34, 197, 94, 0.1);
  border-bottom: 1px solid var(--border);
  color: var(--success);
  font-size: 0.85rem;
}

.doc-item.doc-extracted {
  background: rgba(34, 197, 94, 0.05);
  border-left: 3px solid var(--success);
}

.doc-extracted-badge {
  background: var(--success);
  color: #000;
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  font-size: 0.7rem;
  font-weight: 600;
  margin-left: auto;
}

/* ==================== CLEANUP MODAL ==================== */
.modal-large {
  max-width: 800px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.cleanup-actions-top {
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.cleanup-list {
  flex: 1;
  overflow-y: auto;
  max-height: 400px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 1rem;
}

.cleanup-item {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition-fast);
}

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

.cleanup-item:hover {
  background: var(--bg-surface);
}

.cleanup-item.pursuing {
  background: rgba(34, 197, 94, 0.1);
  border-left: 3px solid var(--success);
}

.cleanup-item label {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  cursor: pointer;
}

.cleanup-item input[type="checkbox"] {
  margin-top: 0.25rem;
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--accent);
}

.cleanup-info {
  flex: 1;
}

.cleanup-title {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}

.cleanup-meta {
  display: flex;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.tag-pursuing {
  background: var(--success);
  color: #000;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  font-weight: 600;
  font-size: 0.7rem;
}

/* ==================== SIMILAR OPPORTUNITIES ==================== */
.similar-item {
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.5rem;
  background: var(--bg-surface);
  border-radius: 8px;
  cursor: pointer;
  border-left: 3px solid var(--bg-hover);
  transition: all var(--transition-fast);
}

.similar-item:hover {
  background: var(--bg-elevated);
  border-left-color: var(--accent);
}

.similar-item.pursuing {
  border-left-color: var(--success);
}

.similar-item.excluded {
  opacity: 0.5;
  border-left-color: var(--danger);
}

.similar-title {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
}

.similar-meta {
  display: flex;
  gap: 0.75rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.similar-match {
  color: var(--accent);
  font-weight: 500;
}

.similar-status {
  text-transform: capitalize;
}

/* ==================== FLATPICKR OVERRIDES ==================== */
.flatpickr-calendar {
  background: var(--bg-surface) !important;
  border-color: var(--border-hover) !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6) !important;
}

.flatpickr-day {
  color: var(--text-secondary) !important;
}

.flatpickr-day:hover {
  background: var(--bg-elevated) !important;
  border-color: var(--bg-elevated) !important;
}

.flatpickr-day.selected {
  background: var(--accent) !important;
  border-color: var(--accent) !important;
  color: #000 !important;
}

.flatpickr-months .flatpickr-month {
  background: var(--bg-surface) !important;
  color: var(--text-secondary) !important;
}

.flatpickr-current-month .flatpickr-monthDropdown-months {
  background: var(--bg-surface) !important;
  color: var(--text-secondary) !important;
}

.flatpickr-weekdays {
  background: var(--bg-surface) !important;
}

.flatpickr-weekday {
  color: var(--text-muted) !important;
}

/* ==================== MAIN CONTENT ==================== */
.main-content {
  display: flex;
  flex: 1;
  overflow: hidden;
  width: 100%;
}

/* ==================== OPPORTUNITIES VIEW ==================== */
.view-opportunities {
  display: flex;
  flex: 1;
  overflow: hidden;
  flex-direction: column;
}

.view-opportunities > .batch-analysis-bar {
  flex-shrink: 0;
}

.view-opportunities > .opportunities-main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.opportunities-list {
  width: 45%;
  min-width: 250px;
  overflow-y: auto;
  padding: 1rem;
  flex-shrink: 0;
}

.opp-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  padding: 1rem;
  margin-bottom: 0.75rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: var(--card-shadow);
}

.opp-card:hover {
  border-color: var(--accent);
  transform: translateX(2px);
  box-shadow: var(--card-shadow-hover);
}

.opp-card.selected {
  border-color: var(--accent);
  background: var(--bg-selected);
}

.opp-card.status-pursuing {
  border-left: 3px solid var(--success);
}

.opp-card.status-reviewed {
  border-left: 3px solid var(--text-muted);
  opacity: 0.85;
}

.opp-card.status-excluded {
  opacity: 0.5;
  border-left: 3px solid var(--danger);
}

.opp-card.status-archived {
  opacity: 0.6;
  border-left: 3px solid var(--purple);
}

.opp-card.status-watchlist {
  border-left: 3px solid var(--info);
}

.opp-title {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}

.opp-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.opp-tag {
  background: var(--bg-elevated);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}

.opp-tag.sdvosb {
  background: var(--success);
  color: #000;
  font-weight: 600;
}

.opp-tag.deadline-soon {
  background: var(--danger);
  color: #fff;
}

.opp-award {
  background: rgba(34, 197, 94, 0.12);
  color: var(--success);
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  border: 1px solid rgba(34, 197, 94, 0.25);
}

.opp-deadline {
  color: var(--warning);
  font-weight: 500;
}

.opp-reviewed {
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-top: 0.25rem;
}

/* ==================== DETAIL PANEL ==================== */
.detail-panel {
  flex: 1;
  min-width: 350px;
  overflow-y: auto;
  padding: 1.5rem;
  border-left: 1px solid var(--border);
}

.detail-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
}

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

.detail-title {
  font-size: 1.25rem;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.detail-agency {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.detail-actions {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.detail-section {
  margin-bottom: 1.5rem;
}

.detail-section h3 {
  font-size: 0.875rem;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.25rem;
}

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

.detail-item {
  background: var(--bg-surface);
  padding: 0.75rem;
  border-radius: 8px;
}

.detail-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.detail-value {
  color: var(--text-secondary);
}

.scope-content {
  background: var(--bg-surface);
  padding: 1rem;
  border-radius: 8px;
  max-height: 400px;
  overflow-y: auto;
  white-space: pre-wrap;
  font-family: 'Consolas', monospace;
  font-size: 0.85rem;
  line-height: 1.5;
}

.notes-textarea {
  width: 100%;
  min-height: 100px;
  padding: 0.75rem;
  border: 1px solid var(--border-hover);
  border-radius: 8px;
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-family: inherit;
  resize: vertical;
}

.notes-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

/* ==================== RESIZABLE DIVIDER ==================== */
.resize-divider {
  width: 6px;
  background: var(--border);
  cursor: col-resize;
  flex-shrink: 0;
  transition: background var(--transition-fast);
  position: relative;
}

.resize-divider:hover,
.resize-divider.dragging {
  background: var(--accent);
}

.resize-divider::after {
  content: '⋮';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--text-muted);
  font-size: 12px;
}

/* ==================== MODAL ==================== */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--bg-surface);
  padding: 2rem;
  border-radius: var(--card-radius);
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.modal-content h2 {
  margin-bottom: 1.5rem;
  color: var(--text-primary);
}

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

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--text-muted);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.fetch-status {
  margin-top: 1rem;
  padding: 0.75rem;
  border-radius: 8px;
  display: none;
}

.fetch-status.loading {
  display: block;
  background: var(--accent-muted);
  color: var(--accent);
}

.fetch-status.success {
  display: block;
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
}

.fetch-status.error {
  display: block;
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
}

.fetch-status.warning {
  display: block;
  background: rgba(245, 158, 11, 0.15);
  color: var(--warning);
}

.btn-tiny {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  background: var(--bg-elevated);
  border: none;
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

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

.loading {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem;
}

/* ==================== PIPELINE VIEW ==================== */
.view-pipeline {
  height: 100%;
  width: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.pipeline-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
}

.pipeline-stats {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.stat-pill {
  background: var(--bg-elevated);
  padding: 0.4rem 0.75rem;
  border-radius: 20px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.pipeline-board {
  display: flex;
  gap: 1rem;
  padding: 1rem;
  overflow-x: auto;
  flex: 1;
}

.pipeline-column {
  background: var(--bg-surface);
  border-radius: var(--card-radius);
  min-width: 260px;
  max-width: 260px;
  display: flex;
  flex-direction: column;
  transition: border-color var(--transition-fast);
  border: 2px solid transparent;
}

.pipeline-column.drag-over {
  border-color: var(--accent);
  background: var(--bg-selected);
}

.pipeline-column h3 {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-primary);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.stage-count {
  background: var(--bg-hover);
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
  font-size: 0.75rem;
}

.pipeline-items {
  padding: 0.5rem;
  flex: 1;
  overflow-y: auto;
  min-height: 200px;
}

/* Pipeline Cards */
.pipeline-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  border-left: 3px solid var(--bg-hover);
}

.pipeline-card:hover {
  border-color: var(--accent);
  background: var(--bg-hover);
  box-shadow: var(--card-shadow);
}

.pipeline-card.urgent {
  border-left-color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
}

.pipeline-card.dragging {
  opacity: 0.5;
  transform: rotate(2deg);
}

.pipeline-card-header {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0.35rem;
}

.pwin-badge {
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  font-size: 0.7rem;
  font-weight: 600;
}

.pwin-5 { background: var(--success); color: #000; }
.pwin-4 { background: #84cc16; color: #000; }
.pwin-3 { background: #eab308; color: #000; }
.pwin-2 { background: #f97316; color: #fff; }
.pwin-1 { background: var(--danger); color: #fff; }

.go-badge {
  background: var(--success);
  color: #000;
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  font-size: 0.65rem;
  font-weight: 700;
}

.nogo-badge {
  background: var(--danger);
  color: #fff;
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  font-size: 0.65rem;
  font-weight: 700;
}

.pipeline-card-title {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.3;
  margin-bottom: 0.35rem;
}

.pipeline-card-value {
  font-size: 0.8rem;
  color: var(--success);
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.pipeline-card-meta {
  display: flex;
  gap: 0.5rem;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.pipeline-card-meta .deadline-urgent {
  color: var(--danger);
  font-weight: 600;
}

.pipeline-card-hours {
  font-size: 0.7rem;
  color: var(--accent);
  margin-top: 0.35rem;
}

/* Pipeline Detail Modal */
.modal-content.modal-pipeline {
  max-width: 1100px;
  width: 95%;
  max-height: 90vh;
  padding: 1.5rem 2rem;
}

.modal-content.modal-pipeline h2 {
  font-size: 1.1rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.pipeline-opp-info {
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.opp-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem 2rem;
  margin-bottom: 1rem;
}

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

.opp-info-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.opp-info-value {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.opp-info-value a {
  color: var(--accent);
  text-decoration: none;
}

.opp-info-value a:hover {
  text-decoration: underline;
}

.opp-info-actions {
  display: flex;
  gap: 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.pipeline-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem 2rem;
  margin: 1.25rem 0;
}

.pipeline-detail-section h4 {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border);
}

.pipeline-detail-section .form-group {
  margin-bottom: 0.75rem;
}

.pipeline-detail-section label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.pipeline-detail-section input,
.pipeline-detail-section select,
.pipeline-detail-section textarea {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--border-hover);
  border-radius: 6px;
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.pipeline-detail-section input:focus,
.pipeline-detail-section select:focus,
.pipeline-detail-section textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.pipeline-detail-section textarea {
  min-height: 60px;
  resize: vertical;
}

.readonly-input {
  background: var(--bg-base) !important;
  color: var(--text-muted) !important;
}

.pipeline-activity-section {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.pipeline-activity-section h4 {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.activity-input {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.activity-input input {
  flex: 1;
  padding: 0.5rem;
  border: 1px solid var(--border-hover);
  border-radius: 6px;
  background: var(--bg-surface);
  color: var(--text-secondary);
}

.activity-input input:focus {
  outline: none;
  border-color: var(--accent);
}

.activity-log {
  max-height: 150px;
  overflow-y: auto;
}

.activity-item {
  display: flex;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.activity-date {
  color: var(--text-muted);
  min-width: 80px;
}

.activity-text {
  color: var(--text-secondary);
}

/* ==================== HELP MODAL ==================== */
.help-modal {
  max-width: 900px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

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

.help-header h2 {
  margin: 0;
}

.help-content {
  display: flex;
  gap: 1.5rem;
  flex: 1;
  overflow: hidden;
}

.help-nav {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 140px;
}

.help-nav-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  font-size: 0.85rem;
  transition: all var(--transition-fast);
}

.help-nav-btn:hover {
  background: var(--bg-elevated);
  color: var(--text-secondary);
}

.help-nav-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
  font-weight: 600;
}

.help-sections {
  flex: 1;
  overflow-y: auto;
  padding-right: 0.5rem;
}

.help-section {
  display: none;
}

.help-section.active {
  display: block;
}

.help-section h3 {
  font-size: 1.25rem;
  color: var(--text-primary);
  margin-bottom: 1rem;
}

.help-section h4 {
  font-size: 0.95rem;
  color: var(--accent);
  margin: 1.25rem 0 0.5rem 0;
}

.help-section p {
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 0.75rem;
}

.help-section ul, .help-section ol {
  color: var(--text-secondary);
  padding-left: 1.5rem;
  margin-bottom: 0.75rem;
}

.help-section li {
  margin-bottom: 0.4rem;
  line-height: 1.5;
}

.help-section strong {
  color: var(--text-primary);
}

/* ==================== CONTEXT MENU ==================== */
.context-menu {
  display: none;
  position: absolute;
  background: var(--bg-surface);
  border: 1px solid var(--border-hover);
  border-radius: var(--card-radius);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  min-width: 200px;
  z-index: 1000;
  overflow: hidden;
}

.context-menu-item {
  padding: 0.65rem 1rem;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.85rem;
  transition: background var(--transition-fast);
}

.context-menu-item:hover {
  background: var(--bg-elevated);
}

.context-menu-item.danger {
  color: var(--danger);
}

.context-menu-item.danger:hover {
  background: rgba(239, 68, 68, 0.15);
}

.context-menu-divider {
  height: 1px;
  background: var(--border);
  margin: 0.25rem 0;
}

/* ==================== ANALYTICS VIEW ==================== */
.view-analytics {
  height: 100%;
  width: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1.5rem 2rem;
}

.analytics-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.5rem;
  width: 100%;
}

.analytics-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  padding: 1.25rem;
  max-height: 400px;
  overflow-y: auto;
  box-shadow: var(--card-shadow);
  min-width: 0;
}

.analytics-card-chart {
  max-height: none;
  overflow: visible;
}

.analytics-card h3 {
  font-size: 0.9rem;
  color: var(--text-primary);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.analytics-row {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

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

.analytics-row.clickable {
  cursor: pointer;
  border-radius: 6px;
  margin: 0 -0.5rem;
  padding: 0.5rem;
  transition: background var(--transition-fast);
}

.analytics-row.clickable:hover {
  background: var(--bg-elevated);
}

.analytics-label {
  color: var(--text-muted);
}

.analytics-value {
  color: var(--text-primary);
  font-weight: 500;
}

/* ==================== ANALYTICS TOOLBAR ==================== */
.analytics-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  flex-wrap: wrap;
}

.analytics-toolbar-left,
.analytics-toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.analytics-toolbar-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-right: 0.25rem;
}

.grid-col-btn {
  padding: 0.375rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-hover);
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.grid-col-btn:hover {
  background: var(--bg-hover);
  color: var(--text-secondary);
}

.grid-col-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
}

.manage-cards-menu {
  right: 0;
  left: auto;
  min-width: 280px;
  max-height: 400px;
  overflow-y: auto;
  padding: 0.5rem 0;
}

.manage-cards-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.manage-cards-item label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  flex: 1;
}

.manage-cards-item input[type="checkbox"] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* ==================== ANALYTICS CARD HEADER ==================== */
.analytics-card-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.analytics-card-header h3 {
  flex: 1;
  margin: 0;
  padding: 0;
  border: none;
}

.analytics-drag-handle {
  cursor: grab;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 0.125rem 0.25rem;
  border-radius: 4px;
  transition: color var(--transition-fast), background var(--transition-fast);
  user-select: none;
}

.analytics-drag-handle:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.analytics-drag-handle:active {
  cursor: grabbing;
}

.analytics-card-controls {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.analytics-card:hover .analytics-card-controls {
  opacity: 1;
}

.btn-icon {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 4px;
  font-size: 0.8rem;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

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

/* ==================== CARD BODY (collapsible) ==================== */
.analytics-card-body {
  transition: max-height 250ms ease, opacity 200ms ease, padding 200ms ease;
  overflow: hidden;
  min-width: 0;
}

.analytics-card.collapsed .analytics-card-body {
  max-height: 0 !important;
  opacity: 0;
  padding: 0;
  overflow: hidden;
}

.analytics-card.collapsed .collapse-icon {
  transform: rotate(180deg);
}

.analytics-card.collapsed {
  max-height: none;
}

.collapse-icon {
  display: inline-block;
  transition: transform var(--transition-fast);
}

/* ==================== CARD SIZING ==================== */
.analytics-card-size-wide {
  grid-column: span 2;
}

.analytics-grid[data-cols="1"] .analytics-card-size-wide {
  grid-column: span 1;
}

/* ==================== SORTABLEJS STYLES ==================== */
.analytics-card.sortable-ghost {
  opacity: 0.4;
  background: var(--accent-muted);
  border: 2px dashed var(--accent);
}

.analytics-card.sortable-chosen {
  box-shadow: var(--card-shadow-hover);
}

.analytics-card.sortable-drag {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.analytics-card.card-hidden {
  display: none;
}

/* Mobile analytics override */
@media (max-width: 768px) {
  .analytics-grid {
    grid-template-columns: 1fr !important;
  }
  .analytics-card-size-wide {
    grid-column: span 1;
  }
  .analytics-card-controls {
    opacity: 1;
  }
}

/* ==================== AI ANALYSIS ==================== */
.ai-analysis {
  background: var(--accent-muted);
  border: 1px solid rgba(34, 197, 94, 0.2);
  border-radius: var(--card-radius);
  padding: 1rem;
  margin-top: 1rem;
}

.ai-score {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.score-circle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 700;
}

.score-high { background: var(--success); color: #000; }
.score-medium { background: var(--warning); color: #000; }
.score-low { background: var(--danger); color: #fff; }

.ai-recommendation {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
}

.rec-pursue { background: var(--success); color: #000; }
.rec-consider { background: var(--warning); color: #000; }
.rec-skip { background: var(--danger); color: #fff; }

/* Quick Exclude */
.quick-exclude {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.quick-exclude button {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
}

/* ==================== SCROLLBAR ==================== */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-base);
}

::-webkit-scrollbar-thumb {
  background: var(--bg-hover);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ==================== SCOPE VIEWER MODAL ==================== */
.modal-scope-viewer {
  width: 90vw;
  max-width: 1200px;
  height: 85vh;
  max-height: 900px;
  display: flex;
  flex-direction: column;
}

.scope-viewer-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.scope-viewer-header h2 {
  margin: 0;
  flex-shrink: 0;
}

.scope-search-container {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  max-width: 400px;
}

.scope-search-container input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  background: var(--bg-base);
  border: 1px solid var(--border-hover);
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.scope-search-container input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.search-results-count {
  color: var(--text-muted);
  font-size: 0.85rem;
  white-space: nowrap;
  min-width: 60px;
}

.scope-viewer-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.scope-viewer-toolbar .btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
}

.scope-char-count {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.scope-viewer-content {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  background: var(--bg-base);
  border-radius: var(--card-radius);
  margin-top: 0.75rem;
}

.scope-viewer-content.raw-mode {
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 0.9rem;
  white-space: pre-wrap;
  word-wrap: break-word;
  line-height: 1.6;
}

.scope-viewer-content.formatted-mode {
  font-size: 0.95rem;
  line-height: 1.7;
}

.scope-viewer-content.formatted-mode h1,
.scope-viewer-content.formatted-mode h2,
.scope-viewer-content.formatted-mode h3,
.scope-viewer-content.formatted-mode h4,
.scope-viewer-content.formatted-mode h5,
.scope-viewer-content.formatted-mode h6 {
  color: var(--text-primary);
  margin-top: 1.5em;
  margin-bottom: 0.75em;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.25em;
}

.scope-viewer-content.formatted-mode h1 { font-size: 1.75rem; }
.scope-viewer-content.formatted-mode h2 { font-size: 1.5rem; }
.scope-viewer-content.formatted-mode h3 { font-size: 1.25rem; }

.scope-viewer-content.formatted-mode p {
  margin-bottom: 1em;
}

.scope-viewer-content.formatted-mode ul,
.scope-viewer-content.formatted-mode ol {
  margin-left: 1.5rem;
  margin-bottom: 1em;
}

.scope-viewer-content.formatted-mode li {
  margin-bottom: 0.5em;
}

.scope-viewer-content.formatted-mode code {
  background: var(--bg-surface);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 0.9em;
  color: #f472b6;
}

.scope-viewer-content.formatted-mode pre {
  background: var(--bg-surface);
  padding: 1rem;
  border-radius: var(--card-radius);
  overflow-x: auto;
  margin-bottom: 1em;
}

.scope-viewer-content.formatted-mode pre code {
  background: none;
  padding: 0;
  color: var(--text-secondary);
}

.scope-viewer-content.formatted-mode table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1em;
}

.scope-viewer-content.formatted-mode th,
.scope-viewer-content.formatted-mode td {
  border: 1px solid var(--border-hover);
  padding: 0.5rem 0.75rem;
  text-align: left;
}

.scope-viewer-content.formatted-mode th {
  background: var(--bg-surface);
  font-weight: 600;
  color: var(--text-primary);
}

.scope-viewer-content.formatted-mode tr:nth-child(even) {
  background: rgba(24, 24, 27, 0.5);
}

.scope-viewer-content.formatted-mode blockquote {
  border-left: 4px solid var(--accent);
  padding-left: 1rem;
  margin: 1em 0;
  color: var(--text-muted);
  font-style: italic;
}

.scope-viewer-content.formatted-mode a {
  color: var(--accent);
  text-decoration: underline;
}

.scope-viewer-content.formatted-mode hr {
  border: none;
  border-top: 1px solid var(--border-hover);
  margin: 1.5em 0;
}

/* Search highlight */
.search-highlight {
  background: #eab308;
  color: #000;
  padding: 0.1em 0.2em;
  border-radius: 2px;
}

.search-highlight.current {
  background: #f97316;
  box-shadow: 0 0 0 2px #f97316;
}

/* No scope text placeholder */
.scope-viewer-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  text-align: center;
}

.scope-viewer-empty p {
  margin-bottom: 1rem;
  font-size: 1.1rem;
}

/* ==================== SETTINGS MODAL ==================== */
.settings-modal {
  max-width: 900px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

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

.settings-header h2 {
  margin: 0;
}

.settings-content {
  display: flex;
  gap: 1.5rem;
  flex: 1;
  overflow: hidden;
}

.settings-nav {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 160px;
}

.settings-nav-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  font-size: 0.85rem;
  transition: all var(--transition-fast);
}

.settings-nav-btn:hover {
  background: var(--bg-elevated);
  color: var(--text-secondary);
}

.settings-nav-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
  font-weight: 600;
}

.settings-sections {
  flex: 1;
  overflow-y: auto;
  padding-right: 0.5rem;
}

.settings-section {
  display: none;
}

.settings-section.active {
  display: block;
}

.settings-section h3 {
  font-size: 1.25rem;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.settings-section h4 {
  font-size: 0.95rem;
  color: var(--accent);
  margin: 1rem 0 0.5rem 0;
}

.settings-description {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

.settings-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.settings-form .form-row {
  display: flex;
  gap: 1rem;
}

.settings-form .form-row .form-group {
  flex: 1;
}

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

.settings-form label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

.settings-form input,
.settings-form select,
.settings-form textarea {
  background: var(--bg-base);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  font-size: 0.9rem;
}

.settings-form input:focus,
.settings-form select:focus,
.settings-form textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

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

.settings-form .form-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.settings-form .form-hint a {
  color: var(--accent);
}

.settings-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.save-status {
  font-size: 0.85rem;
  color: var(--success);
  font-weight: 600;
}

.save-status.error {
  color: var(--danger);
}

.settings-actions .btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

/* API Key Input */
.api-key-input {
  display: flex;
  gap: 0.5rem;
}

.api-key-input input {
  flex: 1;
}

.api-key-status {
  font-size: 0.85rem;
  margin-top: 0.25rem;
}

.api-key-status.configured {
  color: var(--success);
}

.api-key-status.not-configured {
  color: var(--warning);
}

.api-test-results {
  margin-top: 1.5rem;
  padding: 1rem;
  background: var(--bg-surface);
  border-radius: var(--card-radius);
  border: 1px solid var(--border);
}

.api-test-results h4 {
  margin-top: 0;
  margin-bottom: 0.75rem;
}

.api-test-output .test-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.api-test-output .test-item:last-child {
  border-bottom: none;
}

.api-test-output .test-pass {
  color: var(--success);
}

.api-test-output .test-fail {
  color: var(--danger);
}

/* ==================== AI PROVIDER CARDS ==================== */
.ai-provider-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.ai-provider-card {
  background: var(--bg-surface);
  border: 2px solid var(--border);
  border-radius: var(--card-radius);
  padding: 1rem;
  cursor: pointer;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), opacity var(--transition-fast);
  position: relative;
}

.ai-provider-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--card-shadow-hover);
}

.ai-provider-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 0 12px var(--accent-glow);
}

.ai-provider-card.active::after {
  content: 'ACTIVE';
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: var(--accent);
  color: #000;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  letter-spacing: 0.05em;
}

.ai-provider-card.active[data-priority-rank="1"]::after {
  content: '#1 PRIMARY';
}

.ai-provider-card[data-priority-rank]:not(.active) {
  border-color: var(--text-muted);
  border-style: dashed;
}

.ai-provider-card[data-priority-rank]:not(.active)::after {
  content: '#' attr(data-priority-rank) ' FALLBACK';
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: var(--bg-hover);
  color: var(--text-muted);
  font-size: 0.6rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  letter-spacing: 0.05em;
}

.ai-provider-card.active.no-key {
  border-color: var(--warning);
  box-shadow: 0 0 0 1px var(--warning), 0 0 12px rgba(245,158,11,0.15);
}

.ai-provider-card.active.no-key::after {
  content: '⚠ NO API KEY';
  background: var(--warning);
}

.ai-provider-card.coming-soon {
  opacity: 0.5;
  cursor: default;
  pointer-events: none;
}

.ai-provider-card.coming-soon::after {
  content: 'COMING SOON';
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: var(--bg-hover);
  color: var(--text-muted);
  font-size: 0.6rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  letter-spacing: 0.05em;
}

.ai-provider-card-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.ai-provider-card-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.ai-provider-card-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.ai-provider-card-info strong {
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-provider-card-status {
  font-size: 0.75rem;
  font-weight: 500;
}

.ai-provider-card-status.configured {
  color: var(--success);
}

.ai-provider-card-status.not-configured {
  color: var(--text-muted);
}

.ai-provider-active-model {
  background: var(--accent-muted);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 0.35rem 0.6rem;
  margin: 0.4rem 0;
  font-size: 0.78rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.ai-provider-active-model strong {
  color: var(--accent);
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.75rem;
}

/* Provider card footer with model count badge */
.ai-provider-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.5rem;
}

.model-count-badge {
  position: relative;
  display: inline-flex;
  align-items: center;
  font-size: 0.72rem;
  color: var(--text-muted);
  background: var(--bg-hover);
  padding: 0.2rem 0.5rem;
  border-radius: 10px;
  cursor: help;
  font-weight: 500;
  transition: color var(--transition-fast), background var(--transition-fast);
}

.model-count-badge:hover {
  color: var(--accent);
  background: var(--accent-muted);
}

/* Tooltip popup */
.model-tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0;
  min-width: 200px;
  max-width: 280px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  z-index: 100;
  pointer-events: none;
}

.model-count-badge:hover .model-tooltip {
  display: block;
}

.model-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  right: 1rem;
  border: 6px solid transparent;
  border-top-color: var(--border);
}

.model-tooltip-item {
  padding: 0.3rem 0.75rem;
  font-size: 0.78rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.model-tooltip-item:hover {
  background: var(--bg-hover);
}

.model-tooltip-item.default {
  color: var(--accent);
  font-weight: 600;
}

.ai-provider-card .api-key-input {
  margin-top: 0;
}

.ai-provider-card .api-key-input input {
  font-size: 0.85rem;
  padding: 0.4rem 0.6rem;
}

.ai-provider-card .form-hint {
  font-size: 0.75rem;
  margin-top: 0.3rem;
}

/* ==================== PROVIDER PRIORITY LIST ==================== */

.provider-priority-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.priority-item {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  overflow: hidden;
}

.priority-item:hover {
  border-color: var(--border-hover);
}

.priority-item.primary {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 0 8px var(--accent-glow);
}

.priority-item.no-key {
  opacity: 0.7;
  border-color: var(--warning);
}

.priority-item.expanded {
  border-color: var(--accent);
}

.priority-item.sortable-ghost {
  opacity: 0.4;
  border-style: dashed;
  border-color: var(--accent);
}

.priority-item.sortable-chosen {
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

/* Collapsed header row - always visible */
.priority-item-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.75rem;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.priority-item-header:hover {
  background: var(--bg-hover);
}

.priority-handle {
  color: var(--text-muted);
  font-size: 0.9rem;
  cursor: grab;
  user-select: none;
  flex-shrink: 0;
}

.priority-rank {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg-elevated);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
}

.priority-item.primary .priority-rank {
  background: var(--accent);
  color: #000;
}

.priority-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.priority-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.priority-info strong {
  color: var(--text-primary);
  font-size: 0.85rem;
}

.priority-model-preview {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: 'SF Mono', 'Fira Code', monospace;
}

.priority-badges {
  display: flex;
  gap: 0.3rem;
  flex-shrink: 0;
}

.priority-badge {
  font-size: 0.55rem;
  font-weight: 700;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}

.priority-badge.primary { background: var(--accent); color: #000; }
.priority-badge.fallback { background: var(--bg-hover); color: var(--text-muted); }
.priority-badge.no-key { background: var(--warning); color: #000; }

.priority-expand-icon {
  color: var(--text-muted);
  font-size: 0.6rem;
  flex-shrink: 0;
  width: 16px;
  text-align: center;
}

/* Expandable config body */
.priority-item-body {
  padding: 0 0.75rem 0.75rem;
  border-top: 1px solid var(--border);
  background: var(--bg-base);
}

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

.priority-config-row:last-of-type {
  border-bottom: none;
}

.priority-config-row label {
  font-size: 0.78rem;
  color: var(--text-muted);
  min-width: 130px;
  flex-shrink: 0;
}

.priority-model-select {
  flex: 1;
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.35rem 0.5rem;
  font-size: 0.8rem;
}

.priority-config-actions {
  padding-top: 0.5rem;
  display: flex;
  justify-content: flex-end;
}

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

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

.priority-empty {
  padding: 1rem;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: var(--card-radius);
  color: var(--text-muted);
  font-size: 0.85rem;
}

.priority-add-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  align-items: center;
}

.priority-add-row select {
  flex: 1;
  background: var(--bg-base);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  font-size: 0.85rem;
}

/* SAM.gov standalone card */
.api-key-card {
  background: var(--bg-surface);
  border: 2px solid var(--border);
  border-radius: var(--card-radius);
  padding: 1.25rem;
}

.api-key-card-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.api-key-card-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.api-key-card-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.api-key-card-status {
  font-size: 0.75rem;
  font-weight: 500;
}

.api-key-card-status.configured {
  color: var(--success);
}

.api-key-card-status.not-configured {
  color: var(--text-muted);
}

/* Prompt Template */
.prompt-placeholders {
  margin: 0.75rem 0;
}

.prompt-placeholders summary {
  cursor: pointer;
  color: var(--accent);
  font-size: 0.9rem;
}

.prompt-placeholders details[open] summary {
  margin-bottom: 0.5rem;
}

.placeholder-list {
  background: var(--bg-surface);
  padding: 0.75rem;
  border-radius: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.8;
}

.placeholder-list strong {
  color: var(--accent);
}

/* ==================== PLAYBOOKS ==================== */
.view-playbooks {
  flex: 1;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.playbooks-container {
  display: flex;
  height: 100%;
  width: 100%;
  gap: 0;
}

.playbooks-sidebar {
  width: 320px;
  min-width: 280px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.playbooks-header h3 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--text-primary);
}

.playbooks-search {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

.playbooks-search input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.playbooks-search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.playbooks-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

.category-tag {
  padding: 0.25rem 0.5rem;
  background: var(--bg-elevated);
  border: none;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.category-tag:hover {
  background: var(--bg-hover);
  color: var(--text-secondary);
}

.category-tag.active {
  background: var(--accent);
  color: #000;
}

.playbooks-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
}

.playbook-item {
  padding: 0.75rem 1rem;
  background: var(--bg-base);
  border: 1px solid transparent;
  border-radius: var(--card-radius);
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.playbook-item:hover {
  background: var(--bg-surface);
  border-color: var(--border);
}

.playbook-item.active {
  background: var(--accent-muted);
  border-color: var(--accent);
}

.playbook-item-title {
  font-weight: 500;
  color: var(--text-primary);
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
}

.playbook-item-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.playbook-item-category {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.playbook-item-badge {
  font-size: 0.65rem;
  padding: 0.15rem 0.4rem;
  background: var(--bg-elevated);
  border-radius: 4px;
  color: var(--text-muted);
}

.playbook-item-badge.default {
  background: var(--accent-muted);
  color: var(--accent);
}

.playbooks-hidden-section {
  padding: 1rem;
  border-top: 1px solid var(--border);
  background: var(--bg-base);
}

.playbooks-hidden-section h4 {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.hidden-playbook-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem;
  background: var(--bg-surface);
  border-radius: 6px;
  margin-bottom: 0.25rem;
  font-size: 0.8rem;
}

.hidden-playbook-item span {
  color: var(--text-muted);
}

.hidden-playbook-item button {
  padding: 0.2rem 0.5rem;
  font-size: 0.7rem;
}

.playbooks-content {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.playbook-viewer {
  flex: 1;
  overflow-y: auto;
  padding: 2rem;
}

.playbook-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  color: var(--text-muted);
}

.playbook-empty p:first-child {
  font-size: 1.2rem;
}

.playbook-view-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.playbook-view-title {
  margin: 0;
  font-size: 1.5rem;
  color: var(--text-primary);
}

.playbook-view-meta {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.playbook-view-category {
  font-size: 0.8rem;
  padding: 0.25rem 0.5rem;
  background: var(--bg-elevated);
  border-radius: 6px;
  color: var(--text-muted);
}

.playbook-view-actions {
  display: flex;
  gap: 0.5rem;
}

.playbook-rendered {
  color: var(--text-secondary);
  line-height: 1.7;
}

.playbook-rendered h1 {
  font-size: 1.8rem;
  color: var(--text-primary);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--accent);
}

.playbook-rendered h2 {
  font-size: 1.4rem;
  color: var(--text-primary);
  margin-top: 2rem;
  margin-bottom: 0.75rem;
}

.playbook-rendered h3 {
  font-size: 1.15rem;
  color: var(--text-secondary);
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

.playbook-rendered h4 {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-top: 1.25rem;
  margin-bottom: 0.5rem;
}

.playbook-rendered p {
  margin-bottom: 1rem;
}

.playbook-rendered ul, .playbook-rendered ol {
  margin-bottom: 1rem;
  padding-left: 1.5rem;
}

.playbook-rendered li {
  margin-bottom: 0.5rem;
}

.playbook-rendered blockquote {
  border-left: 4px solid var(--accent);
  padding: 0.75rem 1rem;
  background: var(--bg-surface);
  margin: 1rem 0;
  border-radius: 0 var(--card-radius) var(--card-radius) 0;
  font-style: italic;
  color: var(--text-muted);
}

.playbook-rendered code {
  background: var(--bg-surface);
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 0.9em;
  color: #f472b6;
}

.playbook-rendered pre {
  background: var(--bg-surface);
  padding: 1rem;
  border-radius: var(--card-radius);
  overflow-x: auto;
  margin: 1rem 0;
}

.playbook-rendered pre code {
  background: none;
  padding: 0;
  color: var(--text-secondary);
}

.playbook-rendered table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
}

.playbook-rendered th, .playbook-rendered td {
  padding: 0.75rem;
  border: 1px solid var(--border);
  text-align: left;
}

.playbook-rendered th {
  background: var(--bg-surface);
  color: var(--text-primary);
  font-weight: 600;
}

.playbook-rendered td {
  background: var(--bg-base);
}

.playbook-rendered hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

.playbook-rendered strong {
  color: var(--text-primary);
}

.playbook-rendered a {
  color: var(--accent);
  text-decoration: none;
}

.playbook-rendered a:hover {
  text-decoration: underline;
}

/* Modal wide variant */
.modal-content.modal-wide {
  max-width: 1400px !important;
  width: 95% !important;
  max-height: 90vh !important;
  display: flex;
  flex-direction: column;
}

.modal-content.modal-wide textarea#playbookEditContent {
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 0.95rem;
  line-height: 1.6;
  resize: vertical;
  min-height: 55vh;
  height: 55vh;
  width: 100%;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  padding: 1rem;
  color: var(--text-secondary);
}

.modal-content.modal-wide .form-group label {
  display: block;
  margin-bottom: 0.5rem;
}

.modal-content.modal-wide .form-group input,
.modal-content.modal-wide .form-row input {
  width: 100%;
  padding: 0.75rem;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-secondary);
}

.form-row {
  display: flex;
  gap: 1rem;
}

.form-row .form-group {
  flex: 1;
}

/* Playbooks type tabs */
.playbooks-type-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.type-tab {
  flex: 1;
  padding: 0.75rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  border-bottom: 2px solid transparent;
}

.type-tab:hover {
  color: var(--text-muted);
  background: var(--bg-surface);
}

.type-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: var(--bg-surface);
}

/* Tags filter */
.playbooks-tags-filter {
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  max-height: 80px;
  overflow-y: auto;
}

.tag-filter {
  padding: 0.2rem 0.5rem;
  background: var(--bg-elevated);
  border: none;
  border-radius: 12px;
  color: var(--text-muted);
  font-size: 0.7rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.tag-filter:hover {
  background: var(--bg-hover);
  color: var(--text-secondary);
}

.tag-filter.active {
  background: var(--purple);
  color: white;
}

/* Pin indicator */
.playbook-item.pinned {
  border-left: 3px solid var(--warning);
}

.pin-indicator {
  color: var(--warning);
  font-size: 0.8rem;
  margin-right: 0.25rem;
}

/* Tags display */
.playbook-item-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.25rem;
}

.playbook-tag {
  padding: 0.1rem 0.35rem;
  background: var(--bg-hover);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 0.65rem;
}

/* Playbook view tags */
.playbook-view-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.5rem;
}

.playbook-view-tag {
  padding: 0.2rem 0.5rem;
  background: var(--bg-hover);
  border-radius: 12px;
  color: var(--text-secondary);
  font-size: 0.75rem;
}

/* Linked opportunities section */
.playbook-linked-opps {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.playbook-linked-opps h4 {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}

.linked-opp-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.75rem;
  background: var(--bg-surface);
  border-radius: 8px;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
}

.linked-opp-item:hover {
  background: var(--bg-elevated);
}

.linked-opp-title {
  color: var(--text-secondary);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.linked-opp-deadline {
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-left: 1rem;
}

/* Tags input suggestions */
.tags-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.5rem;
}

.tag-suggestion {
  padding: 0.2rem 0.5rem;
  background: var(--bg-elevated);
  border: none;
  border-radius: 12px;
  color: var(--text-muted);
  font-size: 0.7rem;
  cursor: pointer;
}

.tag-suggestion:hover {
  background: var(--purple);
  color: white;
}

/* Export/Print button */
.btn-export {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #000;
}

.btn-export:hover {
  background: var(--accent);
}

/* Header actions */
.playbooks-header-actions {
  display: flex;
  gap: 0.5rem;
}

/* ==================== FILE UPLOAD STYLES ==================== */
.file-upload-section {
  margin-bottom: 1rem;
}

.file-upload-area {
  border: 2px dashed var(--border-hover);
  border-radius: var(--card-radius);
  padding: 1.5rem;
  text-align: center;
  transition: all var(--transition-fast);
  background: var(--bg-surface);
}

.file-upload-area:hover {
  border-color: var(--accent);
  background: var(--accent-muted);
}

.file-upload-area.drag-over {
  border-color: var(--accent);
  background: var(--accent-muted);
  transform: scale(1.01);
}

.file-upload-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.file-upload-hint {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.supported-types {
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-top: 0.5rem;
}

.file-preview {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem;
  background: var(--bg-base);
  border-radius: 8px;
}

.file-preview .file-icon {
  font-size: 2rem;
}

.file-preview .file-info {
  flex: 1;
  text-align: left;
}

.file-preview .file-name {
  display: block;
  font-weight: 500;
  color: var(--text-primary);
}

.file-preview .file-size {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.existing-file-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
  padding: 0.75rem;
  background: var(--accent-muted);
  border-radius: 8px;
  border: 1px solid var(--accent);
}

.existing-file-info .file-icon {
  font-size: 1.25rem;
}

.existing-file-info .file-name {
  flex: 1;
  color: var(--accent);
  font-weight: 500;
}

/* Template Upload Modal */
.upload-drop-zone {
  border: 2px dashed var(--border-hover);
  border-radius: var(--card-radius);
  padding: 2rem;
  text-align: center;
  transition: all var(--transition-fast);
  background: var(--bg-surface);
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.upload-drop-zone:hover {
  border-color: var(--accent);
  background: var(--accent-muted);
}

.upload-drop-zone.drag-over {
  border-color: var(--success);
  background: rgba(34, 197, 94, 0.15);
  transform: scale(1.02);
}

.drop-zone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.drop-zone-content .drop-icon {
  font-size: 3rem;
  margin-bottom: 0.5rem;
}

.drop-zone-content p {
  color: var(--text-muted);
  margin: 0.25rem 0;
}

.drop-zone-content .supported-formats {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 1rem;
}

.drop-zone-content .max-size {
  font-size: 0.7rem;
  color: var(--bg-hover);
}

.drop-zone-preview {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
  padding: 1rem;
  background: var(--bg-base);
  border-radius: var(--card-radius);
}

.drop-zone-preview .preview-icon {
  font-size: 2.5rem;
}

.drop-zone-preview .preview-info {
  flex: 1;
  text-align: left;
}

.drop-zone-preview .preview-name {
  display: block;
  font-weight: 600;
  color: var(--text-primary);
  font-size: 1rem;
}

.drop-zone-preview .preview-size {
  display: block;
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* File type icons */
.file-type-pdf { color: var(--danger); }
.file-type-doc, .file-type-docx { color: var(--info); }
.file-type-xls, .file-type-xlsx { color: var(--success); }
.file-type-txt, .file-type-md { color: var(--text-muted); }
.file-type-csv { color: var(--warning); }

/* Playbook file info display */
.playbook-file-info {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: var(--accent-muted);
  border: 1px solid var(--accent);
  border-radius: var(--card-radius);
  margin-bottom: 1.5rem;
}

.playbook-file-info .file-icon {
  font-size: 2rem;
}

.playbook-file-info .file-details {
  flex: 1;
}

.playbook-file-info .file-details strong {
  display: block;
  color: var(--text-primary);
}

.playbook-file-info .file-size {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* ==================== CONTENT FORMAT STYLES ==================== */
.formatted-html-content {
  background: var(--bg-surface);
  padding: 1.5rem;
  border-radius: var(--card-radius);
  line-height: 1.7;
}

.formatted-html-content h1,
.formatted-html-content h2,
.formatted-html-content h3 {
  color: var(--text-primary);
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
}

.formatted-html-content h1:first-child,
.formatted-html-content h2:first-child,
.formatted-html-content h3:first-child {
  margin-top: 0;
}

.formatted-html-content p {
  margin-bottom: 1rem;
}

.formatted-html-content ul,
.formatted-html-content ol {
  margin: 1rem 0;
  padding-left: 1.5rem;
}

.formatted-html-content li {
  margin-bottom: 0.5rem;
}

.formatted-html-content strong {
  color: var(--text-primary);
}

.formatted-html-content em {
  color: var(--text-secondary);
}

/* Excel table styling */
.formatted-html-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.875rem;
}

.formatted-html-content th,
.formatted-html-content td {
  padding: 0.75rem;
  border: 1px solid var(--border-hover);
  text-align: left;
}

.formatted-html-content th {
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-weight: 600;
}

.formatted-html-content tr:nth-child(even) {
  background: var(--accent-muted);
}

.formatted-html-content tr:hover {
  background: var(--bg-elevated);
}

/* PDF text content */
.pdf-text-content {
  background: var(--bg-surface);
  border-radius: var(--card-radius);
  overflow: hidden;
}

.pdf-notice {
  padding: 0.75rem 1rem;
  background: var(--accent-muted);
  border-bottom: 1px solid var(--accent);
  margin: 0;
  color: var(--accent);
  font-size: 0.875rem;
}

.pdf-text {
  padding: 1.5rem;
  margin: 0;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--text-secondary);
  max-height: 600px;
  overflow-y: auto;
}

/* Plain text content */
.plain-text-content {
  background: var(--bg-surface);
  padding: 1.5rem;
  border-radius: var(--card-radius);
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

/* ==================== COST TRACKING STYLES ==================== */
.view-costs {
  height: 100%;
  width: 100%;
  overflow-y: auto;
  padding: 1.5rem 2rem;
  flex: 1;
}

.view-costs .costs-container {
  max-width: 100%;
  width: 100%;
}

.view-costs .costs-section {
  width: 100%;
}

/* Spacer at bottom */
.api-usage-section::after,
.business-costs-section::after {
  content: '';
  display: block;
  height: 80px;
}

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

/* Cost Form Card */
.costs-form-card {
  background: var(--accent-muted);
  border: 1px solid var(--accent);
  border-radius: var(--card-radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.costs-form-card h3 {
  color: var(--text-primary);
  margin-bottom: 1rem;
  font-size: 1.1rem;
}

.cost-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.cost-form-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: flex-end;
}

.cost-form-row .form-group {
  flex: 1;
  min-width: 150px;
}

.cost-form-row .form-group label {
  display: block;
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
}

.cost-form-row .form-group input,
.cost-form-row .form-group select {
  width: 100%;
  padding: 0.625rem 0.75rem;
  background: var(--bg-base);
  border: 1px solid var(--border-hover);
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.cost-form-row .form-group input:focus,
.cost-form-row .form-group select:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.checkbox-inline label {
  display: flex !important;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  color: var(--text-secondary) !important;
  padding-top: 1.5rem;
}

.checkbox-inline input[type="checkbox"] {
  width: auto !important;
  accent-color: var(--accent);
}

/* Cost Summary Cards */
.costs-summary {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.cost-summary-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  padding: 1.25rem 1.5rem;
  flex: 1;
  min-width: 140px;
  text-align: center;
  transition: transform var(--transition-fast), border-color var(--transition-fast);
  box-shadow: var(--card-shadow);
}

.cost-summary-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.cost-summary-card.all-time {
  background: var(--accent-muted);
  border-color: var(--accent);
}

.cost-summary-card .cost-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.cost-summary-card .cost-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
}

.cost-summary-card.all-time .cost-value {
  color: var(--accent);
}

/* Charts Section */
.costs-charts {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 1000px) {
  .costs-charts {
    grid-template-columns: 1fr;
  }
}

.chart-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  padding: 1.25rem;
  box-shadow: var(--card-shadow);
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chart-header h4 {
  color: var(--text-primary);
  font-size: 1rem;
  margin: 0;
}

.chart-controls {
  display: flex;
  gap: 0.25rem;
}

.chart-period-btn {
  padding: 0.375rem 0.75rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-hover);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.chart-period-btn:hover {
  background: var(--bg-hover);
  color: var(--text-secondary);
}

.chart-period-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
  font-weight: 600;
}

.chart-container {
  position: relative;
  height: 280px;
  width: 100%;
  min-width: 0;
}

.chart-container.chart-small {
  height: 280px;
}

/* Costs List Section */
.costs-list-section {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--card-shadow);
}

.costs-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.costs-list-header h4 {
  color: var(--text-primary);
  margin: 0;
}

.costs-filters {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.costs-filters select,
.costs-filters input {
  padding: 0.5rem 0.75rem;
  background: var(--bg-base);
  border: 1px solid var(--border-hover);
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.costs-list {
  max-height: 400px;
  overflow-y: auto;
}

.cost-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.875rem 1rem;
  background: var(--bg-base);
  border-radius: var(--card-radius);
  margin-bottom: 0.5rem;
  transition: background var(--transition-fast);
}

.cost-item:hover {
  background: var(--bg-elevated);
}

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

.cost-item-category {
  background: var(--bg-elevated);
  padding: 0.25rem 0.625rem;
  border-radius: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
  min-width: 120px;
  text-align: center;
}

.cost-item-desc {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.cost-item-opp {
  color: var(--accent);
  font-size: 0.75rem;
  margin-top: 0.25rem;
}

.cost-item-right {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.cost-item-amount {
  font-weight: 600;
  font-size: 1rem;
  color: var(--danger);
  min-width: 80px;
  text-align: right;
}

.cost-item-date {
  color: var(--text-muted);
  font-size: 0.875rem;
  min-width: 100px;
}

.cost-item-actions {
  display: flex;
  gap: 0.25rem;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.cost-item:hover .cost-item-actions {
  opacity: 1;
}

.cost-item-actions button {
  padding: 0.25rem 0.5rem;
  background: transparent;
  border: 1px solid var(--border-hover);
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.8rem;
}

.cost-item-actions button:hover {
  background: var(--bg-elevated);
  color: var(--text-secondary);
}

.cost-item-actions button.delete:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

/* Cost Analysis Section */
.costs-analysis {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

@media (max-width: 800px) {
  .costs-analysis {
    grid-template-columns: 1fr;
  }
}

.analysis-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  padding: 1.25rem;
  box-shadow: var(--card-shadow);
}

.analysis-card h4 {
  color: var(--text-primary);
  margin: 0 0 1rem 0;
  font-size: 1rem;
}

.analysis-content {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.analysis-row {
  display: flex;
  justify-content: space-between;
  padding: 0.625rem 0;
  border-bottom: 1px solid var(--border);
}

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

.analysis-row span:first-child {
  color: var(--text-muted);
}

.analysis-row span:last-child {
  color: var(--text-primary);
  font-weight: 600;
}

.opportunity-costs {
  max-height: 200px;
  overflow-y: auto;
}

.opp-cost-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.625rem;
  background: var(--bg-base);
  border-radius: 8px;
  margin-bottom: 0.5rem;
}

.opp-cost-item .opp-title {
  color: var(--text-secondary);
  font-size: 0.875rem;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.opp-cost-item .opp-total {
  color: var(--danger);
  font-weight: 600;
  margin-left: 1rem;
}

/* Empty state */
.costs-empty {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
}

.costs-empty-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

/* Category colors */
.category-proposal { background: var(--info); color: #fff; }
.category-labor { background: var(--success); color: #000; }
.category-software { background: var(--purple); color: #fff; }
.category-marketing { background: var(--warning); color: #000; }
.category-travel { background: #06b6d4; color: #fff; }
.category-legal { background: var(--danger); color: #fff; }
.category-training { background: #ec4899; color: #fff; }
.category-subscriptions { background: #8b5cf6; color: #fff; }
.category-office { background: var(--text-muted); color: #fff; }
.category-other { background: var(--bg-hover); color: #fff; }

/* ==================== COSTS TABS ==================== */
.costs-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0;
}

.costs-tab {
  padding: 0.75rem 1.5rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: all var(--transition-fast);
}

.costs-tab:hover {
  color: var(--text-secondary);
}

.costs-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ==================== API USAGE STYLES ==================== */
.api-usage-section {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.api-period-selector {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.api-period-selector span {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.period-btn {
  padding: 0.5rem 1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-hover);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.period-btn:hover {
  background: var(--bg-hover);
  color: var(--text-secondary);
}

.period-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
  font-weight: 600;
}

/* API Summary Cards */
.api-summary-cards {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.api-summary-card {
  background: var(--accent-muted);
  border: 1px solid var(--accent);
  border-radius: var(--card-radius);
  padding: 1.25rem 1.5rem;
  flex: 1;
  min-width: 140px;
  text-align: center;
  box-shadow: var(--card-shadow);
}

.api-metric-value {
  display: block;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--accent);
}

.api-metric-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.5rem;
}

.api-summary-card-model .api-metric-value {
  font-size: 1.1rem;
  word-break: break-all;
  cursor: default;
}

/* API Charts */
.api-charts-row {
  display: flex;
  gap: 1.5rem;
}

@media (max-width: 1000px) {
  .api-charts-row {
    flex-direction: column;
  }
}

.api-chart-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  padding: 1.25rem;
  box-shadow: var(--card-shadow);
}

.api-chart-card h4 {
  color: var(--text-primary);
  margin: 0 0 1rem 0;
  font-size: 1rem;
}

/* API Details */
.api-details-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

@media (max-width: 800px) {
  .api-details-row {
    grid-template-columns: 1fr;
  }
}

.api-details-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  padding: 1.25rem;
  box-shadow: var(--card-shadow);
}

.api-details-card h4 {
  color: var(--text-primary);
  margin: 0 0 1rem 0;
  font-size: 1rem;
}

.api-list {
  max-height: 250px;
  overflow-y: auto;
}

.api-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  background: var(--bg-base);
  border-radius: 8px;
  margin-bottom: 0.5rem;
}

.api-list-item .item-name {
  color: var(--text-secondary);
  font-weight: 500;
  flex: 1;
}

.api-list-item .item-stats {
  display: flex;
  gap: 1rem;
  font-size: 0.875rem;
}

.api-list-item .stat-tokens {
  color: var(--text-muted);
}

.api-list-item .stat-cost {
  color: var(--danger);
  font-weight: 600;
}

.api-list-item .stat-calls {
  color: var(--accent);
}

/* Recent API Calls */
.api-recent-section {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  padding: 1.25rem;
  box-shadow: var(--card-shadow);
}

.api-recent-section h4 {
  color: var(--text-primary);
  margin: 0 0 1rem 0;
}

.api-calls-list {
  max-height: 300px;
  overflow: auto;
  border-radius: 8px;
}

.api-calls-list-inner {
  display: inline-block;
  min-width: 100%;
  background: var(--bg-base);
  border-radius: 8px;
  padding: 0.25rem;
}

.api-call-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
  min-width: 620px;
}

.api-call-item .call-info {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex: 1;
}

.api-call-item .call-model {
  background: var(--bg-elevated);
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  color: var(--accent);
  font-size: 0.75rem;
  min-width: 100px;
  text-align: center;
}

.api-call-item .call-endpoint {
  color: var(--text-muted);
  min-width: 100px;
}

.api-call-item .call-opp {
  color: var(--text-secondary);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.api-call-item .call-tokens {
  color: var(--text-muted);
  min-width: 80px;
  text-align: right;
}

.api-call-item .call-cost {
  color: var(--danger);
  font-weight: 600;
  min-width: 70px;
  text-align: right;
}

.api-call-item .call-time {
  color: var(--text-muted);
  font-size: 0.75rem;
  min-width: 140px;
  text-align: right;
}

.api-call-item.failed {
  border-left: 3px solid var(--danger);
}

/* Pricing Reference */
.api-pricing-reference {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--card-shadow);
}

.api-pricing-reference h4 {
  color: var(--text-primary);
  margin: 0 0 1rem 0;
}

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

.pricing-item {
  display: flex;
  justify-content: space-between;
  padding: 0.75rem;
  background: var(--bg-base);
  border-radius: 8px;
}

.pricing-item .model-name {
  color: var(--accent);
  font-weight: 500;
}

.pricing-item .model-price {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.pricing-item .model-price span {
  color: var(--text-secondary);
  font-weight: 600;
}

/* Staging & Analysis Status */
.opp-tag.staged {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
}

.opp-tag.analyzed {
  background: rgba(34, 197, 94, 0.2);
  color: #4ade80;
}

.badge-staged {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.7rem;
}

.badge-analyzed {
  background: rgba(34, 197, 94, 0.2);
  color: #4ade80;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.7rem;
}

/* ==================== LIGHT MODE FIXES ==================== */
[data-theme="light"] .opp-tag.staged,
[data-theme="light"] .badge-staged {
  color: #b45309;
}

[data-theme="light"] .opp-tag.analyzed,
[data-theme="light"] .badge-analyzed {
  color: #15803d;
}

[data-theme="light"] .scope-viewer-content.formatted-mode code,
[data-theme="light"] .playbook-rendered code {
  color: #db2777;
}

[data-theme="light"] .flatpickr-calendar {
  background: var(--bg-surface);
  border-color: var(--border);
  box-shadow: var(--card-shadow-hover);
}

[data-theme="light"] .flatpickr-months,
[data-theme="light"] .flatpickr-weekdays,
[data-theme="light"] .flatpickr-month {
  background: var(--bg-elevated);
}

[data-theme="light"] .flatpickr-day {
  color: var(--text-primary);
}

[data-theme="light"] .flatpickr-day:hover {
  background: var(--bg-hover);
  border-color: var(--border-hover);
}

[data-theme="light"] .flatpickr-day.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

/* ==================== COSTS DASHBOARD CARD LAYOUT ==================== */

/* Toolbar */
.costs-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  flex-wrap: wrap;
}

.costs-toolbar-left,
.costs-toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.costs-toolbar-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-right: 0.25rem;
}

.costs-grid-col-btn {
  padding: 0.375rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-hover);
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.costs-grid-col-btn:hover {
  background: var(--bg-hover);
  color: var(--text-secondary);
}

.costs-grid-col-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
}

/* Card Grid */
.costs-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.5rem;
  width: 100%;
}

/* Card Base */
.costs-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  padding: 1.25rem;
  max-height: 500px;
  overflow-y: auto;
  box-shadow: var(--card-shadow);
  min-width: 0;
}

.costs-card-chart {
  max-height: none;
  overflow: visible;
}

/* Card Header */
.costs-card-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.costs-card-header h3 {
  flex: 1;
  margin: 0;
  padding: 0;
  border: none;
  font-size: 0.9rem;
  color: var(--text-primary);
}

/* Drag Handle */
.costs-drag-handle {
  cursor: grab;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 0.125rem 0.25rem;
  border-radius: 4px;
  transition: color var(--transition-fast), background var(--transition-fast);
  user-select: none;
}

.costs-drag-handle:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.costs-drag-handle:active {
  cursor: grabbing;
}

/* Card Controls */
.costs-card-controls {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.costs-card:hover .costs-card-controls {
  opacity: 1;
}

/* Collapsible Card Body */
.costs-card-body {
  transition: max-height 250ms ease, opacity 200ms ease, padding 200ms ease;
  overflow: hidden;
  min-width: 0;
}

.costs-card.collapsed .costs-card-body {
  max-height: 0 !important;
  opacity: 0;
  padding: 0;
  overflow: hidden;
}

.costs-card.collapsed .costs-collapse-icon {
  transform: rotate(180deg);
}

.costs-card.collapsed {
  max-height: none;
}

.costs-collapse-icon {
  display: inline-block;
  transition: transform var(--transition-fast);
}

/* Card Sizing */
.costs-card-size-wide {
  grid-column: span 2;
}

.costs-grid[data-cols="1"] .costs-card-size-wide {
  grid-column: span 1;
}

/* Form card accent tint */
.costs-card[data-card-id="biz-form"] {
  border-color: var(--accent);
  box-shadow: var(--card-shadow), 0 0 0 1px rgba(99, 102, 241, 0.1);
}

/* SortableJS Classes */
.costs-card.sortable-ghost {
  opacity: 0.4;
  background: var(--accent-muted);
  border: 2px dashed var(--accent);
}

.costs-card.sortable-chosen {
  box-shadow: var(--card-shadow-hover);
}

.costs-card.sortable-drag {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.costs-card.card-hidden {
  display: none;
}

/* Manage Cards Menu for Costs */
.costs-manage-cards-menu {
  right: 0;
  left: auto;
  min-width: 280px;
  max-height: 400px;
  overflow-y: auto;
  padding: 0.5rem 0;
}

.costs-manage-cards-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.costs-manage-cards-item label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  flex: 1;
}

.costs-manage-cards-item input[type="checkbox"] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* Mobile: force 1 column, always-visible controls */
@media (max-width: 768px) {
  .costs-grid {
    grid-template-columns: 1fr !important;
  }
  .costs-card-size-wide {
    grid-column: span 1;
  }
  .costs-card-controls {
    opacity: 1;
  }
}

/* ==================== BUDGET & ROI COMPONENTS ==================== */

/* Budget Progress Bar */
.budget-progress-bar {
  width: 100%;
  height: 10px;
  background: var(--bg-elevated);
  border-radius: 5px;
  overflow: hidden;
  margin: 0.25rem 0;
}

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

.budget-progress-fill.warning {
  background: var(--warning);
}

.budget-progress-fill.alert {
  background: #f97316;
}

.budget-progress-fill.critical {
  background: var(--danger);
}

.budget-progress-fill.exceeded {
  background: var(--danger);
  animation: budget-pulse 1.5s ease-in-out infinite;
}

@keyframes budget-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* Budget Provider Row */
.budget-provider-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

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

.budget-provider-name {
  min-width: 80px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.budget-provider-bar {
  flex: 1;
}

.budget-provider-stats {
  min-width: 120px;
  text-align: right;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.budget-provider-stats .budget-spent {
  color: var(--text-primary);
  font-weight: 600;
}

.budget-forecast {
  margin-top: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg-elevated);
  border-radius: 6px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.budget-forecast.on-track {
  border-left: 3px solid var(--accent);
}

.budget-forecast.over-budget {
  border-left: 3px solid var(--danger);
  color: var(--danger);
}

.budget-no-limits {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.budget-no-limits a {
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
}

.budget-active-model {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
}

.budget-model-badge {
  background: var(--accent-muted);
  color: var(--accent);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-weight: 600;
  text-transform: capitalize;
}

.budget-model-name {
  color: var(--text-secondary);
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.75rem;
}

.budget-update-link {
  margin-top: 0.75rem;
  text-align: right;
  font-size: 0.8rem;
}

.budget-update-link a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s;
}

.budget-update-link a:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* ROI Metrics */
.roi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 1rem;
}

.roi-metric {
  text-align: center;
  padding: 0.75rem;
  background: var(--bg-elevated);
  border-radius: 8px;
}

.roi-metric-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
  display: block;
  margin-bottom: 0.25rem;
}

.roi-metric-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Cost Per Analysis */
.cost-per-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

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

.cost-per-endpoint {
  color: var(--text-secondary);
  font-weight: 500;
}

.cost-per-stats {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.cost-per-value {
  color: var(--accent);
  font-weight: 600;
}

.cost-per-calls {
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* Spend Limits — How it works (collapsible) */
.spend-limits-howto {
  background: var(--bg-selected);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 1.5rem;
  font-size: 0.85rem;
  line-height: 1.6;
}

.spend-limits-howto summary {
  padding: 0.75rem 1.25rem;
  cursor: pointer;
  font-weight: 600;
  color: var(--text-primary);
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.spend-limits-howto summary::before {
  content: '▸';
  transition: transform 0.15s ease;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.spend-limits-howto[open] summary::before {
  transform: rotate(90deg);
}

.spend-limits-howto summary::-webkit-details-marker {
  display: none;
}

.spend-limits-howto-body {
  padding: 0 1.25rem 1rem;
}

.spend-limits-howto-body ul {
  margin: 0 0 0 1.25rem;
  padding: 0;
  color: var(--text-secondary);
}

.spend-limits-howto-body li {
  margin-bottom: 0.3rem;
}

.spend-limits-howto-example {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* Spend Limits Settings */
.spend-limits-section {
  margin-top: 1.5rem;
}

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

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

.spend-limit-row label {
  min-width: 150px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.spend-limit-row input[type="number"] {
  width: 120px;
  padding: 0.5rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 0.9rem;
}

.spend-limit-row input[type="number"]:focus {
  border-color: var(--accent);
  outline: none;
}

.spend-limit-status {
  flex: 1;
  min-width: 180px;
}

.spend-limit-status-inactive {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
}

.spend-limit-status-active {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.spend-limit-status-text {
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.spend-limit-status-text .limit-percent {
  font-weight: 600;
  font-size: 0.75rem;
}

.spend-limit-mini-bar {
  width: 100%;
  height: 6px;
  background: var(--bg-elevated);
  border-radius: 3px;
  overflow: hidden;
}

.spend-limit-mini-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--accent);
  transition: width 0.4s ease;
}

.spend-limit-mini-fill.warning { background: #eab308; }
.spend-limit-mini-fill.alert { background: #f97316; }
.spend-limit-mini-fill.critical { background: var(--danger); }
.spend-limit-mini-fill.exceeded { background: var(--danger); animation: budget-pulse 1.5s infinite; }

/* Active limits summary banner */
.spend-limits-active-summary {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
}

.spend-limits-active-summary h4 {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.spend-limits-active-summary .summary-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.4rem 0;
}

.spend-limits-active-summary .summary-label {
  min-width: 120px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.spend-limits-active-summary .summary-bar {
  flex: 1;
  height: 8px;
  background: var(--bg-main);
  border-radius: 4px;
  overflow: hidden;
}

.spend-limits-active-summary .summary-fill {
  height: 100%;
  border-radius: 4px;
  background: var(--accent);
  transition: width 0.4s ease;
}

.spend-limits-active-summary .summary-fill.warning { background: #eab308; }
.spend-limits-active-summary .summary-fill.alert { background: #f97316; }
.spend-limits-active-summary .summary-fill.critical { background: var(--danger); }
.spend-limits-active-summary .summary-fill.exceeded { background: var(--danger); animation: budget-pulse 1.5s infinite; }

.spend-limits-active-summary .summary-value {
  min-width: 140px;
  text-align: right;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.spend-limits-active-summary .summary-value strong {
  color: var(--text-primary);
}

.spend-limits-no-active {
  padding: 0.5rem 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ==================== INVITE WELCOME ==================== */

.invite-welcome-card {
  background: var(--bg-card, #1e293b);
  border: 1px solid var(--primary, #3b82f6);
  border-radius: 0.75rem;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  max-width: 380px;
  margin-left: auto;
  margin-right: auto;
}

.invite-welcome-icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.invite-welcome-title {
  color: var(--text-primary, #f8fafc);
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0 0 0.5rem 0;
}

.invite-welcome-detail {
  color: var(--text-secondary, #cbd5e1);
  font-size: 0.9rem;
  margin: 0 0 0.5rem 0;
  line-height: 1.5;
}

.invite-welcome-detail strong {
  color: var(--primary, #3b82f6);
}

.invite-welcome-hint {
  color: var(--text-muted, #64748b);
  font-size: 0.8rem;
  margin: 0;
}

.invite-error-card {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 0.5rem;
  padding: 1rem;
  margin-bottom: 1.5rem;
  max-width: 380px;
  margin-left: auto;
  margin-right: auto;
}

/* ==================== ONBOARDING SCREEN ==================== */

.onboarding-backdrop {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-base, #0f172a);
  padding: 1rem;
}

.onboarding-card {
  background: var(--bg-card, #1e293b);
  border: 1px solid var(--border, #334155);
  border-radius: 1rem;
  padding: 2.5rem;
  max-width: 480px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.onboarding-logo {
  width: 72px;
  height: 72px;
  margin-bottom: 1rem;
}

.onboarding-title {
  color: var(--text-primary, #f8fafc);
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 0.5rem 0;
}

.onboarding-subtitle {
  color: var(--text-muted, #94a3b8);
  font-size: 0.95rem;
  margin: 0 0 2rem 0;
  line-height: 1.5;
}

.onboarding-field {
  text-align: left;
  margin-bottom: 1.5rem;
}

.onboarding-label {
  display: block;
  color: var(--text-secondary, #cbd5e1);
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.onboarding-input {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-base, #0f172a);
  border: 1px solid var(--border, #334155);
  border-radius: 0.5rem;
  color: var(--text-primary, #f8fafc);
  font-size: 1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
}

.onboarding-input:focus {
  outline: none;
  border-color: var(--primary, #3b82f6);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.onboarding-input.input-error {
  border-color: #ef4444;
}

.onboarding-input.input-valid {
  border-color: #22c55e;
}

.onboarding-hint {
  color: var(--text-muted, #64748b);
  font-size: 0.78rem;
  margin-top: 0.4rem;
}

.onboarding-error {
  color: #ef4444;
  font-size: 0.82rem;
  margin-top: 0.4rem;
  font-weight: 500;
}

.onboarding-available {
  color: #22c55e;
  font-size: 0.82rem;
  margin-top: 0.4rem;
  font-weight: 500;
}

.onboarding-btn {
  width: 100%;
  padding: 0.8rem 1.5rem;
  background: var(--primary, #3b82f6);
  color: #fff;
  border: none;
  border-radius: 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.onboarding-btn:hover {
  background: var(--primary-hover, #2563eb);
}

.onboarding-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.onboarding-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: onboarding-spin 0.6s linear infinite;
}

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

/* ==================== ORG SWITCHER ==================== */

.org-switcher {
  position: relative;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.org-switcher-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.5rem 0.65rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  transition: background 150ms ease, border-color 150ms ease;
  position: relative;
}

.org-switcher-btn:hover {
  background: var(--bg-surface);
  border-color: var(--border-hover, #3f3f46);
}

.org-switcher-icon {
  font-size: 1rem;
  flex-shrink: 0;
}

.org-name {
  flex: 1;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.org-switcher-arrow {
  font-size: 0.7rem;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: transform 150ms ease;
}

.org-switcher.open .org-switcher-arrow {
  transform: rotate(180deg);
}

.invite-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--danger);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  line-height: 1;
}

.org-switcher-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0.75rem;
  right: 0.75rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-hover, #3f3f46);
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  z-index: 200;
  max-height: 320px;
  overflow-y: auto;
}

.org-switcher.open .org-switcher-menu {
  display: block;
}

.org-switcher-section {
  padding: 0.25rem 0;
}

.org-switcher-label {
  padding: 0.4rem 0.75rem 0.25rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.org-switcher-divider {
  height: 1px;
  background: var(--border);
  margin: 0.25rem 0;
}

.org-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  transition: background 150ms ease;
  font-size: 0.82rem;
}

.org-item:hover {
  background: var(--bg-elevated);
}

.org-item-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-primary);
}

.org-item-active {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
}

.org-item-role {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  flex-shrink: 0;
}

.org-item-role.owner { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.org-item-role.admin { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }
.org-item-role.member { background: rgba(16, 185, 129, 0.15); color: #10b981; }
.org-item-role.viewer { background: rgba(148, 163, 184, 0.15); color: #94a3b8; }

.org-invite-item {
  padding: 0.5rem 0.75rem;
  font-size: 0.82rem;
}

.org-invite-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.35rem;
}

.org-invite-name {
  color: var(--text-primary);
  font-weight: 500;
}

.org-invite-role {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.org-invite-from {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.org-invite-actions {
  display: flex;
  gap: 0.4rem;
}

.org-invite-actions button {
  padding: 0.25rem 0.6rem;
  border-radius: 5px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: background 150ms ease;
}

.org-invite-accept {
  background: var(--success);
  color: #fff;
  border-color: var(--success) !important;
}
.org-invite-accept:hover { opacity: 0.85; }

.org-invite-decline {
  background: transparent;
  color: var(--text-muted);
}
.org-invite-decline:hover { background: var(--bg-elevated); color: var(--danger); }

/* Collapsed sidebar hides org switcher text */
.sidebar.collapsed .org-switcher-btn .org-name,
.sidebar.collapsed .org-switcher-btn .org-switcher-arrow,
.sidebar.collapsed .org-switcher-label {
  display: none;
}
.sidebar.collapsed .org-switcher-btn {
  justify-content: center;
  padding: 0.5rem;
}
.sidebar.collapsed .org-switcher-menu {
  left: 100%;
  top: 0;
  right: auto;
  min-width: 220px;
  margin-left: 4px;
}

/* ==================== RBAC / Team Management Enhancements ==================== */

/* Team member rows */
.team-member-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem;
  background: var(--bg-elevated);
  border-radius: 8px;
  margin-bottom: 0.5rem;
  transition: opacity 150ms ease;
}
.team-member-row.member-suspended {
  opacity: 0.6;
  border-left: 3px solid #ef4444;
}

.member-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.member-role-badge {
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  flex-shrink: 0;
}

.member-suspended-badge {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.member-role-select {
  padding: 0.25rem;
  border-radius: 4px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 0.8rem;
}

/* Leave org button in org switcher */
.org-leave-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.75rem;
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 150ms, color 150ms, background 150ms;
  flex-shrink: 0;
}
.org-item:hover .org-leave-btn {
  opacity: 1;
}
.org-leave-btn:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

/* Danger button */
.btn-danger {
  background: #ef4444;
  color: #fff;
  border: 1px solid #ef4444;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: background 150ms ease;
}
.btn-danger:hover {
  background: #dc2626;
}
