/* ═══════════════════════════════════════════════════════════════
   ACCELERATE BROADPLAN v2 — Styles
   ═══════════════════════════════════════════════════════════════ */

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

body {
  background: var(--bg-body);
  font-family: 'Inter', sans-serif;
  font-size: 125%;
  color: var(--text-primary);
  padding: 0;
}

:root {
  --accel-brand-orange: #F26522;
  --bg-body: #c8ccd2;
  --bg-surface: #fff;
  --bg-surface-alt: #f8f9fb;
  --bg-panel: #fff;
  --text-primary: #1a1a1a;
  --text-secondary: #666;
  --text-muted: #888;
  --border-light: #f0f0f0;
  --border-medium: #eee;
  --shadow-card: rgba(0,0,0,0.06);
  --row-hover: rgba(0,0,0,0.02);
}

[data-theme="dark"] {
  --bg-body: #1a1d23;
  --bg-surface: #23272e;
  --bg-surface-alt: #2a2f38;
  --bg-panel: #23272e;
  --text-primary: #e4e6ea;
  --text-secondary: #a0a4ab;
  --text-muted: #6b7280;
  --border-light: #333840;
  --border-medium: #2d333b;
  --shadow-card: rgba(0,0,0,0.3);
  --row-hover: rgba(255,255,255,0.03);
}

/* ── Unified Topbar ── */
.topbar {
  background: linear-gradient(135deg, #1e2a3a, #2c3e50);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  border-radius: 12px;
  margin: 12px 16px 0;
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
}

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

.topbar-brand {
  font-size: 18px;
  font-weight: 900;
  color: #fff;
  text-transform: uppercase;
  padding: 14px 20px 14px 0;
  white-space: nowrap;
  letter-spacing: 0.5px;
}

.topbar-brand .o { color: var(--accel-brand-orange); }

.topbar-sep {
  width: 1px;
  height: 24px;
  background: rgba(255,255,255,0.12);
  flex-shrink: 0;
}

.topbar-tabs {
  display: flex;
  align-items: center;
  gap: 0;
  margin-left: 4px;
}

.topbar-tab {
  padding: 16px 20px;
  font-size: 12px;
  font-weight: 600;
  color: rgba(255,255,255,0.45);
  cursor: pointer;
  border: none;
  background: none;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: all 0.2s;
  border-bottom: 3px solid transparent;
  font-family: 'Inter', sans-serif;
}

.topbar-tab:hover { color: rgba(255,255,255,0.8); }
.topbar-tab.active { color: #fff; border-bottom-color: var(--accel-brand-orange); }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar-meta {
  font-size: 11px;
  color: rgba(255,255,255,0.4);
  white-space: nowrap;
}

/* ── Breadcrumbs ── */
.breadcrumbs {
  padding: 10px 28px 0;
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.bc-link { color: var(--text-secondary); font-weight: 500; }
.bc-sep { color: var(--text-muted); font-size: 13px; }
.bc-current { color: var(--text-primary); font-weight: 600; }

/* ── Content Area ── */
.content {
  padding: 12px 16px 24px;
  max-width: 100%;
  min-height: calc(100vh - 60px);
}

/* ── Header (reused from broadplan) ── */
.header {
  background: linear-gradient(135deg, #1e2a3a, #2c3e50);
  border-radius: 12px;
  padding: 20px 32px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header h1 {
  font-size: 20px;
  font-weight: 900;
  color: #fff;
  text-transform: uppercase;
}

.header h1 .o { color: var(--accel-brand-orange); }

.header .meta {
  font-size: 11px;
  color: rgba(255,255,255,0.5);
}

.header-right {
  display: flex;
  gap: 16px;
  align-items: center;
}

/* ── Legend ── */
.legend {
  display: flex;
  gap: 12px;
  font-size: 11px;
  color: rgba(255,255,255,0.7);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

/* PR-ACC-019: Week range toolbar */
.range-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  background: #f8f9fb;
  border-bottom: 1px solid #eee;
}

.range-btn {
  padding: 4px 10px;
  font-size: 10px;
  font-weight: 700;
  font-family: 'Inter', sans-serif;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #fff;
  color: #555;
  cursor: pointer;
  transition: all 0.15s;
}

.range-btn:hover { border-color: var(--accel-brand-orange); color: var(--accel-brand-orange); }
.range-btn.active { background: var(--accel-brand-orange); color: #fff; border-color: var(--accel-brand-orange); }

.range-label {
  margin-left: auto;
  font-size: 10px;
  font-weight: 600;
  color: #888;
}

/* ── Broadplan Grid ── */
.broadplan {
  background: var(--bg-surface);
  border-radius: 12px;
  box-shadow: 0 2px 12px var(--shadow-card);
  overflow: auto;
  max-height: calc(100vh - var(--broadplan-top, 130px));
  min-height: 400px;
}

.bp-row {
  display: grid;
  grid-template-columns: 36px 540px 120px 42px repeat(18, 1fr);
  border-bottom: 1px solid var(--border-light);
  min-height: 34px;
  align-items: stretch;
}

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

/* Milestone sub-row */
.bp-row.ms-row {
  min-height: 26px;
  background: var(--bg-surface-alt);
  display: none;
}

.bp-row.ms-row.visible { display: grid; }

/* PR13: child project sub-row (L1 nest). Mirrors ms-row hide/show. */
.bp-row.bp-child-row { display: none; }
.bp-row.bp-child-row.visible { display: grid; }

.bp-row.ms-row .cell.proj-name {
  font-size: 9px;
  font-weight: 600;
  color: var(--text-secondary);
  padding-left: 28px;
}

.bp-row.ms-row .cell.proj-name::before {
  content: '\2514';
  margin-right: 4px;
  color: #ccc;
}

.bp-row.ms-row .cell.sponsor { font-size: 8px; color: #aaa; }

/* Toggle arrow */
.toggle-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  cursor: pointer;
  font-size: 10px;
  color: var(--text-muted);
  transition: transform 0.2s;
  flex-shrink: 0;
  margin-right: 4px;
  border-radius: 3px;
  user-select: none;
}

.toggle-arrow:hover { color: var(--text-primary); background: var(--row-hover); }
.toggle-arrow.open { transform: rotate(90deg); color: var(--text-secondary); }

/* Header row — sticky below month row (PR-ACC-024) */
.bp-header {
  background: var(--bg-surface-alt);
  font-size: 8px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  position: sticky;
  top: 26px;
  z-index: 11;
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}

.bp-header .cell {
  padding: 8px 4px;
  text-align: center;
  border-right: 1px solid var(--border-medium);
  display: flex;
  align-items: center;
  justify-content: center;
}

.bp-header .cell.proj-col {
  justify-content: flex-start;
  padding-left: 12px;
}

/* PR-ACC-017: Column resize handle */
.col-resize-handle {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 6px;
  cursor: col-resize;
  background: transparent;
  transition: background 0.15s;
  z-index: 5;
}

.col-resize-handle:hover,
.col-resize-handle:active {
  background: rgba(242, 101, 34, 0.3);
}

/* Month header — sticky on scroll (PR-ACC-024) */
.month-row {
  background: #2c3e50;
  min-height: 26px;
  position: sticky;
  top: 0;
  z-index: 12;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.month-row .cell {
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 5px;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.5px;
}

.month-row .cell.month-span {
  border-right: 1px solid rgba(255,255,255,0.1);
}

/* Phase row */
.phase-row { min-height: 44px; margin-top: 8px; }

.phase-row .cell {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  font-size: 15px;
  font-weight: 800;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 1px;
  gap: 8px;
}

.phase-row .cell.phase-name { grid-column: 1 / -1; }

/* Data cells */
.cell {
  padding: 3px 4px;
  display: flex;
  align-items: center;
  border-right: 1px solid var(--border-light);
  font-size: 10px;
}

.cell.phase-col {
  justify-content: center;
  font-size: 8px;
  font-weight: 700;
  color: #fff;
}

.cell.proj-name {
  font-weight: 700;
  font-size: 11px;
  color: var(--text-primary);
  padding-left: 10px;
  cursor: pointer;
}

.cell.proj-name:hover,
.cell.proj-name:focus { color: var(--accel-brand-orange); }

.cell.proj-name:focus {
  outline: 2px solid var(--accel-brand-orange);
  outline-offset: -2px;
  border-radius: 3px;
}

.toggle-arrow:focus {
  outline: 2px solid var(--accel-brand-orange);
  outline-offset: 1px;
}

.cell.sponsor {
  font-size: 9px;
  font-weight: 600;
  color: var(--text-secondary);
  justify-content: center;
}

.cell.rag { justify-content: center; }

.rag-dot {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.rag-g { background: #0DB14B; }
.rag-a { background: #F7921E; }
.rag-r { background: #B3181D; }
.rag-d { background: #0DB14B; }
.rag-h { background: #999; }

/* Timeline cells */
.cell.week {
  padding: 2px;
  justify-content: center;
  position: relative;
}

.cell.week.today { background: rgba(242,101,34,0.06); }

.cell.week.today::before {
  content: '';
  position: absolute;
  top: 0; bottom: 0;
  left: 50%;
  width: 2px;
  background: var(--accel-brand-orange);
  opacity: 0.3;
}

/* Holiday overlay */
.cell.week.holiday {
  background: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 3px,
    rgba(0,0,0,0.02) 3px,
    rgba(0,0,0,0.02) 6px
  );
}

/* Gantt bars */
.bar-wash {
  height: 18px;
  border-radius: 4px;
  width: 100%;
  background: var(--pc);
  opacity: 0.15;
  position: relative;
}

.bar-wash::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--pc);
  transform: translate(-50%, -50%);
  opacity: 1;
}

.bar-done {
  height: 18px;
  border-radius: 4px;
  width: 100%;
  background: #0DB14B;
  opacity: 0.7;
}

.bar-plan {
  height: 18px;
  border-radius: 4px;
  width: 100%;
  background: var(--pc);
  opacity: 0.08;
  border: 1px dashed var(--pc);
}

.bar-amber {
  height: 18px;
  border-radius: 4px;
  width: 100%;
  background: #F7921E;
  opacity: 0.8;
}

.bar-red {
  height: 18px;
  border-radius: 4px;
  width: 100%;
  background: #B3181D;
  opacity: 0.8;
}

.bar-blocked {
  height: 18px;
  border-radius: 4px;
  width: 100%;
  background: #666;
  opacity: 0.6;
}

.bar-empty {
  height: 18px;
  width: 100%;
}

/* Milestone diamond */
.milestone {
  width: 12px;
  height: 12px;
  background: var(--pc);
  transform: rotate(45deg);
  border: 2px solid var(--bg-surface);
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  position: relative;
  z-index: 2;
}

.ms-row .milestone {
  width: 10px;
  height: 10px;
  border-width: 1.5px;
}

/* ── Sponsor Reminder Section ── */
.reminder-section {
  margin-top: 16px;
  background: var(--bg-panel);
  border-radius: 12px;
  box-shadow: 0 2px 12px var(--shadow-card);
  overflow: hidden;
}

.reminder-header {
  background: var(--accel-brand-orange);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.reminder-header h2 {
  font-size: 16px;
  font-weight: 800;
  color: #fff;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 8px;
}

.reminder-header .freq {
  font-size: 11px;
  color: rgba(255,255,255,0.7);
  font-weight: 500;
}

.reminder-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0;
}

.reminder-col {
  border-right: 1px solid #f0f0f0;
  padding: 14px;
}

.reminder-col:last-child { border-right: none; }

.reminder-col h3 {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ── Cards / Panels ── */
.panel {
  background: var(--bg-panel);
  border-radius: 12px;
  box-shadow: 0 2px 12px var(--shadow-card);
  padding: 20px;
  margin-bottom: 16px;
}

.panel h2 {
  font-size: 16px;
  font-weight: 800;
  margin-bottom: 12px;
  color: var(--text-primary);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  font-family: 'Inter', sans-serif;
}

.btn-primary {
  background: var(--accel-brand-orange);
  color: #fff;
}

.btn-primary:hover { background: #d95a1e; }

.btn-secondary {
  background: var(--bg-surface-alt);
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
}

.btn-secondary:hover { background: var(--border-light); }

.btn-sm { padding: 5px 10px; font-size: 11px; }

/* ── RAG Toggle Buttons ── */
.rag-toggle {
  display: flex;
  gap: 4px;
}

.rag-toggle button {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 2px solid transparent;
  cursor: pointer;
  font-weight: 700;
  font-size: 11px;
  color: #fff;
}

.rag-toggle button.active { border-color: #1a1a1a; box-shadow: 0 0 0 2px rgba(0,0,0,0.2); }
.rag-toggle .rag-btn-g { background: #0DB14B; }
.rag-toggle .rag-btn-a { background: #F7921E; }
.rag-toggle .rag-btn-r { background: #B3181D; }

/* ── Forms ── */
.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.form-group textarea,
.form-group input,
.form-group select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  color: var(--text-primary);
  background: var(--bg-surface);
}

.form-group textarea { min-height: 60px; resize: vertical; }
.form-group textarea:focus,
.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--accel-brand-orange);
  box-shadow: 0 0 0 3px rgba(242,101,34,0.1);
}

/* ── Loading ── */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
  font-size: 14px;
}

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state .icon { font-size: 48px; margin-bottom: 12px; }

/* ── Tooltip ── */
.tooltip {
  position: absolute;
  background: #2c3e50;
  color: #fff;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 10px;
  white-space: nowrap;
  z-index: 1000;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

/* ── PR-ACC-015: P3 Popup Modal ── */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
}

.modal-content {
  position: relative;
  background: var(--bg-panel);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  width: 90%;
  max-width: 800px;
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid #e0e0e0;
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid #e0e0e0;
}

.btn-close {
  background: none;
  border: none;
  font-size: 32px;
  color: #999;
  cursor: pointer;
  width: 32px;
  height: 32px;
}

.p3-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.info-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.info-row.full-width {
  grid-column: 1 / -1;
}

.info-row label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.info-value {
  font-size: 14px;
  color: var(--text-primary);
}

.parent-badge {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  margin-right: 8px;
}

.p2-badge {
  background: rgba(33, 150, 243, 0.1);
  color: #1976D2;
}

.p1-badge {
  background: rgba(76, 175, 80, 0.1);
  color: #388E3C;
}

/* ── PR-ACC-016: Edit Mode Indicator ── */
.edit-mode-indicator {
  position: fixed;
  top: 80px;
  right: 24px;
  background: #4CAF50;
  color: white;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  z-index: 999;
}
