/* APG CRM — Styles */

:root {
  --color-bg: #f8f9fa;
  --color-surface: #ffffff;
  --color-border: #e2e8f0;
  --color-text: #1a202c;
  --color-text-muted: #718096;
  --color-primary: #2b6cb0;
  --color-primary-hover: #2c5282;
  --color-header: #2b6cb0;

  /* Status colors */
  --color-new: #3182ce;
  --color-contacted: #d69e2e;
  --color-qualified: #38a169;
  --color-proposal: #805ad5;
  --color-closed: #718096;

  /* Priority colors */
  --color-high: #e53e3e;
  --color-medium: #dd6b20;
  --color-low: #2b6cb0;

  /* Fit score colors */
  --color-score-high: #276749;
  --color-score-mid: #c05621;
  --color-score-low: #718096;
}

[x-cloak] { display: none !important; }

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  background: var(--color-bg);
  color: var(--color-text);
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ── */
header {
  background: var(--color-header);
  color: white;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 50;
}
header h1 { font-size: 16px; font-weight: 600; letter-spacing: 0.02em; }
header .subtitle { font-size: 12px; opacity: 0.8; margin-top: 2px; }
.header-right { font-size: 12px; opacity: 0.85; }

/* ── Top nav tabs ── */
.top-nav {
  background: var(--color-primary);
  display: flex;
  gap: 4px;
  padding: 0 20px;
  border-top: 1px solid rgba(255,255,255,0.15);
  flex-shrink: 0;
  position: sticky;
  top: 57px;
  z-index: 49;
}
.top-nav-tab {
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 16px;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.top-nav-tab:hover { color: rgba(255,255,255,0.95); }
.top-nav-tab.active {
  color: white;
  border-bottom-color: white;
}
.top-nav-tab[draggable="true"] { cursor: grab; }
.top-nav-tab[draggable="true"]:active { cursor: grabbing; }
.top-nav-tab.tab-drag-over { border-bottom-color: rgba(255,255,255,0.6); background: rgba(255,255,255,0.1); }
.top-nav-tab-external {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

/* ── Activity feed tab ── */
.activity-view {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  background: var(--color-bg);
}
.activity-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.activity-header h2 { font-size: 18px; font-weight: 600; }
.activity-feed { display: flex; flex-direction: column; gap: 6px; max-width: 820px; }
.activity-item {
  background: white;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 10px 14px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 12px;
  font-size: 13px;
  cursor: pointer;
  transition: box-shadow 0.1s;
}
.activity-item:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.08); border-color: #cbd5e0; }
.activity-company { font-weight: 600; color: var(--color-primary); }
.activity-company:hover { text-decoration: underline; }
.activity-desc { color: var(--color-text); grid-column: 1; }
.activity-time { color: var(--color-text-muted); font-size: 12px; grid-row: 1; grid-column: 2; text-align: right; white-space: nowrap; }
.activity-by { color: var(--color-text-muted); font-size: 11px; grid-column: 1 / -1; }
.activity-old { color: #e53e3e; text-decoration: line-through; }
.activity-new { color: #276749; font-weight: 500; }

/* ── Inline cell editing overlay ── */
.inline-edit-overlay {
  position: fixed;
  z-index: 400;
  pointer-events: none;
  display: none;
}
.inline-edit-overlay.is-open {
  display: block;
}
.inline-edit-overlay select {
  pointer-events: auto;
  width: 100%;
  height: 100%;
  border: 2px solid var(--color-primary);
  border-radius: 4px;
  font-size: 12px;
  font-family: inherit;
  background: white;
  outline: none;
  cursor: pointer;
  padding: 2px 4px;
}

/* ── Layout ── */
.layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── Sidebar (removed — kept for any residual references) ── */
.sidebar { display: none; }
.sidebar-section { margin-bottom: 20px; }
.sidebar-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  margin-bottom: 8px;
}
.sidebar-stat {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 13px;
  cursor: pointer;
  border-radius: 4px;
  padding: 4px 6px;
}
.sidebar-stat:hover { background: var(--color-bg); }
.sidebar-stat.active { background: #ebf4ff; color: var(--color-primary); font-weight: 500; }
.sidebar-count {
  background: var(--color-bg);
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 11px;
  color: var(--color-text-muted);
}

/* ── Main content ── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Toolbar ── */
.toolbar {
  padding: 12px 16px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.toolbar input[type="text"] {
  flex: 1;
  min-width: 160px;
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  border-radius: 5px;
  font-size: 13px;
  outline: none;
}
.toolbar input[type="text"]:focus { border-color: var(--color-primary); }
.toolbar select {
  padding: 6px 8px;
  border: 1px solid var(--color-border);
  border-radius: 5px;
  font-size: 13px;
  background: white;
  outline: none;
  cursor: pointer;
}
.toolbar select:focus { border-color: var(--color-primary); }
.btn-clear {
  padding: 7px 14px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  color: var(--color-text-muted);
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.btn-clear:hover { border-color: var(--color-text-muted); background: var(--color-bg); }

/* Generic modern button used in the pipeline toolbar etc. */
.btn,
.btn-primary,
.btn-secondary {
  padding: 7px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease, opacity .15s ease;
}
.btn:disabled,
.btn-primary:disabled,
.btn-secondary:disabled { opacity: 0.55; cursor: default; }
.btn-secondary {
  background: var(--color-surface);
  border-color: var(--color-border);
  color: var(--color-text);
}
.btn-secondary:hover:not(:disabled) { background: var(--color-bg); border-color: var(--color-text-muted); }
.btn-primary {
  background: var(--color-primary);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--color-primary-hover); }

/* ── Table ── */
.table-wrap {
  flex: 1;
  overflow-y: auto;
}
table { width: 100%; border-collapse: collapse; }
thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--color-surface);
  border-bottom: 2px solid var(--color-border);
  padding: 9px 12px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-muted);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  overflow: visible;
}

/* ── Column resize handle ── */
.col-resize-handle {
  position: absolute;
  right: 0;
  top: 0;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  z-index: 2;
  border-radius: 0 3px 3px 0;
}
.col-resize-handle:hover,
.col-resize-active {
  background: var(--color-primary);
  opacity: 0.35;
}

/* ── Column filter button ── */
.col-filter-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 11px;
  color: var(--color-text-muted);
  padding: 1px 3px;
  margin-left: 1px;
  border-radius: 3px;
  line-height: 1;
  vertical-align: middle;
}
.col-filter-btn:hover { background: var(--color-bg); color: var(--color-primary); }
.col-filter-btn.col-filter-active { color: var(--color-primary); }

/* ── Column filter panel (floating, Excel-style) ──
   Hidden by default; .is-open class shows it. */
.col-filter-panel {
  position: fixed;
  background: white;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  z-index: 500;
  width: 220px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.15);
  display: none;
  flex-direction: column;
  font-weight: normal;
  cursor: default;
}
.col-filter-panel.is-open { display: flex; }

.col-filter-search-wrap {
  padding: 8px 8px 6px;
  border-bottom: 1px solid var(--color-border);
}
.col-filter-search-input {
  width: 100%;
  padding: 5px 8px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-size: 13px;
  outline: none;
  font-family: inherit;
}
.col-filter-search-input:focus { border-color: var(--color-primary); }

.col-filter-select-all {
  padding: 6px 10px 4px !important;
  font-weight: 500 !important;
}

.col-filter-divider {
  height: 1px;
  background: var(--color-border);
  margin: 2px 0;
}

.col-filter-list {
  overflow-y: auto;
  max-height: 240px;
}

.col-filter-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  font-size: 13px;
  cursor: pointer;
  font-weight: normal;
  user-select: none;
}
.col-filter-item:hover { background: var(--color-bg); }
.col-filter-item input[type="checkbox"] { flex-shrink: 0; cursor: pointer; }

.col-filter-overflow {
  padding: 4px 10px 6px;
  font-size: 11px;
  color: var(--color-text-muted);
  font-style: italic;
}

.col-filter-footer {
  padding: 8px 10px;
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.col-filter-clear-btn {
  background: none;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  color: var(--color-text-muted);
}
.col-filter-clear-btn:hover:not(:disabled) { border-color: var(--color-text-muted); color: var(--color-text); }
.col-filter-clear-btn:disabled { opacity: 0.4; cursor: default; }

/* ── Column picker popover ── */
.col-picker-wrap {
  position: relative;
}
.col-picker-popover {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: white;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 6px 0;
  z-index: 60;
  min-width: 148px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.12);
}
.col-picker-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}
.col-picker-item:hover { background: var(--color-bg); }

/* ── Add Account / secondary action button ── */
.btn-add {
  padding: 7px 16px;
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s ease, box-shadow .15s ease;
}
.btn-add:hover { background: var(--color-primary-hover); }
thead th:hover { color: var(--color-primary); }
thead th.sorted { color: var(--color-primary); }
tbody tr {
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  transition: background 0.1s;
}
tbody tr:hover { background: #f7faff; }
tbody tr.selected { background: #ebf4ff; }
tbody td { padding: 9px 12px; vertical-align: middle; }

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}
.badge-new        { background: #bee3f8; color: #2c5282; }
.badge-contacted  { background: #fefcbf; color: #744210; }
.badge-qualified  { background: #c6f6d5; color: #276749; }
.badge-proposal   { background: #e9d8fd; color: #553c9a; }
.badge-closed     { background: #e2e8f0; color: #4a5568; }

.badge-high   { background: #fed7d7; color: #822727; }
.badge-medium { background: #feebc8; color: #7b341e; }
.badge-low    { background: #bee3f8; color: #2c5282; }

.score {
  font-weight: 600;
  font-size: 13px;
}
.score-high { color: var(--color-score-high); }
.score-mid  { color: var(--color-score-mid); }
.score-low  { color: var(--color-score-low); }

/* ── Sticky layout wrappers ── */
.app-root  { display: flex; flex-direction: column; flex: 1; min-height: 0; overflow: hidden; }
.app-shell { display: flex; flex-direction: column; flex: 1; min-height: 0; overflow: hidden; }

/* ── Account card (full-screen sub-view, replaces the list) ── */
.account-subview {
  flex: 1;
  min-width: 0;
  min-height: 0;
  background: var(--color-surface);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.subview-back {
  background: none;
  border: none;
  padding: 0 0 10px;
  cursor: pointer;
  font-size: 13px;
  color: var(--color-primary);
}
.subview-back:hover { text-decoration: underline; }
.detail-header {
  padding: 16px;
  border-bottom: 1px solid var(--color-border);
}
.detail-header h2 { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.detail-header .detail-location { color: var(--color-text-muted); font-size: 12px; }
.detail-body { padding: 16px; flex: 1; overflow-y: auto; }

/* ── Changelog / History ── */
.detail-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  margin: 20px 0 8px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
}
.changelog-list { display: flex; flex-direction: column; gap: 8px; }
.changelog-entry {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 5px;
  padding: 8px 10px;
  font-size: 12px;
}
.changelog-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 3px;
}
.changelog-field {
  font-weight: 600;
  color: var(--color-text);
  text-transform: capitalize;
}
.changelog-time { color: var(--color-text-muted); font-size: 11px; }
.changelog-values { color: var(--color-text); margin-bottom: 2px; }
.changelog-old { color: #e53e3e; text-decoration: line-through; }
.changelog-new { color: #276749; font-weight: 500; }
.changelog-by { color: var(--color-text-muted); font-size: 11px; }
.changelog-entry--email   { border-left: 3px solid #4299e1; }
.changelog-entry--activity { border-left: 3px solid #48bb78; }

/* ── Column drag-reorder ── */
thead th[draggable="true"] { cursor: grab; }
thead th[draggable="true"]:active { cursor: grabbing; }
thead th .col-resize-handle { cursor: col-resize; }
thead th .col-filter-btn { cursor: pointer; }
thead th.col-drag-over { box-shadow: inset 3px 0 0 var(--color-primary); }
.detail-field { margin-bottom: 14px; }
.detail-field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  margin-bottom: 4px;
}
.detail-field .value { font-size: 13px; }

.detail-select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--color-border);
  border-radius: 5px;
  font-size: 13px;
  background: white;
  cursor: pointer;
}
.detail-select:focus { outline: none; border-color: var(--color-primary); }

.detail-input {
  width: 100%;
  padding: 5px 8px;
  border: 1px solid var(--color-border);
  border-radius: 5px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
}
.detail-input:focus { border-color: var(--color-primary); }

.notes-textarea {
  width: 100%;
  min-height: 100px;
  padding: 8px;
  border: 1px solid var(--color-border);
  border-radius: 5px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
}
.notes-textarea:focus { outline: none; border-color: var(--color-primary); }

.btn-save {
  margin-top: 8px;
  padding: 8px 18px;
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  font-weight: 500;
  transition: background .15s ease, box-shadow .15s ease, opacity .15s ease;
}
.btn-save:hover { background: var(--color-primary-hover); }
.btn-save:disabled { opacity: 0.5; cursor: default; }

/* Small square icon buttons (e.g. Settings → Priorities reorder/delete) */
.icon-btn {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  width: 24px;
  height: 24px;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  color: #4a5568;
  padding: 0;
}
.icon-btn:hover:not(:disabled) { background: #f7fafc; }
.icon-btn:disabled { opacity: 0.4; cursor: default; }

.product-pill {
  display: inline-block;
  background: #e2e8f0;
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 11px;
  margin: 2px;
}

/* ── Empty / loading states ── */
.state-message {
  text-align: center;
  padding: 60px 20px;
  color: var(--color-text-muted);
}
.state-message p { margin-top: 8px; font-size: 13px; }

/* ── Saved toast ── */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #276749;
  color: white;
  padding: 10px 18px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 100;
  transition: opacity 0.3s;
  max-width: 340px;
}
.toast--error {
  background: #b91c1c;
}

/* ── Auth loading screen ── */
.auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  color: var(--color-text-muted);
  font-size: 14px;
}

/* ── Checkbox column ── */
.cb-col {
  width: 36px;
  text-align: center;
  padding: 0 8px !important;
}
.cb-col input[type="checkbox"] {
  cursor: pointer;
  width: 14px;
  height: 14px;
}
tbody tr.row-checked { background: #f0f7ff; }
tbody tr.row-checked:hover { background: #e6f0fc; }

/* ── Campaign toolbar button ── */
.campaign-btn {
  padding: 6px 14px;
  background: #276749;
  color: white;
  border: none;
  border-radius: 5px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.campaign-btn:hover { background: #22543d; }

/* ── Modal overlay + dialog ──
   Hidden by default; .is-open class shows it. Avoids Alpine x-show originalDisplay bug
   where a stuck CSS display:none would prevent the modal from ever showing. */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  /* The account card is now in-flow, but drawers and other fixed overlays still
     stack against this, so keep it high. */
  z-index: 10050;
  display: none;
  align-items: center;
  justify-content: center;
}
.modal-overlay.is-open { display: flex; }

.modal-dialog {
  background: var(--color-surface);
  border-radius: 8px;
  width: 600px;
  max-width: calc(100vw - 40px);
  max-height: 88vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-shrink: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  color: var(--color-text-muted);
  padding: 2px 6px;
  border-radius: 999px;
  line-height: 1;
}
.modal-close:hover { background: var(--color-bg); }

.modal-body {
  padding: 20px;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
}

/* ── Template picker cards ── */
.template-cards {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.template-card {
  flex: 1;
  padding: 10px 12px;
  border: 2px solid var(--color-border);
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.template-card:hover { border-color: var(--color-primary); }
.template-card.active {
  border-color: var(--color-primary);
  background: #ebf4ff;
}

.template-card-name {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 3px;
}
.template-card-desc {
  font-size: 11px;
  color: var(--color-text-muted);
  line-height: 1.4;
}

/* ── Campaign compose inputs ── */
.campaign-input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--color-border);
  border-radius: 5px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
}
.campaign-input:focus { border-color: var(--color-primary); }

.campaign-body {
  width: 100%;
  min-height: 180px;
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: 5px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  outline: none;
  line-height: 1.5;
}
.campaign-body:focus { border-color: var(--color-primary); }

/* ── Preview box ── */
.preview-box p { margin: 0 0 12px 0; }
.preview-box p:last-child { margin-bottom: 0; }
.preview-box {
  margin-top: 10px;
  padding: 12px 14px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 5px;
  font-size: 12px;
  line-height: 1.6;
  max-height: 220px;
  overflow-y: auto;
}

/* ── Campaign send progress ── */
.campaign-progress {
  padding: 10px 0 4px;
  font-size: 13px;
  color: var(--color-text-muted);
}

.progress-bar {
  height: 6px;
  background: var(--color-border);
  border-radius: 3px;
  margin-top: 6px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* ── CSV Import modal ── */
.import-dropzone {
  border: 2px dashed var(--color-border);
  border-radius: 8px;
  padding: 36px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  color: var(--color-text-muted);
}
.import-dropzone:hover,
.import-dropzone-hover {
  border-color: var(--color-primary);
  background: #ebf4ff;
  color: var(--color-primary);
}

.import-stat {
  flex: 1;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 12px;
  text-align: center;
}
.import-stat-num {
  font-size: 24px;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1;
  margin-bottom: 4px;
}
.import-stat-label {
  font-size: 11px;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── Pipeline (Kanban) ── */
.pipeline-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--color-bg);
}
.pipeline-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}
.pipeline-search {
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 5px 10px;
  font-size: 13px;
  font-family: inherit;
  width: 220px;
  outline: none;
}
.pipeline-search:focus { border-color: var(--color-primary); }

.pipeline-board {
  flex: 1;
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  overflow-x: auto;
  overflow-y: hidden;
  align-items: flex-start;
}
.pipeline-col {
  flex: 0 0 240px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  max-height: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.pipeline-col-dragover {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(43,108,176,0.2);
}
.pipeline-col-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}
.pipeline-col-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
}
.pipeline-col-count {
  background: var(--color-bg);
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-muted);
}
.pipeline-cards {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.pipeline-col-empty {
  font-size: 12px;
  color: var(--color-text-muted);
  font-style: italic;
  text-align: center;
  padding: 20px 0;
}

.pipeline-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 10px 10px 10px 14px;
  cursor: grab;
  position: relative;
  overflow: hidden;
  transition: box-shadow 0.15s, opacity 0.15s;
}
.pipeline-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
.pipeline-card-dragging { opacity: 0.4; }
.pipeline-card-stripe {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
}
.stripe-high   { background: var(--color-high); }
.stripe-medium { background: var(--color-medium); }
.stripe-low    { background: var(--color-low); }

.pipeline-card-company {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pipeline-card-sub {
  font-size: 11px;
  color: var(--color-text-muted);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pipeline-card-contact {
  font-size: 11px;
  color: var(--color-text-muted);
  margin-bottom: 6px;
}
.pipeline-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
}
.pipeline-card-score {
  font-size: 11px;
  font-weight: 600;
}
.score-high { color: var(--color-score-high); }
.score-mid  { color: var(--color-score-mid); }
.score-low  { color: var(--color-score-low); }

.pipeline-card-priority {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 6px;
  border-radius: 3px;
}
.priority-high   { color: var(--color-high);   background: rgba(229,62,62,0.1); }
.priority-medium { color: var(--color-medium);  background: rgba(221,107,32,0.1); }
.priority-low    { color: var(--color-low);     background: rgba(43,108,176,0.1); }

/* ── Dashboard ── */
.dashboard-view {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.dash-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}
.dash-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 16px;
  text-align: center;
}
.dash-card-num {
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 6px;
  color: var(--color-text);
}
.dash-card-label {
  font-size: 11px;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.dash-charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.dash-chart-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.dash-chart-wide {
  grid-column: span 2;
}
.dash-chart-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 4px;
}

.dash-bar-row {
  display: grid;
  grid-template-columns: 110px 1fr 80px;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}
.dash-bar-label {
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dash-bar-track {
  background: var(--color-bg);
  border-radius: 3px;
  height: 14px;
  overflow: hidden;
}
.dash-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}
.dash-bar-count {
  text-align: right;
  color: var(--color-text);
  font-weight: 500;
}
.dash-bar-pct {
  color: var(--color-text-muted);
  font-weight: 400;
  margin-left: 3px;
}

.dash-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 16px;
}
.dash-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.dash-activity {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.dash-activity-row {
  display: grid;
  grid-template-columns: 70px 1fr 200px;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  padding: 6px 8px;
  border-radius: 4px;
  transition: background 0.15s;
}
.dash-activity-row:hover { background: var(--color-bg); }
.dash-activity-time {
  color: var(--color-text-muted);
  font-size: 11px;
}
.dash-activity-body { color: var(--color-text); }
.dash-activity-user {
  color: var(--color-text-muted);
  font-size: 11px;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Apollo Contact Cards ──────────────────────────────────────── */
.contact-card {
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 8px;
  background: #f7fafc;
}
.contact-card.editing { background: #fff; border-color: var(--color-primary); }
.contact-card .contact-name  { font-weight: 600; font-size: 13px; color: var(--color-text); }
.contact-card .contact-title { color: var(--color-text-muted); font-size: 12px; margin-top: 2px; }
.contact-card .contact-detail { font-size: 12px; color: var(--color-text); margin-top: 4px; }
.contact-card a { color: var(--color-primary); text-decoration: none; }
.contact-card a:hover { text-decoration: underline; }
.contact-card .card-actions { display: flex; gap: 6px; margin-top: 8px; }
.contact-card .btn-edit {
  font-size: 11px; padding: 2px 10px; background: none;
  border: 1px solid var(--color-border); border-radius: 999px; cursor: pointer; color: var(--color-text-muted);
}
.contact-card .btn-edit:hover { border-color: var(--color-primary); color: var(--color-primary); }
.contact-edit-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 5px; margin-top: 6px;
}
.contact-edit-grid input {
  padding: 4px 7px; border: 1px solid var(--color-border); border-radius: 4px;
  font-size: 12px; width: 100%; outline: none;
}
.contact-edit-grid input:focus { border-color: var(--color-primary); }
.contact-edit-grid .full-width { grid-column: 1 / -1; }

@keyframes progress-indeterminate {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}

/* ── Analysis tab ──────────────────────────────────────────────── */
/* ── Contacts tab ─────────────────────────────────────────── */
.contacts-view {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}
.contacts-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}
.contacts-table-wrap {
  flex: 1;
  overflow: auto;
}
.contacts-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.contacts-table th {
  position: sticky;
  top: 0;
  background: #f7fafc;
  border-bottom: 2px solid var(--color-border);
  padding: 8px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #718096;
  user-select: none;
  z-index: 10;
  white-space: nowrap;
}
.contacts-table th:hover { color: var(--color-primary); }
.contacts-table th.ct-sorted { color: var(--color-primary); }
.contacts-table th[draggable="true"] { cursor: grab; }
.contacts-table th[draggable="true"]:active { cursor: grabbing; }
.contacts-table th.ct-col-drag-over { box-shadow: inset 3px 0 0 var(--color-primary); }

/* ── Contacts grid: per-column filter funnel ─────────────── */
.ct-funnel {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0 2px;
  margin-left: 3px;
  font-size: 10px;
  color: var(--color-text-muted);
  opacity: 0.5;
}
.contacts-table th:hover .ct-funnel { opacity: 1; }
.ct-funnel-on { opacity: 1; color: var(--color-primary); }
.ct-filter-pop {
  position: fixed;
  z-index: 10100;
  width: 200px;
  max-height: 280px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  padding: 8px;
}
.ct-filter-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 4px;
  font-size: 12px;
  color: #2d3748;
  cursor: pointer;
}
.ct-filter-row:hover { background: #f7fafc; }
.ct-filter-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Contacts grid: inline cell editing ──────────────────── */
.ct-cell { display: inline-block; min-width: 100%; }
.ct-cell-editable { cursor: text; border-radius: 3px; }
.ct-cell-editable:hover { box-shadow: inset 0 0 0 1px var(--color-border); }
.ct-edit-input {
  width: 100%;
  box-sizing: border-box;
  padding: 3px 6px;
  font-size: 13px;
  font-family: inherit;
  border: 1px solid var(--color-primary);
  border-radius: 3px;
  outline: none;
}
.ct-notes {
  display: inline-block;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}
/* Floating bulk-selection bar. Fixed rather than sticky so it stays reachable
   however far down the grid the user has scrolled. */
.bulk-bar {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  max-width: calc(100vw - 32px);
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.16);
  padding: 8px 12px;
}
.bulk-bar-row,
.bulk-bar-panel {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
}
.bulk-bar-panel {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--color-border);
}
/* Selected rows win over the overdue tint: the selection is what the bulk bar
   is about to act on, so it has to be the more legible of the two. */
.contacts-table tbody tr.ct-row-selected > td { background: #ebf8ff; }

/* Due date on a next action. Neutral by default, so that only genuinely
   time-critical work carries colour. */
.ct-due {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--color-border);
  background: #f7fafc;
  color: #4a5568;
  font-size: 11px;
  white-space: nowrap;
}
.ct-due-overdue { background: #fed7d7; border-color: #fc8181; color: #c53030; font-weight: 600; }
.ct-due-soon    { background: #feebc8; border-color: #f6ad55; color: #c05621; }

/* A row is tinted only when something on it is late, so scanning the grid
   surfaces overdue work even with the Next Action column hidden. */
.ct-row-overdue > td { background: #fffafa; }

/* One value of a user-defined tag category. An option that carries a colour
   overrides these neutrals with an inline :style. */
.ct-tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 10px;
  border: 1px solid var(--color-border);
  background: #f7fafc;
  color: #4a5568;
  font-size: 11px;
  white-space: nowrap;
}
.ct-row-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
  font-size: 13px;
  opacity: 0.45;
}
.ct-row-btn:hover { opacity: 1; }

/* ── Contact count badge ─────────────────────────────────── */
.contact-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: 11px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
  transition: background 0.15s, transform 0.1s;
}
.contact-count-badge:hover {
  background: #2b6cb0;
  transform: scale(1.1);
}
.contacts-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}
.contacts-table tbody tr:hover { background: #f7fafc; }
.contacts-table a { color: var(--color-primary); text-decoration: none; }
.contacts-table a:hover { text-decoration: underline; }
.link-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-primary);
  font-size: 13px;
  padding: 0;
  text-align: left;
  font-weight: 500;
}
.link-btn:hover { text-decoration: underline; }

.analysis-view { padding: 24px; }

.analysis-controls {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.analysis-controls label {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.analysis-controls select {
  font-size: 13px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 4px 8px;
  background: #fff;
  color: var(--color-text);
  cursor: pointer;
}
.analysis-controls select:focus { outline: 2px solid var(--color-primary); }
.pct-toggle { font-weight: 400 !important; cursor: pointer; }
.pct-toggle input { cursor: pointer; }
.analysis-total-note { font-size: 12px; color: var(--color-text-muted); margin-left: auto; }

/* Cross-tab table */
.crosstab-wrap { overflow-x: auto; }
.crosstab {
  border-collapse: collapse;
  font-size: 13px;
  min-width: 400px;
  width: 100%;
}
.crosstab th,
.crosstab td {
  border: 1px solid var(--color-border);
  padding: 7px 14px;
  text-align: center;
  white-space: nowrap;
}
.crosstab thead th {
  background: #2d4a7a;
  color: #fff;
  font-weight: 600;
}
.crosstab .crosstab-corner {
  text-align: left;
  font-size: 11px;
  min-width: 130px;
}
.crosstab .crosstab-rowlabel {
  text-align: left;
  font-weight: 500;
  background: #f7fafc;
  color: var(--color-text);
}
.crosstab tbody tr:hover .crosstab-rowlabel { background: #ebf8ff; }
.crosstab .crosstab-cell { background: #fff; color: var(--color-text); }
.crosstab tbody tr:hover .crosstab-cell { background: #ebf8ff; }
.crosstab .crosstab-zero { color: #cbd5e0; }
.crosstab .crosstab-total {
  background: #f0f4f8;
  font-weight: 600;
  color: var(--color-text);
}
.crosstab tfoot td {
  background: #edf2f7;
  font-weight: 600;
}

/* ── Rich-text editors (contenteditable) ─────────────────── */
.rich-editor {
  min-height: 180px;
  font-size: 13px;
  font-family: inherit;
  line-height: 1.6;
  padding: 12px 15px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 0 0 4px 4px;
  overflow-y: auto;
  outline: none;
  white-space: pre-wrap;
}
.rich-editor--sig {
  min-height: 120px;
}
.rich-editor:focus {
  border-color: #a0aec0;
}
.rich-editor p { margin: 0 0 0.5em; }
.rich-editor ul, .rich-editor ol { margin: 0 0 0.5em; padding-left: 1.5em; }
.rich-editor blockquote {
  margin: 0 0 0.5em 1em;
  padding-left: 0.75em;
  border-left: 3px solid #cbd5e0;
  color: #718096;
}
/* ── Custom toolbar (replaces Quill's built-in toolbar) ── */
.custom-ql-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1px;
  padding: 5px 8px;
  background: #f7fafc;
  border: 1px solid #e2e8f0;
  border-bottom: none;
  border-radius: 4px 4px 0 0;
}
.custom-ql-toolbar .tb-select {
  border: 1px solid #cbd5e0;
  background: #fff;
  padding: 2px 4px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  line-height: 1.4;
  color: #2d3748;
  margin: 0 2px;
}
.custom-ql-toolbar button {
  border: none;
  background: transparent;
  padding: 3px 7px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1.4;
  color: #2d3748;
}
.custom-ql-toolbar button:hover { background: #e2e8f0; }
.custom-ql-toolbar .tb-sep {
  width: 1px;
  height: 16px;
  background: #cbd5e0;
  margin: 0 4px;
}

/* ── Dashboard action cards ── */
.dash-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 16px 20px;
}
.dash-action-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  overflow: hidden;
}
.dash-action-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px 10px;
  border-bottom: 1px solid var(--color-border);
  background: #f7fafc;
}
.dash-action-icon { font-size: 16px; }
.dash-action-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--color-text);
}
.dash-action-badge {
  background: var(--color-primary);
  color: #fff;
  border-radius: 10px;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 700;
  margin-left: auto;
}
.dash-action-badge-warn  { background: #d69e2e; }
.dash-action-badge-green { background: #38a169; }
.dash-action-badge-red   { background: #e53e3e; }
.dash-action-sub {
  font-size: 11px;
  color: var(--color-text-muted);
  margin-left: 4px;
  white-space: nowrap;
}
.dash-action-list {
  max-height: 220px;
  overflow-y: auto;
}
.dash-action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  cursor: pointer;
  border-bottom: 1px solid #f0f4f8;
  transition: background 0.1s;
}
.dash-action-row:last-child { border-bottom: none; }
.dash-action-row:hover { background: #ebf4ff; }
.dash-action-company {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text);
}
.dash-action-contact {
  font-size: 12px;
  color: var(--color-text-muted);
  text-align: right;
}
.dash-action-empty {
  padding: 16px;
  font-size: 13px;
  color: var(--color-text-muted);
  font-style: italic;
  text-align: center;
}

/* ── Accounts filter panel ── */
.filter-panel {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: #f7fafc;
  border-bottom: 1px solid var(--color-border);
  flex-wrap: wrap;
}
.filter-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.filter-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--color-text-muted);
}
.filter-panel select {
  font-size: 12px;
  padding: 4px 8px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: white;
  color: var(--color-text);
  min-width: 110px;
}
.btn-clear-all {
  padding: 5px 12px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--color-border);
  background: white;
  color: var(--color-text-muted);
  transition: all 0.15s;
  white-space: nowrap;
}
.btn-clear-all.active {
  background: #fff5f5;
  border-color: #e53e3e;
  color: #e53e3e;
}
.btn-clear-all:hover {
  border-color: #e53e3e;
  color: #e53e3e;
}
.filter-result-count {
  margin-left: auto;
  font-size: 12px;
  color: var(--color-text-muted);
  white-space: nowrap;
}

/* ── Pipeline funnel ── */
.funnel-wrap {
  padding: 32px 40px;
  max-width: 760px;
  margin: 0 auto;
}
.funnel-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 4px;
}
.funnel-subtitle {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-bottom: 28px;
}
.funnel-stages {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.funnel-row {
  display: flex;
  align-items: center;
  gap: 16px;
}
.funnel-bar-wrap {
  flex: 0 0 420px;
  display: flex;
  justify-content: center;
  align-items: center;
}
.funnel-bar {
  height: 44px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: filter 0.15s, transform 0.12s;
  min-width: 64px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.18);
}
.funnel-bar:hover {
  filter: brightness(1.1);
  transform: scaleY(1.04);
}
.funnel-bar-label {
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.25);
  pointer-events: none;
}
.funnel-meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.funnel-count {
  font-size: 15px;
  font-weight: 700;
  color: var(--color-text);
}
.funnel-pct-total {
  font-size: 12px;
  color: var(--color-text-muted);
}
.funnel-conv {
  font-size: 11px;
  font-weight: 600;
}
.funnel-total {
  margin-top: 24px;
  font-size: 13px;
  color: var(--color-text-muted);
  text-align: center;
}

/* ── Kanban board ── */
.kanban-wrap {
  padding: 24px 40px 40px;
  border-top: 1px solid var(--color-border);
  margin-top: 8px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}
.kanban-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}
.kanban-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--color-text);
}
.kanban-search {
  width: 220px;
  margin-left: auto;
}
.kanban-board {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  align-items: start;
  overflow-x: auto;
}
.kanban-col {
  background: var(--color-surface-alt, #f7fafc);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  min-height: 180px;
  transition: background 0.15s, box-shadow 0.15s;
}
.kanban-drag-over {
  background: var(--color-primary-light, #ebf8ff);
  box-shadow: 0 0 0 2px var(--color-primary, #3182ce);
}
.kanban-col-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px 8px;
  border-bottom: 1px solid var(--color-border);
}
.kanban-col-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.kanban-col-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--color-text);
  flex: 1;
}
.kanban-col-count {
  font-size: 11px;
  color: var(--color-text-muted);
  background: var(--color-bg);
  border-radius: 999px;
  padding: 1px 7px;
}
.kanban-cards {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 480px;
  overflow-y: auto;
}
.kanban-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 8px 10px;
  cursor: grab;
  transition: box-shadow 0.12s, opacity 0.12s;
}
.kanban-card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.10);
}
.kanban-dragging {
  opacity: 0.4;
  cursor: grabbing;
}
.kanban-card-company {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kanban-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4px;
  font-size: 11px;
  color: var(--color-text-muted);
}
.kanban-fit-badge {
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  background: #718096;
  border-radius: 3px;
  padding: 1px 5px;
}
.kanban-card-contact {
  font-size: 11px;
  color: var(--color-text-muted);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kanban-empty {
  font-size: 12px;
  color: var(--color-text-muted);
  text-align: center;
  padding: 20px 0;
}

/* ── Planner tab (Board / List to-do cards) ───────────────────── */
.planner-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 8px 10px;
  cursor: grab;
  transition: box-shadow 0.12s, opacity 0.12s;
}
.planner-card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.10);
}
.planner-card-done {
  opacity: 0.6;
  cursor: default;
}
.planner-card-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.planner-card-text {
  flex: 1;
  font-size: 12px;
  color: var(--color-text);
  cursor: text;
  word-break: break-word;
}
.planner-card-del {
  background: none;
  border: none;
  color: #cbd5e0;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  padding: 2px 4px;
}
.planner-card-del:hover {
  color: #e53e3e;
}
.planner-card-footer {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  flex-wrap: wrap;
}
.planner-color-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
  cursor: pointer;
  border: 1px solid rgba(0,0,0,0.08);
}
.planner-color-popover {
  position: absolute;
  top: 18px;
  left: 0;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  padding: 6px;
  display: flex;
  gap: 4px;
  z-index: 20;
}
.planner-color-swatch {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  cursor: pointer;
  border: 1px solid rgba(0,0,0,0.08);
}
.planner-bucket-color-dot {
  width: 28px;
  height: 28px;
  display: inline-block;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid #cbd5e0;
}
.planner-bucket-color-popover {
  position: absolute;
  top: 32px;
  left: 0;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(5, 20px);
  gap: 6px;
  z-index: 20;
}
.planner-bucket-color-swatch {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid rgba(0,0,0,0.08);
}
.planner-bucket-color-swatch.is-selected {
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px #2d3748;
}
.planner-badge {
  font-size: 10px;
  color: var(--color-text-muted);
  background: #f7fafc;
  border-radius: 3px;
  padding: 1px 6px;
  cursor: pointer;
}
.planner-badge-empty {
  color: #cbd5e0;
  font-style: italic;
}
.planner-inline-input {
  font-size: 12px;
  border: 1px solid #cbd5e0;
  border-radius: 4px;
  padding: 2px 4px;
  flex: 1;
}
.planner-inline-textarea {
  width: 100%;
  box-sizing: border-box;
  font-size: 12px;
  font-family: inherit;
  line-height: 1.35;
  color: var(--color-text);
  border: 1px solid #cbd5e0;
  border-radius: 4px;
  padding: 3px 5px;
  resize: none;
  overflow: hidden;
  min-height: 20px;
}
.planner-add-row {
  margin-top: 4px;
}
.planner-add-row input {
  width: 100%;
  font-size: 12px;
  border: 1px dashed #cbd5e0;
  border-radius: 4px;
  padding: 5px 8px;
  background: transparent;
}
.planner-done-toggle {
  font-size: 11px;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 6px 2px;
  user-select: none;
}
.planner-gantt-track {
  position: relative;
  height: 6px;
  background: #edf2f7;
  border-radius: 3px;
  margin: 4px 0;
}
.planner-gantt-dot {
  position: absolute;
  top: 50%;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.08);
}
.planner-gantt-cell {
  position: relative;
  padding: 6px 12px;
  width: 45%;
}
.planner-gantt-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  margin-left: -1px;
  opacity: 0.6;
  pointer-events: none;
}
.planner-gantt-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: #4a5568;
  background: #f7fafc;
  border-radius: 10px;
  padding: 2px 8px;
}
.planner-gantt-chip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.planner-gantt-chip-x {
  border: none;
  background: none;
  color: #a0aec0;
  cursor: pointer;
  font-size: 10px;
  padding: 0 0 0 2px;
  line-height: 1;
}
.planner-gantt-line-form {
  position: absolute;
  top: 32px;
  right: 0;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  padding: 10px;
  z-index: 20;
  width: 200px;
}

/* Two conditional styles that used to be `:style` bindings sitting alongside a
   static `style` attribute. Alpine overwrites the whole style attribute when it
   evaluates a `:style`, silently discarding the static one, so a conditional
   tweak has to arrive as a class. */
.push-right { margin-left: auto; }
.is-inactive { opacity: 0.5; }

/* Segmented control: buttons butt together inside one rounded, clipped frame,
   so each drops the .btn-clear pill shape and takes a divider from the button
   before it. The selected state has to be a class rather than a `:style`, for
   the reason above — and the `active` class these once carried was never
   defined, so the inline binding was the only thing colouring them. */
.segmented {
  display: inline-flex;
  border: 1px solid #cbd5e0;
  border-radius: 6px;
  overflow: hidden;
  /* As a flex item this would otherwise be squeezed below its content width,
     and `overflow:hidden` would shear the last button instead of letting the
     toolbar reflow. The heading beside it is prose and can take the squeeze. */
  flex-shrink: 0;
}
.segmented > .btn-clear {
  border: none;
  border-radius: 0;
  padding: 6px 14px;
  font-size: 13px;
}
.segmented > .btn-clear + .btn-clear { border-left: 1px solid #cbd5e0; }
.segmented > .btn-clear.is-on         { background: var(--color-primary); color: #fff; }
.segmented > .btn-clear.is-on-danger  { background: #c53030; color: #fff; }
.segmented > .btn-clear.is-on-success { background: #2f855a; color: #fff; }

/* Contacts grid sort arrow. Rendered on every header so that no column looks
   unsortable, but faint until you hover it or it is the one in use. Showing it
   only on the sorted column is what made the rest look like dead headers. */
.ct-sort {
  margin-left: 4px;
  font-size: 9px;
  opacity: 0;
  transition: opacity .12s;
}
.contacts-table th:hover .ct-sort { opacity: .45; }
.contacts-table th .ct-sort.is-on { opacity: 1; }

/* The explanatory blurb at the top of each Settings section. Measured in `ch`
   rather than pixels: what makes these readable is the number of characters
   per line, not the width of the dialog, and letting them run the full width
   of a wide screen turns three sentences into an unreadable wall. */
.settings-help {
  max-width: 62ch;
  margin-bottom: 14px;
  font-size: 12px;
  line-height: 1.6;
  color: #718096;
}

/* Settings fields that used to be `flex:1` and stretched to the dialog edge.
   A category name is a couple of words, so the input should look like it
   expects a couple of words. */
.settings-field { flex: 0 0 240px; max-width: 100%; }

/* Preset colour swatches — see `tagPalette` for why the native colour input
   was dropped. The picked one is marked with a ring outside the swatch so the
   colour itself is never obscured. */
.tag-swatch {
  width: 20px;
  height: 20px;
  padding: 0;
  border: 1px solid rgba(0, 0, 0, .15);
  border-radius: 4px;
  cursor: pointer;
}
.tag-swatch:disabled { cursor: default; opacity: .6; }
.tag-swatch.is-picked { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--color-primary); }
.tag-palette {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(6, 20px);
  gap: 6px;
  padding: 8px;
  background: #fff;
  border: 1px solid #cbd5e0;
  border-radius: 6px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, .15);
}

/* The full-page contact card. The *content* is capped, not the page, so the
   header's rule still spans the window while the fields stop growing at a
   width you can still scan. Uncapped, a wide monitor put the "+ Add Action"
   button several inches from the field it belongs to. */
.contact-page .detail-body,
.contact-page .card-header-row { max-width: 900px; }

/* A row of fields that sit side by side. This MUST be a class and not an
   inline `display:flex`, because each of these rows is also under an x-show:
   Alpine hides by writing `display:none` inline and re-shows by calling
   removeProperty('display'), which deletes a static inline display for good.
   The row then silently collapses into a full-width stack. */
.card-form-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 8px 0;
  flex-wrap: wrap;
}
/* Free text gets the leftover width but stops short of the far edge; the
   dates are fixed because a date input has one legible size. */
.card-form-row .cf-grow { flex: 1 1 220px; min-width: 0; max-width: 420px; }
.card-form-row .cf-type { flex: 0 0 140px; }
.card-form-row .cf-date { flex: 0 0 140px; }

/* The ✏/🗑 pair on a log entry, pushed to the end of its meta line. Same
   x-show hazard as .card-form-row. */
.card-meta-actions {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

/* Label + control lines in Contact Details. The control is capped so it sits
   next to its label instead of trailing off across the card. */
.card-field-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 12px;
}
.card-field-row > .cf-label { flex: 0 0 130px; color: var(--color-text-muted); }
.card-field-row select.detail-input { flex: 0 1 200px; margin: 0; font-size: 12px; }

/* The full page has far more room than the Accounts panel, so the same field
   list gets more columns rather than two very wide ones. */
.contact-page .contact-edit-grid {
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 8px;
}

/* ── Display utilities, and why they have to exist ──────────────────────────
   Alpine's x-show hides an element by writing `display:none` into its inline
   style, and re-shows it by calling removeProperty('display') — which also
   wipes out whatever static display that same style attribute was carrying.
   An element written as `x-show="…" style="display:flex"` therefore lays out
   correctly exactly once, then collapses to its default display the first
   time it is hidden and shown again.

   So anything under an x-show must carry its display in a class instead.
   These live at the very end of the file on purpose: they are single-class
   selectors, so an earlier position would let any component rule declared
   further down silently outrank them. */
.d-flex { display: flex; }
.d-inline-flex { display: inline-flex; }
.d-inline-block { display: inline-block; }
.d-grid { display: grid; }
