:root {
  --cyan: #00b4e6;
  --cyan-light: #4dd4ff;
  --magenta: #e040a0;
  --yellow: #f5c518;
  --bg: #060608;
  --bg-elevated: #0f1014;
  --bg-card: #14151a;
  --text: #e8eaed;
  --text-muted: #9aa0a8;
  --border: rgba(255, 255, 255, 0.08);
  --gradient: linear-gradient(135deg, var(--cyan) 0%, var(--magenta) 50%, var(--yellow) 100%);
  --danger: #ff6b6b;
  --success: #51cf66;
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--cyan-light); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { width: min(1100px, 92vw); margin: 0 auto; padding: 0 1rem; }

header.app-header {
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
  background: rgba(6, 6, 8, 0.9);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.logo-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: inherit;
  text-decoration: none;
}

.logo-link img { height: 36px; }
.logo-text {
  font-weight: 600;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.5rem;
}

.card h2, .card h3 { margin-bottom: 0.75rem; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

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

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

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

input, select, textarea {
  width: 100%;
  padding: 0.7rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font: inherit;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--cyan);
}

textarea { min-height: 90px; resize: vertical; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 1.2rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  text-decoration: none;
}

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

.btn-outline {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-danger {
  background: rgba(255, 107, 107, 0.15);
  color: var(--danger);
  border: 1px solid rgba(255, 107, 107, 0.3);
}

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

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
}

.auth-card {
  width: min(420px, 100%);
}

.auth-card .logo-wrap {
  text-align: center;
  margin-bottom: 1.5rem;
}

.auth-card .logo-wrap img { height: 56px; margin-bottom: 0.5rem; }

.error-msg {
  background: rgba(255, 107, 107, 0.1);
  border: 1px solid rgba(255, 107, 107, 0.3);
  color: #ffb3b3;
  padding: 0.75rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.875rem;
}

.success-msg {
  background: rgba(81, 207, 102, 0.1);
  border: 1px solid rgba(81, 207, 102, 0.3);
  color: #b2f2bb;
  padding: 0.75rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.875rem;
}

.verify-banner {
  background: rgba(255, 193, 7, 0.1);
  border: 1px solid rgba(255, 193, 7, 0.35);
  color: #ffe08a;
  padding: 0.85rem 1rem;
  border-radius: 8px;
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent, #7c9cff);
  cursor: pointer;
  padding: 0;
  font: inherit;
  text-decoration: underline;
}

.link-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.dashboard { padding: 2rem 0 4rem; }

.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  text-align: center;
  padding: 1.25rem;
}

.stat-card .num {
  font-size: 2rem;
  font-weight: 700;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.stat-card .label { color: var(--text-muted); font-size: 0.85rem; }

.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.tab {
  padding: 0.5rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font: inherit;
}

.tab.active {
  border-color: var(--cyan);
  color: var(--cyan-light);
  background: rgba(0, 180, 230, 0.1);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.list-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}

.list-item:last-child { border-bottom: none; }

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

.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-scan { background: rgba(0, 180, 230, 0.15); color: var(--cyan-light); }
.badge-prescription { background: rgba(224, 64, 160, 0.15); color: #f0a0d0; }
.badge-photo { background: rgba(245, 197, 24, 0.15); color: var(--yellow); }
.badge-follow_up { background: rgba(81, 207, 102, 0.15); color: #69db7c; }

.record-content {
  margin-top: 0.35rem;
  white-space: pre-wrap;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.consultation-result {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--bg-elevated);
  border-radius: 12px;
  border: 1px solid var(--border);
}

.consultation-result h4 {
  color: var(--cyan-light);
  margin: 1rem 0 0.35rem;
}

.consultation-result h4:first-child { margin-top: 0; }

.disclaimer-box {
  margin-top: 1.5rem;
  padding: 1rem;
  border: 1px dashed rgba(245, 197, 24, 0.4);
  border-radius: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem 1rem;
}

.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: var(--cyan);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 0.5rem;
}

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

.stats-row-5 {
  grid-template-columns: repeat(5, 1fr);
}

.event-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 0.75rem;
  background: var(--bg-elevated);
}

.event-detail {
  border-color: rgba(0, 180, 230, 0.25);
}

.event-section {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.event-section h4 {
  color: var(--cyan-light);
  margin-bottom: 0.75rem;
  font-size: 0.95rem;
}

.timeline-item {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.timeline-item:last-child {
  border-bottom: none;
}

.dash-nav {
  display: flex;
  gap: 0.35rem;
  margin-right: 0.5rem;
}

.dash-nav-link {
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.85rem;
  text-decoration: none;
}

.dash-nav-link:hover {
  text-decoration: none;
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.2);
}

.dash-nav-link.active {
  border-color: var(--cyan);
  color: var(--cyan-light);
  background: rgba(0, 180, 230, 0.1);
}

.selfie-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
}

.selfie-thumb {
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
}

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

.selfie-thumb .selfie-meta {
  padding: 0.5rem;
  font-size: 0.75rem;
}

.longevity-accent {
  color: #69db7c;
}

.input-row {
  display: flex;
  gap: 0.5rem;
}

.input-row input {
  flex: 1;
}

.selfie-actions {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.selfie-camera-panel video {
  width: 100%;
  max-height: 320px;
  border-radius: 10px;
  background: #000;
  display: block;
  margin-bottom: 0.75rem;
}

.selfie-preview {
  width: 100%;
  max-height: 320px;
  object-fit: contain;
  border-radius: 10px;
  border: 1px solid var(--border);
  margin-bottom: 1rem;
  background: var(--bg-elevated);
}

.metric-view-toggle {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.metric-view-btn.active {
  border-color: var(--cyan);
  color: var(--cyan-light);
  background: rgba(0, 180, 230, 0.1);
}

.metric-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.metric-table th,
.metric-table td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.metric-table th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
}

.metric-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.metric-flag-high { color: #ff8787; }
.metric-flag-low { color: #74c0fc; }
.metric-flag-normal { color: #69db7c; }

.metric-chart {
  min-height: 220px;
  padding: 1rem 0;
}

.metric-chart svg {
  width: 100%;
  height: 220px;
}

.metric-chart-empty {
  color: var(--text-muted);
  text-align: center;
  padding: 2rem 1rem;
}

.extracted-metrics {
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.recommendation-card {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.recommendation-card:last-child {
  border-bottom: none;
}

.longevist-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1rem;
  background: var(--bg-elevated);
}

.longevist-header {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}

.longevist-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid var(--border);
  background: var(--bg);
}

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

.longevist-card h4 {
  margin: 0 0 0.25rem;
  color: var(--cyan-light);
}

.expert-rec-item {
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
}

.expert-rec-item:last-child {
  border-bottom: none;
}

.expert-rec-category {
  display: inline-block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}

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

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