* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --bg: #07090d;
    --surface: #10141b;
    --surface-2: #171d27;
    --stroke: rgba(255, 255, 255, 0.08);
    --text: #f4f7ff;
    --text-soft: rgba(244, 247, 255, 0.72);
    --text-muted: rgba(244, 247, 255, 0.5);
    --neo: #74d8ff;
    --neo-2: #5aa7ff;
    --warning: #ffc94d;
    --danger: #ff6b6b;
    --success: #4ce2a1;
    --radius-xl: 24px;
    --radius-lg: 18px;
    --radius-md: 14px;
    --nav-h: 76px;
}

html,
body {
    min-height: 100%;
    font-family: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        radial-gradient(1000px 500px at 120% -10%, rgba(90, 167, 255, 0.18), transparent 60%),
        radial-gradient(700px 420px at -20% 10%, rgba(116, 216, 255, 0.18), transparent 55%),
        var(--bg);
    color: var(--text);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#app {
    min-height: 100vh;
    position: relative;
}

.tab-content {
    display: none;
    padding-bottom: calc(var(--nav-h) + 10px);
    transform-origin: center top;
}

.tab-content.active {
    display: block;
}

.tab-content.is-entering {
    animation: tab-enter 0.26s cubic-bezier(0.22, 1, 0.36, 1) both;
}

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

.home-page,
.history-page {
    width: 100%;
    max-width: 520px;
    margin: 0 auto;
    padding: 10px 14px 20px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.brand-logo {
    width: 88px;
    height: auto;
    object-fit: contain;
    transform: translateZ(0);
    backface-visibility: hidden;
}

.balance-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(116, 216, 255, 0.35);
    padding: 7px 12px;
    border-radius: 999px;
    background: rgba(116, 216, 255, 0.12);
    font-size: 12px;
    font-weight: 800;
    color: var(--text);
}

.welcome-card {
    border-radius: var(--radius-xl);
    border: 1px solid rgba(116, 216, 255, 0.25);
    background:
        linear-gradient(140deg, rgba(116, 216, 255, 0.16), rgba(90, 167, 255, 0.08) 45%, rgba(10, 14, 20, 0.9)),
        rgba(11, 16, 22, 0.7);
    margin-bottom: 10px;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.32);
    padding: 12px 14px;
}

.welcome-title {
    font-weight: 800;
    font-size: 17px;
    line-height: 1.25;
}

.welcome-subtitle {
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-soft);
}

.loyalty-card {
    border-radius: 26px;
    border: 1px solid rgba(116, 216, 255, 0.35);
    padding: 14px;
    background:
        radial-gradient(80% 80% at 90% 0%, rgba(116, 216, 255, 0.22), transparent 58%),
        radial-gradient(60% 60% at 0% 100%, rgba(90, 167, 255, 0.18), transparent 58%),
        linear-gradient(150deg, #111723, #0a0e15 65%);
    box-shadow:
        0 0 0 1px rgba(116, 216, 255, 0.08),
        0 20px 60px rgba(0, 0, 0, 0.5);
}

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

.card-title {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--text-soft);
}

.card-chip {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.18em;
    color: #0c1118;
    background: linear-gradient(120deg, var(--neo), var(--neo-2));
    padding: 6px 10px;
    border-radius: 999px;
}

.card-user {
    margin-bottom: 8px;
}

.card-name {
    display: block;
    font-size: 16px;
    font-weight: 800;
}

.card-phone {
    margin-top: 4px;
    display: block;
    font-size: 13px;
    color: var(--text-soft);
    font-family: "SF Mono", Consolas, "Courier New", monospace;
}

.qr-section {
    background: #fefefe;
    border-radius: var(--radius-lg);
    padding: 8px;
    aspect-ratio: 1 / 1;
    max-height: min(48vh, 340px);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.09);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.qr-code {
    width: 100%;
    aspect-ratio: 1 / 1;
    height: auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qr-code img,
.qr-code canvas {
    width: 100% !important;
    height: 100% !important;
    display: block;
    image-rendering: pixelated;
}

.hint {
    margin-top: 8px;
    text-align: center;
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.5;
    padding: 0 8px;
}

.history-header {
    margin-bottom: 12px;
}

.history-header h2 {
    font-size: 24px;
    font-weight: 800;
    line-height: 1.2;
}

.history-header p {
    margin-top: 5px;
    color: var(--text-soft);
    font-size: 13px;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.history-item {
    border-radius: var(--radius-md);
    border: 1px solid var(--stroke);
    background: linear-gradient(140deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.01));
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
}

.history-item.history-item-enter {
    animation: history-item-in 0.3s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes history-item-in {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.985);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.history-skeleton {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-md);
    border: 1px solid var(--stroke);
    background: rgba(255, 255, 255, 0.03);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
}

.history-skeleton::after {
    content: "";
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.08) 45%,
        rgba(255, 255, 255, 0.16) 50%,
        rgba(255, 255, 255, 0.08) 55%,
        transparent 100%
    );
    animation: skeleton-shimmer 1.2s linear infinite;
}

.hs-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.12);
    flex-shrink: 0;
}

.hs-body {
    flex: 1;
    min-width: 0;
}

.hs-line {
    height: 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
}

.hs-line-title {
    width: 72%;
}

.hs-line-date {
    width: 40%;
    margin-top: 8px;
}

.hs-amount {
    width: 46px;
    height: 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    flex-shrink: 0;
}

@keyframes skeleton-shimmer {
    to {
        transform: translateX(100%);
    }
}

.hi-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.hi-icon.earn {
    color: var(--success);
    background: rgba(76, 226, 161, 0.14);
}

.hi-icon.spend {
    color: var(--danger);
    background: rgba(255, 107, 107, 0.14);
}

.hi-body {
    flex: 1;
    min-width: 0;
}

.hi-desc {
    font-size: 14px;
    font-weight: 700;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.hi-date {
    margin-top: 3px;
    font-size: 12px;
    color: var(--text-muted);
}

.hi-amount {
    font-size: 16px;
    font-weight: 800;
    flex-shrink: 0;
}

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

.hi-amount.spend {
    color: var(--danger);
}

.history-empty {
    border: 1px dashed var(--stroke);
    border-radius: var(--radius-lg);
    color: var(--text-muted);
    text-align: center;
    padding: 48px 14px;
}

.btn-more {
    margin-top: 12px;
    width: 100%;
    border: 1px solid rgba(116, 216, 255, 0.3);
    background: linear-gradient(145deg, rgba(116, 216, 255, 0.18), rgba(90, 167, 255, 0.1));
    color: var(--text);
    border-radius: 14px;
    padding: 12px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    transition: transform 0.18s ease, opacity 0.18s ease, filter 0.18s ease;
}

.btn-more:active {
    transform: scale(0.99);
}

.btn-more.is-loading {
    opacity: 0.85;
    filter: saturate(0.8);
}

.bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: var(--nav-h);
    display: flex;
    background: rgba(7, 9, 13, 0.88);
    border-top: 1px solid var(--stroke);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.nav-btn {
    border: 0;
    background: transparent;
    position: relative;
    flex: 1;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-family: inherit;
    font-size: 11px;
    font-weight: 700;
    transition: color 0.2s ease, transform 0.2s ease;
}

.nav-btn::after {
    content: "";
    position: absolute;
    bottom: 8px;
    left: 50%;
    width: 0;
    height: 2px;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--neo), var(--neo-2));
    transform: translateX(-50%);
    transition: width 0.22s ease;
}

.nav-icon {
    width: 20px;
    height: 20px;
    transition: transform 0.22s ease;
}

.nav-btn:active {
    transform: translateY(1px);
}

.nav-btn.active {
    color: var(--neo);
}

.nav-btn.active::after {
    width: 26px;
}

.nav-btn.active .nav-icon {
    transform: scale(1.08);
}

.loading-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    transition: opacity 0.35s ease;
    z-index: 100;
}

.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-logo {
    width: 146px;
    height: auto;
}

.spinner {
    width: 28px;
    height: 28px;
    border-radius: 999px;
    border: 2px solid rgba(116, 216, 255, 0.2);
    border-top-color: var(--neo);
    animation: spin 0.75s linear infinite;
}

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