:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --text: #1a2332;
  --muted: #5a6a7e;
  --primary: #1e5a8a;
  --primary-light: #e8f1f8;
  --accent: #c45c26;
  --border: #d8e0ea;
  --regulatory: #1e5a8a;
  --clinical: #2d8a6e;
  --cmc: #8a6b1e;
  --critical: #c0392b;
  --high: #e67e22;
  --medium: #f1c40f;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(26, 35, 50, 0.08);
  --layout-max: 1680px;
  --layout-gutter: clamp(1.25rem, 3vw, 3rem);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.navbar {
  display: flex;
  align-items: center;
  gap: 2rem;
  padding: 0.75rem var(--layout-gutter);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  max-width: 100%;
}

.navbar > * {
  flex-shrink: 0;
}

.nav-brand { flex-shrink: 1; min-width: 0; }

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.nav-logo-link {
  display: flex;
  align-items: center;
  background: #000;
  padding: 0.4rem 0.85rem;
  border-radius: 6px;
  line-height: 0;
  text-decoration: none;
}

.nav-logo {
  height: 26px;
  width: auto;
  display: block;
}

.nav-subtitle {
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.2;
}

.nav-links { margin-left: auto; display: flex; gap: 1rem; }
.nav-links a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius);
}
.nav-links a.active, .nav-links a:hover { color: var(--primary); background: var(--primary-light); }
.nav-links a i { margin-right: 0.3rem; }
.nav-reset-form { margin-left: 0.5rem; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }

.persona-badge {
  background: var(--primary-light);
  color: var(--primary);
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}

.container {
  flex: 1;
  max-width: var(--layout-max);
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem var(--layout-gutter);
}

.footer {
  display: flex;
  justify-content: space-between;
  padding: 1rem var(--layout-gutter);
  background: var(--surface);
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--muted);
  max-width: 100%;
}

.mock-badge {
  background: #fff3cd;
  color: #856404;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-weight: 600;
}

/* Hero */
.hero { text-align: center; padding: 3rem 1rem; }
.hero h1 { font-size: 2.25rem; margin-bottom: 0.75rem; }
.hero-sub { color: var(--muted); max-width: 600px; margin: 0 auto 1.5rem; }

/* Features */
.features-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-top: 2rem;
}
.feature-card {
  background: var(--surface);
  padding: 1.5rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.feature-list { margin-top: 0.75rem; padding-left: 1.25rem; color: var(--muted); font-size: 0.9rem; }

.demo-scenario {
  margin-top: 2rem;
  padding: 1.5rem;
  background: var(--primary-light);
  border-radius: var(--radius);
  border-left: 4px solid var(--primary);
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.6rem 1.25rem;
  border: none;
  border-radius: var(--radius);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  font-size: 0.9rem;
  transition: background 0.15s;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: #164a72; }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-lg { padding: 0.8rem 1.75rem; font-size: 1rem; }

/* Forms */
.form-group { margin-bottom: 1.25rem; }
.form-group label { display: block; font-weight: 600; margin-bottom: 0.35rem; font-size: 0.9rem; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-family: inherit;
}
.form-group textarea, .followup-input {
  resize: vertical;
  min-height: 2.5rem;
}
.form-actions { margin-top: 1.5rem; display: flex; gap: 1rem; flex-wrap: wrap; }
.inline-form { display: inline; }

/* Persona */
.persona-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}
.persona-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.5rem;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s;
}
.persona-card:has(input:checked) { border-color: var(--primary); background: var(--primary-light); }
.persona-card input { display: none; }
.persona-icon { font-size: 2rem; color: var(--primary); }
.persona-icon i { font-size: 2.25rem; }
.feature-icon { margin-right: 0.4rem; color: var(--primary); }
.persona-label { font-weight: 600; margin-top: 0.5rem; }

/* Steps */
.step-indicator { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.step {
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: var(--border);
  color: var(--muted);
}
.step.active { background: var(--primary); color: white; }
.step.done { background: var(--clinical); color: white; }

.page-header { margin-bottom: 1.5rem; }
.page-header h1 { font-size: 1.75rem; }
.section-desc, .page-header p { color: var(--muted); }

/* Tables */
.data-table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.data-table th, .data-table td { padding: 0.75rem 1rem; text-align: left; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.data-table th { background: var(--primary); color: white; }
.preview-cell { color: var(--muted); font-size: 0.8rem; max-width: 300px; }

.tag {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

/* Pathways */
.pathway-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.25rem; margin-bottom: 1.5rem; }
.pathway-card {
  padding: 1.25rem;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
}
.pathway-card:has(input:checked) { border-color: var(--primary); }
.pathway-card input { display: none; }
.pathway-desc { color: var(--muted); font-size: 0.9rem; margin: 0.5rem 0; }
.timeline-badge { background: var(--accent); color: white; padding: 0.2rem 0.6rem; border-radius: 4px; font-size: 0.8rem; font-weight: 600; }
.pros-cons { font-size: 0.8rem; color: var(--muted); margin-top: 0.75rem; }

/* Follow-up */
.followup-card {
  background: var(--surface);
  padding: 1.25rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}
.followup-question { font-weight: 600; }
.followup-reason { color: var(--muted); font-size: 0.85rem; margin: 0.35rem 0 0.75rem; }
.followup-input { width: 100%; }

/* Timeline vertical */
.timeline-legend { display: flex; gap: 1.5rem; margin-bottom: 1.5rem; font-size: 0.85rem; }
.legend-item.regulatory { color: var(--regulatory); }
.legend-item.clinical { color: var(--clinical); }
.legend-item.cmc { color: var(--cmc); }

.timeline-vertical {
  position: relative;
  padding-left: 2rem;
  margin-bottom: 2rem;
}

.timeline-vertical::before {
  content: "";
  position: absolute;
  left: 0.6rem;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--border);
}

.tl-item {
  position: relative;
  margin-bottom: 1.25rem;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
  border-left: 4px solid var(--regulatory);
  transition: transform 0.1s;
}
.tl-item:hover { transform: translateX(4px); }
.tl-item.team-clinical, .tl-item.team-cmc {
  border-style: dashed;
  border-left-width: 4px;
  opacity: 0.9;
}
.tl-item.team-clinical { border-left-color: var(--clinical); }
.tl-item.team-cmc { border-left-color: var(--cmc); }
.tl-item.user-override { box-shadow: 0 0 0 2px var(--accent); }
.tl-item.recalculated { background: #fff8f0; }

.tl-item::before {
  content: "";
  position: absolute;
  left: -1.65rem;
  top: 1.25rem;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--regulatory);
  border: 2px solid var(--surface);
}
.tl-item.team-clinical::before { background: var(--clinical); }
.tl-item.team-cmc::before { background: var(--cmc); }

.tl-title { font-weight: 700; font-size: 1rem; }
.tl-meta { display: flex; gap: 1rem; margin-top: 0.35rem; font-size: 0.8rem; color: var(--muted); }
.tl-desc { font-size: 0.85rem; color: var(--muted); margin-top: 0.35rem; }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal.hidden { display: none; }
.modal-content {
  background: var(--surface);
  padding: 1.5rem;
  border-radius: var(--radius);
  min-width: 320px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.modal-actions { margin-top: 1rem; display: flex; gap: 0.75rem; }

/* Risk dashboard */
.risk-overview {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
}
.risk-score-card {
  background: var(--surface);
  padding: 1.5rem;
  border-radius: var(--radius);
  text-align: center;
  box-shadow: var(--shadow);
}
.risk-score-card.risk-level-high { border-top: 5px solid var(--critical); background: linear-gradient(180deg, #fff5f5 0%, var(--surface) 40%); }
.risk-score-card.risk-level-medium { border-top: 5px solid var(--high); background: linear-gradient(180deg, #fffbf0 0%, var(--surface) 40%); }
.risk-score-card.risk-level-low { border-top: 5px solid var(--clinical); background: linear-gradient(180deg, #f0faf6 0%, var(--surface) 40%); }
.score-value { display: block; font-size: 3rem; font-weight: 800; }
.risk-level-high .score-value { color: var(--critical); }
.risk-level-medium .score-value { color: var(--high); }
.risk-level-low .score-value { color: var(--clinical); }
.score-label { font-size: 0.85rem; color: var(--muted); }
.risk-level-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.5rem;
  padding: 0.3rem 0.75rem;
  color: white;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}
.risk-level-badge.risk-level-high { background: var(--critical); }
.risk-level-badge.risk-level-medium { background: var(--high); }
.risk-level-badge.risk-level-low { background: var(--clinical); }

.flags-panel { background: var(--surface); padding: 1.25rem; border-radius: var(--radius); box-shadow: var(--shadow); }
.flag-list { list-style: none; }
.flag {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.55rem 0.65rem;
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
  border-radius: var(--radius);
  border-left: 4px solid var(--border);
}
.flag-icon { flex-shrink: 0; width: 1.25rem; text-align: center; }
.flag-contradiction { background: #fff3e0; border-left-color: var(--high); }
.flag-contradiction .flag-icon { color: var(--high); }
.flag-missing_data { background: #e8f4fd; border-left-color: var(--primary); }
.flag-missing_data .flag-icon { color: var(--primary); }
.flag-buried_guidance { background: #f3e8fd; border-left-color: #7b1fa2; }
.flag-buried_guidance .flag-icon { color: #7b1fa2; }
.flag-red_flag { background: #fde8e8; border-left-color: var(--critical); }
.flag-red_flag .flag-icon { color: var(--critical); }

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}
.category-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.category-header { display: flex; justify-content: space-between; padding: 1rem 1.25rem; background: var(--primary-light); }
.cat-score {
  font-weight: 800;
  font-size: 1.25rem;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  color: white;
}
.cat-score-high { background: var(--critical); }
.cat-score-medium { background: var(--high); }
.cat-score-low { background: var(--clinical); }

.issue-card { padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); border-left: 4px solid var(--border); }
.issue-card.severity-critical { border-left-color: var(--critical); background: #fffafa; }
.issue-card.severity-high { border-left-color: var(--high); background: #fffcf7; }
.issue-card.severity-medium { border-left-color: #b7950b; }
.severity-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  color: white;
}
.severity-badge.severity-critical { background: var(--critical); }
.severity-badge.severity-high { background: var(--high); }
.severity-badge.severity-medium { background: #b7950b; }
.issue-card h4 { margin: 0.35rem 0; }
.issue-sources { margin-top: 0.5rem; }

.uncertain-section { margin-bottom: 2rem; }
.uncertain-list { list-style: none; }
.uncertain-item {
  display: flex;
  gap: 1rem;
  padding: 1rem;
  background: var(--surface);
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
  box-shadow: var(--shadow);
}
.priority-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  font-weight: 800;
  font-size: 0.85rem;
  color: white;
  flex-shrink: 0;
}
.priority-badge.priority-1 { background: var(--critical); }
.priority-badge.priority-2 { background: var(--high); }
.priority-badge.priority-3 { background: #b7950b; }
.priority-badge.priority-4, .priority-badge.priority-5 { background: var(--muted); }
.uncertain-item.priority-1 { border-left: 4px solid var(--critical); }
.uncertain-item.priority-2 { border-left: 4px solid var(--high); }
.uncertain-item.priority-3 { border-left: 4px solid #b7950b; }

.upload-status { font-size: 0.9rem; color: var(--primary); margin-top: 0.5rem; }
.upload-status.hidden { display: none; }

.editor-upload-section {
  background: var(--surface);
  padding: 1.25rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}
.editor-upload-row { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin-top: 0.5rem; }
.editor-upload-row select { padding: 0.5rem 0.75rem; border: 1px solid var(--border); border-radius: var(--radius); }
.btn-file { cursor: pointer; margin: 0; }
.btn-file input { display: none; }
.editor-doc-list { list-style: none; margin-top: 0.75rem; font-size: 0.9rem; }
.editor-doc-list li { padding: 0.25rem 0; color: var(--muted); }
.impact { font-size: 0.8rem; color: var(--muted); }

.simulator-panel {
  margin-top: 1.5rem;
  padding: 1.25rem;
  background: #2c1810;
  color: #f5e6d3;
  border-radius: var(--radius);
}
.simulator-panel.hidden { display: none; }
.simulator-panel h3 { color: #e8a87c; margin-bottom: 0.75rem; }
.simulator-panel ul { padding-left: 1.25rem; }

.alert { padding: 0.75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; }
.alert-error { background: #fde8e8; color: var(--critical); }
.alert-info { background: var(--primary-light); color: var(--primary); }

.hint { color: var(--muted); font-size: 0.9rem; margin: 0.5rem 0 0; }
.hint kbd {
  background: var(--border);
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  font-size: 0.8rem;
}
.file-preview {
  background: var(--primary-light);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.file-preview ul { margin: 0.35rem 0 0 1.25rem; color: var(--muted); }
.file-preview.hidden { display: none; }
.upload-actions { margin-bottom: 1.5rem; }

.survey-options {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 1rem;
  align-items: start;
  margin-bottom: 2rem;
}
.option-card {
  background: var(--surface);
  padding: 1.25rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.option-card h2 { font-size: 1rem; margin-bottom: 0.5rem; }
.option-card p { color: var(--muted); font-size: 0.9rem; margin-bottom: 0.75rem; }
.option-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 3rem;
  color: var(--muted);
  font-weight: 600;
}
.option-divider span {
  background: var(--bg);
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--border);
}
.tpp-upload-form .form-group { margin-bottom: 0.75rem; }
.extracted-preview-card {
  margin-bottom: 1.5rem;
}
.extracted-preview-card h2 {
  font-size: 1rem;
  margin-bottom: 0.35rem;
}
.extracted-preview-grid {
  margin-top: 0.75rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.65rem;
}
.extracted-preview-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
}
.extracted-preview-item strong {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.15rem;
}
.extracted-preview-item span {
  font-size: 0.88rem;
}

/* Timeline editor */
.timeline-editor-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.25rem;
  flex-wrap: wrap;
}
.timeline-stats {
  display: flex;
  gap: 1.25rem;
  align-items: center;
  font-size: 0.88rem;
  color: var(--muted);
  flex-shrink: 0;
}
.save-status {
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
}
.save-status.saved { background: #d4edda; color: #155724; }
.save-status.saving { background: #fff3cd; color: #856404; }
.save-status.error { background: #fde8e8; color: var(--critical); }

.timeline-toolbar {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.gantt-section, .milestone-section, .vertical-section {
  margin-bottom: 2rem;
}
.gantt-section h2, .milestone-section h2, .vertical-section h2 {
  font-size: 1.1rem;
  margin-bottom: 0.75rem;
}

.gantt-chart {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
  overflow-x: auto;
}

.gantt-row {
  display: grid;
  grid-template-columns: minmax(200px, 260px) 1fr;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 0.5rem;
  min-height: 32px;
}
.gantt-label {
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gantt-label:hover { color: var(--primary); }
.gantt-track {
  position: relative;
  height: 24px;
  background: var(--bg);
  border-radius: 4px;
  border: 1px solid var(--border);
}
.gantt-bar {
  position: absolute;
  top: 2px;
  height: 18px;
  border-radius: 3px;
  font-size: 0.65rem;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  min-width: 24px;
  font-weight: 600;
}
.gantt-bar.team-regulatory { background: var(--regulatory); }
.gantt-bar.team-clinical { background: var(--clinical); border: 2px dashed white; }
.gantt-bar.team-cmc { background: var(--cmc); border: 2px dashed white; }
.gantt-bar.overridden { box-shadow: 0 0 0 2px var(--accent); }

.gantt-axis {
  position: relative;
  height: 20px;
  margin-top: 0.25rem;
  font-size: 0.7rem;
  color: var(--muted);
}
.gantt-axis > span {
  position: absolute;
  transform: translateX(-50%);
}

.table-wrap { overflow-x: auto; }
.milestone-table .link-btn {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0;
  text-align: left;
}
.milestone-table .delete-btn { color: var(--critical); }
.recalculated-row { background: #fff8f0 !important; }
.deps-cell { font-size: 0.8rem; color: var(--muted); max-width: 280px; }

.modal-wide { min-width: 480px; max-width: 720px; }
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
}
.dep-checkboxes {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 120px;
  overflow-y: auto;
}
.dep-check {
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.btn-danger {
  background: var(--critical);
  color: white;
}
.btn-danger:hover { background: #a93226; }

.recalc-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.9rem;
}
.recalc-notice {
  background: #fff8f0;
  border-left: 3px solid var(--accent);
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}
.recalc-notice.hidden { display: none; }
.alert.hidden { display: none; }

@media (max-width: 768px) {
  .survey-options { grid-template-columns: 1fr; }
  .option-divider { padding: 0.5rem 0; }
  .gantt-row { grid-template-columns: 120px 1fr; }
  .modal-wide { min-width: auto; width: 95vw; }
}

/* Agent chat widget */
.agent-chat {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 200;
  font-size: 0.9rem;
}

.agent-chat-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(30, 90, 138, 0.35);
  transition: transform 0.15s;
}
.agent-chat-toggle:hover { transform: scale(1.03); }

.agent-chat:not(.collapsed) .agent-chat-toggle { display: none; }

.agent-chat-panel {
  display: none;
  flex-direction: column;
  width: 380px;
  max-height: 520px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  border: 1px solid var(--border);
  overflow: hidden;
}

.agent-chat:not(.collapsed) .agent-chat-panel { display: flex; }

.agent-chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: var(--primary);
  color: white;
}

.agent-service-badge {
  display: inline-block;
  margin-left: 0.5rem;
  font-size: 0.7rem;
  background: rgba(255,255,255,0.2);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
}

.agent-chat-close {
  background: none;
  border: none;
  color: white;
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
}

.agent-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 280px;
  max-height: 360px;
}

.chat-message {
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius);
  max-width: 92%;
  line-height: 1.5;
}
.chat-message p { white-space: pre-wrap; margin: 0; }
.chat-message.user {
  align-self: flex-end;
  background: var(--primary-light);
  color: var(--primary);
}
.chat-message.agent {
  align-self: flex-start;
  background: var(--bg);
  border: 1px solid var(--border);
}

.chat-message.agent.streaming {
  animation: message-enter 0.35s ease-out;
  border-color: var(--primary);
  box-shadow: 0 0 0 1px rgba(30, 90, 138, 0.12);
}

.chat-message.agent.typing {
  padding: 0.85rem 1rem;
  min-width: 64px;
}

@keyframes message-enter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.typing-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 20px;
}

.typing-indicator span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--primary);
  opacity: 0.35;
  animation: typing-bounce 1.2s ease-in-out infinite;
}

.typing-indicator span:nth-child(1) { animation-delay: 0s; }
.typing-indicator span:nth-child(2) { animation-delay: 0.15s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.3s; }

@keyframes typing-bounce {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.35;
  }
  30% {
    transform: translateY(-6px);
    opacity: 1;
  }
}

.typewriter-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 2px;
  background: var(--primary);
  vertical-align: text-bottom;
  animation: cursor-blink 0.8s step-end infinite;
}

@keyframes cursor-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.chat-sources {
  margin-top: 0.4rem;
  font-size: 0.7rem;
  color: var(--muted);
}

.chat-sources.fade-in {
  animation: fade-in 0.5s ease-out;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.agent-chat-form {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid var(--border);
}
.agent-chat-form input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
}
.agent-chat-form .btn { padding: 0.5rem 1rem; font-size: 0.85rem; }

@media (max-width: 768px) {
  .features-grid, .risk-overview { grid-template-columns: 1fr; }
  .navbar { flex-wrap: wrap; }
  .agent-chat-panel { width: calc(100vw - 2rem); right: 0; }
}
