/* ══════════════════════════════════════════
   Tích Trữ Pro – Apple Design System
   ══════════════════════════════════════════ */

:root {
    --bg: #f2f2f7;
    --card: rgba(255,255,255,0.82);
    --card-border: rgba(0,0,0,0.05);
    --text: #000000;
    --muted: #8e8e93;
    --blue: #007aff;
    --green: #34c759;
    --red: #ff3b30;
    --amber: #ff9500;
    --radius: 20px;
    --radius-lg: 35px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-top: env(safe-area-inset-top, 0px);
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

html, body {
    width: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    user-select: none;
}

input, textarea, select {
    user-select: text !important;
    -webkit-touch-callout: default !important;
    font-family: inherit;
}

/* ── App Container ── */
.app-container {
    max-width: 430px;
    margin: 0 auto;
    min-height: 100vh;
    padding: 0 20px 130px 20px;
    padding-top: calc(var(--safe-top) + 0px);
    position: relative;
}

/* ── Glass Header ── */
.glass-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(242,242,247,0.72);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    margin: 0 -20px;
    padding: calc(var(--safe-top) + 16px) 20px 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 0.5px solid rgba(0,0,0,0.06);
}

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

.header-logo {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    object-fit: cover;
}

.header-title {
    font-size: 18px;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.3px;
}

.header-subtitle {
    font-size: 9px;
    color: var(--muted);
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-top: 2px;
}

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

.user-greeting {
    text-align: right;
}

.greeting-label {
    font-size: 9px;
    color: var(--muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.greeting-name {
    font-size: 13px;
    font-weight: 700;
}

.btn-login {
    background: var(--text);
    color: #fff;
    border: none;
    border-radius: 20px;
    padding: 8px 18px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-login:active { opacity: 0.7; transform: scale(0.95); }

.desktop-nav {
    display: none;
}

.btn-admin {
    background: var(--amber);
    color: #fff;
    border: none;
    border-radius: 20px;
    padding: 8px 18px;
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
    transition: all 0.2s;
}

/* ── Page Content ── */
.page-content {
    padding-top: 24px;
}

/* ── Cards ── */
.apple-card {
    background: var(--card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--radius);
    padding: 24px;
    border: 1px solid var(--card-border);
    box-shadow: 0 4px 24px rgba(0,0,0,0.04);
    margin-bottom: 20px;
    transition: transform 0.25s cubic-bezier(0.4,0,0.2,1);
}

.apple-card:active { transform: scale(0.98); }

.card-dark {
    background: #1d1d1f;
    color: #fff;
    border: none;
    box-shadow: 0 12px 40px rgba(0,0,0,0.15);
    position: relative;
    overflow: hidden;
}

.card-dark .watermark {
    position: absolute;
    top: 0;
    right: 0;
    padding: 16px;
    opacity: 0.07;
}

/* ── Grid ── */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-bottom: 28px;
}

.grid-2 .apple-card { margin-bottom: 0; }

/* ── Asset Mini Card ── */
.asset-icon {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.asset-icon.gold { background: #fef3c7; color: #d97706; }
.asset-icon.crypto { background: #dbeafe; color: #2563eb; }
.asset-icon.stock { background: #d1fae5; color: #059669; }

.asset-label {
    font-size: 10px;
    color: var(--muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.asset-value {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

/* ── Add Button Card ── */
.add-card {
    background: #fff;
    border: 2px dashed rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    min-height: 130px;
}

.add-card:hover, .add-card:active {
    border-color: var(--blue);
    color: var(--blue);
}

.add-card svg { margin-bottom: 8px; }

/* ── Section Title ── */
.section-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 14px;
    padding-left: 4px;
}

/* ── Market Row ── */
.market-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
}

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

.market-icon {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 11px;
    font-weight: 800;
}

.market-icon.gold-bg { background: linear-gradient(135deg, #f59e0b, #d97706); }
.market-icon.crypto-bg { background: linear-gradient(135deg, #3b82f6, #1d4ed8); }

.market-name { font-size: 12px; font-weight: 700; }
.market-sub { font-size: 10px; color: var(--muted); }
.market-price { font-size: 13px; font-weight: 700; text-align: right; }
.market-live { font-size: 10px; color: var(--green); font-weight: 700; text-align: right; }

/* ── Balance Hero ── */
.balance-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    opacity: 0.6;
    margin-bottom: 6px;
}

.balance-value {
    font-size: 36px;
    font-weight: 800;
    letter-spacing: -1.5px;
    margin-bottom: 14px;
}

.balance-value .currency {
    font-size: 16px;
    font-weight: 400;
    opacity: 0.5;
}

.badge-row { display: flex; gap: 8px; flex-wrap: wrap; }

.badge {
    padding: 4px 12px;
    background: rgba(255,255,255,0.1);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    border: 1px solid rgba(255,255,255,0.05);
}

.badge.up { color: #4ade80; }
.badge.down { color: #f87171; }

/* ── Table ── */
.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.data-table thead tr {
    background: rgba(0,0,0,0.02);
}

.data-table th {
    padding: 10px 14px;
    font-size: 10px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-table td {
    padding: 14px;
    font-size: 12px;
    font-weight: 600;
    border-top: 1px solid rgba(0,0,0,0.03);
}

.data-table tr {
    transition: background 0.2s;
}

.data-table tr:active {
    background: rgba(0,0,0,0.03);
}

.text-right { text-align: right; }
.text-center { text-align: center; }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-amber { color: #d97706; }
.text-blue { color: var(--blue); }
.text-emerald { color: #059669; }
.text-muted { color: var(--muted); }
.text-xs { font-size: 10px; }

.btn-delete {
    background: none;
    border: none;
    color: #fca5a5;
    cursor: pointer;
    padding: 4px;
    transition: color 0.2s;
}

.btn-delete:hover { color: var(--red); }

.empty-row {
    padding: 28px 14px;
    text-align: center;
    color: var(--muted);
    font-size: 12px;
    font-style: italic;
}

/* ── Page Header Row ── */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 0 4px;
}

.page-header h2 {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.page-header p {
    font-size: 10px;
    color: var(--muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

.btn-add {
    width: 48px;
    height: 48px;
    background: #fff;
    border: 1px solid rgba(0,0,0,0.06);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    transition: all 0.2s;
    color: var(--text);
}

.btn-add:active { transform: scale(0.9); }

/* ── Summary Card Colors ── */
.summary-gold { background: #fffbeb; border-color: rgba(245,158,11,0.15); }
.summary-gold .summary-label { color: #d97706; }
.summary-gold .summary-value { color: #78350f; }

.summary-blue { background: #eff6ff; border-color: rgba(59,130,246,0.15); }
.summary-blue .summary-label { color: #2563eb; }
.summary-blue .summary-value { color: #1e3a5f; }

.summary-green { background: #ecfdf5; border-color: rgba(16,185,129,0.15); }
.summary-green .summary-label { color: #059669; }
.summary-green .summary-value { color: #064e3b; }

.summary-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.summary-value {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.summary-value .unit {
    font-size: 13px;
    font-weight: 400;
    opacity: 0.5;
    font-style: italic;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ── Bottom Nav ── */
.bottom-nav {
    position: fixed;
    bottom: calc(16px + var(--safe-bottom));
    left: 20px;
    right: 20px;
    max-width: 390px;
    margin: 0 auto;
    background: rgba(255,255,255,0.88);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-radius: var(--radius-lg);
    height: 72px;
    display: flex;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 8px 40px rgba(0,0,0,0.1);
    border: 1px solid rgba(0,0,0,0.05);
    z-index: 100;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--muted);
    transition: all 0.25s ease;
    gap: 3px;
    padding: 8px;
    cursor: pointer;
}

.nav-item span {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: -0.2px;
}

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

.nav-item:active {
    transform: scale(0.88);
}

/* ── Modal ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: modalIn 0.3s ease;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.35);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.modal-content {
    position: relative;
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border-radius: 32px;
    max-width: 400px;
    width: 100%;
    padding: 32px;
    box-shadow: 0 24px 80px rgba(0,0,0,0.15);
    border: 1px solid rgba(255,255,255,0.5);
    animation: modalSlideUp 0.35s cubic-bezier(0.22,1,0.36,1);
}

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

.modal-title {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.3px;
}

.modal-close {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    padding: 4px;
    transition: color 0.2s;
}

.modal-close:hover { color: var(--text); }

/* ── Type Selector ── */
.type-selector {
    display: flex;
    padding: 4px;
    background: rgba(0,0,0,0.04);
    border-radius: 16px;
    margin-bottom: 28px;
}

.type-btn {
    flex: 1;
    padding: 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 700;
    border: none;
    background: none;
    color: var(--muted);
    cursor: pointer;
    transition: all 0.25s;
}

.type-btn.active {
    background: #fff;
    color: var(--text);
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

/* ── Form ── */
.form-group {
    margin-bottom: 18px;
    flex: 1;
}

.form-label {
    display: block;
    font-size: 10px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
    padding-left: 4px;
}

.form-input {
    width: 100%;
    background: rgba(0,0,0,0.03);
    border: none;
    border-radius: 16px;
    padding: 16px 20px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    outline: none;
    transition: box-shadow 0.2s;
    -webkit-appearance: none;
}

.form-input:focus {
    box-shadow: 0 0 0 3px rgba(0,122,255,0.2);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.btn-save {
    width: 100%;
    background: var(--text);
    color: #fff;
    border: none;
    border-radius: 18px;
    padding: 18px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    letter-spacing: 0.3px;
    margin-top: 8px;
    transition: all 0.2s;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.btn-save:active { transform: scale(0.97); opacity: 0.85; }

/* ── Login / Profile Page ── */
.login-container {
    min-height: 65vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.login-logo-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    background: #fff;
    border-radius: 28px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.08);
    margin: 0 auto 24px;
    overflow: hidden;
}

.login-logo-wrap img {
    width: 64px;
    height: 64px;
    border-radius: 20px;
}

.login-title {
    font-size: 28px;
    font-weight: 800;
    text-align: center;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}

.login-desc {
    font-size: 14px;
    color: var(--muted);
    text-align: center;
    font-weight: 500;
    margin-bottom: 32px;
}

.btn-google {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    background: #fff;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 18px;
    padding: 16px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text);
    text-decoration: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.btn-google:active { transform: scale(0.98); background: #f9f9f9; }

.btn-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    background: #fef2f2;
    color: #dc2626;
    border: none;
    border-radius: 18px;
    padding: 16px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-logout:active { transform: scale(0.98); background: #fee2e2; }

.profile-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    margin: 0 auto 16px;
    overflow: hidden;
    border: 2px solid rgba(0,0,0,0.08);
    background: #f3f4f6;
}

.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }

.profile-name {
    font-size: 20px;
    font-weight: 800;
    text-align: center;
}

.profile-email {
    font-size: 13px;
    color: var(--muted);
    text-align: center;
    margin-top: 4px;
    margin-bottom: 24px;
}

.login-form-group {
    margin-bottom: 14px;
}

.login-form-group .form-input {
    text-align: center;
    font-size: 16px;
}


/* ── Toast ── */
.toast {
    position: fixed;
    top: calc(var(--safe-top) + 16px);
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    background: rgba(0,0,0,0.85);
    color: #fff;
    padding: 12px 24px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    z-index: 9999;
    backdrop-filter: blur(12px);
    transition: transform 0.35s cubic-bezier(0.22,1,0.36,1);
    pointer-events: none;
    white-space: nowrap;
}

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

/* ── Animations ── */
.fade-in {
    animation: fadeIn 0.5s ease-out forwards;
}

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

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

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

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

/* ── Responsive ── */
@media (max-width: 380px) {
    .balance-value { font-size: 30px; }
    .modal-content { padding: 24px; }
}

/* ── Desktop Layout ── */
@media (min-width: 768px) {
    .app-container {
        max-width: 1100px;
        padding-top: 40px;
        padding-bottom: 60px;
    }
    
    .glass-header {
        border-radius: 24px;
        margin: 0;
        top: 20px;
        box-shadow: 0 10px 40px rgba(0,0,0,0.08);
        padding: 16px 24px;
    }
    
    .desktop-nav {
        display: flex;
        gap: 8px;
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        white-space: nowrap;
        flex-wrap: nowrap;
    }
    
    .desktop-nav .nav-item {
        flex-direction: row;
        padding: 10px 16px;
        border-radius: 20px;
        font-size: 13px;
        font-weight: 600;
    }
    
    .desktop-nav .nav-item:hover {
        background: rgba(0,0,0,0.04);
    }
    
    .desktop-nav .nav-item.active {
        background: var(--text);
        color: #fff;
    }
    
    .bottom-nav {
        display: none !important;
    }
    
    .dashboard-grid {
        display: grid;
        grid-template-columns: 380px 1fr;
        gap: 28px;
        margin-bottom: 28px;
    }
    
    .balance-card {
        margin-bottom: 0 !important;
        height: 100%;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }
}
