/* ========================================================================
   DEOX Clinical AI — Dashboard CSS v2.0
   Premium clinical aesthetic · Veeva Vault / Medidata quality
   Brand: Navy #020617 · Orange #fe8c0d · Teal #00ADB5 · Blue #3b82f6
   ======================================================================== */

/* ── Design Tokens ── */
:root {
  /* Brand */
  --primary:       #fe8c0d;
  --primary-dark:  #ea580c;
  --primary-light: #fff7ed;
  --navy:          #020617;
  --navy-mid:      #0f172a;
  --navy-light:    #1e293b;
  --teal:          #00ADB5;
  --teal-light:    #e0f7fa;
  --blue:          #3b82f6;
  --blue-light:    #dbeafe;

  /* Surfaces */
  --bg:            #f8f9fb;
  --bg-elevated:   #ffffff;
  --card:          #ffffff;

  /* Text */
  --text:          #0f172a;
  --text-secondary:#64748b;
  --text-muted:    #94a3b8;

  /* Borders */
  --border:        #e2e8f0;
  --border-light:  #f1f5f9;

  /* Semantic */
  --success:       #059669;
  --success-light: #d1fae5;
  --warning:       #d97706;
  --warning-light: #fef3c7;
  --danger:        #dc2626;
  --danger-light:  #fee2e2;
  --info:          #2563eb;
  --info-light:    #dbeafe;
  --critical:      #991b1b;

  /* Shadows */
  --shadow-xs:     0 1px 2px rgba(2,6,23,0.04);
  --shadow-sm:     0 1px 3px rgba(2,6,23,0.06), 0 1px 2px rgba(2,6,23,0.04);
  --shadow-md:     0 4px 6px -1px rgba(2,6,23,0.06), 0 2px 4px -2px rgba(2,6,23,0.04);
  --shadow-lg:     0 10px 15px -3px rgba(2,6,23,0.08), 0 4px 6px -4px rgba(2,6,23,0.04);
  --shadow-xl:     0 20px 25px -5px rgba(2,6,23,0.08), 0 8px 10px -6px rgba(2,6,23,0.04);

  /* Radii */
  --radius-sm:     6px;
  --radius:        8px;
  --radius-lg:     12px;
  --radius-xl:     16px;

  /* Transitions */
  --transition:    150ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Typography */
  --font-sans:     'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ── Reset ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Header ── */
.header {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-mid) 60%, var(--navy-light) 100%);
  color: #ffffff;
  padding: 12px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2), 0 4px 12px rgba(2,6,23,0.15);
  border-bottom: 1px solid rgba(254,140,13,0.15);
}
.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}
.logo {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: #ffffff;
}
.logo span {
  color: var(--primary);
  font-weight: 500;
}
.demo-badge {
  background: rgba(254,140,13,0.15);
  color: #fdba74;
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.3px;
  border: 1px solid rgba(254,140,13,0.3);
  text-transform: uppercase;
}
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}
.study-info { text-align: right; }
.study-name { font-weight: 600; font-size: 13px; }
.study-detail { font-size: 11px; opacity: 0.7; margin-top: 1px; }

/* ── Navigation Tabs (Grouped Rows) ── */
.nav {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 10px 28px 8px;
  position: sticky;
  top: 52px;
  z-index: 99;
  box-shadow: var(--shadow-xs);
}
.nav-group {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 4px;
}
.nav-group:last-child {
  margin-bottom: 0;
}
.nav-group-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  padding-right: 12px;
  white-space: nowrap;
  min-width: 130px;
  border-right: 1px solid var(--border);
  margin-right: 10px;
  text-align: right;
}
.nav-group-tabs {
  display: flex;
  gap: 0;
  flex-wrap: wrap;
}

.nav-tab {
  padding: 6px 12px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 6px 6px 0 0;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  user-select: none;
  line-height: 1.4;
}
.nav-tab:hover {
  color: var(--primary-dark);
  background: var(--primary-light);
}
.nav-tab.active {
  color: var(--primary-dark);
  border-bottom-color: var(--primary);
  font-weight: 600;
  background: rgba(254,140,13,0.06);
}
.nav-tab .count {
  background: var(--primary-light);
  color: var(--primary-dark);
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
}
.nav-tab .count.warn {
  background: var(--warning-light);
  color: var(--warning);
}
.nav-tab .count.bad, .nav-tab .count.danger {
  background: var(--danger-light);
  color: var(--danger);
}

/* ── Main Content ── */
.main {
  padding: 24px;
  max-width: 1480px;
  margin: 0 auto;
}
.tab-content { display: none; animation: fadeIn 0.2s ease; }
.tab-content.active { display: block; }

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

/* ── Cards ── */
.card {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
  overflow: hidden;
  border: 1px solid var(--border-light);
  transition: box-shadow var(--transition);
}
.card:hover {
  box-shadow: var(--shadow-md);
}
.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(180deg, #fafbfc 0%, var(--card) 100%);
}
.card-header h3 {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.1px;
}
.card-body {
  padding: 20px;
}
.card-footer {
  padding: 10px 20px;
  background: #f8fafc;
  border-top: 1px solid var(--border-light);
  font-size: 11px;
  color: var(--text-muted);
}

/* ── Stats Grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px 16px 14px;
  box-shadow: var(--shadow-xs);
  border-left: 4px solid var(--blue);
  border-top: 1px solid var(--border-light);
  border-right: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-light);
  transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.stat-card.success { border-left-color: var(--success); }
.stat-card.warning { border-left-color: var(--warning); }
.stat-card.danger  { border-left-color: var(--danger); }
.stat-card.teal    { border-left-color: var(--teal); }
.stat-card.orange  { border-left-color: var(--primary); }
.stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
  line-height: 1.2;
}
.stat-label {
  font-size: 10.5px;
  color: var(--text-muted);
  margin-top: 3px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}
.stat-change {
  font-size: 10.5px;
  margin-top: 3px;
  font-weight: 500;
}
.stat-change.up   { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12.5px;
}
th {
  background: #f8fafc;
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
}
td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text);
  vertical-align: top;
}
tbody tr {
  cursor: pointer;
  transition: background var(--transition);
}
tbody tr:hover td {
  background: rgba(254,140,13,0.04);
}
tbody tr:last-child td {
  border-bottom: none;
}

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 10.5px;
  font-weight: 600;
  gap: 4px;
  letter-spacing: 0.1px;
}
.badge-active    { background: var(--success-light); color: var(--success); }
.badge-warning   { background: var(--warning-light); color: var(--warning); }
.badge-danger    { background: var(--danger-light);  color: var(--danger); }
.badge-info      { background: var(--info-light);    color: var(--info); }
.badge-neutral   { background: #f1f5f9;              color: var(--text-secondary); }
.badge-critical  { background: #fef2f2;              color: var(--critical); }

/* ── Progress Bars ── */
.progress-bar {
  height: 20px;
  background: #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
  font-size: 10px;
  font-weight: 700;
  color: white;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}
.progress-fill.green  { background: linear-gradient(90deg, #10b981, #059669); }
.progress-fill.yellow { background: linear-gradient(90deg, #f59e0b, #d97706); }
.progress-fill.red    { background: linear-gradient(90deg, #ef4444, #dc2626); }
.progress-fill.teal   { background: linear-gradient(90deg, #14b8a6, #0d9488); }

/* ── Layout Grids ── */
.two-col   { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.three-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
@media (max-width: 960px) {
  .two-col, .three-col { grid-template-columns: 1fr; }
}

/* ── Filter Bar ── */
.filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}
.filter-bar input,
.filter-bar select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: var(--font-sans);
  background: var(--card);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.filter-bar input:focus,
.filter-bar select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(254,140,13,0.15);
}
.filter-bar input { flex: 1; min-width: 180px; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font-sans);
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  line-height: 1.4;
}
.btn-primary {
  background: var(--primary);
  color: var(--navy);
  font-weight: 600;
}
.btn-primary:hover {
  background: var(--primary-dark);
  color: #ffffff;
  box-shadow: var(--shadow-sm);
}
.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-outline:hover {
  background: var(--border-light);
  border-color: var(--text-secondary);
}
.btn-sm { padding: 4px 10px; font-size: 11px; }

/* ── Timeline ── */
.timeline { position: relative; padding-left: 26px; }
.timeline::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
  border-radius: 1px;
}
.timeline-item { position: relative; padding-bottom: 18px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-dot {
  position: absolute;
  left: -20px;
  top: 5px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--primary);
  background: white;
}
.timeline-dot.critical { border-color: var(--danger); background: var(--danger-light); }
.timeline-dot.warning  { border-color: var(--warning); }
.timeline-dot.success  { border-color: var(--success); background: var(--success-light); }
.timeline-time {
  font-size: 10.5px;
  color: var(--text-muted);
  font-weight: 500;
}
.timeline-text {
  font-size: 12.5px;
  margin-top: 2px;
  color: var(--text);
}
.timeline-detail {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ── Detail Rows ── */
.detail-row {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 4px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 12.5px;
}
.detail-row .label {
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 500;
}

/* ── Severity Indicators ── */
.severity { display: inline-flex; align-items: center; gap: 5px; }
.severity-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.severity-dot.critical { background: var(--danger); }
.severity-dot.high     { background: var(--warning); }
.severity-dot.medium   { background: var(--blue); }
.severity-dot.low      { background: var(--text-muted); }

/* ── Module Grid ── */
.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.module-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-xs);
  border-top: 3px solid var(--teal);
  border: 1px solid var(--border-light);
  border-top: 3px solid var(--teal);
  transition: transform var(--transition), box-shadow var(--transition);
}
.module-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.module-card h4 { font-size: 13px; margin-bottom: 6px; color: var(--text); }
.module-card p  { font-size: 11.5px; color: var(--text-secondary); margin-bottom: 10px; line-height: 1.5; }
.module-meta {
  display: flex;
  justify-content: space-between;
  font-size: 10.5px;
  color: var(--text-muted);
  padding-top: 8px;
  border-top: 1px solid var(--border-light);
}

/* ── Risk Matrix ── */
.risk-matrix {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 3px;
  max-width: 350px;
}
.risk-cell {
  padding: 10px 6px;
  text-align: center;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  color: white;
}
.risk-low      { background: #059669; }
.risk-medium   { background: #d97706; color: var(--navy); }
.risk-high     { background: #dc2626; }
.risk-critical { background: #991b1b; }

/* ── Gauges ── */
.gauge { text-align: center; padding: 12px; }
.gauge-ring {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 8px;
}
.gauge-ring.green  { background: conic-gradient(var(--success) 0%, var(--success) var(--pct), #e2e8f0 var(--pct), #e2e8f0 100%); }
.gauge-ring.yellow { background: conic-gradient(var(--warning) 0%, var(--warning) var(--pct), #e2e8f0 var(--pct), #e2e8f0 100%); }
.gauge-ring.red    { background: conic-gradient(var(--danger) 0%, var(--danger) var(--pct), #e2e8f0 var(--pct), #e2e8f0 100%); }
.gauge-inner {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}
.gauge-label { font-size: 11px; color: var(--text-secondary); }

/* ── Modal ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(2,6,23,0.5);
  backdrop-filter: blur(4px);
  z-index: 200;
  align-items: flex-start;
  justify-content: center;
  padding: 60px 20px;
  overflow-y: auto;
}
.modal-overlay.hidden { display: none; }
.modal-overlay.show   { display: flex; }

.modal {
  background: var(--card);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 700px;
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--border);
  animation: modalIn 0.2s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(-12px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-header h3 { font-size: 15px; font-weight: 600; color: var(--text); }
.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: background var(--transition), color var(--transition);
}
.modal-close:hover { background: #f1f5f9; color: var(--text); }
.modal-body { padding: 24px; max-height: 70vh; overflow-y: auto; }
.modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border-light);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  background: #fafbfc;
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

/* ── Interactive ── */
.clickable { cursor: pointer; transition: transform var(--transition); }
.clickable:hover { transform: translateY(-1px); }

/* ── Selection ── */
::selection {
  background: rgba(254,140,13,0.25);
  color: var(--text);
}

/* ── Scrollbar (global) ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
::-webkit-scrollbar-track { background: transparent; }

/* ── Focus Styles ── */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .header { padding: 10px 16px; }
  .header-left { gap: 10px; }
  .logo { font-size: 16px; }
  .demo-badge { display: none; }
  .study-info { display: none; }
  .nav { padding: 8px 12px 6px; top: 46px; }
  .nav-group { flex-wrap: nowrap; }
  .nav-group-label { min-width: 0; font-size: 8px; padding-right: 6px; margin-right: 6px; display: none; }
  .nav-tab { padding: 5px 8px; font-size: 10.5px; }
  .main { padding: 14px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat-value { font-size: 22px; }
  .stat-card { padding: 14px 12px; }
  .card-body { padding: 14px; }
  .card-header { padding: 12px 14px; }
  .card-header h3 { font-size: 12.5px; }
  th, td { padding: 8px 10px; font-size: 11.5px; }
}

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

/* ── Utility Classes ── */
.text-success { color: var(--success) !important; }
.text-warning { color: var(--warning) !important; }
.text-danger  { color: var(--danger)  !important; }
.text-info    { color: var(--info)    !important; }
.text-muted   { color: var(--text-muted) !important; }
.text-teal    { color: var(--teal)    !important; }

.bg-success-light { background: var(--success-light) !important; }
.bg-warning-light { background: var(--warning-light) !important; }
.bg-danger-light  { background: var(--danger-light)  !important; }

.fw-600 { font-weight: 600; }
.fs-11  { font-size: 11px; }
.fs-12  { font-size: 12px; }
.fs-13  { font-size: 13px; }

/* ── Print ── */
@media print {
  .header, .nav, .modal-overlay { display: none !important; }
  .main { padding: 0; max-width: none; }
  .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
}
