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

/* ═══════════════ RESET ═══════════════ */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #f2f2f7;
    --bg-elevated: #ffffff;
    --bg-grouped: #ffffff;
    --separator: rgba(60, 60, 67, 0.08);
    --text-primary: #1c1c1e;
    --text-secondary: #8e8e93;
    --text-tertiary: #aeaeb2;
    --tint: #007aff;
    --tint-hover: #0066d6;
    --green: #34c759;
    --red: #ff3b30;
    --orange: #ff9500;
    --purple: #af52de;
    --radius: 12px;
    --radius-lg: 16px;
    --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-modal: 0 24px 48px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.04);
    --transition: all 0.2s ease;
}

html {
    height: 100%;
}

body {
    height: 100%;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Helvetica Neue', sans-serif;
    background: var(--bg);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    display: flex;
    justify-content: center;
}

/* ═══════════════ APP ═══════════════ */
#app {
    width: 100%;
    max-width: 420px;
    min-height: 100%;
    background: var(--bg);
}

/* ═══════════════ SCREENS ═══════════════ */
.screen {
    display: none;
    flex-direction: column;
    min-height: 100vh;
    padding: 0 20px;
    animation: screenIn 0.35s ease;
}

.screen.active {
    display: flex;
}

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

/* ═══════════════ HEADER / BRANDING ═══════════════ */
.brand {
    text-align: center;
    padding: 60px 0 36px;
}

.brand-icon {
    width: 64px;
    height: 64px;
    background: var(--tint);
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    margin-bottom: 14px;
}

.brand h1 {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

.brand p {
    font-size: 15px;
    color: var(--text-secondary);
    margin-top: 4px;
    font-weight: 400;
}

/* ═══════════════ CARD ═══════════════ */
.card {
    background: var(--bg-grouped);
    border-radius: var(--radius-lg);
    padding: 24px 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-card);
}

.card-title {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 20px;
    text-align: center;
    color: var(--text-primary);
}

/* ═══════════════ BALANCE CARD ═══════════════ */
.balance-card {
    background: var(--text-primary);
    border-radius: 20px;
    padding: 28px 24px;
    margin: 20px 0;
    color: #fff;
    position: relative;
    overflow: hidden;
}

.balance-card::after {
    content: '';
    position: absolute;
    top: -30px;
    right: -30px;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
}

.balance-card .greeting {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.5);
    font-weight: 500;
    margin-bottom: 2px;
}

.balance-card .username {
    font-size: 20px;
    font-weight: 600;
    color: #fff;
    margin-bottom: 22px;
}

.balance-card .balance-label {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.4);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
    margin-bottom: 2px;
}

.balance-card .balance-value {
    font-size: 36px;
    font-weight: 700;
    color: #fff;
    letter-spacing: -1px;
}

.balance-card .balance-value .currency {
    font-size: 22px;
    font-weight: 500;
    opacity: 0.6;
}

/* ═══════════════ INPUTS ═══════════════ */
.input-group {
    margin-bottom: 16px;
}

.input-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.input-group input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg);
    border: 1px solid var(--separator);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 16px;
    font-family: inherit;
    font-weight: 400;
    transition: var(--transition);
    outline: none;
    -webkit-appearance: none;
}

.input-group input::placeholder {
    color: var(--text-tertiary);
}

.input-group input:focus {
    border-color: var(--tint);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.12);
}

/* ═══════════════ BUTTONS ═══════════════ */
.btn {
    width: 100%;
    padding: 14px 20px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    -webkit-appearance: none;
}

.btn:active {
    transform: scale(0.98);
    opacity: 0.85;
}

.btn-primary {
    background: var(--tint);
    color: #fff;
    margin-top: 4px;
}

.btn-primary:hover {
    background: var(--tint-hover);
}

.btn-success {
    background: var(--green);
    color: #fff;
}

.btn-danger {
    background: var(--red);
    color: #fff;
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    font-weight: 500;
}

.btn-ghost:hover {
    background: rgba(0, 0, 0, 0.03);
}

/* ═══════════════ ACTION GRID ═══════════════ */
.actions-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}

.action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 20px 12px;
    background: var(--bg-grouped);
    border: none;
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-card);
}

.action-btn:hover {
    background: #f8f8fa;
}

.action-btn:active {
    transform: scale(0.97);
    opacity: 0.8;
}

.action-btn .icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.action-btn .icon.green { background: rgba(52, 199, 89, 0.12); }
.action-btn .icon.red { background: rgba(255, 59, 48, 0.12); }
.action-btn .icon.purple { background: rgba(175, 82, 222, 0.12); }
.action-btn .icon.blue { background: rgba(0, 122, 255, 0.12); }

/* ═══════════════ BOTTOM ACTIONS ═══════════════ */
.bottom-actions {
    display: flex;
    gap: 12px;
    margin-bottom: 32px;
}

.bottom-actions .action-btn {
    flex: 1;
    flex-direction: row;
    padding: 14px;
    gap: 10px;
}

.bottom-actions .action-btn .icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    font-size: 16px;
}

/* ═══════════════ LINKS ═══════════════ */
.links-row {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-top: 14px;
}

.link-btn {
    background: none;
    border: none;
    color: var(--tint);
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 8px;
    transition: var(--transition);
}

.link-btn:hover {
    background: rgba(0, 122, 255, 0.06);
}

/* ═══════════════ BACK BUTTON ═══════════════ */
.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    color: var(--tint);
    font-size: 16px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    padding: 16px 0 0;
    transition: var(--transition);
}

.back-btn:hover {
    opacity: 0.7;
}

/* ═══════════════ PAGE HEADER ═══════════════ */
.page-header {
    margin: 12px 0 20px;
}

.page-header h2 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.3px;
    color: var(--text-primary);
}

.page-header p {
    font-size: 15px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ═══════════════ MODAL ═══════════════ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal {
    background: var(--bg-elevated);
    border-radius: 20px;
    padding: 28px 24px;
    width: 100%;
    max-width: 340px;
    box-shadow: var(--shadow-modal);
    animation: modalIn 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.96) translateY(6px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 18px;
    text-align: center;
    color: var(--text-primary);
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 18px;
}

.modal-actions .btn {
    flex: 1;
}

/* ═══════════════ TOAST ═══════════════ */
.toast {
    position: fixed;
    top: 50px;
    left: 50%;
    transform: translateX(-50%) translateY(-60px);
    background: var(--text-primary);
    color: #fff;
    padding: 12px 24px;
    border-radius: 50px;
    font-size: 14px;
    font-weight: 500;
    z-index: 200;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1), opacity 0.4s;
    opacity: 0;
    pointer-events: none;
    white-space: nowrap;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.success { background: var(--green); }
.toast.error { background: var(--red); }

/* ═══════════════ SPINNER ═══════════════ */
.btn .spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    display: none;
}

.btn.loading .spinner { display: block; }
.btn.loading span { display: none; }

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

/* ═══════════════ SCROLLBAR ═══════════════ */
::-webkit-scrollbar { width: 0; background: transparent; }

/* ═══════════════ RESPONSIVE ═══════════════ */
@media (max-width: 420px) {
    #app { padding: 0; }
    .balance-card .balance-value { font-size: 32px; }
}
