/* ==========================================
   Local Titan — Premium Dark Theme
   ========================================== */
:root {
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-card: #1a1f2e;
    --bg-input: #0f1420;
    --border: rgba(255,255,255,0.08);
    --text-main: #e2e8f0;
    --text-muted: #64748b;
    --text-dim: #475569;
    --accent: #6366f1;
    --accent-glow: rgba(99,102,241,0.3);
    --green: #22c55e;
    --yellow: #eab308;
    --orange: #f97316;
    --red: #ef4444;
    --dark-rank: #1e293b;
    --radius: 12px;
    --transition: all 0.2s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: row;
}

/* Header */
#app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    z-index: 100;
}
.header-left { display: flex; align-items: center; }
.logo { display: flex; align-items: center; gap: 12px; }
.logo-icon {
    width: 40px; height: 40px; border-radius: 10px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem; color: white;
    box-shadow: 0 4px 15px rgba(99,102,241,0.3);
}
.logo h1 { font-size: 1.3rem; font-weight: 800; letter-spacing: -0.5px; }
.pro-badge {
    font-size: 0.55rem; background: linear-gradient(135deg, #f59e0b, #f97316);
    color: #000; font-weight: 800; padding: 2px 6px; border-radius: 4px;
    vertical-align: super; letter-spacing: 1px;
}
.tagline { font-size: 0.7rem; color: var(--text-muted); margin-top: 1px; }
.header-right { display: flex; align-items: center; gap: 12px; }
.api-status {
    display: flex; align-items: center; gap: 6px;
    font-size: 0.75rem; color: var(--text-muted);
    background: rgba(255,255,255,0.05); padding: 6px 12px;
    border-radius: 20px; border: 1px solid var(--border);
}
.api-status i { font-size: 0.5rem; color: var(--yellow); }
.api-status.live i { color: var(--green); }
.api-status.live span { color: var(--green); }
.header-btn {
    width: 36px; height: 36px; border-radius: 8px;
    background: rgba(255,255,255,0.05); border: 1px solid var(--border);
    color: var(--text-muted); cursor: pointer; font-size: 0.9rem;
    transition: var(--transition);
}
.header-btn:hover { background: rgba(255,255,255,0.1); color: var(--text-main); }

/* Main Layout */
#app-main {
    flex: 1; display: flex; overflow: hidden;
}

/* Search Panel */
.search-panel {
    width: 360px; min-width: 360px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    overflow-y: auto; display: flex; flex-direction: column;
}
.search-panel::-webkit-scrollbar { width: 4px; }
.search-panel::-webkit-scrollbar-thumb { background: var(--bg-card); border-radius: 4px; }
.panel-section { padding: 20px; border-bottom: 1px solid var(--border); }
.panel-title {
    font-size: 0.75rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 1.5px; color: var(--text-muted); margin-bottom: 16px;
    display: flex; align-items: center; gap: 8px;
}
.panel-title i { color: var(--accent); font-size: 0.8rem; }

/* Form */
.form-group { margin-bottom: 14px; }
.form-group label {
    display: block; font-size: 0.75rem; font-weight: 600;
    color: var(--text-muted); margin-bottom: 6px; text-transform: uppercase;
    letter-spacing: 0.5px;
}
.form-group input, .form-group select {
    width: 100%; background: var(--bg-input); border: 1px solid var(--border);
    border-radius: 8px; color: var(--text-main); padding: 10px 14px;
    font-size: 0.9rem; font-family: inherit; outline: none;
    transition: var(--transition);
}
.form-group input::placeholder { color: var(--text-dim); }
.form-group input:focus, .form-group select:focus {
    border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-group select { cursor: pointer; appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center;
}
.form-row { display: flex; gap: 10px; }
.form-group.half { flex: 1; }

/* Scan Button */
.scan-btn {
    width: 100%; padding: 14px; border: none; border-radius: 10px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white; font-size: 1rem; font-weight: 700; cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 10px;
    transition: all 0.3s ease; margin-top: 6px;
    box-shadow: 0 4px 20px rgba(99,102,241,0.3);
}
.scan-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 30px rgba(99,102,241,0.5);
}
.scan-btn:active { transform: translateY(0); }
.scan-btn.scanning {
    background: var(--bg-card); color: var(--text-muted);
    pointer-events: none; box-shadow: none;
}
.scan-btn.scanning i { animation: pulse-spin 1.5s infinite; }
@keyframes pulse-spin {
    0% { transform: rotate(0deg); opacity: 1; }
    50% { opacity: 0.5; }
    100% { transform: rotate(360deg); opacity: 1; }
}

/* Progress */
.scan-progress { margin-top: 14px; }
.progress-bar {
    height: 4px; background: var(--bg-input); border-radius: 4px; overflow: hidden;
}
.progress-fill {
    height: 100%; width: 0%; border-radius: 4px;
    background: linear-gradient(90deg, #6366f1, #8b5cf6, #a78bfa);
    transition: width 0.3s ease;
}
.progress-text {
    font-size: 0.75rem; color: var(--text-muted); margin-top: 8px; text-align: center;
}

/* Stats Grid */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 10px; padding: 14px; text-align: center;
}
.stat-value {
    font-size: 1.6rem; font-weight: 800; color: var(--text-main);
    line-height: 1;
}
.stat-label {
    font-size: 0.7rem; color: var(--text-muted); margin-top: 4px;
    text-transform: uppercase; letter-spacing: 0.5px;
}
.stat-card.green .stat-value { color: var(--green); }
.stat-card.red .stat-value { color: var(--red); }

/* Legend */
.legend-items { display: flex; flex-direction: column; gap: 8px; }
.legend-item {
    display: flex; align-items: center; gap: 10px;
    font-size: 0.8rem; color: var(--text-muted);
}
.legend-dot {
    width: 20px; height: 20px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.6rem; font-weight: 800; color: #fff; flex-shrink: 0;
}
.legend-dot.rank-1 { background: var(--green); }
.legend-dot.rank-4 { background: var(--yellow); }
.legend-dot.rank-8 { background: var(--orange); }
.legend-dot.rank-11 { background: var(--red); }
.legend-dot.rank-none { background: #334155; }

/* Map Container */
.map-container {
    flex: 1; position: relative; background: var(--bg-primary);
}
#map { width: 100%; height: 100%; z-index: 1; }
.map-empty {
    position: absolute; inset: 0; z-index: 2;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    background: var(--bg-primary);
    text-align: center; padding: 40px;
}
.empty-icon {
    width: 80px; height: 80px; border-radius: 50%;
    background: linear-gradient(135deg, rgba(99,102,241,0.15), rgba(139,92,246,0.15));
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 24px;
}
.empty-icon i { font-size: 2rem; color: var(--accent); }
.map-empty h2 { font-size: 1.5rem; font-weight: 700; margin-bottom: 8px; }
.map-empty p { color: var(--text-muted); font-size: 0.95rem; max-width: 400px; margin-bottom: 30px; }
.empty-features { display: flex; flex-direction: column; gap: 12px; }
.empty-feature {
    display: flex; align-items: center; gap: 10px;
    font-size: 0.85rem; color: var(--text-muted);
    background: rgba(255,255,255,0.03); padding: 10px 20px;
    border-radius: 8px; border: 1px solid var(--border);
}
.empty-feature i { color: var(--accent); width: 20px; text-align: center; }

/* Rank Markers on Map */
.rank-marker {
    display: flex; align-items: center; justify-content: center;
    width: 42px; height: 42px; border-radius: 50%;
    font-size: 0.85rem; font-weight: 800; color: #fff;
    border: 3px solid rgba(255,255,255,0.3);
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
    transition: transform 0.2s;
    cursor: pointer;
    animation: popIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.rank-marker:hover { transform: scale(1.3); z-index: 999 !important; }
.rank-marker.r-green { background: var(--green); border-color: rgba(34,197,94,0.5); }
.rank-marker.r-yellow { background: var(--yellow); border-color: rgba(234,179,8,0.5); color: #000; }
.rank-marker.r-orange { background: var(--orange); border-color: rgba(249,115,22,0.5); }
.rank-marker.r-red { background: var(--red); border-color: rgba(239,68,68,0.5); }
.rank-marker.r-black { background: #334155; border-color: rgba(51,65,85,0.5); }
.rank-marker.center-pin {
    background: var(--accent); border-color: rgba(99,102,241,0.5);
    width: 20px; height: 20px; font-size: 0;
    box-shadow: 0 0 20px rgba(99,102,241,0.6);
}

@keyframes popIn {
    0% { transform: scale(0); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* Modals */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.7);
    display: flex; align-items: center; justify-content: center;
    z-index: 9999;
}
.modal {
    background: var(--bg-card); border-radius: 16px; width: 440px;
    max-width: 90vw; max-height: 90vh; border: 1px solid var(--border);
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    animation: slideUp 0.25s ease;
    display: flex; flex-direction: column;
}
.modal-wide { width: 600px; }
@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
.modal-header {
    padding: 20px 24px; display: flex; align-items: center;
    justify-content: space-between; border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.modal-header h3 {
    margin: 0; font-size: 1.1rem; font-weight: 700;
    display: flex; align-items: center; gap: 10px;
}
.modal-header h3 i { color: var(--accent); }
.modal-close {
    background: none; border: none; color: var(--text-muted);
    cursor: pointer; font-size: 1.2rem; padding: 4px; transition: 0.15s;
}
.modal-close:hover { color: var(--text-main); }
.modal-body { padding: 24px; overflow-y: auto; flex: 1; }
.modal-desc { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 20px; line-height: 1.5; }
.modal-desc strong { color: var(--text-main); }
.api-link {
    display: inline-flex; align-items: center; gap: 6px;
    color: var(--accent); font-size: 0.85rem; text-decoration: none;
    margin-top: 10px;
}
.api-link:hover { text-decoration: underline; }
.modal-footer {
    padding: 16px 24px; display: flex; justify-content: flex-end;
    gap: 10px; border-top: 1px solid var(--border); flex-shrink: 0;
}
.btn-cancel {
    background: none; border: none; color: var(--text-muted); cursor: pointer;
    padding: 10px 20px; font-size: 0.9rem; transition: 0.15s;
}
.btn-cancel:hover { color: var(--text-main); }
.btn-confirm {
    background: var(--accent); border: none; color: #fff; cursor: pointer;
    padding: 10px 24px; border-radius: 8px; font-size: 0.9rem;
    font-weight: 600; transition: 0.2s;
}
.btn-confirm:hover { background: #4f46e5; }

/* History Items */
.history-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px; background: var(--bg-input); border-radius: 10px;
    margin-bottom: 8px; border: 1px solid var(--border); cursor: pointer;
    transition: var(--transition);
}
.history-item:hover { border-color: var(--accent); background: rgba(99,102,241,0.05); }
.history-item-info { flex: 1; }
.history-item-keyword { font-weight: 600; font-size: 0.95rem; }
.history-item-meta { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }
.history-item-rank {
    font-size: 1.1rem; font-weight: 800; padding: 4px 12px;
    border-radius: 8px;
}
.empty-history { color: var(--text-dim); font-size: 0.9rem; text-align: center; padding: 30px; }

/* Leaflet dark overrides */
.leaflet-container { background: #0a0e17 !important; }
.leaflet-control-zoom a {
    background: var(--bg-card) !important; color: var(--text-main) !important;
    border-color: var(--border) !important;
}
.leaflet-control-zoom a:hover { background: var(--bg-secondary) !important; }
.leaflet-popup-content-wrapper {
    background: var(--bg-card) !important; color: var(--text-main) !important;
    border-radius: 10px !important; box-shadow: 0 8px 30px rgba(0,0,0,0.4) !important;
    border: 1px solid var(--border) !important;
}
.leaflet-popup-tip { background: var(--bg-card) !important; }
.leaflet-popup-content { font-family: 'Inter', sans-serif !important; font-size: 0.85rem !important; }

/* ==========================================
   RESPONSIVE — Enterprise Grade
   Breakpoints: 1024 (tablet), 768 (small tablet), 480 (mobile)
   ========================================== */

/* Mobile sidebar overlay backdrop */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 190;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* ---- TABLET (≤ 1024px) ---- */
@media (max-width: 1024px) {
    /* Sidebar collapses off-screen */
    .suite-sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 300;
        box-shadow: none;
    }
    .suite-sidebar.open {
        transform: translateX(0) !important;
        box-shadow: 8px 0 40px rgba(0,0,0,0.5) !important;
    }

    /* Content takes full width */
    .suite-content {
        margin-left: 0 !important;
        width: 100% !important;
    }

    /* Show hamburger */
    .sidebar-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
    }

    /* Overlay */
    .sidebar-overlay.active,
    .sidebar-overlay.open {
        display: block !important;
    }

    /* Rank Tracker layout — stack on tablet */
    #app-main {
        flex-direction: column;
    }
    .search-panel {
        width: 100%;
        min-width: 100%;
        max-height: none;
        border-right: none;
        border-bottom: 1px solid var(--border);
        overflow-y: visible;
    }
    .map-container {
        min-height: 50vh;
        flex: 1;
    }
    body {
        overflow: auto;
    }

    /* Tool pages breathe better */
    .tool-page {
        padding: 20px;
    }
    .tool-grid {
        grid-template-columns: 1fr;
    }
    .tool-header h1 {
        font-size: 1.3rem;
    }
}

/* ---- SMALL TABLET / LARGE PHONE (≤ 768px) ---- */
@media (max-width: 768px) {
    /* Search panel inline instead of sidebar */
    .search-panel {
        max-height: none;
        overflow-y: visible;
    }
    .panel-section {
        padding: 16px;
    }

    /* Form rows stack */
    .form-row {
        flex-direction: column;
        gap: 0;
    }
    .form-group input,
    .form-group select {
        padding: 12px 14px;
        font-size: 1rem;
        min-height: 48px;
    }

    /* Scan button bigger for touch */
    .scan-btn {
        padding: 16px;
        font-size: 1.05rem;
        border-radius: 12px;
    }

    /* Stats grid single column on small tablets */
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    /* Legend compact */
    .legend-items {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 6px;
    }
    .legend-item {
        font-size: 0.72rem;
        gap: 6px;
    }
    .legend-dot {
        width: 16px;
        height: 16px;
        font-size: 0.5rem;
    }

    /* Map minimum height */
    .map-container {
        min-height: 45vh;
    }

    /* Modals full-width on tablet */
    .modal {
        width: 95vw;
        max-height: 85vh;
    }

    /* Metrics grid 2-col */
    .metrics-grid {
        grid-template-columns: 1fr 1fr;
    }

    /* Reduce header padding */
    .content-header {
        padding: 8px 16px;
    }
    .view-title {
        font-size: 0.9rem;
    }

    /* Tool cards full width */
    .tool-card {
        padding: 18px;
    }

    /* Popup list smaller */
    .rank-popup-container .leaflet-popup-content {
        width: 240px !important;
    }
}

/* ---- MOBILE (≤ 480px) ---- */
@media (max-width: 480px) {
    /* Body allows scroll */
    body {
        height: auto;
        overflow: auto;
    }

    /* Sidebar full-width overlay */
    .suite-sidebar {
        width: 280px;
        min-width: 280px;
        max-width: 280px;
    }

    /* Header compact */
    .content-header {
        padding: 8px 12px;
        min-height: 48px;
    }
    .view-title {
        font-size: 0.85rem;
    }
    .api-status-header {
        font-size: 0.65rem;
        padding: 4px 8px;
    }
    .api-status-header span {
        display: none;
    }

    /* Search panel */
    .panel-section {
        padding: 14px 12px;
    }
    .panel-title {
        font-size: 0.7rem;
        margin-bottom: 12px;
    }
    .form-group label {
        font-size: 0.7rem;
    }
    .form-group input,
    .form-group select {
        padding: 14px 12px;
        font-size: 1rem;
        border-radius: 10px;
        min-height: 50px;
    }

    /* Scan button full-width sticky */
    .scan-btn {
        padding: 18px;
        font-size: 1.1rem;
        border-radius: 14px;
        box-shadow: 0 4px 25px rgba(99,102,241,0.4);
    }

    /* Stats 2x2 compact */
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 6px;
    }
    .stat-card {
        padding: 10px;
        border-radius: 8px;
    }
    .stat-value {
        font-size: 1.3rem;
    }
    .stat-label {
        font-size: 0.6rem;
    }

    /* Legend horizontal */
    .legend-items {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 4px;
    }
    .legend-item {
        font-size: 0.65rem;
        padding: 4px 8px;
        background: rgba(255,255,255,0.03);
        border-radius: 6px;
        gap: 4px;
    }
    .legend-dot {
        width: 14px;
        height: 14px;
        font-size: 0.45rem;
    }

    /* Map takes more screen */
    .map-container {
        min-height: 55vh;
    }

    /* Rank markers slightly smaller on mobile */
    .rank-marker {
        width: 36px;
        height: 36px;
        font-size: 0.75rem;
        border-width: 2px;
    }

    /* Modal full screen on mobile */
    .modal {
        width: 100vw;
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 12px 12px 0 0;
        margin: 0;
        position: fixed;
        bottom: 0;
        animation: slideUpMobile 0.3s ease;
    }
    @keyframes slideUpMobile {
        from { transform: translateY(100%); }
        to { transform: translateY(0); }
    }
    .modal-header {
        padding: 16px;
    }
    .modal-body {
        padding: 16px;
    }
    .modal-footer {
        padding: 12px 16px;
    }

    /* Tool page mobile */
    .tool-page {
        padding: 16px 12px;
    }
    .tool-header h1 {
        font-size: 1.15rem;
    }
    .tool-header p {
        font-size: 0.85rem;
    }
    .tool-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    .tool-card {
        padding: 16px;
    }

    /* Metrics stacked on small mobile */
    .metrics-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    .metric-card {
        padding: 14px;
    }
    .metric-card h3 {
        font-size: 1.4rem;
    }

    /* Upload zone compact */
    .upload-zone {
        padding: 24px 16px;
    }

    /* AI table scroll */
    .ai-results-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Autocomplete dropdown */
    .autocomplete-dropdown {
        max-height: 220px;
    }
    .ac-item {
        padding: 12px;
    }

    /* History items */
    .history-item {
        padding: 12px;
        flex-wrap: wrap;
        gap: 8px;
    }
    .history-item-keyword {
        font-size: 0.85rem;
    }

    /* Rank popup mobile */
    .rank-popup-container .leaflet-popup-content {
        width: 220px !important;
    }
    .rank-popup-item {
        font-size: 0.72rem;
    }

    /* Leaflet zoom controls */
    .leaflet-control-zoom {
        margin: 10px !important;
    }
    .leaflet-control-zoom a {
        width: 36px !important;
        height: 36px !important;
        line-height: 36px !important;
        font-size: 16px !important;
    }
}

/* ---- Touch Device Enhancements ---- */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .nav-item {
        padding: 14px 16px;
        min-height: 48px;
    }
    .scan-btn {
        min-height: 52px;
    }
    .form-group input,
    .form-group select {
        min-height: 48px;
    }
    .sidebar-toggle {
        width: 44px;
        height: 44px;
    }
    .header-btn {
        width: 44px;
        height: 44px;
    }
    /* Disable hover transforms on touch */
    .scan-btn:hover {
        transform: none;
    }
    .primary-btn:hover {
        transform: none;
    }
    .rank-marker:hover {
        transform: none;
    }
}

/* ---- Landscape Phone ---- */
@media (max-height: 500px) and (orientation: landscape) {
    .search-panel {
        max-height: none;
    }
    .map-container {
        min-height: 100vh;
    }
    .suite-sidebar {
        width: 220px;
        min-width: 220px;
    }
}

/* ---- Print (just in case) ---- */
@media print {
    .suite-sidebar,
    .content-header,
    .sidebar-overlay,
    .scan-btn { display: none !important; }
    .suite-content { margin-left: 0; }
    body { overflow: visible; background: white; color: black; }
}

/* ==========================================
   Business Autocomplete Dropdown
   ========================================== */
.autocomplete-dropdown {
    position: absolute; top: 100%; left: 0; right: 0;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 10px; margin-top: 4px; z-index: 500;
    max-height: 320px; overflow-y: auto;
    box-shadow: 0 12px 40px rgba(0,0,0,0.5);
    display: none;
}
.autocomplete-dropdown::-webkit-scrollbar { width: 4px; }
.autocomplete-dropdown::-webkit-scrollbar-thumb { background: var(--text-dim); border-radius: 4px; }

.ac-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px; cursor: pointer;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    transition: background 0.15s;
}
.ac-item:last-child { border-bottom: none; }
.ac-item:hover, .ac-item.active { background: rgba(99,102,241,0.1); }
.ac-item-icon {
    width: 32px; height: 32px; border-radius: 8px;
    background: rgba(99,102,241,0.12);
    display: flex; align-items: center; justify-content: center;
    color: var(--accent); font-size: 0.8rem; flex-shrink: 0;
}
.ac-item-info { flex: 1; min-width: 0; }
.ac-item-name {
    font-weight: 600; font-size: 0.85rem; color: var(--text-main);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ac-item-addr {
    font-size: 0.72rem; color: var(--text-muted); margin-top: 2px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* "Use this exact name" highlighted option */
.ac-item-exact {
    background: rgba(99,102,241,0.08);
    border-bottom: 1px solid rgba(99,102,241,0.2) !important;
    position: relative;
}
.ac-item-exact:hover {
    background: rgba(99,102,241,0.18) !important;
}
.ac-item-exact::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(180deg, #6366f1, #8b5cf6);
    border-radius: 0 2px 2px 0;
}

/* ==========================================
   Rank Popup (Competitor List)
   ========================================== */
.rank-popup-container .leaflet-popup-content-wrapper {
    padding: 0 !important; overflow: hidden;
}
.rank-popup-container .leaflet-popup-content {
    margin: 0 !important; width: 280px !important;
}
.rank-popup { font-family: 'Inter', sans-serif; }
.rank-popup-header {
    padding: 12px 14px; border-bottom: 1px solid rgba(255,255,255,0.06);
    text-align: center;
}
.rank-popup-list {
    max-height: 260px; overflow-y: auto;
    padding: 6px 8px;
}
.rank-popup-list::-webkit-scrollbar { width: 3px; }
.rank-popup-list::-webkit-scrollbar-thumb { background: var(--text-dim); border-radius: 3px; }
.rank-popup-item {
    display: flex; align-items: center; gap: 8px;
    padding: 5px 8px; margin: 2px 0; border-radius: 4px;
    font-size: 0.78rem;
    border: 1px solid transparent;
}
.rank-popup-item:hover { background: rgba(255,255,255,0.04); }
.rank-popup-pos {
    font-weight: 800; font-size: 0.75rem; width: 20px;
    text-align: center; flex-shrink: 0;
}
.rank-popup-name {
    color: var(--text-main); flex: 1; min-width: 0;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ==========================================
   API Settings Sections
   ========================================== */
#business-group { position: relative; }

.api-section {
    background: var(--bg-input); border: 1px solid var(--border);
    border-radius: 12px; padding: 18px; margin-bottom: 16px;
}
.api-section-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 10px;
}
.api-section-title {
    display: flex; align-items: center; gap: 8px; font-size: 0.9rem;
}
.api-section-title i { font-size: 1rem; }
.api-tag {
    font-size: 0.55rem; font-weight: 800; padding: 2px 6px;
    border-radius: 4px; text-transform: uppercase; letter-spacing: 0.5px;
}
.api-tag.free { background: rgba(34,197,94,0.15); color: #22c55e; }
.api-section-status {
    font-size: 0.7rem; display: flex; align-items: center; gap: 5px;
}
.api-section-status i { font-size: 0.45rem; }
.api-section-status.active { color: var(--green); }
.api-section-status.active i { color: var(--green); }
.api-section-status:not(.active) { color: var(--text-dim); }
.api-section-status:not(.active) i { color: var(--red); }
.api-section-desc {
    font-size: 0.8rem; color: var(--text-muted); line-height: 1.5;
    margin-bottom: 12px;
}
.api-section-desc strong { color: var(--text-main); }
.api-section .form-group { margin-bottom: 8px; }
.api-setup-steps {
    display: flex; flex-direction: column; gap: 4px;
}
.api-step-note {
    font-size: 0.7rem; color: var(--text-dim); padding-left: 20px;
}

/* Google Places Autocomplete Override */
.pac-container {
    background: var(--bg-card) !important;
    border: 1px solid var(--border) !important;
    border-radius: 10px !important;
    margin-top: 4px !important;
    box-shadow: 0 12px 40px rgba(0,0,0,0.5) !important;
    font-family: 'Inter', sans-serif !important;
    z-index: 10000 !important;
}
.pac-item {
    padding: 10px 14px !important;
    border-bottom: 1px solid rgba(255,255,255,0.04) !important;
    color: var(--text-main) !important;
    cursor: pointer !important;
    font-size: 0.85rem !important;
    line-height: 1.5 !important;
}
.pac-item:hover { background: rgba(99,102,241,0.1) !important; }
.pac-item-selected { background: rgba(99,102,241,0.15) !important; }
.pac-item-query { color: var(--text-main) !important; font-weight: 600 !important; font-size: 0.85rem !important; }
.pac-item .pac-icon { display: none !important; }
.pac-matched { color: var(--accent) !important; font-weight: 700 !important; }
.pac-item span:not(.pac-item-query):not(.pac-matched) { color: var(--text-muted) !important; font-size: 0.75rem !important; }
.hdpi.pac-logo::after, .pac-logo::after { display: none !important; }

/* ==========================================
   SIDEBAR NAVIGATION
   ========================================== */
.suite-sidebar {
    width: 240px;
    min-width: 240px;
    max-width: 240px;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 200;
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
}
.brand-icon {
    width: 38px; height: 38px; border-radius: 10px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    display: flex; align-items: center; justify-content: center;
    font-size: 1rem; color: white;
    box-shadow: 0 4px 15px rgba(99,102,241,0.3);
    flex-shrink: 0;
}
.brand-text h1 { font-size: 1.1rem; font-weight: 800; letter-spacing: -0.5px; }
.brand-text p { font-size: 0.65rem; color: var(--text-muted); margin-top: 1px; }
.sidebar-nav {
    flex: 1;
    padding: 12px 10px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}
.nav-section-label {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-dim);
    padding: 8px 12px 6px;
    margin-top: 8px;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 8px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: var(--transition);
    cursor: pointer;
    margin-bottom: 2px;
}
.nav-item i { width: 18px; text-align: center; font-size: 0.9rem; }
.nav-item:hover {
    background: rgba(255,255,255,0.05);
    color: var(--text-main);
}
.nav-item.active {
    background: rgba(99,102,241,0.15);
    color: #a78bfa;
}
.nav-item.active i { color: #a78bfa; }
.sidebar-footer {
    padding: 14px 16px;
    border-top: 1px solid var(--border);
}
.sidebar-footer .api-status {
    font-size: 0.7rem;
    justify-content: center;
}

/* ==========================================
   SUITE CONTENT AREA
   ========================================== */
.suite-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    margin-left: 240px;
}
.content-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    min-height: 52px;
}
.content-header .header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}
.sidebar-toggle {
    display: none;
    width: 36px; height: 36px; border-radius: 8px;
    background: rgba(255,255,255,0.05); border: 1px solid var(--border);
    color: var(--text-muted); cursor: pointer; font-size: 1rem;
}
.view-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
}
.api-status-header {
    display: flex; align-items: center; gap: 6px;
    font-size: 0.75rem; color: var(--text-muted);
    background: rgba(255,255,255,0.05); padding: 6px 12px;
    border-radius: 20px; border: 1px solid var(--border);
}
.api-status-header i { font-size: 0.5rem; color: var(--yellow); }
.api-status-header.live i { color: var(--green); }
.api-status-header.live span { color: var(--green); }

/* ==========================================
   VIEW CONTAINERS
   ========================================== */
.view-container {
    display: none !important;
    flex: 1;
    overflow: hidden;
}
.view-container.active {
    display: flex !important;
    flex: 1;
}

/* ==========================================
   TOOL PAGE LAYOUT (AI Search, Funnel, Check-in)
   ========================================== */
.tool-page {
    flex: 1;
    padding: 28px 32px;
    overflow-y: auto;
}
.tool-page::-webkit-scrollbar { width: 6px; }
.tool-page::-webkit-scrollbar-thumb { background: var(--bg-card); border-radius: 4px; }
.tool-header {
    margin-bottom: 24px;
}
.tool-header h1 {
    font-size: 1.6rem;
    font-weight: 800;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.tool-header p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* Metrics Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.metric-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 18px 20px;
}
.metric-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.metric-header span {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.metric-header i {
    font-size: 1rem;
    opacity: 0.8;
}
.metric-card h3 {
    font-size: 1.8rem;
    font-weight: 800;
    color: white;
}

/* Tool Grid (2-column) */
.tool-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
    gap: 24px;
    align-items: start;
}
.tool-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 24px;
}
.tool-card h3 {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.tool-card-desc {
    color: var(--text-muted);
    font-size: 0.88rem;
    margin-bottom: 18px;
    line-height: 1.5;
}

/* Tool page form elements */
.tool-page .form-group {
    margin-bottom: 16px;
}
.tool-page label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.tool-page input[type="text"],
.tool-page input[type="tel"],
.tool-page input[type="password"],
.tool-page textarea,
.tool-page select {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-main);
    font-size: 0.9rem;
    font-family: inherit;
    transition: var(--transition);
}
.tool-page input:focus,
.tool-page textarea:focus,
.tool-page select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.tool-page textarea {
    resize: vertical;
    min-height: 70px;
}

/* Primary Button */
.primary-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
}
.primary-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(99,102,241,0.4);
}
.primary-btn.full-width, .full-width { width: 100%; }

/* Icon button small */
.icon-btn-small {
    background: transparent;
    border: none;
    color: #10b981;
    font-weight: bold;
    font-size: 0.78rem;
    cursor: pointer;
    padding: 0;
}
.icon-btn-small:hover { opacity: 0.8; }

/* Upload Zone */
.upload-zone {
    border: 2px dashed rgba(99,102,241,0.3);
    border-radius: var(--radius);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 20px;
    background: rgba(99,102,241,0.03);
}
.upload-zone:hover {
    border-color: var(--accent);
    background: rgba(99,102,241,0.08);
}
.upload-zone h3 {
    color: var(--text-main);
    justify-content: center;
    margin-bottom: 4px;
}
.upload-preview {
    width: 100%;
    max-height: 200px;
    object-fit: cover;
    border-radius: var(--radius);
    margin-bottom: 16px;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #374151;
    border-radius: 26px;
    transition: 0.3s;
}
.toggle-slider::before {
    content: '';
    position: absolute;
    height: 20px; width: 20px;
    left: 3px; bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.3s;
}
.toggle-switch input:checked + .toggle-slider {
    background: #10b981;
}
.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(22px);
}

/* Empty state small */
.empty-state-small {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}
.empty-state-small i {
    font-size: 2rem;
    margin-bottom: 12px;
    opacity: 0.3;
}
.empty-state-small p {
    font-size: 0.88rem;
}

/* AI Results Table */
.ai-results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
.ai-results-table th {
    text-align: left;
    padding: 10px 12px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-dim);
    border-bottom: 1px solid var(--border);
}
.ai-results-table td {
    padding: 10px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    color: var(--text-main);
}
.ai-results-table tr:hover td {
    background: rgba(255,255,255,0.02);
}
.ai-badge-yes {
    display: inline-flex; align-items: center; gap: 4px;
    background: rgba(34,197,94,0.15); color: #22c55e;
    padding: 3px 10px; border-radius: 12px; font-weight: 600; font-size: 0.78rem;
}
.ai-badge-no {
    display: inline-flex; align-items: center; gap: 4px;
    background: rgba(239,68,68,0.15); color: #ef4444;
    padding: 3px 10px; border-radius: 12px; font-weight: 600; font-size: 0.78rem;
}

/* Campaign list items */
.campaign-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    font-size: 0.88rem;
}
.campaign-item:last-child { border-bottom: none; }
.campaign-name { color: var(--text-main); font-weight: 600; }
.campaign-phone { color: var(--text-muted); font-size: 0.8rem; }
.campaign-status {
    font-size: 0.7rem;
    padding: 3px 8px;
    border-radius: 10px;
    font-weight: 600;
}
.campaign-status.active {
    background: rgba(34,197,94,0.15);
    color: #22c55e;
}

/* ==========================================
   MOBILE SIDEBAR OVERLAY
   ========================================== */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    z-index: 250;
    backdrop-filter: blur(4px);
}
.sidebar-overlay.open,
.sidebar-overlay.active {
    display: block;
}

/* ==========================================
   MOBILE-FIRST RESPONSIVE OVERRIDES
   ========================================== */
@media (max-width: 768px) {
    /* Body scrollable */
    body {
        height: auto;
        overflow: auto;
        flex-direction: column;
    }

    /* Sidebar hidden by default, slides in */
    .suite-sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 300;
        box-shadow: none;
        width: 280px;
        min-width: 280px;
        max-width: 280px;
    }
    .suite-sidebar.open {
        transform: translateX(0) !important;
        box-shadow: 8px 0 40px rgba(0,0,0,0.5) !important;
    }

    /* Content full width */
    .suite-content {
        margin-left: 0 !important;
        width: 100% !important;
        height: auto !important;
        overflow: visible !important;
    }

    /* Show hamburger */
    .sidebar-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
    }

    /* Header compact */
    .content-header {
        padding: 8px 14px;
        min-height: 48px;
    }
    .view-title {
        font-size: 1rem;
    }
    .api-status-header span {
        display: none;
    }

    /* Tool page padding */
    .tool-page {
        padding: 16px !important;
    }
    .tool-header h1 {
        font-size: 1.3rem !important;
    }
    .tool-header p {
        font-size: 0.85rem !important;
    }

    /* Metrics grid — 2 col on phone */
    .metrics-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 10px !important;
    }
    .metric-card {
        padding: 14px !important;
    }
    .metric-card h3 {
        font-size: 1.3rem !important;
    }

    /* Tool grid — single column */
    .tool-grid,
    .tool-content-grid {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }

    /* Cards full width */
    .tool-card {
        padding: 16px !important;
    }

    /* Form inputs touch-friendly */
    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 14px 12px !important;
        font-size: 16px !important; /* Prevents iOS zoom */
        border-radius: 10px !important;
    }

    /* Rank Tracker layout */
    #app-main {
        flex-direction: column !important;
    }
    .search-panel {
        width: 100% !important;
        min-width: 100% !important;
        max-height: none !important;
        border-right: none !important;
        border-bottom: 1px solid var(--border);
        overflow-y: visible !important;
    }
    .map-container {
        min-height: 50vh !important;
    }

    /* Buttons */
    .primary-btn,
    .scan-btn,
    #ai-scan-btn,
    #launch-review-btn,
    #checkin-publish-btn {
        padding: 16px !important;
        font-size: 1rem !important;
        border-radius: 12px !important;
    }

    /* Results table scroll */
    .results-table {
        font-size: 0.8rem;
    }
    .results-table th,
    .results-table td {
        padding: 8px 6px !important;
    }

    /* Blog content */
    .blog-output {
        padding: 16px !important;
    }

    /* Icon buttons */
    .icon-btn-small {
        padding: 8px 12px !important;
        font-size: 0.8rem !important;
    }

    /* Modal full-screen on mobile */
    .modal {
        width: 95vw !important;
        max-height: 90vh !important;
        margin: 5vh auto !important;
    }
    .modal-wide {
        width: 95vw !important;
    }
}

/* Extra small phones */
@media (max-width: 380px) {
    .metrics-grid {
        grid-template-columns: 1fr !important;
    }
    .suite-sidebar {
        width: 260px !important;
        min-width: 260px !important;
        max-width: 260px !important;
    }
}
