:root {
  /* main.css tokens — sync with styles.css */
  --navy:     #ffffff;
  --surface:  #ffffff;
  --surface2: #eef0f3;
  --surface3: #e4e7ec;
  --border:   #e2e5ea;
  --text:     #0f1117;
  --gold:     #C07A2E;
  --gold-dim: rgba(192,122,46,.08);
  --gold-bdr: rgba(192,122,46,.20);
  --green:    #1a7f4e;
  --red:      #c92a2a;
  --amber:    #c07d00;
  --blue:     #1971c2;
  --purple:   #7048e8;
  --gray:     #6c757d;
  --gray2:    #495057;
  --gray3:    #212529;
  --gold-text:#C07A2E;
  --gold2:    #D4893A;
  --green-dim:rgba(26,127,78,.08);
  --green-bdr:rgba(26,127,78,.18);
  --red-dim:  rgba(201,42,42,.07);
  --red-bdr:  rgba(201,42,42,.18);
  --amber-bdr:rgba(192,125,0,.18);
  --blue-bdr: rgba(25,113,194,.18);
}

[data-theme="dark"] :root, [data-theme="dark"] {
  --navy:     #0a0e1a;
  --surface:  #111827;
  --surface2: #1a2235;
  --surface3: #222f45;
  --border:   #1e2d45;
  --text:     #f1f3f5;
  --gold:     #c9a84c;
  --gold-dim: rgba(201,168,76,.1);
  --gold-bdr: rgba(201,168,76,.25);
  --green:    #10b981;
  --red:      #ef4444;
  --amber:    #f59e0b;
  --blue:     #3b82f6;
  --purple:   #8b5cf6;
  --gray:     #64748b;
  --gray2:    #94a3b8;
  --gray3:    #e2e8f0;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Plus Jakarta Sans', 'DM Sans', system-ui, sans-serif;
  background: var(--navy);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.5;
}

button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }
a { color: var(--gold); text-decoration: none; }

/* ── TOPBAR ── */
.topbar {
  background: var(--navy);
  border-bottom: 1px solid var(--border);
  padding: .55rem 1.25rem;
  display: flex;
  align-items: center;
  gap: .75rem;
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-logo { font-size: .9rem; font-weight: 800; letter-spacing: .2em; color: var(--gold); }
.topbar-badge {
  font-size: .56rem; padding: .16rem .44rem;
  background: var(--gold-dim); border: 1px solid var(--gold-bdr);
  border-radius: 4px; color: var(--gold); font-weight: 700; letter-spacing: .06em;
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: .65rem; }
.topbar-user { font-size: .72rem; color: var(--gray); }

/* ── LOGIN ── */
#login-screen {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 1rem;
}
.login-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 2.25rem; width: 100%; max-width: 380px;
}
.login-logo { font-size: 1.35rem; font-weight: 800; letter-spacing: .22em; margin-bottom: .2rem; }
.login-sub { font-size: .65rem; letter-spacing: .12em; color: var(--gold); text-transform: uppercase; margin-bottom: 1.75rem; }
.auth-err { color: var(--red); font-size: .73rem; margin-top: .6rem; text-align: center; display: none; }

/* ── FORMS ── */
.field { margin-bottom: .85rem; }
.field label { display: block; font-size: .7rem; color: var(--gray2); margin-bottom: .3rem; font-weight: 500; }
.field input, .field select, .field textarea {
  width: 100%; padding: .58rem .82rem;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: .87rem; outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--gold-bdr); }
.field select option { background: #1a2235; }
.field textarea { resize: vertical; min-height: 65px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }

/* ── BUTTONS ── */
.btn-primary {
  width: 100%; padding: .65rem; background: var(--gold); border: none;
  border-radius: 8px; color: #080d18; font-size: .88rem; font-weight: 700;
}
.btn-primary:hover { opacity: .92; }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary-sm {
  padding: .35rem .85rem; background: var(--gold); border: none;
  border-radius: 7px; color: #080d18; font-size: .75rem; font-weight: 700;
}
.btn-primary-sm:hover { opacity: .9; }
.btn-primary-sm:disabled { opacity: .4; cursor: not-allowed; }

.btn-secondary {
  padding: .38rem .85rem; background: transparent;
  border: 1px solid var(--gold-bdr); border-radius: 7px;
  color: var(--gold); font-size: .75rem;
}
.btn-secondary:hover { background: var(--gold-dim); }

.btn-sm {
  padding: .25rem .6rem; background: transparent;
  border: 1px solid var(--border); border-radius: 6px;
  color: var(--gray2); font-size: .7rem;
}
.btn-sm:hover { border-color: var(--gold-bdr); color: var(--gold); }
.btn-sm:disabled { opacity: .35; cursor: not-allowed; }
.btn-sm.recording { border-color: var(--red); color: var(--red); }

.btn-ghost {
  background: transparent; border: 1px solid var(--border);
  border-radius: 6px; color: var(--gray); padding: .26rem .62rem; font-size: .7rem;
}
.btn-ghost:hover { border-color: var(--gold-bdr); color: var(--gold); }

.btn-add {
  display: flex; align-items: center; gap: .4rem;
  background: var(--gold); border: none; border-radius: 8px;
  color: #080d18; padding: .42rem .95rem; font-size: .78rem; font-weight: 700;
}
.btn-add:hover { opacity: .9; }

/* ── BADGES ── */
.badge {
  font-size: .58rem; font-weight: 700; padding: .16rem .44rem;
  border-radius: 8px; white-space: nowrap; display: inline-block;
}
.status-done   { background: rgba(16,185,129,.12); color: var(--green); }
.status-prog   { background: rgba(245,158,11,.12); color: var(--amber); }
.status-intake { background: rgba(59,130,246,.12); color: var(--blue); }
.status-pend   { background: rgba(100,116,139,.1); color: var(--gray); }
.badge-red     { background: rgba(239,68,68,.12); color: var(--red); }
.badge-amber   { background: rgba(245,158,11,.12); color: var(--amber); }
.badge-green   { background: rgba(16,185,129,.12); color: var(--green); }
.badge-gold    { background: var(--gold-dim); border: 1px solid var(--gold-bdr); color: var(--gold); }

/* ── LAYOUT ── */
.main { max-width: 860px; margin: 0 auto; padding: 1.25rem; }
.view { display: none; }

/* ── CLIENT LIST ── */
.list-header { display: flex; align-items: center; gap: .75rem; margin-bottom: .85rem; }
.list-title { font-size: 1.05rem; font-weight: 700; flex: 1; }

.filter-row { display: flex; gap: .4rem; margin-bottom: .75rem; flex-wrap: wrap; }
.filter-btn {
  padding: .22rem .65rem; background: transparent;
  border: 1px solid var(--border); border-radius: 20px;
  color: var(--gray); font-size: .7rem; cursor: pointer;
}
.filter-btn:hover, .filter-btn.active { border-color: var(--gold-bdr); color: var(--gold); background: var(--gold-dim); }

.search-input {
  width: 100%; padding: .56rem .9rem;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: .84rem; outline: none;
  margin-bottom: .75rem;
}
.search-input:focus { border-color: var(--gold-bdr); }

.client-count { font-size: .6rem; font-weight: 700; color: var(--gold); text-transform: uppercase; letter-spacing: .1em; margin-bottom: .5rem; }

.client-row {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .72rem .9rem;
  cursor: pointer; display: flex; align-items: center; gap: .72rem;
  margin-bottom: .35rem; transition: border-color .15s;
}
.client-row:hover { border-color: var(--gold-bdr); }

.c-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--gold-dim); border: 1px solid var(--gold-bdr);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: var(--gold); font-size: .8rem; flex-shrink: 0;
}
.c-info { flex: 1; min-width: 0; }
.c-name { font-size: .85rem; font-weight: 600; }
.c-sub { font-size: .68rem; color: var(--gray); margin-top: .08rem; }
.c-actions { display: flex; align-items: center; gap: .45rem; flex-shrink: 0; }

/* ── PROFILE ── */
.back-btn {
  background: transparent; border: none; color: var(--gray);
  font-size: .75rem; display: flex; align-items: center;
  gap: .3rem; padding: 0; margin-bottom: .8rem; cursor: pointer;
}
.back-btn:hover { color: var(--text); }

.profile-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: .9rem 1rem; margin-bottom: .65rem;
}

.ph-top { display: flex; align-items: center; gap: .75rem; }
.ph-avatar {
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--gold-dim); border: 1.5px solid var(--gold-bdr);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: var(--gold); font-size: 1rem; flex-shrink: 0;
}
.ph-name { font-size: 1rem; font-weight: 700; }
.ph-meta { font-size: .7rem; color: var(--gray); margin-top: .12rem; }
.ph-header-actions { margin-left: auto; display: flex; gap: .4rem; }

/* Stats */
.stats-row { display: flex; gap: .4rem; margin-top: .7rem; padding-top: .65rem; border-top: 1px solid var(--border); }
.stat-box {
  text-align: center; padding: .32rem .6rem;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; min-width: 52px;
}
.stat-val { font-size: 1rem; font-weight: 800; font-family: Georgia, serif; line-height: 1.1; }
.stat-lbl { font-size: .55rem; color: var(--gray); text-transform: uppercase; letter-spacing: .05em; margin-top: 2px; }

/* Progress */
.progress-row { display: flex; align-items: center; gap: .55rem; margin-top: .65rem; }
.progress-label { font-size: .68rem; color: var(--gray); min-width: 120px; }
.progress-track { flex: 1; height: 4px; background: var(--border); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 3px; background: var(--gold); transition: width .4s; }
.progress-pct { font-size: .68rem; color: var(--gray2); min-width: 28px; text-align: right; }
.progress-steps { font-size: .65rem; color: var(--gray); }

.step-list { display: flex; gap: .3rem; flex-wrap: wrap; margin-top: .45rem; }
.step-pill {
  font-size: .65rem; padding: .18rem .5rem; border-radius: 8px;
  background: var(--surface2); border: 1px solid var(--border); color: var(--gray);
}
.step-pill.done { background: rgba(16,185,129,.1); border-color: rgba(16,185,129,.25); color: var(--green); }
.step-pill.locked { color: var(--gray); opacity: .5; }

/* Assessment link */
.link-box {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .65rem .9rem;
  display: flex; align-items: center; gap: .65rem;
}
.link-label { font-size: .6rem; font-weight: 700; color: var(--gold); text-transform: uppercase; letter-spacing: .08em; margin-bottom: .18rem; }
.link-url { font-size: .72rem; color: var(--gray2); font-family: monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.link-actions { display: flex; gap: .4rem; flex-shrink: 0; }

/* Section headers in profile */
.section-header {
  font-size: .6rem; font-weight: 700; color: var(--gold);
  text-transform: uppercase; letter-spacing: .1em;
  margin-bottom: .55rem; padding-bottom: .4rem;
  border-bottom: 1px solid var(--border);
}

/* ── FLAGS ── */
.flag-row {
  display: flex; align-items: center; gap: .6rem;
  padding: .42rem .5rem; border-radius: 7px;
  background: var(--surface2); margin-bottom: .3rem;
}
.flag-name { font-size: .8rem; font-weight: 600; min-width: 170px; }
.flag-bar-wrap { flex: 1; }
.flag-bar-track { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.flag-bar-fill { height: 100%; border-radius: 3px; }
.flag-score { font-size: .82rem; font-weight: 800; min-width: 28px; text-align: right; font-family: Georgia, serif; }
.crisis-alert {
  background: rgba(239,68,68,.15); border: 1px solid rgba(239,68,68,.4);
  border-radius: 8px; padding: .55rem .8rem;
  color: var(--red); font-size: .82rem; font-weight: 600;
  margin-bottom: .6rem;
}
.see-more { font-size: .7rem; color: var(--gray); text-align: center; padding: .35rem; font-style: italic; }

/* ── COMPOSITES ── */
.composite-grid { display: flex; flex-direction: column; gap: 0; }
.comp-group-label {
  font-size: .6rem; font-weight: 700; color: var(--gold);
  text-transform: uppercase; letter-spacing: .08em;
  padding: .5rem 0 .3rem; margin-top: .3rem;
}
.comp-row {
  display: flex; align-items: center; gap: .5rem;
  padding: .28rem .4rem; border-radius: 5px; font-size: .78rem;
}
.comp-row:nth-child(even) { background: rgba(255,255,255,.02); }
.comp-row.flagged { background: rgba(239,68,68,.06); }
.comp-name { flex: 1; color: var(--text); font-size: .76rem; }
.comp-bar-track { width: 80px; height: 5px; background: var(--border); border-radius: 3px; overflow: hidden; flex-shrink: 0; }
.comp-bar-fill { height: 100%; border-radius: 3px; }
.comp-score { font-size: .78rem; font-weight: 700; min-width: 24px; text-align: right; font-family: Georgia, serif; }
.flag-dot { font-size: .6rem; color: var(--red); min-width: 10px; }

/* ── AI CARDS ── */
.ai-cards { display: grid; grid-template-columns: 1fr 1fr; gap: .65rem; margin-bottom: .65rem; }
@media (max-width: 600px) { .ai-cards { grid-template-columns: 1fr; } }

.ai-card {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.ai-card-header {
  padding: .45rem .75rem; font-size: .7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em; color: #fff;
}
.ai-card-header.gold   { background: linear-gradient(135deg, #b8860b, #d4a017); }
.ai-card-header.blue   { background: linear-gradient(135deg, #1d4ed8, #3b82f6); }
.ai-card-header.purple { background: linear-gradient(135deg, #6d28d9, #8b5cf6); }
.ai-card-header.green  { background: linear-gradient(135deg, #047857, #10b981); }

.ai-card-body { padding: .65rem .75rem; }
.ai-card-body p { font-size: .82rem; color: var(--gray2); line-height: 1.55; margin-bottom: .4rem; }
.ai-label { font-size: .62rem; font-weight: 700; color: var(--gold); text-transform: uppercase; letter-spacing: .08em; margin-bottom: .2rem; }
.ai-score { font-size: 1.1rem; font-weight: 800; color: var(--gold); font-family: Georgia, serif; }
.ai-actions { display: flex; gap: .5rem; }

.values-row { display: flex; align-items: center; gap: .5rem; padding: .25rem 0; border-bottom: 1px solid var(--border); }
.values-row:last-child { border-bottom: none; }
.value-rank {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--gold-dim); border: 1px solid var(--gold-bdr);
  color: var(--gold); font-size: .65rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.value-name { font-size: .82rem; color: var(--text); }

/* ── CONSENT ── */
.consent-summary {
  padding: .5rem .75rem; border-radius: 7px;
  font-size: .8rem; font-weight: 600; margin-bottom: .55rem;
}
.consent-summary.all-share { background: rgba(16,185,129,.1); color: var(--green); }
.consent-summary.partial { background: rgba(245,158,11,.1); color: var(--amber); }

.consent-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .3rem; }
.consent-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: .35rem .55rem; background: var(--surface2);
  border: 1px solid var(--border); border-radius: 7px;
}
.consent-cat { font-size: .78rem; color: var(--text); text-transform: capitalize; }
.consent-choice { font-size: .68rem; font-weight: 700; }
.consent-choice.share { color: var(--green); }
.consent-choice.private { color: var(--amber); }

/* ── SESSION NOTES ── */
.notes-input-wrap {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .75rem; margin-bottom: .65rem;
}
#note-textarea {
  width: 100%; background: var(--navy); border: 1px solid var(--border);
  border-radius: 7px; color: var(--text); padding: .55rem .75rem;
  font-size: .85rem; line-height: 1.55; outline: none; resize: vertical;
}
#note-textarea:focus { border-color: var(--gold-bdr); }

.notes-toolbar { display: flex; align-items: center; gap: .5rem; margin-top: .55rem; flex-wrap: wrap; }
.note-type-select {
  padding: .26rem .55rem; background: var(--navy); border: 1px solid var(--border);
  border-radius: 6px; color: var(--gray2); font-size: .72rem;
}

.dictation-status {
  font-size: .72rem; color: var(--red); display: flex; align-items: center;
  gap: .3rem; margin-top: .4rem;
}

.notes-history { display: flex; flex-direction: column; gap: .4rem; }
.note-entry {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; padding: .6rem .75rem;
  animation: fadeIn .3s ease;
}
.note-entry.new { border-color: var(--gold-bdr); }
.note-meta { font-size: .65rem; color: var(--gray); margin-bottom: .35rem; }
.note-text { font-size: .82rem; color: var(--text); line-height: 1.55; white-space: pre-wrap; }

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

/* ── REPORTS ── */
.report-featured {
  background: var(--gold-dim); border: 1px solid var(--gold-bdr);
  border-radius: 12px; padding: .85rem 1rem;
  display: flex; align-items: center; gap: .75rem; margin-bottom: .65rem;
}
.report-icon { font-size: 1.25rem; flex-shrink: 0; }
.report-info { flex: 1; }
.report-name { font-size: .88rem; font-weight: 700; color: var(--gold); display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.report-desc { font-size: .7rem; color: var(--gray); margin-top: .18rem; }

.report-list { display: flex; flex-direction: column; gap: .35rem; }
.report-row {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 9px; padding: .6rem .85rem;
  display: flex; align-items: center; gap: .68rem;
}
.report-row-icon { font-size: .9rem; width: 18px; text-align: center; flex-shrink: 0; }
.report-row-info { flex: 1; }
.report-row-name { font-size: .8rem; font-weight: 600; }
.report-row-desc { font-size: .65rem; color: var(--gray); margin-top: .1rem; }

/* ── MODAL ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.72);
  z-index: 500; display: none; align-items: center; justify-content: center; padding: 1rem;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 1.65rem; width: 100%; max-width: 480px;
  max-height: 90vh; overflow-y: auto;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.15rem; }
.modal-title { font-size: .95rem; font-weight: 700; }
.modal-close { background: transparent; border: none; color: var(--gray); font-size: 1.1rem; }
.modal-close:hover { color: var(--text); }
.modal-footer { display: flex; gap: .55rem; margin-top: 1.15rem; }
.btn-cancel {
  flex: 1; padding: .62rem; background: transparent;
  border: 1px solid var(--border); border-radius: 8px;
  color: var(--gray); font-size: .85rem;
}
.btn-cancel:hover { border-color: var(--gold-bdr); color: var(--text); }
.btn-submit {
  flex: 2; padding: .62rem; background: var(--gold); border: none;
  border-radius: 8px; color: #080d18; font-size: .85rem; font-weight: 700;
}
.btn-submit:disabled { opacity: .5; cursor: not-allowed; }

/* ── TABS ── */
.tabs { display: flex; gap: .35rem; border-bottom: 1px solid var(--border); margin-bottom: .75rem; overflow-x: auto; }
.tab {
  padding: .45rem .8rem; font-size: .75rem; font-weight: 600;
  color: var(--gray); background: transparent; border: none;
  border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--gold); border-bottom-color: var(--gold); }

/* ── TOAST ── */
#toast {
  position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%);
  background: #1f2937; color: #f9fafb; border: 1px solid #374151;
  border-radius: 8px; padding: .5rem 1.1rem; font-size: .8rem; font-weight: 500;
  z-index: 9999; white-space: nowrap; opacity: 0; pointer-events: none;
  transition: opacity .2s; box-shadow: 0 4px 12px rgba(0,0,0,.15);
}
#toast.show { opacity: 1; }
#toast.error { border-color: #ef4444; color: #fca5a5; }
#toast.success { border-color: #22c55e; color: #86efac; }

/* ── MISC ── */
.spinner {
  display: inline-block; width: 13px; height: 13px;
  border: 2px solid var(--border); border-top-color: var(--gold);
  border-radius: 50%; animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading { text-align: center; padding: 2rem; color: var(--gray); }
.empty-state { text-align: center; padding: 2rem; color: var(--gray); font-size: .85rem; }
.empty-note { font-size: .78rem; color: var(--gray); padding: .5rem 0; font-style: italic; }
.info-note {
  font-size: .78rem; color: var(--gray); padding: .55rem .78rem;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 7px; margin-bottom: .65rem;
}
