:root {
  --bg: #06080F; --surface: #0B0F1C; --card: #0F1525; --card2: #131929;
  --border: #1A2540; --border-hi: #263558; --text: #BCC8E8; --muted: #6A7C9E; --dim: #2B3A55;
  --teal: #00BFA5; --gold: #F0A500; --purple: #8B5CF6; --red: #F04060; --blue: #3B82F6; --green: #10B981; --orange: #F97316;
  --white: #EEF2FF;
  --mono: "DM Mono", ui-monospace, monospace; --sans: "DM Sans", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--sans); font-size: 14px; line-height: 1.55; background: var(--bg); color: var(--text); min-height: 100vh; }
a { color: var(--teal); }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: var(--white); background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--teal); }
label { display: block; font-size: 11px; font-family: var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
h1 { font-size: 26px; color: var(--white); line-height: 1.2; }
h2 { font-size: 18px; color: var(--white); margin-bottom: 4px; }
h3 { font-size: 14px; color: var(--white); margin-bottom: 6px; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.small { font-size: 12px; }
.eyebrow { font-family: var(--mono); font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--teal); }

/* layout */
.topbar { display: flex; align-items: center; gap: 16px; padding: 12px 24px; border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 10; flex-wrap: wrap; }
.brand { display: flex; flex-direction: column; }
.brand b { color: var(--white); font-size: 15px; }
.topbar .spacer { flex: 1; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 28px 24px 80px; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 14px; }
@media (max-width: 860px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } .wrap { padding: 20px 16px 60px; } .bo-layout { grid-template-columns: 1fr !important; } }

.card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 18px; }
.card.hi { border-color: var(--border-hi); }
.card.teal { border-color: rgba(0,191,165,.35); background: linear-gradient(180deg, rgba(0,191,165,.07), var(--card)); }
.card.gold { border-color: rgba(240,165,0,.35); background: linear-gradient(180deg, rgba(240,165,0,.07), var(--card)); }
.card.purple { border-color: rgba(139,92,246,.35); background: linear-gradient(180deg, rgba(139,92,246,.07), var(--card)); }
.card.clickable { cursor: pointer; transition: border-color .12s, transform .12s; }
.card.clickable:hover { border-color: var(--teal); transform: translateY(-1px); }

.btn { background: var(--teal); color: #031512; border: none; border-radius: 6px; padding: 9px 16px; font-weight: 600; }
.btn:hover { filter: brightness(1.1); }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--border-hi); }
.btn.ghost:hover { border-color: var(--teal); color: var(--white); }
.btn.gold { background: var(--gold); color: #1a1000; }
.btn.danger { background: transparent; color: var(--red); border: 1px solid rgba(240,64,96,.4); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }

.tag { display: inline-block; font-family: var(--mono); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; padding: 3px 8px; border-radius: 4px; border: 1px solid; white-space: nowrap; }
.t-teal { color: var(--teal); border-color: rgba(0,191,165,.35); background: rgba(0,191,165,.1); }
.t-gold { color: var(--gold); border-color: rgba(240,165,0,.35); background: rgba(240,165,0,.1); }
.t-red { color: var(--red); border-color: rgba(240,64,96,.35); background: rgba(240,64,96,.1); }
.t-purple { color: var(--purple); border-color: rgba(139,92,246,.35); background: rgba(139,92,246,.1); }
.t-blue { color: var(--blue); border-color: rgba(59,130,246,.35); background: rgba(59,130,246,.1); }
.t-muted { color: var(--muted); border-color: var(--border-hi); }
.t-green { color: var(--green); border-color: rgba(16,185,129,.35); background: rgba(16,185,129,.1); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 18px 0; overflow-x: auto; }
.tab { background: none; border: none; color: var(--muted); padding: 10px 14px; border-bottom: 2px solid transparent; white-space: nowrap; display: flex; gap: 6px; align-items: center; }
.tab.active { color: var(--teal); border-bottom-color: var(--teal); }
.tab:hover { color: var(--white); }

.kpi { display: flex; flex-direction: column; gap: 2px; }
.kpi .v { font-size: 26px; font-weight: 700; color: var(--white); line-height: 1.1; }
.kpi .l { font-family: var(--mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }

.score-ring { --p: 50; --c: var(--teal); width: 92px; height: 92px; border-radius: 50%; background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--dim) 0); display: grid; place-items: center; flex-shrink: 0; }
.score-ring > div { width: 74px; height: 74px; border-radius: 50%; background: var(--card); display: grid; place-items: center; text-align: center; }
.score-ring b { font-size: 24px; color: var(--white); line-height: 1; }
.score-ring span { font-size: 9px; font-family: var(--mono); color: var(--muted); letter-spacing: .08em; }

.bar { height: 6px; background: var(--dim); border-radius: 3px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--teal); border-radius: 3px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { font-family: var(--mono); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; background: var(--card); }
td input, td select { padding: 5px 7px; font-size: 12.5px; min-width: 70px; }

.steps { display: flex; flex-direction: column; gap: 10px; counter-reset: s; }
.step { display: grid; grid-template-columns: 28px 1fr; gap: 10px; align-items: start; }
.step::before { counter-increment: s; content: counter(s); width: 26px; height: 26px; border-radius: 50%; background: rgba(0,191,165,.12); color: var(--teal); display: grid; place-items: center; font-family: var(--mono); font-size: 12px; border: 1px solid rgba(0,191,165,.3); }
.step b { color: var(--white); display: block; }
.step p { color: var(--muted); font-size: 13px; }

.check { display: flex; gap: 8px; align-items: center; font-size: 13px; padding: 3px 0; }
.check i { width: 16px; height: 16px; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-size: 10px; flex-shrink: 0; }
.check.ok i { background: rgba(16,185,129,.2); color: var(--green); }
.check.no i { background: rgba(240,64,96,.15); color: var(--red); }

.locked { text-align: center; padding: 40px 20px; }
.locked .ico { font-size: 34px; margin-bottom: 8px; }

.toast { position: fixed; bottom: 20px; right: 20px; background: var(--card2); border: 1px solid var(--teal); color: var(--white); padding: 10px 16px; border-radius: 8px; z-index: 100; box-shadow: 0 8px 30px rgba(0,0,0,.4); }
.toast.err { border-color: var(--red); }

.bo-layout { display: grid; grid-template-columns: 300px 1fr; gap: 18px; align-items: start; }
.client-list { display: flex; flex-direction: column; gap: 6px; max-height: calc(100vh - 160px); overflow-y: auto; position: sticky; top: 76px; }
.client-row { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; cursor: pointer; }
.client-row.active, .client-row:hover { border-color: var(--teal); }
.kanban { display: grid; grid-template-columns: repeat(4, minmax(200px, 1fr)); gap: 12px; overflow-x: auto; }
.kanban .col { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px; min-height: 200px; }
pre.json { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 14px; overflow: auto; font-family: var(--mono); font-size: 11.5px; max-height: 560px; color: var(--text); }
.hr { border: none; border-top: 1px solid var(--border); margin: 14px 0; }
.note { border-left: 3px solid var(--gold); background: rgba(240,165,0,.06); padding: 10px 14px; border-radius: 6px; font-size: 13px; }
.note.teal { border-color: var(--teal); background: rgba(0,191,165,.06); }
.bo-layout > *, .grid > * { min-width: 0; }
.note .mono, pre.json { word-break: break-all; }
pre.json { white-space: pre-wrap; }

/* ---- inside the DTMG AI Hub ---- */
a.btn { text-decoration: none; display: inline-flex; align-items: center; }
.topbar .hub-back { margin-right: 4px; }
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; gap: 8px; }
  .topbar .spacer { display: none; }
}
.brandbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 24px; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--teal) 10%, var(--surface)); }
.brandbar b { color: var(--white); }
.brandbar .spacer { flex: 1; }
input[type=color] { padding: 2px; height: 38px; }
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; width: 720px; max-width: 100%; max-height: 92vh; display: flex; flex-direction: column; }
.modal iframe { flex: 1; min-height: 60vh; width: 100%; border: 0; border-radius: 8px; background: #fff; }

/* ===================== v1.12: sign-in, client portal theme, documents, application ===================== */
/* Client portal: light, professional theme (brand colors still come from the partner's branding) */
body[data-mode="client"] {
  --bg: #f4f6fb; --surface: #ffffff; --card: #ffffff; --card2: #f8fafc;
  --border: #e3e8f1; --border-hi: #cfd8e6; --text: #334155; --muted: #64748b; --dim: #e2e8f0;
  --white: #0f172a; --teal: #1d4ed8; --gold: #b45309; --red: #dc2626; --green: #047857; --blue: #2563eb;
  --sans: "Inter", "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
}
body[data-mode="client"] .card { box-shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 1px 12px rgba(15, 23, 42, .04); }
body[data-mode="client"] .btn { color: #fff; }
body[data-mode="client"] .btn.ghost { color: var(--text); background: #fff; }
body[data-mode="client"] .btn.gold { color: #fff; }
body[data-mode="client"] input, body[data-mode="client"] select, body[data-mode="client"] textarea { background: #fff; color: #0f172a; border-color: #d5dce8; padding: 10px 12px; }
body[data-mode="client"] input:focus, body[data-mode="client"] select:focus, body[data-mode="client"] textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px color-mix(in srgb, var(--teal) 18%, transparent); }
body[data-mode="client"] input:disabled, body[data-mode="client"] select:disabled { background: #f1f5f9; color: #475569; }
body[data-mode="client"] label { font-family: var(--sans); text-transform: none; letter-spacing: 0; font-size: 13px; font-weight: 600; color: #334155; }
body[data-mode="client"] .eyebrow { font-family: var(--sans); font-weight: 600; letter-spacing: .08em; }
body[data-mode="client"] .topbar { background: #fff; box-shadow: 0 1px 0 var(--border); }
body[data-mode="client"] .toast { background: #0f172a; color: #fff; border-color: #0f172a; }
body[data-mode="client"] .toast.err { background: #7f1d1d; border-color: #7f1d1d; }
body[data-mode="client"] .score-ring > div { background: #fff; }
body[data-mode="client"] .brandbar { background: color-mix(in srgb, var(--teal) 6%, #fff); }
body[data-mode="client"] .note { background: color-mix(in srgb, var(--teal) 6%, #fff); }
body[data-mode="client"] pre.json { background: #f8fafc; color: #0f172a; }

/* Sign-in screens */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(320px, 46%) 1fr; }
.auth-side { background: linear-gradient(150deg, #1e3a8a 0%, #1d4ed8 55%, #2563eb 100%); color: #e0e7ff; padding: 56px 56px 40px; display: flex; flex-direction: column; gap: 18px; position: relative; overflow: hidden; }
.auth-side::after { content: ""; position: absolute; right: -120px; bottom: -120px; width: 380px; height: 380px; border-radius: 50%; background: rgba(255,255,255,.07); }
.auth-side h1 { color: #fff; font-size: 34px; line-height: 1.15; margin-top: 36px; max-width: 460px; letter-spacing: -.01em; }
.auth-side p { font-size: 16px; max-width: 440px; color: #dbe4ff; }
.auth-mark { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 17px; }
.auth-logo { width: 40px; height: 40px; border-radius: 10px; background: #fff; color: #1d4ed8; display: grid; place-items: center; font-weight: 800; font-size: 14px; letter-spacing: .02em; }
.auth-points { list-style: none; display: grid; gap: 12px; margin-top: 10px; max-width: 460px; }
.auth-points li { padding-left: 30px; position: relative; color: #dbe4ff; }
.auth-points li::before { content: "✓"; position: absolute; left: 0; top: 0; width: 20px; height: 20px; border-radius: 50%; background: rgba(255,255,255,.18); color: #fff; font-size: 12px; display: grid; place-items: center; }
.auth-points b { color: #fff; }
.auth-badge { align-self: flex-start; margin-top: 36px; background: rgba(255,255,255,.14); color: #fff; border: 1px solid rgba(255,255,255,.25); padding: 4px 12px; border-radius: 999px; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.auth-badge + h1 { margin-top: 6px; }
.auth-main { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 24px; background: var(--bg); }
.auth-card { width: 100%; max-width: 460px; background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 34px 32px; box-shadow: 0 20px 50px rgba(15, 23, 42, .08); }
.auth-card h2 { font-size: 24px; margin-bottom: 6px; }
.auth-card > p.muted { margin-bottom: 20px; }
.auth-card .stack { gap: 14px; }
.btn.wide { width: 100%; padding: 12px 16px; font-size: 15px; }
.auth-alt { margin-top: 16px; text-align: center; font-size: 14px; color: var(--muted); }
.auth-divider { display: flex; align-items: center; gap: 12px; margin: 22px 0 14px; color: var(--muted); font-size: 13px; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.auth-foot { margin-top: 18px; font-size: 12px; color: var(--muted); text-align: center; max-width: 460px; }
.auth-foot a { color: var(--muted); }
body[data-mode="client"] .auth-card:has(form[data-submit="doSignup"]) { max-width: 640px; }
.check-line { display: flex !important; gap: 10px; align-items: flex-start; font-family: var(--sans) !important; text-transform: none !important; letter-spacing: 0 !important; font-size: 13px !important; font-weight: 400 !important; color: var(--text) !important; line-height: 1.45; margin: 4px 0; }
.check-line input { width: auto; min-width: 0; margin-top: 3px; flex: none; }
/* Back-office sign-in: same layout, dark */
.auth-admin .auth-side { background: linear-gradient(150deg, #0b1020 0%, #111a33 60%, #1b2a55 100%); }
.auth-admin .auth-logo { background: #1d4ed8; color: #fff; }
.auth-admin .auth-card { background: var(--card); box-shadow: 0 20px 60px rgba(0,0,0,.45); }
@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; }
  .auth-side { padding: 28px 22px; }
  .auth-side h1 { font-size: 24px; margin-top: 14px; }
  .auth-points { display: none; }
  .auth-card { padding: 26px 20px; border-radius: 14px; }
}

/* Documents */
.progress { width: 220px; height: 10px; border-radius: 999px; background: var(--dim); overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--teal); border-radius: 999px; }
.doc-row { display: flex; gap: 14px; align-items: flex-start; padding: 16px 18px; background: var(--card); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 10px; transition: border-color .15s, background .15s; }
.doc-row.submitted { border-left: 4px solid var(--green); }
.doc-row.missing { border-left: 4px solid var(--gold); }
.doc-row.optional { border-left: 4px solid var(--border-hi); }
.doc-row:has(input[data-upload]):hover { border-color: var(--teal); }
.doc-status { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; flex: none; font-size: 14px; }
.doc-row.submitted .doc-status { background: color-mix(in srgb, var(--green) 14%, transparent); color: var(--green); }
.doc-row.missing .doc-status { background: color-mix(in srgb, var(--gold) 16%, transparent); color: var(--gold); }
.doc-row.optional .doc-status { background: var(--dim); color: var(--muted); }
.doc-main { flex: 1; min-width: 0; }
.doc-main b { color: var(--white); }
.file-chip { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; font-size: 13px; margin-top: 8px; padding: 7px 10px; background: var(--card2); border: 1px solid var(--border); border-radius: 8px; }
.file-chip span:first-child { color: var(--white); overflow-wrap: anywhere; }
.file-chip a { font-size: 12px; text-decoration: none; }
.file-chip a.danger { color: var(--red); }
.upload-btn { cursor: pointer; flex: none; align-self: center; }

/* Application */
.app-section { margin-bottom: 14px; }
.app-section h3 { font-size: 16px; margin-bottom: 14px; }
.span-all { grid-column: 1 / -1; }
.req { color: var(--red); }
.auth-list { padding-left: 18px; display: grid; gap: 6px; font-size: 13px; color: var(--text); }
.sigpad-wrap { position: relative; border: 2px dashed var(--border-hi); border-radius: 12px; background: #fff; margin-bottom: 10px; }
.sigpad-wrap canvas { display: block; width: 100%; height: 170px; touch-action: none; cursor: crosshair; border-radius: 10px; }
.sigpad-wrap::after { content: ""; position: absolute; left: 6%; right: 6%; bottom: 38px; border-bottom: 1px solid #cbd5e1; pointer-events: none; }
.sig-clear { position: absolute; top: 8px; right: 8px; }
.sig-hint { position: absolute; left: 12px; bottom: 10px; font-size: 12px; color: #94a3b8; pointer-events: none; }
.sig-done { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.sig-done img { max-height: 80px; max-width: 320px; background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 6px 12px; }
body[data-mode="client"] .brandbar { display: none; }

/* v1.12 polish */
label.upload-btn { display: inline-flex; font-family: var(--sans); text-transform: none; letter-spacing: 0; font-size: 12px; font-weight: 600; margin: 0; cursor: pointer; }
.auth-admin .btn.wide, .auth-admin .btn.primary { background: #1d4ed8; border-color: #1d4ed8; color: #fff; }
.auth-admin .auth-card a { color: #93b4ff; }
.tabs.bo-nav { flex-wrap: wrap; overflow: visible; }

/* v1.12.2: BFN logo */
.logo-chip { display: inline-flex; align-items: center; background: #fff; border-radius: 8px; padding: 3px 8px; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.logo-chip img { height: 32px; width: auto; display: block; }
.logo-chip.lg { border-radius: 14px; padding: 10px 16px; box-shadow: 0 10px 30px rgba(2,6,23,.25); }
.logo-chip.lg img { height: 76px; }
.brand-row { flex-direction: row; align-items: center; gap: 12px; }
.topbar-logo { height: 40px; width: auto; display: block; }
.brand-divider { width: 1px; height: 26px; background: var(--border); }
@media (max-width: 760px) { .logo-chip.lg img { height: 56px; } .topbar-logo { height: 32px; } }
