:root {
  --primary: #00897B;
  --primary-hover: #00695C;
  --primary-light: #E8F1F2;
  --secondary: #26A69A;
  --bg-page: #F8FAFC;
  --bg-surface: #FFFFFF;
  --bg-subtle: #F1F5F9;
  --border: #E2E8F0;
  --border-focus: #26A69A;
  --text-main: #0F172A;
  --text-muted: #64748B;
  --text-light: #94A3B8;
  
  --success-bg: #ECFDF5;
  --success-border: #A7F3D0;
  --success-text: #065F46;
  --success-solid: #10B981;

  --warning-bg: #FFFBEB;
  --warning-border: #FDE68A;
  --warning-text: #92400E;
  --warning-solid: #F59E0B;

  --danger-bg: #FEF2F2;
  --danger-border: #FECACA;
  --danger-text: #991B1B;
  --danger-solid: #EF4444;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.07), 0 2px 4px -2px rgb(0 0 0 / 0.05);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.04);
}

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

html {
  overflow-x: hidden;
  width: 100%;
}

body {
  font-family: 'Inter', 'Cairo', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  width: 100%;
  max-width: 100vw;
}

/* Header */
.app-header {
  background: linear-gradient(135deg, #0F172A 0%, #0B2E2B 100%);
  color: #ffffff;
  padding: 0.9rem 1.5rem;
  box-shadow: var(--shadow-md);
  border-bottom: 2px solid #00897B;
  width: 100%;
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  width: 100%;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  text-decoration: none;
  color: inherit;
}

.brand-logo {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  object-fit: cover;
  box-shadow: 0 2px 10px rgba(0, 137, 123, 0.4);
  border: 1.5px solid rgba(38, 166, 154, 0.6);
  background: #ffffff;
  flex-shrink: 0;
}

.brand-icon {
  font-size: 1.75rem;
  font-weight: 700;
  background: linear-gradient(135deg, #00897B, #26A69A);
  color: #fff;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
}

.brand-text h1 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: 'Cairo', 'Inter', sans-serif;
}

.badge {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.55rem;
  border-radius: 9999px;
  text-transform: uppercase;
}

.phase-badge {
  background: rgba(38, 166, 154, 0.22);
  color: #5EEAD4;
  border: 1px solid rgba(94, 234, 212, 0.35);
}

.safety-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.825rem;
  color: #CBD5E1;
  background: rgba(0, 137, 123, 0.15);
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(38, 166, 154, 0.35);
}

.safety-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #26A69A;
  box-shadow: 0 0 8px #26A69A;
}

/* Layout */
.main-layout {
  max-width: 1200px;
  margin: 1.5rem auto;
  padding: 0 1.25rem;
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 1.5rem;
  flex: 1;
  width: 100%;
  box-sizing: border-box;
}

.results-panel {
  min-width: 0;
  max-width: 100%;
  width: 100%;
  overflow-x: hidden;
}

@media (max-width: 920px) {
  .main-layout {
    grid-template-columns: 1fr;
    padding: 0 1rem;
    gap: 1.25rem;
  }
}

/* Cards */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.25rem;
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-main);
}

/* Upload Dropzone */
.dropzone {
  border: 2px dashed #cbd5e1;
  border-radius: var(--radius-md);
  padding: 2rem 1rem;
  text-align: center;
  cursor: pointer;
  background: var(--bg-subtle);
  transition: all 0.2s ease;
  position: relative;
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.file-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.upload-icon {
  width: 40px;
  height: 40px;
  color: var(--primary);
  margin: 0 auto 0.75rem;
  display: block;
}

.dropzone-text {
  font-size: 0.95rem;
  color: var(--text-main);
}

.dropzone-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.sample-action-row {
  margin-top: 0.75rem;
  text-align: center;
}

/* Preview Box */
.preview-wrapper {
  margin-top: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.preview-header {
  background: var(--bg-subtle);
  padding: 0.5rem 0.75rem;
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.preview-box {
  background: #000;
  max-height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.preview-box img {
  max-width: 100%;
  max-height: 280px;
  object-fit: contain;
  display: block;
}

/* Forms */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.825rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.form-control {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: inherit;
  background: #fff;
  transition: border-color 0.15s;
}

.form-control:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.status-hint {
  font-size: 0.75rem;
  margin-top: 0.3rem;
  color: var(--text-muted);
}

.status-hint.configured {
  color: var(--success-text);
  font-weight: 500;
}

.status-hint.unconfigured {
  color: var(--danger-text);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.7rem 1.25rem;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
}

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

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

.btn-secondary:hover {
  background: #e2e8f0;
}

.btn-block {
  width: 100%;
}

.btn-sm {
  font-size: 0.8rem;
  padding: 0.4rem 0.8rem;
}

.btn-xs {
  font-size: 0.75rem;
  padding: 0.25rem 0.6rem;
}

/* Safety Card */
.safety-card {
  background: #f8fafc;
  border-left: 4px solid var(--warning-solid);
}

.safety-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: #b45309;
  margin-bottom: 0.5rem;
}

.safety-list {
  padding-left: 1.2rem;
  font-size: 0.775rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* Alerts */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-top: 1rem;
}

.alert-error {
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: var(--danger-text);
}

/* Empty / Loading States */
.empty-state, .loading-state {
  text-align: center;
  padding: 4rem 2rem;
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.empty-state h3, .loading-state h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.empty-state p, .loading-state p {
  color: var(--text-muted);
  max-width: 500px;
  margin: 0 auto;
  font-size: 0.9rem;
}

.sample-hint {
  margin-top: 1.5rem;
  font-size: 0.8rem;
  color: var(--primary);
  font-weight: 500;
}

.spinner-large {
  width: 50px;
  height: 50px;
  border: 4px solid #e2e8f0;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1.5rem;
}

.btn-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.timer-badge {
  display: inline-block;
  margin-top: 1.5rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  background: var(--bg-subtle);
  padding: 0.35rem 0.85rem;
  border-radius: 9999px;
  border: 1px solid var(--border);
}

/* Stats Ribbon */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

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

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.9rem;
  box-shadow: var(--shadow-sm);
}

.stat-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.03em;
}

.stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  margin: 0.25rem 0;
  color: var(--text-main);
  font-feature-settings: "tnum";
}

.stat-sub {
  font-size: 0.725rem;
  color: var(--text-muted);
}

.confidence-bar-bg {
  height: 6px;
  background: var(--bg-subtle);
  border-radius: 9999px;
  overflow: hidden;
  margin-top: 0.4rem;
}

.confidence-bar-fill {
  height: 100%;
  background: var(--success-solid);
  border-radius: 9999px;
  transition: width 0.5s ease;
}

/* Uncertain Items Banner */
.alert-card-uncertain {
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
}

.uncertain-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.uncertain-header h4 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--warning-text);
}

.uncertain-desc {
  font-size: 0.825rem;
  color: var(--warning-text);
  margin-bottom: 0.5rem;
}

.uncertain-items-list {
  padding-left: 1.4rem;
  font-size: 0.825rem;
  color: var(--warning-text);
}

.uncertain-items-list li {
  margin-bottom: 0.25rem;
}

/* Patient Card */
.section-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.patient-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.patient-cell {
  background: var(--bg-subtle);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.patient-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
}

.patient-val {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
  margin-top: 0.15rem;
  display: block;
}

/* Medications List */
.medications-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.med-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.15rem;
  background: #ffffff;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
  min-width: 0;
  max-width: 100%;
  width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.med-card.status-identified {
  border-left: 4px solid var(--success-solid);
}

.med-card.status-uncertain {
  border-left: 4px solid var(--warning-solid);
  background: #fffdfa;
}

.med-card.status-unreadable {
  border-left: 4px solid var(--danger-solid);
  background: #fffbfb;
}

.med-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  width: 100%;
}

.med-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  max-width: 100%;
}

.med-num {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--bg-subtle);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.med-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  overflow-wrap: break-word;
  word-break: break-word;
}

.med-name.unreadable {
  color: var(--text-muted);
  font-style: italic;
}

.active-ingredient-badge {
  font-size: 0.75rem;
  background: #e0e7ff;
  color: #3730a3;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  font-weight: 500;
  white-space: nowrap;
}

.med-badges {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.status-pill {
  font-size: 0.725rem;
  font-weight: 600;
  text-transform: uppercase;
  padding: 0.2rem 0.5rem;
  border-radius: 9999px;
}

.status-pill.identified {
  background: var(--success-bg);
  color: var(--success-text);
  border: 1px solid var(--success-border);
}

.status-pill.uncertain {
  background: var(--warning-bg);
  color: var(--warning-text);
  border: 1px solid var(--warning-border);
}

.status-pill.unreadable {
  background: var(--danger-bg);
  color: var(--danger-text);
  border: 1px solid var(--danger-border);
}

.confidence-pill {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  padding: 0.2rem 0.45rem;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

/* Raw Transcription Box */
.raw-transcription-box {
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.85rem;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.825rem;
  overflow-wrap: break-word;
  word-break: break-word;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

.raw-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-family: 'Inter', sans-serif;
  flex-shrink: 0;
}

.raw-text-value {
  color: #334155;
  font-weight: 500;
  overflow-wrap: break-word;
  word-break: break-word;
}

/* Medication Details - Strictly stacked vertically (تحت بعض) */
.med-details-grid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
  margin-top: 0.5rem;
  box-sizing: border-box;
}

.detail-cell {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.85rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  width: 100%;
  box-sizing: border-box;
  transition: background 0.15s ease;
}

.detail-cell:hover {
  background: #eef2f6;
}

.detail-lbl {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.detail-val {
  font-size: 0.925rem;
  font-weight: 600;
  color: var(--text-main);
  font-family: 'Cairo', 'Inter', sans-serif;
  overflow-wrap: break-word;
  word-break: break-word;
  text-align: right;
}

.detail-val.is-null {
  color: var(--text-light);
  font-style: italic;
  font-weight: 400;
}

@media (max-width: 540px) {
  .detail-cell {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }
  .detail-val {
    text-align: left;
  }
}

.detail-cell.instructions-cell {
  flex-direction: column;
  align-items: stretch;
  background: #f8fafc;
  border-left: 4px solid var(--primary);
  padding: 0.75rem 1rem;
}

.detail-cell.instructions-cell:hover {
  background: #f1f5f9;
}

.instructions-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
  width: 100%;
}

.instructions-text {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.5;
  text-align: left;
}

/* JSON Viewer */
.json-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  width: 100%;
}

.json-viewer {
  background: #0f172a;
  color: #f8fafc;
  padding: 1rem;
  border-radius: var(--radius-sm);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.775rem;
  max-height: 380px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  line-height: 1.45;
}

/* Footer */
.app-footer {
  background: #f1f5f9;
  border-top: 1px solid var(--border);
  padding: 1.5rem 2rem;
  margin-top: auto;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.footer-container {
  max-width: 1200px;
  margin: 0 auto;
  text-align: center;
  padding: 0 1rem;
}

.disclaimer {
  font-size: 0.725rem;
  color: var(--text-light);
  margin-top: 0.25rem;
}

.hidden {
  display: none !important;
}

/* ==========================================================================
   Navigation Tabs
   ========================================================================== */
.nav-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  background: rgba(255, 255, 255, 0.08);
  padding: 0.25rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.12);
  max-width: 100%;
}

.tab-btn {
  background: transparent;
  border: none;
  color: #cbd5e1;
  font-family: inherit;
  font-size: 0.825rem;
  font-weight: 600;
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.tab-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}

.tab-btn.active {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* ==========================================================================
   Benchmark View (Phase 2)
   ========================================================================== */
.benchmark-layout {
  max-width: 1200px;
  margin: 1.5rem auto;
  padding: 0 1rem;
  flex: 1;
  width: 100%;
  box-sizing: border-box;
}

.benchmark-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.benchmark-header-card {
  padding: 1.5rem;
}

.bench-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.bench-title-row h2 {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.benchmark-model-selector {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

.selector-lbl {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  display: block;
  margin-bottom: 0.5rem;
}

.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.85rem;
  background: var(--bg-subtle);
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: pointer;
}

.checkbox-label input {
  cursor: pointer;
}

/* Benchmark Comparison Table */
.table-responsive {
  overflow-x: auto;
}

.benchmark-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  text-align: left;
}

.benchmark-table th {
  background: var(--bg-subtle);
  padding: 0.75rem 1rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
}

.benchmark-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  font-feature-settings: "tnum";
}

.benchmark-table tr:hover td {
  background: #f8fafc;
}

.critical-safe {
  background: var(--success-bg);
  color: var(--success-text);
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 9999px;
  display: inline-block;
  border: 1px solid var(--success-border);
}

.critical-danger {
  background: var(--danger-bg);
  color: var(--danger-text);
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 9999px;
  display: inline-block;
  border: 1px solid var(--danger-border);
  animation: pulse 1.5s infinite;
}

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

/* Benchmark Cases Grid */
.cases-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

.case-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #ffffff;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
}

.case-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.case-img-box {
  height: 180px;
  background: #0f172a;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.case-img-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s;
}

.case-card:hover .case-img-box img {
  transform: scale(1.05);
}

.case-content {
  padding: 1rem;
}

.case-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.case-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-light);
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-sm);
}

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

.case-pt-info {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.case-meds-summary {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==========================================================================
   Phase 4 & 5: EDA and LASA Safety Additions
   ========================================================================== */
.eda-badge {
  font-size: 0.725rem;
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.eda-badge::before {
  content: "🇪🇬";
  font-size: 0.8rem;
}

.lasa-warning-box {
  background: #fff1f2;
  border: 1px solid #fecdd3;
  border-left: 4px solid #e11d48;
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.75rem;
  font-size: 0.825rem;
  color: #9f1239;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  line-height: 1.4;
  overflow-wrap: break-word;
  word-break: break-word;
}

.lasa-warning-box strong {
  color: #881337;
}

.candidates-container {
  margin-top: 0.75rem;
  border-top: 1px dashed var(--border);
  padding-top: 0.5rem;
}

.candidates-toggle {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  user-select: none;
}

.candidates-toggle:hover {
  text-decoration: underline;
}

.candidates-list {
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.candidate-item {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
}

.candidate-item:hover {
  background: #f0fdf4;
  border-color: #10b981;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.18);
  transform: translateY(-1px);
}

.candidate-item:focus {
  outline: 2px solid #10b981;
  outline-offset: 1px;
}

.candidate-name-wrap {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.candidate-score {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  font-size: 0.725rem;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  background: #e2e8f0;
  color: #334155;
}

.candidate-score.high {
  background: #dcfce7;
  color: #166534;
}

.candidate-score.mid {
  background: #fef9c3;
  color: #854d0e;
}

/* ==========================================================================
   Bilingual Dataset & Training Studio Styles
   ========================================================================== */
.training-actions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-top: 0.75rem;
}

@media (max-width: 860px) {
  .training-actions-grid {
    grid-template-columns: 1fr;
  }
}

.training-action-box {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.training-action-box h4 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
  color: var(--text-main);
}

.training-action-box p {
  font-size: 0.825rem;
  color: var(--text-muted);
  margin-bottom: 0.85rem;
}

.split-filter-group {
  display: inline-flex;
  gap: 0.25rem;
  background: var(--bg-subtle);
  padding: 0.2rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.split-pill {
  border: none;
  background: transparent;
  padding: 0.25rem 0.65rem;
  font-size: 0.775rem;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.split-pill:hover {
  color: var(--text-main);
}

.split-pill.active {
  background: var(--primary);
  color: #ffffff;
}

.bilingual-med-tag {
  display: inline-block;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  font-size: 0.75rem;
  margin: 0.15rem 0.2rem 0.15rem 0;
}

.bilingual-med-tag strong {
  color: var(--text-main);
}

.bilingual-med-tag .ar-instr {
  color: #0369a1;
  direction: rtl;
  margin-left: 0.25rem;
}

.case-btn-row {
  margin-top: 0.75rem;
  display: flex;
  justify-content: flex-end;
}

/* ==========================================================================
   Clinical Indication, Physician Diagnosis & Drug Packaging Visual Styles
   ========================================================================== */

/* Overall Prescription Diagnosis Insight Card */
.overall-diagnosis-card {
  background: linear-gradient(135deg, rgba(0, 137, 123, 0.08), rgba(38, 166, 154, 0.04));
  border: 1px solid rgba(0, 137, 123, 0.28);
  border-radius: var(--radius-md);
  padding: 1.15rem 1.35rem;
  margin-bottom: 1.25rem;
  position: relative;
  overflow: hidden;
  box-shadow: 0 2px 8px -2px rgba(0, 137, 123, 0.12);
}

.overall-diagnosis-card::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 5px;
  height: 100%;
  background: linear-gradient(180deg, var(--primary), var(--secondary));
}

.overall-diag-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.85rem;
  flex-wrap: wrap;
}

.diag-header-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.diag-icon-large {
  font-size: 1.6rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  background: rgba(0, 137, 123, 0.12);
  border-radius: 10px;
}

.diag-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  font-family: 'Cairo', sans-serif;
  line-height: 1.3;
}

.diag-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: block;
}

.overall-diag-body {
  direction: rtl;
  text-align: right;
  font-family: 'Cairo', sans-serif;
}

.overall-diag-highlight {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(0, 137, 123, 0.2);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
}

.diag-bullet {
  font-size: 1.25rem;
  flex-shrink: 0;
  margin-top: 2px;
}

.diag-content strong {
  font-size: 0.85rem;
  color: var(--primary);
  display: block;
  margin-bottom: 0.25rem;
}

.diag-text {
  font-size: 1.05rem;
  font-weight: 600;
  color: #1e293b;
  line-height: 1.6;
}

/* Medication Header Thumbnail Preview */
.med-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
  flex: 1;
}

.med-thumb-preview {
  position: relative;
  width: 68px;
  height: 44px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #ffffff;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.med-thumb-preview:hover {
  transform: scale(1.06);
  border-color: var(--primary);
  box-shadow: 0 4px 10px rgba(0, 137, 123, 0.25);
}

.med-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.thumb-zoom-badge {
  position: absolute;
  bottom: 2px;
  right: 2px;
  background: rgba(15, 23, 42, 0.7);
  color: #ffffff;
  font-size: 0.65rem;
  padding: 1px 3px;
  border-radius: 3px;
  pointer-events: none;
}

.med-name-block {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.med-name-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.med-name-row .med-name {
  cursor: pointer;
  transition: color 0.15s ease;
}

.med-name-row .med-name:hover {
  color: var(--primary);
  text-decoration: underline;
}

.med-ar-badge {
  font-family: 'Cairo', sans-serif;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  direction: rtl;
}

.med-tags-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

/* Concise Clinical Indication Box (تحت الدواء باختصار) */
.clinical-indication-summary-card {
  margin-top: 0.75rem;
  margin-bottom: 0.65rem;
  background: linear-gradient(135deg, rgba(0, 137, 123, 0.08), rgba(38, 166, 154, 0.03));
  border: 1px solid rgba(0, 137, 123, 0.24);
  border-right: 4px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  direction: rtl;
  text-align: right;
  font-family: 'Cairo', sans-serif;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.clinical-indication-summary-card:hover {
  background: linear-gradient(135deg, rgba(0, 137, 123, 0.13), rgba(38, 166, 154, 0.06));
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(0, 137, 123, 0.14);
}

.indication-summary-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.4rem;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.indication-tag-badge {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--primary-hover);
  font-size: 0.85rem;
}

.indication-pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--primary);
  display: inline-block;
  box-shadow: 0 0 0 2px rgba(0, 137, 123, 0.2);
}

.click-details-tag {
  font-size: 0.75rem;
  color: var(--primary);
  font-weight: 600;
  background: rgba(255, 255, 255, 0.85);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  border: 1px solid rgba(0, 137, 123, 0.25);
}

.indication-summary-text {
  font-size: 0.95rem;
  font-weight: 600;
  color: #0F172A;
  line-height: 1.6;
  margin-bottom: 0.4rem;
}

.likely-diagnosis-callout {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #065f46;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.3rem 0.65rem;
  border-radius: 6px;
  margin-top: 0.25rem;
}

.diag-icon-small {
  font-size: 0.95rem;
}

/* Card Action Button */
.med-card-action-row {
  margin-top: 0.75rem;
  display: flex;
  justify-content: flex-end;
}

.view-drug-details-btn {
  font-family: 'Cairo', sans-serif;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.95rem;
  border-radius: 6px;
  border: 1px solid var(--primary);
  background: var(--primary-light);
  color: var(--primary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.view-drug-details-btn:hover {
  background: var(--primary);
  color: #ffffff;
  transform: translateY(-1px);
  box-shadow: 0 3px 6px rgba(0, 137, 123, 0.25);
}

/* ==========================================================================
   Medication Detail & Clinical Diagnosis Modal
   ========================================================================== */
.medication-modal-card {
  max-width: 860px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.med-modal-hero-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
  align-items: stretch;
}

@media (max-width: 768px) {
  .med-modal-hero-grid {
    grid-template-columns: 1fr;
  }
}

.med-modal-image-box {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
}

.med-image-frame {
  width: 100%;
  height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 8px;
  background: #f8fafc;
  position: relative;
}

.med-modal-main-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
  transition: opacity 0.25s ease-in-out;
}

.med-modal-main-img.hidden,
.med-modal-main-img:not([src]),
.med-modal-main-img[src=""] {
  opacity: 0;
  display: none;
}

/* Shimmer Loading Skeleton */
@keyframes shimmerWave {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

.shimmer-active {
  background: linear-gradient(90deg, #f8fafc 25%, #e2e8f0 37%, #f8fafc 50%, #e2e8f0 63%, #f8fafc 75%) !important;
  background-size: 200% 100% !important;
  animation: shimmerWave 1.4s ease-in-out infinite !important;
  color: transparent !important;
  border-color: #cbd5e1 !important;
  border-radius: 6px;
  user-select: none;
  pointer-events: none;
  min-height: 1.25rem;
}

.shimmer-active * {
  visibility: hidden !important;
}

.shimmer-image-placeholder {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, #f8fafc 25%, #e2e8f0 37%, #f8fafc 50%, #e2e8f0 63%, #f8fafc 75%);
  background-size: 200% 100%;
  animation: shimmerWave 1.4s ease-in-out infinite;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  z-index: 5;
  border-radius: 8px;
  color: #64748b;
  font-family: 'Cairo', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  transition: opacity 0.2s ease-out;
}

.shimmer-spinner-icon {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(2, 132, 199, 0.2);
  border-top-color: #0284c7;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.med-image-caption {
  font-size: 0.725rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 0.5rem;
  font-family: 'Cairo', sans-serif;
}

.med-modal-quick-info {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  justify-content: center;
}

.quick-info-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.quick-info-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  font-family: 'Cairo', 'Inter', sans-serif;
}

.quick-info-val {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}

.active-highlight {
  color: var(--primary);
  font-family: 'Inter', sans-serif;
}

.price-highlight {
  color: #059669;
  font-family: 'Cairo', 'Inter', sans-serif;
}

/* Deep Dive Clinical Section */
.clinical-deep-dive-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.15rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.deep-dive-header h4 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: 'Cairo', sans-serif;
  margin-bottom: 0.85rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.deep-dive-header .en-sub {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-muted);
  margin-left: auto;
  font-family: 'Inter', sans-serif;
}

.deep-dive-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
  direction: rtl;
  text-align: right;
  font-family: 'Cairo', sans-serif;
}

@media (max-width: 640px) {
  .deep-dive-grid {
    grid-template-columns: 1fr;
  }
}

.deep-dive-box {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.deep-dive-box-title {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.875rem;
  color: #334155;
}

.indication-highlight-box {
  background: linear-gradient(135deg, rgba(0, 137, 123, 0.08), rgba(0, 137, 123, 0.02));
  border-color: rgba(0, 137, 123, 0.3);
  border-right: 4px solid var(--primary);
}

.indication-highlight-box .deep-dive-box-title {
  color: var(--primary-hover);
}

.diagnosis-highlight-box {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.08), rgba(16, 185, 129, 0.02));
  border-color: rgba(16, 185, 129, 0.3);
  border-right: 4px solid #10b981;
}

.diagnosis-highlight-box .deep-dive-box-title {
  color: #047857;
}

.precautions-box {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.08), rgba(245, 158, 11, 0.02));
  border-color: rgba(245, 158, 11, 0.3);
  border-right: 4px solid #f59e0b;
}

.precautions-box .deep-dive-box-title {
  color: #b45309;
}

.deep-dive-text {
  font-size: 0.925rem;
  font-weight: 600;
  color: #1e293b;
  line-height: 1.6;
}

/* Rx Instructions Card inside Modal */
.rx-instructions-card {
  padding: 1.15rem;
  margin-bottom: 0.5rem;
  direction: rtl;
  text-align: right;
  font-family: 'Cairo', sans-serif;
}

.rx-instructions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

@media (max-width: 640px) {
  .rx-instructions-grid {
    grid-template-columns: 1fr;
  }
}

.rx-spec-item {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.rx-spec-item.full-width {
  grid-column: 1 / -1;
}

.rx-spec-lbl {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
}

.rx-spec-val {
  font-size: 0.925rem;
  font-weight: 600;
  color: var(--text-main);
}

.rx-spec-val.highlight {
  color: var(--primary);
  font-weight: 700;
}

/* Gor3a Secured AI Engine Status Box */
.gor3a-engine-status {
  background: linear-gradient(135deg, #E8F1F2 0%, #F0FDF4 100%);
  border: 1px solid rgba(0, 137, 123, 0.35);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-md);
  padding: 0.9rem 1rem;
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.gor3a-engine-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.gor3a-engine-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: #0F172A;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.gor3a-engine-badge {
  font-size: 0.68rem;
  font-weight: 700;
  background: #00897B;
  color: #ffffff;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  letter-spacing: 0.03em;
}

.gor3a-engine-desc {
  font-size: 0.78rem;
  color: #334155;
  line-height: 1.45;
}
