@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=JetBrains+Mono:wght@400;600&display=swap');

/* ===========================
   CSS Variables & Reset
   =========================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #0a0b0d;
    --bg-secondary: #12151a;
    --bg-tertiary: #1a1f26;
    --bg-card: #1e232b;
    --bg-hover: #252b35;
    --accent-primary: #3b82f6;
    --accent-success: #10b981;
    --accent-warning: #f59e0b;
    --accent-danger: #ef4444;
    --text-primary: #ffffff;
    --text-secondary: #94a3b8;
    --text-dim: #475569;
    --border-color: #2a3441;
    --gradient-primary: linear-gradient(135deg, #3b82f6, #2563eb);
    --gradient-success: linear-gradient(135deg, #10b981, #059669);
    --gradient-warning: linear-gradient(135deg, #f59e0b, #d97706);
    --gradient-danger: linear-gradient(135deg, #ef4444, #dc2626);
    --header-height: 60px;
    --nav-height: 60px;
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

body {
    font-family: 'Space Grotesk', -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow-x: hidden;
    position: relative;
    min-height: 100vh;
    padding-bottom: calc(var(--nav-height) + var(--safe-area-bottom));
}

/* Animated background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 50%, rgba(255, 51, 102, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(0, 255, 136, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 40% 20%, rgba(255, 170, 0, 0.08) 0%, transparent 50%);
    animation: meshMove 30s ease-in-out infinite;
    z-index: -1;
    pointer-events: none;
}

@keyframes meshMove {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(-20px, -20px) scale(1.1); }
    66% { transform: translate(20px, -10px) scale(0.95); }
}

/* ===========================
   Header
   =========================== */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-bottom: 2px solid var(--border-color);
    z-index: 1000;
    backdrop-filter: blur(10px);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    height: var(--header-height);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    width: 36px;
    height: 36px;
    background: var(--gradient-primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--bg-primary);
    font-size: 0.9rem;
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 700;
    background: linear-gradient(135deg, #fff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-icon {
    width: 40px;
    height: 40px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.btn-icon:hover, .btn-icon:active {
    background: var(--bg-hover);
    color: var(--text-primary);
    transform: scale(0.95);
}

/* Search Container */
.search-container {
    display: none;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border-color);
    animation: slideDown 0.3s ease;
}

.search-container.active {
    display: flex;
    gap: 0.5rem;
}

.search-input {
    flex: 1;
    padding: 0.75rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
}

.search-input:focus {
    outline: none;
    border-color: var(--accent-warning);
}

.btn-close {
    width: 40px;
    height: 40px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Status Bar */
.status-bar {
    padding: 0.5rem 1rem;
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.75rem;
    background: rgba(0, 255, 136, 0.1);
    border: 1px solid rgba(0, 255, 136, 0.3);
    border-radius: 100px;
    font-size: 0.75rem;
}

.pulse-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
}

.pulse-dot.live { background: var(--accent-success); }
.pulse-dot.cached { background: var(--accent-warning); }
.pulse-dot.error { background: var(--accent-danger); }

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.5); opacity: 0.5; }
}

/* ===========================
   Mobile Navigation
   =========================== */
.mobile-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-top: 2px solid var(--border-color);
    display: flex;
    justify-content: space-around;
    padding-bottom: var(--safe-area-bottom);
    z-index: 1000;
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    padding: 0.75rem 0.5rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.7rem;
    font-family: inherit;
    font-weight: 500;
}

.nav-item.active {
    color: var(--accent-warning);
}

.nav-item svg {
    width: 24px;
    height: 24px;
}

/* ===========================
   Slide-out Menu
   =========================== */
.slide-menu {
    position: fixed;
    top: 0;
    right: -100%;
    width: 85%;
    max-width: 320px;
    height: 100%;
    background: var(--bg-secondary);
    z-index: 2000;
    transition: right 0.3s ease;
    overflow-y: auto;
    padding-bottom: calc(var(--nav-height) + var(--safe-area-bottom));
}

.slide-menu.active {
    right: 0;
}

.slide-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem 1rem;
    border-bottom: 2px solid var(--border-color);
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
    z-index: 10;
}

.slide-menu-header h3 {
    font-size: 1.25rem;
}

.slide-menu-content {
    padding: 1rem;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    margin-bottom: 0.5rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    text-align: left;
    font-family: inherit;
    font-size: 1rem;
}

.menu-item:hover, .menu-item:active {
    background: var(--bg-hover);
    transform: translateX(-5px);
}

.menu-divider {
    height: 1px;
    background: var(--border-color);
    margin: 1rem 0;
}

.menu-section {
    margin-bottom: 1.5rem;
}

.menu-section h4 {
    font-size: 0.875rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.75rem;
}

.filter-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.filter-btn {
    padding: 0.5rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
    font-size: 0.875rem;
}

.filter-btn.active {
    background: var(--accent-warning);
    color: var(--bg-primary);
    border-color: var(--accent-warning);
}

/* ===========================
   Main Container & Views
   =========================== */
.main-container {
    padding-top: calc(var(--header-height) + 40px);
    min-height: 100vh;
}

.view {
    display: none;
    animation: fadeIn 0.3s ease;
}

.view.active {
    display: block;
}

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

@keyframes slideDown {
    from { max-height: 0; opacity: 0; }
    to { max-height: 100px; opacity: 1; }
}

/* Back Button */
.back-button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    margin: 1rem 1rem 0.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.back-button:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--accent-primary);
    transform: translateX(-4px);
}

.back-button svg {
    transition: transform 0.2s ease;
}

.back-button:hover svg {
    transform: translateX(-2px);
}

/* Hide back button on mobile */
@media (max-width: 768px) {
    .back-button {
        display: none !important;
    }
}

.view-header {
    padding: 1rem;
    background: var(--bg-secondary);
    border-bottom: 2px solid var(--border-color);
    position: sticky;
    top: calc(var(--header-height) + 40px);
    z-index: 100;
}

.view-header h2 {
    font-size: 1.5rem;
    margin-bottom: 0.75rem;
}

.quick-filters {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.quick-filters::-webkit-scrollbar {
    display: none;
}

.quick-filter-btn {
    padding: 0.5rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
    font-size: 0.875rem;
    white-space: nowrap;
    flex-shrink: 0;
}

.quick-filter-btn.active,
.quick-filter-btn:active {
    background: var(--accent-warning);
    color: var(--bg-primary);
    border-color: var(--accent-warning);
}

.news-filters {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ===========================
   Coin List
   =========================== */
.coin-list {
    padding: 1rem;
}

.coin-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    margin-bottom: 0.75rem;
    background: var(--bg-secondary);
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.coin-item:active {
    transform: scale(0.98);
    border-color: var(--accent-warning);
}

.coin-item.selected {
    border-color: var(--accent-warning);
    background: linear-gradient(135deg, rgba(255, 170, 0, 0.1), rgba(255, 170, 0, 0.05));
}

.coin-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
}

.coin-rank {
    min-width: 24px;
    font-size: 0.75rem;
    color: var(--text-dim);
    font-weight: 600;
}

.coin-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
    color: white;
    flex-shrink: 0;
}

.coin-icon-img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    flex-shrink: 0;
    object-fit: cover;
    background: var(--bg-tertiary);
}

.coin-icon-fallback {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
    color: white;
    flex-shrink: 0;
    background: linear-gradient(135deg, var(--accent-warning), var(--accent-success));
}

.coin-details h3 {
    font-size: 1rem;
    font-weight: 600;
}

.coin-details p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.coin-stats {
    text-align: right;
}

.coin-price {
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.coin-change {
    font-size: 0.875rem;
}

.coin-change.positive { color: var(--accent-success); }
.coin-change.negative { color: var(--accent-danger); }

/* ===========================
   Analysis Content
   =========================== */
.analysis-content {
    padding: 1rem;
}

.coin-header {
    background: var(--bg-secondary);
    border-radius: 20px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.coin-header-top {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.coin-header-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.5rem;
    color: white;
    flex-shrink: 0;
}

.coin-header-icon-img {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    flex-shrink: 0;
    object-fit: cover;
    background: var(--bg-tertiary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.coin-header-icon-fallback {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.5rem;
    color: white;
    flex-shrink: 0;
    background: linear-gradient(135deg, var(--accent-warning), var(--accent-success));
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.coin-header-info h2 {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

.coin-header-rank {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.coin-header-price {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    flex-wrap: wrap;
}

.price-main {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.75rem;
    font-weight: 600;
}

.price-change {
    font-size: 1.25rem;
}

.grade-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    border-radius: 16px;
    font-size: 2rem;
    font-weight: 700;
    margin-top: 1rem;
}

.section-title {
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-dim);
    margin: 1.5rem 0 1rem;
}

.sources-grid,
.risk-grid,
.analysis-grid {
    display: grid;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.source-card,
.risk-card,
.analysis-card {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 1.25rem;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.risk-card {
    border-left: 4px solid var(--border-color);
    cursor: pointer;
}

.risk-card.positive { border-left-color: var(--accent-success); }
.risk-card.warning { border-left-color: var(--accent-warning); }
.risk-card.critical { border-left-color: var(--accent-danger); }

.risk-card:active,
.analysis-card:active {
    transform: scale(0.98);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.card-title {
    font-weight: 600;
    font-size: 1rem;
}

.risk-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
}

.risk-score {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.risk-weight {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.risk-summary {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
}

/* ===========================
   News List
   =========================== */
.news-list {
    padding: 1rem;
}

.news-item {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.news-item:active {
    transform: scale(0.98);
    border-color: var(--accent-warning);
}

.news-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    font-size: 0.75rem;
}

.news-source {
    padding: 0.25rem 0.75rem;
    background: var(--bg-tertiary);
    border-radius: 10px;
    font-weight: 600;
    color: var(--text-secondary);
}

.news-time {
    color: var(--text-dim);
}

.news-title {
    font-weight: 600;
    font-size: 1rem;
    line-height: 1.4;
    margin-bottom: 0.5rem;
}

.news-summary {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ===========================
   Reports View
   =========================== */
.reports-grid {
    padding: 1rem;
    display: grid;
    gap: 1rem;
}

.report-card {
    background: var(--bg-secondary);
    border-radius: 20px;
    padding: 2rem 1.5rem;
    text-align: center;
    border: 2px solid var(--border-color);
    transition: all 0.3s ease;
    cursor: pointer;
}

.report-card:active {
    transform: scale(0.98);
    border-color: var(--accent-warning);
}

.report-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.report-card h3 {
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
}

.report-card p {
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

.btn-primary {
    padding: 0.75rem 1.5rem;
    background: var(--gradient-safe);
    border: none;
    border-radius: 12px;
    color: var(--bg-primary);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary:active {
    transform: scale(0.95);
}

.btn-secondary {
    padding: 0.75rem 1.5rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-secondary:active {
    transform: scale(0.95);
}

/* ===========================
   Modals
   =========================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 3000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: fadeIn 0.3s ease;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: 20px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(100px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem;
    border-bottom: 2px solid var(--border-color);
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
    z-index: 10;
}

.modal-header h3 {
    font-size: 1.25rem;
}

.modal-body {
    padding: 1.5rem;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

.modal-actions button {
    flex: 1;
    min-width: 140px;
}

.export-preview {
    background: var(--bg-tertiary);
    border-radius: 12px;
    padding: 1rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 400px;
    overflow-y: auto;
    line-height: 1.6;
}

/* Risk Modal Content */
.risk-modal-score {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.score-display {
    font-size: 2.5rem;
    font-weight: 700;
}

.score-bar-container {
    flex: 1;
}

.score-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.score-fill {
    height: 100%;
    transition: width 0.5s ease;
}

.score-info {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.detail-list {
    margin-bottom: 1.5rem;
}

.detail-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border-radius: 10px;
}

.detail-bullet {
    width: 6px;
    height: 6px;
    background: var(--accent-warning);
    border-radius: 50%;
    margin-top: 0.5rem;
    flex-shrink: 0;
}

.detail-text {
    font-size: 0.875rem;
    line-height: 1.6;
    color: var(--text-secondary);
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.metric-card {
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

.metric-label {
    font-size: 0.75rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.25rem;
}

.metric-value {
    font-size: 1.25rem;
    font-weight: 700;
}

/* Market Trends */
.trend-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    margin-bottom: 1rem;
}

.trend-info {
    flex: 1;
}

.trend-period {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.trend-value {
    font-size: 1.5rem;
    font-weight: 700;
}

.trend-icon {
    font-size: 2rem;
}

/* ===========================
   Overlay
   =========================== */
.overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1500;
    backdrop-filter: blur(5px);
}

.overlay.active {
    display: block;
}

/* ===========================
   Loading & Empty States
   =========================== */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--accent-warning);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    text-align: center;
    color: var(--text-secondary);
}

.empty-state svg {
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.empty-state p {
    font-size: 0.875rem;
    line-height: 1.6;
}

/* ===========================
   Tablet & Desktop Styles
   =========================== */
@media (min-width: 768px) {
    :root {
        --header-height: 70px;
        --nav-height: 0px;
    }
    
    body {
        padding-bottom: 0;
    }
    
    .mobile-nav {
        display: none;
    }
    
    .header-content {
        padding: 1rem 2rem;
    }
    
    .logo-icon {
        width: 40px;
        height: 40px;
    }
    
    .logo-text {
        font-size: 1.5rem;
    }
    
    .main-container {
        padding-top: calc(var(--header-height) + 40px);
        max-width: 1400px;
        margin: 0 auto;
    }
    
    .sources-grid,
    .analysis-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .risk-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .reports-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .coin-item:hover {
        transform: translateX(5px);
        border-color: var(--accent-warning);
    }
    
    .news-item:hover,
    .report-card:hover {
        transform: scale(1.02);
        border-color: var(--accent-warning);
    }
}

@media (min-width: 1024px) {
    .sources-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .analysis-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .risk-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .slide-menu {
        max-width: 400px;
    }
}

@media (min-width: 1200px) {
    .risk-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ===========================
   Stock-Specific Styles
   =========================== */

/* Popular Grid */
.popular-section {
    padding: 1rem;
    padding-top: 0;
}

.section-subtitle {
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-dim);
    margin-bottom: 1rem;
}

.popular-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.popular-card {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 1rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.popular-card:active {
    transform: scale(0.95);
    border-color: var(--accent-primary);
}

.popular-symbol {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent-primary);
    margin-bottom: 0.25rem;
}

.popular-name {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Stock List Section */
.stock-list-section {
    padding: 1rem;
    padding-top: 0;
}

.stock-list {
    display: grid;
    gap: 0.75rem;
}

.stock-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.stock-item:active {
    transform: scale(0.98);
    border-color: var(--accent-primary);
}

.stock-item.selected {
    border-color: var(--accent-primary);
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(37, 99, 235, 0.05));
}

.stock-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
}

.stock-symbol {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent-primary);
    min-width: 60px;
}

.stock-details h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.stock-details p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.stock-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.sector-badge,
.market-badge {
    padding: 0.25rem 0.75rem;
    background: var(--bg-tertiary);
    border-radius: 12px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.market-badge {
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent-primary);
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.stock-action svg {
    color: var(--text-dim);
}

/* Analysis Type Toggle */
.analysis-toggle {
    display: flex;
    gap: 0.5rem;
    padding: 1rem;
    margin-bottom: 1rem;
}

.toggle-btn {
    flex: 1;
    padding: 0.875rem 1rem;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.toggle-btn.active {
    background: var(--gradient-primary);
    color: white;
    border-color: var(--accent-primary);
}

/* Stock Header */
.stock-header {
    background: var(--bg-secondary);
    border-radius: 20px;
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.stock-header h2 {
    font-size: 1.5rem;
    margin-bottom: 0.75rem;
}

.stock-header .stock-meta {
    margin-top: 0.75rem;
}

/* Section Cards */
.section-card {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    border: 1px solid var(--border-color);
}

.section-card h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

/* Score Summary */
.score-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.score-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: 12px;
}

.score-label {
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-bottom: 0.5rem;
    text-align: center;
}

.score-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-primary);
}

/* Factor Scoring */
.factors-grid {
    display: grid;
    gap: 1rem;
}

.factor-item {
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: 12px;
}

.factor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.factor-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.factor-score {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--accent-primary);
}

.factor-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-primary);
    border-radius: 4px;
    overflow: hidden;
}

.factor-fill {
    height: 100%;
    transition: width 0.5s ease;
}

.factor-fill.high {
    background: var(--gradient-success);
}

.factor-fill.medium {
    background: var(--gradient-warning);
}

.factor-fill.low {
    background: var(--gradient-danger);
}

.factor-description {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
    line-height: 1.5;
}

/* Classification Card */
.classification-card {
    text-align: center;
    border: 2px solid;
    position: relative;
    overflow: hidden;
}

.classification-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
}

.classification-card.durable-compounder {
    border-color: var(--accent-success);
    background: rgba(16, 185, 129, 0.1);
}

.classification-card.durable-compounder::before {
    background: var(--gradient-success);
}

.classification-card.strong-but-sensitive {
    border-color: var(--accent-warning);
    background: rgba(245, 158, 11, 0.1);
}

.classification-card.strong-but-sensitive::before {
    background: var(--gradient-warning);
}

.classification-card.externally-carried {
    border-color: var(--accent-primary);
    background: rgba(59, 130, 246, 0.1);
}

.classification-card.externally-carried::before {
    background: var(--gradient-primary);
}

.classification-card.weak-speculative {
    border-color: var(--accent-danger);
    background: rgba(239, 68, 68, 0.1);
}

.classification-card.weak-speculative::before {
    background: var(--gradient-danger);
}

/* Good/Bad/Ugly Sections */
.gbu-section {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    border-left: 4px solid;
}

.good-section {
    border-left-color: var(--accent-success);
}

.bad-section {
    border-left-color: var(--accent-warning);
}

.ugly-section {
    border-left-color: var(--accent-danger);
}

.gbu-section h3 {
    font-size: 1.125rem;
    font-weight: 700;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.gbu-point {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.gbu-point:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.gbu-point h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.gbu-point p {
    font-size: 0.875rem;
    line-height: 1.7;
    color: var(--text-secondary);
}

/* Markets View */
.markets-content {
    padding: 1rem;
}

.indices-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
}

.index-card {
    background: var(--bg-tertiary);
    border-radius: 12px;
    padding: 1rem;
    text-align: center;
}

.index-name {
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.index-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.index-change {
    font-size: 0.875rem;
    font-weight: 600;
}

.index-change.positive {
    color: var(--accent-success);
}

.index-change.negative {
    color: var(--accent-danger);
}

/* Sector Performance */
.sector-list {
    display: grid;
    gap: 0.75rem;
}

.sector-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: 12px;
}

.sector-name {
    font-size: 0.875rem;
    font-weight: 600;
}

.sector-change {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.875rem;
    font-weight: 700;
}

.sector-change.positive {
    color: var(--accent-success);
}

.sector-change.negative {
    color: var(--accent-danger);
}

/* Market Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.stat-item {
    background: var(--bg-tertiary);
    border-radius: 12px;
    padding: 1rem;
    text-align: center;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-bottom: 0.5rem;
}

.stat-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-primary);
}

/* Watchlist Actions */
.watchlist-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
}

.btn-watchlist {
    flex: 1;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-watchlist.added {
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent-primary);
    border-color: var(--accent-primary);
}

.btn-watchlist:active {
    transform: scale(0.95);
}

/* Disclaimer */
.disclaimer {
    margin-top: 2rem;
    padding: 1rem;
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 12px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.disclaimer strong {
    color: var(--text-primary);
}

/* Tablet & Desktop Adjustments */
@media (min-width: 768px) {
    .popular-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }
    
    .indices-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .stock-item:hover {
        transform: translateX(5px);
        border-color: var(--accent-primary);
    }
    
    .popular-card:hover {
        transform: scale(1.05);
        border-color: var(--accent-primary);
    }
}

/* Live Price Card */
.live-price-card {
    background: linear-gradient(135deg, var(--bg-secondary), var(--bg-tertiary));
    border-radius: 20px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    border: 2px solid var(--border-color);
}

.price-header {
    margin-bottom: 1.5rem;
}

.price-main {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.current-price {
    font-family: 'JetBrains Mono', monospace;
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.price-change {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.25rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.price-change.positive {
    color: var(--accent-success);
}

.price-change.negative {
    color: var(--accent-danger);
}

.price-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.data-source {
    padding: 0.25rem 0.75rem;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 12px;
    font-size: 0.75rem;
}

.last-updated {
    font-size: 0.75rem;
    color: var(--text-dim);
}

.price-metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
}

.metric-item {
    background: var(--bg-tertiary);
    padding: 1rem;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.metric-label {
    font-size: 0.75rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* Stock Live Metrics in List */
.stock-live-metrics {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}

.metric-price {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.metric-change {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.875rem;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
}

.metric-change.positive {
    background: rgba(16, 185, 129, 0.1);
    color: var(--accent-success);
}

.metric-change.negative {
    background: rgba(239, 68, 68, 0.1);
    color: var(--accent-danger);
}

.metric-source {
    font-size: 0.7rem;
    color: var(--text-dim);
    padding: 0.125rem 0.5rem;
    background: var(--bg-tertiary);
    border-radius: 8px;
}

.watchlist-star {
    font-size: 1rem;
    margin-right: 0.25rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .current-price {
        font-size: 2rem;
    }
    
    .price-change {
        font-size: 1rem;
    }
    
    .price-metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .current-price {
        font-size: 1.75rem;
    }
    
    .price-main {
        flex-direction: column;
        gap: 0.5rem;
    }
}

/* API Configuration Modal */
.api-config-section {
    padding: 1.5rem;
    background: var(--bg-tertiary);
    border-radius: 12px;
    margin-bottom: 1rem;
    border: 1px solid var(--border-color);
}

.api-config-section h4 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.badge-free {
    padding: 0.125rem 0.5rem;
    background: rgba(16, 185, 129, 0.1);
    color: var(--accent-success);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: 8px;
    font-size: 0.7rem;
    font-weight: 600;
}

.api-description {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.input-group {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.api-key-input {
    flex: 1;
    padding: 0.75rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.875rem;
}

.api-key-input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.btn-save {
    padding: 0.75rem 1.5rem;
    background: var(--gradient-primary);
    border: none;
    border-radius: 8px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-save:active {
    transform: scale(0.95);
}

.api-link {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.875rem;
    color: var(--accent-primary);
    text-decoration: none;
    transition: all 0.3s ease;
}

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

.api-status-section {
    padding: 1.5rem;
    background: var(--bg-tertiary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.api-status-section h4 {
    font-size: 1rem;
    margin-bottom: 1rem;
}

.api-status-item {
    padding: 1rem;
    background: var(--bg-primary);
    border-radius: 8px;
}
