/* ─── THEME VARIABLES ─── */
:root {
  --bg: #0f0f14;
  --bg2: #16161e;
  --bg3: #1e1e2a;
  --border: rgba(255,255,255,0.07);
  --text: #e8e8f0;
  --text2: #8888aa;
  --text3: #4a4a66;
  --accent: #c8b4ff;
  --accent2: #7fd8be;
  --accent3: #ffb56b;
  --accent4: #ff8080;
  --accent5: #80c8ff;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 2px 12px rgba(0,0,0,0.3);
}

[data-theme="light"] {
  --bg: #f5f5f8;
  --bg2: #ffffff;
  --bg3: #eeeef2;
  --border: rgba(0,0,0,0.08);
  --text: #1a1a2e;
  --text2: #555570;
  --text3: #9999aa;
  --accent: #7c5cbf;
  --accent2: #3daa8e;
  --accent3: #d4842a;
  --accent4: #d44;
  --accent5: #3388cc;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Mono', monospace;
  font-size: 14px;
  overflow: hidden;
  transition: background 0.3s, color 0.3s;
}

/* ─── LOGIN SCREEN ─── */
#login-screen {
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg);
}

#login-screen.hidden { display: none; }

.login-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 32px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow);
}

.login-logo {
  font-family: 'DM Serif Display', serif;
  font-size: 32px;
  text-align: center;
  color: var(--text);
  margin-bottom: 4px;
}

.login-subtitle {
  font-size: 12px;
  color: var(--text3);
  text-align: center;
  margin-bottom: 28px;
  letter-spacing: 0.5px;
}

.login-form { display: flex; flex-direction: column; gap: 14px; }

.login-error {
  font-size: 12px;
  color: var(--accent4);
  text-align: center;
  min-height: 16px;
}

/* ─── APP SHELL ─── */
#app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
}

.app-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

/* ─── NAV BRAND (sidebar only) ─── */
.nav-brand { display: none; }

/* ─── NAV USER (sidebar only) ─── */
.nav-user { display: none; }

/* ─── HEADER ─── */
header {
  padding: 16px 20px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 12px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-title {
  font-family: 'DM Serif Display', serif;
  font-size: 22px;
  color: var(--text);
  letter-spacing: -0.5px;
}

.header-subtitle {
  font-size: 11px;
  color: var(--text3);
  margin-top: 1px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.streak-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--accent3);
  white-space: nowrap;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text2);
}

.header-logout-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text3);
  cursor: pointer;
  padding: 4px 8px;
  font-size: 12px;
  transition: all 0.15s;
}
.header-logout-btn:hover { border-color: var(--accent4); color: var(--accent4); }

/* ─── USER SELECTOR ─── */
.user-selector select {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  padding: 6px 10px;
  cursor: pointer;
  max-width: 160px;
}

/* ─── VIEWING BANNER ─── */
.viewing-banner {
  background: rgba(200,180,255,0.1);
  border-bottom: 1px solid var(--accent);
  padding: 8px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--accent);
  flex-shrink: 0;
}
.viewing-banner button {
  background: none;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  color: var(--accent);
  padding: 4px 10px;
  font-size: 11px;
  cursor: pointer;
  font-family: 'DM Mono', monospace;
  transition: all 0.15s;
}
.viewing-banner button:hover { background: var(--accent); color: var(--bg); }

/* ─── NAVIGATION ─── */
nav {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
nav::-webkit-scrollbar { display: none; }

.nav-btn {
  flex: 1;
  min-width: 55px;
  padding: 12px 6px;
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: color 0.2s;
  position: relative;
}

.nav-btn.active { color: var(--accent); }
.nav-btn.active::after {
  content: '';
  position: absolute;
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 24px; height: 2px;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
}

.nav-icon { font-size: 18px; }
.nav-label { pointer-events: none; }

/* ─── MAIN CONTENT ─── */
main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--bg3) transparent;
}

.view {
  display: none;
  padding: 16px 20px 32px;
  animation: fadeIn 0.25s ease;
}
.view.active { display: block; }

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

/* ─── DATE NAV ─── */
.date-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.date-btn {
  width: 36px; height: 36px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text2);
  cursor: pointer;
  font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.date-btn:hover { color: var(--text); border-color: var(--accent); }
.date-btn:disabled { opacity: 0.3; cursor: default; }
.date-btn:disabled:hover { color: var(--text2); border-color: var(--border); }

.current-date {
  font-family: 'DM Serif Display', serif;
  font-size: 18px;
  color: var(--text);
  cursor: pointer;
  text-align: center;
}
.current-date span {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  color: var(--text3);
  display: block;
  text-align: center;
  margin-top: 1px;
}

/* ─── SECTION ─── */
.section {
  margin-bottom: 20px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: background 0.3s, border-color 0.3s;
}

.section-header {
  padding: 14px 16px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border);
}

.section-icon { font-size: 16px; }

.section-title {
  font-family: 'DM Serif Display', serif;
  font-size: 16px;
  color: var(--text);
}

.section-body { padding: 16px; display: flex; flex-direction: column; gap: 14px; }

/* ─── FIELD ─── */
.field { display: flex; flex-direction: column; gap: 6px; }

.field-label {
  font-size: 11px;
  color: var(--text3);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* ─── INPUTS ─── */
input[type="time"],
input[type="number"],
input[type="text"],
input[type="password"],
input[type="date"],
textarea,
select {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: 'DM Mono', monospace;
  font-size: 16px;
  padding: 10px 12px;
  width: 100%;
  outline: none;
  transition: border-color 0.2s, background 0.3s;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
}
textarea { resize: vertical; min-height: 80px; }

input[type="number"] { -moz-appearance: textfield; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; }

.input-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.input-row input[type="time"] {
  min-width: 0;
  padding: 10px 6px;
  font-size: 13px;
}

/* ─── SLIDER ─── */
.slider-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.slider-val {
  min-width: 28px;
  text-align: center;
  font-size: 16px;
  font-weight: 500;
  color: var(--accent);
}

input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  height: 4px;
  background: var(--bg3);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--bg);
  box-shadow: 0 0 10px rgba(200,180,255,0.4);
}

/* ─── TOGGLE ─── */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.toggle-label { color: var(--text2); font-size: 13px; }

.toggle {
  width: 44px; height: 24px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 12px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  flex-shrink: 0;
}
.toggle.on { background: var(--accent); border-color: var(--accent); }
.toggle::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 16px; height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: left 0.2s;
}
.toggle.on::after { left: 23px; }

/* ─── STEPPER ─── */
.stepper {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.step-btn {
  width: 44px; height: 44px;
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  font-size: 20px;
  display: flex; align-items: center; justify-content: center;
  transition: color 0.15s, background 0.15s;
}
.step-btn:hover { color: var(--text); background: var(--border); }

.step-val {
  flex: 1;
  text-align: center;
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
}

/* ─── MOOD PICKER ─── */
.mood-grid {
  display: flex;
  gap: 6px;
}

.mood-btn {
  flex: 1;
  padding: 10px 4px;
  background: var(--bg3);
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.mood-btn span:first-child { font-size: 20px; }
.mood-btn span:last-child { font-size: 10px; color: var(--text3); }
.mood-btn.selected { border-color: var(--accent); background: rgba(200,180,255,0.1); }

/* ─── MOOD TAGS ─── */
.mood-tags-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mood-tag {
  padding: 5px 12px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  color: var(--text2);
  cursor: pointer;
  transition: all 0.15s;
}
.mood-tag.selected {
  border-color: var(--accent);
  background: rgba(200,180,255,0.15);
  color: var(--accent);
}

/* ─── SAVE BTN ─── */
.save-btn {
  width: 100%;
  padding: 14px;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  font-family: 'DM Mono', monospace;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.5px;
  cursor: pointer;
  margin-top: 8px;
  transition: opacity 0.2s, transform 0.1s;
}
.save-btn:hover { opacity: 0.9; }
.save-btn:active { transform: scale(0.98); }
.save-btn.saved { background: var(--accent2); }

/* ─── DASHBOARD ─── */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  transition: background 0.3s;
}

.stat-card .label {
  font-size: 10px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.stat-card .value {
  font-family: 'DM Serif Display', serif;
  font-size: 28px;
  line-height: 1;
}

.stat-card .sub {
  font-size: 11px;
  color: var(--text3);
  margin-top: 3px;
}

.stat-card .trend {
  font-size: 11px;
  margin-top: 4px;
}
.trend.up { color: var(--accent2); }
.trend.down { color: var(--accent4); }
.trend.neutral { color: var(--text3); }

.stat-card.sleep .value { color: var(--accent5); }
.stat-card.mood .value { color: var(--accent); }
.stat-card.energy .value { color: var(--accent3); }
.stat-card.steps .value { color: var(--accent2); }

/* ─── CHART ─── */
.charts-grid { display: flex; flex-direction: column; }

.chart-wrap {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  transition: background 0.3s;
}

.chart-title {
  font-size: 11px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 14px;
}

canvas { width: 100% !important; }

/* ─── PERIOD SELECTOR ─── */
.period-sel {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
}

.period-btn {
  flex: 1;
  padding: 7px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text3);
  cursor: pointer;
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  text-align: center;
  transition: all 0.15s;
}
.period-btn.active {
  background: var(--bg3);
  border-color: var(--accent);
  color: var(--accent);
}

/* ─── CORRELATIONS ─── */
.corr-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  transition: background 0.3s;
}

.corr-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.corr-label { font-size: 13px; color: var(--text); }

.corr-value {
  font-weight: 500;
  font-size: 13px;
  padding: 2px 8px;
  border-radius: 10px;
}
.corr-value.positive { background: rgba(127,216,190,0.15); color: var(--accent2); }
.corr-value.negative { background: rgba(255,128,128,0.15); color: var(--accent4); }

.corr-bar {
  height: 4px;
  background: var(--bg3);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 6px;
}
.corr-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.5s ease;
}

.corr-desc {
  font-size: 11px;
  color: var(--text3);
  margin-top: 6px;
}

/* ─── INSIGHTS ─── */
.insight-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.insight-header {
  font-family: 'DM Serif Display', serif;
  font-size: 16px;
  margin-bottom: 12px;
  color: var(--text);
}

.insight-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.insight-row:last-child { border-bottom: none; }

.insight-metric { font-size: 13px; color: var(--text2); }
.insight-val { font-weight: 500; color: var(--text); }
.insight-change { font-size: 11px; margin-left: 8px; }

/* ─── HISTORY LIST ─── */
.history-search {
  margin-bottom: 16px;
  position: relative;
}
.history-search input {
  padding-left: 36px;
}
.history-search::before {
  content: '🔍';
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
}

.history-item {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.3s;
}
.history-item:hover { border-color: var(--accent); }

.history-date {
  font-family: 'DM Serif Display', serif;
  font-size: 16px;
  margin-bottom: 8px;
}

.history-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.chip {
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px;
  border: 1px solid var(--border);
  color: var(--text2);
}
.chip.sleep { border-color: var(--accent5); color: var(--accent5); }
.chip.mood { border-color: var(--accent); color: var(--accent); }
.chip.energy { border-color: var(--accent3); color: var(--accent3); }
.chip.steps { border-color: var(--accent2); color: var(--accent2); }

/* ─── HEATMAP ─── */
.heatmap-wrap {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.heatmap-title {
  font-size: 11px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

.heatmap-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}

.heatmap-day-label {
  font-size: 9px;
  color: var(--text3);
  text-align: center;
  padding-bottom: 4px;
}

.heatmap-cell {
  aspect-ratio: 1;
  border-radius: 3px;
  background: var(--bg3);
  transition: background 0.2s;
  cursor: pointer;
  position: relative;
}
.heatmap-cell:hover { outline: 1px solid var(--accent); }
.heatmap-cell.l1 { background: rgba(200,180,255,0.15); }
.heatmap-cell.l2 { background: rgba(200,180,255,0.3); }
.heatmap-cell.l3 { background: rgba(200,180,255,0.5); }
.heatmap-cell.l4 { background: rgba(200,180,255,0.7); }
.heatmap-cell.future { opacity: 0.3; cursor: default; }

/* ─── HABITS ─── */
.habit-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.habit-row:last-child { border-bottom: none; }

.habit-check {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.15s;
  flex-shrink: 0;
}
.habit-check.checked {
  background: var(--accent2);
  border-color: var(--accent2);
  color: var(--bg);
}

.habit-name { font-size: 13px; color: var(--text); flex: 1; }

.habit-streak {
  font-size: 11px;
  color: var(--text3);
}

.habit-add {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.habit-add input { flex: 1; padding: 8px 12px; font-size: 13px; }
.habit-add button {
  padding: 8px 14px;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: 'DM Mono', monospace;
  font-size: 13px;
  transition: opacity 0.15s;
}
.habit-add button:hover { opacity: 0.9; }

/* ─── GOALS ─── */
.goal-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
}

.goal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.goal-label { font-size: 13px; color: var(--text); }

.goal-target {
  font-size: 12px;
  color: var(--text3);
}

.goal-progress {
  height: 6px;
  background: var(--bg3);
  border-radius: 3px;
  overflow: hidden;
}

.goal-progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease;
  background: var(--accent2);
}
.goal-progress-fill.over { background: var(--accent); }

.goal-status {
  font-size: 11px;
  color: var(--text3);
  margin-top: 6px;
  display: flex;
  justify-content: space-between;
}

.goal-delete {
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 6px;
  transition: color 0.15s;
}
.goal-delete:hover { color: var(--accent4); }

/* ─── SETTINGS ─── */
.settings-row {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background 0.3s;
}

.settings-label { font-size: 13px; color: var(--text2); }
.settings-sub { font-size: 11px; color: var(--text3); margin-top: 2px; }

.settings-btn {
  padding: 8px 14px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text2);
  cursor: pointer;
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  transition: all 0.15s;
}
.settings-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ─── THEME QUICK TOGGLE ─── */
.theme-toggle-btn {
  width: 36px; height: 36px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}
.theme-toggle-btn:hover { border-color: var(--accent); transform: scale(1.1); }

/* ─── HEATMAP IMPROVED ─── */
.heatmap-months {
  display: flex;
  gap: 0;
  margin-bottom: 6px;
  padding-left: 0;
}

.heatmap-month-label {
  font-size: 10px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.heatmap-cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.heatmap-day-num {
  font-size: 7px;
  color: var(--text3);
  opacity: 0.7;
  line-height: 1;
  pointer-events: none;
}

.heatmap-cell.l1 .heatmap-day-num,
.heatmap-cell.l2 .heatmap-day-num,
.heatmap-cell.l3 .heatmap-day-num,
.heatmap-cell.l4 .heatmap-day-num {
  color: var(--text);
  opacity: 0.6;
}

.heatmap-legend {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 10px;
  font-size: 10px;
  color: var(--text3);
}

.heatmap-legend-cell {
  width: 12px;
  height: 12px;
  border-radius: 2px;
}

/* ─── ANALYSIS VIEW ─── */
.analysis-header {
  text-align: center;
  margin-bottom: 24px;
}

.analysis-score {
  font-family: 'DM Serif Display', serif;
  font-size: 48px;
  line-height: 1;
  color: var(--accent);
}

.analysis-score-label {
  font-size: 12px;
  color: var(--text3);
  margin-top: 4px;
}

.analysis-section {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  overflow: hidden;
}

.analysis-section-header {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

.analysis-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'DM Serif Display', serif;
  font-size: 16px;
  color: var(--text);
}

.analysis-section-score {
  font-size: 14px;
  font-weight: 500;
  padding: 2px 10px;
  border-radius: 10px;
  background: var(--bg3);
}

.analysis-section-score.good { color: var(--accent2); background: rgba(127,216,190,0.15); }
.analysis-section-score.ok { color: var(--accent3); background: rgba(255,181,107,0.15); }
.analysis-section-score.warn { color: var(--accent4); background: rgba(255,128,128,0.15); }

.analysis-section-body {
  padding: 16px;
}

.analysis-insight {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 0;
  font-size: 13px;
  color: var(--text2);
  line-height: 1.5;
}

.analysis-insight-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 6px;
}

.analysis-insight-dot.good { background: var(--accent2); }
.analysis-insight-dot.warn { background: var(--accent4); }
.analysis-insight-dot.neutral { background: var(--text3); }
.analysis-insight-dot.stat { background: var(--accent5); }

.analysis-suggestions {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.analysis-suggestion {
  display: flex;
  gap: 10px;
  padding: 8px 0;
  font-size: 12px;
  color: var(--text2);
  line-height: 1.6;
}

.analysis-suggestion-icon {
  font-size: 14px;
  flex-shrink: 0;
  margin-top: 1px;
}

.analysis-recs {
  background: var(--bg2);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.analysis-recs-title {
  font-family: 'DM Serif Display', serif;
  font-size: 18px;
  color: var(--accent);
  margin-bottom: 14px;
}

.analysis-rec-item {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text2);
  line-height: 1.6;
}
.analysis-rec-item:last-child { border-bottom: none; }

.analysis-rec-icon {
  font-size: 16px;
  flex-shrink: 0;
  margin-top: 2px;
}

/* ─── USERS MANAGEMENT ─── */
.user-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.user-card-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--bg3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--text2);
  flex-shrink: 0;
  text-transform: uppercase;
  font-weight: 500;
}

.user-card-name {
  font-size: 14px;
  color: var(--text);
}

.user-card-role {
  font-size: 11px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.user-card-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.user-view-btn {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text2);
  padding: 6px 10px;
  font-size: 11px;
  cursor: pointer;
  font-family: 'DM Mono', monospace;
  transition: all 0.15s;
}
.user-view-btn:hover { border-color: var(--accent); color: var(--accent); }

.user-add-form {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ─── TOAST ─── */
#toast {
  position: fixed;
  bottom: 20px; left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--bg3);
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 13px;
  transition: transform 0.3s;
  z-index: 100;
  white-space: nowrap;
}
#toast.show { transform: translateX(-50%) translateY(0); }

/* ─── EMPTY STATE ─── */
.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text3);
}
.empty .icon { font-size: 40px; margin-bottom: 12px; }
.empty p { font-size: 13px; line-height: 1.6; }

/* ─── ONBOARDING MODAL ─── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
  animation: fadeIn 0.3s ease;
}

.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  max-width: 400px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-title {
  font-family: 'DM Serif Display', serif;
  font-size: 22px;
  margin-bottom: 16px;
  text-align: center;
}

.modal-text {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.7;
  margin-bottom: 12px;
}

.modal-step {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.modal-step-num {
  width: 28px; height: 28px;
  background: var(--accent);
  color: var(--bg);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 500;
  flex-shrink: 0;
}

.modal-step-text {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.6;
  padding-top: 3px;
}

.modal-btn {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'DM Mono', monospace;
  font-size: 14px;
  cursor: pointer;
  margin-top: 8px;
  transition: opacity 0.15s;
}
.modal-btn:hover { opacity: 0.9; }

/* ─── SCROLLBAR ─── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg3); border-radius: 2px; }

/* ─── SUB-TABS ─── */
.sub-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  background: var(--bg2);
  border-radius: var(--radius-sm);
  padding: 3px;
  border: 1px solid var(--border);
}

.sub-tab {
  flex: 1;
  padding: 8px 6px;
  background: none;
  border: none;
  border-radius: 7px;
  color: var(--text3);
  cursor: pointer;
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  text-align: center;
  transition: all 0.15s;
}
.sub-tab.active {
  background: var(--bg3);
  color: var(--accent);
}

.sub-view { display: none; }
.sub-view.active { display: block; animation: fadeIn 0.2s ease; }

/* ─── GOAL ADD FORM ─── */
.goal-form {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.goal-form .field { margin-bottom: 10px; }

.goal-form select,
.goal-form input {
  padding: 8px 12px;
  font-size: 13px;
}

.goal-form-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.goal-form-actions button {
  flex: 1;
  padding: 8px;
  border-radius: var(--radius-sm);
  border: none;
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  cursor: pointer;
  transition: opacity 0.15s;
}

.add-goal-btn {
  width: 100%;
  padding: 10px;
  background: var(--bg2);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text3);
  cursor: pointer;
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  margin-bottom: 16px;
  transition: all 0.15s;
}
.add-goal-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ─── LOG GRID (for desktop 2-col) ─── */
.log-grid { display: contents; }

/* ─── ROLE BADGES ─── */
.role-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.role-badge.admin { background: rgba(200,180,255,0.15); color: var(--accent); }
.role-badge.coach { background: rgba(127,216,190,0.15); color: var(--accent2); }
.role-badge.uporabnik { background: rgba(128,200,255,0.15); color: var(--accent5); }

/* ═══════════════════════════════════════════════════
   DESKTOP RESPONSIVE (768px+)
   ═══════════════════════════════════════════════════ */

.mobile-only { display: block; }
.desktop-only { display: none; }

@media (min-width: 768px) {
  .mobile-only { display: none !important; }
  .desktop-only { display: block !important; }

  /* App becomes grid with sidebar */
  #app {
    max-width: none;
    display: grid;
    grid-template-columns: 220px 1fr;
    grid-template-rows: 1fr;
  }

  .app-content {
    grid-column: 2;
    grid-row: 1;
    min-height: 0;
  }

  /* Nav becomes vertical sidebar */
  nav {
    grid-column: 1;
    grid-row: 1;
    flex-direction: column;
    border-bottom: none;
    border-right: 1px solid var(--border);
    background: var(--bg2);
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0;
  }

  .nav-brand {
    display: block;
    padding: 24px 20px 20px;
    border-bottom: 1px solid var(--border);
  }

  .nav-brand .header-title {
    font-size: 24px;
  }

  .nav-btn {
    flex: none;
    flex-direction: row;
    justify-content: flex-start;
    padding: 14px 20px;
    gap: 12px;
    font-size: 12px;
    min-width: auto;
    text-align: left;
  }

  .nav-btn.active::after {
    bottom: auto;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 24px;
    border-radius: 0 2px 2px 0;
  }

  .nav-icon { font-size: 16px; }

  .nav-user {
    display: block;
    margin-top: auto;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
  }

  .nav-user-name {
    font-size: 13px;
    color: var(--text);
    margin-bottom: 2px;
  }

  .nav-user-role {
    font-size: 10px;
    color: var(--text3);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
  }

  .nav-logout-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text3);
    padding: 6px 12px;
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    cursor: pointer;
    width: 100%;
    transition: all 0.15s;
  }
  .nav-logout-btn:hover { border-color: var(--accent4); color: var(--accent4); }

  /* Header adjustments */
  header {
    padding: 16px 32px 12px;
  }

  /* Main content wider */
  .view {
    max-width: 860px;
    margin: 0 auto;
    padding: 24px 32px 40px;
  }

  /* Stats grid 4 columns */
  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  /* Viewing banner */
  .viewing-banner {
    padding: 8px 32px;
  }
}

/* ─── LARGE DESKTOP (1100px+) ─── */
@media (min-width: 1100px) {
  #app {
    grid-template-columns: 240px 1fr;
  }

  .view {
    max-width: 960px;
  }

  /* Log view: 2-column grid for sections */
  .log-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
  }

  .log-grid .section { margin-bottom: 0; }
  .log-grid .log-notes {
    grid-column: 1 / -1;
  }

  /* Charts in 2-col grid */
  .charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }
  .charts-grid .chart-wrap { margin-bottom: 0; }

  /* User management: wider form */
  .user-add-form {
    max-width: 400px;
  }
}

/* ─── EXTRA WIDE (1400px+) ─── */
@media (min-width: 1400px) {
  .view {
    max-width: 1100px;
  }

  /* Correlations in 2-col */
  #correlations-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  #correlations-content .corr-card { margin-bottom: 0; }
  #correlations-content > div:first-child { grid-column: 1 / -1; }
}

/* ─── COACH DASHBOARD ─── */
.client-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  transition: background 0.3s;
}

.client-card.inactive {
  border-left: 3px solid var(--accent4);
}

.client-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.client-card-name {
  display: flex;
  align-items: center;
  gap: 8px;
}

.client-card-name .user-avatar {
  width: 32px;
  height: 32px;
  font-size: 12px;
}

.client-card-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 8px;
}

.client-stat {
  text-align: center;
  padding: 6px;
  background: var(--bg3);
  border-radius: var(--radius-sm);
}

.client-stat-label {
  font-size: 9px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.client-stat-value {
  font-family: 'DM Serif Display', serif;
  font-size: 18px;
  color: var(--text);
  margin-top: 2px;
}

.client-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}

.client-actions button {
  flex: 1;
  padding: 6px 8px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-size: 11px;
  cursor: pointer;
  font-family: 'DM Mono', monospace;
  transition: all 0.15s;
}
.client-actions button:hover { border-color: var(--accent); color: var(--accent); }

.inactive-badge {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(255,128,128,0.15);
  color: var(--accent4);
}

/* ─── COMMENTS ─── */
.comment-count {
  font-size: 11px;
  color: var(--text3);
  margin-left: auto;
}

.comment-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.comment-item:last-child { border-bottom: none; }

.comment-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.comment-author {
  font-size: 12px;
  font-weight: 500;
  color: var(--accent);
}

.comment-date {
  font-size: 10px;
  color: var(--text3);
}

.comment-text {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.5;
}

.comment-delete {
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 4px;
  transition: color 0.15s;
}
.comment-delete:hover { color: var(--accent4); }

.comment-add textarea {
  min-height: 50px;
  resize: vertical;
}

/* ─── PERIODS ─── */
.period-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.period-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.period-card-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.period-type-badge {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  flex-shrink: 0;
}
.period-type-badge.dopust { background: rgba(127,216,190,0.15); color: var(--accent2); }
.period-type-badge.bolezen { background: rgba(255,128,128,0.15); color: var(--accent4); }
.period-type-badge.stres { background: rgba(255,181,107,0.15); color: var(--accent3); }
.period-type-badge.izziv { background: rgba(200,180,255,0.15); color: var(--accent); }
.period-type-badge.drugo { background: rgba(128,200,255,0.15); color: var(--accent5); }

.period-card-label {
  font-size: 13px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.period-card-dates {
  font-size: 11px;
  color: var(--text3);
  margin-top: 2px;
}

/* ─── COMPARISON ─── */
.compare-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
}

.compare-table th,
.compare-table td {
  padding: 8px 10px;
  text-align: center;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
}

.compare-table th {
  color: var(--text3);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: normal;
}

.compare-table td:first-child {
  text-align: left;
  color: var(--text2);
}

.compare-table .diff-positive { color: var(--accent2); }
.compare-table .diff-negative { color: var(--accent4); }
.compare-table .diff-neutral { color: var(--text3); }

/* ─── QUICK ENTRY ─── */
.quick-entry-toggle {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-bottom: 12px;
}

.quick-entry-toggle .toggle-label {
  font-size: 12px;
}

.log-grid.quick-mode .section:not(.quick-visible) {
  display: none;
}

.log-grid.quick-mode .section.quick-visible .section-body > *:not(.quick-field) {
  display: none;
}

/* ─── REPORT ─── */
.report-summary {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.report-metric {
  background: var(--bg3);
  border-radius: var(--radius-sm);
  padding: 10px;
  text-align: center;
}

.report-metric-label {
  font-size: 10px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.report-metric-value {
  font-family: 'DM Serif Display', serif;
  font-size: 22px;
  color: var(--text);
  margin-top: 2px;
}

.report-metric-change {
  font-size: 10px;
  margin-top: 2px;
}

/* ─── CUSTOM METRICS ─── */
.custom-metric-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ─── PDF PRINT STYLES ─── */
@media print {
  body { background: white; color: black; overflow: visible; }
  #app { display: block !important; max-width: none; height: auto; overflow: visible; }
  nav, header, .viewing-banner, .save-btn, .comment-add, .period-actions,
  .quick-entry-toggle, .habit-add, .add-goal-btn, .goal-delete,
  .user-card-actions, .settings-row, #toast, #onboarding-overlay,
  .nav-user, .header-user, .header-right, .date-nav { display: none !important; }
  .app-content { display: block !important; }
  main { overflow: visible !important; height: auto !important; }
  .view { display: block !important; max-width: none; padding: 10px; }
  .view:not(.print-target) { display: none !important; }
  .section { break-inside: avoid; border: 1px solid #ddd; margin-bottom: 10px; }
  .stat-card { border: 1px solid #ddd; }
  .chart-wrap { break-inside: avoid; }
  * { color: black !important; background: white !important; border-color: #ddd !important; }
  .analysis-section-score, .role-badge, .period-type-badge, .inactive-badge,
  .corr-value { color: inherit !important; border: 1px solid #999 !important; }
}

@media (min-width: 768px) {
  .client-card-stats {
    grid-template-columns: repeat(5, 1fr);
  }

  .report-summary {
    grid-template-columns: repeat(4, 1fr);
  }

  .compare-table {
    max-width: 700px;
  }
}
