/*
 * LeadFlow visual polish
 * A restrained, professional skin over the existing CRM structure.
 * Layout, controls, content order, and behavior intentionally remain unchanged.
 */

:root {
  --bg:          oklch(0.968 0.006 252);
  --surface:     oklch(0.992 0.003 252);
  --surface-2:   oklch(0.955 0.008 252);
  --surface-3:   oklch(0.918 0.011 252);
  --border:      oklch(0.838 0.012 252);
  --border-sub:  oklch(0.900 0.009 252);
  --text-1:      oklch(0.235 0.025 252);
  --text-2:      oklch(0.400 0.022 252);
  --text-3:      oklch(0.535 0.018 252);
  --blue:        oklch(0.500 0.165 258);
  --blue-h:      oklch(0.440 0.160 258);
  --blue-tint:   oklch(0.945 0.028 258);
  --blue-mid:    oklch(0.785 0.065 258);
  --blue-text:   oklch(0.395 0.130 258);
  --green:       oklch(0.505 0.120 148);
  --green-h:     oklch(0.445 0.115 148);
  --green-tint:  oklch(0.950 0.025 148);
  --green-text:  oklch(0.375 0.095 148);
  --amber:       oklch(0.625 0.115 72);
  --amber-tint:  oklch(0.962 0.028 72);
  --amber-text:  oklch(0.425 0.095 72);
  --red:         oklch(0.520 0.165 26);
  --red-tint:    oklch(0.960 0.025 26);
  --red-text:    oklch(0.405 0.135 26);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  line-height: 1.45;
  background: var(--bg);
}

button,
input,
select,
textarea {
  font-family: inherit;
}

button,
a,
input,
select,
textarea {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

/* App chrome */
.topbar {
  min-height: 64px;
  padding: 10px 24px;
  gap: 20px;
  border-color: var(--border-sub);
  box-shadow: 0 1px 0 oklch(0.300 0.015 252 / 0.03);
}

.topbar-logo {
  gap: 10px;
  border-radius: 8px;
}

.topbar-leadflow-wordmark {
  width: 136px;
  max-height: 29px;
}

.topbar-logo-mark,
.topbar-logo-mark.is-leadflow-default,
.topbar-logo-mark img {
  border-radius: 8px;
  box-shadow: none;
}

.topbar-logo-mark:not(.has-logo):not(.is-leadflow-default) {
  background: var(--blue);
}

.topbar-search-wrap input {
  height: 40px;
  padding-left: 39px;
  border-color: var(--border-sub);
  border-radius: 9px;
  background: var(--surface-2);
}

.topbar-search-wrap input:hover {
  border-color: var(--border);
}

.topbar-search-wrap input:focus {
  border-color: var(--blue-mid);
  background: var(--surface);
  box-shadow: 0 0 0 3px oklch(0.500 0.165 258 / 0.10);
}

.search-clear {
  border-radius: 6px;
}

.topbar-tool-group {
  height: 40px;
  padding: 3px;
  border-color: var(--border-sub);
  border-radius: 9px;
  background: var(--surface);
  box-shadow: none;
}

.btn-icon {
  height: 32px;
  border-radius: 6px;
  font-weight: 600;
}

.btn-icon.btn-icon-square {
  width: 32px;
}

.topbar-menu {
  padding: 6px;
  border-radius: 10px;
  box-shadow: 0 14px 36px oklch(0.250 0.018 252 / 0.16);
}

.topbar-menu-item,
.lead-context-item {
  border-radius: 6px;
  font-weight: 600;
}

.main {
  padding-top: 28px;
}

/* Familiar controls, with one consistent shape language */
.btn-primary,
.btn-secondary,
.btn-danger,
.btn-settings,
.btn-view,
.btn-add-tag,
.btn-add-reminder,
.btn-done-alert,
.btn-dismiss-alert,
.bulk-mini-btn,
.filter-toggle-btn,
.btn-filter-clear,
.reminder-time-btn,
.reminder-type-btn,
.btn-reminder-done,
.btn-reminder-del,
.lead-card-call,
.lead-card-sms,
.lead-card-action-btn,
.lead-card-menu-btn,
.queue-call-link,
.quick-outcome-btn,
.call-outcome-btn,
.reminder-toast-action,
.reminder-toast-dismiss,
.email-template-variable-btn,
.email-drafts-nav-btn {
  border-radius: 7px;
}

.btn-add-note,
.btn-update-followup,
.today-empty-action,
.btn-copy,
.btn-dial,
.btn-sms,
.btn-called,
.active-call-banner button {
  border-radius: 7px;
}

.btn-primary {
  min-height: 40px;
  padding-inline: 16px;
  font-weight: 650;
  box-shadow: 0 1px 2px oklch(0.280 0.055 258 / 0.18);
}

.btn-primary:hover {
  box-shadow: 0 1px 2px oklch(0.280 0.055 258 / 0.22);
}

.btn-primary:active,
.bulk-mini-btn.primary:active,
.lead-card-call:active,
.queue-call-link:active {
  background: oklch(0.415 0.155 258);
}

.btn-secondary {
  padding: 8px 14px;
  border-color: var(--border);
  font-weight: 600;
}

.btn-danger {
  border-radius: 7px;
  font-weight: 600;
}

.row-action-btn {
  width: 30px;
  height: 30px;
  border-color: var(--border-sub);
  border-radius: 7px;
  background: transparent;
  transition: background 160ms cubic-bezier(0.22, 1, 0.36, 1),
              border-color 160ms cubic-bezier(0.22, 1, 0.36, 1),
              color 160ms cubic-bezier(0.22, 1, 0.36, 1);
}

.row-action-btn:hover {
  transform: none;
  box-shadow: none;
}

/* Tabs remain in the same place, but read as navigation rather than chips */
.tab-bar {
  display: flex;
  width: 100%;
  gap: 22px;
  margin-bottom: 24px;
  padding: 0;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.tab-btn,
.tab-btn.today-tab {
  position: relative;
  margin: 0;
  padding: 9px 1px 11px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text-3);
  font-size: 0.84rem;
  font-weight: 600;
  box-shadow: none;
}

.tab-btn::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 2px;
  background: transparent;
}

.tab-btn:hover,
.tab-btn.today-tab:hover {
  border: 0;
  background: transparent;
  color: var(--text-1);
  box-shadow: none;
}

.tab-btn.active,
.tab-btn.today-tab.active {
  border: 0;
  background: transparent;
  color: var(--text-1);
  box-shadow: none;
}

.tab-btn.active::after {
  background: var(--blue);
}

/* Page hierarchy */
.today-title-bar,
.call-queue-head {
  margin-bottom: 18px;
}

.today-title-bar h1,
.call-queue-head h1 {
  font-size: 1.38rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.today-title-sub,
.call-queue-sub {
  color: var(--text-2);
}

.section-header {
  margin-bottom: 12px;
}

.section-header h2 {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.lead-count,
.queue-pill,
.email-drafts-summary-pill {
  border-radius: 6px;
  background: var(--surface-2);
}

/* Metrics feel like one instrument panel, not four floating cards */
.metrics-grid {
  gap: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.metric-card {
  min-width: 0;
  padding: 15px 17px;
  border: 0;
  border-right: 1px solid var(--border-sub);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.metric-card:last-child {
  border-right: 0;
}

.metric-label {
  margin-bottom: 7px;
  color: var(--text-2);
  font-weight: 600;
}

.metric-value {
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
}

/* Filters and status controls */
.today-filter-row,
.tag-filter-bar {
  gap: 6px;
}

.today-filter-chip,
.tag-filter-chip {
  height: 32px;
  padding: 0 11px;
  border-width: 1px;
  border-radius: 7px;
  background: var(--surface);
  font-weight: 600;
  transition: background 160ms cubic-bezier(0.22, 1, 0.36, 1),
              border-color 160ms cubic-bezier(0.22, 1, 0.36, 1),
              color 160ms cubic-bezier(0.22, 1, 0.36, 1);
}

.today-filter-chip:hover,
.tag-filter-chip:hover {
  border-color: var(--border);
  background: var(--surface-2);
}

.today-filter-chip.active,
.tag-filter-chip.active {
  border-color: var(--blue-mid);
  background: var(--blue-tint);
  color: var(--blue-text);
  box-shadow: none;
}

.filter-toolbar {
  margin-bottom: 10px;
}

.filter-panel {
  gap: 10px;
  padding: 10px;
  border-radius: 10px;
  background: var(--surface);
  box-shadow: none;
}

.filter-block {
  padding: 12px;
  border-color: var(--border-sub);
  border-radius: 8px;
  background: var(--surface-2);
}

.filter-block-title h3,
.filter-field label,
.range-filter-label {
  color: var(--text-2);
  font-weight: 700;
}

.save-name-input,
.view-select,
.filter-toggle-btn,
.bulk-action-input,
.bulk-action-select,
.col-view-tools select,
.col-view-tools input,
.custom-field-tools input,
.custom-field-tools select {
  border-radius: 7px;
}

.filter-field input,
.filter-field select,
.tag-query-row input,
.tag-query-row select,
.range-filter-box {
  border-radius: 7px;
  background-color: var(--surface);
}

.tag-filter-chip.active,
.today-filter-chip.active,
.filter-toggle-btn.active {
  box-shadow: none;
}

.reminder-type-btn {
  transition: background 160ms cubic-bezier(0.22, 1, 0.36, 1),
              border-color 160ms cubic-bezier(0.22, 1, 0.36, 1),
              color 160ms cubic-bezier(0.22, 1, 0.36, 1);
}

/* Tables */
.table-wrap {
  border-radius: 10px;
  box-shadow: none;
}

thead tr {
  background: var(--surface-2);
}

th {
  padding: 11px 8px;
  color: var(--text-2);
  font-size: 0.645rem;
  font-weight: 700;
  letter-spacing: 0.045em;
}

tbody tr {
  transition: background 130ms cubic-bezier(0.22, 1, 0.36, 1);
}

tbody tr:hover {
  background: oklch(0.965 0.008 252);
}

tbody tr.row-selected,
tbody tr.row-selected:hover {
  background: var(--blue-tint);
}

td {
  padding-block: 9px;
  color: var(--text-2);
  font-size: 0.805rem;
}

td.editable:hover {
  background: oklch(0.952 0.010 252 / 0.65);
}

.profile-link,
.cell-link {
  font-weight: 600;
}

.badge-type,
.action-badge {
  border-radius: 5px;
  font-weight: 650;
}

.tag-pill,
.status-badge,
.outcome-badge,
.flag-badge,
.queue-priority-badge,
.active-call-badge,
.profile-record-count,
.filter-count-dot {
  box-shadow: none;
}

.bulk-bar {
  top: 74px;
  border-radius: 9px;
  background: oklch(0.992 0.003 252 / 0.98);
  box-shadow: 0 10px 26px oklch(0.250 0.018 252 / 0.12);
  backdrop-filter: none;
}

.bulk-info {
  border-radius: 6px;
}

/* Daily work lists */
.today-group {
  margin-bottom: 26px;
}

.today-group-header {
  margin-bottom: 8px;
}

.today-group-label,
.today-section-title,
.session-stat-label {
  font-weight: 700;
  letter-spacing: 0.055em;
}

.lead-cards-list,
.call-queue-list {
  gap: 6px;
}

.lead-card,
.call-queue-card,
.today-lead-row,
.today-empty {
  border-radius: 9px;
  box-shadow: none;
}

.lead-card {
  padding: 12px 14px;
}

.lead-card:hover,
.call-queue-card:hover,
.today-lead-row:hover {
  border-color: var(--border);
  background: oklch(0.968 0.008 252);
  box-shadow: none;
}

.lead-card.is-hot {
  background: var(--surface);
}

.lead-card.is-overdue,
.call-queue-card.is-callback {
  border-color: oklch(0.805 0.060 55);
}

.lead-avatar {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  font-weight: 700;
}

.lead-card-name {
  font-weight: 650;
}

.lead-context-menu {
  border-radius: 9px;
  box-shadow: 0 14px 34px oklch(0.250 0.018 252 / 0.16);
}

.session-stat,
.call-review-panel,
.call-review-item {
  border-radius: 8px;
  box-shadow: none;
}

.call-queue-card {
  padding: 13px 14px;
}

/* Alerts and feedback */
.alert-section,
.load-error,
.reminder-toast,
.active-call-banner,
.reminder-add-form,
.empty-state-icon,
.today-empty-icon {
  border-radius: 9px;
  box-shadow: none;
}

.alert-overdue {
  background: var(--amber-tint);
}

.alert-reminders {
  background: var(--blue-tint);
}

.overdue-item,
.reminder-alert-item {
  border-radius: 7px;
  box-shadow: none;
}

.reminder-toast {
  box-shadow: 0 16px 40px oklch(0.250 0.018 252 / 0.18);
}

/* Forms */
input,
select,
textarea {
  border-color: var(--border);
  border-radius: 7px;
  background: var(--surface);
}

input:hover,
select:hover,
textarea:hover {
  border-color: oklch(0.760 0.015 252);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px oklch(0.500 0.165 258 / 0.10);
}

label {
  color: var(--text-2);
  font-weight: 600;
}

.types-checkbox-row,
.lead-flag-row {
  border-radius: 7px;
}

input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--blue);
}

/* Modals and record detail */
.modal-overlay {
  background: oklch(0.170 0.012 252 / 0.48);
}

.modal {
  border-radius: 13px;
  box-shadow: 0 18px 52px oklch(0.220 0.018 252 / 0.22);
  animation: crm-modal-in 180ms cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes crm-modal-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-header {
  padding: 17px 20px 14px;
}

.modal-header h3 {
  font-weight: 700;
  letter-spacing: -0.015em;
}

.modal-close {
  border-radius: 7px;
}

.modal-body {
  padding: 18px 20px;
}

.modal-footer {
  padding: 13px 20px;
  border-color: var(--border-sub);
}

.modal-section h4 {
  color: var(--text-2);
}

.reminder-item,
.note-item,
.profile-note-add,
.profile-file-note,
.profile-reminder-composer,
.col-settings-row,
.brand-section,
.brand-upload,
.team-row,
.account-email,
.auth-optional-brand,
.auth-message.auth-success {
  border-radius: 8px;
}

.brand-avatar-preview {
  border-radius: 8px;
}

.brand-profile-preview {
  border-radius: 999px;
}

.profile-record-tabs {
  gap: 18px;
}

.profile-record-tab {
  font-weight: 600;
}

.profile-activity-item::before {
  background: var(--blue);
  box-shadow: 0 0 0 1px var(--blue);
}

/* Authentication */
.auth-screen {
  padding-top: 54px;
  background: var(--bg);
}

.auth-card,
.auth-card.auth-create-mode {
  width: min(420px, 100%);
  padding: 28px 30px 30px;
  border-color: var(--border);
  border-radius: 14px;
  box-shadow: 0 16px 44px oklch(0.250 0.018 252 / 0.14);
}

.auth-brand {
  gap: 9px;
  margin-bottom: 16px;
}

.auth-brand .topbar-logo-mark {
  order: 0;
  border-radius: 10px;
}

.auth-brand h2 {
  order: 1;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.auth-subtitle {
  color: var(--text-2);
}

.auth-mode-tabs,
.account-tabs {
  gap: 0;
  padding: 3px;
  border-color: var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.auth-mode-tab,
.account-tab {
  border-radius: 6px;
  font-weight: 650;
}

.auth-mode-tab.active,
.account-tab.active {
  color: var(--text-1);
  box-shadow: 0 1px 2px oklch(0.300 0.015 252 / 0.10);
}

.auth-card label {
  margin-top: 13px;
  color: var(--text-2);
  font-size: 0.69rem;
  font-weight: 700;
  letter-spacing: 0.045em;
}

.auth-card input {
  height: 42px;
  padding-inline: 13px;
  border-radius: 7px;
  background: var(--surface);
}

.auth-actions {
  margin-top: 18px;
}

.auth-actions .btn-primary,
.auth-actions .btn-secondary {
  height: 40px;
}

.auth-link-btn {
  border-radius: 6px;
}

/* Gmail compose follows the same visual system */
.email-drafts-preview-panel,
.gmail-connection-row,
.email-drafts-exclusions {
  border-radius: 9px;
}

.email-drafts-preview-panel,
.gmail-connection-row,
.email-drafts-exclusions {
  background: var(--surface-2);
}

.email-drafts-preview-warning,
.email-send-confirmation {
  border-radius: 7px;
}

/* Bulk Messages companion */
.messages-summary-pill {
  border-radius: 6px;
  font-weight: 700;
}

.messages-grid,
.messages-safety,
.messages-connection,
.messages-pairing {
  border-radius: 9px;
}

.messages-nav-btn:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

@media (max-width: 980px) {
  .bulk-bar {
    top: 74px;
  }
}

@media (max-width: 700px) {
  .topbar {
    padding: 9px 12px;
  }

  .topbar-leadflow-wordmark {
    width: 122px;
  }

  .main {
    padding: 16px 12px 48px;
  }

  .tab-bar {
    gap: 18px;
    margin-bottom: 20px;
    overflow-x: auto;
  }

  .tab-btn,
  .tab-btn.today-tab {
    flex: 0 0 auto;
  }

  .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric-card {
    border-right: 1px solid var(--border-sub);
    border-bottom: 1px solid var(--border-sub);
  }

  .metric-card:nth-child(2n) {
    border-right: 0;
  }

  .metric-card:nth-last-child(-n + 2) {
    border-bottom: 0;
  }

  .lead-card {
    border-radius: 8px;
  }

  .lead-card-actions {
    padding-left: 54px;
  }

  .bulk-bar {
    top: 122px;
    border-radius: 9px;
  }

  .auth-screen {
    padding: 12px;
  }

  .auth-card,
  .auth-card.auth-create-mode {
    padding: 22px 20px 24px;
    border-radius: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
