:root {
    --tg-theme-bg-color: #ffffff;
    --tg-theme-text-color: #000000;
    --tg-theme-hint-color: #999999;
    --tg-theme-link-color: #2678b6;
    --tg-theme-button-color: #40a7e3;
    --tg-theme-button-text-color: #ffffff;
    --tg-theme-secondary-bg-color: #f8f9fa;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    background-color: var(--tg-theme-bg-color);
    color: var(--tg-theme-text-color);
    line-height: 1.6;
    padding: 16px;
}

.container {
    max-width: 100%;
    margin: 0 auto;
}

/* Header */
.app-header {
    text-align: center;
    margin-bottom: 24px;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.app-header h1 {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 4px;
}

.header-subtitle {
    font-size: 14px;
    opacity: 0.9;
}

/* Navigation Tabs */
.nav-tabs {
    display: flex;
    justify-content: space-around;
    margin-bottom: 20px;
    background: var(--tg-theme-secondary-bg-color);
    border-radius: 8px;
    padding: 4px;
}

.nav-tab {
    flex: 1;
    padding: 10px 8px;
    background: none;
    border: none;
    color: var(--tg-theme-hint-color);
    font-size: 12px;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.nav-tab.active {
    background: var(--tg-theme-button-color);
    color: var(--tg-theme-button-text-color);
}

/* Tab Content */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--tg-theme-secondary-bg-color);
    padding: 16px;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.stat-icon {
    font-size: 20px;
    margin-bottom: 6px;
}

.stat-value {
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 2px;
}

.stat-label {
    font-size: 11px;
    color: var(--tg-theme-hint-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Sections */
.section {
    background: var(--tg-theme-secondary-bg-color);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.section h3 {
    font-size: 16px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Buttons */
.btn {
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    margin: 4px;
}

.btn-primary {
    background: var(--tg-theme-button-color);
    color: var(--tg-theme-button-text-color);
}

.btn-secondary {
    background: var(--tg-theme-hint-color);
    color: white;
}

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

.action-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

/* Gateway List */
.gateway-list {
    display: grid;
    gap: 10px;
}

.gateway-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: var(--tg-theme-bg-color);
    border-radius: 6px;
    border: 1px solid #e0e0e0;
}

.gateway-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.gateway-icon {
    font-size: 18px;
}

.gateway-details h4 {
    font-size: 13px;
    margin-bottom: 2px;
}

.gateway-details p {
    font-size: 11px;
    color: var(--tg-theme-hint-color);
}

.gateway-balance {
    text-align: right;
}

.balance-amount {
    font-weight: bold;
    font-size: 14px;
}

.balance-status {
    font-size: 10px;
    margin-top: 2px;
}

.status-active { color: #28a745; }
.status-maintenance { color: #ffc107; }
.status-inactive { color: #dc3545; }

/* Transaction List */
.transaction-filters {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.transaction-filters select {
    flex: 1;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 12px;
}

.transaction-list {
    max-height: 300px;
    overflow-y: auto;
}

.transaction-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid #e0e0e0;
}

.transaction-item:last-child {
    border-bottom: none;
}

.transaction-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.transaction-icon {
    font-size: 14px;
}

.transaction-details h5 {
    font-size: 12px;
    margin-bottom: 2px;
}

.transaction-details p {
    font-size: 10px;
    color: var(--tg-theme-hint-color);
}

.transaction-amount {
    text-align: right;
    font-weight: bold;
    font-size: 13px;
}

.amount-positive { color: #28a745; }
.amount-negative { color: #dc3545; }

/* Channel List */
.channel-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background: var(--tg-theme-bg-color);
    border-radius: 6px;
    margin-bottom: 8px;
    border: 1px solid #e0e0e0;
}

.channel-info h5 {
    font-size: 13px;
    margin-bottom: 2px;
}

.channel-info p {
    font-size: 11px;
    color: var(--tg-theme-hint-color);
}

.channel-status {
    padding: 3px 6px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 500;
}

.status-enabled {
    background: #d4edda;
    color: #155724;
}

.status-disabled {
    background: #f8d7da;
    color: #721c24;
}

/* Message Form */
.message-form {
    display: grid;
    gap: 10px;
}

.message-form select {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
}

.message-form textarea {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    min-height: 80px;
    resize: vertical;
}

/* Loading */
.loading {
    text-align: center;
    padding: 20px;
    color: var(--tg-theme-hint-color);
    font-size: 13px;
}

/* Refresh Indicator */
.refresh-indicator {
    position: fixed;
    top: 10px;
    right: 10px;
    background: var(--tg-theme-button-color);
    color: white;
    padding: 6px 10px;
    border-radius: 15px;
    font-size: 11px;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 1000;
}

.refresh-indicator.show {
    opacity: 1;
}

/* Dark theme support */
.dark-theme {
    --tg-theme-bg-color: #212121;
    --tg-theme-text-color: #ffffff;
    --tg-theme-hint-color: #aaaaaa;
    --tg-theme-link-color: #8cc1e0;
    --tg-theme-button-color: #40a7e3;
    --tg-theme-button-text-color: #ffffff;
    --tg-theme-secondary-bg-color: #2e2e2e;
}

/* Media queries */
@media (min-width: 768px) {
    .container {
        max-width: 600px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .action-buttons {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 320px) {
    .nav-tab {
        font-size: 10px;
        padding: 8px 4px;
    }
    
    .stats-grid {
        gap: 8px;
    }
    
    .stat-card {
        padding: 12px;
    }
}