:root {
    color-scheme: light;
    --app-safe-top: env(safe-area-inset-top, 0px);
    --app-safe-right: env(safe-area-inset-right, 0px);
    --app-safe-bottom: env(safe-area-inset-bottom, 0px);
    --app-safe-left: env(safe-area-inset-left, 0px);
}

html {
    min-height: 100%;
    background: #f9fafb;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    min-height: 100vh;
    min-height: 100dvh;
    overscroll-behavior-y: contain;
    -webkit-tap-highlight-color: transparent;
}

button,
a,
input,
select,
textarea {
    touch-action: manipulation;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

.pb-safe {
    padding-bottom: var(--app-safe-bottom);
}

nav.fixed.bottom-0 {
    padding-right: var(--app-safe-right);
    padding-bottom: var(--app-safe-bottom);
    padding-left: var(--app-safe-left);
}

@media (display-mode: standalone) {
    body {
        padding-top: var(--app-safe-top);
    }
}

@media (max-width: 767px) {
    input,
    select,
    textarea {
        font-size: 16px !important;
    }

    body:not(.auth-page) {
        padding-bottom: calc(72px + var(--app-safe-bottom)) !important;
    }
}

@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;
    }
}

/* Phase 1 multi-vertical utilities. Kept here so deployments do not depend on
   a Node/Tailwind build being available on the production XAMPP host. */
.bg-amber-50 { background-color: #fffbeb; }
.bg-amber-50\/50 { background-color: rgba(255, 251, 235, .5); }
.bg-amber-50\/60 { background-color: rgba(255, 251, 235, .6); }
.bg-amber-100 { background-color: #fef3c7; }
.bg-amber-500 { background-color: #f59e0b; }
.text-amber-600 { color: #d97706; }
.text-amber-700 { color: #b45309; }
.text-amber-900 { color: #78350f; }
.border-amber-100 { border-color: #fef3c7; }
.bg-violet-50 { background-color: #f5f3ff; }
.text-violet-700 { color: #6d28d9; }
.bg-purple-600 { background-color: #9333ea; }
.bg-gray-900 { background-color: #111827; }
.bg-gray-600 { background-color: #4b5563; }
.bg-blue-50\/60 { background-color: rgba(239, 246, 255, .6); }
.bg-blue-50\/50 { background-color: rgba(239, 246, 255, .5); }
.col-span-2 { grid-column: span 2 / span 2; }
@media (min-width: 640px) {
    .sm\:col-span-2 { grid-column: span 2 / span 2; }
}
@media (min-width: 768px) {
    .md\:col-span-2 { grid-column: span 2 / span 2; }
}

.bulk-assign-form { flex-wrap: wrap; }
.lead-filter-form { position: relative; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 12px 16px; }
.lead-search-field { grid-column: 1 / -1; grid-row: 1; display: flex; align-items: center; gap: 8px; min-width: 0; padding: 0 52px 0 12px; background: #f3f4f6; border: 1px solid #e5e7eb; border-radius: 12px; }
.lead-search-field:focus-within { background: #fff; border-color: #2563eb; }
.lead-search-field input { min-width: 0; width: 100%; height: 42px; background: transparent; border: 0; outline: 0; font-size: 14px; }
.lead-filter-control { min-width: 0; width: 100%; height: 42px; padding: 0 10px; background: #fff; border: 1px solid #d1d5db; border-radius: 12px; font-size: 13px; }
.lead-status-filter { grid-column: 1; grid-row: 2; }
.lead-vertical-filter { grid-column: 2; grid-row: 2; }
.lead-agent-filter { grid-column: 1 / -1; grid-row: 3; }
.lead-filter-submit { position: absolute; top: 12px; right: 16px; display: flex; width: 42px; height: 42px; align-items: center; justify-content: center; color: #fff; background: #2563eb; border-radius: 12px; font-size: 14px; font-weight: 600; }
.lead-filter-submit span { display: none; }
.lead-filter-clear { grid-column: 1 / -1; display: inline-flex; align-items: center; color: #1d4ed8; font-size: 13px; font-weight: 600; }
#lead-results[aria-busy="true"] { opacity: .6; }
@media (min-width: 768px) {
    .lead-filter-form { display: flex; align-items: center; flex-wrap: wrap; }
    .lead-search-field { flex: 2 1 230px; padding-right: 12px; }
    .lead-filter-control { flex: 1 1 120px; width: auto; max-width: 180px; }
    .lead-filter-submit { position: static; width: auto; height: 42px; padding: 0 16px; }
    .lead-filter-submit span { display: inline; }
    .lead-filter-submit svg { display: none; }
    .lead-filter-clear { height: 42px; }
}
.lead-whatsapp-action { font-size: 14px; }
@media (max-width: 359px) {
    .lead-whatsapp-action { font-size: 12px; }
    .lead-whatsapp-action svg { display: none; }
}
.lead-mobile-cards { display: block; }
.lead-desktop-table { display: none; }
@media (min-width: 1024px) {
    .lead-mobile-cards { display: none; }
    .lead-desktop-table { display: block; }
    .lead-list-main { max-width: none; margin-left: 16rem; margin-right: 0; }
    .lead-search-form { max-width: none; margin-left: 0; margin-right: 0; }
}

.lead-results-table { table-layout: fixed; border-collapse: collapse; font-size: 13px; }
.lead-results-table th, .lead-results-table td { padding: 12px 10px; vertical-align: middle; overflow-wrap: anywhere; }
.lead-results-table th { font-weight: 600; font-size: 12px; white-space: nowrap; }
.lead-results-table td { color: #4b5563; }
.lead-contact-cell { display: flex; align-items: center; gap: 8px; min-width: 0; }
.lead-contact-cell a, .lead-cell-clip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lead-contact-cell a { min-width: 0; }
.lead-row-actions { display: flex; align-items: center; justify-content: flex-start; gap: 4px; white-space: nowrap; }
.lead-row-action { display: inline-flex; flex: 0 0 26px; width: 26px; height: 28px; align-items: center; justify-content: center; border-radius: 8px; }
.lead-row-action-followup { color: #b45309; background: #fffbeb; }
.lead-row-action-edit { color: #2563eb; background: #eff6ff; }
.lead-row-action-view { color: #475569; background: #f1f5f9; }
.lead-row-action:hover { filter: brightness(.94); }
.lead-followup-link { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 3px; max-width: 100%; text-decoration: none; }
.lead-followup-state { display: inline-block; padding: 2px 6px; border-radius: 6px; font-size: 10px; font-weight: 700; line-height: 1.3; }
.lead-followup-date { font-size: 11px; line-height: 1.3; color: #64748b; }
.lead-followup-not-scheduled { color: #64748b; background: #f1f5f9; }
.lead-followup-closed { color: #475569; background: #e2e8f0; }
.lead-followup-overdue { color: #b91c1c; background: #fef2f2; }
.lead-followup-today { color: #1d4ed8; background: #eff6ff; }
.lead-followup-scheduled { color: #047857; background: #ecfdf5; }
.lead-followup-link:hover .lead-followup-date { color: #1d4ed8; text-decoration: underline; }

body.quick-dialog-open { overflow: hidden; }
.quick-dialog { position: fixed; inset: auto 0 0; width: 100%; max-width: none; max-height: min(88dvh, 760px); margin: 0; padding: 0 18px calc(18px + var(--app-safe-bottom)); overflow-y: auto; border: 0; border-radius: 22px 22px 0 0; background: #fff; color: #111827; box-shadow: 0 -12px 40px rgba(15, 23, 42, .16); }
.quick-dialog::backdrop { background: rgba(15, 23, 42, .54); }
.quick-dialog-handle { width: 38px; height: 4px; margin: 10px auto 14px; border-radius: 999px; background: #cbd5e1; }
.quick-dialog-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; }
.quick-dialog-close { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; flex: 0 0 36px; border-radius: 10px; color: #64748b; background: #f1f5f9; }
.quick-dialog-form fieldset { display: grid; gap: 13px; }
.quick-dialog-form fieldset[hidden] { display: none; }
.quick-dialog-label { display: block; font-size: 13px; font-weight: 600; color: #374151; }
.quick-dialog-label[hidden] { display: none; }
.quick-dialog-input { display: block; width: 100%; min-height: 44px; margin-top: 5px; padding: 10px 12px; border: 1px solid #d1d5db; border-radius: 12px; background: #fff; color: #111827; font-size: 15px; font-weight: 400; }
.quick-dialog-input:focus { border-color: #2563eb; outline: 2px solid rgba(37, 99, 235, .18); }
.quick-dialog-error { margin-bottom: 12px; padding: 10px 12px; border: 1px solid #fecaca; border-radius: 10px; background: #fef2f2; color: #b91c1c; font-size: 13px; }
.quick-dialog-actions { display: flex; gap: 10px; margin-top: 20px; }
.quick-dialog-cancel, .quick-dialog-save { min-height: 46px; flex: 1; border-radius: 12px; font-size: 14px; font-weight: 700; }
.quick-dialog-cancel { background: #f1f5f9; color: #475569; }
.quick-dialog-save { background: #2563eb; color: #fff; }
.quick-dialog-save:disabled { opacity: .6; }
.quick-dialog-notice { position: fixed; z-index: 100; top: calc(12px + var(--app-safe-top)); right: 12px; left: 12px; width: max-content; max-width: calc(100% - 24px); margin: 0 auto; padding: 11px 16px; border-radius: 12px; background: #064e3b; color: #fff; box-shadow: 0 10px 30px rgba(0, 0, 0, .2); font-size: 13px; font-weight: 600; }
.quick-dialog-notice[hidden] { display: none; }
@media (min-width: 768px) {
    .quick-dialog { inset: 0; width: min(480px, calc(100% - 32px)); max-height: min(85dvh, 720px); margin: auto; padding: 24px; border-radius: 20px; box-shadow: 0 20px 70px rgba(15, 23, 42, .24); }
    .quick-dialog-handle { display: none; }
    .quick-dialog-notice { left: auto; right: 20px; margin: 0; }
}
@media (min-width: 1200px) {
    .lead-row-action { flex-basis: 32px; width: 32px; height: 32px; }
}
