/* ── Reveal Animation System ──────────────────────────────────────────── */
@keyframes mcReveal {
  from { opacity: 0; transform: translateY(36px); }
  to   { opacity: 1; transform: translateY(0); }
}
.mc-hidden { opacity: 0 !important; }
.mc-in { animation: mcReveal .6s cubic-bezier(.16,.9,.3,1) both; }
@media (prefers-reduced-motion: reduce) {
  .mc-in { animation: none !important; }
  .mc-hidden { opacity: 1 !important; }
}

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Theme system ─────────────────────────────────────────────────────── */
:root {
  /* Dark (default) */
  --bg:           #0a0a0a;
  --bg-2:         #0e0e0e;
  --bg-3:         #141414;
  --bg-4:         #1a1a1a;
  --border:       #1e1e1e;
  --text:         #efefef;
  --text-muted:   #505050;
  --text-dim:     #888888;
  --accent-color: #6366f1;
  --accent:       var(--accent-color);
  --accent-dim:   color-mix(in srgb, var(--accent-color) 72%, #000);
  --green:        #22c55e;
  --blue:         #3b82f6;
  --purple:       #a855f7;
  --orange:       #f97316;
  --red:          #ef4444;
  --yellow:       #eab308;
  --radius:       10px;
  --sidebar-w:    248px;
}

[data-theme="light"] {
  --bg:         #ffffff;
  --bg-2:       #f0f0f0;
  --bg-3:       #e8e8e8;
  --bg-4:       #d8d8d8;
  --border:     #d0d0d0;
  --text:       #111111;
  --text-muted: #666666;
  --text-dim:   #888888;
}

/* ── Light theme: card & container backgrounds ─────────────────────────── */
[data-theme="light"] .mc,
[data-theme="light"] .chart-card,
[data-theme="light"] .hchip,
[data-theme="light"] .hero-card,
[data-theme="light"] .dcard,
[data-theme="light"] .goal-card,
[data-theme="light"] .deload-card,
[data-theme="light"] .tbl-wrap,
[data-theme="light"] .kpi,
[data-theme="light"] .sess-card,
[data-theme="light"] .sc-sets,
[data-theme="light"] .km,
[data-theme="light"] .phase-card,
[data-theme="light"] .cmp-card,
[data-theme="light"] .pr-card,
[data-theme="light"] .ex-card,
[data-theme="light"] .wstat,
[data-theme="light"] .dfactor,
[data-theme="light"] .sc-ex,
[data-theme="light"] .ab-card,
[data-theme="light"] .wtag,
[data-theme="light"] .set-pill,
[data-theme="light"] .scan-tag,
[data-theme="light"] .streak {
  background: var(--bg-2) !important;
  border-color: var(--border) !important;
  color: var(--text) !important;
}

/* ── Light theme: interactive elements ─────────────────────────────────── */
[data-theme="light"] .view-tabs {
  background: var(--bg-3) !important;
  border-color: var(--border) !important;
}
[data-theme="light"] .vtab { color: var(--text-dim) !important; }
[data-theme="light"] .vtab.active {
  background: var(--bg-2) !important;
  color: var(--text) !important;
}
[data-theme="light"] .goal-btn {
  background: var(--bg-2) !important;
  border-color: var(--border) !important;
  color: var(--text-dim) !important;
}
[data-theme="light"] .goal-btn.active {
  background: var(--bg-3) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}
[data-theme="light"] .goal-input {
  background: var(--bg-2) !important;
  border-color: var(--border) !important;
  color: var(--text) !important;
}
[data-theme="light"] .sync-btn {
  background: var(--bg-2) !important;
  border-color: var(--border) !important;
  color: var(--text-dim) !important;
}

/* ── Light theme: progress / bar backgrounds ───────────────────────────── */
[data-theme="light"] .zone-bar-wrap,
[data-theme="light"] .readiness-bar,
[data-theme="light"] .mbar,
[data-theme="light"] .sc-bar-wrap,
[data-theme="light"] .goal-bar-wrap,
[data-theme="light"] .ring-bg,
[data-theme="light"] .hc-ring-bg {
  stroke: var(--bg-3) !important;
  background: var(--bg-3) !important;
}

/* ── Light theme: table hover ──────────────────────────────────────────── */
[data-theme="light"] .hist-table tr:hover td,
[data-theme="light"] .tbl-wrap tr:hover td {
  background: var(--bg-3) !important;
}
[data-theme="light"] .tbl-wrap th {
  background: var(--bg-2) !important;
  color: var(--text-muted) !important;
  border-color: var(--border) !important;
}
[data-theme="light"] .tbl-wrap td {
  border-color: var(--bg-3) !important;
  color: var(--text) !important;
}

/* ── Light theme: text overrides ────────────────────────────────────────── */
[data-theme="light"] .mc-val,
[data-theme="light"] .mc-lbl,
[data-theme="light"] .mc-sub,
[data-theme="light"] .hchip-val,
[data-theme="light"] .hchip-label,
[data-theme="light"] .hchip-trend,
[data-theme="light"] .hchip-unit,
[data-theme="light"] .chart-head,
[data-theme="light"] .sh2,
[data-theme="light"] .page-title,
[data-theme="light"] .page-sub,
[data-theme="light"] .hc-ring-num,
[data-theme="light"] .hc-ring-unit,
[data-theme="light"] .hc-sub,
[data-theme="light"] .hc-delta,
[data-theme="light"] .weight-val,
[data-theme="light"] .weight-lbl,
[data-theme="light"] .kcal-big,
[data-theme="light"] .kcal-lbl,
[data-theme="light"] .macro-name,
[data-theme="light"] .macro-vals,
[data-theme="light"] .dcard-title,
[data-theme="light"] .dcard-right,
[data-theme="light"] .prognose,
[data-theme="light"] .hc-label {
  color: var(--text) !important;
}

[data-theme="light"] body,
[data-theme="light"] .layout-main {
  color: var(--text);
}

[data-theme="midnight"] {
  --bg:         #080c14;
  --bg-2:       #0d1220;
  --bg-3:       #111928;
  --bg-4:       #1a2440;
  --border:     #1e2d52;
  --text:       #d8e4ff;
  --text-muted: #4a5880;
  --text-dim:   #7a8aaa;
}

[data-theme="forest"] {
  --bg:         #080f0a;
  --bg-2:       #0d150f;
  --bg-3:       #111e14;
  --bg-4:       #1a2e1d;
  --border:     #1e3524;
  --text:       #d4edd8;
  --text-muted: #4a6850;
  --text-dim:   #7a9880;
}

html, body { height: 100%; font-family: 'Inter', system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }

a { color: inherit; text-decoration: none; }

/* ---- Layout ---- */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
/* Sidebar keeps its own dark variables regardless of active theme */
.sidebar {
  --bg-2:       #0e0e0e;
  --bg-3:       #141414;
  --bg-4:       #1a1a1a;
  --border:     #1e1e1e;
  --text:       #efefef;
  --text-muted: #505050;
  --text-dim:   #888888;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 0;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}

.logo-mark {
  color: var(--accent);
  flex-shrink: 0;
}

.logo-text {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text);
}

.nav-links {
  list-style: none;
  padding: 12px 10px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 14px;
  transition: background 0.15s, color 0.15s;
}

.nav-link:hover {
  background: var(--bg-3);
  color: var(--text);
}

.nav-link.active {
  background: var(--bg-4);
  color: var(--text);
}

.nav-link svg { flex-shrink: 0; }

.sidebar-footer {
  padding: 14px 12px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

.user-details {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.user-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.btn-logout {
  padding: 6px;
  border-radius: 6px;
  color: var(--text-muted);
  transition: color 0.15s, background 0.15s;
  display: flex;
}

.btn-logout:hover { background: var(--bg-4); color: var(--text); }

/* ---- Main content ---- */
.main-content {
  padding: 32px 36px;
  min-height: 100vh;
  overflow-y: auto;
}

/* ---- Page header ---- */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
}

.page-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.page-sub {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 3px;
}

/* ---- Buttons ---- */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 13px;
  border: none;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

.btn-primary:hover { background: var(--accent-dim); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary.btn-lg { padding: 12px 24px; font-size: 15px; }

/* ---- Stats grid ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 36px;
}

.stat-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color 0.15s;
}

.stat-card:hover { border-color: var(--accent); }

.stat-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-icon-green  { background: rgba(34,197,94,.12); color: var(--green); }
.stat-icon-blue   { background: rgba(59,130,246,.12); color: var(--blue); }
.stat-icon-purple { background: rgba(168,85,247,.12); color: var(--purple); }
.stat-icon-orange { background: rgba(249,115,22,.12); color: var(--orange); }

.stat-body {
  display: flex;
  align-items: baseline;
  gap: 4px;
  flex-wrap: wrap;
}

.stat-label {
  width: 100%;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.stat-value {
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -1px;
}

.stat-unit {
  font-size: 13px;
  color: var(--text-muted);
}

.stat-sub {
  font-size: 12px;
  color: var(--text-muted);
}

/* ---- Quick links ---- */
.section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.quick-links {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.quick-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
  transition: border-color 0.15s, background 0.15s;
}

.quick-card:hover { border-color: var(--accent); background: var(--bg-3); }

.quick-icon { font-size: 18px; }

.quick-arrow { margin-left: auto; color: var(--text-muted); }

/* ---- Table ---- */
.table-container {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--bg-3); }

.score-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.score-green  { background: rgba(34,197,94,.15); color: var(--green); }
.score-yellow { background: rgba(234,179,8,.15);  color: var(--yellow); }
.score-red    { background: rgba(239,68,68,.15);  color: var(--red); }

/* ---- Empty state ---- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 80px 20px;
  color: var(--text-muted);
  text-align: center;
}

.empty-icon { font-size: 48px; }

/* ---- Flash messages ---- */
.flash-container { margin-bottom: 20px; display: flex; flex-direction: column; gap: 8px; }

.flash {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
}

.flash-success { background: rgba(34,197,94,.15); color: var(--green); border: 1px solid rgba(34,197,94,.2); }
.flash-error   { background: rgba(239,68,68,.15);  color: var(--red);   border: 1px solid rgba(239,68,68,.2); }
.flash-info    { background: rgba(59,130,246,.15); color: var(--blue);  border: 1px solid rgba(59,130,246,.2); }

/* ---- Landing page ---- */
.landing {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(108,99,255,.2), transparent);
}

.landing-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
  max-width: 480px;
  padding: 40px 24px;
}

.logo-mark-lg {
  font-size: 48px;
  color: var(--accent);
  display: block;
  line-height: 1;
}

.landing-title {
  font-size: 48px;
  font-weight: 800;
  letter-spacing: -2px;
}

.landing-subtitle {
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1.6;
  margin-bottom: 8px;
}

.landing-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ---- Toast notifications ---- */
#toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-4);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  z-index: 1000;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}

#toast.show { opacity: 1; transform: translateY(0); }
#toast.toast-success { border-color: rgba(34,197,94,.3); color: var(--green); }
#toast.toast-error   { border-color: rgba(239,68,68,.3);  color: var(--red); }

/* ---- Tabs ---- */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  border-radius: 8px 8px 0 0;
  border: 1px solid transparent;
  border-bottom: none;
  margin-bottom: -1px;
  transition: color 0.15s, background 0.15s;
}

.tab-btn:hover { color: var(--text); background: var(--bg-3); }

.tab-active {
  color: var(--text) !important;
  background: var(--bg-2) !important;
  border-color: var(--border) !important;
}

/* ---- Health / Blutwerte ---- */
.blood-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.bscore {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.bscore-green  { background: rgba(34,197,94,.12); color: var(--green); }
.bscore-yellow { background: rgba(234,179,8,.12);  color: var(--yellow); }
.bscore-red    { background: rgba(239,68,68,.12);  color: var(--red); }
.bscore-date   { margin-left: auto; font-size: 12px; color: var(--text-muted); }

.health-group { margin-bottom: 24px; }

.health-group-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.marker-name { font-weight: 500; }
.marker-val  { font-weight: 600; font-variant-numeric: tabular-nums; }
.ref-range   { font-size: 12px; color: var(--text-muted); }
.text-muted  { color: var(--text-muted); font-size: 12px; }

.ampel {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
}

.ampel-green  { color: var(--green); }
.ampel-yellow { color: var(--yellow); }
.ampel-red    { color: var(--red); }

.hist-badge {
  display: inline-block;
  background: var(--bg-4);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 10px;
  color: var(--text-muted);
  margin-left: 4px;
}

/* ---- InBody ---- */
.inbody-latest { }

.inbody-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.inbody-date {
  font-size: 13px;
  color: var(--text-muted);
  background: var(--bg-3);
  border: 1px solid var(--border);
  padding: 5px 12px;
  border-radius: 20px;
}

.fitness-score {
  font-size: 13px;
  color: var(--text-muted);
}

.fitness-score strong {
  color: var(--accent);
  font-size: 18px;
  font-weight: 700;
}

.inbody-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.ib-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: border-color 0.15s;
}

.ib-card:hover   { border-color: var(--accent); }
.ib-card-hi      { border-color: rgba(108,99,255,.3); }

.ib-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.ib-value {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1;
}

.ib-unit { font-size: 13px; font-weight: 400; color: var(--text-muted); }

.health-upload-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-2);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 10px 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.health-upload-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  white-space: nowrap;
}

.health-upload-label:hover { border-color: var(--accent); background: var(--bg-4); }

.health-upload-hint { font-size: 12px; color: var(--text-muted); }

.health-upload-status { font-size: 12px; font-weight: 500; margin-left: auto; }

.scan-row:hover td { background: var(--bg-3); }
.scan-row-active td { background: rgba(108,99,255,.08) !important; }
.scan-row-active td:first-child { border-left: 3px solid var(--accent); }

/* ---- Nutrition ---- */
.macro-val { font-weight: 600; }
.macro-unit { font-size: 11px; color: var(--text-muted); margin-left: 2px; }

.macro-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: middle;
}

.macro-protein { background: var(--blue); }
.macro-carbs   { background: var(--orange); }
.macro-fat     { background: var(--yellow); }

.import-hint {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 12px;
}

.import-hint code {
  font-family: monospace;
  color: var(--accent);
  font-size: 11px;
}

.empty-sub {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.8;
  margin-top: 4px;
}

.empty-sub code {
  font-family: monospace;
  background: var(--bg-3);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--accent);
}

/* ---- Gym ---- */
.exercise-list { display: flex; flex-wrap: wrap; gap: 4px; }

.exercise-tag {
  display: inline-block;
  padding: 2px 7px;
  background: var(--bg-4);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
}

.exercise-tag-more { color: var(--text-muted); border-style: dashed; }

.workout-title { font-weight: 500; }

.volume { font-variant-numeric: tabular-nums; }

/* ---- Pagination ---- */
.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 16px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.page-btn {
  display: inline-flex;
  align-items: center;
  padding: 6px 11px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.page-btn:hover { background: var(--bg-4); color: var(--text); }
.page-btn-active { background: var(--accent) !important; color: #fff !important; }
.page-btn-disabled { opacity: 0.35; pointer-events: none; }

.page-info {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-muted);
}

/* ---- Documents ---- */
.upload-card {
  display: flex;
  gap: 20px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  margin-bottom: 28px;
  align-items: flex-start;
}

.upload-icon {
  width: 52px; height: 52px;
  background: rgba(108,99,255,.12);
  color: var(--accent);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.upload-body { flex: 1; }
.upload-title { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.upload-sub   { font-size: 13px; color: var(--text-muted); margin-bottom: 14px; }

.upload-controls {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
}

.file-input {
  font-size: 13px; color: var(--text-muted);
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 7px 10px;
  cursor: pointer;
}

.select-sm {
  background: var(--bg-3); border: 1px solid var(--border);
  color: var(--text); border-radius: var(--radius);
  padding: 7px 10px; font-size: 13px; cursor: pointer;
}

.upload-status {
  margin-top: 10px; font-size: 13px; min-height: 18px;
  border-radius: 6px; padding: 0 4px;
}

.status-info    { color: var(--text-muted); }
.status-success { color: var(--green); }
.status-error   { color: var(--red); }

.doc-list { display: flex; flex-direction: column; gap: 12px; }

.doc-item {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 12px; padding: 18px;
  transition: border-color 0.15s;
}

.doc-item:hover { border-color: var(--accent); }

.doc-meta {
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap; margin-bottom: 10px;
}

.doc-type-badge {
  padding: 2px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
}

.doc-type-inbody  { background: rgba(108,99,255,.15); color: var(--accent); }
.doc-type-blood   { background: rgba(239,68,68,.12);  color: var(--red); }
.doc-type-other   { background: var(--bg-4); color: var(--text-muted); }

.doc-name  { font-weight: 500; font-size: 14px; }
.doc-date  { font-size: 12px; color: var(--text-muted); margin-left: auto; }

.imported-badge {
  font-size: 11px; font-weight: 600; color: var(--green);
  background: rgba(34,197,94,.12); padding: 2px 8px; border-radius: 20px;
}

.doc-summary {
  font-size: 13px; color: var(--text-dim); line-height: 1.6;
  margin-bottom: 10px; background: var(--bg-3);
  border-radius: 8px; padding: 12px 14px;
  border-left: 3px solid var(--accent);
}

.btn-ghost {
  background: transparent; border: 1px solid var(--border);
  color: var(--text-muted); border-radius: 6px; cursor: pointer;
  font-size: 12px; padding: 4px 10px; transition: all 0.15s;
}
.btn-ghost:hover { background: var(--bg-4); color: var(--text); }
.btn-sm { padding: 4px 10px; font-size: 12px; }

.doc-json {
  margin-top: 10px; background: var(--bg-3); border: 1px solid var(--border);
  border-radius: 8px; padding: 12px; font-size: 11px;
  color: var(--text-muted); overflow-x: auto; white-space: pre-wrap;
  max-height: 300px; overflow-y: auto;
}

/* ---- Collapsible nav groups ---- */
.nav-group { }

.nav-group-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 14px;
  font-family: inherit;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.nav-group-btn:hover {
  background: var(--bg-3);
  color: var(--text);
}

.nav-group.open .nav-group-btn {
  color: var(--text);
}

.nav-group-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-chevron {
  flex-shrink: 0;
  transition: transform 0.2s ease;
  color: var(--text-muted);
}

.nav-group.open .nav-chevron {
  transform: rotate(180deg);
}
.nav-chevron { display: none; }

.nav-sub {
  list-style: none;
  position: fixed;
  left: var(--sidebar-w);
  top: 0;
  width: 190px;
  background: #111;
  border: 1px solid #1e1e1e;
  border-radius: 10px;
  padding: 6px;
  box-shadow: 8px 4px 32px rgba(0,0,0,.7);
  opacity: 0;
  pointer-events: none;
  transform: translateX(-6px);
  transition: opacity .15s ease, transform .15s ease;
  z-index: 9999;
}

.nav-sub.flyout-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

.nav-sub-link {
  display: block;
  padding: 8px 12px;
  border-radius: 7px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 400;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.nav-sub-link:hover {
  background: var(--bg-3);
  color: var(--text);
}

.nav-sub-link.active {
  color: var(--accent);
  font-weight: 500;
}

/* ---- Floating Chat Widget ---- */
#chat-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 900;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}

.chat-fab {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px color-mix(in srgb, var(--accent-color) 45%, transparent);
  transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
  flex-shrink: 0;
}

.chat-fab:hover {
  background: var(--accent-dim);
  transform: scale(1.07);
  box-shadow: 0 6px 28px color-mix(in srgb, var(--accent-color) 55%, transparent);
}

.chat-fab.open {
  background: var(--bg-4);
  box-shadow: 0 4px 12px rgba(0,0,0,.35);
}

.chat-window[hidden] { display: none !important; }

.chat-window {
  width: 380px;
  height: 520px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 16px 48px rgba(0,0,0,.45);
  animation: chat-in 0.18s ease;
}

@keyframes chat-in {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-3);
  flex-shrink: 0;
}

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

.chat-header-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(108,99,255,.18);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chat-header-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}

.chat-header-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.chat-header-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  transition: color 0.15s, background 0.15s;
}

.chat-header-close:hover { background: var(--bg-4); color: var(--text); }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 6px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-welcome {
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  padding: 16px 8px 8px;
  line-height: 1.6;
}

.chat-welcome strong {
  display: block;
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 600;
  margin-bottom: 5px;
}

.chat-msg {
  display: flex;
  max-width: 90%;
}

.chat-msg-user      { align-self: flex-end; }
.chat-msg-assistant { align-self: flex-start; }

.chat-bubble {
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.55;
  word-break: break-word;
}

.chat-bubble-user {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-bubble-assistant {
  background: var(--bg-3);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.chat-bubble-assistant code {
  background: var(--bg-4);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 12px;
  font-family: monospace;
}

.chat-bubble-assistant strong { font-weight: 600; }
.chat-bubble-assistant em     { font-style: italic; color: var(--text-dim); }

.chat-bubble-assistant ul {
  padding-left: 16px;
  margin: 4px 0;
}

.chat-bubble-assistant li { margin: 2px 0; }

/* Typing dots */
.chat-typing-bubble {
  padding: 11px 14px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  display: inline-flex;
  gap: 5px;
  align-items: center;
}

.chat-typing-bubble span {
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: chat-dot 1.2s ease-in-out infinite;
}

.chat-typing-bubble span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing-bubble span:nth-child(3) { animation-delay: 0.4s; }

@keyframes chat-dot {
  0%, 80%, 100% { transform: scale(0.75); opacity: 0.4; }
  40%           { transform: scale(1.1);  opacity: 1; }
}

.chat-footer {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: var(--bg-2);
  align-items: flex-end;
  flex-shrink: 0;
}

.chat-input {
  flex: 1;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  padding: 8px 11px;
  resize: none;
  line-height: 1.45;
  max-height: 112px;
  overflow-y: auto;
  transition: border-color 0.15s;
}

.chat-input:focus        { outline: none; border-color: var(--accent); }
.chat-input::placeholder { color: var(--text-muted); }

.chat-send-btn {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, opacity 0.15s;
}

.chat-send-btn:hover    { background: var(--accent-dim); }
.chat-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---- Dashboard ---- */

.db-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
}

.db-greeting {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.4px;
  line-height: 1.2;
}

.db-date {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 3px;
}

/* Hero row */
.db-hero {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 14px;
}

.db-hero-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px 22px 18px;
  transition: border-color 0.15s;
}

.db-hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.db-hero-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-muted);
}

.db-hero-num {
  display: flex;
  align-items: baseline;
  gap: 5px;
  margin-bottom: 6px;
}

.db-hero-val {
  font-size: 52px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -2px;
  transition: color 0.2s;
}

.db-hero-unit {
  font-size: 16px;
  font-weight: 400;
  color: var(--text-muted);
}

.db-hero-sub {
  font-size: 12px;
  color: var(--text-muted);
  min-height: 16px;
}

/* Trend arrows */
.db-t-up { font-size: 12px; font-weight: 600; color: var(--green); }
.db-t-dn { font-size: 12px; font-weight: 600; color: var(--red); }

/* Generic card */
.db-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px 22px;
  margin-bottom: 14px;
}

.db-card-hd {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.db-card-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-muted);
  flex: 1;
}

.db-card-meta {
  font-size: 12px;
  color: var(--text-muted);
}

/* Score pill */
.db-score-pill {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  background: var(--bg-4);
  color: var(--text-muted);
}

.db-pill-green  { background: rgba(34,197,94,.15);  color: var(--green); }
.db-pill-yellow { background: rgba(234,179,8,.15);  color: var(--yellow); }
.db-pill-red    { background: rgba(239,68,68,.15);  color: var(--red); }

/* Sleep card */
.db-sleep-card { margin-bottom: 14px; }

.db-sleep-bar-wrap {
  margin-bottom: 14px;
}

.db-sleep-bar {
  display: flex;
  height: 14px;
  border-radius: 7px;
  overflow: hidden;
  background: var(--bg-4);
  gap: 2px;
}

.db-seg {
  height: 100%;
  transition: width 0.5s cubic-bezier(.4,0,.2,1);
  border-radius: 2px;
}

.db-seg-light { background: #3b82f6; }
.db-seg-sws   { background: #8b5cf6; }
.db-seg-rem   { background: #06b6d4; }
.db-seg-awake { background: var(--bg-4); border: 1px solid var(--border); }

.db-sleep-legend {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.db-leg-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.db-leg-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.db-leg-label {
  font-size: 12px;
  color: var(--text-muted);
}

.db-leg-val {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.db-sleep-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.db-sleep-footer strong { color: var(--text); font-weight: 600; }
.db-sep { color: var(--border); }

/* 2-col grid */
.db-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.db-grid-2 .db-card { margin-bottom: 0; }

/* Training blocks */
.db-block { padding: 4px 0 10px; }

.db-block-eyebrow {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.db-block-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.db-block-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.db-block-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
}

/* Strain badge */
.db-strain-badge {
  flex-shrink: 0;
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1;
}

.db-strain-green  { background: rgba(34,197,94,.12);  color: var(--green); }
.db-strain-yellow { background: rgba(234,179,8,.12);  color: var(--yellow); }
.db-strain-orange { background: rgba(249,115,22,.12); color: var(--orange); }
.db-strain-red    { background: rgba(239,68,68,.12);  color: var(--red); }

/* Volume badge */
.db-vol-badge {
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
}

.db-divider {
  height: 1px;
  background: var(--border);
  margin: 10px 0 14px;
}

/* Exercise pills */
.db-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 10px;
}

.db-pill {
  display: inline-block;
  padding: 2px 8px;
  background: var(--bg-4);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
}

/* Nutrition */
.db-kcal-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 18px;
}

.db-kcal-val {
  font-size: 40px;
  font-weight: 800;
  letter-spacing: -1.5px;
  line-height: 1;
  color: var(--text);
}

.db-kcal-unit {
  font-size: 14px;
  color: var(--text-muted);
}

.db-macros {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.db-macro-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.db-macro-label {
  font-size: 12px;
  color: var(--text-muted);
  width: 52px;
  flex-shrink: 0;
}

.db-macro-track {
  flex: 1;
  height: 6px;
  background: var(--bg-4);
  border-radius: 3px;
  overflow: hidden;
}

.db-macro-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s cubic-bezier(.4,0,.2,1);
}

.db-macro-val {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  width: 58px;
  text-align: right;
  flex-shrink: 0;
}

.db-weight-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
}

.db-weight-row strong { color: var(--text); font-weight: 600; }

/* Clickable hero cards */
.db-hero-clickable {
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: block;
}

.db-hero-clickable:hover {
  background: var(--bg-3);
  border-color: var(--accent);
}

.db-hero-selected {
  border-color: var(--accent) !important;
  background: var(--bg-3);
}

.db-hero-expand-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
  transition: color 0.15s;
}

.db-hero-clickable:hover .db-hero-expand-hint {
  color: var(--accent);
}

/* Recovery detail panel */
.db-detail-panel {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 22px;
  margin-top: -8px;
  margin-bottom: 14px;
  animation: detail-in 0.18s ease;
}

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

.db-detail-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 14px;
}

.db-detail-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.db-detail-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
}

.db-detail-val {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.8px;
  line-height: 1;
  color: var(--text);
}

.db-detail-unit {
  font-size: 12px;
  color: var(--text-muted);
}

.db-detail-trend {
  font-size: 12px;
  font-weight: 600;
  min-height: 16px;
}

.db-detail-link {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  font-weight: 500;
  color: var(--accent);
  transition: opacity 0.15s;
}

.db-detail-link:hover { opacity: 0.75; }

/* HR Zones Chart.js */
.db-zones-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin: 14px 0 10px;
}

.db-zones-est {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  background: var(--bg-4);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
}

.db-zones-chart-wrap {
  position: relative;
  height: 210px;
}

/* ---- Whoop-style workout metrics ---- */
.whoop-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin-top: 16px;
}

.whoop-metric {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 10px 12px;
  border-right: 1px solid var(--border);
  gap: 4px;
  transition: background 0.15s;
}

.whoop-metric:last-child { border-right: none; }
.whoop-metric:hover { background: var(--bg-3); }

.wm-icon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 2px;
}

.wm-icon-orange { background: rgba(249,115,22,.15); color: var(--orange); }
.wm-icon-blue   { background: rgba(59,130,246,.15);  color: var(--blue); }
.wm-icon-red    { background: rgba(239,68,68,.15);   color: var(--red); }
.wm-icon-dim    { background: var(--bg-4);            color: var(--text-muted); }

.wm-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-muted);
}

.wm-num {
  display: flex;
  align-items: baseline;
  gap: 2px;
}

.wm-val {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text);
}

.wm-unit {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 500;
}

/* ── Snippet card classes (dash-card) ── */
.dash-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px 22px;
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.card-icon { font-size: 14px; }

.card-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.7px;
  color: var(--text-muted);
}

.card-right { color: var(--text-muted); }

/* ── Nutrition card (Gauge redesign) ── */
.nu-card { }

.nu-body {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 22px;
  align-items: center;
}

/* Left column: Eaten */
.nu-eaten {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
}

.nu-eaten-num {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.nu-eaten-val {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -1.5px;
  line-height: 1;
  color: var(--text);
}

.nu-eaten-unit {
  font-size: 13px;
  color: var(--text-muted);
}

.nu-eaten-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
}


/* Middle column: Gauge */
.nu-gauge-wrap {
  flex-shrink: 0;
}

/* Right column: Macro bars */
.nu-macros {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding-left: 4px;
}

.nu-macro-hd {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}

.nu-macro-name {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.nu-macro-vals {
  display: flex;
  align-items: baseline;
  gap: 1px;
}

.nu-macro-cur {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}

.nu-macro-goal {
  font-size: 10px;
  color: var(--text-muted);
}

.nu-macro-track {
  height: 5px;
  background: var(--bg-4);
  border-radius: 3px;
  overflow: hidden;
}

.nu-macro-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.8s cubic-bezier(.4,0,.2,1);
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-4); border-radius: 3px; }

/* ---- Sidebar flyout — always dark (inherits sidebar vars) ---- */
#sidebar-flyout {
  --bg-2:       #0e0e0e;
  --bg-3:       #141414;
  --border:     #1e1e1e;
  --text:       #efefef;
  --text-muted: #505050;
  background: var(--bg-2) !important;
  border: 1px solid var(--border) !important;
  box-shadow: 8px 4px 32px rgba(0,0,0,.6) !important;
}

#sidebar-flyout .nav-sub-link {
  color: var(--text-muted);
}

#sidebar-flyout .nav-sub-link:hover {
  background: var(--bg-3);
  color: var(--text);
}

#sidebar-flyout .nav-sub-link.active {
  color: var(--accent);
  font-weight: 500;
}

/* ---- Sidebar theme toggle icon ---- */
.sidebar-theme-btn .icon-sun  { display: none; }
.sidebar-theme-btn .icon-moon { display: block; }
[data-theme="light"] .sidebar-theme-btn .icon-sun  { display: block; }
[data-theme="light"] .sidebar-theme-btn .icon-moon { display: none; }

/* ---- Settings page ---- */
.settings-section { margin-bottom: 36px; }

.settings-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.settings-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 12px;
}

.settings-card-full {
  align-items: flex-start;
  flex-direction: column;
  gap: 18px;
}

.settings-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 3px;
}

.settings-sub {
  font-size: 13px;
  color: var(--text-muted);
}

/* Mode toggle */
.mode-toggle {
  display: flex;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
  gap: 4px;
  flex-shrink: 0;
}

.mode-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  font-family: inherit;
}

.mode-btn.active {
  background: var(--bg-2);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0,0,0,.12);
}

[data-theme="light"] .mode-btn.active {
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}

/* Color swatches */
.color-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.color-swatch {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.1s, border-color 0.15s;
  flex-shrink: 0;
  position: relative;
}

.color-swatch:hover {
  transform: scale(1.12);
}

.color-swatch.selected {
  border-color: var(--text);
}

.color-swatch.selected::after {
  content: '';
  position: absolute;
  inset: 3px;
  border-radius: 4px;
  border: 2px solid rgba(255,255,255,.6);
  pointer-events: none;
}

.color-swatch[data-color="#ffffff"] {
  border-color: var(--border);
}

.color-swatch[data-color="#ffffff"].selected {
  border-color: var(--text-muted);
}

.color-custom-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.color-custom-label {
  font-size: 12px;
  color: var(--text-muted);
}

.color-custom-input {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 2px solid var(--border);
  cursor: pointer;
  padding: 2px;
  background: var(--bg-3);
}

.color-hex-input {
  background: var(--bg-3);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 11px;
  font-size: 13px;
  font-family: monospace;
  width: 96px;
  transition: border-color 0.15s;
}

.color-hex-input:focus {
  outline: none;
  border-color: var(--accent);
}

.settings-preview {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 6px;
  flex-wrap: wrap;
}

.preview-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--accent);
  color: #fff;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.preview-link {
  font-size: 13px;
  color: var(--accent);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.preview-active-nav {
  font-size: 13px;
  font-weight: 500;
  color: var(--accent);
  background: var(--bg-4);
  border-radius: 7px;
  padding: 5px 10px;
}

/* Light mode adjustments for cards that use hardcoded dark shading */
[data-theme="light"] .stat-card,
[data-theme="light"] .db-hero-card,
[data-theme="light"] .db-card,
[data-theme="light"] .quick-card,
[data-theme="light"] .table-container,
[data-theme="light"] .upload-card,
[data-theme="light"] .doc-item,
[data-theme="light"] .settings-card {
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

[data-theme="light"] .chat-fab {
  box-shadow: 0 4px 20px rgba(0,0,0,.18);
}

[data-theme="light"] .landing {
  background-image: radial-gradient(ellipse 80% 50% at 50% -10%, rgba(108,99,255,.1), transparent);
}

/* ---- Sidebar brand icons (Hevy, Yazio etc.) ---- */
.sidebar-brand-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  filter: brightness(0) invert(1);
  opacity: 0.6;
  transition: opacity 0.15s;
}

.nav-link:hover .sidebar-brand-icon,
.nav-group-btn:hover .sidebar-brand-icon,
a.nav-group-btn:hover .sidebar-brand-icon,
.nav-link.active .sidebar-brand-icon {
  opacity: 0.95;
}


/* ---- Chat Confirm Action ---- */
.chat-confirm {
  background: rgba(59,130,246,0.06);
  border: 1px solid rgba(59,130,246,0.2);
  border-radius: 12px;
  padding: 14px 16px;
  margin: 8px 0;
}
.chat-confirm-text {
  font-size: 13px;
  color: #bbb;
  margin-bottom: 12px;
  line-height: 1.5;
}
.chat-confirm-buttons { display: flex; gap: 8px; }
.btn-confirm-yes {
  padding: 8px 16px; border-radius: 8px; border: 1px solid #22c55e;
  background: rgba(34,197,94,0.1); color: #22c55e;
  font-size: 13px; font-weight: 600; cursor: pointer; transition: all .15s;
}
.btn-confirm-yes:hover { background: rgba(34,197,94,0.2); }
.btn-confirm-no {
  padding: 8px 16px; border-radius: 8px; border: 1px solid #333;
  background: transparent; color: #555;
  font-size: 13px; font-weight: 600; cursor: pointer; transition: all .15s;
}
.btn-confirm-no:hover { color: #888; border-color: #444; }



/* ═══ AI COMMAND PILL ═══ */
#ai-pill-wrapper {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
}

#ai-pill {
  position: relative;
  background: rgba(14,14,14,0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(99,102,241,0.25);
  border-radius: 26px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.5);
  cursor: pointer;
  overflow: hidden;
  width: 52px;
  max-height: 52px;
  min-height: 52px;
  display: flex;
  flex-direction: column;
  transition:
    width      .4s  cubic-bezier(0.25, 1, 0.5, 1),
    max-height .45s cubic-bezier(0.25, 1, 0.5, 1),
    border-radius .35s ease,
    border-color .3s ease,
    box-shadow .3s ease;
}

#ai-pill.expanded {
  width: 340px;
  max-height: 600px;
  border-radius: 20px;
  border-color: rgba(99,102,241,0.45);
  box-shadow:
    0 4px 32px rgba(0,0,0,0.6),
    0 0 0 3px rgba(99,102,241,0.08);
  cursor: default;
}

#ai-pill.collapsing {
  max-height: 52px !important;
  width: 52px !important;
  border-radius: 26px !important;
  transition:
    max-height .45s cubic-bezier(0.4, 0, 0.2, 1),
    width .4s cubic-bezier(0.4, 0, 0.2, 1),
    border-radius .35s ease !important;
}

#ai-pill.has-response {
  width: 360px;
  max-height: 600px;
  border-radius: 18px;
  border-color: rgba(99,102,241,0.5);
  box-shadow: 0 8px 40px rgba(0,0,0,0.7), 0 0 0 3px rgba(99,102,241,0.08);
  cursor: default;
}

#ai-pill.thinking {
  animation: pillPulse 1.5s ease infinite;
}

@keyframes pillPulse {
  0%,100% { border-color: rgba(99,102,241,0.4); box-shadow: 0 4px 24px rgba(0,0,0,0.5), 0 0 15px rgba(99,102,241,0.1); }
  50%      { border-color: rgba(139,92,246,0.7); box-shadow: 0 4px 32px rgba(0,0,0,0.6), 0 0 30px rgba(139,92,246,0.2); }
}

/* Response body */
#ai-pill-body {
  display: flex;
  flex-direction: column;
  padding: 0 18px;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition:
    max-height .7s cubic-bezier(0.25, 1, 0.5, 1),
    opacity .5s ease .15s,
    padding .5s ease;
}

#ai-pill.has-response #ai-pill-body {
  max-height: 400px;
  opacity: 1;
  padding: 16px 18px 12px;
}

#ai-pill-response-text {
  font-size: 15px;
  line-height: 1.8;
  color: #b0b0b0;
  white-space: pre-wrap;
  max-height: 280px;
  overflow-y: auto;
}

#ai-pill-response-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

#ai-pill-close {
  font-size: 11px;
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid #222;
  background: transparent;
  color: #444;
  cursor: pointer;
  font-family: inherit;
  transition: all .15s;
}
#ai-pill-close:hover { color: #666; border-color: #333; }

/* Divider */
#ai-pill-divider {
  height: 1px;
  background: rgba(255,255,255,0.05);
  margin: 0 18px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity .4s ease .5s;
}

#ai-pill.has-response #ai-pill-divider {
  opacity: 1;
}

/* Input row */
#ai-pill-main {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 16px;
  min-height: 52px;
  height: auto;
}

#ai-pill-icon {
  margin-top: 2px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  transition: transform .3s ease;
}

#ai-pill.expanded #ai-pill-icon,
#ai-pill.has-response #ai-pill-icon {
  transform: scale(0.85);
}

#ai-pill-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #e0e0e0;
  font-size: 15px;
  font-family: inherit;
  line-height: 1.5;
  resize: none;
  overflow-y: auto;
  min-height: 21px;
  max-height: none;
  padding: 0;
  margin: 0;
  display: block;
  opacity: 0;
  width: 0;
  pointer-events: none;
  transition: opacity .25s ease .15s;
}

#ai-pill.expanded #ai-pill-input,
#ai-pill.responding #ai-pill-input,
#ai-pill.has-response #ai-pill-input {
  opacity: 1;
  width: auto;
  pointer-events: all;
}

#ai-pill-input::placeholder { color: #383838; }

#ai-pill-send {
  margin-top: 1px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(99,102,241,0.1);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease .4s, background .15s;
}

#ai-pill.expanded #ai-pill-send,
#ai-pill.has-response #ai-pill-send {
  opacity: 1;
  pointer-events: all;
}

#ai-pill-send:hover { background: rgba(99,102,241,0.25); }

#ai-pill-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  background: #6366f1;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  pointer-events: none;
  z-index: 10;
}
#ai-pill-badge.visible { display: flex; }

#ai-pill-attach,
#ai-pill-mic {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(99,102,241,0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease .2s, background .15s;
}

#ai-pill.expanded #ai-pill-attach,
#ai-pill.expanded #ai-pill-mic,
#ai-pill.responding #ai-pill-attach,
#ai-pill.responding #ai-pill-mic {
  opacity: 1;
  pointer-events: all;
}

#ai-pill-attach:hover,
#ai-pill-mic:hover { background: rgba(99,102,241,0.2); }

#ai-pill-mic.recording {
  background: rgba(239,68,68,0.15);
  animation: micPulse 1s ease infinite;
}

@keyframes micPulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.3); }
  50%      { box-shadow: 0 0 0 6px rgba(239,68,68,0); }
}

#ai-pill-preview {
  padding: 8px 16px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

#ai-pill-preview img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid #222;
}

.pill-preview-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #111;
  border: 1px solid #222;
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 11px;
  color: #888;
}

.pill-preview-chip button {
  background: none;
  border: none;
  color: #555;
  cursor: pointer;
  font-size: 13px;
  padding: 0;
  line-height: 1;
}
