@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600;700&family=Plus+Jakarta+Sans:wght@600;700;800&display=swap');

:root,
[data-theme="light"] {
  --bg-app: #F1F5F9;
  --bg-surface: #FFFFFF;
  --bg-surface-alt: #F8FAFC;
  --bg-surface-hover: #E0F2FE;
  --bg-surface-selected: #BAE6FD;
  --bg-wbs-row: #E2E8F0;
  --bg-header: #0B1120;
  --bg-subbar: #111827;
  --bg-table-header: #F1F5F9;
  --text-primary: #0F172A;
  --text-secondary: #334155;
  --text-muted: #64748B;
  --text-inverse: #F8FAFC;
  --border-color: #CBD5E1;
  --border-subtle: #E2E8F0;
  --accent-primary: #0284C7;
  --accent-primary-hover: #0369A1;
  --accent-cyan: #38BDF8;
  --color-critical: #E11D48;
  --color-critical-bg: #FFE4E6;
  --color-progress: #10B981;
  --color-completed: #0284C7;
  --color-baseline: #F59E0B;
  --color-milestone: #7C3AED;
  --color-warn: #D97706;
  --color-warn-bg: #FEF3C7;
  --color-pass: #16A34A;
  --color-pass-bg: #DCFCE7;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.10);
  --shadow-lg: 0 20px 45px rgba(15, 23, 42, 0.24);
  --row-height: 28px;
  --header-height: 40px;
}

[data-theme="dark"] {
  --bg-app: #070B14;
  --bg-surface: #0F172A;
  --bg-surface-alt: #131D33;
  --bg-surface-hover: #1E293B;
  --bg-surface-selected: #0C4A6E;
  --bg-wbs-row: #1E293B;
  --bg-header: #04070D;
  --bg-subbar: #0B1120;
  --bg-table-header: #1E293B;
  --text-primary: #F1F5F9;
  --text-secondary: #CBD5E1;
  --text-muted: #94A3B8;
  --text-inverse: #F8FAFC;
  --border-color: #334155;
  --border-subtle: #1E293B;
  --accent-primary: #38BDF8;
  --accent-primary-hover: #0284C7;
  --color-critical-bg: rgba(225, 29, 72, 0.2);
  --color-warn-bg: rgba(217, 119, 6, 0.2);
  --color-pass-bg: rgba(22, 163, 74, 0.2);
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 12.5px;
  color: var(--text-primary);
  background-color: var(--bg-app);
  -webkit-font-smoothing: antialiased;
}

.mono {
  font-family: 'JetBrains Mono', monospace;
  font-variant-numeric: tabular-nums;
}

/* App Shell */
.app-shell {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
}

/* 1. Top Command Header */
.top-navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  height: 50px;
  background: linear-gradient(90deg, #070B14 0%, #0F172A 60%, #0B1528 100%);
  color: #F8FAFC;
  border-bottom: 1px solid #1E293B;
  flex-shrink: 0;
  gap: 10px;
}

.brand-cluster {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: linear-gradient(135deg, #0284C7 0%, #38BDF8 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 800;
  font-size: 13px;
  color: #070B14;
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.35);
}

.brand-title {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: -0.02em;
  color: #FFFFFF;
  display: flex;
  align-items: center;
  gap: 7px;
}

.brand-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(56, 189, 248, 0.16);
  color: #38BDF8;
  border: 1px solid rgba(56, 189, 248, 0.35);
}

.brand-sub {
  font-size: 10.5px;
  color: #94A3B8;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
}

.nav-select {
  background: #1E293B;
  color: #F8FAFC;
  border: 1px solid #334155;
  border-radius: 5px;
  padding: 5px 9px;
  font-size: 11.5px;
  font-family: 'IBM Plex Sans', sans-serif;
  font-weight: 600;
  cursor: pointer;
  outline: none;
}

.nav-select:hover, .nav-select:focus {
  border-color: #38BDF8;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 5px;
  font-size: 11.5px;
  font-weight: 600;
  font-family: 'IBM Plex Sans', sans-serif;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.14s ease;
  white-space: nowrap;
}

.btn-primary {
  background: #0284C7;
  color: #FFFFFF;
  border-color: #0369A1;
}
.btn-primary:hover {
  background: #0369A1;
}

.btn-amber {
  background: #D97706;
  color: #FFFFFF;
  border-color: #B45309;
}
.btn-amber:hover {
  background: #B45309;
}

.btn-emerald {
  background: #059669;
  color: #FFFFFF;
  border-color: #047857;
}
.btn-emerald:hover {
  background: #047857;
}

.btn-crimson {
  background: #E11D48;
  color: #FFFFFF;
  border-color: #BE123C;
}
.btn-crimson:hover {
  background: #BE123C;
}

.btn-ghost {
  background: #1E293B;
  color: #E2E8F0;
  border-color: #334155;
}
.btn-ghost:hover {
  background: #334155;
  color: #FFFFFF;
}

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

/* 2. Forensic Deliverable Ribbon & KPI Telemetry Strip */
.telemetry-ribbon {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
  gap: 10px;
  flex-wrap: wrap;
}

.kpi-cluster {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.kpi-pill {
  display: flex;
  flex-direction: column;
  padding: 3px 10px;
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-color);
  border-radius: 5px;
  min-width: 98px;
}

.kpi-label {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 700;
}

.kpi-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
}

.kpi-val.crit {
  color: var(--color-critical);
}
.kpi-val.pass {
  color: var(--color-pass);
}
.kpi-val.warn {
  color: var(--color-warn);
}

.forensic-tools-bar {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

/* 3. Filter & Canvas Toolbar */
.workspace-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 14px;
  background: var(--bg-surface-alt);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-group, .gantt-controls-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.search-input {
  padding: 4px 9px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 12px;
  width: 195px;
}
.search-input:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.filter-chip {
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
}
.filter-chip:hover {
  border-color: var(--accent-primary);
}
.filter-chip.active {
  background: var(--accent-primary);
  color: #FFFFFF;
  border-color: var(--accent-primary);
}

/* 4. Main Split View (Activity Table Left | Interactive Gantt Right) */
.main-split-container {
  display: flex;
  flex: 1;
  min-height: 220px;
  overflow: hidden;
  border-bottom: 1px solid var(--border-color);
  position: relative;
}

.table-pane {
  width: 52%;
  min-width: 340px;
  display: flex;
  flex-direction: column;
  border-right: 2px solid var(--border-color);
  background: var(--bg-surface);
  overflow: hidden;
}

.gantt-pane {
  flex: 1;
  min-width: 320px;
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  overflow: hidden;
}

/* Synchronized Header Heights (40px) */
.pane-header {
  height: var(--header-height);
  min-height: var(--header-height);
  max-height: var(--header-height);
  background: var(--bg-table-header);
  border-bottom: 1px solid var(--border-color);
  overflow: hidden;
  position: relative;
}

.table-scroll-container {
  flex: 1;
  overflow: auto;
  position: relative;
}

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

.p6-table th {
  height: var(--header-height);
  background: var(--bg-table-header);
  color: var(--text-primary);
  font-weight: 700;
  font-size: 11px;
  padding: 0 6px;
  border-right: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  text-align: left;
  position: sticky;
  top: 0;
  z-index: 10;
  user-select: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.p6-table tr {
  height: var(--row-height);
  min-height: var(--row-height);
  max-height: var(--row-height);
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
}

.p6-table tr:nth-child(even) {
  background-color: var(--bg-surface-alt);
}

.p6-table tr.wbs-row {
  background-color: var(--bg-wbs-row);
  font-weight: 700;
}

.p6-table tr.crit-row td:first-child {
  border-left: 3px solid var(--color-critical);
}

.p6-table tr:hover {
  background-color: var(--bg-surface-hover);
}

.p6-table tr.selected {
  background-color: var(--bg-surface-selected) !important;
}

.p6-table td {
  height: var(--row-height);
  padding: 0 6px;
  font-size: 11.5px;
  border-right: 1px solid var(--border-subtle);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wbs-toggle {
  display: inline-block;
  width: 16px;
  text-align: center;
  font-weight: 700;
  cursor: pointer;
  color: var(--accent-primary);
}

/* Gantt Scroll & SVG Surface */
.gantt-header-scroll {
  height: var(--header-height);
  overflow: hidden;
  background: var(--bg-table-header);
  border-bottom: 1px solid var(--border-color);
  position: relative;
}

.gantt-body-scroll {
  flex: 1;
  overflow: auto;
  position: relative;
  background: var(--bg-surface);
}

.gantt-tooltip {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  background: #0F172A;
  color: #F8FAFC;
  border: 1px solid #38BDF8;
  border-radius: 6px;
  padding: 8px 11px;
  font-size: 11.5px;
  line-height: 1.45;
  box-shadow: var(--shadow-lg);
  max-width: 340px;
  display: none;
}

/* 5. Bottom 8-Tab Forensic Details Inspector */
.details-pane {
  height: 245px;
  min-height: 180px;
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  flex-shrink: 0;
}

.details-tabs-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-table-header);
  border-bottom: 1px solid var(--border-color);
  padding: 0 10px;
  height: 34px;
  flex-shrink: 0;
}

.details-tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  overflow-x: auto;
}

.details-tab {
  padding: 6px 12px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
}

.details-tab:hover {
  color: var(--accent-primary);
}

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

.details-content {
  flex: 1;
  overflow: auto;
  padding: 10px 14px;
}

.inspector-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 10px;
}

.inspector-card {
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 8px 12px;
}

.inspector-card h4 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent-primary);
  margin-bottom: 6px;
}

.kv-row {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  border-bottom: 1px dashed var(--border-subtle);
  font-size: 11.5px;
}
.kv-row:last-child {
  border-bottom: none;
}
.kv-key {
  color: var(--text-muted);
  font-weight: 500;
}
.kv-val {
  font-weight: 600;
  color: var(--text-primary);
}

/* Status Badges */
.badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10.5px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
}
.badge-pass {
  background: var(--color-pass-bg);
  color: var(--color-pass);
}
.badge-fail {
  background: var(--color-critical-bg);
  color: var(--color-critical);
}
.badge-warn {
  background: var(--color-warn-bg);
  color: var(--color-warn);
}
.badge-info {
  background: rgba(2, 132, 199, 0.15);
  color: var(--accent-primary);
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(7, 11, 20, 0.72);
  backdrop-filter: blur(3px);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop.open {
  display: flex;
}

.modal-window {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  width: min(1180px, 96vw);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: #0F172A;
  color: #FFFFFF;
  border-bottom: 1px solid #1E293B;
}

.modal-title {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-close {
  background: transparent;
  border: none;
  color: #94A3B8;
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
}
.modal-close:hover {
  color: #FFFFFF;
}

.modal-body {
  padding: 16px 18px;
  overflow-y: auto;
  flex: 1;
  display: block;
}

.prop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
}

.prop-card {
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 7px 11px;
}

.prop-card-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.prop-card-val {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}

.stat-cards-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

.stat-card {
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 9px 12px;
}

.stat-card-title {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.stat-card-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.mini-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
}

.mini-table th {
  background: var(--bg-table-header);
  color: var(--text-primary);
  padding: 6px 9px;
  text-align: left;
  font-weight: 700;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 2;
}

.mini-table td {
  padding: 5px 9px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.mini-table tr:nth-child(even) {
  background: var(--bg-surface-alt);
}

.mini-table tr:hover {
  background: var(--bg-surface-hover);
}

.badge-crit {
  background: var(--color-critical-bg);
  color: var(--color-critical);
}

.badge-amber {
  background: var(--color-warn-bg);
  color: var(--color-warn);
}

.badge-teal {
  background: rgba(13, 148, 136, 0.14);
  color: var(--color-normal);
}

.badge-slate {
  background: var(--bg-table-header);
  color: var(--text-secondary);
}

.code-textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-surface-alt);
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px;
  line-height: 1.45;
  resize: vertical;
}

.form-input,
.form-select {
  padding: 6px 9px;
  border: 1px solid var(--border-color);
  border-radius: 5px;
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 12px;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  background: var(--bg-table-header);
  border-top: 1px solid var(--border-color);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-field label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
}

.form-field input,
.form-field select,
.form-field textarea {
  padding: 6px 9px;
  border: 1px solid var(--border-color);
  border-radius: 5px;
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 12px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
}

.data-table th {
  background: #0F172A;
  color: #FFFFFF;
  padding: 7px 9px;
  text-align: left;
  font-weight: 700;
  position: sticky;
  top: 0;
}

.data-table td {
  padding: 6px 9px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: top;
}

.data-table tr:nth-child(even) {
  background: var(--bg-surface-alt);
}

.data-table tr:hover {
  background: var(--bg-surface-hover);
}

/* Dropzone Overlay */
.dropzone-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 132, 199, 0.88);
  color: #FFFFFF;
  z-index: 5000;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 24px;
  font-weight: 800;
}
.dropzone-overlay.active {
  display: flex;
}

/* Toast Notification */
.toast-notification {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #0F172A;
  color: #F8FAFC;
  border-left: 4px solid #38BDF8;
  padding: 10px 16px;
  border-radius: 6px;
  box-shadow: var(--shadow-lg);
  font-size: 12px;
  font-weight: 600;
  z-index: 6000;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.2s ease;
  pointer-events: none;
}
.toast-notification.show,
.toast-notification.visible {
  opacity: 1;
  transform: translateY(0);
}
