:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --bg-color: #f3f4f6;
    --card-bg: #ffffff;
    --text-color: #1f2937;
    --border-color: #e5e7eb;
    --success-color: #10b981;
    --error-color: #ef4444;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --radius: 8px;
}

* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding: 24px;
    background-color: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

h1 {
    margin: 0;
    font-size: 28px;
    font-weight: 700;
}

h2 {
    margin: 0 0 16px 0;
    font-size: 20px;
    font-weight: 600;
}

.controls {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

/* Buttons */
button,
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-block;
}

#startBtn {
    background-color: var(--primary-color);
    color: white;
}

#startBtn:hover:not(:disabled) {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

#startBtn:disabled {
    background-color: #9ca3af;
    cursor: not-allowed;
    transform: none;
}

.btn.secondary {
    background-color: white;
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 8px 16px;
    font-size: 13px;
}

.btn.secondary:hover {
    background-color: #f9fafb;
}

.toggle-control {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    font-size: 14px;
    user-select: none;
}

.toggle-control input {
    margin-right: 8px;
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.status {
    font-weight: 500;
    color: #6b7280;
}

/* Stats Section */
.stats-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background-color: var(--card-bg);
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    text-align: center;
}

.stat-card h3 {
    margin-bottom: 12px;
    color: #6b7280;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

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

.stat-value.success {
    color: var(--success-color);
}

.stat-value.error {
    color: var(--error-color);
}

/* Logs */
.logs-section {
    margin-bottom: 24px;
}

.logs-container {
    background-color: #1f2937;
    color: #10b981;
    font-family: 'Consolas', 'Monaco', monospace;
    padding: 16px;
    border-radius: var(--radius);
    height: 300px;
    overflow-y: auto;
    font-size: 13px;
    line-height: 1.5;
    box-shadow: var(--shadow-sm);
}

.log-entry {
    margin-bottom: 4px;
    border-bottom: 1px solid #374151;
    padding-bottom: 2px;
}

/* Chart Section */
.chart-section {
    background-color: var(--card-bg);
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.chart-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chart-controls label {
    font-size: 14px;
    font-weight: 500;
    color: #6b7280;
}

.metric-selector {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    background-color: white;
    cursor: pointer;
    transition: border-color 0.2s;
}

.metric-selector:hover {
    border-color: var(--primary-color);
}

.metric-selector:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.quadrant-container {
    position: relative;
    width: calc(100% - 100px);
    height: 450px;
    background-color: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-left: 90px;
    /* Increased for Y ticks + larger label spacing */
    /* Space for Y label */
    margin-top: 70px;
    /* Space for X label and LEGEND */
    margin-bottom: 120px;
    /* Increased for X ticks + larger label spacing + Legend below */
    /* Space for X label */
    margin-right: 10px;
    overflow: visible;
}

.scatter-legend {
    position: absolute;
    bottom: -110px;
    left: 0;
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px 16px;
    pointer-events: none;
}

.scatter-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #475569;
}

.scatter-legend-swatch {
    width: 22px;
    height: 12px;
    border-radius: 2px;
    border: 2px solid transparent;
    box-sizing: border-box;
}

.scatter-trendline {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
}

.quadrant-point {
    z-index: 10;
}

.quadrant-line {
    position: absolute;
}

.quadrant-line.vertical {
    top: 0;
    bottom: 0;
    left: 50%;
    width: 2px;
    border-right: 2px dashed #cbd5e1;
    background: none;
}

.quadrant-line.horizontal {
    left: 0;
    right: 0;
    top: 50%;
    height: 2px;
    border-bottom: 2px dashed #cbd5e1;
    background: none;
}

.axis-label {
    position: absolute;
    font-size: 14px;
    color: #1e293b;
    font-weight: 700;
    letter-spacing: 0.3px;
}

/* Y-axis label - positioned OUTSIDE container on the left, centered vertically */
.y-axis {
    top: 50%;
    left: -65px;
    /* Increased from -50px for more space from tick numbers */
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: translateY(-50%) rotate(180deg);
    /* Center and rotate */
}

/* X-axis label - positioned OUTSIDE container at the bottom, centered horizontally */
.x-axis {
    bottom: -40px;
    /* Increased from -32px for more space from tick numbers */
    left: 50%;
    transform: translateX(-50%);
    /* Center horizontally */
    text-align: center;
}

.axis-tick {
    position: absolute;
    font-size: 11px;
    color: #64748b;
    pointer-events: none;
    font-weight: 500;
}

.axis-tick.x {
    bottom: -24px;
    /* Increased from -20px */
    transform: translateX(-50%);
}

.axis-tick.y {
    left: -50px;
    /* Increased from -35px for more space */
    width: 45px;
    /* Increased from 30px */
    text-align: right;
    transform: translateY(50%);
}

.chart-legend {
    position: absolute;
    top: -60px;
    right: 0;
    z-index: 30;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 8px 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    font-size: 12px;
    color: #475569;
    max-width: 500px;
    display: flex;
    gap: 16px;
    align-items: center;
}

.chart-legend-line {
    display: flex;
    align-items: center;
    gap: 6px;
    line-height: 1.2;
    white-space: nowrap;
}

.chart-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(37, 99, 235, 0.8);
    flex: 0 0 auto;
}

.q-label {
    position: absolute;
    font-size: 13px;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    z-index: 0;
    opacity: 0.5;
}

.q-leaders {
    top: 24px;
    right: 24px;
}

.q-visionaries {
    bottom: 24px;
    right: 24px;
}

.q-challengers {
    top: 24px;
    left: 24px;
}

.q-niche {
    bottom: 24px;
    left: 24px;
}

.quadrant-point {
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    transform: translate(-50%, 50%);
    cursor: pointer;
    z-index: 10;
    transition: all 0.2s;
}

.quadrant-point:hover {
    width: 24px;
    height: 24px;
    z-index: 20;
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.2);
}

.bank-point {
    position: absolute;
    width: 36px;
    height: 36px;
    background-color: var(--primary-color);
    border-radius: 50%;
    transform: translate(-50%, 50%);
    color: white;
    font-size: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
    z-index: 10;
    transition: transform 0.2s, box-shadow 0.2s;
}

.bank-point:hover {
    transform: translate(-50%, 50%) scale(1.15);
    z-index: 20;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.bank-point.highlight {
    background-color: #ef4444;
    border: 2px solid white;
    width: 44px;
    height: 44px;
    font-size: 11px;
    z-index: 15;
}

/* Results Section */
.results-section {
    background-color: var(--card-bg);
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 16px;
}

.results-meta {
    display: flex;
    align-items: center;
    gap: 16px;
}

.last-updated {
    font-size: 13px;
    color: #6b7280;
    font-style: italic;
}

.downloads {
    display: flex;
    gap: 8px;
}

/* Bank Accordion */
.bank-accordion {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.bank-card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background-color: #fafbfc;
    overflow: hidden;
    transition: box-shadow 0.2s;
}

.bank-card:hover {
    box-shadow: var(--shadow-md);
}

.bank-card-header {
    padding: 16px 20px;
    background-color: var(--card-bg);
    cursor: pointer;
    user-select: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.2s;
}

.bank-card-header:hover {
    background-color: #f9fafb;
}

.bank-card-header.expanded {
    border-bottom: 1px solid var(--border-color);
}

.bank-card-title {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.bank-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-color);
}

.bank-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 13px;
    color: #6b7280;
}

.bank-meta-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.bank-status {
    display: inline-flex;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.bank-status.success {
    background-color: #d1fae5;
    color: #065f46;
}

.bank-status.failed {
    background-color: #fee2e2;
    color: #991b1b;
}

.toggle-icon {
    font-size: 20px;
    color: #9ca3af;
    transition: transform 0.2s;
}

.toggle-icon.expanded {
    transform: rotate(180deg);
}

.bank-card-content {
    max-height: 2000px;
    overflow-y: hidden;
}

.bank-card-body {
    padding: 20px;
}

.bank-content {
    padding: 0;
}

.bank-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
    padding: 16px;
    background-color: #f8fafc;
    border-radius: 6px;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.info-label {
    font-size: 12px;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.info-value {
    font-size: 14px;
    color: var(--text-color);
    font-weight: 500;
}

.products-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    overflow: hidden;
}

.products-table th,
.products-table td {
    text-align: left;
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
    height: 48px;
    line-height: 1.2;
}

.products-table th {
    background-color: #f9fafb;
    font-weight: 600;
    font-size: 13px;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.products-table tbody tr:last-child td {
    border-bottom: none;
}

.products-table tr:hover {
    background-color: #f9fafb;
}

.products-table td {
    font-size: 14px;
}

.rate-cell {
    font-variant-numeric: tabular-nums;
    text-align: right;
    white-space: nowrap;
    font-weight: 600;
    color: #0f172a;
}

.money-cell {
    font-variant-numeric: tabular-nums;
    text-align: right;
    white-space: nowrap;
}

.date-cell {
    white-space: nowrap;
    color: #334155;
}

.product-name {
    font-weight: 600;
    color: #0f172a;
}

.app-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.app-link:hover {
    text-decoration: underline;
}

.screenshots-section {
    margin-top: 20px;
}

.screenshots-section h4 {
    margin: 0 0 12px 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-color);
}

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

.screenshot-item {
    border: 1px solid var(--border-color);
    border-radius: 6px;
    overflow: hidden;
    background: white;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
}

.screenshot-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.screenshot-item img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    object-position: top;
    display: block;
}

.screenshot-caption {
    padding: 8px;
    font-size: 11px;
    color: #666;
    background: #f9fafb;
    border-top: 1px solid var(--border-color);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.no-data {
    padding: 40px 20px;
    text-align: center;
    color: #9ca3af;
    font-style: italic;
}

/* Modal */
.modal {
    display: flex;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.75);
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
}

.hidden {
    display: none !important;
}

.modal-content {
    background-color: white;
    padding: 32px;
    border-radius: 12px;
    width: 90%;
    max-width: 1000px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.close-modal {
    color: #9ca3af;
    float: right;
    font-size: 32px;
    font-weight: bold;
    cursor: pointer;
    position: absolute;
    right: 24px;
    top: 16px;
    transition: color 0.2s;
}

.close-modal:hover {
    color: #1f2937;
}

#modalTitle {
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 24px;
}

#screenshotGallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

/* App Layout */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: #1f2937;
    color: white;
    display: flex;
    flex-direction: column;
    padding: 24px 0;
    transition: width 0.3s ease;
    flex-shrink: 0;
}

.sidebar.collapsed {
    width: 80px;
}

.sidebar-header {
    padding: 0 24px;
    margin-bottom: 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h2 {
    font-size: 20px;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar.collapsed .sidebar-header h2 {
    display: none;
}

.icon-btn {
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    font-size: 20px;
    padding: 4px;
}

.icon-btn:hover {
    color: white;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 0 12px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    color: #9ca3af;
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.2s;
    font-size: 14px;
    font-weight: 500;
}

.nav-item:hover,
.nav-item.active {
    background-color: #374151;
    color: white;
}

.nav-item .icon {
    font-size: 18px;
    min-width: 24px;
    text-align: center;
}

.sidebar.collapsed .nav-item .label {
    display: none;
}

/* Main Content */
.main-content {
    flex: 1;
    background-color: var(--bg-color);
    padding: 32px;
    overflow-y: auto;
    height: 100vh;
}

/* View Sections */
.view-section {
    display: none;
    animation: fadeIn 0.3s ease-out;
}

.view-section.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Modern Tables */
.table-container {
    background: white;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

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

.modern-table th {
    background-color: #f9fafb;
    color: #6b7280;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    text-align: left;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
}

.modern-table td {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
    color: var(--text-color);
}

.modern-table tbody tr:hover {
    background-color: #f9fafb;
}

.text-sm {
    font-size: 14px;
}

.text-gray-500 {
    color: #6b7280;
}

.text-center {
    text-align: center;
}

.card {
    background: white;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    padding: 0;
    /* Let table fill */
    overflow: hidden;
}

.section-header {
    margin-bottom: 24px;
}

.section-header h2 {
    margin-bottom: 4px;
}

/* Filter Group */
.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-group label {
    font-size: 14px;
    font-weight: 600;
    color: #4b5563;
}

/* Badges */
.badge {
    display: inline-flex;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    background-color: #e5e7eb;
    color: #374151;
}

.badge.type-cd {
    background-color: #dbeafe;
    color: #1e40af;
}

.badge.type-savings {
    background-color: #d1fae5;
    color: #065f46;
}

.badge.type-checking {
    background-color: #f3f4f6;
    color: #1f2937;
}

.badge.type-money_market {
    background-color: #ffedd5;
    color: #9a3412;
}

.badge.type-credit_card {
    background-color: #fce7f3;
    color: #9d174d;
}

.badge.type-loan {
    background-color: #e0e7ff;
    color: #3730a3;
}

.badge.type-other {
    background-color: #f3f4f6;
    color: #4b5563;
}

/* Features */
.features-cell {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.feature-tag {
    font-size: 10px;
    background-color: #f0f9ff;
    color: #0369a1;
    border: 1px solid #bae6fd;
    padding: 1px 4px;
    border-radius: 4px;
    white-space: nowrap;
}

/* Chart Container for Radar */
.chart-container {
    position: relative;
    width: 100%;
}

/* Responsive */
@media (max-width: 1024px) {
    .sidebar {
        position: fixed;
        height: 100%;
        z-index: 50;
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar.collapsed {
        width: 260px;
    }

    .main-content {
        padding: 16px;
    }
}

@media (max-width: 768px) {
    body {
        padding: 0;
    }

    header {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* Charts Layout */
.charts-row {
    display: flex;
    gap: 24px;
    margin-top: 24px;
    align-items: stretch;
}

.correlation-chart {
    flex: 2;
    margin-top: 0 !important;
}

.radar-chart {
    flex: 1;
    margin-top: 0 !important;
}

@media (max-width: 1024px) {
    .charts-row {
        flex-direction: column;
    }

    .correlation-chart,
    .radar-chart {
        flex: auto;
    }
}
