/* UpstreamLab Coach Dashboard
   Design tokens from landing page — dark green palette */

:root {
  --bg: #0C0F0A;
  --bg-elevated: #141A12;
  --bg-card: #1A2117;
  --bg-card-hover: #1f2a1b;
  --fg: #E8E4DC;
  --fg-muted: #9B978F;
  --accent: #A8D86E;
  --accent-dim: #7BA84D;
  --accent-glow: rgba(168,216,110,0.10);
  --warm: #D4A853;
  --red: #e05252;
  --red-dim: rgba(224,82,82,0.15);
  --warn-dim: rgba(212,168,83,0.15);
  --border: rgba(168,216,110,0.10);
  --border-strong: rgba(168,216,110,0.20);
  --font-display: 'Syne', sans-serif;
  --font-body: 'DM Sans', sans-serif;
  --radius: 10px;
  --radius-sm: 6px;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-weight: 400;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }

/* ============================================================
   NAV
   ============================================================ */
.dash-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  height: 56px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.dash-logo {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--accent);
  letter-spacing: -0.02em;
}
.dash-nav-links { display: flex; gap: 1rem; align-items: center; }
.nav-link {
  font-size: 0.875rem;
  color: var(--fg-muted);
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
}
.nav-link:hover, .nav-link.active {
  color: var(--fg);
  background: var(--accent-glow);
}

/* ============================================================
   LAYOUT
   ============================================================ */
.dash-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: calc(100vh - 56px);
}

.dash-sidebar {
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.dash-main {
  padding: 1.75rem 2rem;
  overflow-y: auto;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar-label {
  display: block;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--fg-muted);
  text-transform: uppercase;
  margin-bottom: 0.75rem;
}

.risk-dist { display: flex; flex-direction: column; gap: 0.5rem; }
.risk-bar-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
}
.risk-label { flex: 1; color: var(--fg-muted); }
.risk-count { font-weight: 600; font-size: 0.875rem; }

.stat-mini-list { display: flex; flex-direction: column; gap: 0.5rem; }
.stat-mini { display: flex; align-items: baseline; gap: 0.5rem; }
.stat-mini-val { font-family: var(--font-display); font-size: 1.3rem; font-weight: 700; }
.stat-mini-val.accent { color: var(--accent); }
.stat-mini-val.warn { color: var(--red); }
.stat-mini-val.muted { color: var(--fg-muted); }
.stat-mini-label { font-size: 0.78rem; color: var(--fg-muted); }

/* Alert clients */
.alert-client {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.5rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.25rem;
  transition: background 0.15s;
}
.alert-client:hover { background: var(--accent-glow); }
.alert-name { flex: 1; font-size: 0.85rem; }
.alert-score {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--fg-muted);
}

/* ============================================================
   RISK DOTS & BADGES
   ============================================================ */
.risk-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}
.risk-dot.critical { background: var(--red); box-shadow: 0 0 6px var(--red); }
.risk-dot.high     { background: var(--warm); box-shadow: 0 0 6px rgba(212,168,83,0.5); }
.risk-dot.moderate { background: var(--accent-dim); }
.risk-dot.low      { background: #4a7a3a; }

.risk-badge {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.2rem 0.5rem;
  border-radius: 100px;
}
.risk-badge.critical { background: var(--red-dim); color: var(--red); border: 1px solid rgba(224,82,82,0.3); }
.risk-badge.high     { background: var(--warn-dim); color: var(--warm); border: 1px solid rgba(212,168,83,0.3); }
.risk-badge.moderate { background: var(--accent-glow); color: var(--accent); border: 1px solid var(--border-strong); }
.risk-badge.low      { background: rgba(74,122,58,0.15); color: #6daa58; border: 1px solid rgba(74,122,58,0.3); }

.critical-text { color: var(--red) !important; }
.high-text     { color: var(--warm) !important; }
.moderate-text { color: var(--accent) !important; }
.low-text      { color: #6daa58 !important; }
.accent-text   { color: var(--accent); }

/* ============================================================
   STAT CARDS
   ============================================================ */
.stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.75rem;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.stat-card.critical-card { border-color: rgba(224,82,82,0.25); background: rgba(224,82,82,0.05); }
.stat-num {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
}
.stat-desc { font-size: 0.8rem; color: var(--fg-muted); }

/* ============================================================
   SECTIONS
   ============================================================ */
.dash-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
}
.section-title {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.section-sub {
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--fg-muted);
  flex: 1;
}

/* ============================================================
   CHART
   ============================================================ */
.chart-container {
  width: 100%;
  height: 160px;
}
#riskTrendChart { width: 100% !important; height: 160px !important; display: block; }

/* ============================================================
   TWO-COL
   ============================================================ */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

/* ============================================================
   CLIENT LIST
   ============================================================ */
.client-list { display: flex; flex-direction: column; gap: 0; }
.client-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.5rem;
  border-radius: var(--radius-sm);
  transition: background 0.12s;
  border-bottom: 1px solid var(--border);
}
.client-row:last-child { border-bottom: none; }
.client-row:hover { background: var(--accent-glow); }
.client-info { flex: 1; min-width: 0; }
.client-name { display: block; font-weight: 500; font-size: 0.9rem; }
.client-meta { display: block; font-size: 0.75rem; color: var(--fg-muted); }
.client-risk {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}
.risk-score-bar {
  width: 60px;
  height: 4px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  overflow: hidden;
}
.risk-score-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.3s;
}
.risk-score-fill.critical { background: var(--red); }
.risk-score-fill.high     { background: var(--warm); }
.risk-score-fill.moderate { background: var(--accent-dim); }
.risk-score-fill.low      { background: #4a7a3a; }
.risk-number {
  font-size: 0.8rem;
  font-weight: 700;
  width: 22px;
  text-align: right;
}

/* ============================================================
   INTERVENTION CARDS
   ============================================================ */
.intervention-list { display: flex; flex-direction: column; gap: 0.75rem; max-height: 480px; overflow-y: auto; }
.intervention-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
}
.iv-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
  flex-wrap: wrap;
}
.iv-client { font-weight: 600; font-size: 0.875rem; display: flex; align-items: center; gap: 0.4rem; flex: 1; }
.iv-type {
  font-size: 0.72rem;
  color: var(--fg-muted);
  text-transform: capitalize;
  background: rgba(255,255,255,0.05);
  padding: 0.15rem 0.5rem;
  border-radius: 100px;
}
.iv-outcome {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.15rem 0.5rem;
  border-radius: 100px;
}
.outcome-improved  { background: var(--accent-glow); color: var(--accent); }
.outcome-no_change { background: rgba(155,151,143,0.1); color: var(--fg-muted); }
.outcome-declined  { background: var(--red-dim); color: var(--red); }
.outcome-pending   { background: var(--warn-dim); color: var(--warm); }

.iv-notes { font-size: 0.82rem; color: var(--fg-muted); line-height: 1.5; margin-bottom: 0.25rem; }
.iv-goal { font-size: 0.82rem; color: var(--fg); margin-bottom: 0.25rem; }
.iv-date { font-size: 0.72rem; color: rgba(155,151,143,0.6); }
.iv-duration { font-size: 0.72rem; color: var(--fg-muted); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn-primary {
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.6rem 1.25rem;
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 600;
  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.full-width { width: 100%; }
.btn-ghost {
  background: transparent;
  color: var(--fg-muted);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.5rem 1rem;
  font-family: var(--font-body);
  font-size: 0.875rem;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.btn-ghost:hover { color: var(--fg); border-color: var(--accent); }
.btn-sm { padding: 0.25rem 0.65rem; font-size: 0.78rem; margin-left: auto; }

/* ============================================================
   MODALS
   ============================================================ */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 100;
  align-items: center;
  justify-content: center;
}
.modal.open { display: flex; }
.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 2rem;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

/* ============================================================
   FORMS
   ============================================================ */
.form-row { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 1rem; }
.form-row label { font-size: 0.8rem; font-weight: 500; color: var(--fg-muted); }
.form-row.two-field { flex-direction: row; gap: 1rem; }
.form-row.two-field > div { flex: 1; display: flex; flex-direction: column; gap: 0.35rem; }
.form-row input,
.form-row select,
.form-row textarea {
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 0.875rem;
  padding: 0.55rem 0.75rem;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}
.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus { border-color: var(--accent); }
.form-row select option { background: var(--bg-card); }
.inline-form { display: flex; flex-direction: column; }
.form-msg { margin-top: 0.75rem; font-size: 0.82rem; padding: 0.5rem 0.75rem; border-radius: var(--radius-sm); }
.form-msg.hidden { display: none; }
.form-msg.success { background: var(--accent-glow); color: var(--accent); }
.form-msg.error   { background: var(--red-dim); color: var(--red); }

/* ============================================================
   CLIENT DETAIL PAGE
   ============================================================ */
.client-detail-layout {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 2rem 4rem;
}
.client-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
  gap: 1rem;
}
.client-header-left { display: flex; align-items: center; gap: 1.25rem; }
.client-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 800;
  flex-shrink: 0;
}
.client-avatar.critical { background: var(--red-dim); color: var(--red); border: 2px solid rgba(224,82,82,0.3); }
.client-avatar.high     { background: var(--warn-dim); color: var(--warm); border: 2px solid rgba(212,168,83,0.3); }
.client-avatar.moderate { background: var(--accent-glow); color: var(--accent); border: 2px solid var(--border-strong); }
.client-avatar.low      { background: rgba(74,122,58,0.15); color: #6daa58; border: 2px solid rgba(74,122,58,0.3); }
.client-heading {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 800;
}
.client-meta-line {
  display: flex;
  gap: 1rem;
  font-size: 0.82rem;
  color: var(--fg-muted);
  flex-wrap: wrap;
}
.client-header-right { display: flex; align-items: center; gap: 1rem; }
.big-risk-score { display: flex; flex-direction: column; align-items: center; }
.big-num {
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 800;
  line-height: 1;
}
.big-label { font-size: 0.72rem; color: var(--fg-muted); text-transform: uppercase; letter-spacing: 0.08em; }
.big-badge { font-size: 0.8rem; padding: 0.3rem 0.8rem; }

/* SIGNALS */
.signals-section { margin-bottom: 1.5rem; }
.signals-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-top: 0.5rem;
}
.signal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
}
.signal-icon { font-size: 1.5rem; }
.signal-value { font-family: var(--font-display); font-size: 1.2rem; font-weight: 700; }
.signal-name { font-size: 0.72rem; color: var(--fg-muted); text-align: center; }
.signal-bar {
  width: 100%;
  height: 4px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 0.25rem;
}
.signal-fill { height: 100%; background: var(--accent-dim); border-radius: 2px; }
.signal-fill.sleep     { background: #6888d4; }
.signal-fill.stress    { background: var(--red); }
.signal-fill.nutrition { background: var(--accent); }

/* TIMELINE */
.client-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
}
.timeline { display: flex; flex-direction: column; gap: 0; position: relative; }
.timeline-item {
  display: flex;
  gap: 0.85rem;
  padding-bottom: 1.25rem;
  position: relative;
}
.timeline-item:last-child { padding-bottom: 0; }
.timeline-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 0.35rem;
  position: relative;
  z-index: 1;
}
.timeline-dot.outcome-improved  { background: var(--accent); box-shadow: 0 0 6px var(--accent-dim); }
.timeline-dot.outcome-no_change { background: var(--fg-muted); }
.timeline-dot.outcome-declined  { background: var(--red); box-shadow: 0 0 6px rgba(224,82,82,0.5); }
.timeline-dot.outcome-pending   { background: var(--warm); }
.timeline-content { flex: 1; }

.empty-msg { color: var(--fg-muted); font-size: 0.875rem; padding: 0.5rem 0; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
  .dash-layout { grid-template-columns: 1fr; }
  .dash-sidebar { border-right: none; border-bottom: 1px solid var(--border); flex-direction: row; flex-wrap: wrap; gap: 1.5rem; }
  .two-col, .client-two-col { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: 1fr 1fr; }
  .signals-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 540px) {
  .stat-row { grid-template-columns: 1fr; }
  .dash-main { padding: 1rem; }
}
