/* =========================================================================
 * DealFlow AI — styles
 * Design system: navy + teal fintech palette, Inter / Plus Jakarta Sans.
 * No business data here — purely presentation.
 * ========================================================================= */

:root {
  /* Color system — boutique private-credit: warm paper, ink, royal blue */
  --navy-900: #0c1f38;
  --navy-800: #11243d;
  --navy-700: #16304f;
  --navy-600: #1d3a5c;
  --ink:      #0c1f38;
  --ink-2:    #3a4654;
  --muted:    #5f6b78;
  --muted-2:  #8b95a1;
  --line:     #e7e2d8;
  --line-2:   #efeae0;
  --surface:  #ffffff;
  --bg:       #f4f2ec;
  --bg-2:     #efeae0;

  --teal-600: #164a82;
  --teal-500: #1d5fa5;
  --teal-50:  #eaf2fb;
  --brand:    #1d5fa5;
  --brand-600:#164a82;
  --brand-50: #eaf2fb;

  --amber:    #9a6b00;
  --amber-50: #fbf3e0;
  --green:    #0a7d54;
  --green-50: #eaf6f0;
  --red:      #b5462f;
  --red-50:   #fbece7;
  --violet:   #4f46b5;
  --violet-50:#eeedfb;

  --radius:   14px;
  --radius-sm:10px;
  --shadow:   0 1px 2px rgba(12,31,56,.05), 0 18px 40px -22px rgba(12,31,56,.26);
  --shadow-lg:0 28px 70px -28px rgba(12,31,56,.40);

  --font:  'Inter', system-ui, -apple-system, sans-serif;
  --font-display: 'Fraunces', Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.5;
  overflow-x: hidden; /* no page-level sideways scroll on mobile */
}
.hidden { display: none !important; }
.mobile-only { display: none; }
a { color: var(--brand); text-decoration: none; }
h1,h2,h3 { font-family: var(--font-display); font-weight: 600; letter-spacing: -.01em; }

/* ---------- Brand mark ---------- */
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--ink);
  color: #fff; font-weight: 600; font-family: var(--font-display);
  display: grid; place-items: center; letter-spacing: -.5px; font-size: 15px;
  box-shadow: none;
}
.brand-row, .sidebar-brand { display: flex; align-items: center; gap: 10px; }
.brand-name { font-family: var(--font-display); font-weight: 800; letter-spacing: -.3px; }

/* =========================================================================
 * Boot overlay
 * ========================================================================= */
.boot-overlay {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  background: radial-gradient(1200px 600px at 50% -10%, #16264a, var(--navy-900));
}
.boot-card { text-align: center; color: #cbd5e1; }
.boot-card .brand-mark { margin: 0 auto 18px; width: 48px; height: 48px; font-size: 20px; }
.boot-card p { margin-top: 14px; font-size: 13px; }

.spinner {
  width: 30px; height: 30px; margin: 0 auto;
  border: 3px solid rgba(148,163,184,.3); border-top-color: var(--teal-500);
  border-radius: 50%; animation: spin .8s linear infinite;
}
.spinner-sm { width: 16px; height: 16px; border-width: 2px; display: inline-block; vertical-align: middle; }
.btn-spin { border: 2px solid rgba(255,255,255,.5); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* =========================================================================
 * AUTH SCREEN
 * ========================================================================= */
.auth-screen { position: fixed; inset: 0; z-index: 50; background: var(--bg); }
.auth-split { display: grid; grid-template-columns: 1.1fr 1fr; height: 100%; }
.auth-brand {
  background: radial-gradient(1000px 700px at 0% 0%, #1c2f55, var(--navy-900));
  color: #e2e8f0; display: grid; align-items: center; padding: 56px;
}
.auth-brand-inner { max-width: 460px; }
.auth-brand .brand-mark { width: 40px; height: 40px; font-size: 17px; }
.auth-brand h1 { font-size: 34px; line-height: 1.15; margin: 30px 0 16px; color: #fff; letter-spacing: -.5px; }
.auth-brand p { color: #aab8cf; font-size: 15px; }
.auth-points { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 12px; }
.auth-points li { position: relative; padding-left: 28px; color: #cdd9ec; }
.auth-points li::before {
  content: '✓'; position: absolute; left: 0; top: 0;
  width: 18px; height: 18px; border-radius: 50%; font-size: 11px;
  background: var(--teal-500); color: #042f2a; display: grid; place-items: center; font-weight: 800;
}
.auth-form-panel { display: grid; place-items: center; padding: 40px; }
.auth-form-card { width: 100%; max-width: 380px; }
.auth-tabs { display: flex; gap: 6px; background: var(--bg-2); padding: 5px; border-radius: 12px; margin-bottom: 26px; }
.auth-tab { flex: 1; border: none; background: transparent; padding: 9px; border-radius: 8px; font-weight: 600; color: var(--muted); cursor: pointer; font-family: var(--font); }
.auth-tab.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.auth-form { display: grid; gap: 16px; }
.auth-form label { display: grid; gap: 6px; font-weight: 600; font-size: 13px; color: var(--ink-2); }
.auth-fineprint { font-size: 12px; color: var(--muted); margin: 4px 0 0; }
.auth-error { background: var(--red-50); color: var(--red); padding: 11px 14px; border-radius: 10px; font-size: 13px; margin-top: 16px; border: 1px solid #fecaca; }
.link-btn { background: none; border: none; color: var(--brand); cursor: pointer; font-size: 13px; font-weight: 600; padding: 0; justify-self: center; font-family: var(--font); }

/* Inputs */
input, select, textarea {
  font-family: var(--font); font-size: 14px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; width: 100%; transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 80px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }

/* =========================================================================
 * BUTTONS
 * ========================================================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font); font-weight: 600; font-size: 14px;
  padding: 10px 16px; border-radius: 10px; border: 1px solid transparent;
  cursor: pointer; transition: background .15s, box-shadow .15s, transform .05s; white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary { background: var(--ink); color: #fff; box-shadow: none; }
.btn-primary:hover:not(:disabled) { background: #16304f; }
.btn-teal { background: var(--teal-600); color: #fff; }
.btn-teal:hover:not(:disabled) { background: #0f766e; }
.btn-ghost { background: var(--surface); color: var(--ink-2); border-color: var(--line); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-2); }
.btn-danger { background: var(--red-50); color: var(--red); border-color: #fecaca; }
.btn-danger:hover:not(:disabled) { background: #fee2e2; }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.icon-btn { background: transparent; border: 1px solid transparent; border-radius: 9px; padding: 7px 9px; cursor: pointer; font-size: 16px; position: relative; color: var(--ink-2); }
.icon-btn:hover { background: var(--bg-2); }

/* =========================================================================
 * APP SHELL
 * ========================================================================= */
/* Full-width workspace; the sidebar is a slide-over drawer on every screen size. */
.app-shell { min-height: 100vh; }
.sidebar { background: #f0ede4; color: var(--ink-2); display: flex; flex-direction: column; padding: 16px 12px; position: fixed; top: 0; left: 0; width: 264px; height: 100vh; z-index: 46; transform: translateX(-100%); transition: transform .28s cubic-bezier(.2,.7,.2,1); overflow-y: auto; border-right: 1px solid var(--line); }
.sidebar.open { transform: none; box-shadow: 0 24px 70px rgba(12,31,56,.22); }
.sidebar-brand { padding: 4px 8px 20px; color: var(--ink); }
.sidebar-nav { display: grid; gap: 1px; flex: 1; overflow-y: auto; scroll-behavior: smooth; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.nav-section { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted-2); padding: 15px 10px 6px; font-weight: 700; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px;
  border-radius: 8px; color: var(--ink-2); cursor: pointer; font-weight: 500; font-size: 13px;
  border: none; background: transparent; width: 100%; text-align: left; font-family: var(--font);
}
.nav-item:hover { background: #e6e1d7; color: var(--ink); }
.nav-item.active { background: var(--brand-50); color: var(--brand-600); font-weight: 600; box-shadow: inset 3px 0 0 var(--brand); }
.nav-item.active .nav-ico { color: var(--brand); opacity: 1; }
.nav-ico { width: 18px; text-align: center; font-size: 15px; opacity: .75; flex: 0 0 auto; }
.nav-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-tip { position: fixed; z-index: 70; max-width: 244px; background: var(--ink); color: #fff; border-radius: 11px; padding: 11px 14px; box-shadow: 0 18px 44px rgba(12,31,56,.34); opacity: 0; transform: translateX(-6px); pointer-events: none; transition: opacity .16s ease, transform .16s ease; }
.nav-tip.show { opacity: 1; transform: none; }
.nav-tip-t { font-family: var(--font-display); font-weight: 600; font-size: 13.5px; }
.nav-tip-d { font-size: 12px; color: #c7d2e0; margin-top: 4px; line-height: 1.5; }
.sidebar-foot { padding-top: 14px; border-top: 1px solid var(--line); }
.plan-badge { font-size: 12px; color: var(--muted); padding: 8px 12px; }
.plan-badge strong { color: var(--ink); }
.nav-search { display: flex; align-items: center; gap: 8px; width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; font-size: 12.5px; color: var(--muted); cursor: pointer; font-family: var(--font); margin-bottom: 8px; transition: border-color .15s ease, background .15s ease; }
.nav-search:hover { border-color: #d7cfc0; }
.nav-search i { font-size: 15px; }
.nav-search span { flex: 1; text-align: left; }
.nav-search kbd { font-size: 10px; background: var(--line-2); border-radius: 4px; padding: 1px 6px; color: var(--muted); font-family: var(--font); }
.nav-div { height: 1px; background: var(--line); margin: 8px 8px 4px; }
/* Deal workspace (tabbed deal modal) */
.dw-bar { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.dtabs { display: flex; gap: 2px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin: 14px 0 18px; }
.dtab { font-size: 13px; font-weight: 600; color: var(--muted); background: none; border: none; padding: 9px 14px; cursor: pointer; border-bottom: 2px solid transparent; font-family: var(--font); margin-bottom: -1px; }
.dtab:hover { color: var(--ink); }
.dtab.active { color: var(--ink); border-bottom-color: var(--brand); }
.dpanel { display: none; }
.dpanel.active { display: block; animation: viewIn .2s ease; }
/* Onboarding checklist */
.ob-card { margin-bottom: 18px; }
.ob-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.ob-title { font-family: var(--font-display); font-size: 16px; font-weight: 600; }
.ob-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.ob-bar { height: 6px; border-radius: 6px; background: var(--line-2); overflow: hidden; margin: 14px 0 8px; }
.ob-bar span { display: block; height: 100%; background: var(--brand); }
.ob-row { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line-2); }
.ob-row:first-child { border-top: none; }
.ob-check { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; flex: 0 0 auto; }
.ob-check.done { background: var(--green); color: #fff; }
.ob-check.todo { border: 1.5px solid var(--line); color: var(--muted-2); }
.ob-label { flex: 1; font-size: 13.5px; font-weight: 500; }
.ob-row.done .ob-label { color: var(--muted); text-decoration: line-through; }
/* Action Center — "needs attention" */
.ac-row { display: flex; align-items: center; gap: 13px; width: 100%; text-align: left; background: none; border: none; border-top: 1px solid var(--line-2); padding: 14px 18px; cursor: pointer; font-family: var(--font); }
.ac-row:first-child { border-top: none; }
.ac-row:hover { background: var(--bg-2); }
.ac-ic { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; font-size: 17px; flex: 0 0 auto; }
.ac-ic.warn { background: var(--amber-50); color: var(--amber); }
.ac-ic.info { background: var(--brand-50); color: var(--brand); }
.ac-ic.good { background: var(--green-50); color: var(--green); }
.ac-txt { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.ac-txt .t { font-size: 14px; font-weight: 600; color: var(--ink); }
.ac-txt .d { font-size: 12.5px; color: var(--muted); }
.ac-go { color: var(--muted-2); font-size: 18px; flex: 0 0 auto; }

.main-col { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 14px; padding: 0 24px; height: 62px;
  background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.topbar-title { font-weight: 700; font-size: 18px; font-family: var(--font-display); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.notif-dot { position: absolute; top: 0; right: 0; min-width: 16px; height: 16px; padding: 0 4px; background: var(--red); color: #fff; font-size: 10px; font-weight: 700; border-radius: 9px; display: grid; place-items: center; }
.user-chip { display: flex; align-items: center; gap: 9px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg,var(--teal-500),var(--brand)); color: #fff; font-weight: 700; display: grid; place-items: center; font-size: 13px; }
.user-meta { display: grid; line-height: 1.2; }
.user-name { font-weight: 600; font-size: 13px; }
.user-role { font-size: 11px; color: var(--muted); text-transform: capitalize; }

/* Notification drawer */
.notif-drawer { position: absolute; top: 62px; right: 18px; width: 360px; max-width: calc(100vw - 24px); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); z-index: 40; overflow: hidden; }
.notif-drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.notif-list { max-height: 60vh; overflow-y: auto; }
.notif-item { padding: 13px 16px; border-bottom: 1px solid var(--line-2); cursor: pointer; }
.notif-item:hover { background: var(--bg-2); }
.notif-item.unread { background: var(--brand-50); }
.notif-item strong { display: block; font-size: 13px; }
.notif-item span { font-size: 12px; color: var(--muted); }
.notif-item time { font-size: 11px; color: var(--muted-2); }

/* =========================================================================
 * VIEWS / LAYOUT PRIMITIVES
 * ========================================================================= */
.view-root { padding: 26px; max-width: 1240px; width: 100%; margin: 0 auto; }
.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.view-head h2 { margin: 0 0 4px; font-size: 23px; letter-spacing: -.4px; }
.view-head p { margin: 0; color: var(--muted); font-size: 13.5px; }
.view-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }
.card-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-head h3 { margin: 0; font-size: 15px; }

.grid { display: grid; gap: 18px; }
.grid-stats { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

/* Stat cards */
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.stat-label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 28px; font-weight: 800; font-family: var(--font-display); margin-top: 6px; letter-spacing: -.6px; }
.stat-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.stat-ico { float: right; width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; font-size: 19px; background: var(--brand-50); color: var(--brand); }
.stat-value { font-weight: 600; }
.nav-ico i.ti, .stat-ico i.ti, .state-ico i.ti { line-height: 1; vertical-align: -.06em; }

/* Tables */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th { text-align: left; padding: 11px 14px; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data td { padding: 13px 16px; border-bottom: 1px solid var(--line-2); font-variant-numeric: tabular-nums; }
table.data tr:hover td { background: var(--bg-2); }

/* Badges / pills */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600; border: 1px solid rgba(12,31,56,.07); }
.pill-gray { background: var(--bg-2); color: var(--ink-2); }
.pill-blue { background: var(--brand-50); color: var(--brand-600); }
.pill-teal { background: var(--teal-50); color: var(--teal-600); }
.pill-green { background: var(--green-50); color: var(--green); }
.pill-amber { background: var(--amber-50); color: var(--amber); }
.pill-red { background: var(--red-50); color: var(--red); }
.pill-violet { background: var(--violet-50); color: var(--violet); }
.grade { font-weight: 600; font-family: var(--font-display); width: 26px; height: 26px; border-radius: 7px; display: inline-grid; place-items: center; }
.grade-A { background: var(--green-50); color: var(--green); }
.grade-B { background: var(--brand-50); color: var(--brand-600); }
.grade-C { background: var(--amber-50); color: var(--amber); }
.grade-D, .grade-F { background: var(--red-50); color: var(--red); }

/* =========================================================================
 * EMPTY / LOADING / ERROR states
 * ========================================================================= */
.state { text-align: center; padding: 54px 24px; color: var(--muted); }
.state .state-ico { font-size: 40px; opacity: .55; }
.state h3 { margin: 14px 0 6px; color: var(--ink); font-size: 17px; }
.state p { margin: 0 auto 18px; max-width: 380px; }
.state-loading { display: grid; place-items: center; gap: 14px; padding: 60px 24px; color: var(--muted); }
.state-error { background: var(--red-50); border: 1px solid #fecaca; border-radius: var(--radius); color: var(--red); padding: 18px 20px; display: flex; align-items: center; gap: 12px; }
.state-error button { margin-left: auto; }

/* =========================================================================
 * KANBAN (deal pipeline)
 * ========================================================================= */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(248px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 8px; }
.kcol { background: var(--bg-2); border-radius: var(--radius); padding: 10px; min-height: 200px; }
.kcol-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px 10px; font-weight: 700; font-size: 13px; }
.kcol-head .count { background: var(--surface); color: var(--muted); border-radius: 999px; padding: 1px 9px; font-size: 11px; }
.kcol.drop-hover { outline: 2px dashed var(--brand); outline-offset: -2px; }
.deal-card { background: var(--surface); border: 1px solid var(--line); border-radius: 11px; padding: 12px; margin-bottom: 9px; cursor: grab; box-shadow: var(--shadow); }
.deal-card:active { cursor: grabbing; }
.deal-card h4 { margin: 0 0 4px; font-size: 13.5px; }
.deal-card .addr { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.deal-card .meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.deal-card .amt { font-weight: 700; font-size: 13.5px; }

/* =========================================================================
 * TIMELINE (deal lifecycle)
 * ========================================================================= */
.timeline { position: relative; padding-left: 8px; }
.timeline::before { content: ''; position: absolute; left: 13px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.timeline-item { position: relative; display: flex; gap: 16px; padding: 0 0 18px 0; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-dot { position: relative; z-index: 1; flex: 0 0 12px; width: 12px; height: 12px; margin-top: 5px; margin-left: 8px; border-radius: 50%; background: var(--teal-500); box-shadow: 0 0 0 3px var(--teal-50); }
.timeline-body { flex: 1; min-width: 0; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; }
.timeline-body strong { font-size: 13.5px; }

/* =========================================================================
 * MODAL
 * ========================================================================= */
.modal-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: grid; place-items: center; z-index: 60; padding: 20px; }
.modal { background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); width: 100%; max-width: 560px; max-height: 90vh; display: flex; flex-direction: column; overflow: hidden; }
.modal.wide { max-width: 820px; }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-body { padding: 22px; overflow-y: auto; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }

/* Forms */
.form-grid { display: grid; gap: 15px; }
.form-grid.cols-2 { grid-template-columns: 1fr 1fr; }
.field { display: grid; gap: 6px; }
.field label, .field > span.lbl { font-weight: 600; font-size: 13px; color: var(--ink-2); }
.field small { color: var(--muted); font-size: 12px; }
.span-2 { grid-column: 1 / -1; }

/* Calculator */
.calc-wrap { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.calc-out { background: var(--navy-900); color: #e2e8f0; border-radius: var(--radius); padding: 22px; }
.calc-out .big { font-size: 34px; font-weight: 800; font-family: var(--font-display); color: #fff; letter-spacing: -1px; }
.calc-row { display: flex; align-items: center; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid rgba(255,255,255,.08); font-size: 13.5px; }
.calc-row:last-child { border-bottom: none; }
.calc-row span:last-child { font-weight: 700; color: #fff; }
.rate-source { font-size: 11.5px; color: var(--muted-2); margin-top: 12px; }

/* AI panels */
.ai-out { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; white-space: pre-wrap; font-size: 13.5px; line-height: 1.6; }
.chat-box { display: flex; flex-direction: column; height: calc(100vh - 220px); min-height: 420px; }
.chat-log { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.chat-msg { max-width: 78%; padding: 11px 14px; border-radius: 14px; font-size: 13.5px; white-space: pre-wrap; line-height: 1.55; }
.chat-msg.user { align-self: flex-end; background: var(--brand); color: #fff; border-bottom-right-radius: 4px; }
.chat-msg.ai { align-self: flex-start; background: var(--bg-2); color: var(--ink); border-bottom-left-radius: 4px; }
.chat-input-row { display: flex; gap: 10px; padding: 14px; border-top: 1px solid var(--line); }
.chat-input-row textarea { min-height: 46px; max-height: 140px; }

/* Dropzone */
.dropzone { border: 2px dashed var(--line); border-radius: var(--radius); padding: 38px 20px; text-align: center; color: var(--muted); cursor: pointer; transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone.hover { border-color: var(--brand); background: var(--brand-50); }
.dropzone .dz-ico { font-size: 34px; }

/* New-deal wizard */
.wiz { display: flex; flex-direction: column; gap: 18px; }
.wiz-steps { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.wiz-step { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 600; }
.wiz-step .wiz-dot { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%; background: var(--line); color: var(--muted); font-size: 12.5px; }
.wiz-step.active { color: var(--brand); }
.wiz-step.active .wiz-dot { background: var(--brand); color: #fff; }
.wiz-step.done .wiz-dot { background: var(--green); color: #fff; }
.wiz-arrow { color: var(--line); margin: 0 2px; }
.wiz-pane { animation: toastIn .18s ease; }
.wiz-h { margin: 0; }
.wiz-hint { color: #b91c1c; font-size: 13px; margin-top: 6px; }
.wiz #wiz-name { font-size: 17px; padding: 13px 14px; }

.wiz-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.wiz-card { position: relative; text-align: left; display: flex; flex-direction: column; gap: 7px; padding: 22px 20px; border: 2px solid var(--line); border-radius: var(--radius); background: #fff; cursor: pointer; transition: border-color .15s, box-shadow .15s, transform .1s; }
.wiz-card:hover { border-color: var(--brand); box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.wiz-card-ico { font-size: 30px; }
.wiz-card-title { font-size: 16px; font-weight: 800; color: var(--ink); }
.wiz-card-sub { font-size: 13px; color: var(--muted); }
.wiz-badge { position: absolute; top: 12px; right: 12px; background: var(--green-50); color: var(--green); border: 1px solid #bbf7d0; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; }

.wiz-filelist { display: grid; gap: 8px; }
.wiz-file, .wiz-file-status { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 13.5px; }
.wiz-file-name { font-weight: 600; }

.wiz-fin { border: 1px solid var(--line); border-radius: var(--radius); background: var(--brand-50); padding: 14px; }
.wiz-fin-head { font-weight: 800; color: var(--ink); margin-bottom: 10px; }
.wiz-fin-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.wiz-ai-tag { display: inline-block; background: var(--brand); color: #fff; font-size: 10px; font-weight: 800; letter-spacing: .03em; padding: 1px 6px; border-radius: 5px; vertical-align: middle; margin-left: 4px; }
.wiz-filing { gap: 6px; }

@media (max-width: 640px) {
  .wiz-cards { grid-template-columns: 1fr; }
  .wiz-fin-grid { grid-template-columns: 1fr 1fr; }
}

/* Toasts */
.toast-stack { position: fixed; right: 20px; bottom: 20px; z-index: 80; display: grid; gap: 10px; }
.toast { background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 11px; box-shadow: var(--shadow-lg); font-size: 13.5px; max-width: 360px; animation: toastIn .2s ease; display: flex; gap: 10px; align-items: flex-start; }
.toast.success { background: #0f766e; }
.toast.error { background: #b91c1c; }
.toast.info { background: var(--navy-700); }
@keyframes toastIn { from { transform: translateY(8px); opacity: 0; } }

/* Misc helpers */
.muted { color: var(--muted); }
.mono { font-variant-numeric: tabular-nums; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stack { display: grid; gap: 14px; }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
hr.sep { border: none; border-top: 1px solid var(--line); margin: 18px 0; }
.inline-actions { display: flex; gap: 8px; align-items: center; }
.score-bar { height: 7px; border-radius: 999px; background: var(--bg-2); overflow: hidden; min-width: 80px; }
.score-bar > i { display: block; height: 100%; background: linear-gradient(90deg,var(--teal-500),var(--brand)); }

/* =========================================================================
 * RESPONSIVE
 * ========================================================================= */
/* =========================================================================
 * WAVE 5 — Quote comparison + public upload portal
 * ========================================================================= */

/* Best-value cell highlight in the quote comparison table */
.quote-compare td.q-best {
  background: var(--green-50);
  color: var(--green);
  font-weight: 700;
}
.quote-compare th { vertical-align: top; }
.quote-compare td:first-child, .quote-compare th:first-child {
  position: sticky; left: 0; background: var(--surface); z-index: 1;
}
.quote-compare tr:hover td:first-child { background: var(--bg-2); }

/* Standalone borrower upload page (no sidebar, no login) */
.public-portal { min-height: 100vh; background: var(--bg); }
.public-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.public-main { max-width: 720px; margin: 0 auto; padding: 32px 20px 60px; }
.public-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px 24px;
}
.public-card + .public-card { margin-top: 16px; }
.public-doc-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 0; border-bottom: 1px solid var(--line-2);
}
.public-doc-row:last-child { border-bottom: none; }
.public-doc-meta { min-width: 0; }
.public-doc-action { flex-shrink: 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

@media (max-width: 900px) {
  .auth-split { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
  .calc-wrap { grid-template-columns: 1fr; }
  .form-grid.cols-2 { grid-template-columns: 1fr; }
  .public-doc-row { flex-direction: column; align-items: flex-start; }
  .public-doc-action { justify-content: flex-start; }
}

/* =========================================================================
 * UI POLISH — smoother motion, executive refinements, mobile dynamics
 * ========================================================================= */
.btn, .nav-item, .pill { transition: background-color .18s ease, border-color .18s ease, color .18s ease, box-shadow .2s ease, transform .12s ease; }
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(0) scale(.985); }
.btn-primary { box-shadow: none; }
.card { transition: box-shadow .22s ease, transform .2s ease, border-color .18s ease; }
.nav-item:active { transform: scale(.985); }
input, select, textarea { transition: border-color .16s ease, box-shadow .18s ease; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37,99,235,.13); }

/* Smooth view transition on navigation */
#view-root { animation: viewIn .26s cubic-bezier(.2,.7,.2,1); }
@keyframes viewIn { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }

/* Sticky topbar with subtle elevation */
.topbar { position: sticky; top: 0; z-index: 30; background: var(--surface); backdrop-filter: saturate(1.1) blur(6px); }

/* Mobile sidebar scrim + smoother slide */
.sidebar { transition: transform .28s cubic-bezier(.2,.7,.2,1); }
.sidebar-scrim { position: fixed; inset: 0; background: rgba(10,16,28,.45); z-index: 44; opacity: 0; pointer-events: none; transition: opacity .24s ease; -webkit-backdrop-filter: blur(1px); backdrop-filter: blur(1px); }
.sidebar-scrim.show { opacity: 1; pointer-events: auto; }

/* More dynamic, touch-friendly mobile layout */
@media (max-width: 900px) {
  .topbar { padding-left: 14px; padding-right: 14px; }
  .card-pad { padding: 16px; }
  /* wide tables scroll (as their own block) instead of overflowing the screen */
  .view-root .table-wrap { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .view-root table { display: block; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; white-space: nowrap; }
  .inline-actions { flex-wrap: wrap; }
  .view-head { flex-wrap: wrap; gap: 12px; }
  .modal.wide { max-width: 100%; }
  .dtabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .dtab { white-space: nowrap; }
}
@media (max-width: 640px) {
  .topbar-title { font-size: 16px; }
  .card-head { padding: 14px 16px; }
  .btn { padding: 11px 16px; }   /* larger touch targets */
  .btn-sm { padding: 9px 13px; }
  .modal-overlay { padding: 10px; }
  .modal { max-height: 94vh; }
  /* 16px inputs stop iOS from auto-zooming the page on focus */
  input, select, textarea { font-size: 16px; }
  .view-head h2 { font-size: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  #view-root { animation: none; }
  .btn:hover:not(:disabled), .btn:active:not(:disabled), .nav-item:active { transform: none; }
}

/* =========================================================================
 * SHELL v2 — hamburger drawer + decluttered workspace
 * ========================================================================= */
.hamburger { display: inline-flex; flex-direction: column; justify-content: center; gap: 4px; width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); cursor: pointer; padding: 0; transition: background .15s ease, border-color .15s ease; flex: 0 0 auto; }
.hamburger:hover { background: var(--bg-2); border-color: #d7deea; }
.hamburger:active { transform: scale(.96); }
.hamburger span { display: block; width: 18px; height: 2px; background: #334155; margin: 0 auto; border-radius: 2px; }
/* a close control at the top of the drawer */
.sidebar-close { position: absolute; top: 16px; right: 14px; width: 30px; height: 30px; border-radius: 8px; border: none; background: rgba(255,255,255,.08); color: #cbd5e1; cursor: pointer; font-size: 16px; line-height: 1; }
.sidebar-close:hover { background: rgba(255,255,255,.16); color: #fff; }

/* Calmer, roomier workspace chrome */
.topbar { -webkit-backdrop-filter: saturate(1.05) blur(6px); backdrop-filter: saturate(1.05) blur(6px); }
.view-root { padding: 30px 30px 52px; max-width: 1160px; }
.view-head { margin-bottom: 26px; }
.view-head h2 { font-size: 22px; }
.card { box-shadow: 0 1px 2px rgba(12,31,56,.04); border-color: #e7e2d8; border-radius: 14px; }
@media (max-width: 640px) { .view-root { padding: 20px 16px 40px; } }

/* Pinned sidebar on true desktop; phones & tablets use the slide-over drawer + hamburger */
@media (min-width: 1024px) {
  .app-shell { display: grid; grid-template-columns: 264px 1fr; }
  .sidebar { position: sticky; top: 0; height: 100vh; transform: none; box-shadow: none; z-index: 30; }
  #sidebar-toggle { display: none; }
  .sidebar-scrim { display: none !important; }
}
