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

:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --secondary: #ec4899;
    --secondary-hover: #db2777;
    --bg-color: #f3f4f6;
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.5);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
    --radius: 16px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background: var(--bg-color);
    /* beautiful modern mesh gradient background */
    background-image: 
        radial-gradient(at 40% 20%, hsla(28,100%,74%,1) 0px, transparent 50%),
        radial-gradient(at 80% 0%, hsla(189,100%,56%,1) 0px, transparent 50%),
        radial-gradient(at 0% 50%, hsla(355,100%,93%,1) 0px, transparent 50%),
        radial-gradient(at 80% 50%, hsla(340,100%,76%,1) 0px, transparent 50%),
        radial-gradient(at 0% 100%, hsla(22,100%,77%,1) 0px, transparent 50%),
        radial-gradient(at 80% 100%, hsla(242,100%,70%,1) 0px, transparent 50%),
        radial-gradient(at 0% 0%, hsla(343,100%,76%,1) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-main);
    display: flex;
    justify-content: center;
    min-height: 100vh;
}

.app-container {
    width: 100%;
    max-width: 480px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    padding-bottom: 80px; /* space for bottom nav */
}

/* Glassmorphism Utilities */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
}

header.glass-panel {
    padding: 20px;
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 10;
    border-radius: 0 0 var(--radius) var(--radius);
    margin-bottom: 20px;
}

header h1 {
    font-size: 1.25rem;
    font-weight: 600;
}

#loading {
    font-size: 0.85rem;
    color: var(--primary);
    margin-top: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}
.spin { animation: spin 1s linear infinite; }
@keyframes spin { 100% { transform: rotate(360deg); } }
.hidden { display: none !important; }

/* Main Content Area */
.content-area {
    padding: 0 20px;
    flex: 1;
}

.view {
    display: none;
    animation: fadeIn 0.3s ease;
}
.view.active {
    display: block;
}

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

/* Cards */
.card, .stats-card {
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
}

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

.card-header h2 {
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.badge {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.desc {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 15px;
}

.desc strong {
    color: var(--primary);
}

/* Buttons */
.btn-group {
    display: flex;
    gap: 10px;
}

.btn {
    border: none;
    padding: 12px 20px;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    flex: 1;
    transition: all 0.2s;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0); }

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.btn-secondary {
    background: var(--secondary);
    color: white;
    box-shadow: 0 4px 15px rgba(236, 72, 153, 0.3);
}

.btn-full {
    width: 100%;
    margin-top: 10px;
}

.btn-gradient {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
}

/* Forms */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
}

.input-glass {
    width: 100%;
    padding: 12px 15px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.4);
    font-size: 1rem;
    color: var(--text-main);
    outline: none;
    transition: all 0.2s;
}

.input-glass:focus {
    background: rgba(255, 255, 255, 0.7);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

/* History and Stats */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-top: 15px;
}

.stat-item {
    background: rgba(255, 255, 255, 0.5);
    padding: 15px;
    border-radius: 12px;
    text-align: center;
}

.stat-item .label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.stat-item .value {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary);
    margin-top: 5px;
}

.section-title {
    font-size: 1.1rem;
    margin: 25px 0 15px;
}

.history-list {
    border-radius: var(--radius);
    overflow: hidden;
}

.record-item {
    padding: 15px 20px;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.record-item:last-child {
    border-bottom: none;
}

.record-info h4 {
    font-size: 0.95rem;
    margin-bottom: 4px;
}

.record-info span {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.record-amount {
    font-weight: 700;
    color: var(--secondary);
}
.record-amount.positive {
    color: #10b981;
}

.empty-state {
    padding: 30px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Bottom Nav */
.bottom-nav {
    position: fixed;
    bottom: 0px;
    width: 100%;
    max-width: 480px;
    display: flex;
    justify-content: space-around;
    padding: 15px 10px calc(15px + env(safe-area-inset-bottom));
    border-radius: var(--radius) var(--radius) 0 0;
    z-index: 100;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.nav-item.active {
    color: var(--primary);
}

.nav-item i {
    font-size: 1.5rem;
}

.nav-item span {
    font-size: 0.75rem;
    font-weight: 500;
}

/* Dialog Overlay */
.overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s;
}

.dialog {
    width: 90%;
    max-width: 340px;
    padding: 25px;
    border-radius: 20px;
    text-align: center;
}

.dialog h3 {
    margin-bottom: 10px;
}

.dialog p {
    color: var(--text-muted);
    margin-bottom: 20px;
    font-size: 0.95rem;
}

.version-info {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: 20px;
}

/* Toggle Switch logic is purely active classes */
