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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f8f9fa;
  color: #1a1a1a;
  line-height: 1.5;
}

/* Header */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 48px;
  background: #3b82f6;
  z-index: 100;
}

.header-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 20px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-logo {
  color: #fff;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.15);
  padding: 6px 16px;
  border-radius: 999px;
  font-size: 0.78rem;
  color: #fff;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.15);
}

.header-status .status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255,255,255,0.4);
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

.header-status .status-dot.status-ok {
  background: #34d399;
  box-shadow: 0 0 8px rgba(52, 211, 153, 0.7);
}

.header-status .status-dot.status-error {
  background: #f87171;
  box-shadow: 0 0 8px rgba(248, 113, 113, 0.7);
}

.status-label {
  font-weight: 500;
}

.status-count {
  opacity: 0.7;
  font-weight: 400;
}

.container {
  max-width: 900px;
  margin: 72px auto 48px;
  padding: 0 20px;
}

.view { display: none; }
.view.active { display: block; }

h1 { font-size: 1.4rem; margin-bottom: 16px; color: #1a1a1a; }
h2 { font-size: 1.2rem; margin-bottom: 8px; color: #1a1a1a; }

code { font-family: 'SF Mono', 'Menlo', monospace; font-size: 0.85em; background: #f0f0f0; padding: 2px 5px; border-radius: 3px; }

/* Search */
.search-box input {
  width: 100%;
  padding: 10px 14px;
  font-size: 0.95rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  outline: none;
  background: #fff;
}

.search-box input:focus { border-color: #4a90d9; box-shadow: 0 0 0 2px rgba(74,144,217,0.15); }

.search-hint {
  margin-top: 10px;
  font-size: 0.85rem;
  color: #666;
  line-height: 1.6;
}

.status { margin-top: 10px; font-size: 0.85rem; color: #777; }

.results { list-style: none; margin-top: 12px; }

.results li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  margin-bottom: 4px;
  cursor: pointer;
  transition: background 0.1s;
}

.results li:hover { background: #f0f5ff; border-color: #4a90d9; }
.results .name { font-weight: 500; font-size: 0.95rem; }
.results .ehr-id { font-size: 0.78rem; color: #999; font-family: monospace; }

/* Detail */
.btn-back {
  background: none;
  border: 1px solid #ccc;
  padding: 6px 14px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.85rem;
  color: #555;
  margin-bottom: 20px;
}

.btn-back:hover { background: #eee; }

/* Cards */
.cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.card {
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  transition: box-shadow 0.2s ease;
}

.card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.card-demo {
  border-top: 3px solid #3b82f6;
}

.card-ehr {
  border-top: 3px solid #8b5cf6;
}

.card-header {
  padding: 12px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #444;
  background: #f9fafb;
  border-bottom: 1px solid #e5e5e5;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-icon {
  font-size: 1rem;
}

.card-body { padding: 16px; }

.card-name {
  font-size: 1.15rem;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid #f0f0f0;
}

.comp-count {
  display: inline-block;
  background: #8b5cf6;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 999px;
}

.card-table { width: 100%; border-collapse: collapse; }
.card-table th {
  text-align: left;
  padding: 5px 0;
  font-size: 0.82rem;
  font-weight: 500;
  color: #888;
  width: 120px;
}
.card-table td {
  padding: 5px 0;
  font-size: 0.9rem;
}
.uid { font-family: monospace; font-size: 0.78rem; color: #666; }

/* Timeline section */
.timeline-section { margin-top: 4px; }

.timeline-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  color: #333;
  text-align: left;
}

.timeline-toggle:hover { background: #f9fafb; }

.timeline-toggle-icon {
  font-size: 0.7rem;
  color: #999;
  transition: transform 0.15s;
}

/* Timeline */
.timeline {
  position: relative;
  padding: 8px 0 8px 16px;
  margin-top: 8px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #ddd;
}

.timeline-item {
  position: relative;
  display: flex;
  align-items: flex-start;
  padding: 10px 0 10px 24px;
}

.timeline-dot {
  position: absolute;
  left: 3px;
  top: 14px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #4a90d9;
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px #4a90d9;
  z-index: 1;
}

.timeline-date {
  min-width: 140px;
  font-size: 0.8rem;
  color: #777;
  font-family: monospace;
  padding-top: 1px;
  flex-shrink: 0;
}

.timeline-event-label {
  font-size: 0.72rem;
  color: #4a90d9;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-weight: 500;
  margin-top: 2px;
}

.timeline-content {
  flex: 1;
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  padding: 8px 12px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.timeline-title { font-weight: 500; font-size: 0.92rem; }
.timeline-uid { font-size: 0.75rem; color: #999; font-family: monospace; margin-top: 2px; }

.timeline-empty { padding: 20px; color: #999; text-align: center; }

/* Composition type colors */
.type-person .timeline-dot { background: #6b7280; box-shadow: 0 0 0 2px #6b7280; }
.type-fall .timeline-dot { background: #f59e0b; box-shadow: 0 0 0 2px #f59e0b; }
.type-diagnose .timeline-dot { background: #ef4444; box-shadow: 0 0 0 2px #ef4444; }
.type-labor .timeline-dot { background: #10b981; box-shadow: 0 0 0 2px #10b981; }
.type-prozedur .timeline-dot { background: #8b5cf6; box-shadow: 0 0 0 2px #8b5cf6; }
.type-medikation .timeline-dot { background: #06b6d4; box-shadow: 0 0 0 2px #06b6d4; }
.type-default .timeline-dot { background: #4a90d9; box-shadow: 0 0 0 2px #4a90d9; }

.type-person .timeline-content { border-left: 3px solid #6b7280; }
.type-fall .timeline-content { border-left: 3px solid #f59e0b; }
.type-diagnose .timeline-content { border-left: 3px solid #ef4444; }
.type-labor .timeline-content { border-left: 3px solid #10b981; }
.type-prozedur .timeline-content { border-left: 3px solid #8b5cf6; }
.type-medikation .timeline-content { border-left: 3px solid #06b6d4; }

/* Fall grouping */
.fall-group {
  background: #ececec;
  border-radius: 8px;
  margin-top: 4px;
  padding: 8px;
}

.fall-group:not(:first-of-type) {
  margin-top: 12px;
}

.fall-group-header {
  font-size: 0.72rem;
  font-weight: 600;
  color: #6b7280;
  font-family: monospace;
  padding: 2px 0 2px 8px;
  margin-bottom: 2px;
}

.fall-group-items .timeline-item {
  padding-left: 22px;
}

/* Diagnosis detail (inline expand) */
.diagnosis-detail {
  margin: 0 0 8px 0;
  padding-left: 24px;
}

.diag-entry {
  padding: 10px 0;
  border-bottom: 1px solid #f3f4f6;
}

.diag-entry:last-child { border-bottom: none; }

.diag-entry .card-table th { color: #6b7280; }
.diag-entry .card-table td { color: #1a1a1a; }

.diag-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 8px;
}

.diag-code {
  display: inline-block;
  background: #ef4444;
  color: #fff;
  padding: 2px 8px;
  border-radius: 4px;
  font-family: monospace;
  font-weight: 600;
  font-size: 0.85rem;
}

.diag-name {
  font-weight: 500;
  font-size: 0.95rem;
  color: #1a1a1a;
}

.diag-freitext {
  font-style: italic;
  color: #555;
}

.diag-empty {
  padding: 16px;
  color: #999;
  text-align: center;
}

/* Prozedur detail (Name + Status-Badge) */
.proc-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.proc-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.proc-badge {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: capitalize;
  padding: 2px 8px;
  border-radius: 999px;
}

.proc-ok     { background: #d1fae5; color: #065f46; }
.proc-active { background: #dbeafe; color: #1e40af; }
.proc-pending{ background: #fef3c7; color: #92400e; }
.proc-cancel { background: #fee2e2; color: #991b1b; }
.proc-default{ background: #e5e7eb; color: #374151; }

.timeline-content[style*="cursor"]:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

/* Labor detail table */
.labor-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.labor-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #6b7280;
  background: #f9fafb;
  border-bottom: 1px solid #e5e5e5;
}

.labor-table td {
  padding: 6px 12px;
  border-bottom: 1px solid #f3f4f6;
}

.labor-table tbody tr:last-child td {
  border-bottom: none;
}

.lab-analyte {
  display: flex;
  flex-direction: column;
}

.lab-analyte-name {
  font-weight: 500;
  color: #1a1a1a;
}

.lab-analyte-code {
  font-size: 0.72rem;
  color: #9ca3af;
  font-family: monospace;
}

.lab-value {
  font-weight: 600;
  font-family: 'SF Mono', 'Menlo', monospace;
  font-size: 0.92rem;
}

.lab-normal { color: #059669; }
.lab-high { color: #dc2626; background: #fef2f2; border-radius: 3px; padding: 1px 4px; }
.lab-low { color: #2563eb; background: #eff6ff; border-radius: 3px; padding: 1px 4px; }

.lab-unit {
  color: #6b7280;
  font-size: 0.82rem;
}

.lab-status {
  font-size: 0.82rem;
  color: #374151;
}

.lab-probe {
  font-size: 0.82rem;
  color: #6b7280;
}

.labor-empty {
  padding: 16px;
  color: #999;
  text-align: center;
}

/* --- Timeline Label --- */

.ellipsis {
  display: inline-block;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}

.timeline-title-uid {
  font-size: 0.7rem;
  color: #9ca3af;
  margin-left: 6px;
}

/* --- Lab Indicator --- */

.lab-indicator {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-left: 5px;
  vertical-align: middle;
}

.lab-ind-ok { background: #059669; }
.lab-ind-prelim { background: #d97706; }
.lab-ind-abn { background: #dc2626; }

/* --- Accordion Slide-Out (CSS Grid) --- */

.composition-detail {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.35s ease-in-out;
}

.composition-detail.open {
  grid-template-rows: 1fr;
}

.composition-detail > .composition-detail-inner {
  min-height: 0;
  overflow: hidden;
}

