/* QwikFlo CRM — "Plan" reference theme.
   Monochrome, airy, large-radius. Near-black type on white inside a floating
   rounded shell over a grey page. Colour is functional, not decorative:
   orange = brand/primary action, blue = email, green = call/success,
   yellow = pending, black = strong inline action.
   Previous themes kept at style.hubspot-theme.css.bak / style.qwikflo-theme.css.bak */

:root {
  /* Surfaces */
  --page:        #ECECEC;   /* backdrop the app floats on */
  --surface:     #FFFFFF;
  --surface-2:   #F7F7F8;   /* icon tiles, subtle fills */
  --surface-3:   #F1F1F2;   /* segmented control track, inactive */
  --surface-4:   #E9E9EB;   /* hover on grey */

  /* Type */
  --text:        #14161A;
  --text-2:      #5B616B;
  --text-muted:  #9096A1;

  /* Lines */
  --border:      #EAEAEC;
  --border-2:    #DEDEE1;

  /* Functional colour */
  --brand:       #E75718;   /* QwikFlo flame — primary actions */
  --brand-hover: #CC4A11;
  --brand-soft:  #FFF0E9;
  --blue:        #2F6BFF;
  --blue-soft:   #EAF0FF;
  --green:       #17B26A;
  --green-soft:  #E7F8EF;
  --yellow:      #FCE34A;
  --yellow-soft: #FFF9D6;
  --red:         #E5484D;
  --red-soft:    #FDEBEC;
  --ink:         #14161A;   /* black circular actions */

  /* Shape */
  --r-shell:  22px;
  --r-card:   14px;
  --r-btn:    10px;
  --r-tile:   10px;

  --shadow-shell: 0 1px 2px rgba(20,22,26,.04), 0 12px 40px rgba(20,22,26,.07);
  --shadow-pop:   0 8px 28px rgba(20,22,26,.14);
  --ring:         0 0 0 3px rgba(231,87,24,.16);

  --font: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--page);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.015em; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* ---------- Floating app shell ---------- */
.app-shell {
  max-width: 1680px;
  margin: 18px auto;
  min-height: calc(100vh - 36px);
  background: var(--surface);
  border-radius: var(--r-shell);
  box-shadow: var(--shadow-shell);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ---------- Top bar ---------- */
.topnav {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 24px;
  background: var(--surface);
  flex-shrink: 0;
}
.hamburger { display: none; background: none; border: none; font-size: 20px; color: var(--text); cursor: pointer; padding: 4px 6px; }
.logo { display: inline-flex; align-items: center; gap: 9px; font-weight: 800; font-size: 17px; letter-spacing: -.02em; white-space: nowrap; }
.logo-mark {
  width: 28px; height: 28px;
  background: var(--brand); color: #fff;
  border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 800;
}
.logo-suffix { color: var(--text-muted); font-weight: 600; }

/* Command-palette style search */
#global-search {
  flex: 1;
  max-width: 460px;
  padding: 11px 16px 11px 40px;
  border: 1px solid var(--border);
  border-radius: var(--r-btn);
  background: var(--surface-2) url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239096A1' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E") no-repeat 14px center;
  color: var(--text);
  font-size: 13.5px;
}
#global-search::placeholder { color: var(--text-muted); }
#global-search:focus { outline: none; background-color: #fff; border-color: var(--border-2); box-shadow: var(--ring); }

.top-links { display: flex; align-items: center; gap: 4px; }
.top-links a {
  padding: 8px 14px;
  border-radius: var(--r-btn);
  font-size: 13.5px; font-weight: 600;
  color: var(--text-2);
}
.top-links a:hover { background: var(--surface-2); color: var(--text); }
.top-links a.active { background: var(--surface-3); color: var(--text); font-weight: 700; }

.user-chip {
  margin-left: auto;
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--ink); color: #fff;
  border-radius: 50%;
  font-size: 12px; font-weight: 700; letter-spacing: .02em;
  text-transform: uppercase;
}

/* ---------- Layout ---------- */
.layout { display: flex; flex: 1; min-height: 0; border-top: 1px solid var(--border); }
.sidebar {
  width: 236px; flex-shrink: 0;
  padding: 18px 14px;
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.sidebar-nav { display: none; flex-direction: column; gap: 2px; margin-bottom: 20px; }
.sidebar-nav a { padding: 9px 12px; border-radius: var(--r-btn); font-size: 14px; font-weight: 600; color: var(--text-2); }
.sidebar-nav a:hover { background: var(--surface-2); }
.sidebar-nav a.active { background: var(--surface-3); color: var(--text); font-weight: 700; }

.sidebar-section { margin-bottom: 24px; }
.sidebar-section h4 {
  margin: 0 0 10px; padding: 0 10px;
  font-size: 10.5px; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-muted);
}
.stage-counts { display: flex; flex-direction: column; gap: 1px; }
.stage-counts button {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  width: 100%; padding: 8px 12px;
  background: none; border: none; border-radius: var(--r-btn);
  font: inherit; font-size: 13.5px; font-weight: 600; color: var(--text-2);
  cursor: pointer; text-align: left;
}
.stage-counts button:hover { background: var(--surface-2); color: var(--text); }
.stage-counts button.active { background: var(--surface-3); color: var(--text); font-weight: 700; }
.stage-counts .count {
  background: var(--surface-3); color: var(--text-2);
  border-radius: 8px; padding: 1px 8px;
  font-size: 11.5px; font-weight: 700;
}
.stage-counts button.active .count { background: var(--ink); color: #fff; }

.filter-buttons { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 8px; }
.filter-buttons button {
  padding: 6px 13px;
  border: 1px solid var(--border-2); border-radius: 999px;
  background: var(--surface);
  font: inherit; font-size: 12.5px; font-weight: 600; color: var(--text-2);
  cursor: pointer;
}
.filter-buttons button:hover { border-color: var(--text-muted); color: var(--text); }
.filter-buttons button.active { background: var(--ink); border-color: var(--ink); color: #fff; }

.sidebar-dates { display: flex; flex-direction: column; gap: 8px; padding: 0 8px; }
.sidebar-dates input[type="date"], .date-range-inline input[type="date"] {
  padding: 9px 11px;
  border: 1px solid var(--border-2); border-radius: var(--r-btn);
  background: var(--surface); color: var(--text);
  font: inherit; font-size: 13px; color-scheme: light;
}
.sidebar-dates input:focus, .date-range-inline input:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
.date-range-inline { display: flex; align-items: center; gap: 8px; }

.content { flex: 1; padding: 26px 30px; min-width: 0; overflow-x: hidden; }

/* ---------- Page header ---------- */
.page-header { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; flex-wrap: wrap; }
.page-header h1 { font-size: 28px; font-weight: 800; letter-spacing: -.03em; }
.page-header .spacer, .spacer { flex: 1; }
.obj-count { font-size: 13px; color: var(--text-muted); font-weight: 500; margin-top: 2px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 17px;
  border: 1px solid var(--border-2); border-radius: var(--r-btn);
  background: var(--surface); color: var(--text);
  font-family: inherit; font-size: 13.5px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
  transition: background .13s ease, border-color .13s ease, opacity .13s ease;
}
.btn:hover { background: var(--surface-2); border-color: var(--text-muted); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.dark:hover { background: #000; }
.btn.danger { background: var(--surface); border-color: var(--border-2); color: var(--red); }
.btn.danger:hover { background: var(--red-soft); border-color: var(--red); }
.btn.warm { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.small { padding: 6px 12px; font-size: 12.5px; border-radius: 8px; }
.spinner {
  display: inline-block; width: 13px; height: 13px;
  border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Circular icon actions (accept / reject pattern from the reference) */
.icon-btn {
  width: 32px; height: 32px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; border: 1px solid var(--border-2);
  background: var(--surface); color: var(--text-2);
  font-size: 14px; cursor: pointer; padding: 0;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.solid { background: var(--ink); border-color: var(--ink); color: #fff; }
.icon-btn.solid:hover { background: #000; }
.icon-btn.danger:hover { background: var(--red-soft); border-color: var(--red); color: var(--red); }

/* ---------- Cards & tables ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  overflow: hidden;
}
.leads-table-wrap { overflow-x: auto; }
table.leads-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.leads-table th, .leads-table td { padding: 14px 18px; text-align: left; vertical-align: middle; }
.leads-table th {
  font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--text-muted); background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap; cursor: pointer; user-select: none;
}
.leads-table th .arrow { color: var(--brand); font-size: 9px; margin-left: 4px; }
.leads-table tbody tr { border-bottom: 1px solid var(--border); cursor: pointer; }
.leads-table tbody tr:last-child { border-bottom: none; }
.leads-table tbody tr:hover { background: var(--surface-2); }
.record-link { color: var(--text); font-weight: 700; }
.record-link:hover { color: var(--brand); }

.lead-cards { display: none; flex-direction: column; gap: 10px; }
.lead-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-card); padding: 16px; cursor: pointer;
}
.lead-card h3 { font-size: 15px; margin-bottom: 8px; }
.lead-card .meta { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; color: var(--text-muted); }

/* ---------- Chips / badges ---------- */
.badge {
  display: inline-block; padding: 4px 10px;
  border-radius: 7px;
  font-size: 11.5px; font-weight: 700; line-height: 1.45; white-space: nowrap;
}
.badge.stage { background: var(--surface-3); color: var(--text-2); }
.badge.stage-won { background: var(--green-soft); color: #0F8A50; }
.badge.stage-lost { background: var(--red-soft); color: #C13034; }
.badge.risk-low { background: var(--green-soft); color: #0F8A50; }
.badge.risk-medium { background: var(--yellow-soft); color: #8A6D00; }
.badge.risk-high { background: var(--red-soft); color: #C13034; }
.badge.warm { background: var(--brand-soft); color: var(--brand-hover); }
.badge.overdue { background: var(--red); color: #fff; }
.badge.new { background: var(--yellow); color: #4A4200; }
.badge.progress { background: var(--green-soft); color: #0F8A50; }

/* ---------- Pagination ---------- */
.pagination { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 20px; }
.pagination .info { font-size: 13px; color: var(--text-muted); font-weight: 500; }

/* ---------- Documents ---------- */
.doc-counts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 18px; }
.doc-count {
  background: var(--surface-2); border-radius: 12px; padding: 14px 16px;
}
.doc-count .dc-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 8px;
}
.doc-count .dc-value { font-size: 26px; font-weight: 800; letter-spacing: -.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.doc-count.owed .dc-value { color: var(--brand); }
.doc-count.pending .dc-value { color: var(--warn, #A66A12); }
.doc-count.accepted .dc-value { color: var(--green); }
.doc-status {
  font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  padding: 3px 9px; border-radius: 6px; white-space: nowrap;
}
.doc-status.owed { background: var(--brand-soft); color: var(--brand-hover); }
.doc-status.pending_review { background: var(--yellow-soft); color: #8A6D00; }
.doc-status.accepted { background: var(--green-soft); color: #0F8A50; }
.doc-status.rejected { background: var(--red-soft); color: #C13034; }
.doc-actions { display: flex; gap: 6px; }
.call-extras { display: flex; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.call-extras select, .call-extras input {
  padding: 8px 11px; border: 1px solid var(--border-2); border-radius: var(--r-btn);
  background: var(--surface); color: var(--text); font: inherit; font-size: 13px;
}

/* ---------- Dashboard ---------- */
/* Categorical series colours validated for CVD separation against the light
   surface (see dataviz validator). Assigned in fixed order, never cycled. */
:root {
  --series-1: #17B26A;  /* calls */
  --series-2: #2F6BFF;  /* emails */
  --series-3: #D4501A;  /* meetings */
  --series-4: #7B4FBF;  /* notes */
  --grid: #EFEFF1;
}
.dash-filters { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }
.dash-grid .full { grid-column: 1 / -1; }
.panel-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-card); padding: 20px;
}
.panel-card h3 {
  margin: 0 0 4px; font-size: 15px; font-weight: 700; letter-spacing: -.015em;
}
.panel-note { font-size: 12.5px; color: var(--text-muted); margin: 0 0 18px; }

/* Hero stat tiles */
.hero-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.hero {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-card); padding: 18px 20px;
}
.hero .h-label {
  font-size: 11px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--text-muted); margin-bottom: 8px;
}
.hero .h-value { font-size: 30px; font-weight: 800; letter-spacing: -.035em; line-height: 1; font-variant-numeric: tabular-nums; }
.hero .h-sub { font-size: 12.5px; color: var(--text-muted); margin-top: 7px; }
.hero.accent .h-value { color: var(--brand); }
.hero.good .h-value { color: var(--green); }

/* Horizontal magnitude bars */
.hbar-row { display: grid; grid-template-columns: 132px 1fr auto; align-items: center; gap: 12px; margin-bottom: 10px; }
.hbar-label { font-size: 12.5px; color: var(--text-2); font-weight: 600; text-align: right; }
.hbar-track { background: var(--surface-2); border-radius: 4px; height: 22px; position: relative; }
.hbar-fill { height: 100%; border-radius: 0 4px 4px 0; background: var(--brand); min-width: 3px; }
.hbar-fill.neutral { background: var(--ink); }
.hbar-fill.muted { background: #A9B0BE; }
.hbar-value { font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 60px; text-align: right; }
.hbar-row:hover .hbar-track { outline: 2px solid var(--border-2); outline-offset: 1px; }

/* Funnel */
.funnel-step { display: grid; grid-template-columns: 132px 1fr auto; align-items: center; gap: 12px; }
.funnel-gap {
  grid-column: 2 / 3; font-size: 11.5px; color: var(--text-muted);
  padding: 3px 0 3px 2px; font-variant-numeric: tabular-nums;
}
.funnel-gap b { color: var(--text-2); }
.funnel-gap.drop b { color: var(--red); }

/* Weekly activity chart */
.chart-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-2); font-weight: 600; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.chart-wrap { overflow-x: auto; position: relative; }
.chart-tooltip {
  position: absolute; pointer-events: none; z-index: 5;
  background: var(--ink); color: #fff; border-radius: 8px;
  padding: 9px 12px; font-size: 12px; line-height: 1.6;
  box-shadow: var(--shadow-pop); white-space: nowrap; opacity: 0;
  transition: opacity .1s;
}
.chart-tooltip.show { opacity: 1; }
.chart-tooltip .tt-title { font-weight: 700; margin-bottom: 3px; }
.chart-tooltip .tt-row { display: flex; align-items: center; gap: 7px; }
.chart-tooltip .tt-row i { width: 8px; height: 8px; border-radius: 2px; }
.chart-tooltip .tt-row b { margin-left: auto; font-variant-numeric: tabular-nums; }
.mini-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.mini-table th, .mini-table td { padding: 7px 10px; text-align: right; border-bottom: 1px solid var(--line, var(--border)); }
.mini-table th:first-child, .mini-table td:first-child { text-align: left; }
.mini-table th { font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--text-muted); font-weight: 700; }
.mini-table td { font-variant-numeric: tabular-nums; }
.dash-empty { font-size: 13px; color: var(--text-muted); padding: 18px 0; }

/* ---------- Attention ---------- */
.nav-badge {
  display: none; margin-left: 6px; padding: 1px 7px;
  border-radius: 9px; background: var(--red); color: #fff;
  font-size: 10.5px; font-weight: 700; vertical-align: 1px;
}
.nav-badge.show { display: inline-block; }
.att-group { margin-bottom: 26px; }
.att-head {
  display: flex; align-items: center; gap: 10px;
  font-size: 11px; font-weight: 700; letter-spacing: .09em;
  text-transform: uppercase; color: var(--text-muted); margin-bottom: 10px;
}
.att-row {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; margin-bottom: 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--border-2);
  border-radius: 12px; cursor: pointer;
}
.att-row:hover { border-color: var(--border-2); box-shadow: var(--shadow-pop); }
.att-row.high { border-left-color: var(--red); }
.att-row.medium { border-left-color: var(--yellow); }
.att-row.low { border-left-color: var(--border-2); }
.att-row .grow { flex: 1; min-width: 0; }
.att-title { font-size: 14px; font-weight: 700; letter-spacing: -.01em; }
.att-sub { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.att-deal { font-size: 12.5px; color: var(--text-2); font-weight: 600; }

/* ---------- Import ---------- */
.map-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
.map-row { display: flex; align-items: center; gap: 10px; }
.map-row label { flex: 0 0 130px; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.map-row select { flex: 1; }
.import-summary {
  background: var(--surface-2); border-radius: 12px; padding: 14px 16px;
  font-size: 13.5px; margin-top: 14px;
}
.import-summary b { font-variant-numeric: tabular-nums; }
.import-problem { color: var(--red); font-size: 12.5px; margin-top: 8px; }
.next-step-box {
  display: flex; align-items: center; gap: 10px;
  background: var(--brand-soft); border: 1px solid #FFD9C6;
  border-radius: 12px; padding: 12px 14px; margin-bottom: 18px;
}
.next-step-box .ns-label {
  font-size: 10.5px; font-weight: 700; letter-spacing: .09em;
  text-transform: uppercase; color: var(--brand-hover); flex-shrink: 0;
}
.next-step-box input {
  flex: 1; border: none; background: none; font: inherit;
  font-size: 14px; font-weight: 600; color: var(--text); padding: 0;
}
.next-step-box input:focus { outline: none; }
.next-step-box input::placeholder { color: var(--brand-hover); opacity: .6; font-weight: 500; }

/* ---------- Pipeline summary strip ---------- */
.pipeline-summary {
  display: flex; flex-wrap: wrap; gap: 10px;
  margin-bottom: 20px;
}
.ps-item {
  flex: 1 1 150px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-card); padding: 14px 16px;
}
.ps-label {
  display: block; font-size: 11px; font-weight: 600;
  letter-spacing: .07em; text-transform: uppercase; color: var(--text-muted);
  margin-bottom: 5px;
}
.ps-value {
  font-size: 22px; font-weight: 800; letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
}
.ps-value.ps-won { color: var(--green); }
.pipeline-toggle button { white-space: nowrap; }
.badge.value { background: var(--ink); color: #fff; font-variant-numeric: tabular-nums; }
.kanban-col-value {
  padding: 7px 16px;
  background: var(--surface); border: 1px solid var(--border); border-top: none;
  font-size: 12.5px; font-weight: 700; color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

/* ---------- Kanban board ---------- */
.kanban { display: flex; gap: 14px; align-items: flex-start; overflow-x: auto; padding-bottom: 14px; }
.kanban-col { min-width: 276px; width: 276px; flex-shrink: 0; }
.kanban-col-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 13px 16px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-card) var(--r-card) 0 0;
  font-size: 13px; font-weight: 700;
}
.kanban-col-head .count {
  background: var(--surface-3); color: var(--text-2);
  border-radius: 8px; padding: 1px 9px; font-size: 11.5px; font-weight: 700;
}
.kanban-col.won .kanban-col-head { color: #0F8A50; }
.kanban-col.won .kanban-col-head .count { background: var(--green-soft); color: #0F8A50; }
.kanban-col.lost .kanban-col-head { color: #C13034; }
.kanban-col.lost .kanban-col-head .count { background: var(--red-soft); color: #C13034; }
.kanban-col-body {
  display: flex; flex-direction: column; gap: 10px;
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border); border-top: none;
  border-radius: 0 0 var(--r-card) var(--r-card);
  min-height: 76px;
}
.kanban-col-body.drag-over { background: var(--brand-soft); border-color: var(--brand); }
.kanban-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px; cursor: pointer;
  transition: box-shadow .13s ease, border-color .13s ease;
}
.kanban-card:hover { border-color: var(--border-2); box-shadow: var(--shadow-pop); }
.kanban-card.dragging { opacity: .4; }
.kanban-card .kc-title { font-size: 14px; font-weight: 700; margin-bottom: 4px; letter-spacing: -.01em; }
.kanban-card .kc-meta { font-size: 12.5px; color: var(--text-muted); font-weight: 500; margin-bottom: 10px; }
.kanban-card .kc-badges { display: flex; flex-wrap: wrap; gap: 5px; }
.kanban-card .kc-followup {
  margin-top: 11px; padding-top: 11px; border-top: 1px solid var(--border);
  font-size: 11.5px; color: var(--text-muted); font-weight: 500;
}
.kanban-empty { font-size: 12.5px; color: var(--text-muted); text-align: center; padding: 18px 0; font-weight: 500; }

/* ---------- Record page ---------- */
.record-grid { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 22px; align-items: start; }

/* Left: contact card */
.record-about { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); overflow: hidden; }
.about-head { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 26px 20px 20px; }
.avatar {
  width: 76px; height: 76px; border-radius: 50%;
  background: var(--ink); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 30px; font-weight: 700; margin-bottom: 14px;
}
.about-head h1 { font-size: 21px; letter-spacing: -.025em; margin-bottom: 4px; }
.about-sub { font-size: 13px; color: var(--text-muted); font-weight: 500; margin-bottom: 12px; }
.about-badges { display: flex; flex-wrap: wrap; gap: 5px; justify-content: center; }

/* Big channel action buttons */
.record-actions { display: flex; gap: 10px; justify-content: center; padding: 0 20px 18px; }
.chan-btn {
  flex: 1; max-width: 84px;
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  padding: 13px 6px 11px;
  border: none; border-radius: 12px;
  color: #fff; cursor: pointer;
  font-family: inherit; font-size: 12px; font-weight: 700;
  transition: filter .13s ease;
}
.chan-btn:hover { filter: brightness(1.07); }
.chan-btn .ci { font-size: 17px; line-height: 1; }
.chan-btn.mail { background: var(--blue); }
.chan-btn.call { background: var(--green); }
.chan-btn.more { background: var(--surface-3); color: var(--text-2); }
.chan-btn.more:hover { background: var(--surface-4); }

.about-activity {
  display: flex; align-items: center; gap: 8px; justify-content: center;
  padding: 0 20px 20px;
  font-size: 12.5px; color: var(--text-2); font-weight: 500;
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); flex-shrink: 0; }

/* Left card inner tabs */
.mini-tabs { display: flex; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.mini-tabs button {
  flex: 1; padding: 13px 8px;
  background: none; border: none; border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font: inherit; font-size: 13.5px; font-weight: 600; color: var(--text-muted);
  cursor: pointer;
}
.mini-tabs button:hover { color: var(--text); }
.mini-tabs button.active { color: var(--text); font-weight: 700; border-bottom-color: var(--ink); }
.mini-body { padding: 18px 20px 22px; }

/* Property rows with icon tiles */
.prop-list { display: flex; flex-direction: column; gap: 16px; }
.prop {
  display: flex; align-items: flex-start; gap: 12px;
}
.prop-tile {
  width: 38px; height: 38px; flex-shrink: 0;
  border-radius: var(--r-tile); background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; color: var(--text-2);
}
.prop-text { min-width: 0; }
.prop-text label {
  display: block; font-size: 11px; font-weight: 600;
  letter-spacing: .04em; color: var(--text-muted); margin-bottom: 1px;
}
.prop-text div { font-size: 14px; font-weight: 700; word-break: break-word; letter-spacing: -.01em; }
.prop-text a { color: var(--brand); font-weight: 700; }
.section-label {
  font-size: 10.5px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--text-muted);
  margin: 22px 0 14px;
}

/* Right: main record column */
.breadcrumb { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; font-size: 14px; font-weight: 600; }
.breadcrumb .bc-back { color: var(--text-2); font-size: 16px; }
.breadcrumb .bc-link { color: var(--text-2); }
.breadcrumb .bc-link:hover { color: var(--text); }
.breadcrumb .bc-sep { color: var(--text-muted); }
.breadcrumb .bc-current { color: var(--text); }

.record-title { font-size: 34px; font-weight: 800; letter-spacing: -.035em; margin-bottom: 14px; }
.record-meta { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.record-meta .rm-label { font-size: 13.5px; color: var(--text-2); font-weight: 500; }
.record-meta .rm-label strong { color: var(--text); font-weight: 700; }

/* Main record tabs */
.rec-tabs {
  display: flex; gap: 4px; overflow-x: auto;
  border-bottom: 1px solid var(--border);
  margin-bottom: 22px;
}
.rec-tabs button {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 13px 16px;
  background: none; border: none; border-bottom: 2px solid transparent;
  margin-bottom: -1px; white-space: nowrap;
  font: inherit; font-size: 14px; font-weight: 600; color: var(--text-muted);
  cursor: pointer;
}
.rec-tabs button:hover { color: var(--text); }
.rec-tabs button.active { color: var(--text); font-weight: 700; border-bottom-color: var(--ink); }
.tab-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 10px; background: var(--surface-3); color: var(--text-2);
  font-size: 11px; font-weight: 700;
}
.rec-tabs button.active .tab-count { background: var(--ink); color: #fff; }

/* Stat cards */
.stat-wrap { border: 1px solid var(--border); border-radius: var(--r-card); padding: 18px; margin-bottom: 24px; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.stat {
  background: var(--surface-2); border-radius: 12px; padding: 16px 18px;
}
.stat .s-label {
  display: flex; align-items: center; gap: 7px;
  font-size: 12.5px; font-weight: 600; color: var(--text-2); margin-bottom: 10px;
}
.stat .s-value { font-size: 30px; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.stat .s-sub { font-size: 15px; font-weight: 600; color: var(--text-muted); }
.stat-link {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 16px; font-size: 13.5px; font-weight: 700; color: var(--text);
  cursor: pointer;
}
.stat-link:hover { color: var(--brand); }

/* Section toolbar (segmented + actions) */
.sec-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.segmented { display: inline-flex; background: var(--surface-3); border-radius: var(--r-btn); padding: 3px; }
.segmented button {
  padding: 8px 18px; border: none; border-radius: 8px; background: none;
  font: inherit; font-size: 13px; font-weight: 600; color: var(--text-2); cursor: pointer;
}
.segmented button.active { background: var(--surface); color: var(--text); font-weight: 700; box-shadow: 0 1px 2px rgba(20,22,26,.08); }
.view-toggle { gap: 0; padding: 3px; background: var(--surface-3); border-radius: var(--r-btn); }
.view-toggle button { border: none; background: none; border-radius: 8px; padding: 7px 16px; font-weight: 600; color: var(--text-2); }
.view-toggle button:hover { border: none; background: none; color: var(--text); }
.view-toggle button.active { background: var(--surface); color: var(--text); font-weight: 700; box-shadow: 0 1px 2px rgba(20,22,26,.08); }

/* ---------- Document-style list rows ---------- */
.item-list { display: flex; flex-direction: column; gap: 10px; }
.item-row {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px;
}
.item-row:hover { border-color: var(--border-2); }
.item-tile {
  width: 40px; height: 40px; flex-shrink: 0;
  border-radius: var(--r-tile); background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: var(--text-2);
}
.item-row .grow { flex: 1; min-width: 0; }
.item-row .title { font-size: 14px; font-weight: 700; letter-spacing: -.01em; margin-bottom: 2px; }
.item-row .sub { font-size: 12.5px; color: var(--text-muted); font-weight: 500; }
.item-row.done .title { color: var(--text-muted); text-decoration: line-through; }
.item-actions { display: flex; align-items: center; gap: 7px; flex-shrink: 0; }

/* ---------- Notes ---------- */
.note-composer { margin-bottom: 18px; }
.notes-area {
  width: 100%; min-height: 88px; resize: vertical;
  padding: 14px 16px;
  border: 1px solid var(--border-2); border-radius: 12px;
  background: var(--surface); color: var(--text);
  font: inherit; font-size: 13.5px;
}
.notes-area:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
.notes-area::placeholder { color: var(--text-muted); }
.note-card {
  background: var(--yellow-soft);
  border: 1px solid #F3E8B8;
  border-radius: 12px; padding: 16px 18px; margin-bottom: 12px;
}
.note-card .note-body { font-size: 13.5px; line-height: 1.6; word-break: break-word; }
.note-card .note-meta {
  display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 12px; font-size: 11.5px; color: #8A7B3E; font-weight: 600;
}
.note-actions { display: flex; gap: 7px; }
.note-card .notes-area { background: #fff; border-color: #E8D99A; }
.autosave-hint { margin: 8px 0 0; font-size: 12px; color: var(--text-muted); }

/* ---------- Pipeline tracker (clickable chevron stepper) ---------- */
.pipeline-wrap {
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: 16px 18px;
  margin-bottom: 22px;
}
.pipeline-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 14px;
}
.pipeline-head .ph-label {
  font-size: 10.5px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--text-muted);
}
.pipeline-head .ph-current { font-size: 15px; font-weight: 800; letter-spacing: -.02em; }
.pipeline-head .ph-meta { font-size: 12.5px; color: var(--text-muted); font-weight: 500; }

.pipeline-track {
  display: flex; align-items: stretch;
  overflow-x: auto;
  padding-bottom: 4px;
}
.pipeline-track .step {
  position: relative;
  flex: 1 0 auto;
  min-width: 116px;
  padding: 11px 14px 11px 26px;
  margin-left: -13px;
  background: var(--surface-3);
  color: var(--text-2);
  border: none;
  font-family: inherit; font-size: 12px; font-weight: 600;
  text-align: left; white-space: nowrap;
  cursor: pointer;
  clip-path: polygon(0 0, calc(100% - 13px) 0, 100% 50%, calc(100% - 13px) 100%, 0 100%, 13px 50%);
  transition: background .12s ease, color .12s ease;
}
.pipeline-track .step:first-child {
  margin-left: 0; padding-left: 16px;
  clip-path: polygon(0 0, calc(100% - 13px) 0, 100% 50%, calc(100% - 13px) 100%, 0 100%);
}
.pipeline-track .step:last-child {
  clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 13px 50%);
}
.pipeline-track .step .s-num {
  display: block; font-size: 10px; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase; opacity: .65;
}
.pipeline-track .step.done { background: var(--green-soft); color: #0F8A50; }
.pipeline-track .step.current { background: var(--ink); color: #fff; font-weight: 700; }
.pipeline-track .step.lost { background: var(--red); color: #fff; font-weight: 700; }
.pipeline-track .step:not(.current):not(:disabled):hover { background: var(--brand); color: #fff; }
.pipeline-track .step:disabled { cursor: default; opacity: .75; }
.pipeline-track .step.locked:not(.current):hover { background: var(--surface-4); color: var(--text-2); }
.delivery-block { margin-top: 18px; padding-top: 16px; border-top: 1px dashed var(--border-2); }
.pipeline-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.pipeline-hint { font-size: 12px; color: var(--text-muted); margin-top: 10px; }

/* ---------- Activity feed ---------- */
.act-composer {
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: 14px 16px;
  margin-bottom: 20px;
}
.act-types { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.act-types button {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px;
  border: 1px solid var(--border-2); border-radius: 999px;
  background: var(--surface); color: var(--text-2);
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.act-types button:hover { border-color: var(--text-muted); color: var(--text); }
.act-types button.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.act-filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.act-filters button {
  padding: 6px 13px;
  border: 1px solid var(--border-2); border-radius: 999px;
  background: var(--surface); color: var(--text-2);
  font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.act-filters button.active { background: var(--surface-3); border-color: var(--border-2); color: var(--text); }

.feed { position: relative; padding-left: 46px; }
.feed-item { position: relative; padding-bottom: 20px; }
.feed-item:last-child { padding-bottom: 0; }
.feed-item::before {
  content: ""; position: absolute; left: -30px; top: 38px; bottom: -2px;
  width: 1px; background: var(--border);
}
.feed-item:last-child::before { display: none; }
.feed-icon {
  position: absolute; left: -46px; top: 0;
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2); color: var(--text-2);
  border: 1px solid var(--border);
}
.feed-icon.note { background: var(--yellow-soft); border-color: #F0E4B0; color: #8A6D00; }
.feed-icon.call { background: var(--green-soft); border-color: #C7EBD8; color: #0F8A50; }
.feed-icon.meeting { background: var(--blue-soft); border-color: #CBD9FF; color: var(--blue); }
.feed-icon.task { background: var(--brand-soft); border-color: #FFD9C6; color: var(--brand-hover); }
.feed-icon.email { background: var(--surface-3); color: var(--text-2); }
.feed-icon.stage { background: var(--ink); border-color: var(--ink); color: #fff; }
.feed-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 13px 16px;
}
.feed-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.feed-title { font-size: 13.5px; font-weight: 700; letter-spacing: -.01em; }
.feed-when { font-size: 11.5px; color: var(--text-muted); font-weight: 500; margin-left: auto; }
.feed-body { font-size: 13.5px; line-height: 1.6; margin-top: 6px; white-space: pre-wrap; word-break: break-word; }
.feed-actions { display: flex; gap: 7px; margin-top: 10px; }
.feed-item.is-done .feed-title { color: var(--text-muted); text-decoration: line-through; }

/* ---------- Timeline ---------- */
.timeline { position: relative; padding-left: 42px; }
.timeline-item { position: relative; padding-bottom: 22px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before {
  content: ""; position: absolute; left: -27px; top: 32px; bottom: -4px;
  width: 1px; background: var(--border-2);
}
.timeline-item:last-child::before { display: none; }
.timeline-item::after {
  content: ""; position: absolute; left: -42px; top: 0;
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--surface-2); border: 1px solid var(--border);
}
.timeline-item .t-head { font-size: 13.5px; font-weight: 600; color: var(--text-2); line-height: 1.45; }
.timeline-item .t-head strong { color: var(--text); font-weight: 700; }
.timeline-item .t-meta { font-size: 12px; color: var(--text-muted); font-weight: 500; margin-top: 3px; }
.timeline-item .t-diff { margin-top: 8px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.timeline-item .t-diff code {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 7px; padding: 3px 8px; font-size: 11.5px; font-family: inherit;
  color: var(--text-2); word-break: break-all;
}

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.field label .req { color: var(--red); }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 13px;
  border: 1px solid var(--border-2); border-radius: var(--r-btn);
  background: var(--surface); color: var(--text);
  font: inherit; font-size: 13.5px;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: var(--ring);
}
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--red); }
.field .helper { font-size: 12px; color: var(--text-muted); margin-top: 5px; }
.field.invalid .helper { color: var(--red); }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(20,22,26,.45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 52px 16px; overflow-y: auto;
  backdrop-filter: blur(2px);
}
.modal {
  background: var(--surface); border-radius: 18px;
  box-shadow: 0 24px 70px rgba(20,22,26,.28);
  width: 100%; max-width: 580px;
}
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 22px 24px 18px; }
.modal-head h2 { font-size: 19px; font-weight: 800; letter-spacing: -.02em; }
.modal-close {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--surface-2); border: none; color: var(--text-2);
  font-size: 17px; line-height: 1; cursor: pointer;
}
.modal-close:hover { background: var(--surface-3); color: var(--text); }
.modal-body { padding: 0 24px 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 18px 24px 22px; border-top: 1px solid var(--border); }
.missing-list { margin: 8px 0 0; padding-left: 18px; font-size: 13px; color: var(--red); font-weight: 600; }

/* ---------- Tabs (list views) ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tabs button {
  padding: 12px 16px; background: none; border: none;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  font: inherit; font-size: 14px; font-weight: 600; color: var(--text-muted); cursor: pointer;
}
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--text); font-weight: 700; border-bottom-color: var(--ink); }

/* ---------- Toasts ---------- */
.toast-root { position: fixed; bottom: 24px; right: 24px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  display: flex; align-items: center; gap: 12px;
  background: var(--ink); color: #fff;
  border-radius: 12px; padding: 14px 18px;
  box-shadow: var(--shadow-pop);
  font-size: 13.5px; font-weight: 600; max-width: 400px;
}
.toast.success { background: var(--ink); }
.toast.success::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--green); flex-shrink: 0; }
.toast.error::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--red); flex-shrink: 0; }
.toast .toast-action { background: none; border: none; color: var(--yellow); font: inherit; font-weight: 700; cursor: pointer; padding: 0; }

/* ---------- Empty states ---------- */
.empty-state { text-align: center; color: var(--text-muted); padding: 54px 20px; font-size: 14px; font-weight: 500; }

/* ---------- Email stats ---------- */
.email-stats { display: flex; gap: 16px; font-size: 12.5px; color: var(--text-muted); font-weight: 500; margin-top: 6px; }
.email-stats strong { color: var(--text); font-weight: 700; }
.email-body-preview {
  border: 1px solid var(--border); border-radius: 12px;
  padding: 16px; margin-top: 10px; background: var(--surface-2);
  font-size: 13.5px; max-height: 300px; overflow-y: auto;
}

/* ---------- Quill ---------- */
.ql-toolbar.ql-snow { border: 1px solid var(--border-2); border-radius: 12px 12px 0 0; background: var(--surface-2); }
.ql-container.ql-snow {
  border: 1px solid var(--border-2); border-top: none; border-radius: 0 0 12px 12px;
  background: var(--surface); color: var(--text); font-family: var(--font); font-size: 14px;
}
.ql-editor { min-height: 190px; }
.ql-editor.ql-blank::before { color: var(--text-muted); font-style: normal; }
.ql-snow .ql-stroke { stroke: var(--text-2); }
.ql-snow .ql-fill, .ql-snow .ql-stroke.ql-fill { fill: var(--text-2); }
.ql-snow .ql-picker { color: var(--text-2); }
.ql-snow .ql-picker-options { background: var(--surface); border-color: var(--border); border-radius: 10px; }
.ql-snow.ql-toolbar button:hover .ql-stroke, .ql-snow.ql-toolbar button.ql-active .ql-stroke { stroke: var(--brand); }
.ql-snow.ql-toolbar button:hover .ql-fill, .ql-snow.ql-toolbar button.ql-active .ql-fill { fill: var(--brand); }
.ql-snow a { color: var(--brand); }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .record-grid { grid-template-columns: 288px minmax(0, 1fr); }
  .top-links { display: none; }
  .sidebar-nav { display: flex; }
}
@media (max-width: 900px) {
  .record-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .app-shell { margin: 0; border-radius: 0; min-height: 100vh; }
  .hamburger { display: block; }
  .top-links { display: none; }
  .sidebar-nav { display: flex; }
  .topnav { padding: 12px 16px; gap: 12px; }
  #global-search { max-width: none; }
  .user-chip { display: none; }
  .sidebar {
    position: fixed; top: 64px; left: 0; bottom: 0; width: 260px;
    background: var(--surface);
    transform: translateX(-100%); transition: transform .2s ease;
    z-index: 60; box-shadow: var(--shadow-pop);
  }
  .sidebar.open { transform: translateX(0); }
  .content { padding: 18px 16px; }
  .leads-table-wrap { display: none; }
  .lead-cards { display: flex; }
  .form-grid { grid-template-columns: 1fr; }
  .record-title { font-size: 26px; }
  .modal-overlay { padding: 16px 10px; }
}
@media (min-width: 769px) { .lead-cards { display: none !important; } }
