/* BMVP CRM — brand styles pulled from bmvp.us
   Accent cyan #00adef · navies #0c1228 / #0f1e5e / #04102b · slate #3d5470
   Headings: Playfair Display · Body: Inter */

:root {
  --brand-accent: #00adef;
  --brand-accent-deep: #0080c0;
  --brand-navy: #0c1228;
  --brand-navy-2: #0f1e5e;
  --brand-navy-3: #04102b;
  --brand-blue: #1535c8;
  --brand-slate: #3d5470;
  --brand-slate-light: #8a9fae;
  --bg: #f2f6fc;
  --bg-alt: #e8f2fb;
  --line: #dce8f5;
  --card: #ffffff;
  --text: #0c1228;
  --text-muted: #3d5470;
  --green: #158a4e;
  --green-bright: #22d17a;
  --red: #b3352c;
  --shadow: 0 1px 3px rgba(15, 30, 94, 0.07), 0 4px 14px rgba(15, 30, 94, 0.07);
  --shadow-lift: 0 4px 18px rgba(15, 30, 94, 0.13);
  --radius: 10px;
  --font-head: 'Playfair Display', Georgia, serif;
  --font-body: 'Inter', -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3 { font-family: var(--font-head); color: var(--brand-navy); margin: 0 0 .5rem; }
a { color: var(--brand-accent-deep); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: var(--bg-alt); padding: .1em .35em; border-radius: 4px; font-size: .9em; }
hr { border: 0; border-top: 1px solid var(--line); margin: .4rem 0; }

/* ---------- Top navigation ---------- */
.topnav {
  background: linear-gradient(135deg, var(--brand-navy-3) 0%, var(--brand-navy) 55%, #061840 100%);
  border-bottom: 3px solid var(--brand-accent);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topnav-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 58px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: .5rem; }
.brand:hover { text-decoration: none; }
/* Logo source is a JPEG-in-PNG with a black background; screen blending
   makes the black disappear into the dark nav. */
.brand-logo { height: 34px; mix-blend-mode: screen; }
.login-logo { mix-blend-mode: normal; }
.brand-app {
  color: var(--brand-accent);
  font-weight: 700;
  letter-spacing: .18em;
  font-size: .8rem;
  border: 1px solid rgba(0, 173, 239, 0.35);
  border-radius: 4px;
  padding: .1rem .4rem;
}
.nav-links { display: flex; align-items: center; gap: .25rem; flex: 1; }
.nav-links > a, .nav-dropdown-btn {
  color: rgba(255, 255, 255, 0.8);
  padding: .45rem .7rem;
  border-radius: 6px;
  font-weight: 500;
  font-size: .92rem;
  background: none;
  border: 0;
  cursor: pointer;
  font-family: var(--font-body);
}
.nav-links > a:hover, .nav-dropdown-btn:hover { color: #fff; background: rgba(255, 255, 255, 0.07); text-decoration: none; }
.nav-links > a.active, .nav-dropdown-btn.active { color: #fff; background: rgba(0, 173, 239, 0.2); }
.nav-dropdown { position: relative; }
.caret { font-size: .7em; opacity: .7; }
.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: var(--card);
  border-radius: 8px;
  box-shadow: var(--shadow-lift);
  border: 1px solid var(--line);
  min-width: 260px;
  padding: .35rem;
  z-index: 60;
}
.nav-dropdown.open .nav-dropdown-menu { display: block; }
.nav-dropdown-menu a {
  display: block;
  padding: .45rem .6rem;
  border-radius: 6px;
  color: var(--text);
  font-size: .92rem;
}
.nav-dropdown-menu a:hover { background: var(--bg-alt); text-decoration: none; }
.cat-icon { margin-right: .25rem; }
/* "Pipeline" section header — only shown in the stacked mobile menu. */
.nav-section-label { display: none; }
/* Drawer chrome — only used by the mobile slide-in drawer, hidden on desktop. */
.nav-backdrop { display: none; }
.nav-drawer-head { display: none; }
.nav-user { margin-left: auto; display: flex; align-items: center; gap: .6rem; }
.nav-username { color: rgba(255, 255, 255, 0.6); font-size: .88rem; }
.nav-toggle {
  display: none;
  background: none;
  border: 0;
  cursor: pointer;
  padding: .6rem;
  margin-left: auto;
  border-radius: 8px;
  min-width: 44px;
  min-height: 44px;
}
.nav-toggle:hover { background: rgba(255, 255, 255, 0.08); }
.nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: #fff;
  margin: 5px auto;
  border-radius: 2px;
  transition: transform .2s, opacity .2s;
}
/* Animate the hamburger into an X when the menu is open. */
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---------- Layout ---------- */
.page { flex: 1; }
.container { max-width: 1100px; margin: 0 auto; padding: 1.4rem 1rem 2.5rem; }
.container.narrow { max-width: 760px; }
.container.wide { max-width: 1400px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.1rem; }
.page-title { font-size: 1.7rem; margin: 0; }
.title-icon { font-size: 1.3rem; margin-right: .15rem; }
.page-actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.muted { color: var(--text-muted); }
.small { font-size: .85rem; }
.empty { color: var(--text-muted); font-style: italic; }
.site-footer { text-align: center; color: var(--brand-slate-light); font-size: .8rem; padding: 1.2rem; }

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  padding: 1.1rem 1.25rem;
  margin-bottom: 1.1rem;
}
.card-title { font-size: 1.08rem; margin-bottom: .8rem; }
.table-card { padding: .3rem .5rem; overflow-x: auto; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: .5rem .95rem;
  font-size: .92rem;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  text-align: center;
}
.btn:hover { text-decoration: none; }
.btn-sm { padding: .32rem .7rem; font-size: .85rem; }
.btn-block { width: 100%; }
.btn-primary { background: var(--brand-accent); color: #fff; }
.btn-primary:hover { background: var(--brand-accent-deep); }
.btn-secondary { background: #fff; color: var(--brand-navy-2); border-color: var(--brand-slate-light); }
.btn-secondary:hover { border-color: var(--brand-accent); color: var(--brand-accent-deep); }
.btn-ghost { background: none; color: var(--text-muted); }
.btn-ghost:hover { color: var(--brand-navy); }
.btn-danger-ghost { background: none; color: var(--red); border-color: transparent; }
.btn-danger-ghost:hover { border-color: var(--red); }
.btn-link-danger { background: none; border: 0; color: var(--red); cursor: pointer; font-size: .82rem; padding: 0; font-family: var(--font-body); }
.btn-link-danger:disabled { color: var(--brand-slate-light); cursor: not-allowed; }
.inline-form { display: inline; }

/* ---------- Forms ---------- */
.field { display: block; margin-bottom: .85rem; }
.field > span { display: block; font-size: .84rem; font-weight: 600; color: var(--brand-slate); margin-bottom: .25rem; }
.field input, .field select, .field textarea, .note-form input, .note-form textarea,
.filter-bar input, .filter-bar select, .stage-edit-form input, .stage-edit-form select,
.stage-add-form input, .stage-add-form select,
.task-form input, .task-form select, .task-edit-form input, .task-edit-form select {
  width: 100%;
  padding: .5rem .6rem;
  border: 1px solid var(--line);
  border-radius: 7px;
  font-size: .95rem;
  font-family: var(--font-body);
  color: var(--text);
  background: #fff;
}
.field input:focus, .field select:focus, .field textarea:focus,
.note-form input:focus, .note-form textarea:focus {
  outline: 2px solid rgba(0, 173, 239, 0.35);
  border-color: var(--brand-accent);
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; }
.field-row.three { grid-template-columns: 1fr 1fr 1fr; }
.form-actions { display: flex; gap: .6rem; align-items: center; margin-top: .5rem; }
.subfields { border: 1px solid var(--line); border-radius: 8px; padding: .8rem .9rem .2rem; margin: 0 0 .9rem; }
.subfields legend { font-size: .84rem; font-weight: 600; color: var(--brand-slate); padding: 0 .35rem; }
.alert { border-radius: 8px; padding: .65rem .9rem; margin-bottom: .9rem; font-size: .92rem; }
.alert-error { background: #fdecea; color: var(--red); border: 1px solid #f3c5c0; }
.alert-success { background: #e9f9f0; color: var(--green); border: 1px solid #bfe9d2; }
.bullets { margin: .3rem 0 .8rem 1.2rem; padding: 0; }

/* ---------- Login ---------- */
.login-body {
  background:
    radial-gradient(900px 500px at 80% -10%, rgba(0, 173, 239, 0.25), transparent 60%),
    linear-gradient(160deg, var(--brand-navy-3), var(--brand-navy) 60%, var(--brand-navy-2));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.login-card {
  background: rgba(4, 16, 43, 0.65);
  border: 1px solid rgba(0, 173, 239, 0.35);
  border-radius: 14px;
  padding: 2rem 2.2rem;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}
.login-logo { width: 100%; max-width: 280px; display: block; margin: 0 auto .8rem; mix-blend-mode: screen; }
.login-title { color: #fff; text-align: center; font-size: 1.25rem; margin-bottom: 1.2rem; }
.login-card .field > span { color: rgba(255, 255, 255, 0.8); }
.login-card input { background: rgba(255, 255, 255, 0.95); border-color: transparent; }

/* ---------- Filter bar ---------- */
.filter-bar { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.filter-bar input, .filter-bar select { width: auto; }
.filter-search { flex: 1; min-width: 200px; }

/* ---------- Tables ---------- */
.data-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.data-table th {
  text-align: left;
  font-size: .76rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--brand-slate);
  padding: .6rem .7rem;
  border-bottom: 2px solid var(--line);
}
.data-table td { padding: .6rem .7rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table .num { text-align: right; }
tr.row-link { cursor: pointer; }
tr.row-link:hover { background: var(--bg-alt); }

/* ---------- Chips ---------- */
.chip {
  display: inline-block;
  background: var(--bg-alt);
  color: var(--brand-slate);
  border-radius: 999px;
  padding: .1rem .55rem;
  font-size: .76rem;
  font-weight: 600;
  margin: .05rem .15rem .05rem 0;
  white-space: nowrap;
}
.chip-link { border: 1px solid var(--line); background: #fff; }
.chip-link:hover { border-color: var(--brand-accent); text-decoration: none; }
.chip-current { background: var(--brand-navy); color: #fff; border-color: var(--brand-navy); }
.chip-admin { background: var(--brand-navy-2); color: #fff; }
.chip-cat { background: #fff; border: 1px solid var(--line); }
.chip-renewal { background: #fdf4e3; color: #8a6210; }
.chip-due { background: #eef2f7; color: var(--brand-slate); }
.chip-due.chip-overdue { background: #f3e9e8; color: var(--red); }
.chip-status.chip-lead { background: #e6eefc; color: var(--brand-blue); }
.chip-status.chip-in_progress { background: #d0f0fb; color: var(--brand-accent-deep); }
.chip-status.chip-won { background: #e9f9f0; color: var(--green); }
.chip-status.chip-lost { background: #f3e9e8; color: var(--red); }
.chip-pin { background: #fdf4e3; color: #8a6210; }

/* ---------- Dashboard ---------- */
.dash-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 1.1rem; align-items: start; }
.dash-main { grid-row: span 2; }
.note-feed { list-style: none; margin: 0; padding: 0; }
.note-feed-item { padding: .75rem 0; border-bottom: 1px solid var(--line); }
.note-feed-item:last-child { border-bottom: 0; }
.note-feed-top { display: flex; align-items: baseline; gap: .5rem; flex-wrap: wrap; }
.note-title { font-weight: 600; color: var(--brand-navy); }
.note-context { font-size: .84rem; color: var(--text-muted); }
.note-snippet, .note-body { margin: .25rem 0; font-size: .9rem; color: var(--text); white-space: pre-line; }
.note-meta { font-size: .8rem; color: var(--brand-slate-light); display: flex; gap: .6rem; align-items: baseline; }
.renewal-list, .pipe-summary, .deal-list { list-style: none; margin: 0; padding: 0; }
.renewal-item { display: flex; gap: .9rem; padding: .6rem 0; border-bottom: 1px solid var(--line); }
.renewal-item:last-child { border-bottom: 0; }
.renewal-when { min-width: 92px; display: flex; flex-direction: column; font-size: .85rem; }
.renewal-item.overdue .renewal-when strong, .renewal-item.overdue .renewal-when .muted { color: var(--red); }
.pipe-summary li a { display: flex; justify-content: space-between; gap: .5rem; padding: .5rem 0; border-bottom: 1px solid var(--line); color: var(--text); }
.pipe-summary li:last-child a { border-bottom: 0; }
.pipe-summary li a:hover { text-decoration: none; color: var(--brand-accent-deep); }
.pipe-figures { color: var(--text-muted); font-size: .88rem; white-space: nowrap; }
.dash-counts { display: flex; gap: 1.2rem; margin-top: .8rem; padding-top: .8rem; border-top: 1px solid var(--line); }
.dash-counts a { color: var(--text-muted); font-size: .9rem; }
.dash-counts strong { color: var(--brand-navy); font-size: 1.05rem; }

/* ---------- Detail pages ---------- */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem; align-items: start; }
.detail-list { margin: 0; }
.detail-list div { display: flex; padding: .4rem 0; border-bottom: 1px solid var(--line); }
.detail-list div:last-child { border-bottom: 0; }
.detail-list dt { width: 90px; flex-shrink: 0; font-size: .84rem; font-weight: 600; color: var(--brand-slate); }
.detail-list dd { margin: 0; }
.deal-list-item { display: flex; justify-content: space-between; align-items: center; gap: .6rem; padding: .55rem 0; border-bottom: 1px solid var(--line); }
.deal-list-item:last-child { border-bottom: 0; }
.deal-list-name { font-weight: 600; }
.note-form { margin-bottom: 1rem; padding-bottom: 1rem; border-bottom: 2px solid var(--line); }
.note-form input { margin-bottom: .5rem; }
.note-form textarea { resize: vertical; }
.note-form-actions { display: flex; justify-content: space-between; align-items: center; gap: .8rem; margin-top: .5rem; flex-wrap: wrap; }

/* ---------- Quick-note inline new contact ---------- */
.qn-newcontact {
  border: 1px dashed var(--brand-accent);
  background: var(--bg-alt);
  border-radius: 8px;
  padding: .7rem .8rem;
  margin-bottom: .7rem;
}
.qn-newcontact-head { margin-bottom: .5rem; }
.qn-newcontact-more { margin-top: .5rem; }
.qn-newcontact-more summary { cursor: pointer; }
.qn-newcontact-more .quicknote-selects { margin-top: .5rem; }

.chip-leadflag {
  background: rgba(0, 173, 239, 0.14);
  color: var(--brand-accent-deep);
  font-weight: 600;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .05em;
}

/* ---------- Leads ---------- */
.lead-tabs { margin-bottom: 1rem; }
.lead-card { padding: .9rem 1.1rem; }
.lead-overdue { border-left: 3px solid var(--red); }
.lead-head { display: flex; align-items: flex-start; justify-content: space-between; gap: .8rem; flex-wrap: wrap; }
.lead-name { font-weight: 700; font-size: 1.02rem; color: var(--brand-navy); }
.lead-chips { display: flex; gap: .35rem; flex-wrap: wrap; }
.lead-body {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1rem;
  margin: .7rem 0 .6rem;
  padding-top: .6rem;
  border-top: 1px solid var(--line);
}
.lead-col { min-width: 0; }
.lead-label {
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--brand-slate-light);
  margin-bottom: .25rem;
}
.lead-note-title { font-weight: 600; font-size: .93rem; }
.lead-task-title { font-weight: 600; font-size: .93rem; color: var(--brand-navy); }
.lead-actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.lead-snooze { display: flex; align-items: center; gap: .35rem; }
.lead-snooze input[type="date"] {
  padding: .3rem .45rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: .85rem;
  font-family: var(--font-body);
  width: auto;
}

/* Density toggle (Detailed / Compact) */
.density-toggle { display: inline-flex; }
.density-toggle .btn { border-radius: 0; }
.density-toggle .btn:first-child { border-radius: 7px 0 0 7px; }
.density-toggle .btn:last-child { border-radius: 0 7px 7px 0; margin-left: -1px; }
.density-toggle .btn.is-active {
  background: var(--brand-navy);
  border-color: var(--brand-navy);
  color: #fff;
}

/* Compact leads: one scannable line each. Everything is still on the card —
   the detail lines are just collapsed, and the full text stays one click away
   on the contact. */
.leads-compact .lead-card {
  display: flex;
  align-items: center;
  gap: .9rem;
  padding: .45rem .75rem;
  margin-bottom: .4rem;
}
.leads-compact .lead-head { flex: 0 0 26%; min-width: 0; display: block; }
.leads-compact .lead-who { min-width: 0; }
.leads-compact .lead-name { font-size: .95rem; }
.leads-compact .lead-head .muted.small,
.leads-compact .lead-note-title,
.leads-compact .lead-task-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}
.leads-compact .lead-chips { margin-top: .1rem; }
.leads-compact .lead-body {
  flex: 1;
  display: flex;
  gap: 1.2rem;
  align-items: center;
  margin: 0;
  padding: 0;
  border-top: 0;
  min-width: 0;
}
.leads-compact .lead-col { flex: 1; min-width: 0; }
.leads-compact .lead-label { display: none; }
.leads-compact .note-snippet { display: none; }
.leads-compact .lead-body .empty { margin: 0; font-size: .82rem; }
.leads-compact .lead-actions { flex: 0 0 auto; gap: .35rem; }
.leads-compact .lead-snooze { display: none; }   /* snooze lives in Detailed */
.leads-compact .lead-actions .btn { padding: .25rem .55rem; font-size: .8rem; }

/* ---------- Daily briefing ---------- */
.brief-subhead {
  font-family: var(--font-body);
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--brand-slate);
  margin: 1.1rem 0 .5rem;
  padding-bottom: .3rem;
  border-bottom: 1px solid var(--line);
}
.brief-subhead:first-of-type { margin-top: 0; }
.brief-overdue-head { color: var(--red); border-bottom-color: #f3c5c0; }
.brief-list { list-style: none; margin: 0; padding: 0; }
.brief-item {
  display: flex;
  align-items: flex-start;
  gap: .5rem;
  padding: .5rem 0;
  border-bottom: 1px solid var(--line);
}
.brief-item:last-child { border-bottom: 0; }
.brief-body { min-width: 0; }
.brief-title { font-weight: 600; color: var(--brand-navy); font-size: .92rem; }
.brief-check { color: var(--green); font-weight: 700; flex-shrink: 0; }
.brief-overdue { color: var(--red); font-weight: 600; }

/* ---------- Quick note widget ---------- */
.quicknote-selects, .quicknote-next {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: .7rem;
}
.quicknote-next { align-items: end; }
.quicknote-form > .field { margin-bottom: .7rem; }
.quicknote-selects .field, .quicknote-next .field { margin-bottom: 0; }

/* ---------- Additional-contacts picker (new deal form) ---------- */
.subcontact-chips { list-style: none; margin: 0 0 .5rem; padding: 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.subcontact-chips:empty { margin: 0; }
.subcontact-chip {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  background: var(--bg-alt);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .25rem .3rem .25rem .7rem;
  font-size: .86rem;
  color: var(--brand-navy);
}
.subcontact-remove {
  background: none;
  border: 0;
  color: var(--brand-slate);
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 .3rem;
}
.subcontact-remove:hover { color: var(--red); }
.subcontact-add { display: flex; gap: .5rem; align-items: center; }
.subcontact-add input { flex: 1; min-width: 0; }
.subcontact-add .btn { flex-shrink: 0; }
.picker-create-hint { margin: .45rem 0 0; }

/* ---------- Deal contacts ---------- */
.deal-contact-list { list-style: none; margin: 0 0 .8rem; padding: 0; }
.deal-contact-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .6rem;
  padding: .5rem 0;
  border-bottom: 1px solid var(--line);
}
.deal-contact-item:last-child { border-bottom: 0; }
.deal-contact-name { min-width: 0; }
.chip-primary { background: rgba(0, 173, 239, 0.14); color: var(--brand-accent-deep); font-weight: 600; }
.deal-add-contact { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.deal-add-contact .bulk-input { flex: 1; min-width: 180px; }

/* ---------- Note attachments ---------- */
.note-file-field { display: block; margin-bottom: .5rem; }
.note-file-field > span { display: block; margin-bottom: .2rem; }
.note-file-input {
  display: block;
  width: 100%;
  font-size: .88rem;
  font-family: var(--font-body);
  color: var(--text-muted);
  padding: .3rem 0;
  margin-bottom: 0;
  border: 0;
  background: none;
}
.note-file-input::file-selector-button {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: .85rem;
  color: var(--brand-navy);
  background: var(--bg-alt);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: .35rem .7rem;
  margin-right: .6rem;
  cursor: pointer;
}
.note-file-input::file-selector-button:hover { background: #dcecfb; }
.attach-list { list-style: none; margin: .4rem 0 .1rem; padding: 0; display: flex; flex-direction: column; gap: .3rem; }
.attach-item { display: flex; align-items: center; gap: .5rem; font-size: .86rem; }
.attach-link { display: inline-flex; align-items: center; gap: .35rem; min-width: 0; }
.attach-icon { flex-shrink: 0; }
.attach-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-size { color: var(--brand-slate-light); font-size: .78rem; flex-shrink: 0; }
.attach-remove {
  background: none;
  border: 0;
  color: var(--brand-slate-light);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 .2rem;
  flex-shrink: 0;
}
.attach-remove:hover { color: var(--red); }
.note-attach-count { color: var(--brand-slate); font-weight: 600; white-space: nowrap; }

/* ---------- Tasks ---------- */
.task-form { margin-bottom: 1rem; padding-bottom: 1rem; border-bottom: 2px solid var(--line); }
.task-form > input[name="title"] { margin-bottom: .6rem; }
.task-form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .7rem; align-items: end; }
.task-form-grid .field { margin-bottom: 0; }
.task-form-actions { margin-top: .7rem; }
.filter-check { display: inline-flex; align-items: center; gap: .4rem; font-size: .9rem; color: var(--brand-slate); }
.filter-check input { width: auto; }

.task-list { list-style: none; margin: 0; padding: 0; }
.task-item { display: flex; align-items: flex-start; gap: .6rem; padding: .6rem 0; border-bottom: 1px solid var(--line); }
.task-item:last-child { border-bottom: 0; }
.task-check-form { margin: 0; }
.task-check {
  background: none;
  border: 0;
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
  color: var(--brand-slate);
  padding: .1rem .35rem;
  margin-left: -.35rem;
  border-radius: 6px;
}
.task-check:hover { color: var(--brand-accent-deep); }
.task-main { flex: 1; min-width: 0; }
.task-title { font-weight: 600; color: var(--brand-navy); }
.task-item.done .task-title { text-decoration: line-through; color: var(--text-muted); font-weight: 500; }
.task-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-top: .2rem; font-size: .82rem; color: var(--text-muted); }
.task-context a { color: var(--brand-slate); }
.task-assignee { color: var(--brand-slate-light); }
.task-delete { flex-shrink: 0; }
.task-edit { margin-top: .4rem; }
.task-edit summary { cursor: pointer; font-size: .8rem; color: var(--brand-slate-light); width: max-content; }
.task-edit summary:hover { color: var(--brand-accent-deep); }
.task-edit-form { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .5rem; align-items: center; }
.task-edit-form input[name="title"] { flex: 1 1 220px; }
.task-edit-form input[type="date"], .task-edit-form select { width: auto; }

/* ---------- Kanban boards ---------- */
.board-toolbar { display: flex; flex-direction: column; gap: .6rem; margin-bottom: 1rem; }
.board-switcher { display: flex; gap: .4rem; flex-wrap: wrap; }
.board {
  display: flex;
  gap: .9rem;
  overflow-x: auto;
  padding-bottom: 1rem;
  align-items: flex-start;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
}
.board-col {
  flex: 0 0 290px;
  max-width: 290px;
  scroll-snap-align: start;
  background: var(--bg-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 240px);
  min-height: 180px;
}
.board-col-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .6rem .8rem;
  font-weight: 700;
  font-size: .88rem;
  color: var(--brand-navy);
  border-bottom: 2px solid var(--line);
  border-top: 3px solid var(--brand-slate-light);
  border-radius: var(--radius) var(--radius) 0 0;
  background: #fff;
}
.board-col-head.col-lead { border-top-color: var(--brand-blue); }
.board-col-head.col-in_progress { border-top-color: var(--brand-accent); }
.board-col-head.col-won { border-top-color: var(--green-bright); }
.board-col-head.col-lost { border-top-color: var(--red); }
.board-col-head .count { background: var(--bg); border-radius: 999px; font-size: .76rem; padding: .05rem .5rem; color: var(--text-muted); }
.board-col-body { padding: .6rem; overflow-y: auto; flex: 1; min-height: 60px; }
.kcard {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: .6rem .7rem;
  margin-bottom: .6rem;
  cursor: grab;
}
.kcard:active { cursor: grabbing; }
/* Lead cards on the Overview board — same shape as a client card, dialled back
   so signed work still reads first. Must follow .kcard to win on order. */
.kcard-lead { background: var(--bg-alt); border-style: dashed; }
.kcard-ghost { opacity: .4; border: 2px dashed var(--brand-accent); }
.kcard-top { display: flex; justify-content: space-between; align-items: flex-start; gap: .4rem; }
.kcard-title { font-weight: 600; color: var(--brand-navy); font-size: .95rem; }
.kcard-sub { font-size: .82rem; color: var(--text-muted); margin-top: .1rem; }
.kcard-detail { font-size: .78rem; color: var(--brand-slate); font-style: italic; margin-top: .15rem; }
.kcard-foot { display: flex; align-items: center; gap: .5rem; margin-top: .45rem; flex-wrap: wrap; }
.kcard-value { font-weight: 700; font-size: .88rem; color: var(--brand-navy-2); }
.kcard-services { list-style: none; margin: .45rem 0 0; padding: 0; }
.kcard-service {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .4rem;
  padding: .25rem 0;
  font-size: .82rem;
  color: var(--text);
  border-top: 1px dashed var(--line);
}
.kcard-service:hover { text-decoration: none; color: var(--brand-accent-deep); }
.svc-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pin-badge { font-size: .85rem; flex-shrink: 0; }
.reset-pin {
  margin-top: .5rem;
  width: 100%;
  background: none;
  border: 1px dashed var(--brand-slate-light);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: .76rem;
  padding: .25rem;
  cursor: pointer;
  font-family: var(--font-body);
}
.reset-pin:hover { border-color: var(--brand-accent); color: var(--brand-accent-deep); }

/* ---------- Stage management ---------- */
.stage-list { list-style: none; margin: 0; padding: 0; }
.stage-item { display: flex; align-items: center; gap: .6rem; padding: .5rem 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.stage-item:last-child { border-bottom: 0; }
.drag-handle { cursor: grab; color: var(--brand-slate-light); font-size: 1.1rem; user-select: none; }
.stage-edit-form { display: flex; gap: .5rem; flex: 1; min-width: 260px; }
.pipeline-icon-input { flex: 0 0 64px !important; width: 64px; text-align: center; }
.stage-edit-form input { flex: 1; }
.stage-edit-form select { width: auto; }
.stage-deal-count { min-width: 60px; text-align: right; }
.stage-add-form { display: flex; gap: .5rem; flex-wrap: wrap; }
.stage-add-form input { flex: 1; min-width: 200px; }
.stage-add-form select { width: auto; }

/* ---------- Admin ---------- */
.user-row { border-bottom: 1px solid var(--line); padding: .45rem 0; }
.user-row:last-child { border-bottom: 0; }
.user-row summary { cursor: pointer; display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.user-edit-form { padding: .8rem 0 .3rem; }

/* ---------- Bulk contact actions ---------- */
.bulk-bar {
  display: flex;
  align-items: center;
  gap: .8rem;
  flex-wrap: wrap;
  margin-bottom: .7rem;
  min-height: 34px;
}
.bulk-all-label { display: inline-flex; align-items: center; gap: .4rem; font-size: .9rem; color: var(--brand-slate); cursor: pointer; }
.bulk-count { font-weight: 600; color: var(--brand-navy); font-size: .9rem; }
.bulk-actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.bulk-input {
  padding: .38rem .55rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: .9rem;
  font-family: var(--font-body);
  color: var(--text);
  background: #fff;
  width: 130px;
}
.td-subline { display: block; line-height: 1.3; }
.checkbox-cell { width: 36px; text-align: center; padding-right: 0; }
.bulk-bar input[type="checkbox"], .checkbox-cell input[type="checkbox"] { width: 17px; height: 17px; cursor: pointer; }

/* ---------- Mobile ---------- */
@media (max-width: 800px) {
  .nav-toggle { display: block; }

  /* Slide-in drawer from the right edge. Fixed positioning takes the menu out
     of the header's flex row, so it no longer squishes beside the logo. */
  .nav-links {
    display: flex;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(84vw, 320px);
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 0 0 1.2rem;
    background: linear-gradient(160deg, var(--brand-navy-3) 0%, var(--brand-navy) 60%, #061840 100%);
    box-shadow: -8px 0 24px rgba(4, 16, 43, 0.45);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    z-index: 70;
    transform: translateX(100%);
    visibility: hidden;
    transition: transform .25s ease, visibility 0s linear .25s;
  }
  .nav-links.open {
    transform: none;
    visibility: visible;
    transition: transform .25s ease;
  }

  /* Dimmed backdrop behind the drawer; tapping it closes the menu. */
  .nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(4, 16, 43, 0.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease;
    z-index: 65;
  }
  .nav-backdrop.open { opacity: 1; pointer-events: auto; }

  /* Drawer header with title + close (×) button. */
  .nav-drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .85rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    margin-bottom: .3rem;
  }
  .nav-drawer-title {
    color: rgba(255, 255, 255, 0.5);
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
  }
  .nav-close {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    margin-right: -.4rem;
    background: none;
    border: 0;
    border-radius: 8px;
    color: #fff;
    font-size: 1.7rem;
    line-height: 1;
    cursor: pointer;
  }
  .nav-close:hover { background: rgba(255, 255, 255, 0.1); }

  /* Lock background scrolling while the drawer is open. */
  body.nav-open { overflow: hidden; }
  /* Big, comfortable tap targets for every top-level item. */
  .nav-links > a {
    padding: .8rem 1rem;
    font-size: 1rem;
    border-radius: 0;
    display: flex;
    align-items: center;
    min-height: 48px;
  }
  .nav-links > a.active { background: rgba(0, 173, 239, 0.18); }

  /* On mobile the Pipeline links are always shown under a section label —
     no nested tap needed. Hide the desktop dropdown toggle. */
  .nav-dropdown-btn { display: none; }
  .nav-section-label {
    display: block;
    padding: .9rem 1rem .3rem;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.45);
  }
  .nav-dropdown-menu {
    display: block !important;
    position: static;
    box-shadow: none;
    border: 0;
    background: none;
    min-width: 0;
    padding: 0;
  }
  .nav-dropdown-menu a {
    color: rgba(255, 255, 255, 0.82);
    padding: .7rem 1rem .7rem 1.6rem;
    font-size: .98rem;
    min-height: 46px;
    display: flex;
    align-items: center;
    border-radius: 0;
  }
  .nav-dropdown-menu a:hover { background: rgba(255, 255, 255, 0.08); }
  .nav-dropdown-menu hr { display: none; }
  .nav-user {
    margin-left: 0;
    justify-content: space-between;
    padding: .8rem 1rem 0;
    margin-top: .4rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
  }
  .nav-user .btn { min-height: 40px; }

  /* Single-column stacking for grids and multi-field rows. */
  .dash-grid, .detail-grid, .field-row, .field-row.three { grid-template-columns: 1fr; }
  .dash-main { grid-row: auto; }

  /* Larger inputs; 16px font stops iOS Safari from zooming on focus. */
  .field input, .field select, .field textarea, .note-form input, .note-form textarea,
  .filter-bar input, .filter-bar select, .stage-edit-form input, .stage-edit-form select,
  .stage-add-form input, .stage-add-form select,
  .task-form input, .task-form select, .task-edit-form input, .task-edit-form select {
    font-size: 16px;
    padding: .65rem .7rem;
  }

  /* Buttons are easy to hit and page actions go full-width. */
  .btn { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
  .btn-sm { min-height: 38px; }
  /* Comfortable tap target for the task complete/reopen toggle. */
  .task-check { min-width: 44px; min-height: 44px; font-size: 1.4rem; }
  .task-form-grid { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; align-items: stretch; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; }

  /* Filter bar: each control on its own full-width row. */
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar input, .filter-bar select, .filter-bar .btn { width: 100%; }
  .filter-search { min-width: 0; }

  /* Contact table reflows into stacked cards, one field per line. */
  .table-card { overflow-x: visible; padding: 0; background: none; box-shadow: none; border: 0; }
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
  .data-table thead { position: absolute; left: -9999px; }
  .data-table tr {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: .7rem;
    padding: .3rem .2rem;
  }
  .data-table td {
    border: 0;
    padding: .4rem .8rem;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    text-align: right;
  }
  .data-table td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: .78rem;
    color: var(--brand-slate);
    text-align: left;
    flex-shrink: 0;
  }
  .data-table td.td-primary {
    justify-content: flex-start;
    text-align: left;
    padding-top: .6rem;
    padding-bottom: .5rem;
    border-bottom: 1px solid var(--line);
    margin-bottom: .2rem;
  }
  .data-table td.td-primary::before { display: none; }
  .data-table td.td-primary a { font-weight: 600; font-size: 1.02rem; }
  .data-table td.num { text-align: right; }
  /* Checkbox sits at the top-left of each card, no data-label prefix. */
  .data-table td.checkbox-cell { justify-content: flex-start; padding: .5rem .8rem 0; }
  .data-table td.checkbox-cell::before { display: none; }
  .data-table td.checkbox-cell input[type="checkbox"] { width: 22px; height: 22px; }
  /* Bulk action controls stack full-width and stay easy to tap. */
  .bulk-actions { width: 100%; flex-direction: column; align-items: stretch; }
  .bulk-actions .bulk-input, .bulk-actions .btn { width: 100%; }
  .bulk-input { font-size: 16px; }

  /* Stage management forms stack cleanly. */
  .stage-item { gap: .4rem; }
  .stage-edit-form { flex-direction: column; min-width: 0; width: 100%; }
  .stage-edit-form select, .stage-edit-form .btn { width: 100%; }
  .stage-add-form { flex-direction: column; }
  .stage-add-form input, .stage-add-form select, .stage-add-form .btn { width: 100%; min-width: 0; }
  .stage-deal-count { min-width: 0; text-align: left; }

  /* Leads: stack the two columns and let actions wrap full-width. */
  .lead-body { grid-template-columns: 1fr; gap: .6rem; }
  .lead-snooze { width: 100%; }
  .lead-snooze input[type="date"] { flex: 1; font-size: 16px; }

  /* Compact on a phone: keep the stacked layout (a single row can't fit),
     just tighten it and drop the secondary detail. */
  .leads-compact .lead-card { display: block; padding: .55rem .75rem; }
  .leads-compact .lead-head { flex: none; }
  .leads-compact .lead-body { display: block; }
  .leads-compact .lead-col + .lead-col { margin-top: .25rem; }
  .leads-compact .lead-actions { margin-top: .4rem; }

  /* Kanban: wide swipeable columns; taller card bodies use the screen. */
  .hide-mobile { display: none; }
  .board-col { flex: 0 0 84vw; max-width: 84vw; max-height: none; }
  .board-col-body { max-height: 60vh; }
  .board { scroll-snap-type: x mandatory; }
  .board-switcher { overflow-x: auto; flex-wrap: nowrap; padding-bottom: .3rem; -webkit-overflow-scrolling: touch; }
  .board-switcher .chip { flex-shrink: 0; }

  .note-form-actions { flex-direction: column; align-items: stretch; }
  .note-form-actions .btn { width: 100%; }
  .container { padding: 1rem .8rem 2.5rem; }
  .page-title { font-size: 1.4rem; }
}
