    * { box-sizing: border-box; margin: 0; padding: 0; }
    body {
      font-family: 'Inter', -apple-system, sans-serif;
      background: #f0f4f8;
      color: #1e293b;
      height: 100vh;
      overflow: hidden;
      padding-top: 30px;
    }
    /* History Sidebar */
    .history-sidebar {
      width: 0;
      min-width: 0;
      overflow: hidden;
      transition: width 0.3s, min-width 0.3s;
      background: #f8fafc;
      flex-shrink: 0;
      height: 100vh;
      position: sticky;
      top: 0;
      display: flex;
      flex-direction: column;
    }
    .history-sidebar.open {
      width: 260px;
      min-width: 260px;
      border-right: 1px solid #e2e8f0;
      overflow-y: auto;
    }
    .history-header {
      padding: 0.875rem 1rem;
      background: linear-gradient(135deg, #1F4E79, #2563eb);
      color: white;
      font-weight: 600;
      font-size: 0.875rem;
      display: flex;
      justify-content: space-between;
      align-items: center;
      flex-shrink: 0;
    }
    .history-close {
      background: none;
      border: none;
      color: white;
      font-size: 1.25rem;
      cursor: pointer;
      opacity: 0.8;
    }
    .history-close:hover { opacity: 1; }
    .history-filter {
      padding: 0.5rem 0.75rem;
      border-bottom: 1px solid #e2e8f0;
      flex-shrink: 0;
    }
    .history-filter select {
      width: 100%;
      padding: 0.375rem;
      border: 1px solid #e2e8f0;
      border-radius: 6px;
      font-size: 0.8125rem;
      font-family: inherit;
    }
    .history-list {
      flex: 1;
      overflow-y: auto;
      padding: 0.5rem;
    }
    .history-item {
      padding: 0.625rem 0.75rem;
      border-radius: 8px;
      cursor: pointer;
      margin-bottom: 0.375rem;
      border: 1px solid #e2e8f0;
      background: white;
      transition: background 0.15s;
    }
    .history-item:hover { background: #eff6ff; }
    .history-item.active { background: #dbeafe; border-color: #93c5fd; }
    .history-item-patient {
      font-size: 0.6875rem;
      color: #2563eb;
      font-weight: 500;
    }
    .history-item-title {
      font-size: 0.8125rem;
      font-weight: 500;
      color: #1e293b;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      margin-top: 0.125rem;
    }
    .history-item-meta {
      font-size: 0.6875rem;
      color: #94a3b8;
      margin-top: 0.125rem;
    }
    .history-toggle {
      position: fixed;
      left: 0;
      top: 50%;
      transform: translateY(-50%);
      z-index: 200;
      background: #1F4E79;
      color: white;
      border: none;
      border-radius: 0 8px 8px 0;
      padding: 0.5rem 0.375rem;
      font-size: 0.75rem;
      cursor: pointer;
      writing-mode: vertical-rl;
      text-orientation: mixed;
      font-family: inherit;
      font-weight: 600;
      box-shadow: 2px 0 8px rgba(0,0,0,0.12);
      transition: left 0.3s, opacity 0.3s;
    }
    .history-toggle:hover { background: #163a5c; }
    .history-toggle.open { opacity: 0; pointer-events: none; }

    .clinician-banner {
      background: #fef3c7;
      border-bottom: 2px solid #f59e0b;
      padding: 0.375rem 1rem;
      text-align: center;
      font-size: 0.75rem;
      font-weight: 600;
      color: #92400e;
      letter-spacing: 0.02em;
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      z-index: 500;
    }
    .clinician-banner .clinician-icon { margin-right: 0.375rem; }
    .app-layout {
      display: flex;
      height: calc(100vh - 30px);
      width: 100%;
      overflow: hidden;
    }
    .main-content {
      flex: 1;
      display: flex;
      flex-direction: column;
      min-width: 0;
    }
    .footer-disclaimer {
      display: block;
      margin-top: 0.25rem;
      font-size: 0.625rem;
      color: #64748b;
    }
    header {
      background: linear-gradient(135deg, #1F4E79 0%, #2563eb 100%);
      color: white;
      padding: 0.875rem 1.5rem;
      display: flex;
      align-items: center;
      justify-content: space-between;
      flex-wrap: wrap;
      gap: 0.5rem;
      box-shadow: 0 2px 8px rgba(0,0,0,0.15);
      position: sticky;
      top: 0;
      z-index: 100;
    }
    .header-left { display: flex; align-items: center; gap: 0.75rem; }
    .header-left h1 { font-size: 1.125rem; font-weight: 600; }
    .header-left .badge {
      background: rgba(255,255,255,0.2);
      padding: 0.2rem 0.5rem;
      border-radius: 4px;
      font-size: 0.7rem;
      font-weight: 500;
    }
    .new-chat-btn {
      padding: 0.375rem 0.75rem;
      border-radius: 6px;
      border: 1px solid rgba(255,255,255,0.3);
      background: rgba(255,255,255,0.15);
      color: white;
      font-size: 0.8125rem;
      font-family: inherit;
      cursor: pointer;
      font-weight: 500;
      transition: background 0.15s;
    }
    .new-chat-btn:hover { background: rgba(255,255,255,0.3); }
    .patient-selector {
      display: flex;
      align-items: center;
      gap: 0.5rem;
    }
    .patient-selector label {
      font-size: 0.8125rem;
      opacity: 0.9;
    }
    .patient-selector select {
      padding: 0.375rem 0.5rem;
      border-radius: 6px;
      border: 1px solid rgba(255,255,255,0.3);
      background: rgba(255,255,255,0.15);
      color: white;
      font-size: 0.8125rem;
      font-family: inherit;
      cursor: pointer;
    }
    .patient-selector select option { color: #1e293b; background: white; }
    .patient-selector select.locked,
    .patient-selector select:disabled {
      opacity: 0.7;
      pointer-events: none;
      border-color: rgba(255,255,255,0.15);
      -webkit-appearance: none;
      cursor: not-allowed;
    }
    .patient-lock-hint {
      font-size: 0.625rem;
      color: rgba(255,255,255,0.6);
      margin-left: 0.25rem;
      cursor: help;
    }

    #quick-prompts {
      padding: 0.75rem 1.5rem;
      background: white;
      border-bottom: 1px solid #e2e8f0;
      display: flex;
      gap: 0.5rem;
      overflow-x: auto;
      max-width: 100%;
      position: sticky;
      top: 52px;
      z-index: 99;
    }
    .quick-btn {
      flex-shrink: 0;
      padding: 0.375rem 0.75rem;
      border: 1px solid #cbd5e1;
      border-radius: 20px;
      background: white;
      color: #475569;
      font-size: 0.8125rem;
      cursor: pointer;
      font-family: inherit;
      transition: all 0.15s;
    }
    .quick-btn:hover {
      background: #1F4E79;
      color: white;
      border-color: #1F4E79;
    }
    .quick-btn.disabled {
      opacity: 0.4;
      cursor: not-allowed;
      pointer-events: none;
    }
    .patient-context {
      padding: 0.5rem 1.5rem;
      background: #eff6ff;
      border-bottom: 1px solid #bfdbfe;
    }
    .patient-context-inner {
      max-width: 800px;
      margin: 0 auto;
      display: flex;
      align-items: center;
      gap: 0.625rem;
    }
    .patient-context-icon { font-size: 1.125rem; }
    .patient-context-name {
      font-weight: 600;
      font-size: 0.875rem;
      color: #1e293b;
    }
    .patient-context-detail {
      font-size: 0.75rem;
      color: #64748b;
      margin-left: 0.5rem;
    }
    .patient-warning {
      background: #fef3c7;
      border-bottom: 1px solid #fde68a;
      padding: 0.5rem 1.5rem;
      font-size: 0.8125rem;
      color: #92400e;
      text-align: center;
      display: none;
    }
    .patient-required {
      animation: pulse-border 0.5s ease 2;
    }
    @keyframes pulse-border {
      0%, 100% { border-color: rgba(255,255,255,0.3); box-shadow: none; }
      50% { border-color: #ef4444; box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.3); }
    }

    .patient-switch-notice {
      background: #eff6ff;
      border: 1px solid #3b82f6;
      border-radius: 8px;
      padding: 0.625rem 0.875rem;
      margin: 0.5rem 0;
      font-size: 0.8125rem;
      color: #1e40af;
      max-width: 800px;
      align-self: center;
    }
    .patient-switch-notice strong { color: #1e3a8a; }
    .patient-switch-actions {
      display: flex;
      gap: 0.5rem;
      margin-top: 0.5rem;
    }
    .patient-switch-btn {
      padding: 0.375rem 0.75rem;
      border-radius: 6px;
      font-size: 0.75rem;
      font-family: inherit;
      font-weight: 500;
      cursor: pointer;
      border: none;
    }
    .patient-switch-btn.primary {
      background: #2563eb;
      color: white;
    }
    .patient-switch-btn.primary:hover { background: #1d4ed8; }
    .patient-switch-btn.secondary {
      background: white;
      color: #475569;
      border: 1px solid #cbd5e1;
    }
    .patient-switch-btn.secondary:hover { background: #f1f5f9; }

    #chat-container {
      flex: 1;
      overflow-y: auto;
      padding: 1.5rem;
      max-width: 800px;
      margin: 0 auto;
      width: 100%;
    }
    .message {
      margin-bottom: 1rem;
      display: flex;
      gap: 0.75rem;
    }
    .message.user { flex-direction: row-reverse; }
    .message-bubble {
      max-width: 80%;
      padding: 0.875rem 1rem;
      border-radius: 12px;
      line-height: 1.6;
      font-size: 0.9375rem;
    }
    .message.agent .message-bubble {
      background: white;
      border: 1px solid #e2e8f0;
      box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    }
    .message.user .message-bubble {
      background: #1F4E79;
      color: white;
    }
    .message-content { white-space: pre-wrap; word-break: break-word; }
    .message-content.md-rendered { white-space: normal; }
    /* Markdown rendered styles */
    .md-rendered h2.md-h2 { font-size: 1.125rem; font-weight: 700; color: #1e293b; margin: 0.75rem 0 0.375rem; }
    .md-rendered h3.md-h3 { font-size: 1rem; font-weight: 600; color: #1F4E79; margin: 0.625rem 0 0.25rem; }
    .md-rendered h4.md-h4 { font-size: 0.9375rem; font-weight: 600; color: #334155; margin: 0.5rem 0 0.25rem; }
    .md-rendered p.md-p { margin: 0.375rem 0; }
    .md-rendered ul, .md-rendered ol { margin: 0.375rem 0 0.375rem 1.25rem; padding: 0; }
    .md-rendered li { margin-bottom: 0.25rem; line-height: 1.5; }
    .md-rendered hr { border: none; border-top: 1px solid #e2e8f0; margin: 0.75rem 0; }
    .md-rendered strong { font-weight: 600; color: #1e293b; }
    .md-rendered em { font-style: italic; color: #475569; }

    .tool-badges {
      display: flex;
      flex-wrap: wrap;
      gap: 0.375rem;
      margin-top: 0.625rem;
      padding-top: 0.5rem;
      border-top: 1px solid #f1f5f9;
    }
    .tool-badge {
      display: inline-flex;
      align-items: center;
      gap: 0.25rem;
      padding: 0.2rem 0.5rem;
      background: #eff6ff;
      border: 1px solid #bfdbfe;
      border-radius: 4px;
      font-size: 0.7rem;
      color: #1e40af;
      font-weight: 500;
    }
    .tool-badge .icon { font-size: 0.75rem; }
    .tool-badge.streaming-badge {
      animation: tool-pulse 1.5s ease-in-out infinite;
      border-color: #93c5fd;
      background: #dbeafe;
    }
    @keyframes tool-pulse {
      0%, 100% { opacity: 1; }
      50% { opacity: 0.6; }
    }
    .message.streaming .message-bubble {
      border-left: 3px solid #2563eb;
    }
    .streaming-cursor::after {
      content: '\u2588';
      animation: blink 1s step-end infinite;
      color: #2563eb;
    }
    @keyframes blink {
      0%, 100% { opacity: 1; }
      50% { opacity: 0; }
    }
    .tool-detail {
      margin-top: 0.375rem;
      font-size: 0.75rem;
      color: #64748b;
      cursor: pointer;
    }
    .tool-detail-content {
      display: none;
      margin-top: 0.25rem;
      padding: 0.5rem;
      background: #f8fafc;
      border-radius: 6px;
      overflow-x: auto;
      font-size: 0.7rem;
      font-family: 'SF Mono', 'Fira Code', monospace;
    }
    .tool-detail.open .tool-detail-content { display: block; }

    .safety-alert {
      background: #fef3c7;
      border-left: 4px solid #f59e0b;
      padding: 0.5rem 0.75rem;
      margin-bottom: 0.5rem;
      border-radius: 0 6px 6px 0;
      font-size: 0.875rem;
      font-weight: 500;
    }
    .safety-alert.critical {
      background: #fee2e2;
      border-left-color: #ef4444;
    }

    .meta-unavailable-note {
      font-size: 0.8rem;
      color: #64748b;
      padding: 0.5rem 0.75rem;
      margin-top: 0.5rem;
      background: #f8fafc;
      border-radius: 6px;
      border-left: 3px solid #94a3b8;
    }

    .message-timing {
      font-size: 0.7rem;
      color: #94a3b8;
      margin-top: 0.375rem;
      padding-top: 0.375rem;
      border-top: 1px solid #f1f5f9;
    }
    .feedback-row {
      display: flex;
      gap: 0.375rem;
      margin-top: 0.5rem;
      padding-top: 0.375rem;
    }
    .feedback-row button {
      background: none;
      border: 1px solid transparent;
      cursor: pointer;
      font-size: 0.875rem;
      padding: 0.125rem 0.375rem;
      border-radius: 4px;
      opacity: 0.5;
      transition: all 0.15s;
    }
    .feedback-row button:hover { opacity: 0.8; border-color: #e2e8f0; }
    .feedback-row button.active { opacity: 1; background: #eff6ff; border-color: #bfdbfe; }

    #input-area {
      padding: 1rem 1.5rem;
      background: white;
      border-top: 1px solid #e2e8f0;
      max-width: 800px;
      margin: 0 auto;
      width: 100%;
    }
    #input-row {
      display: flex;
      gap: 0.5rem;
    }
    #message-input {
      flex: 1;
      padding: 0.75rem 1rem;
      border: 1px solid #e2e8f0;
      border-radius: 8px;
      font-size: 0.9375rem;
      font-family: inherit;
      resize: none;
      min-height: 42px;
      max-height: 150px;
      overflow-y: auto;
      line-height: 1.5;
    }
    #message-input:focus {
      outline: none;
      border-color: #1F4E79;
      box-shadow: 0 0 0 2px rgba(31, 78, 121, 0.2);
    }
    #send-btn {
      padding: 0.75rem 1.25rem;
      background: #1F4E79;
      color: white;
      border: none;
      border-radius: 8px;
      font-weight: 600;
      cursor: pointer;
      font-family: inherit;
      transition: background 0.15s;
    }
    #send-btn:hover { background: #163a5c; }
    #send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

    .thinking-indicator {
      display: flex;
      align-items: center;
      gap: 0.5rem;
      color: #64748b;
      font-style: italic;
      padding: 0.5rem 0;
    }
    .dot-pulse { display: flex; gap: 0.25rem; }
    .dot-pulse span {
      width: 6px; height: 6px;
      background: #94a3b8;
      border-radius: 50%;
      animation: pulse 1.2s infinite;
    }
    .dot-pulse span:nth-child(2) { animation-delay: 0.2s; }
    .dot-pulse span:nth-child(3) { animation-delay: 0.4s; }
    @keyframes pulse { 0%, 80%, 100% { opacity: 0.3; } 40% { opacity: 1; } }

    .welcome {
      text-align: center;
      padding: 2rem 1rem;
      color: #64748b;
    }
    .welcome h2 { color: #1e293b; margin-bottom: 0.5rem; font-size: 1.25rem; }
    .welcome p { font-size: 0.9375rem; max-width: 500px; margin: 0 auto; }

    footer {
      text-align: center;
      padding: 0.625rem;
      font-size: 0.7rem;
      color: #94a3b8;
      background: #f8fafc;
      border-top: 1px solid #f1f5f9;
    }
    footer a { color: #64748b; text-decoration: none; }
    footer a:hover { text-decoration: underline; }

    /* Observability Sidebar */
    .obs-toggle {
      position: fixed;
      right: 0;
      top: 50%;
      transform: translateY(-50%);
      z-index: 200;
      background: #1F4E79;
      color: white;
      border: none;
      border-radius: 8px 0 0 8px;
      padding: 0.5rem 0.375rem;
      font-size: 0.75rem;
      cursor: pointer;
      writing-mode: vertical-rl;
      text-orientation: mixed;
      letter-spacing: 0.05em;
      font-family: inherit;
      font-weight: 600;
      box-shadow: -2px 0 8px rgba(0,0,0,0.12);
      transition: right 0.3s;
    }
    .obs-toggle:hover { background: #163a5c; }
    .obs-toggle.open { opacity: 0; pointer-events: none; }

    .obs-sidebar {
      width: 0;
      min-width: 0;
      overflow: hidden;
      transition: width 0.3s, min-width 0.3s;
      background: #f8fafc;
      border-left: none;
      box-shadow: -4px 0 16px rgba(0,0,0,0.08);
      flex-shrink: 0;
      height: 100vh;
      position: sticky;
      top: 0;
      display: flex;
      flex-direction: column;
    }
    .obs-sidebar.open {
      width: 320px;
      min-width: 320px;
      border-left: 1px solid #e2e8f0;
      overflow-y: auto;
    }

    .obs-header {
      padding: 1rem;
      background: linear-gradient(135deg, #1F4E79 0%, #2563eb 100%);
      color: white;
      font-weight: 600;
      font-size: 0.875rem;
      display: flex;
      align-items: center;
      justify-content: space-between;
      position: sticky;
      top: 0;
      z-index: 10;
    }
    .obs-header-title { display: flex; align-items: center; gap: 0.5rem; }
    .obs-close {
      background: none;
      border: none;
      color: white;
      font-size: 1.25rem;
      cursor: pointer;
      padding: 0 0.25rem;
      opacity: 0.8;
      transition: opacity 0.15s;
    }
    .obs-close:hover { opacity: 1; }

    .obs-section {
      padding: 0.875rem 1rem;
      border-bottom: 1px solid #e2e8f0;
    }
    .obs-section-title {
      font-size: 0.6875rem;
      font-weight: 600;
      color: #64748b;
      text-transform: uppercase;
      letter-spacing: 0.05em;
      margin-bottom: 0.625rem;
    }

    .obs-stats-grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 0.5rem;
    }
    .obs-stat-card {
      background: white;
      border: 1px solid #e2e8f0;
      border-radius: 8px;
      padding: 0.625rem;
      text-align: center;
    }
    .obs-stat-value {
      font-size: 1.25rem;
      font-weight: 700;
      color: #1e293b;
      line-height: 1;
    }
    .obs-stat-value.error { color: #ef4444; }
    .obs-stat-value.warn { color: #f59e0b; }
    .obs-stat-label {
      font-size: 0.6875rem;
      color: #64748b;
      margin-top: 0.25rem;
    }

    .obs-tool-row {
      display: flex;
      align-items: center;
      gap: 0.5rem;
      margin-bottom: 0.375rem;
      font-size: 0.75rem;
    }
    .obs-tool-name {
      width: 110px;
      flex-shrink: 0;
      color: #475569;
      text-align: right;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .obs-tool-bar-bg {
      flex: 1;
      height: 14px;
      background: #e2e8f0;
      border-radius: 4px;
      overflow: hidden;
    }
    .obs-tool-bar {
      height: 100%;
      background: linear-gradient(90deg, #2563eb, #1F4E79);
      border-radius: 4px;
      transition: width 0.4s ease;
      min-width: 2px;
    }
    .obs-tool-count {
      width: 28px;
      flex-shrink: 0;
      color: #64748b;
      font-weight: 600;
      font-size: 0.6875rem;
    }

    .obs-debug {
      font-size: 0.75rem;
      color: #475569;
    }
    .obs-debug-row {
      display: flex;
      justify-content: space-between;
      padding: 0.25rem 0;
      border-bottom: 1px solid #f1f5f9;
    }
    .obs-debug-label { color: #94a3b8; }
    .obs-debug-value { font-weight: 500; font-family: 'SF Mono', 'Fira Code', monospace; font-size: 0.6875rem; }

    .obs-error-log {
      max-height: 120px;
      overflow-y: auto;
      font-size: 0.6875rem;
      font-family: 'SF Mono', 'Fira Code', monospace;
      color: #ef4444;
      background: #fef2f2;
      border-radius: 6px;
      padding: 0.5rem;
      margin-top: 0.5rem;
    }
    .obs-error-entry {
      padding: 0.2rem 0;
      border-bottom: 1px dashed #fecaca;
    }
    .obs-error-entry:last-child { border-bottom: none; }
    .obs-no-data {
      text-align: center;
      color: #94a3b8;
      font-size: 0.75rem;
      padding: 1rem 0;
    }
    .obs-no-data-detail {
      font-size: 0.6875rem;
      color: #cbd5e1;
      margin-top: 0.375rem;
      line-height: 1.5;
    }

    /* Collapsible sections */
    .obs-section-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      cursor: pointer;
      user-select: none;
    }
    .obs-section-header .obs-chevron {
      font-size: 0.625rem;
      color: #94a3b8;
      transition: transform 0.2s;
    }
    .obs-section.collapsed .obs-section-body { display: none; }
    .obs-section.collapsed .obs-chevron { transform: rotate(-90deg); }

    /* Last Request trace */
    .obs-last-request {
      background: white;
      border: 1px solid #e2e8f0;
      border-radius: 8px;
      padding: 0.625rem;
      font-size: 0.75rem;
    }
    .obs-last-query {
      color: #1e293b;
      font-weight: 500;
      margin-bottom: 0.375rem;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .obs-last-timing {
      display: flex;
      gap: 0.75rem;
      color: #64748b;
      font-size: 0.6875rem;
      margin-bottom: 0.375rem;
    }
    .obs-last-timing strong { color: #1e293b; }
    .obs-last-tools {
      display: flex;
      flex-wrap: wrap;
      gap: 0.25rem;
    }
    .obs-last-tool-pill {
      background: #eff6ff;
      color: #2563eb;
      padding: 0.125rem 0.5rem;
      border-radius: 10px;
      font-size: 0.625rem;
      font-weight: 500;
    }

    /* Request timeline */
    .obs-timeline-entry {
      display: flex;
      align-items: center;
      gap: 0.5rem;
      padding: 0.3rem 0;
      border-bottom: 1px solid #f1f5f9;
      font-size: 0.6875rem;
    }
    .obs-timeline-entry:last-child { border-bottom: none; }
    .obs-timeline-time { color: #94a3b8; width: 52px; flex-shrink: 0; }
    .obs-timeline-tools { flex: 1; color: #475569; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .obs-timeline-dur { color: #64748b; font-weight: 600; width: 40px; text-align: right; flex-shrink: 0; }
    .obs-timeline-status { width: 16px; flex-shrink: 0; text-align: center; }

    /* Tool usage with latency */
    .obs-tool-latency {
      color: #94a3b8;
      font-size: 0.625rem;
      margin-left: 0.25rem;
    }

    /* Copy session ID button */
    .obs-copy-btn {
      background: none;
      border: none;
      color: #94a3b8;
      cursor: pointer;
      font-size: 0.75rem;
      padding: 0 0.25rem;
      transition: color 0.15s;
    }
    .obs-copy-btn:hover { color: #2563eb; }

    /* Clear / Export buttons */
    .obs-actions {
      display: flex;
      gap: 0.5rem;
      padding: 0.625rem 1rem;
      border-bottom: 1px solid #e2e8f0;
    }
    .obs-action-btn {
      flex: 1;
      padding: 0.375rem 0.5rem;
      border: 1px solid #e2e8f0;
      border-radius: 6px;
      background: white;
      color: #475569;
      font-size: 0.6875rem;
      font-family: inherit;
      cursor: pointer;
      text-align: center;
      transition: background 0.15s;
    }
    .obs-action-btn:hover { background: #f1f5f9; }

    /* Latency distribution */
    .obs-latency-dist {
      font-size: 0.6875rem;
      color: #64748b;
      display: flex;
      gap: 0.75rem;
      margin-top: 0.375rem;
    }
    .obs-latency-dist strong { color: #1e293b; }

    /* Error log improvements */
    .obs-error-badge {
      background: #ef4444;
      color: white;
      border-radius: 10px;
      padding: 0 0.375rem;
      font-size: 0.625rem;
      font-weight: 600;
      margin-left: 0.375rem;
    }

    /* Langfuse link */
    .obs-langfuse-link {
      display: inline-block;
      color: #2563eb;
      font-size: 0.6875rem;
      text-decoration: none;
      margin-top: 0.375rem;
    }
    .obs-langfuse-link:hover { text-decoration: underline;
      font-style: italic;
    }

    /* Performance Targets */
    .perf-target-row {
      display: flex;
      align-items: center;
      gap: 0.5rem;
      padding: 0.375rem 0;
      border-bottom: 1px solid #f1f5f9;
      font-size: 0.75rem;
    }
    .perf-target-row:last-child { border-bottom: none; }
    .perf-icon { font-size: 0.8125rem; flex-shrink: 0; }
    .perf-label { flex: 1; color: #475569; }
    .perf-value {
      font-weight: 600;
      font-family: 'SF Mono', 'Fira Code', monospace;
      font-size: 0.6875rem;
    }
    .perf-value.met { color: #16a34a; }
    .perf-value.unmet { color: #ef4444; }
    .perf-value.pending { color: #94a3b8; }
    .perf-target-bar {
      width: 100%;
      height: 6px;
      background: #e2e8f0;
      border-radius: 3px;
      overflow: hidden;
      margin-top: 0.125rem;
    }
    .perf-target-fill {
      height: 100%;
      border-radius: 3px;
      transition: width 0.4s ease;
    }
    .perf-target-fill.met { background: #16a34a; }
    .perf-target-fill.unmet { background: #ef4444; }
    .perf-target-fill.partial { background: #f59e0b; }
    .perf-score {
      text-align: center;
      padding: 0.625rem;
      margin-bottom: 0.5rem;
      background: white;
      border: 1px solid #e2e8f0;
      border-radius: 8px;
    }
    .perf-score-value {
      font-size: 1.5rem;
      font-weight: 700;
      line-height: 1;
    }
    .perf-score-value.good { color: #16a34a; }
    .perf-score-value.ok { color: #f59e0b; }
    .perf-score-value.bad { color: #ef4444; }
    .perf-score-label {
      font-size: 0.6875rem;
      color: #64748b;
      margin-top: 0.25rem;
    }

    /* Structured Result panel */
    .structured-result {
      margin-top: 0.375rem;
      font-size: 0.75rem;
      color: #64748b;
      cursor: pointer;
    }
    .structured-result-content {
      display: none;
      margin-top: 0.25rem;
      padding: 0.625rem;
      background: #1e293b;
      border-radius: 8px;
      overflow-x: auto;
      font-size: 0.7rem;
      font-family: 'SF Mono', 'Fira Code', monospace;
      color: #e2e8f0;
      line-height: 1.5;
    }
    .structured-result.open .structured-result-content { display: block; }
    .sr-key { color: #94a3b8; }
    .sr-string { color: #34d399; }
    .sr-number { color: #f59e0b; }
    .sr-bool-true { color: #34d399; }
    .sr-bool-false { color: #f87171; }
    .sr-badge {
      display: inline-block;
      padding: 0.125rem 0.375rem;
      border-radius: 3px;
      font-size: 0.625rem;
      font-weight: 600;
      margin-right: 0.25rem;
    }
    .sr-badge.sources { background: #1e3a5f; color: #7dd3fc; }
    .sr-badge.grounded { background: #14532d; color: #86efac; }
    .sr-badge.domain { background: #14532d; color: #86efac; }
    .sr-badge.escalation { background: #7f1d1d; color: #fca5a5; }
    .sr-badge.valid { background: #14532d; color: #86efac; }
    .sr-badge.confidence-high { background: #14532d; color: #86efac; }
    .sr-badge.confidence-med { background: #78350f; color: #fde68a; }
    .sr-badge.confidence-low { background: #7f1d1d; color: #fca5a5; }
    .confidence-pill {
      display: inline-flex;
      align-items: center;
      gap: 0.25rem;
      padding: 0.125rem 0.5rem;
      border-radius: 10px;
      font-size: 0.6875rem;
      font-weight: 600;
      margin-left: 0.375rem;
    }
    .confidence-pill.high { background: #dcfce7; color: #166534; }
    .confidence-pill.med { background: #fef3c7; color: #92400e; }
    .confidence-pill.low { background: #fee2e2; color: #991b1b; }
    .sr-badges {
      display: flex;
      gap: 0.25rem;
      flex-wrap: wrap;
      margin-bottom: 0.5rem;
    }

    /* Structured Result Card */
    .sr-card {
      margin-top: 0.75rem;
      padding: 0.75rem;
      background: #f8fafc;
      border: 1px solid #e2e8f0;
      border-radius: 10px;
      font-size: 0.8125rem;
    }
    .sr-confidence-row {
      display: flex;
      align-items: center;
      gap: 0.5rem;
      margin-bottom: 0.625rem;
    }
    .sr-confidence-label {
      font-size: 0.75rem;
      font-weight: 600;
      color: #64748b;
      width: 72px;
      flex-shrink: 0;
    }
    .sr-confidence-bar {
      flex: 1;
      height: 24px;
      background: #e2e8f0;
      border-radius: 6px;
      overflow: hidden;
      position: relative;
    }
    .sr-confidence-fill {
      height: 100%;
      border-radius: 6px;
      transition: width 0.4s ease;
      display: flex;
      align-items: center;
      justify-content: flex-end;
      padding-right: 8px;
      min-width: 60px;
    }
    .sr-confidence-fill .sr-conf-inner {
      font-size: 0.75rem;
      font-weight: 700;
      color: #fff;
      white-space: nowrap;
      text-shadow: 0 1px 2px rgba(0,0,0,0.2);
    }
    .sr-conf-high { background: #16a34a; color: #16a34a; }
    .sr-conf-med { background: #f59e0b; color: #f59e0b; }
    .sr-conf-low { background: #ef4444; color: #ef4444; }
    .sr-checks-grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 0.375rem;
      margin-bottom: 0.625rem;
    }
    .sr-check {
      font-size: 0.75rem;
      color: #475569;
      padding: 0.25rem 0;
    }
    .sr-sources {
      display: flex;
      flex-wrap: wrap;
      gap: 0.375rem;
      margin-bottom: 0.625rem;
    }
    .sr-source-pill {
      display: inline-block;
      padding: 0.2rem 0.5rem;
      background: #dbeafe;
      color: #1e40af;
      border-radius: 12px;
      font-size: 0.6875rem;
      font-weight: 500;
    }
    .sr-escalation {
      background: #fee2e2;
      border: 1px solid #fecaca;
      border-radius: 8px;
      padding: 0.5rem 0.75rem;
      font-size: 0.8125rem;
      color: #991b1b;
      margin-bottom: 0.625rem;
    }
    .sr-raw-toggle {
      cursor: pointer;
      font-size: 0.75rem;
      color: #94a3b8;
      padding-top: 0.375rem;
      border-top: 1px solid #e2e8f0;
    }
    .sr-raw-toggle:hover { color: #64748b; }
    .sr-raw-content {
      display: none;
      margin-top: 0.375rem;
      padding: 0.5rem;
      background: #1e293b;
      border-radius: 6px;
      color: #e2e8f0;
      font-family: 'SF Mono', 'Fira Code', monospace;
      font-size: 0.6875rem;
      white-space: pre-wrap;
      overflow-x: auto;
      max-height: 200px;
      overflow-y: auto;
    }
    .sr-raw-toggle.open .sr-raw-content { display: block; }

    /* Copy button */
    .copy-btn {
      background: none;
      border: 1px solid transparent;
      cursor: pointer;
      font-size: 0.75rem;
      padding: 0.125rem 0.5rem;
      border-radius: 4px;
      color: #94a3b8;
      transition: all 0.15s;
      font-family: inherit;
    }
    .copy-btn:hover { color: #475569; border-color: #e2e8f0; }
    .copy-btn.copied { color: #16a34a; }

    /* Feedback toast */
    .feedback-toast {
      position: fixed;
      bottom: 2rem;
      left: 50%;
      transform: translateX(-50%) translateY(20px);
      background: #1e293b;
      color: white;
      padding: 0.625rem 1.25rem;
      border-radius: 8px;
      font-size: 0.875rem;
      font-family: inherit;
      opacity: 0;
      transition: opacity 0.3s, transform 0.3s;
      z-index: 1000;
      pointer-events: none;
    }
    .feedback-toast.show {
      opacity: 1;
      transform: translateX(-50%) translateY(0);
    }

    /* Medium screens — narrower sidebar */
    @media (max-width: 1200px) {
      .obs-sidebar.open { width: 260px; min-width: 260px; }
      header { flex-wrap: wrap; gap: 0.5rem; }
      .patient-selector { flex-wrap: wrap; }
    }

    /* Mobile responsiveness */
    @media (max-width: 768px) {
      header { flex-wrap: wrap; gap: 0.5rem; padding: 0.625rem 0.75rem; }
      .header-left { width: 100%; }
      .patient-selector { width: 100%; flex-wrap: wrap; }
      .patient-selector select { flex: 1; min-width: 0; }
      .new-chat-btn { flex-shrink: 0; }
      #quick-prompts { padding: 0.5rem 0.75rem; gap: 0.375rem; }
      .quick-btn { font-size: 0.75rem; padding: 0.25rem 0.625rem; }
      #chat-container { padding: 0.75rem; }
      .message-bubble { max-width: 90%; }
      .sr-checks-grid { grid-template-columns: 1fr; }
      .history-sidebar.open { width: 100%; min-width: 100%; position: fixed; z-index: 300; top: 0; left: 0; height: 100vh; }
      .obs-sidebar.open { width: 100%; min-width: 100%; position: fixed; z-index: 300; top: 0; right: 0; height: 100vh; }
      #input-area { padding: 0.75rem; }
      .clinician-banner { font-size: 0.625rem; padding: 0.25rem 0.5rem; }
      footer { font-size: 0.625rem; }
    }

    .doc-actions {
      display: flex;
      gap: 0.5rem;
      margin-top: 0.625rem;
      flex-wrap: wrap;
      align-items: center;
    }
    .finalize-btn, .edit-btn, .save-edit-btn, .cancel-edit-btn {
      display: inline-flex;
      align-items: center;
      gap: 0.375rem;
      padding: 0.5rem 1rem;
      color: white;
      border: none;
      border-radius: 8px;
      font-size: 0.875rem;
      font-weight: 600;
      font-family: inherit;
      cursor: pointer;
      transition: background 0.15s;
    }
    .finalize-btn { background: #16a34a; }
    .finalize-btn:hover { background: #15803d; }
    .finalize-btn:disabled { opacity: 0.5; cursor: not-allowed; }
    .finalize-btn.finalized {
      background: #e2e8f0;
      color: #64748b;
      cursor: default;
    }
    .edit-btn { background: #2563eb; }
    .edit-btn:hover { background: #1d4ed8; }
    .edit-btn:disabled { opacity: 0.5; cursor: not-allowed; }
    .save-edit-btn { background: #16a34a; }
    .save-edit-btn:hover { background: #15803d; }
    .cancel-edit-btn { background: #64748b; }
    .cancel-edit-btn:hover { background: #475569; }
    .draft-editor {
      width: 100%;
      min-height: 200px;
      margin-top: 0.625rem;
      padding: 0.75rem;
      border: 2px solid #2563eb;
      border-radius: 8px;
      font-family: inherit;
      font-size: 0.875rem;
      line-height: 1.6;
      resize: vertical;
      background: #fefce8;
    }
    .draft-editor:focus {
      outline: none;
      border-color: #1d4ed8;
      box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
    }
