:root {
    --bg-primary: #0a0b10;
    --bg-secondary: #0f1117;
    --bg-tertiary: #151720;
    --bg-card: #161822;
    --bg-card-hover: #1c1e2e;
    --bg-elevated: #1a1d2e;
    --bg-input: #12141e;
    --accent-primary: #7c6cf0;
    --accent-primary-hover: #9083f5;
    --accent-primary-soft: rgba(124, 108, 240, 0.12);
    --accent-secondary: #00d4aa;
    --accent-secondary-soft: rgba(0, 212, 170, 0.12);
    --gradient-purple: linear-gradient(135deg, #7c6cf0 0%, #a78bfa 100%);
    --gradient-blue: linear-gradient(135deg, #3b82f6 0%, #60a5fa 100%);
    --gradient-teal: linear-gradient(135deg, #14b8a6 0%, #2dd4bf 100%);
    --gradient-amber: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%);
    --gradient-rose: linear-gradient(135deg, #f43f5e 0%, #fb7185 100%);
    --gradient-emerald: linear-gradient(135deg, #10b981 0%, #34d399 100%);
    --gradient-brand: linear-gradient(135deg, #7c6cf0 0%, #00d4aa 100%);
    --text-primary: #e8eaf0;
    --text-secondary: #8b8fa8;
    --text-muted: #555a72;
    --text-accent: #a78bfa;
    --border-color: rgba(255, 255, 255, 0.06);
    --border-subtle: rgba(255, 255, 255, 0.03);
    --border-active: rgba(124, 108, 240, 0.4);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 30px rgba(124, 108, 240, 0.2);
    --sidebar-width: 260px;
    --topbar-height: 64px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

body.auth-locked .sidebar,
body.auth-locked .main-content {
    filter: blur(2px);
    pointer-events: none;
    user-select: none;
}

a { color: var(--accent-primary); text-decoration: none; }
a:hover { color: var(--accent-primary-hover); }

.auth-shell {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: none;
    place-items: center;
    background:
        radial-gradient(circle at top left, rgba(124, 108, 240, 0.2), transparent 30%),
        radial-gradient(circle at bottom right, rgba(0, 212, 170, 0.15), transparent 25%),
        rgba(10, 11, 16, 0.94);
    backdrop-filter: blur(18px);
}

body.auth-locked .auth-shell {
    display: grid;
}

body:not(.auth-locked) .auth-shell {
    display: none;
}

.auth-panel {
    width: min(460px, calc(100vw - 32px));
    padding: 32px;
    border-radius: 24px;
    background: rgba(22, 24, 34, 0.94);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: var(--shadow-lg);
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 24px;
}

.auth-brand h1 {
    font-size: 1.45rem;
    font-weight: 800;
}

.auth-brand p {
    color: var(--text-secondary);
    font-size: 0.86rem;
}

.auth-copy {
    margin-bottom: 18px;
}

.auth-copy h2 {
    font-size: 1.5rem;
    margin-bottom: 8px;
}

.auth-copy p {
    color: var(--text-secondary);
    line-height: 1.6;
}

.auth-form {
    display: grid;
    gap: 16px;
}

.auth-switch {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 16px;
    color: var(--text-secondary);
    font-size: 0.86rem;
}

.auth-status {
    margin-bottom: 16px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    font-size: 0.86rem;
}

.auth-status.loading {
    color: #60a5fa;
    border-color: rgba(59, 130, 246, 0.28);
    background: rgba(59, 130, 246, 0.08);
}

.auth-status.error {
    color: #fb7185;
    border-color: rgba(239, 68, 68, 0.28);
    background: rgba(239, 68, 68, 0.08);
}

.topbar-user-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
}

.topbar-user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-primary-soft);
    color: var(--accent-primary);
}

.topbar-user-avatar i {
    width: 16px;
    height: 16px;
}

.topbar-username {
    font-weight: 600;
    font-size: 0.84rem;
}

.topbar-role {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

::selection {
    background: var(--accent-primary);
    color: #fff;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
    transition: transform var(--transition-slow), width var(--transition-slow);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.brand-icon {
    width: 42px;
    height: 42px;
    background: var(--gradient-brand);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: var(--shadow-glow);
}

.brand-icon-svg { width: 22px; height: 22px; color: #fff; }

.brand-text h1 {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: var(--text-primary);
}

.brand-accent { color: var(--accent-primary); }

.brand-tagline {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 400;
    margin-top: 1px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.92rem;
    transition: all var(--transition-fast);
    position: relative;
    text-decoration: none;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--accent-primary-soft);
    color: var(--accent-primary);
    font-weight: 600;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--accent-primary);
    border-radius: 0 4px 4px 0;
}

.nav-item i { width: 20px; height: 20px; flex-shrink: 0; }

.nav-badge {
    font-size: 0.65rem;
    padding: 2px 8px;
    background: var(--accent-secondary);
    color: #000;
    border-radius: 20px;
    font-weight: 700;
    margin-left: auto;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.nav-count {
    font-size: 0.8rem;
    padding: 1px 8px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    border-radius: 20px;
    font-weight: 600;
    margin-left: auto;
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border-color);
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #555;
    flex-shrink: 0;
}

.status-dot.connected {
    background: var(--accent-secondary);
    box-shadow: 0 0 8px rgba(0, 212, 170, 0.5);
}

.status-dot.disconnected { background: #ef4444; }

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left var(--transition-slow);
}

.topbar {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(15, 17, 23, 0.8);
    backdrop-filter: blur(20px);
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.page-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.search-box-top {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon-top {
    position: absolute;
    left: 12px;
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    pointer-events: none;
}

.search-input-top {
    width: 260px;
    padding: 8px 14px 8px 38px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.88rem;
    font-family: var(--font-family);
    transition: all var(--transition-fast);
}

.search-input-top:focus,
.form-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-primary-soft);
}

.sidebar-toggle { display: none; }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 18px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-family);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.btn i { width: 16px; height: 16px; }

.btn-primary {
    background: var(--gradient-purple);
    color: #fff;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(124, 108, 240, 0.35);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.12);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.12);
    color: #ef4444;
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.2);
}

.btn-sm { padding: 6px 12px; font-size: 0.82rem; }
.btn-full { width: 100%; justify-content: center; }
.btn-glow { box-shadow: var(--shadow-glow); }

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-icon:hover {
    background: rgba(255,255,255,0.06);
    color: var(--text-primary);
}

.btn-icon i { width: 18px; height: 18px; }

.view {
    display: none;
    padding: 28px;
    flex: 1;
    animation: fadeIn 0.3s ease;
}

.view.active { display: block; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    position: relative;
    overflow: hidden;
    transition: all var(--transition-normal);
}

.stat-card:hover {
    border-color: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.stat-card.gradient-purple::before { background: var(--gradient-purple); }
.stat-card.gradient-blue::before { background: var(--gradient-blue); }
.stat-card.gradient-teal::before { background: var(--gradient-teal); }
.stat-card.gradient-amber::before { background: var(--gradient-amber); }
.stat-card.gradient-rose::before { background: var(--gradient-rose); }
.stat-card.gradient-emerald::before { background: var(--gradient-emerald); }

.stat-card-inner {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.stat-label {
    display: block;
    font-size: 0.82rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 6px;
}

.stat-value {
    display: block;
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -1px;
    color: var(--text-primary);
}

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-card.gradient-purple .stat-icon { background: rgba(124,108,240,0.12); color: #a78bfa; }
.stat-card.gradient-blue .stat-icon { background: rgba(59,130,246,0.12); color: #60a5fa; }
.stat-card.gradient-teal .stat-icon { background: rgba(20,184,166,0.12); color: #2dd4bf; }
.stat-card.gradient-amber .stat-icon { background: rgba(245,158,11,0.12); color: #fbbf24; }
.stat-card.gradient-rose .stat-icon { background: rgba(244,63,94,0.12); color: #fb7185; }
.stat-card.gradient-emerald .stat-icon { background: rgba(16,185,129,0.12); color: #34d399; }

.stat-icon i { width: 20px; height: 20px; }

.stat-progress {
    margin-top: 14px;
    height: 3px;
    border-radius: 3px;
    background: rgba(255,255,255,0.04);
    overflow: hidden;
}

.stat-progress-bar {
    height: 100%;
    border-radius: 3px;
    transition: width 0.6s ease;
}

.stat-card.gradient-purple .stat-progress-bar { background: var(--gradient-purple); }
.stat-card.gradient-blue .stat-progress-bar { background: var(--gradient-blue); }
.stat-card.gradient-teal .stat-progress-bar { background: var(--gradient-teal); }
.stat-card.gradient-amber .stat-progress-bar { background: var(--gradient-amber); }
.stat-card.gradient-rose .stat-progress-bar { background: var(--gradient-rose); }
.stat-card.gradient-emerald .stat-progress-bar { background: var(--gradient-emerald); }

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: 20px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.card-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
}

.card-header h3 i { width: 18px; height: 18px; color: var(--text-muted); }

.card-body { padding: 20px; }

.card-description {
    color: var(--text-secondary);
    font-size: 0.88rem;
    line-height: 1.6;
    margin-bottom: 20px;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1.6fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.dashboard-grid .card { margin-bottom: 0; }

.glass-panel {
    background: rgba(22, 24, 34, 0.92);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.discover-layout {
    display: flex;
    gap: 0;
    height: calc(100vh - var(--topbar-height) - 56px);
    margin: -28px;
}

.search-panel {
    width: 380px;
    min-width: 380px;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.search-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border-color);
}

.search-form {
    padding: 20px;
    display: grid;
    gap: 18px;
}

.form-group {
    display: grid;
    gap: 8px;
}

.form-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 600;
}

.form-group label i { width: 15px; height: 15px; color: var(--text-muted); }

.form-input {
    width: 100%;
    padding: 11px 13px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-family);
}

.form-hint {
    color: var(--text-muted);
    font-size: 0.78rem;
    line-height: 1.5;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-secondary);
}

.area-status {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.area-status.ready {
    border-color: rgba(0, 212, 170, 0.24);
    color: #34d399;
}

.crawl-progress-wrapper {
    margin-top: 6px;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 0.84rem;
}

.progress-bar-container {
    height: 10px;
    background: rgba(255,255,255,0.04);
    border-radius: 999px;
    overflow: hidden;
}

.progress-bar {
    width: 0;
    height: 100%;
    border-radius: 999px;
    background: var(--gradient-purple);
    position: relative;
    transition: width 0.35s ease;
}

.crawl-bar {
    background: var(--gradient-teal);
}

.progress-bar-shimmer {
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.28), transparent);
    animation: shimmer 1.8s infinite;
}

@keyframes shimmer {
    from { transform: translateX(-100%); }
    to { transform: translateX(100%); }
}

.progress-message,
.site-crawl-meta {
    margin-top: 10px;
    color: var(--text-secondary);
    font-size: 0.82rem;
}

.map-wrapper,
#map {
    flex: 1;
    min-height: 100%;
}

.leads-toolbar,
.leads-actions,
.filter-group,
.crawl-actions,
.site-upload-actions,
.input-with-action {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.leads-toolbar {
    justify-content: space-between;
    margin-bottom: 16px;
}

.filter-btn {
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
}

.filter-btn.active {
    background: var(--accent-primary-soft);
    color: var(--accent-primary);
    border-color: rgba(124, 108, 240, 0.28);
}

.table-wrapper {
    overflow: auto;
}

.leads-table {
    width: 100%;
    border-collapse: collapse;
}

.leads-table th,
.leads-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: top;
}

.leads-table th {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-muted);
}

.sortable {
    cursor: pointer;
}

.lead-name-cell {
    display: grid;
    gap: 4px;
}

.lead-name {
    font-weight: 600;
}

.lead-address,
.rating-reviews {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.category-badge,
.status-badge,
.modal-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
}

.category-badge {
    background: rgba(124, 108, 240, 0.12);
    color: #a78bfa;
}

.status-pending {
    background: rgba(245, 158, 11, 0.12);
    color: #fbbf24;
}

.status-crawled {
    background: rgba(16, 185, 129, 0.12);
    color: #34d399;
}

.status-error {
    background: rgba(239, 68, 68, 0.12);
    color: #fb7185;
}

.contact-cell {
    display: grid;
    gap: 6px;
}

.contact-item {
    font-size: 0.82rem;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.contact-item i,
.website-link i,
.rating-cell i {
    width: 14px;
    height: 14px;
}

.table-actions {
    display: flex;
    gap: 6px;
}

.website-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.rating-cell {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.table-empty,
.empty-state,
.empty-state-mini {
    display: grid;
    place-items: center;
    gap: 10px;
    text-align: center;
    color: var(--text-secondary);
    padding: 28px 12px;
}

.empty-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: rgba(255,255,255,0.04);
}

.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 18px;
}

.recent-leads-table table {
    width: 100%;
    border-collapse: collapse;
}

.recent-leads-table th {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-align: left;
    padding: 10px 12px;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
}

.recent-leads-table td {
    padding: 10px 12px;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--border-subtle);
}

.recent-leads-table tr:last-child td { border-bottom: none; }

.activity-feed {
    max-height: 300px;
    overflow-y: auto;
}

.feed-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-subtle);
}

.feed-item:last-child { border-bottom: none; }

.feed-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.feed-icon.search { background: rgba(124,108,240,0.12); color: #a78bfa; }
.feed-icon.lead { background: rgba(0,212,170,0.12); color: #00d4aa; }
.feed-icon.crawl { background: rgba(59,130,246,0.12); color: #60a5fa; }
.feed-icon.email { background: rgba(16,185,129,0.12); color: #34d399; }
.feed-icon.error { background: rgba(239,68,68,0.12); color: #fb7185; }

.feed-icon i { width: 16px; height: 16px; }

.feed-content {
    flex: 1;
    min-width: 0;
}

.feed-message {
    font-size: 0.85rem;
    color: var(--text-primary);
    line-height: 1.4;
}

.feed-time {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-live {
    background: rgba(239, 68, 68, 0.12);
    color: #ef4444;
}

.pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.crawl-layout,
.site-upload-layout,
.linkedin-layout,
.outreach-layout {
    display: grid;
    gap: 20px;
}

.outreach-config-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.outreach-textarea {
    min-height: 120px;
    resize: vertical;
}

.outreach-message-template {
    min-height: 160px;
}

.outreach-checkbox {
    margin: 10px 0 18px;
}

.outreach-ai-settings {
    display: none;
    margin-top: 4px;
    padding-top: 18px;
    border-top: 1px solid var(--border-subtle);
}

.outreach-ai-settings.is-visible {
    display: grid;
    gap: 18px;
}

.outreach-ai-grid {
    align-items: start;
}

.manual-outreach-panel {
    display: grid;
    gap: 16px;
    margin-top: 16px;
}

.manual-outreach-actions {
    display: grid;
    gap: 14px;
}

.manual-delay-group {
    max-width: 260px;
}

.manual-button-row {
    align-items: center;
}

.outreach-results-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.outreach-log-panel {
    min-height: 260px;
}

.outreach-log-list {
    display: grid;
    gap: 12px;
    margin-top: 12px;
}

.outreach-log-item {
    padding: 12px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
}

.outreach-log-email {
    font-weight: 600;
    margin-bottom: 6px;
}

.outreach-log-subject,
.outreach-log-message,
.outreach-log-error {
    color: var(--text-secondary);
    font-size: 0.82rem;
    line-height: 1.55;
    white-space: pre-wrap;
}

.outreach-log-error {
    color: #fb7185;
}

.manual-outreach-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.outreach-manual-message {
    min-height: 180px;
}

.linkedin-form-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.linkedin-status,
.site-upload-summary,
.single-crawl-result {
    margin-top: 20px;
    padding: 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
}

.single-crawl-result.loading {
    border-color: rgba(59, 130, 246, 0.28);
    background: rgba(59, 130, 246, 0.08);
    color: #93c5fd;
}

.single-crawl-result.success {
    border-color: rgba(16, 185, 129, 0.28);
    background: rgba(16, 185, 129, 0.08);
    color: #86efac;
}

.single-crawl-result.error {
    border-color: rgba(239, 68, 68, 0.28);
    background: rgba(239, 68, 68, 0.08);
    color: #fda4af;
}

.linkedin-status-note,
.site-upload-note {
    color: var(--text-secondary);
    line-height: 1.6;
}

.linkedin-status-note.error,
.site-upload-note.error {
    color: #fda4af;
}

.site-pill-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
}

.site-pill {
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(124, 108, 240, 0.14);
    border: 1px solid rgba(124, 108, 240, 0.28);
    color: var(--text-primary);
    font-size: 0.82rem;
}

.site-upload-rejected {
    margin-top: 14px;
}

.site-pill-rejected {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.28);
    color: #fda4af;
}

.single-crawl-form {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.single-crawl-form input { flex: 1; }

.export-layout { max-width: 800px; }

.export-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.export-card {
    padding: 24px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    text-align: center;
    transition: all var(--transition-normal);
}

.export-card:hover {
    border-color: rgba(255,255,255,0.1);
    transform: translateY(-2px);
}

.export-card-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 14px;
}

.export-card-icon i { width: 24px; height: 24px; color: #fff; }

.export-card h4 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.export-card p {
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 16px;
}

.settings-layout { max-width: 700px; }

.input-with-action input { flex: 1; }

.settings-status {
    margin-top: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
}

.settings-status.success {
    background: rgba(16,185,129,0.1);
    border: 1px solid rgba(16,185,129,0.2);
    color: #34d399;
}

.settings-status.error {
    background: rgba(239,68,68,0.1);
    border: 1px solid rgba(239,68,68,0.2);
    color: #fb7185;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
}

.demo-overlay {
    backdrop-filter: blur(10px);
}

.modal {
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.demo-modal {
    max-width: 560px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid var(--border-color);
}

.demo-modal-header {
    align-items: flex-start;
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
}

.demo-kicker {
    display: inline-flex;
    margin-bottom: 10px;
    padding: 5px 10px;
    border-radius: 999px;
    background: rgba(0, 212, 170, 0.14);
    color: var(--accent-secondary);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.7px;
}

.demo-modal-body {
    display: grid;
    gap: 20px;
}

.demo-progress-meta {
    display: grid;
    gap: 10px;
    color: var(--text-secondary);
    font-size: 0.86rem;
}

.demo-progress-track {
    width: 100%;
    height: 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    overflow: hidden;
}

.demo-progress-bar {
    height: 100%;
    width: 0;
    border-radius: inherit;
    background: var(--gradient-brand);
    transition: width var(--transition-normal);
}

.demo-description {
    color: var(--text-primary);
    line-height: 1.75;
    font-size: 0.95rem;
}

.demo-target-note {
    min-height: 54px;
    padding: 14px 16px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(124, 108, 240, 0.22);
    background: rgba(124, 108, 240, 0.08);
    color: #c9c2ff;
    line-height: 1.6;
}

.demo-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 24px 24px;
}

.demo-actions-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.demo-highlight {
    position: relative;
    z-index: 650;
    border-radius: var(--radius-md);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.9), 0 0 0 8px rgba(0, 212, 170, 0.22), 0 18px 48px rgba(0, 0, 0, 0.45);
    transition: box-shadow var(--transition-normal);
}

.modal-field {
    margin-bottom: 16px;
}

.modal-field-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.modal-field-value {
    font-size: 0.92rem;
    color: var(--text-primary);
    line-height: 1.5;
}

.modal-field-value a {
    color: var(--accent-primary);
}

.modal-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    font-size: 0.85rem;
    max-width: 380px;
}

.toast.success { border-color: rgba(16,185,129,0.3); }
.toast.error { border-color: rgba(239,68,68,0.3); }
.toast.info { border-color: rgba(59,130,246,0.3); }

.toast i { width: 18px; height: 18px; flex-shrink: 0; }
.toast.success i { color: #34d399; }
.toast.error i { color: #fb7185; }
.toast.info i { color: #60a5fa; }

@media (max-width: 768px) {
    .demo-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .demo-actions-right {
        width: 100%;
        justify-content: space-between;
    }
}

.leaflet-container {
    background: var(--bg-primary) !important;
    font-family: var(--font-family) !important;
}

.leaflet-control-zoom {
    border: none !important;
    box-shadow: var(--shadow-md) !important;
}

.leaflet-control-zoom a {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-color) !important;
    width: 35px !important;
    height: 35px !important;
    line-height: 35px !important;
    font-size: 16px !important;
}

.leaflet-control-zoom a:hover {
    background: var(--bg-elevated) !important;
}

.leaflet-draw-toolbar a {
    background-color: var(--bg-card) !important;
    border: 1px solid var(--border-color) !important;
}

.leaflet-popup-content-wrapper {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-radius: var(--radius-sm) !important;
    border: 1px solid var(--border-color) !important;
    box-shadow: var(--shadow-lg) !important;
}

.leaflet-popup-tip {
    background: var(--bg-card) !important;
    border: 1px solid var(--border-color) !important;
}

.leaflet-popup-content {
    font-family: var(--font-family) !important;
    font-size: 0.85rem !important;
    line-height: 1.5 !important;
}

.map-popup-title {
    font-weight: 700;
    font-size: 0.95rem;
    margin-bottom: 4px;
}

.map-popup-category {
    color: var(--accent-primary);
    font-size: 0.78rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.map-popup-info {
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.link {
    color: var(--accent-primary);
    text-decoration: underline;
    text-underline-offset: 2px;
}

@media (max-width: 1200px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .sidebar-toggle {
        display: flex;
    }

    .search-panel {
        width: 320px;
        min-width: 320px;
    }

    .topbar {
        height: auto;
        min-height: var(--topbar-height);
        padding-top: 12px;
        padding-bottom: 12px;
        align-items: flex-start;
    }

    .topbar-right {
        flex-wrap: wrap;
        justify-content: flex-end;
        row-gap: 10px;
    }

    .card-header {
        gap: 12px;
        flex-wrap: wrap;
        align-items: flex-start;
    }

    .site-upload-actions .btn,
    .manual-button-row .btn,
    .input-with-action .btn {
        min-height: 42px;
    }
}

@media (max-width: 900px) {
    .linkedin-form-grid,
    .outreach-config-grid {
        grid-template-columns: 1fr;
    }

    .manual-delay-group {
        max-width: none;
    }

    .outreach-results-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-grid {
        gap: 16px;
    }

    .site-upload-layout,
    .linkedin-layout,
    .outreach-layout {
        gap: 16px;
    }

    .manual-button-row,
    .site-upload-actions,
    .input-with-action,
    .topbar-right {
        flex-direction: column;
        align-items: stretch;
    }

    .topbar-right > * {
        width: 100%;
    }

    .search-input-top {
        width: 100%;
    }

    .toast-container {
        left: 16px;
        right: 16px;
        bottom: 16px;
    }

    .toast {
        max-width: none;
    }
}

@media (max-width: 768px) {
    .topbar {
        padding: 0 16px;
        gap: 12px;
        flex-direction: column;
        align-items: stretch;
    }

    .search-box-top {
        display: none;
    }

    .view {
        padding: 16px;
    }

    .card-body,
    .search-form,
    .search-panel-header {
        padding: 16px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .discover-layout {
        flex-direction: column;
        margin: -16px;
    }

    .search-panel {
        width: 100%;
        min-width: 0;
        max-height: 40vh;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .leads-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .export-options {
        grid-template-columns: 1fr;
    }

    .topbar-right {
        gap: 10px;
        width: 100%;
    }

    .topbar-user-meta {
        display: none !important;
    }

    .page-title {
        font-size: 1.2rem;
    }

    .table-wrapper {
        margin: 0 -4px;
        padding-bottom: 4px;
        -webkit-overflow-scrolling: touch;
    }

    .leads-table,
    .recent-leads-table table {
        min-width: 760px;
    }

    .manual-outreach-meta {
        display: grid;
        grid-template-columns: 1fr;
    }

    .manual-outreach-panel,
    .manual-outreach-actions {
        gap: 12px;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    html {
        font-size: 13px;
    }

    .auth-panel {
        padding: 24px;
    }

    .auth-switch {
        flex-direction: column;
        align-items: flex-start;
    }

    .view {
        padding: 12px;
    }

    .card-header {
        padding: 14px 16px;
    }

    .card-body,
    .search-form,
    .search-panel-header,
    .stat-card {
        padding: 14px;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }

    .site-pill-list {
        gap: 8px;
    }

    .topbar-left,
    .topbar-right {
        width: 100%;
    }

    .topbar-left {
        justify-content: space-between;
    }

    .auth-panel {
        width: min(100vw - 20px, 460px);
        padding: 20px;
    }
}

