/* =========================================================================
   BluPosiVon Dashboard
   Editorial dark theme. Restrained palette. Fraunces (display) + Inter Tight
   (UI) + JetBrains Mono (numerics). Designed to match bluposivon.com.
   ========================================================================= */

:root {
  /* Surfaces */
  --bg:         #0a0c10;
  --bg-elev:    #11141b;
  --bg-elev-2:  #161a23;
  --bg-card:    #0f1218;

  /* Lines */
  --line:        #1e2230;
  --line-bright: #2a2f40;

  /* Ink */
  --ink:        #e8eaef;
  --ink-dim:    #9aa0ac;
  --ink-faint:  #6a6f7c;
  --ink-mute:   #4a4f5b;

  /* Accent — a cold blue-violet pulled from the brand, with sharp warm contrast */
  --accent:        #6c8cff;
  --accent-warm:   #ffb86b;
  --accent-soft:   rgba(108, 140, 255, 0.18);

  /* Status */
  --green:  #4ade80;
  --yellow: #fbbf24;
  --red:    #f87171;

  /* Pattern palette — 11 distinct, restrained hues */
  --p-push:      #6c8cff;
  --p-pull:      #ffb86b;
  --p-squat:     #4ade80;
  --p-hinge:     #f87171;
  --p-lunge:     #c084fc;
  --p-carry:     #fbbf24;
  --p-rotation:  #2dd4bf;
  --p-locomot:   #fb7185;
  --p-balance:   #a3e635;
  --p-flex:      #e879f9;
  --p-cardio:    #38bdf8;

  /* Typography */
  --font-display: 'Fraunces', Georgia, serif;
  --font-ui:      'Inter Tight', system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, monospace;

  /* Geometry */
  --rad-sm: 6px;
  --rad-md: 10px;
  --rad-lg: 14px;
  --gut: 24px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* Subtle grain to keep the dark surface from going flat */
body::before {
  content: '';
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--ink); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 32px;
  border-bottom: 1px solid var(--line);
  background: rgba(10, 12, 16, 0.85);
  backdrop-filter: blur(12px);
}
.brand {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 20px;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.brand-accent { color: var(--accent); font-style: italic; }
.topnav { display: flex; align-items: center; gap: 16px; }
.user-email { color: var(--ink-dim); font-size: 13px; font-family: var(--font-mono); }

/* ---------- Buttons ---------- */
.primary-btn {
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 15px;
  padding: 12px 20px;
  background: var(--ink);
  color: var(--bg);
  border: none;
  border-radius: var(--rad-sm);
  cursor: pointer;
  transition: transform .12s ease, background .15s ease;
}
.primary-btn:hover { background: var(--accent); color: var(--ink); transform: translateY(-1px); }
.ghost-btn {
  font-family: var(--font-ui);
  font-size: 13px;
  padding: 8px 14px;
  background: transparent;
  color: var(--ink-dim);
  border: 1px solid var(--line-bright);
  border-radius: var(--rad-sm);
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.ghost-btn:hover { color: var(--ink); border-color: var(--ink); }

/* ---------- Auth gate ---------- */
.auth-gate {
  min-height: 80vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 64px 32px;
}
.auth-card {
  max-width: 420px;
  width: 100%;
  padding: 40px;
  border: 1px solid var(--line);
  border-radius: var(--rad-lg);
  background: var(--bg-card);
}
.auth-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 56px;
  line-height: 1;
  letter-spacing: -0.025em;
  margin: 8px 0 16px;
  font-style: italic;
}
.auth-sub { color: var(--ink-dim); margin: 0 0 28px; }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form input {
  font-family: var(--font-ui); font-size: 15px;
  padding: 13px 16px;
  background: var(--bg-elev);
  color: var(--ink);
  border: 1px solid var(--line-bright);
  border-radius: var(--rad-sm);
  transition: border-color .15s;
}
.auth-form input:focus { outline: none; border-color: var(--accent); }
.auth-status { color: var(--ink-dim); font-size: 13px; margin-top: 16px; min-height: 1em; }
.auth-status.error { color: var(--red); }
.auth-status.success { color: var(--green); }

/* ---------- Eyebrow ---------- */
.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--accent);
  margin: 0;
}

/* ---------- Dashboard layout ---------- */
.dashboard {
  max-width: 1240px;
  margin: 0 auto;
  padding: 48px 32px 96px;
  position: relative;
  z-index: 2;
}

.hero { margin-bottom: 48px; }
.hero-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(40px, 6vw, 72px);
  line-height: 1;
  letter-spacing: -0.025em;
  margin: 12px 0 16px;
  font-style: italic;
}
.hero-title span { color: var(--accent); }
.hero-sub { color: var(--ink-dim); max-width: 60ch; margin: 0; }

/* ---------- Lifetime strip ---------- */
.strip {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--rad-lg);
  overflow: hidden;
  margin-bottom: 40px;
}
.strip-item {
  background: var(--bg-card);
  padding: 24px 20px;
  display: flex; flex-direction: column;
  gap: 6px;
}
.strip-label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-faint);
}
.strip-value {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.strip-note { font-size: 11px; color: var(--ink-faint); font-style: italic; }

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

/* ---------- Time windows ---------- */
.windows {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--gut);
  margin-bottom: 40px;
}
@media (max-width: 900px) { .windows { grid-template-columns: 1fr; } }

.window-card {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--rad-lg);
  background: var(--bg-card);
}
.window-card h3 {
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-dim);
  margin: 0 0 20px;
}
.w-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px 12px;
  margin-bottom: 18px;
}
.w-grid > div { display: flex; flex-direction: column; }
.w-num {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 500;
  line-height: 1;
  color: var(--ink);
}
.w-lbl {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-faint);
  margin-top: 4px;
}
.w-foot {
  font-size: 13px;
  color: var(--ink-dim);
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.w-foot span { color: var(--ink); font-weight: 500; }

/* ---------- Card ---------- */
.card {
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: var(--rad-lg);
  background: var(--bg-card);
  margin-bottom: var(--gut);
}
.card-head { margin-bottom: 24px; }
.card-head h2 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 26px;
  letter-spacing: -0.015em;
  margin: 0 0 6px;
  font-style: italic;
}
.card-sub { color: var(--ink-dim); margin: 0; font-size: 14px; }

.row-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gut);
}
@media (max-width: 900px) { .row-2col { grid-template-columns: 1fr; } }
.row-2col .card { margin-bottom: var(--gut); }

/* ---------- Pattern debt ---------- */
.pattern-debt {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  height: 220px;
  padding: 16px 0 32px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}
.pd-bar {
  flex: 1 1 0;
  min-width: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  height: 100%;
}
.pd-bar-fill {
  width: 100%;
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-soft) 100%);
  border-radius: 4px 4px 0 0;
  position: relative;
  transition: filter .15s;
}
.pd-bar:hover .pd-bar-fill { filter: brightness(1.2); }
.pd-bar-label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-dim);
  margin-top: 10px;
  text-align: center;
  white-space: nowrap;
}
.pd-bar-val {
  position: absolute;
  top: -22px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink);
}

/* ---------- Horizontal bars (frequency, sore regions) ---------- */
.hbar-list { display: flex; flex-direction: column; gap: 10px; }
.hbar {
  display: grid;
  grid-template-columns: 140px 1fr 60px;
  align-items: center;
  gap: 14px;
}
.hbar-label {
  font-size: 13px;
  color: var(--ink-dim);
  text-transform: capitalize;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hbar-track {
  height: 12px;
  background: var(--bg-elev);
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}
.hbar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 6px;
  transition: width .4s ease;
}
.hbar-val {
  font-family: var(--font-mono);
  font-size: 12px;
  text-align: right;
  color: var(--ink);
}

/* ---------- Charts ---------- */
.chart-host { height: 280px; width: 100%; }
.legend {
  display: flex; flex-wrap: wrap; gap: 8px 16px;
  margin-top: 16px;
}
.legend-item {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-dim);
  cursor: pointer;
  display: flex; align-items: center; gap: 6px;
  transition: color .15s;
}
.legend-item:hover { color: var(--ink); }
.legend-item.muted { opacity: 0.4; }
.legend-swatch {
  width: 10px; height: 10px; border-radius: 2px;
}

/* ---------- Day-of-week heatmap ---------- */
.dow-heat {
  display: grid;
  grid-template-columns: 80px repeat(7, 1fr);
  gap: 4px;
}
.dow-cell {
  aspect-ratio: 1;
  border-radius: 4px;
  background: var(--bg-elev);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-faint);
  transition: transform .12s ease;
}
.dow-cell.has-data { color: var(--bg); font-weight: 600; }
.dow-cell:hover { transform: scale(1.08); }
.dow-cell.label {
  background: transparent;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 10px;
  justify-content: flex-start;
  padding-left: 4px;
}
.dow-cell.col-label {
  background: transparent;
  color: var(--ink-faint);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  aspect-ratio: auto;
  padding-bottom: 6px;
  align-items: flex-end;
}

/* ---------- Exercise lists ---------- */
.ex-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
}
@media (max-width: 900px) { .ex-cols { grid-template-columns: 1fr; } }
.col-title {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-dim);
  margin: 0 0 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.ex-list {
  list-style: none;
  padding: 0;
  margin: 0;
  counter-reset: ex;
}
.ex-list li {
  display: grid;
  grid-template-columns: 24px 16px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  counter-increment: ex;
}
.ex-list li::before {
  content: counter(ex);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-faint);
}
.ex-name { font-size: 14px; color: var(--ink); }
.ex-pattern {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
  display: block;
  margin-top: 2px;
}
.ex-count {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink);
}

/* Traffic-light dots */
.dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}
.dot-green  { background: var(--green); box-shadow: 0 0 8px rgba(74, 222, 128, 0.4); }
.dot-yellow { background: var(--yellow); box-shadow: 0 0 8px rgba(251, 191, 36, 0.4); }
.dot-red    { background: var(--red); box-shadow: 0 0 8px rgba(248, 113, 113, 0.4); }

/* ---------- Sessions list ---------- */
.sessions-list { display: flex; flex-direction: column; gap: 1px; background: var(--line); border-radius: var(--rad-md); overflow: hidden; }
.session-row {
  display: grid;
  grid-template-columns: 120px 1fr auto auto auto;
  gap: 20px;
  padding: 16px 20px;
  background: var(--bg-card);
  align-items: center;
}
.session-date {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.session-summary { color: var(--ink); font-size: 14px; }
.session-stat {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-dim);
}
.session-stat strong { color: var(--ink); font-weight: 500; }

/* ---------- Footer ---------- */
.foot {
  margin-top: 64px;
  padding-top: 32px;
  border-top: 1px solid var(--line);
  color: var(--ink-faint);
  font-size: 13px;
}

/* ---------- uPlot overrides ---------- */
.uplot { font-family: var(--font-mono) !important; }
.u-axis { color: var(--ink-faint); }
.u-legend { display: none !important; }
/* Engine behavior card */
.engine-behavior-card { margin-top: 32px; }
.eb-legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin: 12px 0 16px;
  font-size: 13px;
  color: var(--text-muted);
}
.eb-legend .dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}
.dot.util-good { background: var(--green); }
.dot.util-mid  { background: var(--yellow); }
.dot.util-low  { background: var(--accent-warm); }
.dot.util-zero { background: var(--muted); }
.eb-table {
  display: grid;
  grid-template-columns: 1fr auto auto auto auto;
  gap: 0;
  font-size: 14px;
}
.eb-row {
  display: contents;
  cursor: pointer;
}
.eb-row > div {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: transparent;
  transition: background 0.1s;
}
.eb-row:hover > div { background: var(--surface-2); }
.eb-row.active > div { background: var(--surface-3); }
.eb-row.header > div {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
  cursor: default;
}
.eb-pattern { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.eb-num { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-muted); }
.eb-num strong { color: var(--text); font-weight: 500; }
.eb-drilldown {
  margin-top: 20px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}
.eb-drilldown h3 {
  margin: 0 0 12px;
  font-size: 18px;
}
.eb-drilldown .close-btn {
  float: right;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}
.eb-drill-stats {
  display: flex;
  gap: 24px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--text-muted);
}
.eb-drill-stats strong { color: var(--text); margin-right: 4px; }
.eb-ex-list {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px 16px;
  font-size: 13px;
}
.eb-ex-list > div {
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.eb-ex-bar {
  position: relative;
  height: 18px;
  background: var(--surface-3);
  border-radius: 3px;
  overflow: hidden;
  min-width: 60px;
}
.eb-ex-bar > span {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--accent);
  border-radius: 3px;
}
.eb-ex-new {
  display: inline-block;
  font-size: 10px;
  letter-spacing: 0.05em;
  background: var(--green);
  color: var(--bg);
  padding: 1px 6px;
  border-radius: 3px;
  margin-left: 6px;
  vertical-align: middle;
}
/* Weekly target cards */
.weekly-target-card { margin-top: 32px; }

/* Cards 1 & 2: This week / Rolling 7d list */
.wt-list {
  display: grid;
  grid-template-columns: 1fr auto auto 1fr;
  gap: 0;
  font-size: 14px;
}
.wt-row { display: contents; }
.wt-row > div {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.wt-row.header > div {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
}
.wt-pattern { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.wt-actual {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.wt-actual .unit { color: var(--text-muted); font-size: 12px; margin-left: 2px; }
.wt-target {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}
.wt-bar-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-right: 12px;
}
.wt-bar {
  flex: 1;
  position: relative;
  height: 18px;
  background: var(--surface-3);
  border-radius: 3px;
  overflow: hidden;
  min-width: 80px;
}
.wt-bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 3px;
  transition: width 0.2s;
}
.wt-bar-fill.under { background: var(--accent-warm); }
.wt-bar-fill.on { background: var(--green); }
.wt-bar-fill.over { background: var(--accent); }
.wt-bar-fill.zero { background: var(--muted); }
.wt-pct {
  min-width: 50px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--text-muted);
}
.wt-pct strong { color: var(--text); }
.wt-pct.over-target strong { color: var(--accent); }

/* Card 3: Last 4 weeks */
.wt-4w {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px 16px;
  font-size: 14px;
}
.wt-4w-row { display: contents; }
.wt-4w-row > div {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.wt-4w-row.header > div {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
}
.wt-4w-bars {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  align-items: end;
  height: 40px;
  margin-bottom: 16px;
}
.wt-4w-bar {
  position: relative;
  background: var(--surface-3);
  border-radius: 2px;
  height: 100%;
}
.wt-4w-bar-fill {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  border-radius: 2px;
}
.wt-4w-bar-fill.under { background: var(--accent-warm); }
.wt-4w-bar-fill.on { background: var(--green); }
.wt-4w-bar-fill.over { background: var(--accent); }
.wt-4w-bar-fill.zero { background: var(--muted); }
.wt-4w-bar-label {
  position: absolute;
  left: 0; right: 0; top: 100%;
  margin-top: 2px;
  text-align: center;
  font-size: 10px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.wt-4w-target-row {
  font-size: 11px;
  color: var(--text-muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}