/* ── proScan Design System ── */
/* Dark theme · Poppins · Yellow accent */

:root {
    --bg: #0d0d0d;
    --surface: #161616;
    --border: #222222;
    --text: #ffffff;
    --text-secondary: #999999;
    --text-tertiary: #666666;
    --accent: #f59e0b;
    --accent-hover: #fbbf24;
    --accent-dim: rgba(245, 158, 11, 0.12);
    --red: #ff4d4d;
    --red-dim: rgba(255, 77, 77, 0.12);
    --yellow: #ffc107;
    --yellow-dim: rgba(255, 193, 7, 0.12);
    --green: #22c55e;
    --green-dim: rgba(34, 197, 94, 0.12);
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.4);
    --transition: 0.2s ease;
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* ── Layout ── */

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

/* ── Typography ── */

h1 {
    font-size: 48px;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.1;
}

h2 {
    font-size: 32px;
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1.2;
}

h3 {
    font-size: 20px;
    font-weight: 500;
    line-height: 1.3;
}

p {
    font-size: 16px;
    color: var(--text-secondary);
}

.text-sm { font-size: 14px; }
.text-xs { font-size: 12px; }
.text-accent { color: var(--accent); }
.text-red { color: var(--red); }
.text-green { color: var(--green); }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }

/* ── Top Bar ── */

.topbar-outer {
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px 32px;
}

.topbar-brand {
    display: inline-flex;
    align-items: center;
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
    letter-spacing: -0.01em;
}

.topbar-brand span {
    color: var(--accent);
}

.topbar-nav {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-link {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-tertiary);
    text-decoration: none;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.topbar-link:hover {
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.04);
}

.topbar-link.active {
    color: var(--accent);
}

/* ── Cards ── */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    transition: border-color var(--transition);
}

.card:hover {
    border-color: #333;
}

.card-interactive {
    cursor: pointer;
}

.card-interactive:hover {
    border-color: var(--accent);
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

/* ── Stats Grid ── */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
}

.stat-value {
    font-size: 36px;
    font-weight: 600;
    color: var(--text);
}

.stat-label {
    font-size: 12px;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 4px;
}

/* ── Buttons ── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-family: 'Poppins', sans-serif;
    font-size: 14px;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    line-height: 1;
}

.btn-primary {
    background: var(--accent);
    color: #000;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    border-color: #444;
    background: rgba(255, 255, 255, 0.04);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 12px;
}

.btn-lg {
    padding: 16px 32px;
    font-size: 16px;
}

/* ── Badges ── */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    border-radius: 100px;
    line-height: 1;
}

.badge-accent {
    background: var(--accent-dim);
    color: var(--accent);
}

.badge-green {
    background: var(--green-dim);
    color: var(--green);
}

.badge-red {
    background: var(--red-dim);
    color: var(--red);
}

.badge-yellow {
    background: var(--yellow-dim);
    color: var(--yellow);
}

/* ── Tables ── */

.table-wrapper {
    overflow-x: auto;
}

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

th {
    text-align: left;
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
}

td {
    padding: 14px 16px;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
}

tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

tr.clickable {
    cursor: pointer;
}

th a {
    color: inherit;
    text-decoration: none;
}

th a:hover {
    color: var(--accent);
}

/* ── Inputs ── */

input, select {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    font-family: 'Poppins', sans-serif;
    font-size: 14px;
    color: var(--text);
    transition: border-color var(--transition);
    width: 100%;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--accent);
}

input::placeholder {
    color: var(--text-tertiary);
}

/* ── Search Bar ── */

.search-bar {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.search-bar input {
    max-width: 320px;
}

.search-bar select {
    max-width: 160px;
}

/* ── Customer Row ── */

.customer-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    vertical-align: middle;
}

.customer-avatar-lg {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--border);
}

/* ── Profile Page ── */

.profile-header {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 40px 0 24px;
}

.profile-info h1 {
    font-size: 32px;
    margin-bottom: 4px;
}

.profile-meta {
    display: flex;
    gap: 16px;
    font-size: 14px;
    color: var(--text-secondary);
}

/* ── Confidence Meter ── */

.confidence-meter {
    margin: 24px 0;
}

.confidence-bar {
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 8px;
}

.confidence-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

.confidence-fill.low { background: var(--red); }
.confidence-fill.mid { background: var(--yellow); }
.confidence-fill.high { background: var(--green); }

/* ── Profile Sections ── */

.profile-sections {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-top: 24px;
}

@media (max-width: 900px) {
    .profile-sections { grid-template-columns: 1fr; }
}

.profile-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
}

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

.profile-section-header h3 {
    font-size: 16px;
    font-weight: 500;
}

.profile-field {
    margin-bottom: 12px;
}

.profile-field-label {
    font-size: 12px;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 2px;
}

.profile-field-value {
    font-size: 14px;
    color: var(--text);
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tag {
    display: inline-block;
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 100px;
    font-size: 12px;
    color: var(--text-secondary);
}

/* ── Accordion ── */

.accordion {
    margin-top: 32px;
}

.accordion-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 16px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: 'Poppins', sans-serif;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.accordion-trigger:hover {
    border-color: #333;
}

.accordion-trigger .arrow {
    transition: transform var(--transition);
}

.accordion-trigger.open .arrow {
    transform: rotate(180deg);
}

.accordion-content {
    display: none;
    padding: 16px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
}

.accordion-content.open {
    display: block;
}

.scrape-query {
    margin-bottom: 16px;
}

.scrape-query-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--accent);
    margin-bottom: 8px;
}

.scrape-result {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.scrape-result:last-child {
    border-bottom: none;
}

.scrape-result-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
}

.scrape-result-url {
    font-size: 12px;
    color: var(--accent);
    text-decoration: none;
    word-break: break-all;
}

.scrape-result-url:hover {
    text-decoration: underline;
}

.scrape-result-snippet {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ── Pagination ── */

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 32px;
}

.pagination a, .pagination span {
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    text-decoration: none;
    transition: all var(--transition);
}

.pagination a {
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.pagination a:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.pagination .current {
    background: var(--accent);
    color: #000;
    font-weight: 500;
}

/* ── Dashboard ── */

.dashboard-hero {
    text-align: center;
    padding: 60px 0 40px;
}

.dashboard-hero h1 {
    margin-bottom: 8px;
}

.dashboard-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 32px;
}

/* ── Progress Bar ── */

.progress-bar {
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    transition: width 0.3s ease;
}

/* ── Page Sections ── */

.page-header {
    padding: 40px 0 24px;
}

.page-content {
    padding: 0 0 60px;
}

/* ── Empty State ── */

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-tertiary);
}

.empty-state h3 {
    color: var(--text-secondary);
    margin-bottom: 8px;
}

/* ── Utility ── */

.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mt-32 { margin-top: 32px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-16 { gap: 16px; }

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

.card-enter {
    animation: cardEnter 0.3s ease forwards;
}

/* ── Web presence links ── */
.web-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--accent);
    text-decoration: none;
    font-size: 13px;
    transition: all var(--transition);
}

.web-link:hover {
    border-color: var(--accent);
    background: var(--accent-dim);
}

/* ── Brand Subtitle ── */

.brand-subtitle {
    font-size: 16px;
    font-weight: 400;
    color: var(--text-tertiary);
    margin-left: 8px;
    letter-spacing: 0.02em;
}

/* ── Animated Stripe Progress Bar ── */

.progress-bar-animated .progress-fill {
    background: repeating-linear-gradient(
        -45deg,
        var(--accent),
        var(--accent) 10px,
        rgba(245, 158, 11, 0.65) 10px,
        rgba(245, 158, 11, 0.65) 20px
    );
    background-size: 28.28px 100%;
    animation: stripeMove 0.6s linear infinite;
}

@keyframes stripeMove {
    0% { background-position: 0 0; }
    100% { background-position: 28.28px 0; }
}

.progress-bar-idle {
    display: none;
}

/* ── Analytics Section ── */

.analytics-section {
    padding: 40px 0 60px;
    display: none;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 32px 0 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.section-header h2 {
    font-size: 20px;
    font-weight: 600;
}

.section-header .section-badge {
    font-size: 12px;
    color: var(--text-tertiary);
}

/* ── Chart Grid ── */

.chart-row {
    display: grid;
    gap: 16px;
    margin-bottom: 16px;
}

.chart-row-3 { grid-template-columns: repeat(3, 1fr); }
.chart-row-2 { grid-template-columns: repeat(2, 1fr); }
.chart-row-2w { grid-template-columns: 3fr 2fr; }
.chart-row-1 { grid-template-columns: 1fr; }

/* ── Chart Card ── */

.chart-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    transition: border-color var(--transition);
    position: relative;
    cursor: pointer;
}

.chart-card:hover {
    border-color: #333;
}

.chart-card-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 12px;
}

.chart-card canvas {
    width: 100% !important;
}

.chart-card::after {
    content: 'Click to drill down';
    position: absolute;
    bottom: 6px;
    right: 10px;
    font-size: 10px;
    color: var(--text-tertiary);
    opacity: 0;
    transition: opacity var(--transition);
    pointer-events: none;
}

.chart-card:hover::after {
    opacity: 0.7;
}

/* ── VIP / Cross-sell Tables ── */

.vip-rank {
    font-size: 16px;
    font-weight: 600;
    color: var(--accent);
    width: 36px;
    text-align: center;
}

.vip-score-bar {
    display: inline-block;
    height: 6px;
    border-radius: 3px;
    background: var(--accent);
    vertical-align: middle;
    margin-left: 8px;
}

.crosssell-spend {
    font-weight: 600;
    color: var(--accent);
}

/* ── Filter Banner ── */

.filter-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--accent-dim);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 14px;
}

.filter-banner .filter-label {
    color: var(--accent);
    font-weight: 500;
}

.filter-banner .filter-value {
    color: var(--text);
}

.filter-banner .filter-clear {
    margin-left: auto;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 12px;
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.filter-banner .filter-clear:hover {
    border-color: var(--red);
    color: var(--red);
}

/* ── Treemap ── */

.treemap-container {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    min-height: 180px;
    align-content: flex-start;
}

.treemap-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    color: #fff;
    text-align: center;
    padding: 10px 8px;
    transition: opacity var(--transition), transform var(--transition);
    cursor: default;
    min-height: 54px;
    line-height: 1.3;
}

.treemap-item:hover {
    opacity: 0.85;
    transform: scale(1.02);
}

.treemap-item .treemap-count {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 2px;
}

.treemap-item .treemap-label {
    font-size: 11px;
    font-weight: 400;
    opacity: 0.85;
}

/* ── Geo Map ── */

.geo-map-wrap {
    position: relative;
    width: 100%;
    overflow: hidden;
}

.geo-map-wrap svg {
    width: 100%;
    height: auto;
    display: block;
}

.geo-circle {
    transition: r var(--transition), opacity var(--transition);
    cursor: pointer;
}

.geo-circle:hover {
    opacity: 1 !important;
}

.geo-tooltip {
    position: absolute;
    background: #1a1a1a;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: 12px;
    color: var(--text);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    white-space: nowrap;
    z-index: 10;
}

.geo-tooltip.visible {
    opacity: 1;
}

.geo-tooltip .geo-tt-state {
    font-weight: 600;
    color: var(--accent);
}

.chart-card-notclick {
    cursor: default;
}

.chart-card-notclick::after {
    display: none;
}

/* ── Responsive ── */

@media (max-width: 900px) {
    .chart-row-3 { grid-template-columns: 1fr; }
    .chart-row-2, .chart-row-2w { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
    .dashboard-actions { flex-direction: column; align-items: center; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
