/* ── AIMCA — Dark Fintech Theme ─────────────────────────────────── */
:root {
  --bg-deep: #050a18;
  --bg-card: #0c1425;
  --bg-surface: #111b2e;
  --bg-hover: #162038;
  --border: #1e2d4a;
  --text: #e2e8f0;
  --text-dim: #8892a8;
  --text-muted: #5a6478;
  --green: #10b981;
  --green-bg: rgba(16,185,129,.12);
  --amber: #f59e0b;
  --amber-bg: rgba(245,158,11,.12);
  --red: #ef4444;
  --red-bg: rgba(239,68,68,.12);
  --blue: #3b82f6;
  --blue-bg: rgba(59,130,246,.12);
  --accent: #10b981;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 2px 8px rgba(0,0,0,.3);
  --font: 'Inter', -apple-system, system-ui, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body { font-family: var(--font); background: var(--bg-deep); color: var(--text); line-height: 1.5; min-height: 100vh; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
input, select, textarea, button { font-family: inherit; font-size: inherit; }

/* ── Buttons ──────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .5rem 1rem; border-radius: var(--radius); border: 1px solid transparent; cursor: pointer; font-weight: 500; transition: all .15s; text-decoration: none; }
.btn-primary { background: var(--accent); color: #000; border-color: var(--accent); }
.btn-primary:hover { background: #0ea572; text-decoration: none; }
.btn-ghost { background: transparent; color: var(--text-dim); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }
.btn-outline { background: transparent; color: var(--text); border-color: var(--text-dim); }
.btn-outline:hover { border-color: var(--text); text-decoration: none; }
.btn-full { width: 100%; justify-content: center; }
.btn-lg { padding: .75rem 1.5rem; font-size: 1rem; }
.btn-sm { padding: .3rem .6rem; font-size: .8rem; }
.btn-xs { padding: .15rem .35rem; font-size: .75rem; }
.btn-green { background: var(--green); color: #000; }

/* ── Forms ─────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: .3rem; }
.form-group label { font-size: .8rem; color: var(--text-dim); font-weight: 500; text-transform: uppercase; letter-spacing: .03em; }
.form-input { background: var(--bg-deep); border: 1px solid var(--border); border-radius: var(--radius); padding: .55rem .75rem; color: var(--text); outline: none; transition: border .15s; }
.form-input:focus { border-color: var(--accent); }
.form-input::placeholder { color: var(--text-muted); }
select.form-input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238892a8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .6rem center; padding-right: 2rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.form-section { margin-bottom: 1.5rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border); }
.section-title { font-size: .9rem; color: var(--accent); margin-bottom: .75rem; text-transform: uppercase; letter-spacing: .05em; }

/* ── Cards ─────────────────────────────────────────────────────── */
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.25rem; margin-bottom: 1rem; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.card-header h3 { font-size: 1rem; font-weight: 600; }
.card-desc { color: var(--text-dim); font-size: .85rem; margin-bottom: 1rem; }

/* ── Alerts / Badges ──────────────────────────────────────────── */
.alert { padding: .6rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: .85rem; }
.alert-error { background: var(--red-bg); color: var(--red); border: 1px solid rgba(239,68,68,.25); }
.alert-success { background: var(--green-bg); color: var(--green); border: 1px solid rgba(16,185,129,.25); }
.badge { display: inline-block; padding: .15rem .5rem; border-radius: 99px; font-size: .75rem; font-weight: 600; }
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-amber { background: var(--amber-bg); color: var(--amber); }
.badge-red { background: var(--red-bg); color: var(--red); }

/* ── Landing ──────────────────────────────────────────────────── */
.landing-body { background: var(--bg-deep); }
.landing-container { max-width: 1100px; margin: 0 auto; padding: 0 1.5rem; }
.landing-header { padding: 1rem 0; }
.landing-header .landing-container { display: flex; justify-content: space-between; align-items: center; }
.landing-brand { font-size: 1.3rem; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: .4rem; }
.brand-icon { font-size: 1.2rem; }
.landing-nav { display: flex; gap: .75rem; }
.hero { padding: 5rem 0 4rem; text-align: center; }
.hero-badge { display: inline-block; padding: .3rem .9rem; background: var(--green-bg); color: var(--green); border-radius: 99px; font-size: .8rem; font-weight: 600; margin-bottom: 1.5rem; }
.hero-title { font-size: 3rem; font-weight: 800; line-height: 1.1; margin-bottom: 1.25rem; }
.text-green { color: var(--green); }
.hero-sub { font-size: 1.1rem; color: var(--text-dim); max-width: 600px; margin: 0 auto 2rem; line-height: 1.6; }
.hero-ctas { display: flex; gap: .75rem; justify-content: center; }
.features-section { padding: 4rem 0; }
.features-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.5rem; }
.feature-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 2rem 1.5rem; text-align: center; }
.feature-icon { font-size: 2.5rem; margin-bottom: 1rem; }
.feature-card h3 { margin-bottom: .5rem; font-size: 1.1rem; }
.feature-card p { color: var(--text-dim); font-size: .9rem; line-height: 1.5; }
.stats-section { padding: 3rem 0; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.5rem; text-align: center; }
.stat-number { font-size: 2.5rem; font-weight: 800; color: var(--green); }
.stat-label { color: var(--text-dim); font-size: .85rem; margin-top: .25rem; }
.cta-section { padding: 4rem 0; text-align: center; }
.cta-section h2 { font-size: 2rem; margin-bottom: .5rem; }
.cta-section p { color: var(--text-dim); margin-bottom: 1.5rem; }
.landing-footer { padding: 2rem 0; text-align: center; color: var(--text-muted); font-size: .8rem; }

/* ── Auth ──────────────────────────────────────────────────────── */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg-deep); }
.auth-container { width: 100%; max-width: 420px; padding: 1rem; }
.auth-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 2rem; }
.auth-brand { font-size: 1.5rem; font-weight: 700; text-align: center; margin-bottom: 1.5rem; display: flex; align-items: center; justify-content: center; gap: .4rem; }
.auth-card h2 { text-align: center; margin-bottom: .25rem; }
.auth-sub { text-align: center; color: var(--text-dim); margin-bottom: 1.5rem; font-size: .9rem; }
.auth-card .form-group { margin-bottom: 1rem; }
.auth-card .btn { margin-top: .5rem; }
.auth-switch { text-align: center; margin-top: 1.25rem; font-size: .85rem; color: var(--text-dim); }

/* ── App Shell ────────────────────────────────────────────────── */
.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: 230px; background: var(--bg-card); border-right: 1px solid var(--border); display: flex; flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0; z-index: 100; transition: transform .2s; }
.sidebar-brand { padding: 1rem 1.25rem; font-size: 1.2rem; font-weight: 700; display: flex; align-items: center; gap: .4rem; border-bottom: 1px solid var(--border); }
.sidebar-close { display: none; background: none; border: none; color: var(--text); font-size: 1.5rem; cursor: pointer; margin-left: auto; }
.sidebar-nav { flex: 1; padding: .5rem 0; overflow-y: auto; display: flex; flex-direction: column; }
.nav-item { display: flex; align-items: center; gap: .6rem; padding: .55rem 1.25rem; color: var(--text-dim); font-size: .85rem; transition: all .15s; text-decoration: none; }
.nav-item:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--bg-hover); color: var(--accent); border-right: 2px solid var(--accent); }
.nav-icon { font-size: 1rem; width: 1.4rem; text-align: center; }
.nav-spacer { flex: 1; }
.sidebar-user { padding: .75rem 1.25rem; border-top: 1px solid var(--border); display: flex; align-items: center; gap: .6rem; }
.user-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: #000; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .8rem; flex-shrink: 0; }
.user-name { font-size: .8rem; font-weight: 600; }
.user-company { font-size: .7rem; color: var(--text-muted); }
.main-content { margin-left: 230px; flex: 1; min-width: 0; }
.topbar { padding: .75rem 1.5rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 1rem; background: var(--bg-card); position: sticky; top: 0; z-index: 50; }
.hamburger { display: none; background: none; border: none; color: var(--text); font-size: 1.3rem; cursor: pointer; }
.page-title { font-size: 1.05rem; font-weight: 600; }
.content-area { padding: 1.5rem; max-width: 1200px; }

/* ── Dashboard ────────────────────────────────────────────────── */
.dashboard-grid { display: flex; flex-direction: column; gap: 1rem; }
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; }
.stat-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.25rem; }
.stat-card .stat-label { font-size: .75rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: .04em; }
.stat-card .stat-value { font-size: 1.8rem; font-weight: 700; margin-top: .25rem; }
.stat-card.stat-green .stat-value { color: var(--green); }
.quick-actions { display: flex; gap: .75rem; flex-wrap: wrap; }
.action-btn { display: flex; align-items: center; gap: .4rem; padding: .6rem 1.2rem; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); font-weight: 500; text-decoration: none; transition: all .15s; }
.action-btn:hover { background: var(--bg-hover); text-decoration: none; }
.action-btn.action-green { border-color: rgba(16,185,129,.3); color: var(--green); }
.action-btn.action-amber { border-color: rgba(245,158,11,.3); color: var(--amber); }
.pipeline-stages { display: flex; gap: .5rem; flex-wrap: wrap; }
.stage-pill { display: flex; align-items: center; gap: .4rem; padding: .4rem .8rem; border-radius: var(--radius); font-size: .8rem; font-weight: 500; text-decoration: none; transition: all .15s; }
.stage-pill:hover { text-decoration: none; opacity: .85; }
.stage-new { background: var(--blue-bg); color: var(--blue); }
.stage-qualifying { background: rgba(139,92,246,.12); color: #8b5cf6; }
.stage-submitted { background: var(--amber-bg); color: var(--amber); }
.stage-approved { background: rgba(6,182,212,.12); color: #06b6d4; }
.stage-funded { background: var(--green-bg); color: var(--green); }
.stage-declined { background: var(--red-bg); color: var(--red); }
.stage-dead { background: rgba(107,114,128,.12); color: #6b7280; }
.stage-count { font-weight: 700; }
.deal-list { display: flex; flex-direction: column; }
.deal-row { display: flex; justify-content: space-between; align-items: center; padding: .65rem 0; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .1s; }
.deal-row:last-child { border-bottom: none; }
.deal-row:hover { background: var(--bg-hover); margin: 0 -1.25rem; padding-left: 1.25rem; padding-right: 1.25rem; }
.deal-info { display: flex; flex-direction: column; gap: .15rem; }
.deal-name { font-weight: 600; font-size: .9rem; }
.deal-meta { font-size: .75rem; color: var(--text-dim); }
.deal-right { display: flex; align-items: center; gap: .5rem; }
.stage-badge { padding: .15rem .5rem; border-radius: 99px; font-size: .7rem; font-weight: 600; }
.score-mini { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 50%; font-size: .75rem; font-weight: 700; }
.score-green { background: var(--green-bg); color: var(--green); }
.score-amber { background: var(--amber-bg); color: var(--amber); }
.score-red { background: var(--red-bg); color: var(--red); }
.empty-state { padding: 2rem; text-align: center; color: var(--text-dim); }

/* ── Quick Qual / Full Deal ───────────────────────────────────── */
.qual-layout { display: grid; grid-template-columns: 1fr; gap: 1rem; }
.result-card { border-color: var(--accent); }
.score-display { display: flex; gap: 2rem; align-items: center; margin-bottom: 1.5rem; flex-wrap: wrap; }
.score-circle { width: 120px; height: 120px; border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; flex-shrink: 0; }
.score-circle.score-green { background: var(--green-bg); border: 3px solid var(--green); }
.score-circle.score-amber { background: var(--amber-bg); border: 3px solid var(--amber); }
.score-circle.score-red { background: var(--red-bg); border: 3px solid var(--red); }
.score-number { font-size: 2.2rem; font-weight: 800; line-height: 1; }
.score-circle.score-green .score-number { color: var(--green); }
.score-circle.score-amber .score-number { color: var(--amber); }
.score-circle.score-red .score-number { color: var(--red); }
.score-label { font-size: .65rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: .05em; margin-top: .2rem; }
.score-details { flex: 1; min-width: 200px; }
.score-row { display: flex; justify-content: space-between; padding: .4rem 0; border-bottom: 1px solid var(--border); font-size: .85rem; }
.score-row span { color: var(--text-dim); }
.tier-badge { padding: .1rem .4rem; border-radius: 4px; font-size: .8rem; }
.tier-A { background: var(--green-bg); color: var(--green); }
.tier-B { background: var(--blue-bg); color: var(--blue); }
.tier-C { background: var(--amber-bg); color: var(--amber); }
.tier-D { background: var(--red-bg); color: var(--red); }
.strategy-box { display: flex; gap: .75rem; align-items: flex-start; background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }
.strategy-icon { font-size: 1.3rem; }
.strategy-text { font-size: .9rem; line-height: 1.5; }
.sr-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
.sr-col h4 { font-size: .85rem; margin-bottom: .5rem; }
.sr-item { font-size: .85rem; padding: .3rem 0; color: var(--text-dim); }
.strengths .sr-item { color: var(--green); }
.risks .sr-item { color: var(--amber); }
.save-form { border-top: 1px solid var(--border); padding-top: 1rem; margin-top: 1rem; }
.save-actions { display: flex; gap: .75rem; margin-top: .75rem; }

/* Deal Structure */
.deal-structure, .lender-matching, .strategy-list, .script-box, .followup-seq { margin-bottom: 1.5rem; }
.deal-structure h4, .lender-matching h4, .strategy-list h4, .script-box h4, .followup-seq h4 { font-size: .9rem; margin-bottom: .75rem; color: var(--accent); }
.structure-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .75rem; }
.struct-item { background: var(--bg-surface); border-radius: var(--radius); padding: .6rem .8rem; }
.struct-item span { display: block; font-size: .7rem; color: var(--text-dim); text-transform: uppercase; }
.struct-item strong { font-size: 1.05rem; }
.lender-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; }
.lender-item { background: var(--bg-surface); border-radius: var(--radius); padding: .6rem; text-align: center; }
.lender-tier { font-weight: 700; font-size: .85rem; }
.lender-fit { font-size: .8rem; font-weight: 600; margin: .25rem 0; }
.fit-good .lender-fit { color: var(--green); }
.fit-fair .lender-fit { color: var(--amber); }
.fit-poor .lender-fit { color: var(--red); }
.lender-notes { font-size: .7rem; color: var(--text-dim); }
.strategy-item { padding: .4rem 0; font-size: .85rem; border-bottom: 1px solid var(--border); }
.script-content { background: var(--bg-surface); border-radius: var(--radius); padding: 1rem; font-size: .85rem; line-height: 1.6; white-space: pre-wrap; word-wrap: break-word; font-family: var(--font); color: var(--text-dim); max-height: 400px; overflow-y: auto; }
.fu-item { display: flex; align-items: flex-start; gap: .75rem; padding: .6rem 0; border-bottom: 1px solid var(--border); }
.fu-day { font-weight: 600; font-size: .8rem; color: var(--text-dim); min-width: 45px; }
.fu-channel { font-size: .7rem; font-weight: 600; padding: .1rem .4rem; border-radius: 4px; min-width: 45px; text-align: center; }
.channel-sms { background: var(--blue-bg); color: var(--blue); }
.channel-email { background: var(--green-bg); color: var(--green); }
.channel-call { background: var(--amber-bg); color: var(--amber); }
.fu-template { font-size: .85rem; color: var(--text-dim); flex: 1; }

/* ── Chat ─────────────────────────────────────────────────────── */
.chat-layout { display: grid; grid-template-columns: 1fr 220px; grid-template-rows: auto 1fr; gap: 1rem; height: calc(100vh - 120px); }
.chat-modes { grid-column: 1 / -1; display: flex; gap: .5rem; flex-wrap: wrap; }
.mode-btn { padding: .4rem .8rem; border-radius: var(--radius); border: 1px solid var(--border); background: var(--bg-card); color: var(--text-dim); cursor: pointer; font-size: .8rem; transition: all .15s; }
.mode-btn.active { border-color: var(--accent); color: var(--accent); background: rgba(16,185,129,.08); }
.chat-container { display: flex; flex-direction: column; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.chat-messages { flex: 1; overflow-y: auto; padding: 1rem; }
.chat-welcome { text-align: center; padding: 3rem 1rem; }
.welcome-icon { font-size: 3rem; margin-bottom: 1rem; }
.chat-welcome h3 { margin-bottom: .5rem; }
.chat-welcome p { color: var(--text-dim); margin-bottom: 1.5rem; font-size: .9rem; }
.welcome-prompts { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; }
.prompt-btn { padding: .4rem .7rem; border-radius: var(--radius); border: 1px solid var(--border); background: var(--bg-surface); color: var(--text-dim); cursor: pointer; font-size: .8rem; transition: all .15s; }
.prompt-btn:hover { border-color: var(--accent); color: var(--accent); }
.chat-msg { display: flex; gap: .75rem; padding: .75rem 0; }
.msg-avatar { font-size: 1.2rem; padding-top: .1rem; }
.msg-content { flex: 1; line-height: 1.6; font-size: .9rem; }
.msg-user .msg-content { color: var(--text); }
.msg-assistant .msg-content { color: var(--text-dim); }
.typing { color: var(--accent); animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }
.chat-input-area { display: flex; gap: .5rem; padding: .75rem; border-top: 1px solid var(--border); }
.chat-input-area textarea { flex: 1; background: var(--bg-deep); border: 1px solid var(--border); border-radius: var(--radius); padding: .5rem .75rem; color: var(--text); resize: none; outline: none; }
.chat-input-area textarea:focus { border-color: var(--accent); }
.chat-sidebar { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1rem; overflow-y: auto; }
.chat-sidebar h4 { font-size: .85rem; margin-bottom: .75rem; color: var(--text-dim); }
.session-item { padding: .5rem .6rem; border-radius: var(--radius); cursor: pointer; margin-bottom: .25rem; transition: background .1s; }
.session-item:hover { background: var(--bg-hover); }
.session-title { display: block; font-size: .8rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.session-mode { font-size: .65rem; color: var(--text-muted); }

/* ── Pipeline ─────────────────────────────────────────────────── */
.pipeline-page { display: flex; flex-direction: column; gap: 1rem; }
.pipeline-filters { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.filter-pill { padding: .35rem .7rem; border-radius: var(--radius); border: 1px solid var(--border); color: var(--text-dim); font-size: .8rem; text-decoration: none; transition: all .15s; }
.filter-pill:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.filter-pill.active { background: var(--accent); color: #000; border-color: var(--accent); }
.sort-group { margin-left: auto; display: flex; gap: .5rem; align-items: center; font-size: .8rem; color: var(--text-muted); }
.sort-link { color: var(--text-dim); text-decoration: none; padding: .2rem .4rem; border-radius: 4px; }
.sort-link.active { color: var(--accent); background: rgba(16,185,129,.08); }
.deals-table { overflow-x: auto; }
.table-header { display: grid; grid-template-columns: 2fr 1fr .7fr 1.1fr .6fr .9fr .7fr; gap: .5rem; padding: .5rem 0; border-bottom: 1px solid var(--border); font-size: .7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.table-row { display: grid; grid-template-columns: 2fr 1fr .7fr 1.1fr .6fr .9fr .7fr; gap: .5rem; padding: .6rem 0; border-bottom: 1px solid var(--border); align-items: center; font-size: .85rem; }
.table-row:hover { background: var(--bg-hover); }
.col-name strong { display: block; }
.col-name small { color: var(--text-dim); font-size: .75rem; }
.stage-select { background: var(--bg-card); border: 1px solid var(--border); border-radius: 4px; color: var(--text); padding: .2rem .4rem; font-size: .75rem; cursor: pointer; }
.stage-select option { background: #0d1530; color: #f0f4ff; padding: 8px; }
.stage-select.stage-funded { border-color: rgba(16,185,129,.3); color: var(--green); }
.stage-select.stage-approved { border-color: rgba(6,182,212,.3); color: #06b6d4; }
.stage-select.stage-declined { border-color: rgba(239,68,68,.3); color: var(--red); }

.stage-select.stage-contracts_sent { border-color: rgba(168,85,247,.3); color: #a855f7; }
.stage-select.stage-contract_signed { border-color: rgba(99,102,241,.3); color: #6366f1; }
.stage-select.stage-bank_login { border-color: rgba(14,165,233,.3); color: #0ea5e9; }
.stage-select.stage-funding_call { border-color: rgba(234,179,8,.3); color: #eab308; }
.stage-select.stage-dead { border-color: rgba(107,114,128,.3); color: #6b7280; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 200; padding: 1rem; }
.modal-content { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.5rem; max-width: 600px; width: 100%; max-height: 85vh; overflow-y: auto; position: relative; -webkit-overflow-scrolling: touch; }
@media(max-width:640px){
  .modal-content{max-height:92vh;border-radius:16px 16px 0 0;margin-top:auto;padding:20px 16px calc(20px + env(safe-area-inset-bottom));}
  .modal-overlay{align-items:flex-end;padding:0;}
  .modal-grid{grid-template-columns:1fr !important;gap:.4rem !important;}
}
.modal-close { position: absolute; top: .75rem; right: .75rem; background: none; border: none; color: var(--text-dim); font-size: 1.3rem; cursor: pointer; }
.modal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin: 1rem 0; font-size: .85rem; }

/* ── Dead Files ───────────────────────────────────────────────── */
.dead-files-page { display: flex; flex-direction: column; gap: 1rem; }
.upload-area { display: flex; align-items: center; gap: 1rem; }
.dead-list { display: flex; flex-direction: column; }
.dead-item { display: flex; justify-content: space-between; align-items: center; padding: .65rem 0; border-bottom: 1px solid var(--border); gap: 1rem; }
.dead-item:last-child { border-bottom: none; }
.dead-info { display: flex; flex-direction: column; gap: .2rem; flex: 1; }
.dead-info strong { font-size: .9rem; }
.dead-info span { font-size: .8rem; }
.rec-text { color: var(--text-dim); font-size: .8rem; }
.status-badge { padding: .1rem .4rem; border-radius: 4px; font-size: .75rem; font-weight: 600; }
.status-green { color: var(--green); }
.status-yellow { color: var(--amber); }
.status-red { color: var(--red); }
.status-pending { color: var(--text-muted); }
.status-converted { color: var(--blue); }
.recovery-stats { display: flex; gap: 1rem; margin: 1rem 0; }
.recovery-stat { flex: 1; text-align: center; padding: 1rem; border-radius: var(--radius); }
.recovery-stat.stat-green { background: var(--green-bg); }
.recovery-stat.stat-amber { background: var(--amber-bg); }
.recovery-stat.stat-red { background: var(--red-bg); }
.recovery-count { display: block; font-size: 2rem; font-weight: 700; }
.recovery-label { font-size: .8rem; }
.revenue-estimate { text-align: center; padding: 1rem; background: var(--green-bg); border-radius: var(--radius); color: var(--green); }

/* ── Scripts ──────────────────────────────────────────────────── */
.scripts-page { display: flex; flex-direction: column; gap: 1rem; }
.script-card .card-header { flex-wrap: wrap; }
.script-meta { display: flex; align-items: center; gap: .5rem; }

/* ── Portal Badge ────────────────────────────────────────────── */
.portal-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; border-radius: 99px; background: var(--red); color: #fff; font-size: .65rem; font-weight: 700; margin-left: auto; padding: 0 4px; }

/* ── My Portal ───────────────────────────────────────────────── */
.portal-page { display: flex; flex-direction: column; gap: 1rem; }
.portal-link-box { display: flex; align-items: center; gap: .75rem; background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem 1rem; }
.portal-link-box input { flex: 1; background: var(--bg-deep); border: 1px solid var(--border); border-radius: var(--radius); padding: .5rem .75rem; color: var(--accent); font-family: monospace; font-size: .85rem; }
.portal-link-box .btn { flex-shrink: 0; }
.portal-qr { text-align: center; padding: 1rem; }
.portal-qr img { border-radius: var(--radius); }
.share-template { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin-bottom: .75rem; position: relative; }
.share-template h4 { font-size: .85rem; color: var(--accent); margin-bottom: .5rem; }
.share-template pre { font-size: .8rem; color: var(--text-dim); white-space: pre-wrap; word-wrap: break-word; line-height: 1.5; }
.share-copy { position: absolute; top: .75rem; right: .75rem; background: var(--bg-card); border: 1px solid var(--border); border-radius: 4px; color: var(--text-dim); padding: .2rem .5rem; font-size: .7rem; cursor: pointer; }
.share-copy:hover { color: var(--accent); border-color: var(--accent); }
.portal-leads-list { display: flex; flex-direction: column; }
.portal-lead-row { display: flex; justify-content: space-between; align-items: center; padding: .65rem 0; border-bottom: 1px solid var(--border); gap: 1rem; flex-wrap: wrap; }
.portal-lead-row:last-child { border-bottom: none; }
.portal-lead-info { display: flex; flex-direction: column; gap: .15rem; flex: 1; min-width: 200px; }
.portal-lead-info strong { font-size: .9rem; }
.portal-lead-info span { font-size: .75rem; color: var(--text-dim); }
.portal-lead-actions { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.portal-lead-actions .btn { font-size: .75rem; padding: .25rem .5rem; }
.portal-stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }

/* ── Settings ─────────────────────────────────────────────────── */
.settings-page { max-width: 600px; }

/* ── Lender Directory ────────────────────────────────────────── */
.lenders-page { display: flex; flex-direction: column; gap: 1rem; }
.lender-search-bar { display: flex; gap: .5rem; margin-bottom: .5rem; }
.count-badge { font-size: .7rem; font-weight: 700; opacity: .7; margin-left: .2rem; }
.tier-pill-A { border-color: rgba(16,185,129,.3); }
.tier-pill-B { border-color: rgba(59,130,246,.3); }
.tier-pill-C { border-color: rgba(245,158,11,.3); }
.tier-pill-D { border-color: rgba(239,68,68,.3); }
.tier-pill-unknown { border-color: rgba(100,116,139,.3); }

.lender-list { display: flex; flex-direction: column; gap: .5rem; }
.lender-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1rem 1.25rem; }
.lender-card:hover { border-color: rgba(16,185,129,.2); }
.lender-card-header { display: flex; align-items: center; gap: .6rem; margin-bottom: .4rem; }
.lender-name { font-size: 1rem; }
.lender-tier-badge { display: inline-flex; align-items: center; padding: .15rem .5rem; border-radius: 4px; font-size: .7rem; font-weight: 700; flex-shrink: 0; }
.lender-tier-badge.tier-a { background: var(--green-bg); color: var(--green); }
.lender-tier-badge.tier-b { background: var(--blue-bg); color: var(--blue); }
.lender-tier-badge.tier-c { background: var(--amber-bg); color: var(--amber); }
.lender-tier-badge.tier-d { background: var(--red-bg); color: var(--red); }
.lender-tier-badge.tier-unknown { background: rgba(100,116,139,.12); color: #64748b; }
.lender-aka { font-size: .8rem; color: var(--text-muted); margin-bottom: .3rem; }
.lender-venue { font-size: .8rem; color: var(--text-dim); margin-bottom: .3rem; }
.lender-notes { font-size: .85rem; color: var(--text-dim); background: var(--bg-surface); border-radius: var(--radius); padding: .5rem .75rem; margin: .4rem 0; line-height: 1.5; border-left: 3px solid var(--accent); }
.lender-card-footer { display: flex; align-items: center; gap: .5rem; margin-top: .5rem; flex-wrap: wrap; }
.lender-email-wrap { display: flex; align-items: center; gap: .3rem; flex: 1; min-width: 200px; }
.lender-email-input { font-size: .8rem; padding: .3rem .5rem; flex: 1; }
.lender-updated { font-size: .7rem; color: var(--text-muted); margin-top: .3rem; }

/* Matching Lenders (inline in results) */
.matching-lenders-section { margin: 1.5rem 0; padding-top: 1rem; border-top: 1px solid var(--border); }
.matching-lenders-section h4 { font-size: .9rem; color: var(--accent); margin-bottom: .5rem; }
.matching-lender-list { display: flex; flex-direction: column; gap: .35rem; max-height: 400px; overflow-y: auto; }
.matching-lender-item { display: flex; align-items: flex-start; gap: .5rem; padding: .4rem .6rem; background: var(--bg-surface); border-radius: var(--radius); }
.matching-lender-info { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.matching-lender-info strong { font-size: .85rem; }
.lender-aka-small { font-size: .75rem; color: var(--text-muted); }
.lender-notes-small { font-size: .75rem; color: var(--text-dim); line-height: 1.4; }

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: block; }
  .main-content { margin-left: 0; }
  .hamburger { display: block; }
  .hero-title { font-size: 2rem; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .hero-ctas { flex-direction: column; align-items: center; }
  .table-header, .table-row { grid-template-columns: 1.5fr 1fr .8fr; }
  .col-tier, .col-date, .col-actions { display: none; }
  .chat-layout { grid-template-columns: 1fr; }
  .chat-sidebar { display: none; }
  .sr-grid { grid-template-columns: 1fr; }
  .lender-grid { grid-template-columns: repeat(2, 1fr); }
  .score-display { flex-direction: column; align-items: flex-start; }
  .form-grid { grid-template-columns: 1fr; }
  .lender-email-wrap { min-width: 150px; }
  .lender-card-footer { flex-direction: column; align-items: stretch; }
}
@media (max-width: 480px) {
  .content-area { padding: 1rem; }
  .stats-row { grid-template-columns: 1fr 1fr; }
  .quick-actions { flex-direction: column; }
}


/* Mobile filter/toggle fixes */
@media(max-width:768px){
  .pipeline-filters{flex-direction:column;gap:8px;align-items:stretch;}
  .filter-group{display:flex;flex-wrap:wrap;gap:6px;}
  .filter-pill{padding:8px 12px;font-size:0.75rem;min-height:36px;display:inline-flex;align-items:center;justify-content:center;-webkit-tap-highlight-color:transparent;touch-action:manipulation;}
  .sort-group{margin-left:0;flex-wrap:wrap;gap:8px;}
  .sort-link{padding:4px 8px;min-height:32px;display:inline-flex;align-items:center;}
  .count-badge{font-size:0.68rem;}
}
@media(max-width:480px){
  .filter-pill{padding:6px 10px;font-size:0.7rem;}
}
