:root {
  --bg: #050816;
  --bg-alt: #0b1020;
  --bg-elevated: rgba(15, 23, 42, 0.9);
  --accent: #38bdf8;
  --accent-soft: rgba(56, 189, 248, 0.25);
  --accent-strong: #0ea5e9;
  --accent-gradient: #38bdf8;
  --danger: #f97373;
  --success: #4ade80;
  --border-subtle: rgba(148, 163, 184, 0.25);
  --text: #e5e7eb;
  --text-soft: #9ca3af;
  --text-muted: #6b7280;
  --shadow-soft: 0 18px 45px rgba(15, 23, 42, 0.9);
  --radius-lg: 18px;
  --radius-xl: 24px;
  --timing-fast: 150ms;
  --timing-med: 220ms;
}

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

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  color: var(--text);
  background: #020617;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
}

.page-root {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Top bar */
.topbar {
  height: 60px;
  background: #000;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.75rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.4);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.topbar-title {
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.9rem;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo,
.logo-large {
  display: block;
  object-fit: contain;
  border-radius: 999px;
}

.logo {
  width: 32px;
  height: 32px;
}

.logo-large {
  width: 40px;
  height: 40px;
}

.logo-fallback {
  background: #1f2937;
}

.page-main {
  flex: 1;
  padding: 2.5rem 1.5rem 2rem;
  display: flex;
  align-items: stretch;
  justify-content: center;
}

/* Auth layout */
.auth-shell {
  width: 100%;
  max-width: 960px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.auth-panel {
  width: 100%;
  max-width: 520px;
  border-radius: var(--radius-xl);
  padding: 2.25rem 2.5rem;
  position: relative;
  overflow: hidden;
}

.glass {
  background: #020617;
  border: 1px solid var(--border-subtle);
  box-shadow: none;
  backdrop-filter: none;
}

.auth-header {
  margin-bottom: 1.75rem;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.auth-brand-text h1 {
  margin: 0;
  font-size: 1.4rem;
}

.auth-brand-text .subtitle {
  margin: 0.2rem 0 0;
  font-size: 0.85rem;
  color: var(--text-soft);
}

/* Forms */
.form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.form-field label {
  font-size: 0.8rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
}

.field-hint {
  margin: 0.25rem 0 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 0.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.input-wrapper input {
  width: 100%;
  padding: 0.7rem 0.9rem 0.7rem 2.25rem;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: rgba(15, 23, 42, 0.9);
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
  transition: border-color var(--timing-med) ease, box-shadow var(--timing-med) ease,
    background var(--timing-med) ease, transform var(--timing-fast) ease;
}

.input-wrapper input::placeholder {
  color: var(--text-muted);
}

.input-wrapper input:focus {
  border-color: var(--accent);
  box-shadow: none;
  background: rgba(15, 23, 42, 0.98);
  transform: translateY(-1px);
}

.input-wrapper input[readonly] {
  opacity: 0.8;
  cursor: default;
}

.form-actions {
  margin-top: 0.25rem;
}

.form-footer {
  display: flex;
  justify-content: flex-end;
  font-size: 0.85rem;
}

.form-message {
  border-radius: 999px;
  padding: 0.55rem 0.9rem;
  font-size: 0.8rem;
}

.form-error {
  background: rgba(239, 68, 68, 0.18);
  border: 1px solid rgba(248, 113, 113, 0.5);
  color: #fecaca;
}

.form-success {
  background: rgba(34, 197, 94, 0.16);
  border: 1px solid rgba(74, 222, 128, 0.45);
  color: #bbf7d0;
}

/* Buttons */
.btn {
  --btn-bg: rgba(15, 23, 42, 0.9);
  --btn-color: var(--text);
  --btn-border: rgba(148, 163, 184, 0.6);
  --btn-shadow: none;

  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1.2rem;
  border-radius: 999px;
  border: 1px solid var(--btn-border);
  background: var(--btn-bg);
  color: var(--btn-color);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  overflow: hidden;
  transition: transform var(--timing-med) ease, box-shadow var(--timing-med) ease,
    border-color var(--timing-med) ease, background var(--timing-med) ease,
    color var(--timing-med) ease;
}

.btn .btn-label {
  position: relative;
  z-index: 1;
}

.btn .btn-glow {
  display: none;
}

.btn.primary {
  --btn-bg: var(--accent);
  --btn-color: #0b1120;
  --btn-border: transparent;
  box-shadow: none;
}

.btn.ghost {
  --btn-bg: rgba(15, 23, 42, 0.8);
  --btn-color: var(--text-soft);
  --btn-border: rgba(55, 65, 81, 0.9);
}

.btn:hover {
  transform: translateY(-1px);
}

.btn.primary:hover .btn-glow {
  /* no glow */
}

.btn:active {
  transform: translateY(0);
  box-shadow: none;
}

.btn:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 2px;
}

.btn.w-100 {
  width: 100%;
}

/* Links */
.link {
  color: var(--accent);
  text-decoration: none;
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}

.link::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -0.1rem;
  width: 0;
  height: 1px;
  background: var(--accent);
  transition: width var(--timing-med) ease;
}

.link:hover::after {
  width: 100%;
}

.link.subtle {
  color: var(--text-soft);
}

/* Flash messages */
.flash-stack {
  position: fixed;
  top: 76px;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 30;
}

.flash {
  min-width: 220px;
  padding: 0.5rem 0.8rem;
  border-radius: 999px;
  font-size: 0.8rem;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(148, 163, 184, 0.5);
  box-shadow: none;
}

.flash-success {
  border-color: rgba(74, 222, 128, 0.8);
}

.flash-info {
  border-color: rgba(56, 189, 248, 0.7);
}

.flash-error {
  border-color: rgba(248, 113, 113, 0.8);
}

/* App layout (home/add user) */
.layout-shell {
  width: 100%;
  max-width: 1200px;
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 1.75rem;
}

.sidebar {
  border-radius: 22px;
  background: #020617;
  border: 1px solid var(--border-subtle);
  box-shadow: none;
  padding: 1.3rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.avatar-pulse {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: #111827;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.avatar-pulse::before {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: inherit;
  border: 1px solid rgba(56, 189, 248, 0.5);
  opacity: 0.4;
  animation: pulse-ring 2.4s infinite ease-out;
}

.avatar-initial {
  font-weight: 600;
  font-size: 1rem;
}

.sidebar-user-meta {
  display: flex;
  flex-direction: column;
}

.sidebar-user-name {
  font-size: 0.9rem;
  font-weight: 500;
}

.sidebar-user-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.sidebar-spacer {
  flex: 1;
}

.sidebar-bottom {
  margin-top: auto;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.85rem;
  border-radius: 999px;
  font-size: 0.85rem;
  color: var(--text-soft);
  text-decoration: none;
  border: 1px solid transparent;
  transition: background var(--timing-med) ease, transform var(--timing-fast) ease,
    border-color var(--timing-med) ease, color var(--timing-med) ease;
}

.sidebar-link:hover {
  background: rgba(15, 23, 42, 0.95);
  transform: translateY(-1px);
}

.sidebar-link.accent {
  border-color: rgba(56, 189, 248, 0.5);
  color: var(--accent);
  background: rgba(56, 189, 248, 0.14);
}

.sidebar-link.accent.active {
  background: rgba(56, 189, 248, 0.22);
}

.content-shell {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.hero-card,
.form-card {
  border-radius: var(--radius-xl);
  padding: 1.8rem 1.9rem;
}

.hero-card h1,
.form-card h1 {
  margin: 0 0 0.6rem;
  font-size: 1.4rem;
}

.subtitle {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.9rem;
}

.metric-card {
  margin-top: 1.5rem;
  border-radius: var(--radius-xl);
  padding: 1.4rem 1.6rem;
  background: #020617;
  border: 1px solid var(--border-subtle);
}

.metric-header {
  margin-bottom: 0.8rem;
}

.metric-title {
  font-size: 0.95rem;
}

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

.metric-grid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.metric-row {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.8rem;
}

.metric-label {
  color: var(--text-soft);
}

.metric-bar {
  position: relative;
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.3);
  overflow: hidden;
}

.metric-bar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.metric-value {
  font-variant-numeric: tabular-nums;
  color: var(--text-soft);
}

.stats-grid {
  margin-top: 1.6rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.9rem;
}

.stat-card {
  padding: 0.9rem 0.9rem;
  border-radius: 16px;
  background: #020617;
  border: 1px solid rgba(30, 64, 175, 0.6);
}

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

.stat-value {
  margin-top: 0.2rem;
  font-size: 0.95rem;
}

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

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--timing-med) ease, visibility var(--timing-med) ease;
  z-index: 40;
}

.modal-backdrop.open {
  opacity: 1;
  visibility: visible;
}

.modal {
  width: 100%;
  max-width: 380px;
  border-radius: var(--radius-lg);
  padding: 1.6rem 1.7rem 1.4rem;
  background: var(--bg-elevated);
  border: 1px solid rgba(74, 222, 128, 0.65);
  box-shadow: none;
  text-align: center;
}

.modal h2 {
  margin: 0.3rem 0 0.4rem;
  font-size: 1.2rem;
}

.modal p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-soft);
}

.modal-icon {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.2rem;
}

.modal-icon.success {
  background: rgba(22, 163, 74, 0.2);
  color: #bbf7d0;
}

.modal-actions {
  margin-top: 1rem;
  display: flex;
  justify-content: center;
}

.progress-bar {
  margin-top: 0.8rem;
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.4);
  overflow: hidden;
}

.progress-bar-fill {
  width: 40%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  animation: progress-pulse 1s ease-in-out infinite;
}

/* Tabs for participants page */
.tabs {
  margin-top: 1.4rem;
  margin-bottom: 1rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.2rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.45);
}

.tab-pill {
  border: none;
  background: transparent;
  color: var(--text-soft);
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background var(--timing-med) ease, color var(--timing-med) ease,
    transform var(--timing-fast) ease;
}

.tab-pill.active {
  background: var(--accent);
  color: #0b1120;
  transform: translateY(-1px);
}

.tab-panels {
  margin-top: 0.4rem;
}

.tab-panel {
  display: none;
}

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

.range-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 0.65rem;
  align-items: center;
}

.range-separator {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.email-suffix {
  position: absolute;
  right: 0.9rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.participants-footer {
  margin-top: 1.4rem;
  padding-top: 0.8rem;
  border-top: 1px dashed rgba(148, 163, 184, 0.4);
}

.participants-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.participants-label {
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.participants-value {
  color: var(--accent);
}

.progress-table-wrapper {
  margin-top: 1.2rem;
  overflow-x: auto;
}

.progress-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.progress-table th,
.progress-table td {
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid rgba(31, 41, 55, 0.9);
  text-align: left;
}

.progress-table th {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.progress-email-cell {
  font-size: 0.85rem;
}

.progress-flag-cell {
  width: 36px;
}

.progress-flag-cell.ok {
  background: rgba(34, 197, 94, 0.45);
}

.progress-flag-cell.missing {
  background: rgba(239, 68, 68, 0.45);
}

.progress-ecg-cell {
  text-align: center;
  font-variant-numeric: tabular-nums;
  border: 1px solid transparent;
}

.progress-ecg-cell.ok {
  border-color: rgba(34, 197, 94, 0.8);
}

.progress-ecg-cell.missing {
  border-color: rgba(239, 68, 68, 0.8);
}

/* Icons (minimal inline icons, no emojis) */
.icon-user::before,
.icon-lock::before,
.icon-mail::before,
.icon-plus-circle::before,
.icon-home::before,
.icon-power::before,
.icon-check::before,
.icon-steps::before,
.icon-calories::before,
.icon-heart::before,
.icon-sleep::before,
.icon-oxygen::before,
.icon-ecg::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  background: var(--accent);
}

/* Animations */
.fade-in-up {
  animation: fade-in-up 420ms ease-out;
}

.shake {
  animation: shake 380ms ease-out;
}

.scale-in {
  animation: scale-in 260ms ease-out;
}

@keyframes fade-in-up {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20%,
  60% {
    transform: translateX(-4px);
  }
  40%,
  80% {
    transform: translateX(4px);
  }
}

@keyframes scale-in {
  from {
    opacity: 0;
    transform: scale(0.92);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes progress-pulse {
  0% {
    transform: translateX(-60%);
  }
  50% {
    transform: translateX(-10%);
  }
  100% {
    transform: translateX(40%);
  }
}

@keyframes pulse-ring {
  0% {
    transform: scale(0.95);
    opacity: 0.6;
  }
  80% {
    transform: scale(1.15);
    opacity: 0;
  }
  100% {
    opacity: 0;
  }
}

/* Responsive */
@media (max-width: 900px) {
  .layout-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .sidebar-spacer {
    display: none;
  }

  .sidebar-bottom {
    margin-top: 0;
  }
}

@media (max-width: 640px) {
  .topbar {
    padding-inline: 1rem;
  }

  .auth-panel {
    padding: 1.7rem 1.4rem;
  }

  .page-main {
    padding-inline: 1rem;
  }
}

