/* === DogMind CRM — Modern Design System === */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

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

:root {
    --bg: #f8fafc;
    --surface: #ffffff;
    --surface-raised: #ffffff;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --text: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --primary: #14b8a6;
    --primary-hover: #0d9488;
    --primary-soft: #f0fdfa;
    --accent: #f97316;
    --accent-hover: #ea580c;
    --accent-soft: #fff7ed;
    --stage-new: #3b82f6;
    --stage-contacted: #8b5cf6;
    --stage-scheduled: #eab308;
    --stage-assessment: #f97316;
    --stage-won: #10b981;
    --stage-lost: #94a3b8;
    --success: #10b981;
    --success-soft: #ecfdf5;
    --danger: #ef4444;
    --danger-soft: #fef2f2;
    --info: #3b82f6;
    --info-soft: #eff6ff;
    --warning: #f59e0b;
    --warning-soft: #fffbeb;
    --dark: #0f172a;
    --dark-secondary: #1e293b;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --r: 12px;
    --r-sm: 10px;
    --r-xs: 8px;
    --r-pill: 100px;
    --t: 150ms;
    --t-slow: 250ms;
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

html { font-size: 14px; scroll-behavior: smooth; }
body {
    font-family: 'Inter', -apple-system, system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}
a { color: inherit; text-decoration: none; }
input, select, textarea, button { font-family: inherit; font-size: inherit; }

/* === Reduced Motion === */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* === Page Header === */
.page-header { margin-bottom: 24px; }
.page-header h2 {
    font-size: 1.5rem; font-weight: 800; color: var(--text);
    display: flex; align-items: center; gap: 8px;
}

/* === Stat Grid — responsive === */
.stat-grid {
    display: grid; gap: 16px; margin-bottom: 24px;
    grid-template-columns: repeat(2, 1fr);
}
@media (min-width: 640px) {
    .stat-grid { grid-template-columns: repeat(4, 1fr); }
}

.stat-item {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--r); padding: 16px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--t) var(--ease), transform var(--t) var(--ease);
}
.stat-item:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}
.stat-value {
    font-size: 1.75rem; font-weight: 800; color: var(--text);
    margin-bottom: 2px;
}
.stat-label {
    font-size: 0.75rem; font-weight: 600; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.5px;
}

/* === Section / Card === */
.section {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--r); padding: 20px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
}
.section-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 16px; flex-wrap: wrap; gap: 10px;
}
.section-title {
    font-size: 1rem; font-weight: 700; color: var(--text);
    display: flex; align-items: center; gap: 8px;
}

/* === Search / Filters — stack on mobile === */
.search-bar {
    display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap;
}
.search-bar input,
.search-bar select {
    flex: 1; min-width: 140px;
    padding: 10px 14px; border: 1px solid var(--border);
    border-radius: var(--r-sm); font-size: 13px;
    background: var(--surface); color: var(--text);
    transition: border-color var(--t), box-shadow var(--t);
}
.search-bar input:focus,
.search-bar select:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}
.search-bar input { min-width: 200px; }

/* === Buttons === */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px; border: none; border-radius: var(--r-sm);
    font-size: 13px; font-weight: 600; cursor: pointer;
    transition: all var(--t) var(--ease);
    text-decoration: none; white-space: nowrap;
    min-height: 40px; /* touch target */
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-hover); }
.btn-ghost {
    background: transparent; color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg); border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 6px 12px; font-size: 12px; min-height: 34px; }
.btn-block { width: 100%; justify-content: center; }

/* === Table — horizontal scroll on mobile === */
.table-wrap {
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    margin: 0 -4px; padding: 0 4px;
}
.table {
    width: 100%; border-collapse: collapse; font-size: 13px;
    min-width: 500px; /* force scroll on narrow screens */
}
.table th {
    font-weight: 700; color: var(--text); padding: 12px 14px;
    border-bottom: 2px solid var(--border); text-align: right;
    white-space: nowrap; position: sticky; top: 0;
    background: var(--surface); z-index: 1;
}
.table td {
    padding: 12px 14px; border-bottom: 1px solid var(--border-light);
    color: var(--text-secondary); vertical-align: middle;
}
.table tr { transition: background var(--t); }
.table tbody tr:hover { background: var(--primary-soft); }

/* === Cards Grid — responsive === */
.card-grid {
    display: grid; gap: 16px;
    grid-template-columns: 1fr;
}
@media (min-width: 640px) {
    .card-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1024px) {
    .card-grid { grid-template-columns: repeat(3, 1fr); }
}

.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--r); padding: 16px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--t) var(--ease), transform var(--t) var(--ease);
    cursor: pointer;
}
.card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}
.card:active { transform: scale(0.98); }

/* === Badges === */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px; border-radius: var(--r-pill);
    font-size: 11px; font-weight: 700; letter-spacing: 0.3px;
    white-space: nowrap;
}
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.badge-new { background: #dbeafe; color: #2563eb; }
.badge-contacted { background: #ede9fe; color: #7c3aed; }
.badge-followup { background: #fef3c7; color: #d97706; }
.badge-hot { background: #fee2e2; color: #dc2626; }
.badge-converted { background: #d1fae5; color: #059669; }
.badge-closed { background: #f1f5f9; color: #64748b; }

/* === Avatar === */
.avatar {
    width: 42px; height: 42px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 15px; color: #fff;
    flex-shrink: 0;
}
.avatar-sm { width: 32px; height: 32px; font-size: 12px; }
.avatar-lg { width: 56px; height: 56px; font-size: 20px; }

/* === Lead Row === */
.lead-row {
    display: flex; align-items: center; gap: 12px;
    padding: 12px; border-bottom: 1px solid var(--border-light);
    transition: background var(--t);
    flex-wrap: wrap;
}
.lead-row:last-child { border-bottom: none; }
.lead-row:hover { background: var(--primary-soft); }
.lead-info { flex: 1; min-width: 120px; }
.lead-name { font-weight: 700; color: var(--text); font-size: 14px; }
.lead-detail { font-size: 12px; color: var(--text-muted); }
.lead-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* === Empty State === */
.empty-state {
    text-align: center; padding: 48px 24px;
    color: var(--text-muted);
}
.empty-state svg { width: 56px; height: 56px; margin-bottom: 16px; opacity: 0.3; }
.empty-state h3 { font-size: 16px; color: var(--text-secondary); margin-bottom: 8px; }
.empty-state p { font-size: 13px; }

/* === Grid Layout for dashboard === */
.grid-2 {
    display: grid; gap: 16px;
    grid-template-columns: 1fr;
}
@media (min-width: 768px) {
    .grid-2 { grid-template-columns: 1fr 1fr; }
}

/* === Quick Actions Grid === */
.quick-actions {
    display: grid; gap: 10px;
    grid-template-columns: repeat(2, 1fr);
    margin-bottom: 20px;
}
@media (min-width: 640px) {
    .quick-actions { grid-template-columns: repeat(4, 1fr); }
}

.quick-action-btn {
    display: flex; flex-direction: column; align-items: center;
    gap: 6px; padding: 16px 10px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--r); font-size: 12px; font-weight: 600;
    color: var(--text-secondary); cursor: pointer;
    transition: all var(--t) var(--ease);
    min-height: 72px; /* touch friendly */
}
.quick-action-btn:hover {
    border-color: var(--primary); color: var(--primary);
    box-shadow: var(--shadow); transform: translateY(-1px);
}
.quick-action-btn:active { transform: scale(0.95); }
.quick-action-btn svg { width: 22px; height: 22px; }

/* === Kennel Grid — 1 col mobile, 2 col tablet, 3 col desktop === */
.kennel-grid {
    display: grid; gap: 12px;
    grid-template-columns: 1fr;
}
@media (min-width: 480px) {
    .kennel-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 768px) {
    .kennel-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1024px) {
    .kennel-grid { grid-template-columns: repeat(4, 1fr); }
}

.kennel-compartment {
    background: var(--surface); border: 2px solid var(--border);
    border-radius: var(--r); padding: 14px;
    min-height: 80px; cursor: pointer;
    transition: all var(--t) var(--ease);
    box-shadow: var(--shadow-sm);
    display: flex; flex-direction: column; justify-content: center;
}
.kennel-compartment:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}
.kennel-compartment:active { transform: scale(0.97); }
.kennel-compartment.occupied {
    border-color: var(--success);
    background: linear-gradient(135deg, #ecfdf5, #f0fdf4);
}
.kennel-compartment.cleaning {
    border-color: var(--info);
    background: linear-gradient(135deg, #eff6ff, #dbeafe);
}
.kennel-compartment.maintenance {
    border-color: var(--warning);
    background: linear-gradient(135deg, #fffbeb, #fef3c7);
    opacity: 0.7; cursor: not-allowed;
}
.kennel-compartment.drop-target {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
    transform: scale(1.02);
}
.kennel-compartment.dragging {
    opacity: 0.5; transform: scale(0.95);
}
.kennel-compartment-name {
    font-size: 12px; font-weight: 700; color: var(--text);
    margin-bottom: 4px;
}
.kennel-compartment-dog {
    font-size: 11px; color: var(--text-secondary);
}
.kennel-compartment-dog strong {
    color: var(--primary); font-weight: 700;
}
.kennel-compartment-status {
    font-size: 10px; font-weight: 600; margin-top: 4px;
}

/* === Date Chips === */
.date-chips {
    display: flex; gap: 6px; flex-wrap: wrap;
}
.date-chip {
    padding: 6px 12px; border-radius: var(--r-pill);
    font-size: 12px; font-weight: 600;
    background: var(--bg); color: var(--text-secondary);
    border: 1px solid var(--border);
    cursor: pointer; transition: all var(--t);
    min-height: 34px; display: flex; align-items: center;
}
.date-chip:hover { border-color: var(--primary); color: var(--primary); }
.date-chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* === Status Toggle === */
.status-toggle {
    display: inline-flex; gap: 4px;
}
.status-btn {
    padding: 4px 10px; border-radius: var(--r-pill);
    font-size: 11px; font-weight: 600; cursor: pointer;
    border: 1px solid var(--border); background: var(--surface);
    color: var(--text-secondary); transition: all var(--t);
}
.status-btn:hover { border-color: var(--primary); }
.status-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* === Filter Chips === */
.filter-chips {
    display: flex; gap: 6px; flex-wrap: wrap;
    margin-bottom: 16px;
}
.filter-chip {
    padding: 6px 14px; border-radius: var(--r-pill);
    font-size: 12px; font-weight: 600;
    background: var(--bg); color: var(--text-secondary);
    border: 1px solid var(--border);
    cursor: pointer; transition: all var(--t);
    min-height: 34px; display: inline-flex; align-items: center;
}
.filter-chip:hover { border-color: var(--primary); color: var(--primary); }
.filter-chip.active { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }

/* === Tabs === */
.tabs {
    display: flex; gap: 4px; border-bottom: 2px solid var(--border);
    margin-bottom: 16px; overflow-x: auto;
}
.tab-btn {
    padding: 8px 16px; border: none; background: none;
    font-size: 13px; font-weight: 600; color: var(--text-muted);
    cursor: pointer; border-bottom: 2px solid transparent;
    margin-bottom: -2px; transition: all var(--t);
    white-space: nowrap;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

/* === Timeline === */
.timeline { margin: 12px 0; }
.timeline-item {
    display: flex; gap: 12px; padding: 12px 0;
    border-bottom: 1px solid var(--border-light);
}
.timeline-item:last-child { border-bottom: none; }
.timeline-icon {
    width: 32px; height: 32px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; font-size: 14px;
}
.timeline-icon.call { background: #dbeafe; color: #2563eb; }
.timeline-icon.email { background: #ede9fe; color: #7c3aed; }
.timeline-icon.whatsapp { background: #d1fae5; color: #059669; }
.timeline-icon.meeting { background: #fef3c7; color: #d97706; }
.timeline-icon.note { background: #f1f5f9; color: #64748b; }
.timeline-content { flex: 1; min-width: 0; }
.timeline-title { font-weight: 600; font-size: 13px; }
.timeline-text { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.timeline-time { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* === Document Cards === */
.doc-card {
    display: flex; align-items: center; gap: 12px;
    padding: 12px; border: 1px solid var(--border);
    border-radius: var(--r-sm); margin-bottom: 8px;
    transition: all var(--t);
}
.doc-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
}
.doc-icon {
    width: 40px; height: 40px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; font-size: 18px;
}
.doc-icon.vaccine { background: #dbeafe; color: #2563eb; }
.doc-icon.agreement { background: #d1fae5; color: #059669; }
.doc-icon.medical { background: #fee2e2; color: #dc2626; }
.doc-icon.other { background: #f1f5f9; color: #64748b; }
.doc-info { flex: 1; min-width: 0; }
.doc-name { font-weight: 600; font-size: 13px; }
.doc-meta { font-size: 11px; color: var(--text-muted); }

/* === Utility === */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.gap-8 { gap: 8px; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

/* === MOBILE-FIRST GLOBAL OVERRIDES === */
@media (max-width: 768px) {
    html { font-size: 15px; } /* larger base for mobile */
    .container { padding: 16px !important; }
    .section { padding: 14px; margin-bottom: 14px; }
    .section-header { flex-direction: column; align-items: flex-start; }
    .page-header h2 { font-size: 1.25rem; }
    .stat-value { font-size: 1.5rem; }
    .btn { min-height: 44px; padding: 10px 16px; font-size: 14px; }
    .btn-sm { min-height: 38px; padding: 8px 14px; font-size: 13px; }
    .search-bar { flex-direction: column; }
    .search-bar input,
    .search-bar select { min-width: 100%; }
    .lead-row { padding: 14px 8px; }
    .lead-actions { width: 100%; }
    .lead-actions .btn { flex: 1; justify-content: center; }
    .kennel-compartment { min-height: 70px; padding: 12px; }
    .quick-action-btn { padding: 14px 8px; min-height: 64px; }
    .card { padding: 14px; }
    .card-grid { gap: 12px; }
    .doc-card { padding: 10px; }
    .timeline-item { gap: 10px; }
    .tab-btn { padding: 10px 14px; font-size: 14px; }
    .filter-chip { min-height: 38px; padding: 8px 14px; font-size: 13px; }
    .date-chip { min-height: 38px; }
    /* Force single column for grids */
    .grid-2 { grid-template-columns: 1fr !important; }
}

@media (max-width: 480px) {
    .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat-item { padding: 12px; }
    .stat-value { font-size: 1.3rem; }
    .stat-label { font-size: 0.65rem; }
    .kennel-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .quick-actions { grid-template-columns: 1fr 1fr; gap: 8px; }
    .avatar { width: 36px; height: 36px; font-size: 13px; }
}

/* === Safe area for notched phones === */
/* === BACKWARD COMPAT — old classes mapped to new === */
.stats-row { display: grid; gap: 12px; margin-bottom: 20px; grid-template-columns: repeat(2, 1fr); }
@media (min-width: 640px) { .stats-row { grid-template-columns: repeat(4, 1fr); } }
.stat-val { font-size: 1.75rem; font-weight: 800; color: var(--text); margin-bottom: 2px; }
.stat-lbl { font-size: 0.75rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.btn-secondary { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border: 1px solid var(--border); border-radius: var(--r-sm); font-size: 13px; font-weight: 600; cursor: pointer; transition: all var(--t) var(--ease); text-decoration: none; white-space: nowrap; min-height: 40px; background: transparent; color: var(--text-secondary); }
.btn-secondary:hover { background: var(--bg); border-color: var(--primary); color: var(--primary); }
.btn-full { width: 100%; justify-content: center; display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border: none; border-radius: var(--r-sm); font-size: 13px; font-weight: 600; cursor: pointer; min-height: 40px; }
.btn-full.btn-primary { background: var(--primary); color: #fff; }
.btn-full.btn-primary:hover { background: var(--primary-hover); }
.lead-dot { display: none; }
.lead-phone { font-size: 12px; color: var(--text-muted); }
.lead-meta { display: flex; align-items: center; gap: 8px; }
.lead-tag { font-size: 11px; font-weight: 600; color: var(--text-muted); padding: 2px 6px; background: var(--bg); border-radius: var(--r-pill); }
.lead-date { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.badge-won { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: var(--r-pill); font-size: 11px; font-weight: 700; letter-spacing: 0.3px; white-space: nowrap; background: #d1fae5; color: #059669; }
.badge-lost { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: var(--r-pill); font-size: 11px; font-weight: 700; letter-spacing: 0.3px; white-space: nowrap; background: #f1f5f9; color: #64748b; }
.badge-scheduled { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: var(--r-pill); font-size: 11px; font-weight: 700; letter-spacing: 0.3px; white-space: nowrap; background: #fef3c7; color: #d97706; }
.is-accent { border-color: var(--accent) !important; }
.is-success { border-color: var(--success) !important; }
/* Search */
.search-form { display: flex; gap: 10px; margin-bottom: 16px; }
.search-form input { flex: 1; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--r-sm); font-size: 13px; background: var(--surface); color: var(--text); }
.search-form input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.search-input { padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--r-sm); font-size: 13px; background: var(--surface); color: var(--text); width: 100%; }
.search-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.leads-list { }
.btn-back { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border: 1px solid var(--border); border-radius: var(--r-sm); font-size: 13px; font-weight: 600; cursor: pointer; text-decoration: none; color: var(--text-secondary); background: transparent; min-height: 40px; }
.btn-back:hover { background: var(--bg); border-color: var(--primary); color: var(--primary); }
.btn-dark { display: inline-flex; align-items: center; gap: 4px; padding: 6px 12px; border-radius: var(--r-pill); font-size: 12px; font-weight: 600; border: 1px solid var(--dark); background: var(--dark); color: #fff; cursor: pointer; text-decoration: none; white-space: nowrap; min-height: 34px; }
/* Funnel chart */
.funnel { display: flex; flex-direction: column; gap: 10px; padding: 8px 0; }
.funnel-row { display: flex; align-items: center; gap: 12px; }
.funnel-label { width: 100px; font-size: 12px; font-weight: 600; color: var(--text-secondary); text-align: right; flex-shrink: 0; }
.funnel-bar-track { flex: 1; height: 20px; background: var(--bg); border-radius: var(--r-pill); overflow: hidden; }
.funnel-bar-fill { height: 100%; border-radius: var(--r-pill); transition: width 0.5s; min-width: 8px; }
.funnel-num { display: flex; align-items: center; gap: 6px; width: 60px; justify-content: flex-start; }
.funnel-count { font-size: 16px; font-weight: 800; color: var(--text); }
.funnel-pct { font-size: 11px; color: var(--text-muted); }
.pipeline-filter .pipe-seg { min-width: 48px; padding: 8px 6px; }
.pipeline-filter .pipe-seg.active { box-shadow: 0 0 0 2px var(--primary); }
/* Monthly comparison */
.monthly-grid { display: grid; grid-template-columns: 1fr 1px 1fr 1px 1fr; gap: 16px; align-items: start; }
.monthly-col { text-align: center; }
.monthly-head { font-size: 12px; font-weight: 700; color: var(--text-muted); margin-bottom: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
.monthly-stat { margin-bottom: 8px; }
.monthly-val { font-size: 20px; font-weight: 800; color: var(--text); }
.monthly-sub { display: block; font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.monthly-delta { font-size: 18px; font-weight: 800; }
.delta-up { color: var(--success); }
.delta-down { color: var(--danger); }
.monthly-divider { width: 1px; background: var(--border); height: 100%; align-self: stretch; }
@media (max-width: 480px) { .monthly-grid { grid-template-columns: 1fr; gap: 16px; } .monthly-divider { display: none; } }
/* Source table */
.source-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.source-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 400px; }
.source-table th { font-weight: 700; color: var(--text); padding: 10px 12px; border-bottom: 2px solid var(--border); text-align: right; white-space: nowrap; }
.source-table td { padding: 10px 12px; border-bottom: 1px solid var(--border-light); color: var(--text-secondary); }
.source-table tbody tr:hover { background: var(--primary-soft); }
.src-name { font-weight: 600; color: var(--text); }
.src-num { text-align: left !important; }
.rate-badge { font-weight: 700; padding: 2px 8px; border-radius: var(--r-pill); background: var(--bg); color: var(--text-muted); font-size: 12px; }
.rate-good { background: var(--success-soft); color: var(--success); }
.rate-mid { background: var(--accent-soft); color: var(--accent); }
.source-cards { display: none; }
@media (max-width: 640px) { .source-table-wrap { display: none; } .source-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; } }
@media (max-width: 480px) { .source-cards { grid-template-columns: 1fr; } }
.source-card { border: 1px solid var(--border); border-radius: var(--r); padding: 12px; }
.source-card-head { font-size: 13px; font-weight: 700; margin-bottom: 8px; }
.source-card-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sc-item { text-align: center; }
.sc-val { font-size: 18px; font-weight: 800; }
.sc-lbl { display: block; font-size: 10px; color: var(--text-muted); }
/* Bar chart */
.bar-chart { display: flex; gap: 12px; align-items: flex-end; justify-content: center; padding: 16px 0 0; min-height: 160px; }
.bar-item { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: 1; }
.bar-value { font-size: 13px; font-weight: 700; color: var(--text); }
.bar-fill { width: 28px; min-height: 4px; background: var(--primary); border-radius: 4px 4px 0 0; transition: height 0.5s; }
.bar-label { font-size: 10px; color: var(--text-muted); font-weight: 600; margin-top: 4px; }
/* Interest list */
.interest-list { display: flex; flex-direction: column; gap: 8px; }
.interest-row { display: flex; align-items: center; gap: 12px; }
.interest-label { width: 100px; font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.interest-bar-track { flex: 1; height: 12px; background: var(--bg); border-radius: var(--r-pill); overflow: hidden; }
.interest-bar-fill { height: 100%; background: var(--primary); border-radius: var(--r-pill); min-width: 4px; }
.interest-count { font-size: 14px; font-weight: 700; color: var(--text); width: 24px; text-align: left; }
/* Wins list */
.wins-list { display: flex; flex-direction: column; }
.win-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border-light); }
.win-row:last-child { border-bottom: none; }
.win-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); flex-shrink: 0; }
.win-info { flex: 1; min-width: 0; }
.win-name { font-size: 14px; font-weight: 600; }
.win-meta { font-size: 11px; color: var(--text-muted); }
.win-right { text-align: left; }
.win-days { font-size: 14px; font-weight: 700; color: var(--text); }
.win-date { font-size: 11px; color: var(--text-muted); }
/* Text */
.text-muted { color: var(--text-muted); }
/* Lead card */
.lead-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 20px; box-shadow: var(--shadow-sm); margin-bottom: 16px; }
.lead-card-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.lead-card-name { font-size: 20px; font-weight: 800; color: var(--text); }
.lead-card-phone { font-size: 14px; color: var(--text-secondary); margin-top: 2px; }
.lead-card-source { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.lead-card-interest { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.lead-card-dates { font-size: 11px; color: var(--text-muted); margin-top: 8px; }
.status-form { margin-top: 10px; }
.status-form select { width: 100%; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--r-sm); font-size: 14px; background: var(--surface); color: var(--text); }
.status-form select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
/* Messages */
.messages-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; max-height: 320px; overflow-y: auto; }
.msg { display: flex; flex-direction: column; gap: 4px; }
.msg-in { align-items: flex-start; }
.msg-out { align-items: flex-end; }
.msg-meta { font-size: 10px; color: var(--text-muted); }
.msg-bubble { max-width: 80%; padding: 10px 14px; border-radius: var(--r-sm); font-size: 13px; line-height: 1.5; }
.msg-in .msg-bubble { background: var(--bg); color: var(--text); }
.msg-out .msg-bubble { background: var(--primary); color: #fff; }
/* Send form */
.send-form { display: flex; gap: 8px; }
.send-form input { flex: 1; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--r-sm); font-size: 13px; background: var(--surface); }
.send-form input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
/* Notes */
.note-form { margin-bottom: 12px; }
.note-form textarea { width: 100%; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--r-sm); font-size: 13px; background: var(--surface); min-height: 60px; resize: vertical; }
.note-form textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.note-form button { margin-top: 6px; }
.note-item { padding: 10px 0; border-bottom: 1px solid var(--border-light); font-size: 13px; color: var(--text-secondary); }
.note-item:last-child { border-bottom: none; }
.note-item strong { color: var(--text); font-size: 12px; }
/* Badge status colors */
.badge-new { background: #dbeafe; color: #2563eb; }
.badge-contacted { background: #ede9fe; color: #7c3aed; }
.badge-scheduled { background: #fef3c7; color: #d97706; }
.badge-assessment { background: #fff7ed; color: #ea580c; }
.badge-won { background: #d1fae5; color: #059669; }
.badge-lost { background: #f1f5f9; color: #64748b; }

/* Pipeline bar — GLOBAL */
.pipeline-bar { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
/* Progress bar */
.progress-bar { background: var(--bg); border-radius: var(--r-pill); height: 8px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: var(--r-pill); transition: width 0.4s; }
.fill-success { background: var(--success); }
.fill-info { background: var(--info); }
.fill-warning { background: var(--accent); }
/* Alert */
.alert-danger { background: var(--danger-soft); border: 1px solid var(--danger); border-radius: var(--r-sm); padding: 10px 12px; margin-bottom: 10px; }
/* Form inputs global */
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"], textarea, select { width: 100%; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--r-sm); font-size: 14px; background: var(--surface); color: var(--text); }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
textarea { min-height: 60px; resize: vertical; }
/* Safe area for notched phones */
@supports (padding: env(safe-area-inset-bottom)) {
    body { padding-bottom: env(safe-area-inset-bottom); }
}
