:root {
    /* Color Palette - Refined */
    --bg: #F8FAFC;
    --card: #FFFFFF;
    --primary: #FF4757;
    --primary-dark: #E84118;
    --primary-light: #FFEBEE;
    --primary-gradient: linear-gradient(135deg, #FF6B81 0%, #FF4757 100%);
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.4);
    
    --text-h: #2D3436;
    --text-p: #636E72;
    --text-light: #B2BEC3;
    
    /* Extended Colors */
    --success: #2ECC71;
    --success-light: #E8F8F5;
    --warning: #F1C40F;
    --warning-light: #FEF9E7;
    --info: #3498DB;
    --info-light: #EBF5FB;
    
    /* Shadows - More subtle and modern */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.02);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.08);
    --shadow-primary: 0 10px 25px rgba(255, 71, 87, 0.2);
    
    /* Border Radius */
    --radius-sm: 12px;
    --radius-md: 20px;
    --radius-lg: 28px;
    --radius-xl: 40px;
    
    /* Spacing System */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
}

/* ============================================
   Reset & Base Styles
   ============================================ */

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

body {
    background: var(--bg);
    color: var(--text-h);
    font-family: 'Inter', -apple-system, "PingFang SC", "Noto Sans SC", sans-serif;
    font-size: 15px;
    line-height: 1.6;
    min-height: 100vh;
}

/* ============================================
   Layout Components
   ============================================ */

.app {
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    padding: 24px 20px 100px;
    display: flex;
    flex-direction: column;
}

.header {
    margin-bottom: 28px;
}

.summary-card {
    margin-bottom: 32px;
}

.quick-actions {
    margin-bottom: 32px;
}

.section {
    margin-bottom: 32px;
}

/* ============================================
   Header Section
   ============================================ */

.user-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.avatar-group {
    display: flex;
    align-items: center;
    gap: 16px;
}

.avatar {
    width: 48px;
    height: 48px;
    background: var(--primary-gradient);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 18px;
    box-shadow: var(--shadow-primary);
}

.welcome-text h1 {
    font-size: 20px;
    font-weight: 800;
    color: var(--text-h);
    letter-spacing: -0.5px;
}

.welcome-text p {
    font-size: 13px;
    color: var(--text-light);
    margin-top: 2px;
}

.msg-btn {
    background: var(--card);
    border-radius: 14px;
    padding: 10px 14px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-h);
    border: 1px solid rgba(0,0,0,0.02);
}

/* ============================================
   Summary Card - Glassmorphism
   ============================================ */

.summary-card {
    background: var(--primary-gradient);
    border-radius: var(--radius-lg);
    padding: 32px 28px;
    color: white;
    box-shadow: var(--shadow-primary);
    position: relative;
    overflow: hidden;
}

.summary-card::before {
    content: '';
    position: absolute;
    top: -50px;
    right: -50px;
    width: 150px;
    height: 150px;
    background: radial-gradient(circle, rgba(255,255,255,0.2) 0%, rgba(255,255,255,0) 70%);
    border-radius: 50%;
}

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

.summary-header span {
    font-size: 14px;
    font-weight: 500;
    opacity: 0.8;
}

.summary-header .badge {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(4px);
    padding: 4px 12px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
}

.summary-main .val {
    font-size: 44px;
    font-weight: 800;
    letter-spacing: -1px;
    margin-bottom: 24px;
}

.summary-footer {
    display: flex;
    gap: 40px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-item .label {
    font-size: 12px;
    opacity: 0.7;
    font-weight: 500;
}

.stat-item .count {
    font-size: 20px;
    font-weight: 700;
}

/* ============================================
   Quick Actions
   ============================================ */

.quick-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.action-btn {
    background: var(--card);
    padding: 24px 12px;
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text-h);
    box-shadow: var(--shadow-sm);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(0,0,0,0.01);
}

.action-btn:active {
    transform: translateY(2px);
    box-shadow: none;
    background: #fdfdfd;
}

.btn-icon {
    width: 52px;
    height: 52px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    transition: all 0.3s;
}

.action-btn:hover .btn-icon {
    transform: scale(1.1) rotate(-5deg);
    background: var(--primary);
    color: white;
}

.action-btn span {
    font-size: 13px;
    font-weight: 700;
}

/* ============================================
   Section Lists
   ============================================ */

.section-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.section-title h3 {
    font-size: 18px;
    font-weight: 800;
    color: var(--text-h);
}

.section-title a {
    font-size: 13px;
    color: var(--primary);
    text-decoration: none;
    font-weight: 700;
}

.list-card {
    background: var(--card);
    border-radius: var(--radius-md);
    padding: 8px 4px;
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(0,0,0,0.02);
}

.row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 16px;
    border-bottom: 1px solid #F1F5F9;
    transition: background 0.2s;
}

.row:last-child {
    border: none;
}

.row:active {
    background: #F8FAFC;
}

.row-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.row-icon {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background: #F1F5F9;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--text-p);
}

.row-text .title {
    font-size: 15px;
    font-weight: 700;
    display: block;
    color: var(--text-h);
    margin-bottom: 2px;
}

.row-text .sub {
    font-size: 12px;
    color: var(--text-light);
    font-weight: 500;
}

.row-side {
    text-align: right;
}

.row-side .amt {
    font-size: 16px;
    font-weight: 800;
    color: var(--text-h);
}

.row-side .tag {
    display: inline-block;
    font-size: 11px;
    padding: 2px 10px;
    border-radius: 8px;
    background: #F1F5F9;
    color: var(--text-p);
    font-weight: 700;
    margin-top: 4px;
}

/* ============================================
   Bottom Navigation - Floating Glass
   ============================================ */

.bottom-nav {
    position: fixed;
    bottom: 24px;
    left: 20px;
    right: 20px;
    max-width: 440px;
    margin: 0 auto;
    height: 72px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 36px;
    display: flex;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.5);
    z-index: 1000;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    text-decoration: none;
    color: var(--text-light);
    transition: all 0.3s;
    padding: 8px 16px;
    border-radius: 20px;
}

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

.nav-icon {
    font-size: 20px;
}

.nav-label {
    font-size: 10px;
    font-weight: 800;
}

.nav-item.highlight {
    background: var(--primary-gradient);
    color: white !important;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    margin-top: -45px;
    box-shadow: var(--shadow-primary);
    display: flex;
    justify-content: center;
    border: 4px solid var(--card);
}

.nav-item.highlight .nav-icon {
    font-size: 24px;
}

.nav-item.highlight .nav-label {
    display: none;
}

/* ============================================
   Animations
   ============================================ */

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

.app > * {
    animation: fadeInUp 0.6s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.app > *:nth-child(1) { animation-delay: 0.1s; }
.app > *:nth-child(2) { animation-delay: 0.2s; }
.app > *:nth-child(3) { animation-delay: 0.3s; }
.app > *:nth-child(4) { animation-delay: 0.4s; }
.app > *:nth-child(5) { animation-delay: 0.5s; }

/* ============================================
   Ledger Page Styles
   ============================================ */

.ledger-hero {
    background: var(--primary-gradient);
    padding: 32px 24px 60px;
    color: white;
    border-bottom-left-radius: var(--radius-lg);
    border-bottom-right-radius: var(--radius-lg);
    position: relative;
    margin-bottom: 24px;
    box-shadow: var(--shadow-primary);
}

.ledger-hero::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 40px;
    background: var(--bg);
    clip-path: ellipse(55% 100% at 50% 100%);
}

.hero-top-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 24px;
    position: relative;
}

.page-title {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.header-add-btn {
    position: absolute;
    right: 0;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    text-decoration: none;
    font-size: 20px;
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    transition: all 0.2s;
}

.header-add-btn:active {
    transform: scale(0.9);
    background: rgba(255, 255, 255, 0.3);
}

.hero-info h1 {
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 6px;
}

.hero-info p {
    font-size: 14px;
    opacity: 0.8;
}

.hero-stats {
    display: flex;
    gap: 32px;
    margin-top: 24px;
}

.h-stat-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.h-stat-val {
    font-size: 22px;
    font-weight: 800;
}

.h-stat-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.7;
}

/* Filter Tabs */
.filter-tabs {
    margin: -30px 20px 20px;
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding: 8px 4px 16px;
    scrollbar-width: none;
    position: relative;
    z-index: 10;
}

.filter-tabs::-webkit-scrollbar {
    display: none;
}

.tab {
    background: var(--card);
    padding: 10px 24px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    color: var(--text-p);
    white-space: nowrap;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    border: 1px solid transparent;
}

.tab.active {
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow-primary);
    transform: translateY(-2px);
}

/* Book Cards */
.books-container {
    padding: 0 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.book-card {
    background: var(--card);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    gap: 16px;
    box-shadow: var(--shadow-sm);
    text-decoration: none;
    color: inherit;
    transition: all 0.3s;
    border: 1px solid rgba(0, 0, 0, 0.03);
    position: relative;
    overflow: hidden;
}

.book-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--primary);
    opacity: 0;
    transition: opacity 0.3s;
}

.book-card:active {
    transform: scale(0.98);
    background: #FAFAFA;
}

.book-card:hover::before {
    opacity: 1;
}

.book-cover {
    width: 64px;
    height: 84px;
    border-radius: 4px 8px 8px 4px;
    position: relative;
    box-shadow: 4px 4px 12px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.book-cover::after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 6px;
    background: rgba(0, 0, 0, 0.1);
}

.cover-type {
    position: absolute;
    top: 8px;
    right: 0;
    background: rgba(255, 255, 255, 0.25);
    padding: 2px 6px;
    font-size: 9px;
    color: white;
    border-radius: 4px 0 0 4px;
    font-weight: 800;
    backdrop-filter: blur(4px);
}

.cover-icon {
    font-size: 24px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.book-info {
    flex: 1;
    display: flex;    flex-direction: column;
    justify-content: space-between;
}

.b-top {
    margin-bottom: 8px;
}

.b-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-h);
    display: block;
    margin-bottom: 2px;
}

.b-date {
    font-size: 12px;
    color: var(--text-light);
}

.b-bottom {
    display: flex;
    gap: 20px;
}

.b-stat {
    display: flex;
    flex-direction: column;
}

.b-stat .v {
    font-size: 15px;
    font-weight: 700;
    color: var(--primary);
}

.b-stat .l {
    font-size: 11px;
    color: var(--text-light);
}

.arrow-indicator {
    display: flex;
    align-items: center;
    color: var(--text-light);
    font-size: 20px;
}

/* Empty State */
.empty-state {
    padding: 60px 20px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.empty-state .icon {
    font-size: 64px;
    opacity: 0.2;
}

.empty-state .text {
    color: var(--text-light);
    font-size: 15px;
}

/* Popup Styles */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 100;
}

.popup-content {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--card);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 32px 24px calc(32px + env(safe-area-inset-bottom));
    z-index: 101;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.1);
    animation: slideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.popup-title {
    font-size: 20px;
    font-weight: 800;
    margin-bottom: 24px;
    text-align: center;
}

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

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-p);
    margin-bottom: 8px;
}

.form-input, .form-textarea, .picker-view {
    width: 100%;
    background: var(--bg);
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    font-size: 15px;
    transition: all 0.2s;
}

.form-input:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 4px var(--primary-light);
}

.picker-view {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.submit-btn {
    width: 100%;
    background: var(--primary-gradient);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    padding: 16px;
    font-size: 16px;
    font-weight: 700;
    margin-top: 12px;
    box-shadow: var(--shadow-primary);
}

.submit-btn:active {
    transform: scale(0.98);
    opacity: 0.9;
}
