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

:root {
  /* Palette copied from ironhound.com:
     #c7ad8c tan (primary brand, matches logo wordmark, thin rules, footer)
     #b27a63 bronze (hover / deeper accent)
     #234b64 slate navy (secondary brand, headings, buttons)
     #162130 ink (body text)
     #fcfcfc off-white (page background)
     #f7f7f7 light gray surface (alt sections)
     #909395 medium gray (secondary text) */
  --bg: #fcfcfc;              /* page background */
  --bg2: #ffffff;             /* panels, cards */
  --bg3: #f7f7f7;             /* input + surface */
  --bg4: #eceae4;             /* hover surface */
  --gold: #c7ad8c;            /* ironhound tan */
  --gold-light: #d6c0a5;      /* lighter tan for gradient highlight */
  --bronze: #b27a63;          /* deeper tan, hover */
  --navy: #234b64;            /* slate navy — primary action color on light bg */
  --ink: #162130;             /* deep near-black — body text */
  --gold-dim: rgba(199,173,140,0.12);
  --navy-dim: rgba(35,75,100,0.08);
  --blue: #4a9eff; --green: #2ecc71; --red: #e74c3c; --orange: #f39c12;
  --purple: #9b59b6; --teal: #1abc9c;
  --text: #162130;            /* primary text */
  --text2: #6c757d;            /* secondary text */
  --text3: #909395;            /* tertiary / placeholder */
  --border: #e5ddd0;           /* tan-tinged border */
  --border-light: #c7ad8c;     /* hover border = brand tan */
  --on-gold: #162130;          /* text color that sits on top of --gold */
  --font: 'Lato', 'Inter', 'Segoe UI', -apple-system, sans-serif;
  --font-serif: 'Cardo', 'Georgia', 'Times New Roman', serif;
  --shadow-sm: 0 1px 3px rgba(22,33,48,0.06);
  --shadow-md: 0 4px 12px rgba(22,33,48,0.08);
  --shadow-lg: 0 8px 32px rgba(22,33,48,0.12);
  --radius: 8px;
  --radius-sm: 5px;
  --radius-lg: 12px;
  --transition: 0.2s ease;
}

html { scroll-behavior: smooth; }
body { font-family: var(--font); background: var(--bg); color: var(--text); min-height: 100vh; -webkit-font-smoothing: antialiased; }

::selection { background: var(--gold); color: var(--on-gold); }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--bg4); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* === TOP NAV === */
.topnav {
  display: flex; align-items: center; height: 52px;
  background: var(--bg2); border-bottom: 1px solid var(--border);
  padding: 0 24px; position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  box-shadow: 0 1px 4px rgba(22,33,48,0.06);
  backdrop-filter: blur(12px);
}
.topnav-brand {
  display: flex; align-items: center; margin-right: 36px;
  white-space: nowrap; position: relative;
}
.topnav-brand img {
  display: block; height: 32px; width: auto;
}
.topnav-brand::after {
  content: ''; position: absolute; right: -18px; top: 50%; transform: translateY(-50%);
  width: 1px; height: 20px; background: var(--border);
}
.topnav-tabs { display: flex; gap: 0; height: 100%; }
.topnav-tab {
  display: flex; align-items: center; padding: 0 16px; height: 100%;
  color: var(--text2); text-decoration: none; font-size: 0.8rem; font-weight: 500;
  border-bottom: 2px solid transparent; transition: all var(--transition);
  white-space: nowrap; cursor: pointer; background: none; border-top: none;
  border-left: none; border-right: none; font-family: var(--font);
  position: relative;
}
.topnav-tab:hover { color: var(--text); }
.topnav-tab.active { color: var(--gold); border-bottom-color: var(--gold); }
.topnav-right {
  margin-left: auto; display: flex; align-items: center; gap: 20px;
  font-size: 0.78rem;
}
.topnav-rate {
  color: var(--text2); white-space: nowrap;
  background: var(--bg3); padding: 4px 10px; border-radius: 4px;
  border: 1px solid var(--border);
}
.topnav-rate .rate-label { color: var(--text3); margin-right: 4px; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.5px; }
.topnav-rate .rate-value { color: var(--gold); font-weight: 600; font-variant-numeric: tabular-nums; }
.topnav-user {
  display: flex; align-items: center; gap: 10px;
  padding-left: 18px; border-left: 1px solid var(--border);
}
.topnav-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  color: var(--on-gold); display: flex;
  align-items: center; justify-content: center; font-size: 0.7rem; font-weight: 700;
  box-shadow: 0 2px 8px rgba(199,173,140,0.3);
}
.topnav-user-name { color: var(--text); font-weight: 500; font-size: 0.82rem; }
.topnav-signout {
  color: var(--text3); cursor: pointer; font-size: 0.75rem;
  background: none; border: none; font-family: var(--font);
  padding: 4px 8px; transition: var(--transition); border-radius: 3px;
}
.topnav-signout:hover { color: var(--red); background: rgba(231,76,60,0.08); }

/* === MAIN LAYOUT === */
.main-app { padding-top: 52px; min-height: 100vh; }
.page-content { padding: 24px 32px; max-width: 1600px; }

/* === LOGIN === */
.login-screen {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(199,173,140,0.04) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 50%, rgba(74,158,255,0.03) 0%, transparent 60%);
}
.login-screen.hidden { display: none; }
.login-box {
  background: var(--bg2); border: 1px solid var(--border);
  padding: 48px 44px; width: 100%; max-width: 420px;
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  position: relative; overflow: hidden;
}
.login-box::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--gold), var(--gold-light), var(--gold));
}
.login-logo {
  display: block; width: 220px; height: auto; margin: 0 auto 20px;
}
.login-box h2 {
  text-align: center; margin-bottom: 6px; color: var(--navy);
  font-size: 1.3rem; font-weight: 800; letter-spacing: 2px;
}
.login-box .sub {
  text-align: center; color: var(--text2); margin-bottom: 32px;
  font-size: 0.85rem; font-weight: 400;
}
.login-box input {
  width: 100%; padding: 13px 16px; background: var(--bg3);
  border: 1px solid var(--border); color: var(--text);
  font-family: var(--font); font-size: 0.88rem; margin-bottom: 14px;
  border-radius: var(--radius-sm); transition: border-color var(--transition);
}
.login-box input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(199,173,140,0.1); }
.login-box input::placeholder { color: var(--text3); }
.login-error {
  color: var(--red); font-size: 0.82rem; text-align: center;
  margin-bottom: 12px; display: none;
  background: rgba(231,76,60,0.08); padding: 8px; border-radius: var(--radius-sm);
}

/* === BUTTONS === */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 9px 20px; font-size: 0.8rem; font-weight: 600; border: none;
  cursor: pointer; font-family: var(--font); transition: all var(--transition);
  border-radius: var(--radius-sm); gap: 6px; position: relative; overflow: hidden;
}
.btn:active { transform: scale(0.97); }
.btn-gold {
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  color: var(--on-gold); box-shadow: 0 2px 8px rgba(199,173,140,0.25);
}
.btn-gold:hover { box-shadow: 0 4px 16px rgba(199,173,140,0.35); filter: brightness(1.05); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text2); }
.btn-outline:hover { border-color: var(--gold); color: var(--gold); background: var(--gold-dim); }
.btn-danger { background: rgba(231,76,60,0.15); color: var(--red); border: 1px solid rgba(231,76,60,0.2); }
.btn-danger:hover { background: rgba(231,76,60,0.25); }
.btn-sm { padding: 5px 12px; font-size: 0.72rem; }
.btn-block { width: 100%; text-align: center; padding: 12px; font-size: 0.88rem; }
.btn-add-dashboard {
  background: transparent; border: 1px dashed var(--border); color: var(--text3);
  padding: 4px 12px; font-size: 0.72rem; border-radius: var(--radius-sm); cursor: pointer;
  transition: var(--transition); font-family: var(--font);
}
.btn-add-dashboard:hover { border-color: var(--gold); color: var(--gold); border-style: solid; }

/* === STAT CARDS === */
.stat-row { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; margin-bottom: 28px; }
.stat-card {
  background: var(--bg2); border: 1px solid var(--border); padding: 20px;
  text-align: center; border-radius: var(--radius); position: relative;
  transition: all var(--transition); overflow: hidden;
}
.stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  opacity: 0; transition: opacity var(--transition);
}
.stat-card:hover { border-color: var(--border-light); transform: translateY(-1px); }
.stat-card:hover::before { opacity: 1; }
.stat-card .label { font-size: 0.68rem; color: var(--text2); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px; }
.stat-card .value { font-size: 1.5rem; font-weight: 700; color: var(--navy); font-variant-numeric: tabular-nums; }
.stat-card .sub { font-size: 0.75rem; color: var(--text2); margin-top: 2px; }

/* === SUB TABS === */
.sub-tabs { display: flex; gap: 0; margin-bottom: 24px; border-bottom: 1px solid var(--border); }
.sub-tab {
  padding: 10px 22px; font-size: 0.82rem; color: var(--text2); cursor: pointer;
  border-bottom: 2px solid transparent; background: none; border-top: none;
  border-left: none; border-right: none; font-family: var(--font);
  transition: all var(--transition); position: relative;
}
.sub-tab:hover { color: var(--text); }
.sub-tab.active { color: var(--gold); border-bottom-color: var(--gold); }

/* === DEAL CARDS === */
.deal-cards-grid { display: flex; gap: 16px; flex-wrap: wrap; }
.deal-card {
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; width: 380px; flex-shrink: 0;
  transition: all var(--transition);
}
.deal-card:hover { border-color: var(--border-light); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.deal-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; }
.deal-card-title { font-size: 0.95rem; font-weight: 600; color: var(--text); }
.deal-card-address { font-size: 0.78rem; color: var(--text2); margin-top: 4px; }
.deal-card-type {
  font-size: 0.65rem; padding: 3px 10px; border-radius: 20px;
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
  white-space: nowrap;
}
.type-office { background: rgba(74,158,255,0.12); color: var(--blue); }
.type-retail { background: rgba(243,156,18,0.12); color: var(--orange); }
.type-lodging { background: rgba(231,76,60,0.12); color: var(--red); }
.type-mixed-use { background: rgba(26,188,156,0.12); color: var(--teal); }
.type-multi-family { background: rgba(46,204,113,0.12); color: var(--green); }
.type-industrial { background: rgba(155,89,182,0.12); color: var(--purple); }
.type-self-storage { background: rgba(199,173,140,0.12); color: #c9a84c; }
.type-other { background: rgba(138,143,168,0.12); color: var(--text2); }

.deal-card-metrics { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.deal-card-metric .metric-label { font-size: 0.65rem; color: var(--text3); text-transform: uppercase; letter-spacing: 0.5px; }
.deal-card-metric .metric-value { font-size: 0.88rem; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.deal-card-servicer { font-size: 0.78rem; color: var(--text2); margin-bottom: 12px; }

/* === MY DASHBOARD LAYOUT === */
.my-dash-layout { display: grid; grid-template-columns: 1fr 320px; gap: 28px; }
.my-dash-main { min-width: 0; }
.my-dash-sidebar { display: flex; flex-direction: column; gap: 20px; }

.calendar-widget {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px;
}
.calendar-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.calendar-header h4 { font-size: 0.75rem; color: var(--text2); font-weight: 600; letter-spacing: 1px; }
.calendar-nav { display: flex; gap: 8px; }
.calendar-nav button { background: none; border: none; color: var(--text2); cursor: pointer; font-size: 0.8rem; padding: 2px 6px; transition: var(--transition); }
.calendar-nav button:hover { color: var(--gold); }
.calendar-title { font-size: 0.82rem; color: var(--text); font-weight: 500; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; gap: 2px; }
.calendar-grid .cal-day-name { font-size: 0.62rem; color: var(--text3); padding: 4px 0; text-transform: uppercase; letter-spacing: 0.5px; }
.calendar-grid .cal-day { font-size: 0.75rem; color: var(--text2); padding: 6px 0; border-radius: 50%; cursor: default; transition: var(--transition); }
.calendar-grid .cal-day.today { background: var(--gold); color: var(--on-gold); font-weight: 700; }
.calendar-grid .cal-day.empty { visibility: hidden; }
.calendar-grid .cal-day.has-event { color: var(--gold); font-weight: 600; }

.chart-widget { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.chart-widget h4 { font-size: 0.72rem; color: var(--text3); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 16px; }
canvas#chart-closed-by-year, canvas#chart-volume-by-year, canvas#chart-ih-closed-by-year, canvas#chart-ih-volume-by-year { display: block; width: 100%; height: 200px; }
.donut-container { display: flex; align-items: center; gap: 20px; }
.donut-legend { display: flex; flex-direction: column; gap: 6px; }
.donut-legend-item { display: flex; align-items: center; gap: 8px; font-size: 0.78rem; }
.donut-legend-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.donut-legend-count { margin-left: auto; color: var(--text2); min-width: 20px; text-align: right; font-variant-numeric: tabular-nums; }
.donut-legend-pct { color: var(--text3); font-size: 0.72rem; min-width: 36px; text-align: right; }

/* === IH DEALS PAGE === */
.ih-deals-layout { display: flex; gap: 0; }
.filter-sidebar {
  width: 230px; flex-shrink: 0; background: var(--bg2);
  border-right: 1px solid var(--border); padding: 20px 16px;
  max-height: calc(100vh - 52px); overflow-y: auto;
  position: sticky; top: 52px;
}
.filter-group { margin-bottom: 18px; }
.filter-group-title {
  font-size: 0.68rem; color: var(--text3); text-transform: uppercase;
  letter-spacing: 1px; margin-bottom: 10px; font-weight: 600;
}
.filter-group label {
  display: flex; align-items: center; gap: 8px; font-size: 0.78rem;
  color: var(--text2); padding: 4px 0; cursor: pointer; transition: var(--transition);
}
.filter-group label:hover { color: var(--text); }
.filter-group input[type="checkbox"] { accent-color: var(--gold); width: 14px; height: 14px; }
.filter-group select {
  width: 100%; padding: 7px 10px; background: var(--bg3); border: 1px solid var(--border);
  color: var(--text); font-family: var(--font); font-size: 0.78rem; border-radius: var(--radius-sm);
}
.ih-deals-main { flex: 1; min-width: 0; }
.ih-deals-topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 24px; border-bottom: 1px solid var(--border); background: var(--bg2);
  position: sticky; top: 52px; z-index: 10;
}
.search-input {
  padding: 8px 16px; background: var(--bg3); border: 1px solid var(--border);
  color: var(--text); font-family: var(--font); font-size: 0.82rem;
  min-width: 280px; border-radius: var(--radius-sm); transition: border-color var(--transition);
}
.search-input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(199,173,140,0.08); }
.deal-count { color: var(--text2); font-size: 0.82rem; font-variant-numeric: tabular-nums; }

/* === DATA TABLE === */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); }
.data-table th {
  font-size: 0.68rem; color: var(--text3); text-transform: uppercase;
  letter-spacing: 0.8px; background: var(--bg2); font-weight: 600;
  position: sticky; top: 0; z-index: 1;
}
.data-table td { font-size: 0.82rem; color: var(--text); }
.data-table tbody tr { transition: background var(--transition); }
.data-table tbody tr:hover { background: rgba(199,173,140,0.04); }
.sortable { cursor: pointer; user-select: none; transition: color var(--transition); }
.sortable:hover { color: var(--gold); }
.sortable.asc::after { content: ' \25B2'; font-size: 0.6rem; }
.sortable.desc::after { content: ' \25BC'; font-size: 0.6rem; }

/* Status badges */
.status-badge {
  padding: 4px 12px; font-size: 0.65rem; text-transform: uppercase;
  letter-spacing: 0.5px; font-weight: 600; border-radius: 20px; white-space: nowrap;
  display: inline-block;
}
.status-pipeline { background: rgba(74,158,255,0.12); color: var(--blue); }
.status-underwriting { background: rgba(155,89,182,0.12); color: var(--purple); }
.status-negotiation { background: rgba(243,156,18,0.12); color: var(--orange); }
.status-closing { background: rgba(46,204,113,0.12); color: var(--green); }
.status-closed { background: rgba(199,173,140,0.12); color: var(--gold); }
.status-dead { background: rgba(231,76,60,0.12); color: var(--red); }

/* Outreach badges */
.outreach-badge { padding: 4px 12px; font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; border-radius: 20px; }
.outreach-none { background: rgba(90,95,122,0.12); color: var(--text3); }
.outreach-reached-out { background: rgba(243,156,18,0.12); color: var(--orange); }
.outreach-contacted { background: rgba(74,158,255,0.12); color: var(--blue); }
.outreach-engaged { background: rgba(155,89,182,0.12); color: var(--purple); }
.outreach-closed { background: rgba(199,173,140,0.12); color: var(--gold); }

/* Property type badges */
.prop-type-badge {
  font-size: 0.68rem; padding: 3px 10px; border-radius: 20px;
  font-weight: 500; white-space: nowrap;
}

/* Outreach select in table */
.outreach-select {
  padding: 4px 8px; background: var(--bg3); border: 1px solid var(--border);
  color: var(--text); font-size: 0.72rem; cursor: pointer; font-family: var(--font);
  border-radius: var(--radius-sm); transition: border-color var(--transition);
}
.outreach-select:focus { outline: none; border-color: var(--gold); }

/* Inline note input */
.inline-note-input {
  padding: 4px 8px; background: var(--bg3); border: 1px solid var(--border);
  color: var(--text); font-size: 0.72rem; font-family: var(--font);
  border-radius: var(--radius-sm); width: 100%; transition: border-color var(--transition);
}
.inline-note-input:focus { outline: none; border-color: var(--gold); }

/* === DEAL DETAIL === */
.detail-topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 32px; border-bottom: 1px solid var(--border);
  background: var(--bg2); box-shadow: var(--shadow-sm);
}
.detail-tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 24px; }
.detail-tab {
  padding: 12px 22px; font-size: 0.82rem; color: var(--text2); cursor: pointer;
  border-bottom: 2px solid transparent; background: none; border-top: none;
  border-left: none; border-right: none; font-family: var(--font);
  transition: all var(--transition);
}
.detail-tab:hover { color: var(--text); background: var(--gold-dim); }
.detail-tab.active { color: var(--gold); border-bottom-color: var(--gold); }
.tab-panel { display: none; animation: fadeIn 0.25s ease; }
.tab-panel.active { display: block; }
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.info-section {
  background: var(--bg2); border: 1px solid var(--border);
  padding: 20px; border-radius: var(--radius);
}
.info-section h3 { font-size: 0.75rem; color: var(--navy); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 14px; }
.info-row { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid rgba(255,255,255,0.03); }
.info-row:last-child { border-bottom: none; }
.info-label { color: var(--text2); font-size: 0.78rem; }
.info-value { color: var(--text); font-size: 0.82rem; font-weight: 500; }

/* Timeline */
.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline-item {
  display: flex; gap: 14px; padding: 12px 0;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  transition: background var(--transition);
}
.timeline-item:hover { background: var(--gold-dim); margin: 0 -8px; padding-left: 8px; padding-right: 8px; border-radius: var(--radius-sm); }
.timeline-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); margin-top: 6px; flex-shrink: 0; }
.timeline-dot.note { background: var(--blue); }
.timeline-dot.status { background: var(--green); }
.timeline-text { font-size: 0.82rem; }
.timeline-user { font-size: 0.72rem; color: var(--text2); margin-top: 2px; }

/* Docs */
.doc-grid { display: flex; flex-direction: column; gap: 6px; }
.doc-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); transition: all var(--transition);
}
.doc-row:hover { border-color: var(--border-light); }
.doc-row a { color: var(--gold); font-size: 0.82rem; text-decoration: none; font-weight: 500; }
.doc-row a:hover { color: var(--gold-light); }
.doc-meta { font-size: 0.72rem; color: var(--text2); display: flex; gap: 14px; align-items: center; }

/* Forms */
.form-grid {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px;
  background: var(--bg2); border: 1px solid var(--border);
  padding: 24px; margin-bottom: 24px; border-radius: var(--radius);
}
.form-grid.cols-2 { grid-template-columns: 1fr 1fr; }
.form-grid label { font-size: 0.72rem; color: var(--text2); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 5px; display: block; }
.form-group { display: flex; flex-direction: column; }
.form-group.full { grid-column: 1 / -1; }
.form-grid input, .form-grid select, .form-grid textarea {
  width: 100%; padding: 9px 14px; background: var(--bg3); border: 1px solid var(--border);
  color: var(--text); font-family: var(--font); font-size: 0.82rem;
  border-radius: var(--radius-sm); transition: border-color var(--transition);
}
.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus {
  outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(199,173,140,0.08);
}
.form-grid input::placeholder, .form-grid textarea::placeholder { color: var(--text3); }
.form-grid textarea { min-height: 80px; resize: vertical; }
.form-actions { grid-column: 1 / -1; display: flex; gap: 8px; }

/* Task list */
.task-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  background: var(--bg2); border: 1px solid var(--border); margin-bottom: 6px;
  border-radius: var(--radius-sm); transition: all var(--transition);
}
.task-item:hover { border-color: var(--border-light); }
.task-check { width: 16px; height: 16px; cursor: pointer; accent-color: var(--gold); }
.task-item .title { flex: 1; font-size: 0.82rem; }
.task-item .title.done { text-decoration: line-through; color: var(--text3); }
.task-item .due { font-size: 0.72rem; color: var(--text2); }
.task-item .due.overdue { color: var(--red); font-weight: 600; }
.badge {
  display: inline-block; padding: 3px 10px; font-size: 0.62rem;
  text-transform: uppercase; letter-spacing: 0.5px; border-radius: 20px;
}
.badge-high { background: rgba(231,76,60,0.12); color: var(--red); }
.badge-medium { background: rgba(243,156,18,0.12); color: var(--orange); }
.badge-low { background: rgba(46,204,113,0.12); color: var(--green); }

/* Pipeline */
.pipeline-board { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 24px; }
.pipeline-col {
  background: var(--bg2); border: 1px solid var(--border);
  min-height: 100px; border-radius: var(--radius);
}
.pipeline-col-header {
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.pipeline-col-header h3 { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 1px; color: var(--text2); }
.pipeline-col-header .count {
  background: var(--gold-dim); color: var(--gold);
  padding: 2px 10px; font-size: 0.72rem; font-weight: 700;
  border-radius: 20px; border: 1px solid rgba(199,173,140,0.2);
}
.pipeline-card {
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  cursor: pointer; transition: all var(--transition);
}
.pipeline-card:hover { background: var(--bg3); }
.pipeline-card:last-child { border-bottom: none; }
.pipeline-card h4 { font-size: 0.82rem; margin-bottom: 4px; font-weight: 600; }
.pipeline-card .meta { font-size: 0.72rem; color: var(--text2); }

/* Stat grid (outreach) */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 28px; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(22,33,48,0.45);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
  display: none; backdrop-filter: blur(4px);
}
.modal-overlay.open { display: flex; animation: fadeIn 0.2s ease; }
.modal {
  background: var(--bg2); border: 1px solid var(--border);
  padding: 36px; width: 100%; max-width: 700px; max-height: 85vh;
  overflow-y: auto; border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); animation: slideUp 0.25s ease;
}
.modal h2 { font-size: 1.1rem; margin-bottom: 24px; color: var(--navy); }

/* Engaged deal card docs */
.engaged-doc-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 5px 0; border-bottom: 1px solid var(--bg3); font-size: 0.75rem;
}

/* === TOAST NOTIFICATIONS === */
.toast-container {
  position: fixed; top: 64px; right: 24px; z-index: 10000;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  background: var(--bg2); border: 1px solid var(--border);
  padding: 12px 20px; border-radius: var(--radius);
  box-shadow: var(--shadow-lg); font-size: 0.82rem;
  animation: slideIn 0.3s ease, fadeOut 0.3s ease 2.7s forwards;
  pointer-events: auto; max-width: 360px;
  display: flex; align-items: center; gap: 10px;
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }
.toast.info { border-left: 3px solid var(--blue); }
.toast-icon { font-size: 1rem; flex-shrink: 0; }

/* === LOADING SPINNER === */
.spinner {
  width: 18px; height: 18px; border: 2px solid var(--border);
  border-top-color: var(--gold); border-radius: 50%;
  animation: spin 0.6s linear infinite; display: inline-block;
}
.page-loading {
  display: flex; align-items: center; justify-content: center;
  padding: 60px; color: var(--text3);
  gap: 12px; font-size: 0.85rem;
}

/* === ANIMATIONS === */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideIn { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse-voice { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }

/* === RESPONSIVE === */
@media (max-width: 1100px) {
  .my-dash-layout { grid-template-columns: 1fr; }
  .my-dash-sidebar { flex-direction: row; flex-wrap: wrap; }
  .calendar-widget, .chart-widget { flex: 1; min-width: 280px; }
}
@media (max-width: 900px) {
  .stat-row { grid-template-columns: repeat(3, 1fr); }
  .filter-sidebar { display: none; }
  .info-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .pipeline-board { grid-template-columns: 1fr; }
  .deal-cards-grid { flex-direction: column; }
  .deal-card { width: 100%; }
  .page-content { padding: 16px; }
  .topnav-tabs { overflow-x: auto; }
}
@media (max-width: 600px) {
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .topnav-user-name { display: none; }
  .topnav-tab { padding: 0 10px; font-size: 0.75rem; }
}

/* === MOBILE (iPhone-ish ≤ 768px) ===
   Only show My Deals / IH Deals / Brokerage Deals / Calendar in the top nav.
   Hide Deal Tracker, Outreach, Users, the rates ticker, and the per-user
   controls (Security / Change Password) to keep the bar readable on a narrow
   screen. Sign Out stays reachable. Desktop layout (> 768px) is untouched. */
@media (max-width: 768px) {
  html { max-width: 100vw; }
  body { max-width: 100vw; }
  /* Don't force overflow-x: hidden on body — breaks position:fixed elements
     like the chatbot on iOS Safari. Let individual overflowing components
     clip themselves. */
  .topnav-tab[data-page="deals"],
  .topnav-tab[data-page="outreach"],
  .topnav-tab[data-page="users"],
  #security-btn,
  #change-pw-btn { display: none !important; }
  /* Topnav grows to two rows on mobile: row 1 = brand + tabs + sign-out,
     row 2 = compact rates ticker. Adjust main-app padding to match. */
  .topnav {
    flex-wrap: wrap;
    height: auto;
    min-height: 52px;
    padding: 6px 10px;
    row-gap: 4px;
    align-items: center;
  }
  .main-app { padding-top: 92px; }
  .topnav-brand { margin-right: 12px; }
  .topnav-brand img { height: 24px; }
  .topnav-tab { padding: 0 10px; font-size: 0.78rem; }
  .topnav-user { padding-left: 10px; gap: 6px; }
  .topnav-signout { font-size: 0.72rem; padding: 4px 6px; }
  /* Rates ticker sits on its own row below the nav on mobile — shrink so
     SOFR / 5Y / 10Y all fit side-by-side on an iPhone. */
  .topnav-right {
    order: 10;            /* push to the end, allowing wrap to line 2 */
    width: 100%;
    justify-content: flex-start;
    gap: 8px;
    font-size: 0.72rem;
  }
  .topnav-rate { padding: 2px 8px; font-size: 0.72rem; }
  .topnav-rate .rate-label { font-size: 0.6rem; margin-right: 3px; }
  .topnav-user { margin-left: auto; }
  .page-content { padding: 12px; max-width: 100%; }
  /* Stat card grids collapse to 2 columns to fit */
  .stat-row { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 12px; }
  .stat-card .value { font-size: 1.1rem; }
  /* Tables: let them scroll horizontally inside their container rather than
     overflow the page. The .data-table parents already have overflow-x:auto
     on most callers; this is a belt-and-suspenders rule. */
  .data-table { font-size: 0.75rem; }
  .data-table th, .data-table td { padding: 8px 10px; }
  /* Deal detail: tabs can scroll horizontally */
  .detail-tabs { overflow-x: auto; flex-wrap: nowrap; }
  .detail-tab { flex-shrink: 0; padding: 10px 12px; font-size: 0.78rem; }
  .detail-topbar { padding: 10px 12px; flex-wrap: wrap; gap: 8px; }
  .detail-topbar h1 { font-size: 0.95rem; }
  /* Sub-tabs (Active / 2026 Closed / All Closed) — allow wrap or scroll */
  .sub-tabs { overflow-x: auto; flex-wrap: nowrap; }
  .sub-tab { flex-shrink: 0; padding: 8px 14px; font-size: 0.78rem; }
  /* Calendar cells shrink so a week fits */
  .cal-grid .cal-cell { min-height: 70px; padding: 4px; }
  .cal-cell-day { font-size: 0.7rem; }
  .cal-event { font-size: 0.62rem; padding: 1px 4px; }
  /* My Dashboard + IH Deals charts stack instead of 2-col grid */
  #page-my-dashboard .page-content > div[style*="grid-template-columns:1fr 1fr"],
  #page-ih-deals .page-content > div[style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
  /* Modals should not exceed viewport */
  .modal { max-width: calc(100vw - 20px); max-height: 90vh; padding: 20px; }
  /* Chatbot panel: full width minus a small margin. Respect safe area so the
     button isn't under the iPhone home indicator. SVG inside the toggle gets
     pointer-events:none so taps always hit the parent div handler. */
  #chatbot-panel {
    width: calc(100vw - 20px);
    right: 10px;
    bottom: max(10px, env(safe-area-inset-bottom));
    height: min(70vh, calc(100vh - 80px));
  }
  #chatbot-toggle {
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
  }
  #chatbot-toggle svg, #chatbot-toggle path { pointer-events: none; }
  /* Chat input row: tighten padding and give the input min-width:0 so flex
     can shrink it instead of pushing the mic button off-screen to the left. */
  #chatbot-form { padding: 10px; gap: 6px; flex-wrap: nowrap; }
  #chatbot-input { min-width: 0; flex: 1 1 auto; padding: 8px 10px; font-size: 0.82rem; }
  #voice-btn { width: 34px; height: 34px; flex-shrink: 0; }
  #chatbot-form .btn { flex-shrink: 0; padding: 8px 12px; font-size: 0.78rem; }
  #chatbot-header { padding: 12px 14px; font-size: 0.82rem; }
  #chatbot-messages { padding: 12px; gap: 10px; }
  .chat-msg { max-width: 92%; font-size: 0.82rem; padding: 10px 12px; }
}

/* === FULL PAGE CALENDAR === */
.cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
}
.cal-grid .cal-header {
  background: var(--bg2); padding: 12px 0; text-align: center;
  font-size: 0.7rem; color: var(--text3); text-transform: uppercase;
  letter-spacing: 1px; font-weight: 600; border-bottom: 1px solid var(--border);
}
.cal-grid .cal-cell {
  min-height: 110px; background: var(--bg2); border: 1px solid var(--border);
  padding: 8px 8px; vertical-align: top; position: relative;
  transition: background var(--transition);
}
.cal-grid .cal-cell:hover { background: var(--bg3); }
.cal-grid .cal-cell.other-month { background: var(--bg); opacity: 0.4; }
.cal-grid .cal-cell.today { background: rgba(199,173,140,0.06); }
.cal-cell-day {
  font-size: 0.78rem; font-weight: 600; color: var(--text2); margin-bottom: 6px;
}
.cal-cell.today .cal-cell-day {
  color: var(--on-gold); background: var(--gold);
  width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem;
}
.cal-event {
  display: block; padding: 2px 6px; margin-bottom: 3px; border-radius: 3px;
  font-size: 0.68rem; font-weight: 500; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: all var(--transition);
}
.cal-event:hover { filter: brightness(1.3); transform: translateX(2px); }
.cal-event.type-maturity { background: rgba(231,76,60,0.15); color: #e74c3c; }
.cal-event.type-extension { background: rgba(243,156,18,0.15); color: #f39c12; }
.cal-event.type-payoff { background: rgba(46,204,113,0.15); color: #2ecc71; }
.cal-event.type-notice { background: rgba(155,89,182,0.15); color: #9b59b6; }
.cal-event.type-test { background: rgba(74,158,255,0.15); color: #4a9eff; }
.cal-event.type-closing { background: rgba(199,173,140,0.15); color: #c9a84c; }
.cal-event.type-transfer { background: rgba(26,188,156,0.15); color: #1abc9c; }
.cal-event.type-engagement { background: rgba(199,173,140,0.15); color: #c9a84c; }
.cal-event.type-rate_change { background: rgba(243,156,18,0.15); color: #f39c12; }
.cal-event.type-reserve { background: rgba(74,158,255,0.15); color: #4a9eff; }
.cal-event.type-other { background: rgba(138,143,168,0.15); color: #8a8fa8; }
.cal-event-more {
  font-size: 0.65rem; color: var(--text3); padding: 2px 6px; cursor: pointer;
}
.cal-event-more:hover { color: var(--gold); }
.cal-legend { display: flex; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.cal-legend-item { display: flex; align-items: center; gap: 5px; font-size: 0.72rem; color: var(--text2); }
.cal-legend-dot { width: 8px; height: 8px; border-radius: 2px; }

/* === CHATBOT === */
#chatbot-toggle {
  position: fixed; bottom: 24px; right: 24px; z-index: 999;
  width: 52px; height: 52px; border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  color: var(--on-gold); display: flex;
  align-items: center; justify-content: center; cursor: pointer;
  box-shadow: 0 4px 24px rgba(199,173,140,0.35); transition: all 0.25s;
}
#chatbot-toggle:hover { transform: scale(1.08); box-shadow: 0 6px 32px rgba(199,173,140,0.45); }
#chatbot-panel {
  position: fixed; bottom: 24px; right: 24px; z-index: 1000;
  width: 420px; height: 520px; background: var(--bg2);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: var(--shadow-lg); animation: slideUp 0.25s ease;
}
#chatbot-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; background: var(--bg3); border-bottom: 1px solid var(--border);
  font-size: 0.88rem; font-weight: 600; color: var(--navy);
}
#chatbot-messages {
  flex: 1; overflow-y: auto; padding: 18px; display: flex;
  flex-direction: column; gap: 12px;
}
.chat-msg {
  font-size: 0.82rem; line-height: 1.6; padding: 12px 16px;
  border-radius: var(--radius-lg); max-width: 88%; word-wrap: break-word;
}
.chat-msg.user {
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  color: var(--on-gold); align-self: flex-end;
  border-bottom-right-radius: 4px; font-weight: 500;
}
.chat-msg.assistant {
  background: var(--bg3); color: var(--text); align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.chat-msg.assistant strong { color: var(--navy); }
.chat-msg.thinking {
  background: var(--bg3); color: var(--text3); align-self: flex-start;
  font-style: italic;
}
#chatbot-form {
  display: flex; gap: 8px; padding: 14px 18px;
  border-top: 1px solid var(--border); background: var(--bg3);
}
#chatbot-input {
  flex: 1; padding: 9px 14px; background: var(--bg); border: 1px solid var(--border);
  color: var(--text); font-family: var(--font); font-size: 0.82rem;
  border-radius: var(--radius); transition: border-color var(--transition);
}
#chatbot-input:focus { outline: none; border-color: var(--gold); }
#voice-btn {
  background: var(--bg); border: 1px solid var(--border); color: var(--text2);
  width: 38px; height: 38px; border-radius: var(--radius); cursor: pointer;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: all var(--transition);
}
#voice-btn:hover { border-color: var(--gold); color: var(--gold); }
#voice-btn.listening { background: var(--red); border-color: var(--red); color: #fff; animation: pulse-voice 1s infinite; }

/* === FOCUS STATES === */
*:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}

/* Per-tab search input on My Deals / IH Deals / Brokerage Deals */
.deal-search {
  display: block;
  width: 100%;
  max-width: 480px;
  padding: 9px 14px;
  margin: 0 0 14px;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.88rem;
  border-radius: var(--radius-sm);
  transition: border-color var(--transition);
}
.deal-search:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(199,173,140,0.1); }
.deal-search::placeholder { color: var(--text3); }

/* === MOBILE CHATBOT OVERRIDES (must come after base chatbot rules) ===
   Sits at the end of the file to win the cascade against #chatbot-panel's
   desktop styles (420px wide, 24px from right) which would otherwise push
   the panel off-screen to the left on a 390px iPhone. */
@media (max-width: 768px) {
  #chatbot-panel {
    width: calc(100vw - 20px);
    right: 10px;
    left: 10px;
    bottom: max(10px, env(safe-area-inset-bottom));
    height: min(70vh, calc(100vh - 80px));
  }
  #chatbot-toggle {
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
  }
}
