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

:root {
    /* Pixel Dark - Clean & Minimal */
    --bg-primary: #0f0f0f;
    --bg-surface: #1a1a1a;
    --bg-elevated: #242424;
    --bg-muted: #2a2a2a;

    /* Accent - Material You Blue */
    --accent: #8ab4f8;
    --accent-light: rgba(138, 180, 248, 0.12);
    --accent-soft: rgba(138, 180, 248, 0.08);

    /* Semantic colors */
    --success: #81c995;
    --success-bg: rgba(129, 201, 149, 0.12);
    --error: #f28b82;
    --error-bg: rgba(242, 139, 130, 0.12);

    /* Text hierarchy */
    --text-primary: #e8eaed;
    --text-secondary: #9aa0a6;
    --text-muted: #5f6368;

    /* Borders & Shadows */
    --border: rgba(255, 255, 255, 0.08);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);

    /* Spacing */
    --radius-sm: 12px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-full: 100px;

    /* Telegram overrides */
    --tg-theme-bg-color: var(--bg-primary);
    --tg-theme-text-color: var(--text-primary);
    --tg-theme-hint-color: var(--text-muted);
    --tg-theme-link-color: var(--accent);
    --tg-theme-button-color: var(--accent);
    --tg-theme-button-text-color: #0f0f0f;
    --tg-theme-secondary-bg-color: var(--bg-surface);
}

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

html {
    scroll-behavior: smooth;
    scrollbar-gutter: stable;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   CONTAINER & LAYOUT
   ============================================ */

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 24px 20px 40px;
}

/* ============================================
   TYPOGRAPHY
   ============================================ */

h1 {
    font-size: 28px;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

h1 .gradient-text {
    color: var(--text-primary);
    background: none;
    -webkit-text-fill-color: var(--text-primary);
}

h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0;
    text-transform: none;
    margin-bottom: 16px;
}

.subtitle {
    font-size: 16px;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* ============================================
   CARDS - Pixel Dark Style
   ============================================ */

.card {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    padding: 20px;
    border: 1px solid var(--border);
}

.card::before {
    display: none;
}

/* ============================================
   LANDING PAGE - HERO
   ============================================ */

.hero {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 32px 24px;
    background: var(--bg-primary);
}

.hero-content {
    max-width: 440px;
}

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

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--accent-light);
    border-radius: var(--radius-full);
    font-size: 13px;
    font-weight: 500;
    color: var(--accent);
    margin-bottom: 32px;
    border: none;
}

.hero-badge .dot {
    width: 8px;
    height: 8px;
    background: var(--accent);
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.hero-title {
    font-size: 40px;
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.03em;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.hero-title .gradient-text {
    color: var(--accent);
    -webkit-text-fill-color: var(--accent);
}

.hero-subtitle {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 40px;
    line-height: 1.6;
}

/* Card Input Form */
.card-input-wrapper {
}

.card-input-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.input-group {
    position: relative;
}

.input-field {
    width: 100%;
    padding: 18px 60px 18px 20px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 18px;
    font-weight: 500;
    letter-spacing: 0.1em;
    color: var(--text-primary);
    background: var(--bg-surface);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    outline: none;
    transition: all 0.2s ease;
    text-align: center;
}

.input-field::placeholder {
    color: var(--text-muted);
    letter-spacing: 0.05em;
}

.input-field:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-soft);
}

.input-hint {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
}

.input-hint.complete {
    color: var(--success);
}

/* Primary Button - Pixel Dark Style */
.btn-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 16px 24px;
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    font-weight: 600;
    color: var(--bg-primary);
    background: var(--accent);
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary:hover {
    background: #aecbfa;
    box-shadow: var(--shadow-md);
}

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

.btn-primary svg {
    width: 18px;
    height: 18px;
}

/* Feature Cards */
.features-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-top: 48px;
}

.feature-card {
    padding: 20px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    text-align: left;
    transition: all 0.2s ease;
}

.feature-card:hover {
    background: var(--bg-elevated);
}

.feature-icon {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-light);
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    font-size: 20px;
}

.feature-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.feature-desc {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.4;
}

/* ============================================
   DASHBOARD HEADER
   ============================================ */

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

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

.tg-header h1 {
    font-size: 22px;
    font-weight: 600;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.back-btn:hover {
    background: var(--bg-elevated);
}

.refresh-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 500;
    color: var(--accent);
    background: var(--accent-light);
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all 0.2s ease;
}

.refresh-btn:hover {
    background: rgba(138, 180, 248, 0.2);
}

.refresh-btn:active {
    transform: scale(0.97);
}

.refresh-btn svg {
    width: 16px;
    height: 16px;
}

.refresh-btn.loading svg {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================
   BALANCE HERO CARD - Pixel Dark Style
   ============================================ */

.balance-hero {
    position: relative;
    padding: 28px 24px;
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
    border: 1px solid var(--border);
    overflow: visible;
}

.balance-hero::before,
.balance-hero::after {
    display: none;
}

.balance-content {
    position: relative;
    z-index: 1;
}

.balance-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.balance-amount {
    font-family: 'Inter', sans-serif;
    font-size: 48px;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 16px;
    background: none;
    -webkit-text-fill-color: var(--text-primary);
}

.balance-meta {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-secondary);
}

.meta-item svg {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
}

.card-chip {
    display: none;
}

/* ============================================
   STATS GRID - Pixel Dark Style
   ============================================ */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 12px;
}

.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
}

.stat-card::before {
    display: none;
}

.stat-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-light);
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    color: var(--accent);
}

.stat-card:nth-child(1) .stat-icon {
    background: var(--error-bg);
    color: var(--error);
}

.stat-card:nth-child(2) .stat-icon {
    background: var(--success-bg);
    color: var(--success);
}

.stat-card:nth-child(3) .stat-icon {
    background: var(--accent-light);
    color: var(--accent);
}

.stat-value {
    font-family: 'Inter', sans-serif;
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.stat-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: none;
    letter-spacing: 0;
}

.stat-card-wide {
    grid-column: span 1;
}

/* ============================================
   CHARTS - Pixel Dark Style
   ============================================ */

.charts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.chart-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
}

.chart-card h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.chart-card h3 svg {
    width: 18px;
    height: 18px;
    color: var(--text-muted);
}

.chart-container {
    position: relative;
    height: 240px;
}

.chart-full {
    margin-top: 0;
}

.chart-full .chart-container {
    height: 200px;
}

/* ============================================
   TRANSACTIONS - Pixel Dark Style
   ============================================ */

.transactions-section {
    margin: 0 0 12px 0;
}

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

.section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.section-title svg {
    width: 20px;
    height: 20px;
    color: var(--text-muted);
}

.tx-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 162px; /* ~3 items: 3 * 52px + 2 * 2px gap */
    overflow-y: auto;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.tx-list::-webkit-scrollbar {
    width: 4px;
}

.tx-list::-webkit-scrollbar-track {
    background: transparent;
}

.tx-list::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.tx-list::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.tx-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--bg-surface);
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: background 0.15s ease;

    &:first-child {
        border-top-left-radius: var(--radius-lg);
        border-top-right-radius: var(--radius-lg);
    }

    &:last-child {
        border-bottom-left-radius: var(--radius-lg);
        border-bottom-right-radius: var(--radius-lg);
    }
}

.tx-row:hover {
    background: var(--bg-elevated);
}

.tx-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1;
}

.tx-date {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    white-space: nowrap;
}

.tx-location {
    color: var(--text-primary);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tx-amount {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    margin-left: 12px;
}

.amount-positive {
    color: var(--success);
}

.amount-negative {
    color: var(--error);
}

/* ============================================
   LOADING & ERROR STATES
   ============================================ */

#loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    gap: 20px;
}

.spinner {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 3px solid var(--bg-elevated);
    border-top-color: var(--accent);
    animation: spin 0.8s linear infinite;
}

.spinner::before {
    display: none;
}

.loading-text {
    font-size: 14px;
    color: var(--text-muted);
}

.error-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 40vh;
    text-align: center;
    padding: 32px;
    background: var(--error-bg);
    border: 1px solid rgba(242, 139, 130, 0.2);
    border-radius: var(--radius-lg);
}

.error-icon {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-surface);
    border-radius: 50%;
    margin-bottom: 16px;
    font-size: 24px;
}

.error-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--error);
    margin-bottom: 8px;
}

.error-desc {
    color: var(--text-secondary);
    max-width: 280px;
    font-size: 14px;
}

/* ============================================
   TELEGRAM WEBAPP SPECIFICS
   ============================================ */

.tg-container {
    padding: 16px;
}

.tg-container .balance-hero {
    padding: 24px 20px;
    margin-bottom: 16px;
}

.tg-container .stats-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.tg-container .stat-card {
    padding: 16px;
}

.tg-container .stat-value {
    font-size: 20px;
}

.tg-container .charts-grid {
    grid-template-columns: 1fr;
    gap: 12px;
}

.tg-container .chart-container {
    height: 200px;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    .container {
        padding: 16px;
    }

    .hero {
        min-height: auto;
        padding: 48px 20px;
    }

    .hero-title {
        font-size: 32px;
    }

    .features-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .balance-hero {
        padding: 24px 20px;
    }

    .balance-amount {
        font-size: 36px;
    }

    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .stat-card {
        padding: 16px;
    }

    .stat-value {
        font-size: 18px;
    }

    .stat-label {
        font-size: 11px;
    }

    .charts-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .balance-amount {
        font-size: 32px;
    }

    .stat-value {
        font-size: 16px;
    }

    .stat-icon {
        width: 32px;
        height: 32px;
        margin-bottom: 8px;
    }

    .stat-icon svg {
        width: 16px;
        height: 16px;
    }

    .input-field {
        font-size: 16px;
        padding: 16px;
    }

    .tx-row {
        padding: 12px;
    }

    .tx-date {
        font-size: 11px;
    }

    .tx-location {
        font-size: 13px;
    }
}

/* ============================================
   ANIMATIONS
   ============================================ */

/* Simple fade-in - no delays, clean appearance */
.fade-in {
    animation: fadeIn 0.3s ease-out;
}

/* Stagger children animation */
.stagger-children > * {
    opacity: 0;
    animation: fadeIn 0.25s ease-out forwards;
}

.stagger-children > *:nth-child(1) {
    animation-delay: 0s;
}

.stagger-children > *:nth-child(2) {
    animation-delay: 0.05s;
}

.stagger-children > *:nth-child(3) {
    animation-delay: 0.1s;
}

.stagger-children > *:nth-child(4) {
    animation-delay: 0.15s;
}
