:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #22263a;
  --border: #2a2e42;
  --text: #e2e8f0;
  --text-muted: #8892a4;
  --accent: #6366f1;
  --accent-hover: #4f52d9;
  --green: #10b981;
  --red: #ef4444;
  --yellow: #f59e0b;
  --radius: 12px;
  --sidebar-w: 220px;
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  font-size: 14px;
}

/* ── Sidebar ──────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}
.logo { display: flex; align-items: center; gap: 10px; margin-bottom: 32px; padding: 0 8px; }
.logo-icon { font-size: 24px; }
.logo-text { font-size: 18px; font-weight: 700; }
.nav-links { list-style: none; display: flex; flex-direction: column; gap: 4px; }
.nav-links a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; color: var(--text-muted); text-decoration: none; font-size: 13px; font-weight: 500; transition: all 0.15s; }
.nav-links a:hover { background: var(--surface2); color: var(--text); }
.nav-links a.active { background: var(--accent); color: white; }

/* ── Content ──────────────────────────────────────────────────── */
.content { margin-left: var(--sidebar-w); flex: 1; padding: 32px; min-width: 0; }
.view { display: none; }
.view.active { display: block; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.page-header h1 { font-size: 24px; font-weight: 700; }
.date { color: var(--text-muted); font-size: 13px; }
.section-label { font-size: 13px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin: 24px 0 12px; }
.muted { color: var(--text-muted); font-size: 13px; line-height: 1.6; }

/* ── Cards ────────────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; }
.card h2 { font-size: 16px; font-weight: 600; margin-bottom: 16px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* ── Stat Grid ────────────────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.stat-card.primary { border-color: var(--accent); background: rgba(99,102,241,.08); }
.stat-card.negative { border-color: var(--red); background: rgba(239,68,68,.06); }
.stat-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 8px; text-align: left; }
.stat-value { font-size: 24px; font-weight: 700; text-align: right; }
.stat-card.primary .stat-value { color: var(--accent); }
.stat-card.negative .stat-value { color: var(--red); }

/* ── Account / Asset Cards ────────────────────────────────────── */
.accounts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; margin-bottom: 12px; }
.account-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; position: relative; }
.acc-type-badge { font-size: 11px; background: var(--surface2); border-radius: 4px; padding: 2px 8px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.acc-name { font-size: 16px; font-weight: 600; margin: 8px 0 4px; }
.acc-institution { font-size: 12px; color: var(--text-muted); margin-bottom: 12px; }
.acc-balance { font-size: 26px; font-weight: 700; }
.acc-balance.positive { color: var(--green); }
.acc-balance.negative { color: var(--red); }
.acc-meta { font-size: 12px; color: var(--text-muted); margin-top: 6px; }
.acc-gain { font-size: 12px; margin-top: 4px; }
.acc-gain.positive { color: var(--green); }
.acc-gain.negative { color: var(--red); }
.acc-actions { position: absolute; top: 16px; right: 16px; display: flex; gap: 8px; }
.acc-actions button { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 14px; padding: 4px; border-radius: 4px; }
.acc-actions button:hover { background: var(--surface2); color: var(--text); }
.utilization-bar { height: 4px; background: var(--surface2); border-radius: 2px; margin-top: 10px; }
.utilization-fill { height: 100%; border-radius: 2px; background: var(--accent); transition: width .3s; }
.utilization-fill.warn { background: var(--yellow); }
.utilization-fill.danger { background: var(--red); }

/* ── Dashboard account list ───────────────────────────────────── */
#accounts-list-dashboard { display: flex; flex-direction: column; gap: 10px; }
.acc-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); }
.acc-row:last-child { border-bottom: none; }
.acc-row-name { font-weight: 500; }
.acc-row-type { font-size: 11px; color: var(--text-muted); }
.acc-row-balance { font-weight: 600; font-size: 15px; }
.acc-row-balance.positive { color: var(--green); }
.acc-row-balance.negative { color: var(--red); }

/* ── Spending ─────────────────────────────────────────────────── */
.spending-item { margin-bottom: 10px; }
.spending-label { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; }
.spending-bar-bg { height: 6px; background: var(--surface2); border-radius: 3px; }
.spending-bar { height: 100%; border-radius: 3px; }

/* ── Alerts ───────────────────────────────────────────────────── */
.alert-box { background: rgba(245,158,11,.1); border: 1px solid var(--yellow); border-radius: var(--radius); padding: 14px 18px; margin-bottom: 16px; display: flex; align-items: flex-start; gap: 12px; }
.alert-icon { font-size: 18px; }
.alert-title { font-weight: 600; margin-bottom: 2px; }
.alert-msg { font-size: 13px; color: var(--text-muted); }

/* ── Transactions ─────────────────────────────────────────────── */
.filters { display: flex; gap: 12px; margin-bottom: 16px; }
.filters select { background: var(--surface); border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: 8px 12px; font-size: 13px; }
.txn-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.txn-table th { text-align: left; padding: 10px 12px; color: var(--text-muted); font-weight: 500; border-bottom: 1px solid var(--border); }
.txn-table td { padding: 12px; border-bottom: 1px solid var(--border); }
.txn-table tr:last-child td { border-bottom: none; }
.txn-table tr:hover td { background: var(--surface2); }
.amount-positive { color: var(--green); font-weight: 600; text-align: right; }
.amount-negative { color: var(--text); font-weight: 600; text-align: right; }
.category-badge { background: var(--surface2); border-radius: 4px; padding: 2px 8px; font-size: 11px; color: var(--text-muted); text-transform: capitalize; }
.btn-delete { background: none; border: none; cursor: pointer; color: var(--text-muted); padding: 4px 8px; border-radius: 4px; font-size: 14px; }
.btn-delete:hover { background: rgba(239,68,68,.1); color: var(--red); }

/* ── Liabilities ──────────────────────────────────────────────── */
.liability-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 12px; display: flex; justify-content: space-between; align-items: flex-start; }
.lib-info { flex: 1; }
.lib-name { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.lib-meta { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.lib-progress-bg { height: 6px; background: var(--surface2); border-radius: 3px; width: 240px; margin-top: 8px; }
.lib-progress-fill { height: 100%; border-radius: 3px; background: var(--red); transition: width .3s; }
.lib-balance { font-size: 22px; font-weight: 700; color: var(--red); text-align: right; }
.lib-payment { font-size: 12px; color: var(--text-muted); text-align: right; margin-top: 4px; }
.lib-actions { margin-left: 16px; }

/* ── Rules ────────────────────────────────────────────────────── */
.ai-assist-box { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 20px; }
.ai-assist-input { display: flex; gap: 10px; }
.ai-assist-input input { flex: 1; background: var(--surface); border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: 10px 14px; font-size: 13px; }
.ai-assist-input input:focus { outline: none; border-color: var(--accent); }
.rule-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 12px; display: flex; align-items: flex-start; gap: 16px; }
.rule-card.disabled { opacity: .5; }
.rule-toggle { cursor: pointer; font-size: 20px; margin-top: 2px; }
.rule-info { flex: 1; }
.rule-name { font-weight: 600; font-size: 15px; margin-bottom: 4px; }
.rule-description { color: var(--text-muted); font-size: 13px; margin-bottom: 8px; }
.rule-condition { font-size: 12px; background: var(--surface2); border-radius: 6px; padding: 6px 10px; display: inline-block; }
.rule-action { margin-top: 8px; font-size: 13px; color: var(--accent); }

/* ── Ingest ───────────────────────────────────────────────────── */
textarea { width: 100%; background: var(--surface2); border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: 10px 12px; font-size: 13px; font-family: monospace; resize: vertical; }
textarea:focus { outline: none; border-color: var(--accent); }
.tips-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.tips-list li { display: flex; gap: 8px; font-size: 13px; color: var(--text-muted); }
.tips-list li::before { content: '→'; color: var(--accent); }
.bulk-balance-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.bulk-balance-row label { flex: 1; font-size: 13px; }
.bulk-balance-row input { width: 120px; background: var(--surface2); border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: 8px 10px; font-size: 13px; text-align: right; }

/* ── Settings ─────────────────────────────────────────────────── */
.info-box { background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; margin-top: 12px; }
.info-box strong { display: block; margin-bottom: 6px; }
.info-box p { font-size: 13px; color: var(--text-muted); }
.info-box a { color: var(--accent); text-decoration: none; }
.info-box a:hover { text-decoration: underline; }
.credit-history-item { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.credit-history-item:last-child { border-bottom: none; }
.score-badge { font-weight: 700; font-size: 18px; }
.score-badge.excellent { color: var(--green); }
.score-badge.good { color: #84cc16; }
.score-badge.fair { color: var(--yellow); }
.score-badge.poor { color: var(--red); }

/* ── Chat ─────────────────────────────────────────────────────── */
.chat-container { display: flex; flex-direction: column; height: calc(100vh - 160px); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.chat-messages { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.chat-msg { display: flex; }
.chat-msg.user { justify-content: flex-end; }
.chat-bubble { max-width: 70%; padding: 12px 16px; border-radius: 12px; font-size: 14px; line-height: 1.6; }
.chat-msg.user .chat-bubble { background: var(--accent); color: white; border-bottom-right-radius: 4px; }
.chat-msg.assistant .chat-bubble { background: var(--surface2); color: var(--text); border-bottom-left-radius: 4px; }
.chat-input-row { display: flex; gap: 10px; padding: 16px; border-top: 1px solid var(--border); }
.chat-input-row input { flex: 1; background: var(--surface2); border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: 10px 14px; font-size: 14px; }
.chat-input-row input:focus { outline: none; border-color: var(--accent); }

/* ── AI Content ───────────────────────────────────────────────── */
.ai-content { line-height: 1.7; font-size: 14px; }
.ai-placeholder { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.ai-icon { font-size: 48px; margin-bottom: 16px; }
.ai-content h1 { font-size: 20px; margin: 16px 0 8px; }
.ai-content h2 { font-size: 17px; border-bottom: 1px solid var(--border); padding-bottom: 6px; margin: 20px 0 10px; }
.ai-content h3 { font-size: 15px; margin: 14px 0 6px; }
.ai-content p { margin-bottom: 10px; color: var(--text-muted); }
.ai-content p strong, .ai-content strong { color: var(--text); }
.ai-content ul, .ai-content ol { padding-left: 20px; margin-bottom: 10px; color: var(--text-muted); }
.ai-content li { margin-bottom: 4px; }
.ai-content code { background: var(--surface2); padding: 2px 6px; border-radius: 4px; font-size: 13px; }
.streaming-cursor::after { content: '▊'; animation: blink .8s step-end infinite; color: var(--accent); }
@keyframes blink { 50% { opacity: 0; } }

/* ── Buttons ──────────────────────────────────────────────────── */
.btn-primary { background: var(--accent); color: white; border: none; border-radius: 8px; padding: 9px 18px; font-size: 13px; font-weight: 500; cursor: pointer; transition: background .15s; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-ghost { background: none; color: var(--text-muted); border: 1px solid var(--border); border-radius: 8px; padding: 9px 18px; font-size: 13px; cursor: pointer; }
.btn-ghost:hover { background: var(--surface2); color: var(--text); }

/* ── Modal ────────────────────────────────────────────────────── */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.7); z-index: 1000; display: flex; align-items: center; justify-content: center; }
.modal.hidden { display: none; }
.modal-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; width: 480px; max-height: 90vh; overflow-y: auto; }
.modal-box h2 { margin-bottom: 20px; font-size: 18px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 13px; color: var(--text-muted); font-weight: 500; }
.form-group input, .form-group select { width: 100%; background: var(--surface2); border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: 10px 12px; font-size: 14px; }
.form-group input:focus, .form-group select:focus { outline: none; border-color: var(--accent); }
.form-group small { color: var(--text-muted); font-size: 11px; display: block; margin-top: 4px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; }
.inline-fields { display: flex; gap: 8px; }
.inline-fields select, .inline-fields input { flex: 1; }

/* ── Success/error status ─────────────────────────────────────── */
.status-ok { color: var(--green); font-size: 13px; }
.status-err { color: var(--red); font-size: 13px; }

/* ── Currency ─────────────────────────────────────────────────── */
.orig-currency { font-size: 11px; color: var(--text-muted); margin-left: 4px; background: var(--surface2); padding: 1px 5px; border-radius: 4px; font-weight: 400; }

/* ── User switcher ────────────────────────────────────────────── */
.user-switcher { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--border); }
.user-select { width: 100%; background: var(--surface2); border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: 8px 10px; font-size: 13px; font-weight: 500; cursor: pointer; }
.user-select:focus { outline: none; border-color: var(--accent); }
.user-label { font-size: 11px; color: var(--text-muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .05em; }

/* ── Integrations ─────────────────────────────────────────────── */
.integration-card { border-color: var(--accent); }
.integration-header { display: flex; align-items: center; gap: 14px; }
.integration-logo { width: 40px; height: 40px; border-radius: 10px; background: linear-gradient(135deg, #00c47d, #027a48); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 13px; color: white; flex-shrink: 0; }
.integration-name { font-weight: 600; font-size: 15px; }
.integration-url { font-size: 12px; color: var(--text-muted); }
.integration-status { font-size: 12px; padding: 3px 10px; border-radius: 20px; font-weight: 500; }
.integration-status.saved { background: rgba(16,185,129,.15); color: var(--green); }
.integration-status.empty { background: var(--surface2); color: var(--text-muted); }

.integration-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--border); }
.integration-row:last-child { border-bottom: none; }
.integration-row-logo { width: 32px; height: 32px; border-radius: 8px; background: var(--surface2); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: var(--text-muted); }
.integration-row-name { font-weight: 500; font-size: 14px; }
.integration-row-user { font-size: 12px; color: var(--text-muted); }

/* ── Discovery flow ───────────────────────────────────────────── */
.discover-instructions { display: flex; flex-direction: column; gap: 12px; background: var(--surface2); border-radius: var(--radius); padding: 16px; }
.discover-step-row { display: flex; align-items: flex-start; gap: 12px; font-size: 14px; }
.discover-step-num { width: 24px; height: 24px; min-width: 24px; background: var(--accent); color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; }
.discover-step-row kbd { background: var(--surface); border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; font-size: 12px; }
.discover-account-card { display: flex; align-items: flex-start; gap: 12px; padding: 14px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 8px; cursor: pointer; transition: border-color .15s; }
.discover-account-card:hover { border-color: var(--accent); }
.discover-account-card.selected { border-color: var(--accent); background: rgba(99,102,241,.06); }
.discover-account-card input[type=checkbox] { margin-top: 2px; accent-color: var(--accent); width: 16px; height: 16px; flex-shrink: 0; }
.discover-acc-name { font-weight: 600; font-size: 14px; }
.discover-acc-meta { font-size: 12px; color: var(--text-muted); margin-top: 3px; display: flex; flex-wrap: wrap; gap: 8px; }
.discover-acc-tag { background: var(--surface2); border-radius: 4px; padding: 2px 7px; }

/* ── Driver picker ────────────────────────────────────────────── */
.driver-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.driver-card { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px 10px; background: var(--surface2); border: 1.5px solid var(--border); border-radius: var(--radius); cursor: pointer; transition: all .15s; text-align: center; }
.driver-card:hover { border-color: var(--accent); background: rgba(99,102,241,.08); }
.driver-card.coming-soon { opacity: .45; cursor: default; }
.driver-card.coming-soon:hover { border-color: var(--border); background: var(--surface2); }
.driver-card-icon { font-size: 28px; }
.driver-card-name { font-size: 13px; font-weight: 600; color: var(--text); }
.driver-card-desc { font-size: 11px; color: var(--text-muted); line-height: 1.3; }
.driver-card-badge { font-size: 10px; background: var(--surface); border: 1px solid var(--border); color: var(--text-muted); padding: 2px 6px; border-radius: 20px; }

/* ── LTV calculator ───────────────────────────────────────────── */
.ltv-band-bar { display: flex; height: 28px; border-radius: 6px; overflow: visible; position: relative; gap: 2px; }
.ltv-band-seg { border-radius: 4px; background: color-mix(in srgb, var(--band-color) 25%, var(--surface2)); display: flex; align-items: flex-end; padding-bottom: 2px; transition: background .15s; position: relative; }
.ltv-band-seg.active { background: color-mix(in srgb, var(--band-color) 45%, var(--surface2)); outline: 1.5px solid var(--band-color); }
.ltv-band-label { font-size: 9px; color: var(--text-muted); padding: 0 4px; white-space: nowrap; overflow: hidden; }
.ltv-marker { position: absolute; top: -6px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; pointer-events: none; }
.ltv-marker-line { width: 2px; height: 40px; border-radius: 1px; }
.ltv-marker-label { font-size: 10px; font-weight: 700; margin-top: 2px; white-space: nowrap; }
.ltv-action-box { background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 8px; padding: 12px 14px; font-size: 13px; }

/* ── Balance sparklines & liability notes ─────────────────────── */
.balance-sparkline-wrap { display: flex; align-items: center; }
.lib-notes { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ── Credit Health ────────────────────────────────────────────── */
.score-gauge-wrap { margin-top: 12px; }
.score-gauge-bg { height: 8px; background: var(--surface2); border-radius: 4px; overflow: hidden; }
.score-gauge-fill { height: 100%; border-radius: 4px; transition: width .6s ease; }
.score-label-badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.score-range-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.score-range-row { display: flex; align-items: center; gap: 8px; font-size: 13px; opacity: .55; transition: opacity .15s; }
.score-range-row.active { opacity: 1; font-weight: 600; }
.score-range-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.score-range-label { flex: 1; }
.score-range-val { font-size: 12px; color: var(--text-muted); }
.score-chart-wrap { width: 100%; overflow-x: auto; }

/* Drop-off timeline */
.timeline-item { display: flex; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.timeline-item:last-child { border-bottom: none; }
.timeline-dot { width: 12px; height: 12px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.timeline-body { flex: 1; }
.timeline-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.timeline-name { font-weight: 600; font-size: 14px; }
.timeline-date { font-size: 13px; font-weight: 600; }
.timeline-meta { font-size: 12px; color: var(--text-muted); margin-top: 4px; margin-bottom: 8px; }
.timeline-progress-bg { height: 6px; background: var(--surface2); border-radius: 3px; overflow: hidden; }
.timeline-progress-fill { height: 100%; border-radius: 3px; transition: width .6s ease; }

/* Problem accounts */
.problem-account-row { display: flex; justify-content: space-between; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--border); }
.problem-account-row:last-of-type { border-bottom: none; }
.problem-type-badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; margin-right: 8px; }
.problem-name { font-weight: 600; font-size: 14px; }
.problem-meta { font-size: 13px; color: var(--text-muted); }
.problem-balance { font-size: 16px; font-weight: 700; }
.problem-drop { font-size: 11px; color: var(--text-muted); }

/* Strategy */
.strategy-item { padding: 14px 0; border-bottom: 1px solid var(--border); }
.strategy-item:last-child { border-bottom: none; }
.strategy-header { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.strategy-priority { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.strategy-name { font-weight: 600; flex: 1; }
.strategy-amount { font-size: 14px; font-weight: 700; color: var(--red); }
.strategy-action { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.strategy-rationale { font-size: 12px; color: var(--text-muted); line-height: 1.5; }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }


/* ── Ownership badge ── */
.own-badge {
  display: inline-block;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 10px;
  margin-left: 6px;
  cursor: pointer;
  vertical-align: middle;
  transition: opacity .15s;
}
.own-badge:hover { opacity: .7; }
.own-100 { background: var(--surface2); color: var(--text-muted); border: 1px solid var(--border); }
.own-partial { background: #f59e0b22; color: #f59e0b; border: 1px solid #f59e0b44; font-weight: 600; }

/* ── Inline-editable table ── */
.table-wrap { width: 100%; overflow-x: auto; }
.inline-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 600px; }
.inline-table th { padding: 8px 12px; text-align: left; font-size: 11px; color: var(--text-muted); border-bottom: 1px solid var(--border); white-space: nowrap; }
.inline-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.inline-table tr:last-child td { border-bottom: none; }
.inline-table tbody tr:hover { background: var(--surface2); }
.inline-table .editable { cursor: text; border-radius: 3px; padding: 1px 3px; }
.inline-table .editable:hover { background: var(--surface2); outline: 1px dashed var(--border); }
.inline-table tfoot td { border-top: 2px solid var(--border); background: var(--surface2); }

/* ── Company profile badges ── */
.badge {
  display: inline-block;
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 10px;
  background: var(--surface2);
  color: var(--text-muted);
  border: 1px solid var(--border);
  font-weight: 500;
  letter-spacing: 0.02em;
}

/* ── Markdown tables (AI brief) ── */
.md-table { width: 100%; border-collapse: collapse; font-size: 13px; margin: 12px 0; }
.md-table th { padding: 8px 12px; text-align: left; font-size: 12px; font-weight: 600; color: var(--text-muted); border-bottom: 2px solid var(--border); background: var(--surface2); white-space: nowrap; }
.md-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); }
.md-table tr:last-child td { border-bottom: none; }
.md-table tr:hover td { background: var(--surface2); }
.md-table td:first-child, .md-table th:first-child { padding-left: 16px; }

/* ── Markdown HR ── */
.streaming-cursor hr, #brief-content hr { border: none; height: 1px; background: var(--border); margin: 20px 0; }

/* ── TL;DR Card ── */
.tldr-card { background: linear-gradient(135deg, var(--surface2), var(--bg)); border-left: 4px solid var(--accent); }
.tldr-card h2 { font-size: 16px; margin-bottom: 8px; }
.tldr-card p, .tldr-card li { font-size: 13px; line-height: 1.6; }

/* ── Action Cards ── */
.action-item { display: flex; justify-content: space-between; align-items: flex-start; padding: 12px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; background: var(--bg); }
.action-item:hover { border-color: var(--accent); }
.action-info { flex: 1; }
.action-title { font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.action-meta { font-size: 11px; color: var(--text-muted); }
.action-buttons { display: flex; gap: 6px; align-items: center; flex-shrink: 0; margin-left: 12px; }
.action-buttons button { font-size: 11px; padding: 4px 10px; border-radius: 4px; border: 1px solid var(--border); background: var(--bg); cursor: pointer; color: var(--text); }
.action-buttons button.accept { border-color: var(--green); color: var(--green); }
.action-buttons button.accept:hover { background: var(--green); color: white; }
.action-buttons button.dismiss { border-color: var(--red); color: var(--red); }
.action-buttons button.dismiss:hover { background: var(--red); color: white; }
.action-buttons button.feedback { border-color: var(--accent); color: var(--accent); }
.urgency-high { color: var(--red); font-weight: 600; }
.urgency-medium { color: var(--yellow); }
.urgency-low { color: var(--green); }

/* ── Goals ── */
.goal-card { padding: 16px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 10px; cursor: pointer; background: var(--bg); transition: border-color 0.2s; }
.goal-card:hover { border-color: var(--accent); }
.goal-card-header { display: flex; justify-content: space-between; align-items: center; }
.goal-card-title { font-weight: 600; font-size: 14px; }
.goal-card-meta { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.goal-card-badges { display: flex; gap: 6px; }
.goal-badge { font-size: 10px; padding: 2px 8px; border-radius: 10px; }
.goal-badge.high { background: rgba(239,68,68,0.15); color: var(--red); }
.goal-badge.medium { background: rgba(234,179,8,0.15); color: var(--yellow); }
.goal-badge.low { background: rgba(34,197,94,0.15); color: var(--green); }
.goal-badge.status { background: var(--surface2); color: var(--text-muted); }
.goal-tab { font-size: 13px; padding: 6px 14px; border-radius: 6px; }
.goal-tab.active { background: var(--accent); color: white; border-color: var(--accent); }

/* ── Comments ── */
.comment { padding: 8px 12px; margin-bottom: 8px; border-radius: 8px; font-size: 13px; line-height: 1.5; }
.comment.from-user { background: var(--surface2); margin-left: 40px; }
.comment.from-ai, .comment.from-cron { background: linear-gradient(135deg, rgba(99,102,241,0.1), rgba(99,102,241,0.05)); margin-right: 40px; }
.comment-header { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }

/* ── Changelog ── */
.changelog-entry { padding: 16px; border-left: 3px solid var(--border); margin-bottom: 12px; margin-left: 8px; background: var(--bg); border-radius: 0 8px 8px 0; }
.changelog-entry.feature { border-left-color: var(--green); }
.changelog-entry.fix { border-left-color: var(--red); }
.changelog-entry.improvement { border-left-color: var(--accent); }
.changelog-entry.brief { border-left-color: var(--yellow); }
.changelog-entry.goal { border-left-color: #8b5cf6; }
.changelog-title { font-weight: 600; font-size: 14px; }
.changelog-meta { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.changelog-desc { font-size: 13px; margin-top: 8px; line-height: 1.5; }
.changelog-files { font-size: 11px; color: var(--text-muted); margin-top: 6px; }

/* ── Modal ── */
.modal { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal-content { background: var(--surface); border-radius: 12px; padding: 24px; width: 90%; max-height: 80vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }

/* ── Onboarding Wizard ── */
.onboarding-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: var(--bg); z-index: 2000; display: flex; align-items: center; justify-content: center; overflow-y: auto; }
.onboarding-wizard { width: 100%; max-width: 700px; margin: 20px auto; padding: 0 20px; }
.onboarding-header { text-align: center; margin-bottom: 24px; }
.onboarding-logo { font-size: 24px; font-weight: 700; margin-bottom: 16px; }
.onboarding-progress { max-width: 400px; margin: 0 auto; }
.onboarding-progress-bar { height: 6px; background: var(--surface2); border-radius: 3px; overflow: hidden; }
.onboarding-progress-fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.3s ease; width: 9%; }
.onboarding-step-label { font-size: 12px; color: var(--text-muted); margin-top: 6px; }
.onboarding-body { background: var(--surface); border-radius: 12px; padding: 32px; box-shadow: 0 4px 20px rgba(0,0,0,0.1); min-height: 300px; }
.onboarding-footer { display: flex; align-items: center; gap: 12px; margin-top: 16px; padding: 0 4px; }
.onboard-step h2 { font-size: 20px; margin-bottom: 4px; }
.onboard-step .muted { font-size: 13px; color: var(--text-muted); margin-bottom: 20px; }
.onboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.onboard-grid .full-width { grid-column: 1 / -1; }
.onboard-step hr { border: none; height: 1px; background: var(--border); margin: 20px 0; }
.ob-goals-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ob-goal-option { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 10px 14px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; transition: all 0.2s; }
.ob-goal-option:hover { border-color: var(--accent); background: var(--surface2); }
.ob-goal-option:has(input:checked) { border-color: var(--accent); background: rgba(99,102,241,0.1); }
.ob-goal-option input { accent-color: var(--accent); }

/* ── Profile Page ── */
.profile-section { margin-bottom: 16px; }
.profile-section-header { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; cursor: pointer; border-radius: 8px; background: var(--surface2); }
.profile-section-header:hover { background: var(--border); }
.profile-section-header h3 { font-size: 14px; margin: 0; }
.profile-section-body { padding: 16px; display: none; }
.profile-section.open .profile-section-body { display: block; }
.profile-section.open .profile-section-header { border-radius: 8px 8px 0 0; }
.profile-completion { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.profile-completion-bar { flex: 1; height: 8px; background: var(--surface2); border-radius: 4px; overflow: hidden; }
.profile-completion-fill { height: 100%; background: var(--green); border-radius: 4px; transition: width 0.3s; }
.profile-completion-text { font-size: 13px; font-weight: 600; min-width: 40px; }
@media (max-width: 600px) {
  .onboard-grid, .ob-goals-grid { grid-template-columns: 1fr; }
  .onboarding-body { padding: 20px; }
}

/* ── Mobile Responsive ── */
@media (max-width: 768px) {
  .sidebar { position: fixed; left: -260px; width: 260px; z-index: 900; transition: left 0.3s; height: 100vh; }
  .sidebar.open { left: 0; }
  .content { margin-left: 0 !important; padding: 12px !important; }
  .stat-grid { grid-template-columns: 1fr 1fr !important; gap: 8px !important; }
  .card { padding: 14px !important; }
  .page-header { flex-direction: column; align-items: flex-start !important; gap: 8px; }
  .page-header h1 { font-size: 20px !important; }
  .form-group { margin-bottom: 8px; }
  .form-group input, .form-group select, .form-group textarea { font-size: 16px !important; /* Prevents iOS zoom */ }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .md-table { min-width: 500px; }
  .txn-table { min-width: 400px; }
  .inline-table { min-width: 500px; }
  .modal-content { width: 95% !important; max-height: 90vh !important; padding: 16px !important; }
  .action-item { flex-direction: column; gap: 8px; }
  .action-buttons { margin-left: 0; }
  .goal-card { padding: 12px; }
  .ob-goals-grid { grid-template-columns: 1fr !important; }
  .onboard-grid { grid-template-columns: 1fr !important; }
  .onboarding-body { padding: 16px !important; }
  /* Mobile nav toggle */
  .mobile-menu-btn { display: block !important; position: fixed; top: 12px; left: 12px; z-index: 901; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; font-size: 18px; cursor: pointer; }
  .mobile-overlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); z-index: 899; }
  .sidebar.open ~ .mobile-overlay { display: block; }
  #cron-settings-panel { grid-template-columns: 1fr !important; }
  .changelog-entry { margin-left: 0; }
  .profile-section-header { padding: 12px; }
  .user-switcher { padding: 12px; }
}
@media (min-width: 769px) {
  .mobile-menu-btn { display: none !important; }
  .mobile-overlay { display: none !important; }
}

/* ── Onboarding smart banners ── */
.ob-known-banner { background: rgba(34,197,94,0.1); border: 1px solid rgba(34,197,94,0.3); border-radius: 8px; padding: 12px 16px; font-size: 13px; line-height: 1.5; margin-bottom: 16px; color: var(--green); }

/* ── Onboarding Layout with Sidebar ── */
.onboarding-layout { display: flex; gap: 20px; }
.onboarding-body { flex: 1; min-width: 0; background: var(--surface); border-radius: 12px; padding: 32px; box-shadow: 0 4px 20px rgba(0,0,0,0.1); min-height: 300px; }
.onboarding-sidebar { width: 260px; flex-shrink: 0; background: var(--surface); border-radius: 12px; padding: 20px; box-shadow: 0 4px 20px rgba(0,0,0,0.1); max-height: 500px; overflow-y: auto; }
.onboarding-sidebar h3 { font-size: 13px; font-weight: 600; margin-bottom: 10px; }
.ob-service { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 6px; margin-bottom: 6px; font-size: 12px; }
.ob-service.connected { background: rgba(34,197,94,0.08); border: 1px solid rgba(34,197,94,0.2); }
.ob-service.disconnected { background: var(--surface2); border: 1px solid var(--border); color: var(--text-muted); }
.ob-service-icon { font-size: 16px; }
.ob-service-name { font-weight: 500; }
.ob-service-status { margin-left: auto; font-size: 10px; }
.ob-data-item { display: flex; justify-content: space-between; padding: 4px 0; font-size: 12px; border-bottom: 1px solid var(--border); }
.ob-data-item:last-child { border-bottom: none; }
.ob-data-value { font-weight: 600; color: var(--text); }
.ob-data-source { font-size: 10px; color: var(--text-muted); }
@media (max-width: 768px) {
  .onboarding-layout { flex-direction: column; }
  .onboarding-sidebar { width: 100%; max-height: none; order: -1; }
}

/* ── Profile Layout ── */
.profile-layout { display: flex; gap: 20px; }
.profile-main { flex: 1; min-width: 0; }
.profile-sidebar { width: 280px; flex-shrink: 0; }
.profile-sidebar .card { padding: 16px; }
@media (max-width: 768px) {
  .profile-layout { flex-direction: column; }
  .profile-sidebar { width: 100%; order: -1; }
}
