:root {
  --bg: #f3f5f8;
  --panel: #ffffff;
  --ink: #142033;
  --muted: #687386;
  --line: #dfe4eb;
  --line-strong: #c7cfdb;
  --navy: #0b1324;
  --blue: #2458d3;
  --blue-dark: #183e9e;
  --red: #b42318;
  --red-bg: #fff1f0;
  --amber: #9a6700;
  --amber-bg: #fff8e1;
  --green: #16794b;
  --green-bg: #eaf8f0;
  --shadow: 0 12px 40px rgba(16, 31, 56, 0.12);
  --radius: 12px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { width: 100%; max-width: 100%; margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); }
body { min-width: 320px; overflow-x: visible; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--blue); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.compact { margin: 3px 0 0; }
.eyebrow { margin: 0 0 4px; color: var(--blue); font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.spacer { flex: 1; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at top right, #233b6d 0, var(--navy) 45%, #050a13 100%); }
.login-card { width: min(430px, 100%); padding: 40px; border-radius: 22px; background: rgba(255,255,255,.98); box-shadow: var(--shadow); text-align: center; }
.login-card h1 { margin: 6px 0 10px; font-size: 34px; }
.login-logo { display: block; width: min(216px, 70vw); height: auto; margin: 0 auto 18px; object-fit: contain; }
.brand-mark { width: 72px; height: 72px; margin: 0 auto 18px; border-radius: 18px; display: grid; place-items: center; background: var(--navy); color: #fff; font-weight: 900; letter-spacing: .08em; }
.brand-mark.small { width: 38px; height: 38px; margin: 0; border-radius: 9px; font-size: 12px; }
.header-logo { display: block; flex: 0 0 38px; width: 38px; height: 38px; object-fit: contain; }
.google-button { display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 28px; padding: 13px 18px; border: 1px solid var(--line-strong); border-radius: 10px; background: #fff; color: var(--ink); font-weight: 750; text-decoration: none; }
.google-button:hover { background: #f7f9fc; }
.google-g { color: #4285f4; font-size: 20px; font-weight: 900; }
.login-message { min-height: 20px; color: var(--red); font-size: 13px; }

.app-header { position: sticky; top: 0; z-index: 20; height: 64px; padding: 0 18px; display: flex; align-items: center; gap: 24px; background: var(--navy); color: #fff; box-shadow: 0 3px 12px rgba(0,0,0,.15); }
.app-shell, main { min-width: 0; max-width: 100%; overflow-x: visible; }
.brand-row { display: flex; align-items: center; gap: 10px; min-width: 230px; }
.header-subtitle { display: block; color: #9fb0cd; font-size: 11px; }
.top-nav { display: flex; align-self: stretch; }
.nav-button { border: 0; background: transparent; color: #aebbd0; font-weight: 750; cursor: pointer; }
.top-nav .nav-button { padding: 0 15px; border-bottom: 3px solid transparent; }
.nav-button.active { color: #fff; border-color: #7da2ff; }
.header-actions { margin-left: auto; display: flex; gap: 8px; }
.gmail-nav-status { display: inline-flex; align-items: center; gap: 6px; padding: 7px 9px; border: 1px solid rgba(255,255,255,.2); border-radius: 8px; color: #fff; font-size: 11px; font-weight: 750; text-decoration: none; white-space: nowrap; }
.gmail-nav-status:hover { background: rgba(255,255,255,.08); }
.gmail-status-dot { width: 8px; height: 8px; border-radius: 50%; background: #94a3b8; box-shadow: 0 0 0 2px rgba(255,255,255,.12); }
.gmail-nav-status.connected .gmail-status-dot { background: #4ade80; }
.gmail-nav-status.disconnected .gmail-status-dot { background: #fbbf24; }
.gmail-nav-status.error .gmail-status-dot { background: #fb7185; }

.primary-button, .secondary-button, .danger-button, .icon-button { border-radius: 8px; padding: 9px 13px; font-weight: 750; cursor: pointer; }
.primary-button { border: 1px solid var(--blue); background: var(--blue); color: #fff; }
.primary-button:hover { background: var(--blue-dark); }
.secondary-button { border: 1px solid var(--line-strong); background: #fff; color: var(--ink); }
.danger-button { border: 1px solid #f0b8b3; background: var(--red-bg); color: var(--red); }
.icon-button { border: 1px solid rgba(255,255,255,.18); background: rgba(255,255,255,.08); color: inherit; }
.modal-header .icon-button { color: var(--ink); border-color: var(--line); background: #fff; }

.view-panel { min-width: 0; max-width: 100%; padding: 18px; }
.view-toolbar { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 14px; }
.view-toolbar h2 { margin: 0; font-size: 22px; }
.toolbar-controls { display: flex; flex-wrap: wrap; gap: 8px; }
.toolbar-controls input, .toolbar-controls select { min-height: 39px; border: 1px solid var(--line-strong); border-radius: 8px; background: #fff; padding: 8px 10px; color: var(--ink); }
.card-display-toggle { min-height: 39px; white-space: nowrap; }

/* Keep the board as the scroll container; its fixed viewport height keeps the horizontal scrollbar reachable. */
#boardView { overflow-x: visible; }
.kanban-board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(292px, 292px); gap: 10px; width: 100%; max-width: 100%; height: calc(100vh - 150px); height: calc(100dvh - 150px); min-height: 360px; overflow-x: auto; overflow-y: auto; padding-bottom: 24px; scroll-snap-type: x proximity; scrollbar-color: #8995a8 #dfe4eb; scrollbar-gutter: stable; overscroll-behavior-x: contain; }
.kanban-board::-webkit-scrollbar { width: 12px; height: 14px; }
.kanban-board::-webkit-scrollbar-track { border-radius: 10px; background: #dfe4eb; }
.kanban-board::-webkit-scrollbar-thumb { border: 3px solid #dfe4eb; border-radius: 10px; background: #8995a8; }
.kanban-board::-webkit-scrollbar-thumb:hover { background: #687386; }
.kanban-column { display: flex; flex-direction: column; min-width: 292px; min-height: 300px; border: 1px solid var(--line); border-radius: 10px; background: #e9edf3; scroll-snap-align: start; }
.column-header { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; padding: 10px 11px; border-bottom: 1px solid #d2d8e1; background: #e9edf3; border-radius: 10px 10px 0 0; }
.column-header h3 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: .035em; }
.column-count { min-width: 24px; padding: 2px 7px; border-radius: 20px; background: #d5dce7; text-align: center; font-size: 11px; font-weight: 800; }
.column-cards { flex: 1; padding: 8px; display: flex; flex-direction: column; gap: 8px; }
.column-cards.drag-over { outline: 2px dashed var(--blue); outline-offset: -4px; background: #dfe8fb; }

.deal-card { position: relative; padding: 10px; border: 1px solid #cfd6e0; border-radius: 8px; background: #fff; box-shadow: 0 1px 3px rgba(10,25,50,.07); cursor: pointer; }
.deal-card:hover { border-color: #9dacc0; box-shadow: 0 4px 12px rgba(10,25,50,.1); }
.deal-card.overdue { border-left: 4px solid var(--red); }
.deal-card.dragging { opacity: .45; }
.card-topline { display: flex; align-items: start; gap: 8px; }
.card-title { flex: 1; margin: 0; font-size: 14px; line-height: 1.25; }
.score-badge { min-width: 35px; padding: 4px 6px; border-radius: 7px; background: #e7edff; color: #28479a; font-size: 11px; font-weight: 900; text-align: center; }
.card-location { margin: 4px 0 8px; color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.card-metric { padding: 6px; border-radius: 6px; background: #f5f7fa; }
.card-metric span { display: block; color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .04em; }
.card-metric strong { display: block; margin-top: 1px; font-size: 12px; }
.card-finance-row { display: flex; gap: 6px; margin-top: 7px; }
.finance-pill { flex: 1; padding: 5px 6px; border-radius: 6px; background: var(--green-bg); color: var(--green); font-size: 10px; font-weight: 800; }
.finance-pill.warning { background: var(--amber-bg); color: var(--amber); }
.finance-pill.danger { background: var(--red-bg); color: var(--red); }
.card-underwriting { margin-top: 8px; border: 1px solid #dce2ea; border-radius: 7px; background: #fbfcfe; cursor: default; }
.kanban-board.compact-cards .card-underwriting { display: none; }
.card-underwriting summary { padding: 7px 8px; color: #34425a; font-size: 10px; font-weight: 850; cursor: pointer; user-select: none; }
.card-underwriting[open] summary { border-bottom: 1px solid #e4e8ee; }
.card-underwriting-body { padding: 5px 8px 8px; }
.card-underwriting-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 3px 0; color: var(--muted); font-size: 9px; }
.card-underwriting-row strong { color: var(--ink); font-size: 10px; text-align: right; }
.card-underwriting-row.emphasized { margin-top: 2px; padding-top: 5px; border-top: 1px solid #e8ebf0; }
.card-loan-editor { margin: 6px 0; padding: 6px; border-radius: 6px; background: #eef3ff; }
.card-loan-label { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 4px; }
.card-loan-label label { color: #34425a; font-size: 9px; font-weight: 850; }
.card-loan-label span { color: var(--blue); font-size: 8px; font-weight: 850; text-transform: uppercase; }
.card-loan-input-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 3px; }
.card-loan-input-row span { color: var(--muted); font-size: 10px; }
.card-loan-input-row input { width: 100%; min-width: 0; padding: 5px 4px; border: 1px solid #aebbd0; border-radius: 5px; background: #fff; font-size: 11px; font-weight: 750; }
.card-loan-input-row button { padding: 5px; border: 1px solid #b9c4d5; border-radius: 5px; background: #fff; color: var(--blue); font-size: 8px; font-weight: 800; cursor: pointer; }
.card-action { margin-top: 8px; padding-top: 7px; border-top: 1px solid #edf0f4; font-size: 11px; }
.action-row { display: flex; justify-content: space-between; gap: 8px; }
.due-overdue { color: var(--red); font-weight: 800; }
.card-footer { display: flex; justify-content: space-between; gap: 8px; margin-top: 6px; color: var(--muted); font-size: 10px; }
.card-move { width: 100%; margin-top: 8px; padding: 7px; border: 1px solid var(--line); border-radius: 6px; background: #fff; display: none; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.metric-card { padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.metric-card span { display: block; color: var(--muted); font-size: 12px; }
.metric-card strong { display: block; margin-top: 4px; font-size: 28px; }
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.panel-card { min-height: 220px; padding: 15px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.panel-card h3 { margin: 0 0 12px; }
.dashboard-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; padding: 9px 0; border-bottom: 1px solid #edf0f4; cursor: pointer; }
.dashboard-row:last-child { border-bottom: 0; }
.dashboard-row small { display: block; color: var(--muted); }

.modal-backdrop { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 14px; background: rgba(5,10,19,.66); }
.modal-shell { width: min(1100px, 100%); max-height: calc(100vh - 28px); display: flex; flex-direction: column; border-radius: 14px; background: #fff; box-shadow: var(--shadow); overflow: hidden; }
.modal-header { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-header h2 { margin: 0; font-size: 21px; }
.modal-header .icon-button { margin-left: auto; }
.modal-tabs { display: flex; gap: 2px; overflow-x: auto; padding: 7px 12px 0; border-bottom: 1px solid var(--line); background: #f7f8fa; }
.modal-tab { flex: none; padding: 10px 11px; border: 0; border-bottom: 3px solid transparent; background: transparent; color: var(--muted); font-size: 12px; font-weight: 800; cursor: pointer; }
.modal-tab.active { color: var(--blue); border-color: var(--blue); }
.modal-content { min-height: 300px; overflow-y: auto; padding: 18px; }
.modal-footer { display: flex; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); background: #fafbfc; }
.form-section { margin-bottom: 22px; }
.form-section h3 { margin: 0 0 10px; font-size: 15px; }
.form-section-note { margin: -5px 0 12px; color: var(--muted); font-size: 12px; }
.section-heading-row { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.section-heading-row .form-section-note { margin-bottom: 10px; }
.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-field { min-width: 0; }
.form-field.span-2 { grid-column: span 2; }
.form-field.span-4 { grid-column: 1 / -1; }
.form-field label { display: block; margin-bottom: 5px; color: #465168; font-size: 11px; font-weight: 800; }
.form-field input, .form-field select, .form-field textarea { width: 100%; min-height: 39px; padding: 8px 9px; border: 1px solid var(--line-strong); border-radius: 7px; background: #fff; color: var(--ink); }
.form-field textarea { min-height: 92px; resize: vertical; }
.inline-check { display: flex; align-items: center; gap: 8px; min-height: 39px; }
.inline-check input { width: auto; min-height: auto; }
.input-help { margin-top: 4px; color: var(--muted); font-size: 10px; }
.input-state { font-weight: 800; }
.input-state.estimated { color: var(--blue); }
.input-state.manual { color: var(--amber); }

.calculation-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.calculation-card { padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: #f7f9fc; }
.calculation-card span { display: block; color: var(--muted); font-size: 10px; text-transform: uppercase; }
.calculation-card strong { display: block; margin-top: 3px; font-size: 15px; }
.calculation-card.primary { border-color: #b9c8ef; background: #edf2ff; }
.financial-summary { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.financial-summary .calculation-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.validation-banner { margin-bottom: 12px; padding: 10px; border-radius: 8px; background: var(--red-bg); color: var(--red); font-size: 12px; font-weight: 750; }

.score-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.score-row { display: grid; grid-template-columns: 1fr 80px; gap: 10px; align-items: center; padding: 9px; border: 1px solid var(--line); border-radius: 8px; }
.score-row small { display: block; color: var(--muted); }
.score-row input { width: 100%; }
.score-total { display: inline-grid; place-items: center; width: 82px; height: 82px; border-radius: 50%; background: var(--navy); color: #fff; font-size: 25px; font-weight: 900; }

.contact-card, .document-row, .gmail-row, .activity-row { padding: 11px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.contacts-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.directory-contact-card { min-width: 0; padding: 15px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: 0 1px 3px rgba(10,25,50,.05); cursor: pointer; }
.directory-contact-card:hover { border-color: #9dacc0; box-shadow: 0 4px 12px rgba(10,25,50,.08); }
.contact-card-heading { display: flex; align-items: start; justify-content: space-between; gap: 10px; }
.contact-card-heading h3, .contact-card-heading p { margin: 0; }
.contact-card-heading p { margin-top: 3px; color: var(--muted); font-size: 12px; }
.contact-type-badge { flex: none; padding: 4px 7px; border-radius: 20px; background: #e7edff; color: #28479a; font-size: 10px; font-weight: 850; }
.contact-links { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 12px; font-size: 12px; }
.contact-notes { display: -webkit-box; overflow: hidden; margin: 11px 0 0; color: var(--muted); font-size: 12px; line-height: 1.4; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.contact-opportunities { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 12px; }
.contact-opportunities button { padding: 4px 7px; border: 1px solid var(--line); border-radius: 20px; background: #f7f9fc; color: var(--ink); font-size: 10px; cursor: pointer; }
.contact-card-footer { display: flex; justify-content: space-between; gap: 8px; margin-top: 13px; padding-top: 9px; border-top: 1px solid #edf0f4; color: var(--muted); font-size: 10px; }
.contact-card-footer strong { color: var(--ink); }
.contacts-empty { grid-column: 1 / -1; }
.contact-modal-shell { width: min(760px, 100%); }
.opportunity-check-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.opportunity-check { display: flex; align-items: center; gap: 9px; padding: 9px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.opportunity-check input { flex: none; }
.opportunity-check span { min-width: 0; }
.opportunity-check strong, .opportunity-check small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.opportunity-check small { margin-top: 2px; color: var(--muted); }
.contact-link-controls { display: flex; flex-wrap: wrap; gap: 8px; }
.contact-link-controls select { flex: 1; min-width: 220px; padding: 8px 9px; border: 1px solid var(--line-strong); border-radius: 7px; background: #fff; }
.import-panel { min-height: 0; margin-bottom: 14px; }
.import-upload-row { display: flex; align-items: center; gap: 10px; }
.import-upload-row input { flex: 1; min-width: 0; padding: 8px; border: 1px solid var(--line-strong); border-radius: 8px; }
.import-heading-row { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.import-heading-row h3 { margin-bottom: 2px; }
.import-metrics { grid-template-columns: repeat(7, minmax(0, 1fr)); margin-top: 14px; }
.import-metrics .metric-card { padding: 11px; }
.import-metrics .metric-card strong { font-size: 22px; }
.import-detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 14px 0; }
.import-detail-grid h4 { margin: 0 0 7px; }
.import-issue-list { max-height: 250px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.import-issue { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 11px; }
.import-issue:last-child { border-bottom: 0; }
.import-issue span { color: var(--muted); }
.import-confirm { display: flex; align-items: start; gap: 8px; margin: 12px 0; font-size: 12px; font-weight: 700; }
.import-history-row { display: flex; justify-content: space-between; gap: 14px; padding: 11px; border: 1px solid var(--line); border-radius: 8px; }
.import-history-row > div { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.import-history-row > div:last-child { align-items: flex-end; }
.import-history-row span, .import-history-row small { color: var(--muted); }
.import-status { padding: 3px 7px; border-radius: 20px; background: var(--green-bg); color: var(--green) !important; font-size: 10px; font-weight: 800; text-transform: capitalize; }
.import-status.failed { background: var(--red-bg); color: var(--red) !important; }
.import-status.completed_with_warnings { background: var(--amber-bg); color: var(--amber) !important; }
.admin-token-form { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr) auto; gap: 10px; align-items: end; margin: 12px 0; }
.created-token-panel { margin: 12px 0; padding: 13px; border: 1px solid #d7a32f; border-radius: 8px; background: #fff8e6; }
.created-token-panel > div { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.created-token-panel code { flex: 1; overflow-wrap: anywhere; padding: 9px; border-radius: 6px; background: #fff; }
.intake-batch { border: 1px solid var(--line); border-radius: 9px; background: #fff; }
.intake-batch > summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px; cursor: pointer; }
.intake-batch > summary div { display: flex; flex-direction: column; gap: 3px; }
.intake-batch > summary span { color: var(--muted); font-size: 11px; }
.intake-batch-body { padding: 0 13px 13px; border-top: 1px solid var(--line); }
.intake-counts { display: grid; grid-template-columns: repeat(6,minmax(0,1fr)); gap: 7px; margin: 12px 0; }
.intake-counts span { display: flex; flex-direction: column; padding: 8px; border-radius: 7px; background: #f5f7fa; color: var(--muted); font-size: 10px; }
.intake-counts strong { color: var(--ink); font-size: 18px; }
.duplicate-resolution { display: grid; grid-template-columns: 1fr minmax(240px, 1fr); gap: 10px; align-items: center; margin: 7px 0; padding: 9px; border: 1px solid var(--line); border-radius: 7px; }
.duplicate-resolution select { padding: 8px; border: 1px solid var(--line-strong); border-radius: 7px; background: #fff; }
.intake-change-list { max-height: 220px; overflow: auto; margin: 7px 0; padding-left: 20px; color: var(--muted); font-size: 11px; }
.audit-row { display: flex; flex-direction: column; gap: 2px; padding: 10px 11px; border: 1px solid var(--line); border-radius: 8px; }
.audit-row span, .audit-row small { color: var(--muted); }
.stack-list { display: flex; flex-direction: column; gap: 8px; }
.row-actions { display: flex; gap: 6px; margin-top: 8px; }
.row-actions button { padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: #fff; cursor: pointer; }
.gmail-row p, .activity-row p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.gmail-search-row { display: flex; gap: 8px; margin-bottom: 12px; }
.gmail-search-row input { flex: 1; min-width: 0; padding: 9px; border: 1px solid var(--line-strong); border-radius: 8px; }
.gmail-heading { display: flex; justify-content: space-between; gap: 12px; }
.gmail-heading span { flex: none; color: var(--muted); font-size: 11px; }
.gmail-metadata { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 5px; color: var(--muted); font-size: 11px; }
.email-search-grid { margin-bottom: 12px; }
.email-template-controls { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.email-template-controls select { flex: 1; min-width: 220px; padding: 8px 9px; border: 1px solid var(--line-strong); border-radius: 7px; background: #fff; }
.email-compose-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.gmail-connection-status { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 14px; padding: 12px 14px; border: 1px solid var(--line); border-left-width: 4px; border-radius: 9px; background: #f8fafc; }
.gmail-connection-status strong, .gmail-connection-status p { margin: 0; }
.gmail-connection-status p { margin-top: 3px; color: var(--muted); font-size: 12px; }
.gmail-connection-status.connected { border-left-color: #22a06b; background: #f0fdf7; }
.gmail-connection-status.disconnected { border-left-color: #d89a16; background: #fff9e8; }
.gmail-connection-status.error { border-left-color: #c33b32; background: var(--red-bg); }
.empty-state { padding: 30px 14px; color: var(--muted); text-align: center; }

.toast-region { position: fixed; right: 16px; bottom: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { max-width: 360px; padding: 11px 13px; border-radius: 8px; background: var(--navy); color: #fff; box-shadow: var(--shadow); font-size: 13px; }
.toast.error { background: #7a1b13; }
.mobile-nav { display: none; }

@media (max-width: 900px) {
  .top-nav { display: none; }
  .header-subtitle { display: none; }
  .gmail-nav-status span:last-child { display: none; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .contacts-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-field.span-4 { grid-column: 1 / -1; }
  .calculation-grid, .financial-summary .calculation-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .app-header { height: 58px; padding: 0 10px; }
  .brand-row { min-width: 0; }
  .brand-row strong { font-size: 13px; }
  .header-actions #newOpportunityButton, .header-actions #logoutButton { display: none; }
  .view-panel { padding: 11px 9px 76px; }
  .view-toolbar { align-items: stretch; flex-direction: column; gap: 10px; }
  .toolbar-controls { width: 100%; }
  .toolbar-controls input { flex: 1; min-width: 0; }
  .kanban-board { grid-auto-columns: minmax(84vw, 84vw); height: calc(100vh - 190px); height: calc(100dvh - 190px); min-height: 320px; padding-bottom: 76px; }
  .kanban-column { min-width: 84vw; }
  .card-move { display: block; }
  .mobile-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; display: grid; grid-template-columns: 1fr 48px 1fr 1fr 1fr 1fr; align-items: center; height: 62px; padding-bottom: env(safe-area-inset-bottom); background: var(--navy); }
  .mobile-nav .nav-button { height: 100%; border: 0; }
  .mobile-new { width: 48px; height: 48px; margin: -18px auto 0; border: 4px solid var(--bg); border-radius: 50%; background: var(--blue); color: #fff; font-size: 28px; }
  .modal-backdrop { padding: 0; align-items: end; }
  .modal-shell { width: 100%; max-height: 96vh; border-radius: 14px 14px 0 0; }
  .modal-content { padding: 14px 11px; }
  .modal-footer { padding: 10px; }
  .form-grid, .form-grid.two, .score-grid { grid-template-columns: 1fr; }
  .form-field.span-2, .form-field.span-4 { grid-column: auto; }
  .calculation-grid, .financial-summary .calculation-grid { grid-template-columns: 1fr 1fr; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .contacts-grid, .opportunity-check-grid { grid-template-columns: 1fr; }
  .contact-link-controls > * { width: 100%; }
  .import-upload-row, .import-heading-row, .import-history-row { align-items: stretch; flex-direction: column; }
  .import-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .import-detail-grid { grid-template-columns: 1fr; }
  .import-history-row > div:last-child { align-items: flex-start; }
  .admin-token-form, .duplicate-resolution { grid-template-columns: 1fr; }
  .intake-counts { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .login-card { padding: 30px 20px; }
}
