/*
 *= require_tree .
 *= require_self
 */

/* ---------- BASE ---------- */

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background-color: #f9fafb;
  color: #111827;
  --accent-color: #2563eb;
  --card-shadow: 0 12px 30px rgba(15, 23, 42, 0.06);
}

/* ---------- LAYOUT ---------- */

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

.inline {
  display: inline-block;
}

main.container {
  margin-top: 24px;
}

/* ---------- NAVIGATION (legacy-safe) ---------- */

.app-header {
  background: #111827;
  color: #ffffff;
}

.app-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.logo {
  font-size: 18px;
  font-weight: 600;
}

.nav a {
  color: #d1d5db;
  margin-left: 20px;
  text-decoration: none;
  font-size: 14px;
}

.nav a:hover {
  color: #ffffff;
}

/* ---------- STATUS BADGES (AUTHORITATIVE) ---------- */

.status-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  text-transform: capitalize;
  letter-spacing: 0.01em;
}

.contact-link {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: #cbd5e1;
  text-underline-offset: 2px;
}

.contact-link:hover {
  text-decoration-color: #94a3b8;
}

.returning-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* Status colors - single source of truth */
.status-new {
  background: #eef2ff;
  color: #3730a3;
}

.status-contacted {
  background: #ecfeff;
  color: #155e75;
}

.status-scheduled {
  background: #ecfdf5;
  color: #065f46;
}

.status-completed {
  background: #f0fdf4;
  color: #166534;
}

.status-lost {
  background: #fef2f2;
  color: #b91c1c;
}

.status-canceled {
  background: #fef2f2;
  color: #b91c1c;
}

/* ---------- GLOBAL COMPONENTS ---------- */

/* Buttons: Primary = main action, Secondary = supporting, Destructive = irreversible, Tertiary = low emphasis */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0.55rem 1rem;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  font-family: inherit;
  background: transparent;
  transition: background 150ms ease, border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.btn-primary {
  background: var(--accent-color);
  color: #ffffff;
  border-color: var(--accent-color);
  box-shadow: 0 10px 22px rgba(37, 99, 235, 0.18);
}

.btn-primary:hover {
  background: #1d4ed8;
  border-color: #1d4ed8;
}

.btn-secondary {
  background: #ffffff;
  color: #0f172a;
  border-color: #e2e8f0;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

.btn-secondary:hover {
  border-color: #cbd5f5;
  background: #f8fafc;
}

.btn-tertiary {
  background: transparent;
  color: #334155;
  border-color: transparent;
}

.btn-tertiary:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.btn-destructive {
  background: #dc2626;
  color: #ffffff;
  border-color: #dc2626;
}

.btn-destructive:hover {
  background: #b91c1c;
  border-color: #b91c1c;
}

.btn-pill {
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  font-weight: 500;
  background: #ffffff;
  color: #0f172a;
  border-color: #e2e8f0;
}

.btn-pill.is-active {
  background: var(--accent-color);
  color: #ffffff;
  border-color: var(--accent-color);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.16);
}

.btn-block {
  width: 100%;
}

.btn-menu {
  justify-content: flex-start;
}

.btn-icon {
  gap: 8px;
  letter-spacing: -0.01em;
}

.btn-icon__glyph {
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
}

.policy-page {
  padding: 24px 0 48px;
}

.policy-card {
  max-width: 860px;
  margin: 0 auto;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  box-shadow: var(--card-shadow);
  padding: 32px;
}

.policy-title {
  margin: 0 0 12px 0;
  font-size: 28px;
  letter-spacing: -0.02em;
}

.policy-intro {
  margin: 0 0 20px 0;
  color: #6b7280;
  font-size: 15px;
  line-height: 1.7;
}

.policy-section + .policy-section {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #e5e7eb;
}

.policy-section h2 {
  margin: 0 0 8px 0;
  font-size: 16px;
  letter-spacing: -0.01em;
}

.policy-section p {
  margin: 0;
  color: #374151;
  font-size: 14px;
  line-height: 1.7;
}

.app-footer {
  border-top: 1px solid #e5e7eb;
  background: #ffffff;
  margin-top: 24px;
}

.app-footer__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #6b7280;
  font-size: 13px;
}

.app-footer__links {
  display: flex;
  align-items: center;
  gap: 16px;
}

.app-footer__link {
  color: #1f2937;
  text-decoration: none;
  font-weight: 600;
}

.app-footer__link:hover {
  color: #111827;
}
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  padding: 20px 24px;
  box-shadow: var(--card-shadow);
}

.page-title {
  margin: 0;
  font-size: 28px;
  letter-spacing: -0.02em;
}

.page-subtitle {
  margin: 6px 0 0 0;
  color: #6b7280;
  font-size: 14px;
}

.panel {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  box-shadow: var(--card-shadow);
  padding: 20px;
}

.panel + .panel {
  margin-top: 20px;
}

.filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.table-shell {
  margin-top: 16px;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  box-shadow: var(--card-shadow);
  overflow: hidden;
}

.leads-table-shell {
  max-height: 520px;
  overflow-y: scroll;
  scroll-behavior: smooth;
  scrollbar-gutter: stable;
}

.leads-table-shell .dash-table {
  table-layout: fixed;
  width: 100%;
}

.leads-table-shell .dash-table th:nth-child(1),
.leads-table-shell .dash-table td:nth-child(1) {
  width: 30%;
}

.leads-table-shell .dash-table th:nth-child(2),
.leads-table-shell .dash-table td:nth-child(2) {
  width: 18%;
}

.leads-table-shell .dash-table th:nth-child(3),
.leads-table-shell .dash-table td:nth-child(3) {
  width: 16%;
}

.leads-table-shell .dash-table th:nth-child(4),
.leads-table-shell .dash-table td:nth-child(4) {
  width: 16%;
}

.leads-table-shell .dash-table th:nth-child(5),
.leads-table-shell .dash-table td:nth-child(5) {
  width: 20%;
}

.contacts-table-shell {
  max-height: 520px;
  overflow-y: scroll;
  scroll-behavior: smooth;
  scrollbar-gutter: stable;
}

.contacts-table-shell .dash-table {
  table-layout: fixed;
  width: 100%;
}

.contacts-table-shell .dash-table th:nth-child(1),
.contacts-table-shell .dash-table td:nth-child(1) {
  width: 36%;
}

.contacts-table-shell .dash-table th:nth-child(2),
.contacts-table-shell .dash-table td:nth-child(2) {
  width: 16%;
}

.contacts-table-shell .dash-table th:nth-child(3),
.contacts-table-shell .dash-table td:nth-child(3) {
  width: 28%;
}

.contacts-table-shell .dash-table th:nth-child(4),
.contacts-table-shell .dash-table td:nth-child(4) {
  width: 20%;
}

body.contacts-index {
  overflow: hidden;
}

main.contacts-index-main {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 120px);
}

main.contacts-index-main .contacts-results {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

main.contacts-index-main .contacts-table-shell {
  max-height: 400px;
  overflow-y: scroll;
  scroll-behavior: smooth;
  scrollbar-gutter: stable;
}

.form-card {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  box-shadow: var(--card-shadow);
  padding: 24px;
}

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

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.settings-form {
  --settings-grid-gap: 1.5rem;
  --settings-grid-column-gap: 2rem;
}

.settings-grid {
  /* Settings page uses a 4-column grid; most fields span 2 columns for uniform rows. */
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--settings-grid-gap) var(--settings-grid-column-gap);
  width: 100%;
  max-width: 980px;
  margin-right: auto;
}

.settings-span-2 {
  grid-column: span 2;
}

.settings-span-4 {
  grid-column: 1 / -1;
}

@media (max-width: 980px) {
  .settings-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .settings-span-2,
  .settings-span-4 {
    grid-column: span 2;
  }
}

@media (max-width: 640px) {
  .settings-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .settings-span-2,
  .settings-span-4 {
    grid-column: span 1;
  }
}
.settings-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.settings-section + .settings-section {
  margin-top: 18px;
}

.settings-section-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}

.settings-section-title--compact {
  margin-bottom: 0;
}

.settings-divider {
  margin: 18px 0;
  border: none;
  border-top: 1px solid #e5e7eb;
}

.settings-help {
  margin: 0;
  color: #6b7280;
  font-size: 13px;
  line-height: 1.6;
}

.settings-help--tight {
  margin-top: 4px;
}

.settings-list {
  font-size: 13px;
  color: #475569;
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 6px;
}

.settings-actions {
  display: flex;
  align-items: center;
}

.settings-section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

.settings-card {
  padding: 20px;
  margin-top: 12px;
}

.form-label {
  font-weight: 600;
  color: #0f172a;
  font-size: 14px;
}

.input-control {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  font-size: 14px;
  background: #f8fafc;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.settings-form .input-control {
  padding: 0.4rem 0.65rem;
}

.input-control:focus {
  outline: none;
  border-color: var(--accent-color);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.16);
}

.activity-log-comment {
  resize: none;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.activity-log-scroll {
  max-height: 420px;
  overflow-y: auto;
  scroll-behavior: smooth;
  padding-right: 0.75rem;
}

.activity-log-scroll + form,
.activity-log-scroll + turbo-frame {
  padding-right: 0.75rem;
}

.activity-log-scroll + turbo-frame {
  display: block;
}

.section-heading {
  margin: 0 0 10px 0;
  font-size: 18px;
  letter-spacing: -0.01em;
}

@media (max-width: 720px) {
  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ---------- DASHBOARD ---------- */

.dash-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  padding: 20px 24px;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  box-shadow: var(--card-shadow);
}

.dash-title {
  margin: 0;
  font-size: 28px;
  letter-spacing: -0.02em;
}

.dash-subtitle {
  margin: 6px 0 0 0;
  color: #6b7280;
  font-size: 14px;
}

.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.dash-card {
  background: #ffffff;
  padding: 20px;
  border-radius: 16px;
  border: 1px solid #e5e7eb;
  box-shadow: var(--card-shadow);
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.dash-card:hover {
  transform: translateY(-4px);
  border-color: rgba(37, 99, 235, 0.24);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.12);
}

.dash-card__label {
  font-size: 13px;
  color: #6b7280;
  letter-spacing: 0.01em;
}

.dash-card__value {
  font-size: 36px;
  font-weight: 700;
  margin: 8px 0 12px 0;
  letter-spacing: -0.01em;
}

.dash-card__link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent-color);
  font-weight: 600;
  text-decoration: none;
  font-size: 14px;
  transition: color 150ms ease, transform 150ms ease;
}

.dash-card__link:hover {
  color: #1d4ed8;
  transform: translateX(2px);
}

.dash-section {
  margin-top: 32px;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  box-shadow: var(--card-shadow);
  padding: 20px;
}

.dash-table {
  width: 100%;
  border-collapse: collapse;
}

.dash-table thead {
  background: #f8fafc;
}

.dash-table th {
  padding: 14px;
  font-size: 13px;
  color: #6b7280;
  text-align: left;
}

.dash-table td {
  padding: 14px;
  font-size: 14px;
  color: #0f172a;
  border-top: 1px solid #e5e7eb;
}

.dash-table tr {
  transition: background 140ms ease;
}

.dash-table tr:hover {
  background: #f8fafc;
}

.lead-row.is-new,
.contact-row.is-new {
  animation: row-enter 0.35s ease-out;
}

@keyframes row-enter {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.pagination-loading {
  font-size: 12px;
  color: #64748b;
}

.btn.is-loading {
  opacity: 0.6;
  pointer-events: none;
}

.pagination-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #475569;
}

.pagination-toggle__state {
  padding: 2px 8px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #0f172a;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

[hidden] {
  display: none !important;
}

.dash-meta {
  color: #6b7280;
  font-size: 13px;
}

/* ---------- LEAD PAGE ---------- */

.lead-page {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.lead-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 20px 24px;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  box-shadow: var(--card-shadow);
}

.lead-header__actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.lead-kicker {
  margin: 0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #94a3b8;
  font-weight: 600;
}

.lead-title {
  margin: 6px 0;
  font-size: 28px;
  letter-spacing: -0.02em;
}

.lead-subtitle {
  margin: 0;
  color: #64748b;
  font-size: 14px;
}

.lead-layout {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.section-card {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  box-shadow: var(--card-shadow);
  padding: 20px 24px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.section-title {
  margin: 0;
  font-size: 18px;
  letter-spacing: -0.01em;
}

.section-subtitle {
  margin: 6px 0 0 0;
  color: #6b7280;
  font-size: 13px;
}

.section-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lead-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  padding: 16px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  margin-bottom: 16px;
}

.summary-label {
  margin: 0;
  font-size: 12px;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.summary-value {
  margin: 6px 0 0 0;
  font-weight: 700;
}

.summary-meta {
  margin: 6px 0 0 0;
  color: #64748b;
  font-size: 13px;
}

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

.slot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
}

.slot-pill {
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  background: #ffffff;
}

.slot-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 10px;
  height: 10px;
  margin-left: 6px;
  flex: 0 0 10px;
}

.slot-indicator__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: transparent;
}

.slot-indicator__dot--medium {
  background: #f4d07d;
}

.slot-indicator__dot--low {
  background: #86efac;
}

.slot-indicator__dot--high {
  background: #d97706;
}

.action-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.status-panel {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.status-meta {
  font-size: 13px;
  color: #64748b;
}

.info-banner {
  margin-top: 12px;
  padding: 12px;
  border-radius: 12px;
  background: #eff6ff;
  color: #1e3a8a;
  border: 1px solid #bfdbfe;
  font-size: 13px;
}

.info-banner.neutral {
  background: #f1f5f9;
  color: #334155;
  border-color: #e2e8f0;
}

.dash-meta.danger {
  color: #b91c1c;
}

@media (max-width: 720px) {
  .lead-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ---------- MICRO-INTERACTIONS ---------- */

.interactive:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
}

.fade-in {
  opacity: 0;
  transform: translateY(12px);
  animation: fadeInUp 240ms ease forwards;
}

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

/* ---------- ANIMATIONS ---------- */

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

.lead-row.is-new {
  animation: slide-in 0.25s ease-out;
}

/* ---------- CONTACTS ---------- */

.contacts-search {
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
}

.contacts-search__row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.contacts-search__input {
  min-width: 220px;
  flex: 1 1 240px;
}

.contacts-search__hint {
  margin: 8px 0 0 0;
}

.contacts-results__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.contacts-table {
  margin-top: 0;
}

.contact-name {
  display: flex;
  align-items: center;
  gap: 12px;
}

.contact-primary {
  font-weight: 600;
  color: #0f172a;
}

.contact-secondary {
  margin-top: 2px;
}

.contact-phone {
  font-weight: 600;
  color: #1f2937;
}

.contacts-empty {
  padding: 16px;
  border-radius: 14px;
  background: #f8fafc;
  border: 1px dashed #e2e8f0;
}

.contacts-empty h3 {
  margin: 0 0 6px 0;
  font-size: 16px;
}

.activity-log-toggle__closed {
  display: none;
}

.activity-log-toggle[open] .activity-log-toggle__open {
  display: none;
}

.activity-log-toggle[open] .activity-log-toggle__closed {
  display: inline;
}

.toast-stack {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(420px, calc(100vw - 32px));
}

.toast {
  background: #0f172a;
  color: #f8fafc;
  border-radius: 12px;
  padding: 12px 14px;
  display: grid;
  gap: 6px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.25);
}

.toast__content {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 14px;
}

.toast__link {
  color: #bae6fd;
  font-weight: 600;
  text-decoration: none;
}

.toast__time {
  font-size: 12px;
  color: #cbd5f5;
}


@media (max-width: 720px) {
  .contact-name {
    flex-direction: column;
    align-items: flex-start;
  }
}
