:root {
    --primary: #1565C0;
    --primary-dark: #0D47A1;
    --accent: #00897B;
    --bg: #F5F7FA;
    --card: #ffffff;
    --text: #1A1A2E;
    --muted: #6B7280;
    --error: #C62828;
    --success: #2E7D32;
    --warning: #F57C00;
    --radius: 16px;
    --shadow: 0 2px 12px rgba(0,0,0,0.06);
}

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

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

.loading-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    color: var(--muted);
}

.spinner {
    width: 40px; height: 40px;
    border: 3px solid #e0e0e0;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 12px;
}

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

.hidden { display: none !important; }

/* Auth */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.auth-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 32px 24px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow);
}

.auth-logo {
    width: 64px; height: 64px;
    background: rgba(21,101,192,0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    margin: 0 auto 16px;
}

.auth-card h1 {
    text-align: center;
    font-size: 22px;
    margin-bottom: 4px;
}

.auth-subtitle {
    text-align: center;
    color: var(--muted);
    font-size: 14px;
    margin-bottom: 28px;
}

.form-group { margin-bottom: 16px; }

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
}

.form-group input, .form-group select {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #ddd;
    border-radius: 12px;
    font-size: 15px;
    background: #fafafa;
}

.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(21,101,192,0.15);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 13px 20px;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: white; width: 100%; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }

.btn-outline {
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
    width: 100%;
    margin-top: 12px;
}

.btn-sm { padding: 8px 14px; font-size: 13px; width: auto; }

.btn-danger { background: var(--error); color: white; }
.btn-ghost { background: #f0f0f0; color: var(--text); }

.auth-link {
    text-align: center;
    margin-top: 16px;
    font-size: 14px;
}

.auth-link a { color: var(--primary); text-decoration: none; font-weight: 500; }

.alert {
    padding: 12px 14px;
    border-radius: 10px;
    font-size: 14px;
    margin-bottom: 16px;
}

.alert-error { background: #FFEBEE; color: var(--error); }
.alert-success { background: #E8F5E9; color: var(--success); }

/* Layout */
.layout { min-height: 100vh; padding-bottom: 72px; }

.header {
    background: var(--card);
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
    position: sticky;
    top: 0;
    z-index: 10;
}

.header h2 { font-size: 18px; font-weight: 600; }
.header p { font-size: 13px; color: var(--muted); margin-top: 2px; }

.content { padding: 16px; max-width: 800px; margin: 0 auto; }

.hero-card {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 16px;
}

.hero-card .label { font-size: 13px; opacity: 0.8; }
.hero-card .amount { font-size: 32px; font-weight: 700; margin: 8px 0 16px; }
.hero-stats { display: flex; gap: 24px; }
.hero-stats .stat-label { font-size: 11px; opacity: 0.7; }
.hero-stats .stat-value { font-size: 15px; font-weight: 600; }

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.stat-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    border: 1px solid #f0f0f0;
}

.stat-card .icon {
    width: 36px; height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    margin-bottom: 10px;
}

.stat-card .title { font-size: 12px; color: var(--muted); font-weight: 500; }
.stat-card .value { font-size: 18px; font-weight: 700; margin-top: 4px; }

.card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    border: 1px solid #f0f0f0;
    margin-bottom: 12px;
}

.card h3 { font-size: 15px; font-weight: 600; margin-bottom: 12px; }

.row-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    font-size: 14px;
}

.row-between.bold { font-weight: 600; }

.progress {
    height: 6px;
    background: #eee;
    border-radius: 3px;
    overflow: hidden;
    margin: 8px 0;
}

.progress-bar {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    transition: width 0.3s;
}

.progress-bar.warn { background: var(--warning); }

.chip {
    display: inline-block;
    padding: 4px 10px;
    background: rgba(21,101,192,0.08);
    color: var(--primary);
    border-radius: 20px;
    font-size: 12px;
    margin-right: 6px;
}

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

.account-actions { display: flex; gap: 4px; }

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    font-size: 16px;
    color: var(--muted);
    border-radius: 8px;
}

.icon-btn:hover { background: #f0f0f0; }
.icon-btn.danger { color: var(--error); }

.tx-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid #f0f0f0;
}

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

.tx-icon {
    width: 40px; height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.tx-icon.usage { background: #FFEBEE; color: var(--error); }
.tx-icon.payment { background: #E8F5E9; color: var(--success); }

.tx-info { flex: 1; }
.tx-amount { font-weight: 600; font-size: 15px; }
.tx-amount.usage { color: var(--error); }
.tx-amount.payment { color: var(--success); }
.tx-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }

.bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--card);
    border-top: 1px solid #eee;
    display: flex;
    padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
    z-index: 100;
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px;
    border: none;
    background: none;
    cursor: pointer;
    color: var(--muted);
    font-size: 10px;
    font-weight: 500;
}

.nav-item.active { color: var(--primary); }
.nav-icon-wrap { position: relative; font-size: 22px; line-height: 1; }
.nav-badge {
    position: absolute;
    top: -4px; right: -10px;
    min-width: 16px; height: 16px;
    padding: 0 4px;
    background: var(--error);
    color: white;
    font-size: 10px;
    font-weight: 700;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.inbox-item {
    background: var(--card);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 10px;
    box-shadow: var(--shadow);
    cursor: pointer;
    border-left: 3px solid transparent;
}
.inbox-item.unread { border-left-color: var(--primary); background: #f0f7ff; }
.inbox-title { font-weight: 600; font-size: 15px; margin-bottom: 6px; }
.inbox-message {
    font-size: 14px;
    color: var(--text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
}
.inbox-date { font-size: 12px; color: var(--muted); margin-top: 8px; }

.inbox-banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #e3f2fd;
    border: 1px solid #90caf9;
    color: var(--primary);
    padding: 14px 16px;
    border-radius: 12px;
    margin-bottom: 16px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
}

.global-error {
    background: #ffebee;
    color: var(--error);
    padding: 12px 16px;
    text-align: center;
    font-size: 14px;
    border-bottom: 1px solid #ffcdd2;
}

.fab {
    position: fixed;
    bottom: 84px;
    right: 20px;
    width: 56px; height: 56px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    border: none;
    font-size: 28px;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(21,101,192,0.4);
    z-index: 50;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 200;
    padding: 0;
}

.modal {
    background: var(--card);
    border-radius: 20px 20px 0 0;
    padding: 24px;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal h3 { margin-bottom: 20px; font-size: 18px; }

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

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

.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--muted);
}

.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.4; }
.empty-state h3 { color: var(--text); margin-bottom: 8px; }

.settings-group { margin-bottom: 24px; }
.settings-group h4 {
    font-size: 12px;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    padding: 0 4px;
}

.settings-item {
    background: var(--card);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #f0f0f0;
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 14px;
    cursor: pointer;
}

.settings-row:last-child { border-bottom: none; }
.settings-row.danger { color: var(--error); }

.toggle {
    width: 48px; height: 28px;
    background: #ccc;
    border-radius: 14px;
    position: relative;
    cursor: pointer;
    transition: background 0.2s;
}

.toggle.on { background: var(--primary); }

.toggle::after {
    content: '';
    position: absolute;
    width: 22px; height: 22px;
    background: white;
    border-radius: 50%;
    top: 3px; left: 3px;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle.on::after { transform: translateX(20px); }

.notify-status {
    font-size: 12px;
    color: var(--muted);
    margin: -4px 4px 10px;
    line-height: 1.4;
}

.notify-settings .notify-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid #f0f0f0;
}

.notify-settings .notify-row:last-of-type {
    border-bottom: none;
}

.notify-label {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    min-width: 0;
}

.notify-time {
    flex-shrink: 0;
    width: 108px;
    padding: 6px 8px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    background: var(--bg);
    text-align: center;
}

.notify-time:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.notify-time:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(21, 101, 192, 0.15);
}

.notify-settings .toggle {
    flex-shrink: 0;
}

.notify-save {
    padding: 12px 16px;
    border-top: 1px solid #f0f0f0;
}

.notify-save .btn {
    width: 100%;
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--card);
    border-radius: var(--radius);
    margin-bottom: 16px;
    border: 1px solid #f0f0f0;
}

.avatar {
    width: 48px; height: 48px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 600;
}

@media (min-width: 768px) {
    .modal-overlay { align-items: center; padding: 24px; }
    .modal { border-radius: var(--radius); }
    .bottom-nav { max-width: 800px; left: 50%; transform: translateX(-50%); border-radius: 16px 16px 0 0; }
}
