/* Linear Dark Minimal Modern Theme */
:root {
  --bg-dark: #090a0f;
  --card-bg: #12141c;
  --card-border: #1e2230;
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --accent-cyan: #38bdf8;
  --accent-fire: #f97316;
  --accent-green: #22c55e;
  --accent-red: #ef4444;
  --radius: 12px;
  --transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

.bg-glow {
  position: fixed;
  top: -150px;
  left: 50%;
  transform: translateX(-50%);
  width: 600px;
  height: 400px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.15) 0%, rgba(9, 10, 15, 0) 70%);
  pointer-events: none;
  z-index: 0;
}

.app-container {
  max-width: 860px;
  margin: 0 auto;
  padding: 16px;
  position: relative;
  z-index: 1;
}

.hidden { display: none !important; }

/* LOGIN SCREEN */
.login-header {
  text-align: center;
  margin: 40px 0 28px;
}
.logo-badge {
  display: inline-block;
  padding: 6px 14px;
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: var(--primary);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}
.login-header h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 6px;
}
.subtitle {
  color: var(--text-muted);
  font-size: 14px;
}

.profiles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 14px;
  margin-top: 24px;
}

.profile-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 20px 14px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
}
.profile-card:hover, .profile-card:active {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.15);
}
.profile-card .avatar {
  font-size: 38px;
  display: block;
  margin-bottom: 8px;
}
.profile-card .name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* PIN PAD */
.pin-pad-container {
  margin-top: 30px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 28px 20px;
  text-align: center;
  animation: fadeIn 0.25s ease-out;
}
.avatar-large {
  font-size: 48px;
  display: inline-block;
  margin-bottom: 6px;
}
.pin-prompt {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}
.pin-display {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin: 24px 0 20px;
}
.pin-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--card-border);
  transition: var(--transition);
}
.pin-dot.filled {
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.6);
}
.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 76px);
  gap: 12px;
  justify-content: center;
  margin: 0 auto;
}
.pin-btn {
  height: 60px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--card-border);
  color: var(--text-main);
  font-size: 20px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}
.pin-btn:active {
  background: rgba(99, 102, 241, 0.2);
  border-color: var(--primary);
  transform: scale(0.94);
}
.pin-btn-sub {
  font-size: 13px;
  border-radius: var(--radius);
}
.error-msg {
  color: var(--accent-red);
  font-size: 13px;
  margin-top: 14px;
}

/* DASHBOARD TOP BAR */
.top-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0 16px;
  border-bottom: 1px solid var(--card-border);
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
}
.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-green);
  box-shadow: 0 0 8px var(--accent-green);
}
.brand-name {
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.3px;
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.04);
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--card-border);
}
.btn-icon {
  background: transparent;
  border: none;
  font-size: 15px;
  cursor: pointer;
  opacity: 0.8;
  padding: 2px 4px;
}
.btn-icon:hover { opacity: 1; }

/* QUICK ACTIONS */
.quick-actions {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 16px 0;
  scrollbar-width: none;
}
.quick-actions::-webkit-scrollbar { display: none; }
.btn-action {
  white-space: nowrap;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  color: var(--text-main);
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}
.btn-action.primary {
  background: var(--primary);
  border-color: var(--primary);
}
.btn-action:hover {
  border-color: var(--primary);
}

/* KPI GRID */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
@media (min-width: 600px) {
  .kpi-grid { grid-template-columns: repeat(4, 1fr); }
}
.kpi-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
}
.kpi-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.kpi-value {
  font-size: 26px;
  font-weight: 800;
  margin: 6px 0 2px;
  letter-spacing: -0.5px;
}
.kpi-sub {
  font-size: 11px;
  color: var(--text-muted);
}
.highlight-fire { color: var(--accent-fire); }
.highlight-bpm { color: var(--accent-cyan); }

/* TABS */
.tabs-nav {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--card-border);
  margin-bottom: 18px;
  overflow-x: auto;
}
.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* SECTION HEADERS */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.section-header h3 {
  font-size: 16px;
  font-weight: 700;
}
.badge-count {
  font-size: 12px;
  background: rgba(255, 255, 255, 0.06);
  padding: 3px 8px;
  border-radius: 6px;
  color: var(--text-muted);
}

/* WORKOUT CARD */
.workout-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  transition: var(--transition);
}
.workout-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
}
.discipline-title {
  font-size: 16px;
  font-weight: 700;
}
.workout-date {
  font-size: 12px;
  color: var(--text-muted);
}
.workout-meta {
  display: flex;
  gap: 16px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.workout-meta strong {
  color: var(--text-main);
}
.zones-bar {
  display: flex;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 12px;
  background: #1a1d28;
}
.zone-seg { height: 100%; }
.z1 { background: #64748b; }
.z2 { background: #38bdf8; }
.z3 { background: #22c55e; }
.z4 { background: #f97316; }
.z5 { background: #ef4444; }
.workout-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding-top: 10px;
  font-size: 12px;
  color: var(--text-muted);
}

/* LEADERBOARD */
.leaderboard-item {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
}
.lb-rank {
  font-size: 18px;
  font-weight: 800;
  width: 28px;
  color: var(--text-muted);
}
.lb-rank.gold { color: #f59e0b; }
.lb-rank.silver { color: #94a3b8; }
.lb-rank.bronze { color: #b45309; }
.lb-avatar { font-size: 24px; }
.lb-info { flex: 1; }
.lb-name { font-weight: 600; font-size: 14px; }
.lb-sub { font-size: 12px; color: var(--text-muted); }
.lb-score { text-align: right; }
.lb-cal { font-weight: 700; color: var(--accent-fire); font-size: 16px; }
.lb-score-sub { font-size: 11px; color: var(--text-muted); }

/* BADGES GRID */
.badges-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
}
.badge-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 16px 12px;
  text-align: center;
}
.badge-card.locked { opacity: 0.35; filter: grayscale(1); }
.badge-icon { font-size: 32px; margin-bottom: 8px; display: block; }
.badge-name { font-size: 13px; font-weight: 700; margin-bottom: 4px; }
.badge-desc { font-size: 11px; color: var(--text-muted); }

/* MODALS */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}
.modal-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 480px;
  padding: 24px;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}
.close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
}
.form-group { margin-bottom: 14px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.form-control {
  width: 100%;
  background: #090a0f;
  border: 1px solid var(--card-border);
  color: var(--text-main);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
}
.form-control:focus { outline: none; border-color: var(--primary); }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}
.btn-primary {
  background: var(--primary);
  border: none;
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
}
.btn-secondary {
  background: transparent;
  border: 1px solid var(--card-border);
  color: var(--text-muted);
  padding: 10px 16px;
  border-radius: 8px;
  cursor: pointer;
}
.security-banner {
  background: rgba(34, 197, 94, 0.08);
  border: 1px solid rgba(34, 197, 94, 0.25);
  color: #86efac;
  font-size: 12px;
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 16px;
  line-height: 1.4;
}
.code-box {
  background: #090a0f;
  border: 1px solid var(--card-border);
  padding: 10px 12px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 10px 0 16px;
}
.code-box code { font-size: 12px; color: var(--accent-cyan); word-break: break-all; }
.copy-btn {
  background: rgba(255, 255, 255, 0.06);
  border: none;
  color: var(--text-main);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  margin-left: 8px;
}
.guide-list { padding-left: 20px; font-size: 13px; color: var(--text-muted); line-height: 1.6; }
.file-drop-zone {
  border: 2px dashed var(--card-border);
  border-radius: var(--radius);
  padding: 36px 20px;
  text-align: center;
  cursor: pointer;
}
.drop-icon { font-size: 38px; display: block; margin-bottom: 10px; }

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