/* CLCA Practice Management — base stylesheet (no build step required) */
:root {
  --navy: #0b1b3d;
  --navy-light: #16285a;
  --gold: #c9a84c;
  --gold-dark: #ab8d36;
  --ink: #2b2f38;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #f4f6fb;
  --card: #ffffff;
  --green: #1f9d55;
  --red: #c0392b;
  --amber: #b7791f;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(11, 27, 61, .08), 0 4px 16px rgba(11, 27, 61, .05);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  font-size: 15px;
}
a { color: var(--navy); }

/* ---- Top bar ---- */
.topbar {
  background: var(--navy);
  color: #fff;
  border-bottom: 3px solid var(--gold);
}
.topbar-inner {
  max-width: 1140px; margin: 0 auto; padding: 0 20px;
  display: flex; align-items: center; gap: 24px; min-height: 60px;
}
.brand { display: flex; flex-direction: row; align-items: center; gap: 10px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand .org { color: var(--gold); font-weight: 700; font-size: 13px; letter-spacing: .04em; }
.brand .sub { color: #cdd5e6; font-size: 11px; }
.clca-cross { display: block; flex-shrink: 0; }
.login-head .clca-cross, .intake-header .clca-cross { margin: 0 auto 8px; }
.nav { display: flex; flex-wrap: wrap; gap: 4px; margin-left: auto; align-items: center; }
.nav a, .nav span.disabled {
  color: #dfe5f2; text-decoration: none; padding: 8px 12px; border-radius: 6px; font-size: 14px;
}
.nav a:hover { background: var(--navy-light); color: #fff; }
.nav a.active { background: var(--gold); color: var(--navy); font-weight: 600; }
.nav span.disabled { color: #6b7794; cursor: default; }
.nav form { margin: 0; }

/* Dropdown groups */
.nav-group { position: relative; }
.nav-trigger { background: transparent; border: none; color: #dfe5f2; padding: 8px 12px; border-radius: 6px; font-size: 14px; cursor: pointer; font-family: inherit; }
.nav-group:hover .nav-trigger, .nav-trigger:focus { background: var(--navy-light); color: #fff; }
.nav-trigger.active { background: var(--gold); color: var(--navy); font-weight: 600; }
.nav-menu { display: none; position: absolute; top: 100%; left: 0; background: #fff; min-width: 190px; border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); padding: 6px; z-index: 200; }
.nav-group:hover .nav-menu, .nav-group:focus-within .nav-menu, .nav-group.open .nav-menu { display: block; }
.nav-menu a { display: block; color: var(--navy); padding: 8px 12px; border-radius: 6px; white-space: nowrap; font-size: 14px; text-decoration: none; }
.nav-menu a:hover { background: var(--bg); color: var(--navy); }
.nav-menu a.active { background: var(--gold); color: var(--navy); font-weight: 600; }
.btn-logout {
  background: transparent; border: 1px solid #44507a; color: #dfe5f2;
  padding: 7px 12px; border-radius: 6px; cursor: pointer; font-size: 14px;
}
.btn-logout:hover { background: var(--navy-light); }

/* ---- Layout ---- */
.container { max-width: 1140px; margin: 28px auto; padding: 0 20px; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; gap: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; margin: 0; color: var(--navy); }
.page-head .actions { display: flex; gap: 10px; }

/* ---- Cards ---- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card + .card { margin-top: 18px; }
.card h2 { font-size: 16px; margin: 0 0 14px; color: var(--navy); }

.grid { display: grid; gap: 18px; }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 900px) { .grid.cols-4, .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .grid.cols-4, .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; } }

/* ---- Stat tiles ---- */
.stat { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--gold); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.stat .value { font-size: 24px; font-weight: 700; color: var(--navy); margin-top: 4px; }
.stat .value.pos { color: var(--green); }
.stat .value.neg { color: var(--red); }

/* ---- Tables ---- */
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 14px; }
table.data th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
table.data tr:hover td { background: #fafbfe; }
table.data tr[data-href] { cursor: pointer; }
.table-wrap { overflow-x: auto; }

/* ---- Badges ---- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.paid { background: #e4f5ec; color: var(--green); }
.badge.unpaid { background: #fdeceb; color: var(--red); }
.badge.active { background: #e7eefc; color: var(--navy); }
.badge.muted { background: #eef0f4; color: var(--muted); }

/* ---- Buttons ---- */
.btn { display: inline-block; border: none; border-radius: 7px; padding: 9px 16px; font-size: 14px; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-light); }
.btn-gold { background: var(--gold); color: var(--navy); }
.btn-gold:hover { background: var(--gold-dark); }
.btn-light { background: #eef0f4; color: var(--navy); }
.btn-sm { padding: 5px 10px; font-size: 13px; }

/* ---- Forms ---- */
.form-group { margin-bottom: 16px; }
label { display: block; font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 6px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number],
select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid #cbd2de; border-radius: 7px; font-size: 14px; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201,168,76,.2); }
textarea { min-height: 90px; resize: vertical; }

/* ---- Alerts ---- */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 18px; font-size: 14px; }
.alert-success { background: #e4f5ec; color: #156c3b; border: 1px solid #b6e3c9; }
.alert-error { background: #fdeceb; color: #93271c; border: 1px solid #f3c6c1; }

/* ---- WYSIWYG editor ---- */
.wysiwyg { border: 1px solid #cbd2de; border-radius: 8px; overflow: hidden; background: #fff; }
.wysiwyg-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; padding: 8px 10px; background: #f4f6fb; border-bottom: 1px solid var(--line); }
.wy-group { display: flex; gap: 4px; }
.wysiwyg-toolbar button { background: #fff; border: 1px solid var(--line); border-radius: 6px; min-width: 34px; padding: 5px 10px; font-size: 13px; cursor: pointer; color: var(--ink); line-height: 1.2; }
.wysiwyg-toolbar button:hover { border-color: var(--gold); background: #fffdf6; }
.wysiwyg-toolbar button:active { background: var(--gold); color: var(--navy); }
.wysiwyg-editor { min-height: 280px; padding: 16px 18px; font-size: 14px; line-height: 1.7; outline: none; }
.wysiwyg-editor:focus { box-shadow: inset 0 0 0 2px rgba(201,168,76,.25); }
.wysiwyg-editor:empty:before { content: attr(data-placeholder); color: #9aa3b2; }
.wysiwyg-editor p { margin: 0 0 10px; }

/* ---- Attachment picker ---- */
.attach-list { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.attach-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 14px; }
.attach-item:last-child { border-bottom: none; }
.attach-item:hover { background: #fafbfe; }
.attach-item input { width: auto; }
.attach-item .tag { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: #e7eefc; color: var(--navy); }
.attach-item .tag.contract { background: #e4f5ec; color: var(--green); }

/* ---- Email view ---- */
.email-meta { font-size: 13px; color: var(--muted); }
.email-meta strong { color: var(--ink); }
.email-body { font-size: 14px; line-height: 1.7; border: 1px solid var(--line); border-radius: 8px; padding: 16px; background: #fff; overflow-wrap: anywhere; }

/* ---- Confirmation modal ---- */
.modal-overlay { position: fixed; inset: 0; background: rgba(11, 27, 61, .55); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 20px; }
.modal-overlay[hidden] { display: none; }
.modal-box { background: #fff; border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,.35); width: 100%; max-width: 440px; padding: 24px; }
.modal-box h3 { margin: 0 0 10px; color: var(--navy); font-size: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* ---- Login ---- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--navy), #1d2f63); padding: 20px; }
.login-card { background: #fff; border-radius: 14px; box-shadow: 0 12px 40px rgba(0,0,0,.3); width: 100%; max-width: 400px; overflow: hidden; }
.login-head { background: var(--navy); border-bottom: 3px solid var(--gold); color: #fff; padding: 24px; text-align: center; }
.login-head .org { color: var(--gold); font-weight: 700; letter-spacing: .04em; }
.login-head .title { font-size: 13px; color: #cdd5e6; margin-top: 4px; }
.login-body { padding: 26px 24px 28px; }
.muted { color: var(--muted); font-size: 13px; }
.text-right { text-align: right; }
.mt-2 { margin-top: 12px; } .mt-3 { margin-top: 20px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row input { width: auto; }
.checkbox-row label { margin: 0; font-weight: 400; }

/* ---- Public intake form ---- */
.intake-wrap { min-height: 100vh; background: var(--bg); }
.intake-header { background: var(--navy); border-bottom: 3px solid var(--gold); padding: 20px; text-align: center; }
.intake-header .org { color: var(--gold); font-weight: 700; font-size: 14px; letter-spacing: .04em; }
.intake-header .title { color: #cdd5e6; font-size: 13px; margin-top: 4px; }
.intake-body { max-width: 720px; margin: 0 auto; padding: 28px 20px 60px; }
.intake-body h2 { font-size: 17px; color: var(--navy); margin: 28px 0 14px; border-top: 1px solid var(--line); padding-top: 24px; }
.intake-body h2:first-of-type { border-top: none; margin-top: 0; padding-top: 0; }
.wellbeing-item { margin-bottom: 22px; }
.wellbeing-item .q-text { font-size: 14px; font-weight: 600; color: var(--ink); margin: 0 0 10px; }
.wellbeing-scale { display: flex; gap: 6px; }
.wellbeing-scale label { flex: 1; text-align: center; cursor: pointer; }
.wellbeing-scale input[type=radio] { display: none; }
.wellbeing-scale .scale-btn { display: block; padding: 8px 4px; border: 1px solid var(--line); border-radius: 6px; font-size: 11px; color: var(--muted); background: #fff; transition: all .15s; }
.wellbeing-scale input:checked + .scale-btn { background: var(--navy); color: #fff; border-color: var(--navy); }
.wellbeing-scale label:hover .scale-btn { border-color: var(--gold); }
.scale-num { display: block; font-size: 16px; font-weight: 700; margin-bottom: 3px; }
.scale-label { display: block; font-size: 10px; line-height: 1.2; }
.consent-box { background: #f8f9fc; border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; margin-bottom: 10px; }
.consent-box label { font-weight: 400; font-size: 14px; }
.consent-required { border-left: 3px solid var(--gold); }
.intake-submit { margin-top: 24px; }
.intake-submit .btn { width: 100%; padding: 12px; font-size: 15px; }

/* Pastor care pathway */
.pathway-intro { border-top: 4px solid var(--gold); margin-bottom: 24px; }
.pathway-intro h1, .pathway-result h1 { color: var(--navy); font-family: Georgia, serif; font-size: clamp(25px, 5vw, 38px); line-height: 1.15; margin: 8px 0 16px; }
.pathway-intro > p:not(.pathway-kicker), .pathway-result > p { font-size: 15px; line-height: 1.75; }
.pathway-kicker { color: #927019; font-size: 11px; font-weight: 700; letter-spacing: 1.2px; margin: 0 0 6px; text-transform: uppercase; }
.privacy-promise { background: #f7f3e8; border-left: 3px solid var(--gold); border-radius: 4px; display: grid; gap: 5px; margin-top: 20px; padding: 14px 16px; }
.privacy-promise span { color: var(--muted); font-size: 13px; line-height: 1.55; }
.pastor-assessment .card { padding: clamp(18px, 4vw, 30px); }
.question-section { border-top: 1px solid #e6e1d5; color: #927019; font-size: 11px; font-weight: 700; letter-spacing: 1px; margin: 30px 0 18px; padding-top: 20px; text-transform: uppercase; }
.wellbeing-item { border: 0; min-width: 0; padding: 0; }
.wellbeing-item .q-text { align-items: flex-start; display: flex; gap: 10px; }
.wellbeing-item .q-text > span { align-items: center; background: var(--navy); border-radius: 50%; color: #fff; display: inline-flex; flex: 0 0 25px; font-size: 12px; height: 25px; justify-content: center; }
.compact-scale { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.compact-scale .scale-btn { min-height: 47px; padding: 7px 4px; }
.compact-scale .scale-label { font-size: 10px; line-height: 1.25; }
.safety-note { align-items: flex-start; background: #fff8e7; border-color: #e8ce8a; display: grid; gap: 5px; font-size: 13px; }
.pathway-result-primary { border-top: 5px solid var(--gold); }
.pathway-result h2 { color: #927019; font-family: Georgia, serif; font-size: 20px; line-height: 1.35; }
.pathway-next { background: #f7f3e8; border-radius: 5px; padding: 14px; }
.secondary-pathway, .pathway-profile, .pathway-action, .email-pathway { margin-top: 20px; }
.secondary-pathway h2, .pathway-profile h2, .pathway-action h2, .email-pathway h2 { color: var(--navy); margin-top: 0; }
.profile-row { margin: 17px 0; }
.profile-row > div:first-child { display: flex; font-size: 13px; justify-content: space-between; margin-bottom: 6px; }
.profile-row > div:first-child span { color: var(--muted); }
.profile-bar { background: #ece9e1; border-radius: 8px; height: 9px; overflow: hidden; }
.profile-bar span { background: linear-gradient(90deg, #c9a84c, #927019); display: block; height: 100%; }
.pathway-action { background: var(--navy); color: #fff; text-align: center; }
.pathway-action h2 { color: #fff; }
.urgent-care { background: #fff3f1; border: 2px solid var(--red); margin-bottom: 20px; }
.urgent-care h2 { color: var(--red); }
.result-footnote { color: var(--muted); font-size: 12px; line-height: 1.6; margin: 22px auto; max-width: 700px; }

@media (max-width: 620px) {
    .compact-scale { flex-direction: column; gap: 5px; }
    .compact-scale label { width: 100%; }
    .compact-scale .scale-btn { align-items: center; min-height: 38px; padding: 8px 12px; text-align: left; }
    .compact-scale .scale-label { font-size: 12px; }
}
.subscale-head { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--gold-dark); margin: 20px 0 12px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.subscale-head:first-child { margin-top: 0; }

/* Dual-response (SHALOM-style) rows */
.dual-row { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.dual-label { font-size: 12px; color: var(--muted); width: 92px; flex-shrink: 0; text-align: right; }
.dual-scale { display: flex; gap: 6px; flex: 1; }
.dual-scale label { cursor: pointer; }
.dual-scale input[type=radio] { display: none; }
.dual-scale .dual-btn { display: inline-block; min-width: 34px; text-align: center; padding: 6px 0; border: 1px solid var(--line); border-radius: 6px; font-size: 13px; font-weight: 600; color: var(--muted); background: #fff; transition: all .15s; }
.dual-scale input:checked + .dual-btn { background: var(--navy); color: #fff; border-color: var(--navy); }
.dual-scale label:hover .dual-btn { border-color: var(--gold); }

@media (max-width: 560px) {
  .wellbeing-scale { gap: 3px; }
  .scale-num { font-size: 14px; }
  .scale-label { display: none; }
  .dual-row { flex-direction: column; align-items: stretch; gap: 4px; }
  .dual-label { text-align: left; width: auto; }
}

/* Two-factor setup + recovery codes */
.setup-key { font-family: monospace; font-size: 18px; letter-spacing: .12em; background: var(--bg); border: 1px dashed var(--gold-dark); border-radius: 8px; padding: 14px; text-align: center; color: var(--navy); font-weight: 600; }
.recovery-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 12px; max-width: 420px; }
.recovery-code { font-family: monospace; font-size: 15px; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px; text-align: center; letter-spacing: .08em; }
@media (max-width: 560px) { .recovery-grid { grid-template-columns: 1fr; } }

/* Instrument question editor */
.question-row { border-bottom: 1px solid var(--line); padding: 10px 0; }
.question-row summary { cursor: pointer; display: flex; align-items: center; gap: 8px; font-size: 14px; list-style: none; }
.question-row summary::-webkit-details-marker { display: none; }
.question-row .q-order { background: var(--bg); border: 1px solid var(--line); border-radius: 5px; width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; color: var(--muted); flex-shrink: 0; }
.question-row .q-summary { flex: 1; }

/* ---- Client portal ---- */
.portal-topbar { background: var(--navy); border-bottom: 3px solid var(--gold); }
.portal-topbar-inner { max-width: 960px; margin: 0 auto; padding: 0 20px; display: flex; align-items: center; gap: 24px; min-height: 60px; flex-wrap: wrap; }
.portal-container { max-width: 960px; margin: 28px auto; padding: 0 20px; }
.portal-nav { display: flex; flex-wrap: wrap; gap: 4px; margin-left: auto; align-items: center; }
.portal-nav a { color: #dfe5f2; text-decoration: none; padding: 8px 14px; border-radius: 6px; font-size: 14px; }
.portal-nav a:hover { background: var(--navy-light); color: #fff; }
.portal-nav a.active { background: var(--gold); color: var(--navy); font-weight: 600; }
.portal-nav form { margin: 0; }
