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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--tg-theme-bg-color, #fff);
    color: var(--tg-theme-text-color, #000);
    padding-bottom: env(safe-area-inset-bottom);
}

#app {
    max-width: 100vw;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

nav {
    display: flex;
    gap: 8px;
    padding: 12px;
    background: var(--tg-theme-secondary-bg-color, #f5f5f5);
    position: sticky;
    top: 0;
    z-index: 10;
}

.nav-btn {
    flex: 1;
    padding: 12px;
    border: none;
    background: var(--tg-theme-button-color, #0088cc);
    color: var(--tg-theme-button-text-color, #fff);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.nav-btn.active {
    opacity: 1;
}

.page {
    display: none;
    padding: 16px;
    flex: 1;
}

.page.active {
    display: block;
}

h2 {
    font-size: 24px;
    margin-bottom: 16px;
}

h3 {
    font-size: 18px;
    margin: 16px 0 12px;
}

.balance-card {
    background: var(--tg-theme-secondary-bg-color, #f5f5f5);
    padding: 24px;
    border-radius: 12px;
    margin-bottom: 24px;
}

.label {
    font-size: 14px;
    opacity: 0.6;
    margin-bottom: 8px;
}

.amount {
    font-size: 36px;
    font-weight: 700;
}

.transaction, .email-item {
    padding: 16px;
    background: var(--tg-theme-secondary-bg-color, #f5f5f5);
    border-radius: 8px;
    margin-bottom: 8px;
}

.transaction-header, .email-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.transaction-desc {
    font-weight: 500;
}

.transaction-amount {
    font-weight: 600;
}

.transaction-amount.income {
    color: #4caf50;
}

.transaction-amount.expense {
    color: #f44336;
}

.email-from {
    font-size: 12px;
    opacity: 0.6;
}

.email-subject {
    font-weight: 500;
    margin-top: 4px;
}

.email-snippet {
    font-size: 14px;
    opacity: 0.7;
    margin-top: 4px;
}

#finance-loading, #email-loading {
    text-align: center;
    padding: 48px 16px;
    opacity: 0.6;
}

.email-item {
    cursor: pointer;
    transition: background 0.2s;
}

.email-item:active {
    opacity: 0.7;
}

.back-btn {
    background: none;
    border: none;
    color: var(--tg-theme-link-color, #0088cc);
    font-size: 16px;
    padding: 8px 0;
    margin-bottom: 16px;
    cursor: pointer;
}

#email-detail-content {
    margin-bottom: 24px;
}

.email-full {
    padding: 16px;
    background: var(--tg-theme-secondary-bg-color, #f5f5f5);
    border-radius: 8px;
    margin-bottom: 16px;
}

.email-full-subject {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 8px;
}

.email-full-from {
    font-size: 14px;
    opacity: 0.7;
    margin-bottom: 16px;
}

.email-full-body {
    font-size: 15px;
    line-height: 1.5;
    white-space: pre-wrap;
}

.email-thread-count {
    font-size: 12px;
    opacity: 0.6;
    margin-bottom: 16px;
}

.email-message {
    margin-bottom: 16px;
}

.email-message-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
    gap: 8px;
}

.email-message-from {
    font-weight: 600;
    font-size: 14px;
    flex: 1;
}

.email-message-date {
    font-size: 12px;
    opacity: 0.6;
    white-space: nowrap;
}

.email-message-body {
    font-size: 15px;
    line-height: 1.5;
    white-space: pre-wrap;
}

.message-separator {
    border: none;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    margin: 16px 0;
}

.actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px 0;
}

.action-btn {
    padding: 14px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    background: var(--tg-theme-secondary-bg-color, #f5f5f5);
    color: var(--tg-theme-text-color, #000);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
}

.action-btn:active {
    opacity: 0.7;
    transform: scale(0.98);
}

.action-btn.primary {
    background: var(--tg-theme-button-color, #0088cc);
    color: var(--tg-theme-button-text-color, #fff);
}

.task-item {
    padding: 16px;
    background: var(--tg-theme-secondary-bg-color, #f5f5f5);
    border-radius: 8px;
    margin-bottom: 8px;
}

.task-title {
    font-weight: 500;
    margin-bottom: 8px;
}

.task-notes {
    font-size: 14px;
    opacity: 0.7;
    margin-bottom: 12px;
}

.task-actions {
    display: flex;
    gap: 8px;
}

.task-complete-btn, .task-discuss-btn {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
}

.task-complete-btn {
    background: #4caf50;
    color: white;
}

.task-discuss-btn {
    background: var(--tg-theme-button-color, #0088cc);
    color: var(--tg-theme-button-text-color, #fff);
}

.task-complete-btn:active, .task-discuss-btn:active {
    opacity: 0.7;
    transform: scale(0.98);
}

#tasks-loading {
    text-align: center;
    padding: 48px 16px;
    opacity: 0.6;
}
