/* Telegram Mini App theme integration */
:root {
    --bg: var(--tg-theme-bg-color, #ffffff);
    --text: var(--tg-theme-text-color, #000000);
    --hint: var(--tg-theme-hint-color, #999999);
    --link: var(--tg-theme-link-color, #2678b6);
    --btn: var(--tg-theme-button-color, #2678b6);
    --btn-text: var(--tg-theme-button-text-color, #ffffff);
    --secondary-bg: var(--tg-theme-secondary-bg-color, #f0f0f0);
    --section-bg: var(--tg-theme-section-bg-color, var(--bg));
    --section-header: var(--tg-theme-section-header-text-color, var(--hint));
    --radius: 12px;
    --gap: 12px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--secondary-bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

#app { max-width: 600px; margin: 0 auto; }

/* Filters */
.filters {
    display: flex;
    gap: 8px;
    padding: var(--gap);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.filter-select {
    flex: 1;
    min-width: 0;
    padding: 8px 10px;
    border: none;
    border-radius: 8px;
    background: var(--section-bg);
    color: var(--text);
    font-size: 13px;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 4px;
    padding: 0 var(--gap);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
    flex-shrink: 0;
    padding: 8px 14px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--hint);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}
.tab.active {
    background: var(--btn);
    color: var(--btn-text);
}

/* Tab panels */
.tab-panel { display: none; padding: var(--gap); }
.tab-panel.active { display: block; }

/* Sections */
.section {
    background: var(--section-bg);
    border-radius: var(--radius);
    padding: var(--gap);
    margin-bottom: var(--gap);
}
.section h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--section-header);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

/* Charts */
.chart-container {
    position: relative;
    width: 100%;
    max-height: 300px;
}
.chart-square { max-height: 260px; }
.chart-container canvas { width: 100% !important; }

/* Stat cards */
.stat-cards {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}
.stat-card {
    flex: 1;
    text-align: center;
    padding: 10px 6px;
    background: var(--secondary-bg);
    border-radius: 8px;
}
.stat-card.wide { flex: 2; }
.stat-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
}
.stat-label {
    font-size: 11px;
    color: var(--hint);
    margin-top: 2px;
}

/* Progress bar */
.progress-bar {
    height: 6px;
    background: var(--secondary-bg);
    border-radius: 3px;
    margin-top: 8px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: var(--btn);
    border-radius: 3px;
    transition: width 0.5s ease;
    width: 0%;
}

/* Table */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
th, td {
    padding: 8px 6px;
    text-align: left;
    white-space: nowrap;
}
th {
    font-weight: 600;
    color: var(--hint);
    font-size: 11px;
    text-transform: uppercase;
    border-bottom: 1px solid var(--secondary-bg);
}
td { border-bottom: 1px solid var(--secondary-bg); }
tr:last-child td { border-bottom: none; }

/* Trend indicators */
.trend-up { color: #34c759; }
.trend-down { color: #ff3b30; }
.trend-neutral { color: var(--hint); }

/* Loading */
.overlay {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
}
.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--secondary-bg);
    border-top-color: var(--btn);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#empty-state p {
    color: var(--hint);
    font-size: 15px;
}
