/* External @import blocked the rest of this file until fonts.googleapis.com finished — left local CRM/Electron pages unstyled offline or behind strict networks. Fonts fall back to system-ui stack on body{} */

:root {
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --sidebar-bg: #0f172a;
  --sidebar-text: #e2e8f0;
  --sidebar-muted: #94a3b8;
  --sidebar-active: #ffffff;
  --sidebar-hover: rgba(255, 255, 255, 0.08);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 24px rgba(15, 23, 42, 0.08);
  --radius: 12px;
}

body {
  margin: 0;
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, Segoe UI, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* App shell: sidebar + main */
.app-shell {
  display: flex;
  min-height: 100vh;
  align-items: stretch;
}

.app-sidebar {
  flex: 0 0 240px;
  width: 240px;
  min-height: 100vh;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  padding: 24px 0 20px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  align-self: flex-start;
  z-index: 10;
  box-shadow: 4px 0 32px rgba(15, 23, 42, 0.12);
}

.crm-sidebar-brand {
  padding: 0 20px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 12px;
}

.crm-sidebar-brand-link {
  color: var(--sidebar-active) !important;
  text-decoration: none !important;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  display: block;
}

.crm-sidebar-brand-link:hover {
  color: #fff !important;
  opacity: 0.92;
}

.crm-sidebar-nav {
  flex: 1;
  overflow-y: auto;
}

.crm-sidebar-list {
  list-style: none;
  margin: 0;
  padding: 0 12px;
}

.crm-sidebar-list li {
  margin: 0;
}

.crm-sidebar-link {
  display: block;
  padding: 10px 12px;
  margin-bottom: 2px;
  border-radius: 10px;
  color: var(--sidebar-muted) !important;
  text-decoration: none !important;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}

.crm-sidebar-link:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text) !important;
}

.crm-sidebar-link.is-active {
  background: rgba(37, 99, 235, 0.35);
  color: var(--sidebar-active) !important;
}

.crm-sidebar-foot {
  padding: 16px 20px 0;
  margin-top: auto;
  font-size: 11px;
  color: var(--sidebar-muted);
  letter-spacing: 0.02em;
  opacity: 0.85;
}

button.crm-sidebar-logout {
  margin-top: 8px;
  background: transparent;
  border: none;
  color: var(--sidebar-muted);
  font-size: 12px;
  cursor: pointer;
  padding: 6px 0 0;
  font-family: inherit;
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 2px;
}

button.crm-sidebar-logout:hover {
  color: var(--sidebar-text);
}

/* Login page */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  box-sizing: border-box;
  background: var(--bg);
}

.login-shell {
  width: 100%;
  max-width: 420px;
}

.login-card label {
  display: block;
  margin-bottom: 4px;
}

.login-card input[type='password'],
.login-card input[type='text'] {
  width: 100%;
  max-width: none;
  box-sizing: border-box;
}

.login-error {
  color: #b91c1c;
  font-size: 14px;
  margin-bottom: 10px;
  line-height: 1.4;
}

.app-shell-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.app-shell-main > .container,
.app-shell-main > .container.container-wide {
  flex: 1;
  width: 100%;
  box-sizing: border-box;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 24px 40px;
}

.container-wide {
  max-width: 1600px;
}

h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 16px;
  color: var(--text);
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

/* Dashboard: view tabs beside main content on wide screens */
.dashboard-layout {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: stretch;
}

@media (min-width: 960px) {
  .dashboard-layout {
    flex-direction: row;
    align-items: flex-start;
    gap: 20px;
  }

  .tabs.tabs--side {
    flex-direction: column;
    flex-wrap: nowrap;
    min-width: 200px;
    max-width: 220px;
    margin-bottom: 0;
  }

  .tabs.tabs--side .tab {
    width: 100%;
    text-align: left;
    box-sizing: border-box;
  }

  .dashboard-layout-main {
    flex: 1;
    min-width: 0;
  }
}

.tab {
  background: #e5e7eb;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 14px;
  cursor: pointer;
}

.tab:hover {
  background: #d1d5db;
}

.tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}

.row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 12px;
}

/* Lead detail: native status select must stay above card sections (some browsers/Electron glitch on stacked cards). */
.lead-status-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  z-index: 4;
}
.lead-status-field select {
  min-width: 10rem;
  max-width: 100%;
  -webkit-appearance: menulist;
  appearance: auto;
}

label {
  font-size: 13px;
  color: var(--muted);
  margin-right: 8px;
}

input[type='text'],
select,
textarea {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  background: #fff;
}

input[type='text'] {
  min-width: 260px;
}

/* Ensure CRM shell inputs accept typing + visible caret (guards against stray attrs / inherited contrast bugs). */
.app-shell-main input[type='text'],
.app-shell-main input[type='search'],
.app-shell-main input[type='tel'],
.app-shell-main input[type='email'],
.app-shell-main input[type='password'],
.app-shell-main textarea {
  color: var(--text);
  caret-color: auto;
  pointer-events: auto;
}

textarea {
  width: 100%;
  min-height: 120px;
  resize: vertical;
}

button {
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s ease, filter 0.15s ease;
}

button:hover:not(:disabled) {
  background: var(--accent-hover);
}

button.secondary {
  background: #1e293b;
}

button.secondary:hover:not(:disabled) {
  background: #334155;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
}

/* Keep wide lead tables inside the card (scroll horizontally if needed) */
.table-scroll-wrap {
  overflow-x: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}

.table-scroll-wrap table {
  margin-top: 0;
}

.dashboard-leads-table {
  min-width: 640px;
}

/* Call queue / backlog: top-aligned rows; compact action grid */
.dashboard-leads-table--compact th,
.dashboard-leads-table--compact td {
  padding: 6px 8px;
  vertical-align: top;
  font-size: 13px;
}

.dashboard-leads-table--compact .dashboard-address-cell {
  max-width: 11rem;
  line-height: 1.25;
}

.dashboard-leads-table--compact .dashboard-address-cell a {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  word-break: break-word;
  white-space: normal;
}

/* Call queue column order: address, owner, distress, score, primary, secondary, email, conf., … */
.dashboard-leads-table--compact tbody td:nth-child(2),
.dashboard-leads-table--compact tbody td:nth-child(3) {
  max-width: 6.75rem;
  line-height: 1.25;
  word-break: break-word;
}

.dashboard-leads-table--compact tbody td:nth-child(5),
.dashboard-leads-table--compact tbody td:nth-child(6),
.dashboard-leads-table--compact tbody td:nth-child(7),
.dashboard-leads-table--compact tbody td:nth-child(8) {
  max-width: 5.25rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-leads-table--compact .comm-drafts-cell {
  max-width: 9.5rem;
  font-size: 11px;
  line-height: 1.3;
}

.dashboard-leads-table--compact .call-queue-note-cell {
  min-width: 7rem;
  max-width: 9rem;
}

.dashboard-leads-table--compact input.call-queue-quick-note {
  padding: 4px 6px;
  font-size: 12px;
}

/* Many buttons → fixed grid so row height stays predictable (like a dense CRM table) */
.call-queue-actions-cell {
  vertical-align: top;
  min-width: 0;
  max-width: none;
  width: auto;
}

.call-queue-actions-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, max-content));
  gap: 4px 6px;
  justify-items: stretch;
}

.call-queue-actions-grid > .btn-quick,
.call-queue-actions-grid > a.btn-quick,
.call-queue-actions-grid > span.btn-quick {
  padding: 4px 7px;
  font-size: 11px;
  border-radius: 6px;
  text-align: center;
  white-space: nowrap;
}

th,
td {
  border-bottom: 1px solid var(--border);
  padding: 10px 8px;
  text-align: left;
  font-size: 14px;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.muted {
  color: var(--muted);
}

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* Settings page cleanup */
.settings-stack {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.settings-msg {
  margin-bottom: 16px;
  min-height: 1.4em;
}

.settings-file-hint {
  margin-bottom: 16px;
  color: #b45309;
}

.card-title {
  margin: 0 0 8px;
  font-size: 18px;
}

.card-actions {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.settings-subtitle {
  font-size: 16px;
  margin: 18px 0 8px;
}

.settings-subnote {
  font-size: 13px;
  margin-top: 4px;
}

.settings-line {
  margin-top: 8px;
}

.settings-callout {
  margin-top: 16px;
  padding: 14px 16px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.5;
}

.settings-callout-title {
  color: var(--text);
}

.settings-block {
  margin-top: 14px;
}

.settings-pre {
  margin-top: 14px;
  white-space: pre-wrap;
  font-size: 12px;
  max-height: 360px;
  overflow: auto;
}

.settings-inline-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 4px;
}

@media (max-width: 820px) {
  .grid2 {
    grid-template-columns: 1fr;
  }
}

/* Dashboard row + detail quick actions */
.quick-actions-inline,
.quick-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

button.btn-quick,
a.btn-quick {
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 8px;
  white-space: nowrap;
  text-decoration: none;
  display: inline-block;
  box-sizing: border-box;
  border: 1px solid var(--border);
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

a.btn-quick:hover {
  filter: brightness(1.05);
}

button.btn-quick:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

button.btn-quick.btn-danger {
  background: #b91c1c;
}

button.btn-quick.secondary {
  background: #111827;
  border-color: #374151;
}

.actions-cell {
  min-width: 0;
  max-width: 340px;
  vertical-align: top;
  box-sizing: border-box;
}

.actions-cell .quick-actions-inline,
.actions-cell .quick-actions-row {
  max-width: 100%;
}

.call-queue-note-cell {
  min-width: 180px;
  max-width: 320px;
  vertical-align: middle;
}

input.call-queue-quick-note {
  width: 100%;
  box-sizing: border-box;
  padding: 6px 10px;
  font-size: 13px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

input.call-queue-quick-note:disabled {
  opacity: 0.65;
}

.bulk-actions-bar {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
}

.bulk-actions-bar strong {
  color: var(--text);
}

.bulk-actions-bar button.danger {
  color: #fff;
  background: #b91c1c;
  border: 1px solid #991b1b;
}

.bulk-actions-bar button.danger:hover {
  filter: brightness(1.05);
}

.page-nav {
  margin-bottom: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
}

.page-nav-sep {
  color: var(--muted);
  user-select: none;
}

.summary-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 24px;
  margin-bottom: 20px;
  padding: 14px 18px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.summary-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.summary-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.summary-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.page-nav a {
  font-size: 14px;
  font-weight: 600;
}

.health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.health-dl {
  margin: 0;
  display: grid;
  grid-template-columns: minmax(120px, 1fr) 2fr;
  gap: 8px 12px;
  font-size: 14px;
}

.health-dl dt {
  color: var(--muted);
  font-weight: 600;
}

.health-dl dd {
  margin: 0;
}

.health-pre {
  margin: 0;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.notes-cell {
  max-width: 360px;
  min-width: 200px;
  font-size: 13px;
  line-height: 1.4;
  word-break: break-word;
  vertical-align: top;
}

.actions-cell-tight {
  white-space: nowrap;
  vertical-align: middle;
}

a.link-button {
  display: inline-block;
  background: var(--accent);
  color: #fff !important;
  text-decoration: none !important;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
}

a.link-button:hover {
  filter: brightness(1.05);
  text-decoration: none !important;
}

/* Call script modal */
.call-script-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(17, 24, 39, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
}

.call-script-modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow: auto;
  padding: 20px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.12);
}

.call-script-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.call-script-modal-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.call-script-close {
  border: none;
  background: transparent;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  padding: 4px 8px;
  border-radius: 8px;
}

.call-script-close:hover {
  background: var(--bg);
  color: var(--text);
}

.call-script-modal-hint {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.45;
}

.call-script-textarea {
  width: 100%;
  min-height: 220px;
  box-sizing: border-box;
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.5;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  resize: vertical;
  font-family: inherit;
}

.call-script-modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
  align-items: center;
}

.call-script-copy {
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

.call-script-copy:hover {
  filter: brightness(1.05);
}

/* Twilio browser call — floating in-call lead context panel */
.crm-twilio-in-call-panel {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1100;
  width: min(320px, calc(100vw - 32px));
  padding: 14px 16px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.18);
  animation: crmTwilioInCallSlideIn 0.22s ease-out;
}

.crm-twilio-in-call-panel--closing {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

@keyframes crmTwilioInCallSlideIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.crm-twilio-in-call-panel-header {
  margin-bottom: 12px;
}

.crm-twilio-in-call-status {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
}

.crm-twilio-in-call-status[data-status='calling'] {
  color: #b45309;
}

.crm-twilio-in-call-status[data-status='calling']::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
  background: #f59e0b;
  vertical-align: middle;
  animation: crmTwilioPulse 1.2s ease-in-out infinite;
}

.crm-twilio-in-call-status[data-status='connected'] {
  color: #15803d;
}

.crm-twilio-in-call-status[data-status='connected']::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
  background: #22c55e;
  vertical-align: middle;
}

.crm-twilio-in-call-status[data-status='ended'] {
  color: var(--muted);
}

@keyframes crmTwilioPulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.45;
    transform: scale(0.85);
  }
}

.crm-twilio-in-call-lead {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.3;
}

.crm-twilio-in-call-sub {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
}

.crm-twilio-in-call-facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 12px;
  margin: 0 0 14px;
  padding: 0;
}

.crm-twilio-in-call-facts > div {
  min-width: 0;
}

.crm-twilio-in-call-facts dt {
  margin: 0 0 2px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.crm-twilio-in-call-facts dd {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  word-break: break-word;
}

.crm-twilio-in-call-controls {
  display: flex;
  gap: 8px;
}

.crm-twilio-in-call-mute {
  flex: 1;
  padding: 9px 14px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
}

.crm-twilio-in-call-mute:hover:not(:disabled) {
  background: #f8fafc;
}

.crm-twilio-in-call-mute:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.crm-twilio-in-call-mute--active {
  border-color: #fde68a;
  background: #fffbeb;
  color: #b45309;
}

.crm-twilio-in-call-hangup {
  flex: 1;
  padding: 9px 14px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 10px;
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: #b91c1c;
  cursor: pointer;
}

.crm-twilio-in-call-hangup:hover {
  background: #fee2e2;
}

.crm-twilio-in-call-actions {
  display: flex;
  gap: 8px;
}

.crm-twilio-in-call-accept {
  flex: 1;
  padding: 9px 14px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 10px;
  border: 1px solid #bbf7d0;
  background: #f0fdf4;
  color: #15803d;
  cursor: pointer;
}

.crm-twilio-in-call-accept:hover {
  background: #dcfce7;
}

.crm-twilio-in-call-reject {
  flex: 1;
  padding: 9px 14px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 10px;
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: #b91c1c;
  cursor: pointer;
}

.crm-twilio-in-call-reject:hover {
  background: #fee2e2;
}

/* Lead detail: communication drafts (SMS + voicemail) */
.comm-drafts-inline {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.comm-draft-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.comm-draft-textarea {
  width: 100%;
  box-sizing: border-box;
  font-size: 13px;
  line-height: 1.45;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  resize: vertical;
  min-height: 72px;
  background: #fafbfc;
  color: var(--text);
}

/* Call queue: compact draft preview */
.comm-drafts-cell {
  max-width: 300px;
  font-size: 12px;
  line-height: 1.35;
  vertical-align: top;
  color: var(--muted);
}

.comm-drafts-cell .draft-prev {
  margin-bottom: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.comm-drafts-cell .draft-prev .draft-label {
  color: var(--muted);
  font-weight: 600;
  margin-right: 4px;
}

.comm-actions-row,
.outcome-buttons-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.outcome-buttons-row {
  margin-bottom: 0;
}

a.btn-quick.is-disabled {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

.comm-actions-comm,
.comm-actions-outcomes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.comm-actions-outcomes {
  margin-top: 8px;
}

.comm-history-list {
  list-style: none;
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fafbfc;
}

.comm-history-item {
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.comm-history-item:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.readonly-input {
  background: #f3f4f6;
  color: var(--muted);
  cursor: default;
}

.pipeline-history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 13px;
  line-height: 1.45;
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fafbfc;
}

.pipeline-hist-item {
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.pipeline-hist-item:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

/* Kanban */
.kanban-board {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  overflow-x: auto;
  padding-bottom: 16px;
  margin-top: 12px;
}

.kanban-column {
  flex: 0 0 260px;
  min-width: 240px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  max-height: calc(100vh - 140px);
  display: flex;
  flex-direction: column;
}

.kanban-column-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 13px;
}

.kanban-column-count {
  background: var(--bg);
  color: var(--muted);
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
}

.kanban-cards {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  min-height: 72px;
}

.kanban-cards.kanban-drop-hover {
  background: #eff6ff;
  outline: 1px dashed var(--accent);
}

.kanban-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 8px;
  cursor: grab;
  font-size: 13px;
}

.kanban-card.dragging {
  opacity: 0.55;
}

.kanban-card-title {
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  display: block;
  margin-bottom: 4px;
}

.kanban-card-owner,
.kanban-card-meta {
  font-size: 12px;
  margin-top: 2px;
}

.kanban-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}
.kanban-card-actions .btn-quick {
  padding: 4px 8px;
  font-size: 11px;
}

a.button-link {
  background: var(--accent);
  color: #fff !important;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  display: inline-block;
  text-decoration: none;
  font-weight: 600;
}

a.button-link:hover {
  text-decoration: none;
  filter: brightness(0.95);
}

.buyers-table th {
  white-space: nowrap;
}

.matched-buyers-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.matched-buyer-row {
  padding: 10px 12px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.matched-buyer-title {
  font-size: 14px;
  margin-bottom: 4px;
}

.deal-calc-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.deal-calc-row:last-child {
  border-bottom: none;
}

.deal-calc-row strong {
  font-variant-numeric: tabular-nums;
}

.call-script-modal.buyer-blast-modal {
  max-width: 640px;
  max-height: 92vh;
  overflow-y: auto;
}

.buyer-blast-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.buyer-blast-table th,
.buyer-blast-table td {
  padding: 8px 6px;
  vertical-align: top;
}

.buyer-blast-table th {
  font-size: 12px;
}

.buyer-response-btn-active {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.buyer-response-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: #166534;
  background: #dcfce7;
  padding: 2px 8px;
  border-radius: 6px;
  margin-left: 4px;
}

@media (max-width: 900px) {
  .app-shell {
    flex-direction: column;
  }

  .app-sidebar {
    position: relative;
    width: 100%;
    min-height: 0;
    flex: 0 0 auto;
    padding: 14px 0 10px;
    box-shadow: 0 4px 20px rgba(15, 23, 42, 0.12);
  }

  .crm-sidebar-brand {
    padding: 0 16px 12px;
    margin-bottom: 8px;
  }

  .crm-sidebar-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 12px;
  }

  .crm-sidebar-link {
    padding: 8px 12px;
    margin-bottom: 0;
    font-size: 13px;
  }

  .crm-sidebar-foot {
    display: none;
  }

  .container {
    padding: 20px 16px 32px;
  }
}

/* Upload lists */
.list-upload-dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  background: var(--card);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.list-upload-dropzone:hover,
.list-upload-dropzone:focus-visible {
  outline: none;
  border-color: var(--accent);
  background: rgba(37, 99, 235, 0.04);
}
.list-upload-dropzone.is-dragover {
  border-color: var(--accent);
  background: rgba(37, 99, 235, 0.08);
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.data-table th,
.data-table td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}
.data-table thead th {
  background: #f8fafc;
  font-weight: 600;
  font-size: 12px;
  color: var(--muted);
}

/* Calendar */
.calendar-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 4px;
}
.calendar-toolbar-primary {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.calendar-period-title {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
.calendar-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.calendar-view-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--card);
}
.calendar-view-btn {
  border: none;
  background: transparent;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.calendar-view-btn.is-active {
  background: var(--accent);
  color: #fff;
}
.calendar-month-dow {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
  margin-bottom: 4px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
}
.calendar-month-dow-cell {
  text-align: center;
  padding: 4px 0;
}
.calendar-grid {
  display: grid;
  gap: 6px;
  margin-bottom: 24px;
}
.calendar-grid--month {
  grid-template-columns: repeat(7, minmax(0, 1fr));
}
.calendar-grid--week {
  grid-template-columns: repeat(7, minmax(0, 1fr));
}
@media (max-width: 900px) {
  .calendar-grid--month,
  .calendar-grid--week {
    grid-template-columns: 1fr;
  }
  .calendar-month-dow {
    display: none;
  }
}
.calendar-week {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 24px;
}
@media (max-width: 900px) {
  .calendar-week {
    grid-template-columns: 1fr;
  }
}
.calendar-day {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 120px;
  padding: 8px;
  box-shadow: var(--shadow-sm);
}
.calendar-day--today {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.calendar-day--other-month {
  opacity: 0.55;
  background: #f1f5f9;
}
.calendar-day--drop-target {
  border-color: var(--accent);
  background: rgba(37, 99, 235, 0.08);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.25);
}
.calendar-day--move-target {
  cursor: pointer;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.35);
}
.calendar-day-head {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.calendar-day-head:hover {
  color: var(--accent);
}
.calendar-move-hint {
  margin: 0 0 10px;
  padding: 8px 12px;
  border-radius: var(--radius);
  background: rgba(37, 99, 235, 0.1);
  border: 1px solid rgba(37, 99, 235, 0.25);
  font-size: 13px;
  color: var(--text);
}
.calendar-day-panel {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.calendar-day-panel[hidden] {
  display: none !important;
}
.calendar-day-panel-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}
.calendar-day-panel-inner {
  position: relative;
  z-index: 1;
  width: min(520px, 100%);
  max-height: min(80vh, 640px);
  overflow: auto;
  padding: 16px 18px;
}
.calendar-day-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.calendar-day-panel-title {
  margin: 0;
  font-size: 1.15rem;
}
.calendar-day-panel-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.calendar-day-panel-foot {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.calendar-add-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.calendar-add-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  font-weight: 600;
}
.calendar-add-field input,
.calendar-add-field select {
  font: inherit;
  font-weight: 400;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
}
.calendar-add-lead-results {
  margin-top: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: 180px;
  overflow: auto;
  background: var(--card);
}
.calendar-add-lead-option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 400;
  transition: background 0.12s ease;
}
.calendar-add-lead-option:last-child {
  border-bottom: none;
}
.calendar-add-lead-option:hover,
.calendar-add-lead-option.is-selected {
  background: rgba(37, 99, 235, 0.08);
  color: var(--text);
}
.calendar-add-form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.calendar-day-panel-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: #f8fafc;
}
.calendar-day-panel-item-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.calendar-day-panel-time {
  font-weight: 700;
  font-size: 13px;
  color: var(--accent);
  white-space: nowrap;
}
.calendar-day-panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  align-items: center;
}
.calendar-add-form-message {
  color: #b91c1c;
}
.calendar-add-form-message.is-success {
  color: #15803d;
}
.calendar-day-panel-delete {
  color: #b91c1c;
}
.calendar-day-panel-actions input[type="time"] {
  font: inherit;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.calendar-day-num {
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
}
.calendar-day-weekday {
  font-size: 11px;
  color: var(--muted);
  margin-left: 6px;
}
.calendar-day-events {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.calendar-day-empty {
  font-size: 13px;
}
.calendar-event {
  display: block;
  text-decoration: none;
  color: inherit;
  border-radius: 6px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  background: #f8fafc;
  font-size: 13px;
  line-height: 1.35;
  cursor: grab;
  user-select: none;
}
.calendar-event--dragging {
  opacity: 0.45;
  cursor: grabbing;
}
.calendar-event-link {
  display: inline-block;
  margin-top: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  cursor: pointer;
}
.calendar-event-link:hover {
  text-decoration: underline;
}
.calendar-event-move {
  display: inline-block;
  margin-top: 4px;
  margin-left: 8px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.calendar-event-delete {
  display: inline-block;
  margin-top: 4px;
  margin-left: 8px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  color: #b91c1c;
}
.calendar-event-delete:hover {
  color: #991b1b;
}
.calendar-event:hover {
  border-color: var(--accent);
  background: rgba(37, 99, 235, 0.06);
}
.calendar-event-type {
  display: block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 2px;
}
.calendar-event--closing .calendar-event-type {
  color: #047857;
}
.calendar-event--follow-up .calendar-event-type {
  color: #1d4ed8;
}
.calendar-event-title {
  font-weight: 600;
  display: block;
}
.calendar-event-addr,
.calendar-event-phone,
.calendar-event-notes {
  font-size: 12px;
  margin-top: 2px;
}
.calendar-agenda-title {
  font-size: 1.1rem;
  margin: 0 0 12px;
}
.calendar-agenda {
  padding: 16px;
}
.calendar-agenda-group {
  margin-bottom: 16px;
}
.calendar-agenda-group:last-child {
  margin-bottom: 0;
}
.calendar-agenda-date {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 8px;
  color: var(--text);
}

