/* ============================================================================
   MedSecure Health Portal - Healthcare POC Demo Styles
   DAT (Decentralized Agent Trust) Integration Demo
   ============================================================================ */

/* CSS Variables - Healthcare Theme */
:root {
  /* Healthcare Colors */
  --med-primary: #0891b2;
  --med-primary-light: #22d3ee;
  --med-primary-dark: #0e7490;
  --med-secondary: #6366f1;
  --med-accent: #14b8a6;

  /* Status Colors */
  --med-success: #10b981;
  --med-success-light: #34d399;
  --med-warning: #f59e0b;
  --med-warning-light: #fbbf24;
  --med-danger: #ef4444;
  --med-danger-light: #f87171;
  --med-amber: #d97706;
  --med-amber-light: #fbbf24;

  /* Background Colors */
  --med-bg: #f0f9ff;
  --med-bg-dark: #0c4a6e;
  --med-bg-card: #ffffff;
  --med-bg-elevated: #f8fafc;

  /* Text Colors */
  --med-text: #0f172a;
  --med-text-secondary: #475569;
  --med-text-muted: #94a3b8;
  --med-text-light: #ffffff;

  /* Borders */
  --med-border: #e2e8f0;
  --med-border-dark: #cbd5e1;

  /* Shadows */
  --med-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --med-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --med-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --med-shadow-xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;

  /* Border Radius */
  --radius-sm: 0.375rem;
  --radius: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-2xl: 1.5rem;
  --radius-full: 9999px;

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--med-bg);
  color: var(--med-text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ============================================================================
   Header / Navigation
   ============================================================================ */

.portal-header {
  background: linear-gradient(135deg, var(--med-bg-dark) 0%, #164e63 100%);
  color: var(--med-text-light);
  padding: var(--space-4) var(--space-6);
  box-shadow: var(--med-shadow-lg);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  max-width: 1600px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-6);
}

.portal-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.logo-icon {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--med-primary-light) 0%, var(--med-accent) 100%);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  color: white;
  box-shadow: 0 4px 12px rgba(34, 211, 238, 0.3);
}

.logo-text h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.logo-text span {
  font-size: 0.75rem;
  opacity: 0.8;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.header-status {
  display: flex;
  align-items: center;
  gap: var(--space-6);
}

.dat-badge {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: rgba(255, 255, 255, 0.1);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
  font-size: 0.875rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.dat-badge .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--med-success);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.header-actions {
  display: flex;
  gap: var(--space-3);
}

/* ============================================================================
   Flow Diagram (Collapsible)
   ============================================================================ */

.flow-diagram-wrapper {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease, opacity 0.3s ease;
  opacity: 0;
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 50%, #f0f9ff 100%);
  border-bottom: 1px solid var(--med-border);
}

.flow-diagram-wrapper.open {
  max-height: 320px;
  opacity: 1;
}

.flow-diagram-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-6) var(--space-5);
  text-align: center;
}

.flow-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--med-text);
  margin-bottom: var(--space-5);
  letter-spacing: -0.01em;
}

.flow-diagram {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 0;
  flex-wrap: nowrap;
}

.flow-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  background: var(--med-bg-card);
  border: 2px solid var(--med-border);
  border-radius: var(--radius-lg);
  min-width: 130px;
  max-width: 160px;
  transition: all 0.3s ease;
  position: relative;
}

.flow-node-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--med-bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--med-border);
  transition: all 0.3s ease;
}

.flow-node-icon svg {
  width: 20px;
  height: 20px;
  color: var(--med-text-secondary);
  transition: color 0.3s ease;
}

.flow-node-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--med-text);
  line-height: 1.3;
}

.flow-node-desc {
  font-size: 0.7rem;
  color: var(--med-text-muted);
  line-height: 1.3;
}

/* Flow node states */
.flow-node.active {
  border-color: var(--med-primary-light);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.2), 0 4px 12px rgba(8, 145, 178, 0.15);
  animation: flowNodePulse 1.2s ease infinite;
}

.flow-node.active .flow-node-icon {
  background: linear-gradient(135deg, var(--med-primary) 0%, var(--med-primary-light) 100%);
  border-color: var(--med-primary);
}

.flow-node.active .flow-node-icon svg {
  color: white;
}

@keyframes flowNodePulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.2), 0 4px 12px rgba(8, 145, 178, 0.15); }
  50% { box-shadow: 0 0 0 6px rgba(34, 211, 238, 0.1), 0 4px 16px rgba(8, 145, 178, 0.25); }
}

.flow-node.complete {
  border-color: var(--med-success);
}

.flow-node.complete .flow-node-icon {
  background: var(--med-success);
  border-color: var(--med-success);
}

.flow-node.complete .flow-node-icon svg {
  color: white;
}

.flow-node.failed {
  border-color: var(--med-danger);
}

.flow-node.failed .flow-node-icon {
  background: var(--med-danger);
  border-color: var(--med-danger);
}

.flow-node.failed .flow-node-icon svg {
  color: white;
}

/* Flow connector */
.flow-connector {
  display: flex;
  align-items: center;
  padding-top: 20px;
  min-width: 30px;
}

.flow-connector span {
  display: block;
  width: 30px;
  height: 2px;
  background: var(--med-border-dark);
  position: relative;
}

.flow-connector span::after {
  content: '';
  position: absolute;
  right: -1px;
  top: -4px;
  width: 0;
  height: 0;
  border-left: 6px solid var(--med-border-dark);
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
}

/* Flow legend */
.flow-legend {
  display: flex;
  justify-content: center;
  gap: var(--space-6);
  margin-top: var(--space-4);
  font-size: 0.8rem;
  color: var(--med-text-secondary);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

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

.legend-dot.granted {
  background: var(--med-success);
}

.legend-dot.quarantined {
  background: var(--med-warning);
}

.legend-dot.denied {
  background: var(--med-danger);
}

/* ============================================================================
   Main Layout
   ============================================================================ */

.portal-main {
  max-width: 1600px;
  margin: 0 auto;
  padding: var(--space-6);
  display: grid;
  grid-template-columns: 380px 1fr 340px;
  gap: var(--space-6);
  min-height: calc(100vh - 80px);
}

@media (max-width: 1400px) {
  .portal-main {
    grid-template-columns: 340px 1fr;
  }
  .controls-panel {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--space-4);
  }
}

@media (max-width: 1024px) {
  .portal-main {
    grid-template-columns: 1fr;
  }
}

/* ============================================================================
   Panel Styles
   ============================================================================ */

.panel {
  background: var(--med-bg-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--med-shadow);
  border: 1px solid var(--med-border);
  overflow: hidden;
}

.panel-header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--med-border);
  background: var(--med-bg-elevated);
}

.panel-header h2 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--med-text);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.panel-header h2 svg {
  width: 20px;
  height: 20px;
  color: var(--med-primary);
}

.panel-body {
  padding: var(--space-5);
}

/* ============================================================================
   Agent Cards
   ============================================================================ */

.agents-panel .panel-body {
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  max-height: calc(100vh - 280px);
  overflow-y: auto;
}

.agent-card {
  background: var(--med-bg-elevated);
  border: 2px solid var(--med-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.agent-card:hover {
  border-color: var(--med-primary);
  box-shadow: var(--med-shadow);
  transform: translateY(-2px);
}

.agent-card.selected {
  border-color: var(--med-primary);
  background: linear-gradient(135deg, rgba(8, 145, 178, 0.05) 0%, rgba(20, 184, 166, 0.05) 100%);
  box-shadow: 0 0 0 3px rgba(8, 145, 178, 0.1);
}

.agent-card.verifying {
  border-color: var(--med-warning);
  animation: verifyPulse 1s infinite;
}

@keyframes verifyPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4); }
  50% { box-shadow: 0 0 0 10px rgba(245, 158, 11, 0); }
}

.agent-card.granted {
  border-color: var(--med-success);
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.05) 0%, rgba(52, 211, 153, 0.05) 100%);
}

.agent-card.quarantined {
  border-color: var(--med-warning);
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.05) 0%, rgba(251, 191, 36, 0.05) 100%);
}

.agent-card.denied {
  border-color: var(--med-danger);
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.05) 0%, rgba(248, 113, 113, 0.05) 100%);
}

.agent-header {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.agent-avatar {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
  overflow: hidden;
}

.agent-avatar.ai {
  background: linear-gradient(135deg, var(--med-secondary) 0%, #8b5cf6 100%);
  color: white;
}

.agent-avatar.medical {
  background: linear-gradient(135deg, var(--med-primary) 0%, var(--med-accent) 100%);
  color: white;
}

.agent-avatar.pharmacy {
  background: linear-gradient(135deg, #8b5cf6 0%, #a855f7 100%);
  color: white;
}

.agent-avatar.lab {
  background: linear-gradient(135deg, #0891b2 0%, #06b6d4 100%);
  color: white;
}

.agent-avatar.scheduling {
  background: linear-gradient(135deg, #6366f1 0%, #818cf8 100%);
  color: white;
}

.agent-avatar.unknown {
  background: linear-gradient(135deg, #64748b 0%, #475569 100%);
  color: white;
}

.agent-info {
  flex: 1;
  min-width: 0;
}

.agent-name {
  font-weight: 600;
  font-size: 1rem;
  color: var(--med-text);
  margin-bottom: var(--space-1);
}

.agent-did {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--med-text-muted);
  word-break: break-all;
  background: rgba(0, 0, 0, 0.03);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
}

.agent-badges {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-verified {
  background: rgba(16, 185, 129, 0.1);
  color: var(--med-success);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-hipaa {
  background: rgba(99, 102, 241, 0.1);
  color: var(--med-secondary);
  border: 1px solid rgba(99, 102, 241, 0.2);
}

.badge-soc2 {
  background: rgba(8, 145, 178, 0.1);
  color: var(--med-primary);
  border: 1px solid rgba(8, 145, 178, 0.2);
}

.badge-unverified {
  background: rgba(239, 68, 68, 0.1);
  color: var(--med-danger);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.badge-pending {
  background: rgba(245, 158, 11, 0.1);
  color: var(--med-warning);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

/* Trust Score Display */
.trust-score-display {
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--med-border);
}

.trust-score-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-2);
}

.trust-score-label {
  font-size: 0.75rem;
  color: var(--med-text-secondary);
  font-weight: 500;
}

.trust-score-value {
  font-size: 1.25rem;
  font-weight: 700;
}

.trust-score-value.high {
  color: var(--med-success);
}

.trust-score-value.medium {
  color: var(--med-warning);
}

.trust-score-value.low {
  color: var(--med-danger);
}

.trust-bar {
  height: 8px;
  background: var(--med-border);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.trust-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.5s ease, background 0.3s ease;
}

.trust-bar-fill.high {
  background: linear-gradient(90deg, var(--med-success) 0%, var(--med-success-light) 100%);
}

.trust-bar-fill.medium {
  background: linear-gradient(90deg, var(--med-warning) 0%, var(--med-warning-light) 100%);
}

.trust-bar-fill.low {
  background: linear-gradient(90deg, var(--med-danger) 0%, var(--med-danger-light) 100%);
}

/* ============================================================================
   Patient Records Panel
   ============================================================================ */

.records-panel {
  display: flex;
  flex-direction: column;
}

.records-panel .panel-body {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* Access Status Banner */
.access-status {
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.access-status.granted {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.1) 0%, rgba(52, 211, 153, 0.1) 100%);
  border: 2px solid var(--med-success);
}

.access-status.quarantined {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.1) 0%, rgba(251, 191, 36, 0.1) 100%);
  border: 2px solid var(--med-warning);
}

.access-status.denied {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.1) 0%, rgba(248, 113, 113, 0.1) 100%);
  border: 2px solid var(--med-danger);
}

.access-status.verifying {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.1) 0%, rgba(251, 191, 36, 0.1) 100%);
  border: 2px solid var(--med-warning);
}

.access-status.idle {
  background: var(--med-bg-elevated);
  border: 2px solid var(--med-border);
}

.access-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.access-icon svg {
  width: 24px;
  height: 24px;
}

.access-status.granted .access-icon {
  background: var(--med-success);
  color: white;
}

.access-status.quarantined .access-icon {
  background: var(--med-warning);
  color: white;
}

.access-status.denied .access-icon {
  background: var(--med-danger);
  color: white;
}

.access-status.verifying .access-icon {
  background: var(--med-warning);
  color: white;
  animation: spin 1s linear infinite;
}

.access-status.idle .access-icon {
  background: var(--med-border);
  color: var(--med-text-muted);
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.access-info h3 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: var(--space-1);
}

.access-status.granted .access-info h3 { color: var(--med-success); }
.access-status.quarantined .access-info h3 { color: var(--med-amber); }
.access-status.denied .access-info h3 { color: var(--med-danger); }
.access-status.verifying .access-info h3 { color: var(--med-warning); }
.access-status.idle .access-info h3 { color: var(--med-text-secondary); }

.access-info p {
  font-size: 0.875rem;
  color: var(--med-text-secondary);
}

/* ============================================================================
   Verification Steps (5-Step Progress)
   ============================================================================ */

.verification-steps {
  margin-bottom: var(--space-4);
  background: var(--med-bg-elevated);
  border: 1px solid var(--med-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
}

.verification-step {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-2);
  border-radius: var(--radius);
  transition: all 0.3s ease;
  border-left: 3px solid transparent;
}

.verification-step + .verification-step {
  margin-top: var(--space-1);
}

.verification-step.active {
  background: rgba(8, 145, 178, 0.05);
  border-left-color: var(--med-primary-light);
}

.verification-step.complete {
  border-left-color: var(--med-success);
}

.verification-step.failed {
  background: rgba(239, 68, 68, 0.05);
  border-left-color: var(--med-danger);
}

.verification-step.skipped {
  opacity: 0.4;
}

/* Step icon */
.step-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
  transition: all 0.3s ease;
}

.step-icon.pending {
  background: var(--med-border);
  color: var(--med-text-muted);
  border: 2px solid var(--med-border-dark);
}

.step-icon.active {
  background: linear-gradient(135deg, var(--med-primary) 0%, var(--med-primary-light) 100%);
  color: white;
  border: 2px solid var(--med-primary);
  animation: stepPulse 1s ease infinite;
}

@keyframes stepPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(8, 145, 178, 0.4); }
  50% { box-shadow: 0 0 0 6px rgba(8, 145, 178, 0); }
}

.step-icon.complete {
  background: var(--med-success);
  color: white;
  border: 2px solid var(--med-success);
}

.step-icon.failed {
  background: var(--med-danger);
  color: white;
  border: 2px solid var(--med-danger);
}

.step-icon.skipped {
  background: var(--med-border);
  color: var(--med-text-muted);
  border: 2px solid var(--med-border);
}

/* Step spinner */
.step-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: stepSpin 0.6s linear infinite;
}

@keyframes stepSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Step label */
.step-label {
  flex: 1;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--med-text);
}

.verification-step.active .step-label {
  color: var(--med-primary-dark);
}

.verification-step.complete .step-label {
  color: var(--med-text);
}

.verification-step.failed .step-label {
  color: var(--med-danger);
}

.verification-step.skipped .step-label {
  color: var(--med-text-muted);
}

/* Step status text */
.step-status {
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--med-text-muted);
  white-space: nowrap;
}

.verification-step.complete .step-status {
  color: var(--med-success);
}

.verification-step.failed .step-status {
  color: var(--med-danger);
}

/* ============================================================================
   Verification Summary Panel
   ============================================================================ */

.verification-summary {
  margin-bottom: var(--space-4);
  animation: summaryFadeIn 0.4s ease;
}

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

.summary-card {
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  border: 1px solid var(--med-border);
}

.summary-card.granted {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.04) 0%, rgba(52, 211, 153, 0.04) 100%);
  border-color: rgba(16, 185, 129, 0.3);
}

.summary-card.quarantined {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.04) 0%, rgba(251, 191, 36, 0.04) 100%);
  border-color: rgba(245, 158, 11, 0.3);
}

.summary-card.denied {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.04) 0%, rgba(248, 113, 113, 0.04) 100%);
  border-color: rgba(239, 68, 68, 0.3);
}

.summary-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--med-border);
}

.summary-badge {
  display: inline-flex;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.summary-badge.granted {
  background: var(--med-success);
  color: white;
}

.summary-badge.quarantined {
  background: var(--med-warning);
  color: white;
}

.summary-badge.denied {
  background: var(--med-danger);
  color: white;
}

.summary-agent {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--med-text);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
}

.summary-item {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.summary-label {
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--med-text-muted);
}

.summary-value {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--med-text);
}

.summary-value.high {
  color: var(--med-success);
}

.summary-value.medium {
  color: var(--med-amber);
}

.summary-value.low {
  color: var(--med-danger);
}

@media (max-width: 600px) {
  .summary-grid {
    grid-template-columns: 1fr;
  }
}

/* ============================================================================
   Patient Record
   ============================================================================ */

.patient-record {
  flex: 1;
  position: relative;
}

/* Lock Overlay */
.record-locked {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-lg);
  z-index: 10;
  text-align: center;
  padding: var(--space-6);
}

.record-locked.hidden {
  display: none;
}

.lock-icon {
  width: 80px;
  height: 80px;
  background: linear-gradient(135deg, var(--med-border-dark) 0%, var(--med-border) 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-4);
}

.lock-icon svg {
  width: 40px;
  height: 40px;
  color: var(--med-text-muted);
}

.record-locked h3 {
  font-size: 1.25rem;
  color: var(--med-text);
  margin-bottom: var(--space-2);
}

.record-locked p {
  color: var(--med-text-secondary);
  max-width: 280px;
}

/* Quarantine Overlay */
.record-quarantined {
  position: relative;
  z-index: 5;
}

.quarantine-banner {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.12) 0%, rgba(217, 119, 6, 0.12) 100%);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-3);
  color: var(--med-amber);
  font-size: 0.875rem;
  font-weight: 600;
}

.quarantine-banner svg {
  flex-shrink: 0;
  color: var(--med-amber);
}

/* Redaction effect */
.redactable {
  transition: all 0.3s ease;
}

.redactable.redacted {
  background: rgba(245, 158, 11, 0.1);
  color: var(--med-amber);
  padding: 0 var(--space-1);
  border-radius: 2px;
  font-family: var(--font-mono);
  font-size: 0.9em;
  letter-spacing: 0.02em;
}

/* Patient Card */
.patient-card {
  background: var(--med-bg-elevated);
  border: 1px solid var(--med-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.patient-header {
  background: linear-gradient(135deg, var(--med-primary) 0%, var(--med-primary-dark) 100%);
  color: white;
  padding: var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.patient-photo {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 600;
  border: 3px solid rgba(255, 255, 255, 0.3);
}

.patient-name {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: var(--space-1);
}

.patient-meta {
  display: flex;
  gap: var(--space-4);
  font-size: 0.875rem;
  opacity: 0.9;
}

.patient-mrn {
  font-family: var(--font-mono);
  background: rgba(255, 255, 255, 0.15);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
}

.patient-sections {
  padding: var(--space-4);
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-4);
}

@media (max-width: 1200px) {
  .patient-sections {
    grid-template-columns: 1fr;
  }
}

.patient-section {
  background: var(--med-bg-card);
  border: 1px solid var(--med-border);
  border-radius: var(--radius);
  padding: var(--space-4);
}

.patient-section h4 {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--med-primary);
  margin-bottom: var(--space-3);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.patient-section h4 svg {
  width: 16px;
  height: 16px;
}

.info-grid {
  display: grid;
  gap: var(--space-2);
}

.info-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.875rem;
}

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

.info-value {
  font-weight: 500;
  color: var(--med-text);
}

.medication-list, .condition-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.medication-item, .condition-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.875rem;
  padding: var(--space-2);
  background: var(--med-bg-elevated);
  border-radius: var(--radius-sm);
}

.medication-item .pill-icon {
  width: 24px;
  height: 24px;
  background: var(--med-secondary);
  color: white;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
}

.condition-item .condition-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.condition-dot.active { background: var(--med-warning); }
.condition-dot.resolved { background: var(--med-success); }
.condition-dot.chronic { background: var(--med-primary); }

/* ============================================================================
   Controls & Audit Panel
   ============================================================================ */

.controls-panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.threshold-control {
  background: var(--med-bg-card);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  border: 1px solid var(--med-border);
  box-shadow: var(--med-shadow);
}

.threshold-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-4);
}

.threshold-header h3 {
  font-size: 1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.threshold-header h3 svg {
  width: 18px;
  height: 18px;
  color: var(--med-primary);
}

.threshold-value-display {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--med-primary);
}

.threshold-slider {
  width: 100%;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--med-border);
  outline: none;
  -webkit-appearance: none;
  margin-bottom: var(--space-4);
}

.threshold-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--med-primary) 0%, var(--med-primary-light) 100%);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(8, 145, 178, 0.4);
  transition: transform 0.2s ease;
}

.threshold-slider::-webkit-slider-thumb:hover {
  transform: scale(1.1);
}

.threshold-slider::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--med-primary) 0%, var(--med-primary-light) 100%);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(8, 145, 178, 0.4);
  border: none;
}

.threshold-presets {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.preset-btn {
  flex: 1;
  min-width: 70px;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--med-border);
  background: var(--med-bg-elevated);
  border-radius: var(--radius);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.preset-btn:hover {
  border-color: var(--med-primary);
  background: rgba(8, 145, 178, 0.05);
}

.preset-btn.active {
  border-color: var(--med-primary);
  background: rgba(8, 145, 178, 0.1);
  color: var(--med-primary);
}

/* Tier Legend */
.tier-legend {
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--med-border);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.tier-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.8rem;
  color: var(--med-text-secondary);
}

.tier-item span:nth-child(2) {
  font-weight: 500;
  flex: 1;
}

.tier-item small {
  font-size: 0.7rem;
  color: var(--med-text-muted);
}

.tier-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.tier-full .tier-dot {
  background: var(--med-success);
}

.tier-quarantine .tier-dot {
  background: var(--med-warning);
}

.tier-denied .tier-dot {
  background: var(--med-danger);
}

/* Audit Log */
.audit-panel {
  background: var(--med-bg-card);
  border-radius: var(--radius-xl);
  border: 1px solid var(--med-border);
  box-shadow: var(--med-shadow);
  display: flex;
  flex-direction: column;
  max-height: 400px;
}

.audit-panel .panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.audit-count {
  background: var(--med-primary);
  color: white;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
}

.audit-list {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.audit-entry {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--med-bg-elevated);
  border-radius: var(--radius);
  border-left: 3px solid var(--med-border);
  font-size: 0.8125rem;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-10px); }
  to { opacity: 1; transform: translateX(0); }
}

.audit-entry.granted {
  border-left-color: var(--med-success);
}

.audit-entry.quarantined {
  border-left-color: var(--med-warning);
}

.audit-entry.denied {
  border-left-color: var(--med-danger);
}

.audit-entry.verifying {
  border-left-color: var(--med-warning);
}

.audit-entry.system {
  border-left-color: var(--med-primary);
}

.audit-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.audit-icon svg {
  width: 14px;
  height: 14px;
}

.audit-entry.granted .audit-icon {
  background: rgba(16, 185, 129, 0.1);
  color: var(--med-success);
}

.audit-entry.quarantined .audit-icon {
  background: rgba(245, 158, 11, 0.1);
  color: var(--med-warning);
}

.audit-entry.denied .audit-icon {
  background: rgba(239, 68, 68, 0.1);
  color: var(--med-danger);
}

.audit-entry.verifying .audit-icon {
  background: rgba(245, 158, 11, 0.1);
  color: var(--med-warning);
}

.audit-entry.system .audit-icon {
  background: rgba(8, 145, 178, 0.1);
  color: var(--med-primary);
}

.audit-content {
  flex: 1;
  min-width: 0;
}

.audit-action {
  font-weight: 500;
  color: var(--med-text);
  margin-bottom: var(--space-1);
}

.audit-details {
  color: var(--med-text-muted);
  font-size: 0.75rem;
}

.audit-time {
  font-size: 0.7rem;
  color: var(--med-text-muted);
  white-space: nowrap;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: var(--space-8);
  color: var(--med-text-muted);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  margin-bottom: var(--space-3);
  opacity: 0.5;
}

/* ============================================================================
   Buttons
   ============================================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--med-primary) 0%, var(--med-primary-dark) 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(8, 145, 178, 0.3);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(8, 145, 178, 0.4);
}

.btn-secondary {
  background: var(--med-bg-elevated);
  color: var(--med-text);
  border: 1px solid var(--med-border);
}

.btn-secondary:hover {
  border-color: var(--med-primary);
  background: rgba(8, 145, 178, 0.05);
}

.btn-sm {
  padding: var(--space-2) var(--space-3);
  font-size: 0.8125rem;
}

.btn-icon {
  width: 16px;
  height: 16px;
}

/* ============================================================================
   Real Agent Test Section
   ============================================================================ */

.test-real-agent {
  background: var(--med-bg-card);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  border: 1px solid var(--med-border);
  box-shadow: var(--med-shadow);
}

.test-real-agent h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: var(--space-3);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.test-real-agent h3 svg {
  width: 18px;
  height: 18px;
  color: var(--med-secondary);
}

.test-input-group {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.test-input {
  flex: 1;
  padding: var(--space-3);
  border: 1px solid var(--med-border);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  background: var(--med-bg-elevated);
  color: var(--med-text);
}

.test-input:focus {
  outline: none;
  border-color: var(--med-primary);
  box-shadow: 0 0 0 3px rgba(8, 145, 178, 0.1);
}

.test-result {
  padding: var(--space-3);
  border-radius: var(--radius);
  font-size: 0.8125rem;
  display: none;
}

.test-result.show {
  display: block;
}

.test-result.success {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.2);
  color: var(--med-success);
}

.test-result.error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: var(--med-danger);
}

/* ============================================================================
   Call to Action Section
   ============================================================================ */

.cta-section {
  background: linear-gradient(135deg, var(--med-bg-dark) 0%, #164e63 50%, #0c4a6e 100%);
  padding: var(--space-12) var(--space-6);
  text-align: center;
  position: relative;
  overflow: hidden;
}

.cta-section::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(ellipse at 50% 0%, rgba(34, 211, 238, 0.15) 0%, transparent 60%);
  pointer-events: none;
}

.cta-content {
  max-width: 700px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

.cta-content h2 {
  font-size: 2rem;
  font-weight: 700;
  color: white;
  margin-bottom: var(--space-3);
  letter-spacing: -0.02em;
}

.cta-content > p {
  font-size: 1.05rem;
  color: rgba(255, 255, 255, 0.75);
  margin-bottom: var(--space-8);
  line-height: 1.7;
}

.cta-buttons {
  display: flex;
  justify-content: center;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-bottom: var(--space-5);
}

.btn-cta-primary {
  background: linear-gradient(135deg, var(--med-primary-light) 0%, var(--med-accent) 100%);
  color: white;
  padding: var(--space-3) var(--space-6);
  font-weight: 600;
  font-size: 0.95rem;
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 16px rgba(34, 211, 238, 0.3);
  text-decoration: none;
}

.btn-cta-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(34, 211, 238, 0.4);
}

.btn-cta-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: white;
  padding: var(--space-3) var(--space-6);
  font-weight: 600;
  font-size: 0.95rem;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.25);
  text-decoration: none;
}

.btn-cta-secondary:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.4);
  transform: translateY(-2px);
}

.btn-cta-outline {
  background: transparent;
  color: rgba(255, 255, 255, 0.85);
  padding: var(--space-3) var(--space-6);
  font-weight: 500;
  font-size: 0.95rem;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.2);
  text-decoration: none;
}

.btn-cta-outline:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.35);
  color: white;
  transform: translateY(-1px);
}

.cta-note {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.5);
}

.cta-note strong {
  color: rgba(255, 255, 255, 0.7);
}

.cta-note a {
  color: var(--med-primary-light);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.cta-note a:hover {
  color: var(--med-accent);
}

/* ============================================================================
   Dashboard Section: Credentials, Webhooks, API Usage, Anomaly Detection
   ============================================================================ */

.dashboard-section {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 var(--space-6) var(--space-6);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-6);
}

@media (max-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

.dashboard-panel {
  display: flex;
  flex-direction: column;
  max-height: 380px;
}

.dashboard-panel .panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.dashboard-count {
  background: var(--med-primary);
  color: white;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  min-width: 24px;
  text-align: center;
}

.dashboard-list {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.dashboard-content {
  padding: var(--space-4);
}

/* Dashboard Item (shared for credentials & webhooks) */
.dashboard-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--med-bg-elevated);
  border-radius: var(--radius);
  border-left: 3px solid var(--med-border);
  transition: all 0.2s ease;
}

.dashboard-item:hover {
  background: rgba(8, 145, 178, 0.03);
}

.dashboard-item.active {
  border-left-color: var(--med-success);
}

.dashboard-item.revoked {
  border-left-color: var(--med-danger);
  opacity: 0.7;
}

.dashboard-item.rotated {
  border-left-color: var(--med-warning);
}

.dashboard-item.inactive {
  border-left-color: var(--med-text-muted);
  opacity: 0.6;
}

.item-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.credential-icon.active {
  background: rgba(16, 185, 129, 0.1);
}

.credential-icon.revoked {
  background: rgba(239, 68, 68, 0.1);
}

.credential-icon.rotated {
  background: rgba(245, 158, 11, 0.1);
}

.webhook-icon.active {
  background: rgba(99, 102, 241, 0.1);
}

.webhook-icon.inactive {
  background: rgba(100, 116, 139, 0.1);
}

.item-content {
  flex: 1;
  min-width: 0;
}

.item-title {
  font-weight: 500;
  font-size: 0.85rem;
  color: var(--med-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-1);
}

.item-badge {
  display: inline-flex;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.item-badge.active {
  background: rgba(16, 185, 129, 0.1);
  color: var(--med-success);
}

.item-badge.revoked {
  background: rgba(239, 68, 68, 0.1);
  color: var(--med-danger);
}

.item-badge.rotated {
  background: rgba(245, 158, 11, 0.1);
  color: var(--med-warning);
}

.item-badge.inactive {
  background: rgba(100, 116, 139, 0.1);
  color: var(--med-text-muted);
}

.item-type {
  font-size: 0.7rem;
  color: var(--med-text-muted);
}

.item-detail {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--med-text-muted);
  margin-top: 2px;
}

.item-time {
  font-size: 0.7rem;
  color: var(--med-text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Empty State (small) */
.empty-state-sm {
  text-align: center;
  padding: var(--space-6) var(--space-4);
  color: var(--med-text-muted);
}

.empty-state-sm .empty-icon {
  font-size: 2rem;
  display: block;
  margin-bottom: var(--space-2);
  opacity: 0.5;
}

.empty-state-sm p {
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: var(--space-1);
}

.empty-state-sm small {
  font-size: 0.75rem;
  color: var(--med-text-muted);
}

/* Anomaly Detection Panel */
.anomaly-status-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.anomaly-stat {
  background: var(--med-bg-elevated);
  padding: var(--space-3);
  border-radius: var(--radius);
  border: 1px solid var(--med-border);
}

.anomaly-stat .stat-label {
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--med-text-muted);
  margin-bottom: var(--space-1);
}

.anomaly-stat .stat-value {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--med-text);
}

.anomaly-stat .stat-value.high {
  color: var(--med-success);
}

.anomaly-stat .stat-value.medium {
  color: var(--med-warning);
}

.anomaly-stat .stat-value.low {
  color: var(--med-danger);
}

.buffer-progress {
  background: var(--med-bg-elevated);
  padding: var(--space-3);
  border-radius: var(--radius);
  border: 1px solid var(--med-border);
}

.buffer-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--med-text-secondary);
  margin-bottom: var(--space-2);
}

.buffer-bar {
  height: 8px;
  background: var(--med-border);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: var(--space-1);
}

.buffer-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--med-primary) 0%, var(--med-primary-light) 100%);
  transition: width 0.5s ease;
}

.buffer-pct {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--med-primary);
  text-align: right;
}

/* API Usage Panel */
.usage-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

@media (max-width: 600px) {
  .usage-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.usage-stat {
  text-align: center;
  background: var(--med-bg-elevated);
  padding: var(--space-3);
  border-radius: var(--radius);
  border: 1px solid var(--med-border);
}

.usage-stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--med-primary);
  line-height: 1.2;
}

.usage-stat-value.high {
  color: var(--med-success);
}

.usage-stat-label {
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--med-text-muted);
  margin-top: var(--space-1);
}

.usage-agents-breakdown {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.usage-agent-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: var(--med-bg-elevated);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
}

.usage-agent-name {
  flex: 1;
  font-weight: 500;
  color: var(--med-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.usage-agent-score {
  font-weight: 700;
  font-size: 0.85rem;
}

.usage-agent-score.high {
  color: var(--med-success);
}

.usage-agent-score.medium {
  color: var(--med-warning);
}

.usage-agent-score.low {
  color: var(--med-danger);
}

.usage-agent-interactions {
  font-size: 0.75rem;
  color: var(--med-text-muted);
  white-space: nowrap;
}

/* ============================================================================
   Loading States
   ============================================================================ */

.skeleton {
  background: linear-gradient(90deg, var(--med-border) 25%, var(--med-bg-elevated) 50%, var(--med-border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ============================================================================
   Footer
   ============================================================================ */

.portal-footer {
  background: linear-gradient(180deg, #0a3d5c 0%, #072a40 100%);
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.8125rem;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-10) var(--space-6) var(--space-8);
  display: grid;
  grid-template-columns: 1.2fr 2fr;
  gap: var(--space-10);
  align-items: start;
}

.footer-brand {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.footer-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.footer-logo-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--med-primary-light) 0%, var(--med-accent) 100%);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.footer-logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}

.footer-logo-text strong {
  font-size: 1.1rem;
  color: white;
  font-weight: 700;
}

.footer-logo-text span {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.6;
}

.footer-tagline {
  font-size: 0.8rem;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.5);
  max-width: 320px;
}

.footer-links-group {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-6);
}

.footer-links-col h4 {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.9);
  margin-bottom: var(--space-4);
}

.footer-links-col ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.footer-links-col a {
  color: rgba(255, 255, 255, 0.55);
  text-decoration: none;
  font-size: 0.8rem;
  transition: color 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.footer-links-col a:hover {
  color: var(--med-primary-light);
}

.footer-links-col a svg {
  flex-shrink: 0;
  opacity: 0.7;
}

.footer-links-col a:hover svg {
  opacity: 1;
}

.footer-bottom {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding: var(--space-5) var(--space-6);
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto;
}

.footer-bottom p {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.4);
}

.footer-powered a {
  color: var(--med-primary-light);
  text-decoration: none;
  transition: color 0.2s ease;
}

.footer-powered a:hover {
  color: var(--med-accent);
  text-decoration: underline;
}

/* Footer responsive */
@media (max-width: 768px) {
  .footer-content {
    grid-template-columns: 1fr;
    gap: var(--space-8);
    padding: var(--space-8) var(--space-4) var(--space-6);
  }

  .footer-links-group {
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-4);
  }

  .footer-bottom {
    flex-direction: column;
    gap: var(--space-2);
    text-align: center;
    padding: var(--space-4);
  }
}

@media (max-width: 480px) {
  .footer-links-group {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-6);
  }
}

/* ============================================================================
   Responsive
   ============================================================================ */

@media (max-width: 768px) {
  .portal-header {
    padding: var(--space-3) var(--space-4);
  }

  .header-content {
    flex-wrap: wrap;
  }

  .dat-badge {
    display: none;
  }

  .portal-main {
    padding: var(--space-4);
  }

  .patient-sections {
    grid-template-columns: 1fr;
  }

  /* Flow diagram stacks vertically on small screens */
  .flow-diagram {
    flex-direction: column;
    align-items: center;
  }

  .flow-connector {
    transform: rotate(90deg);
    padding-top: 0;
    min-width: auto;
    height: 30px;
  }

  .flow-node {
    min-width: 200px;
  }

  .flow-diagram-wrapper.open {
    max-height: 800px;
  }

  /* CTA responsive */
  .cta-content h2 {
    font-size: 1.5rem;
  }

  .cta-buttons {
    flex-direction: column;
    align-items: center;
  }

  .btn-cta-primary,
  .btn-cta-secondary,
  .btn-cta-outline {
    width: 100%;
    max-width: 280px;
    justify-content: center;
  }

  /* Summary grid single column */
  .summary-grid {
    grid-template-columns: 1fr;
  }
}

/* ============================================================================
   Scrollbar Styling
   ============================================================================ */

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--med-bg-elevated);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb {
  background: var(--med-border-dark);
  border-radius: var(--radius-full);
}

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