/* ========== DARK THEME ========== */
:root {
    --bg: #0f0f0f;
    --bg-card: #161616;
    --bg-input: #1c1c1c;
    --bg-modal: #111111;
    --border: #222;
    --text: #eee;
    --text2: #888;
    --text3: #555;
    --green: #1D9E75;
    --green-dark: #177A5B;
    --green-glow: rgba(29,158,117,0.12);
    --red: #E24B4A;
}

[x-cloak] { display: none !important; }
* { box-sizing: border-box; }

body {
    background: var(--bg) !important;
    color: var(--text) !important;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior-y: contain;
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

/* Scrollbar */
::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-thumb { background: #333; border-radius: 2px; }

/* Number input */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; }
input[type="number"] { -moz-appearance: textfield; }

/* ========== CARD ========== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
}

/* ========== INPUT ========== */
.input {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 12px;
    padding: 14px 16px;
    font-size: 16px;
    width: 100%;
    outline: none;
    transition: border-color 0.15s;
}
.input:focus {
    border-color: var(--green);
    box-shadow: 0 0 0 2px var(--green-glow);
}
.input::placeholder { color: var(--text3); }

/* ========== BOTTOM NAV ========== */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
    background: #0d0d0d;
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom, 0);
}
.bottom-nav-inner {
    display: flex; justify-content: space-around; align-items: center;
    max-width: 28rem; margin: 0 auto; height: 56px;
}
.nav-item {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 6px 14px; color: var(--text3); text-decoration: none;
    font-size: 10px; font-weight: 500; transition: color 0.15s;
}
.nav-item.active { color: var(--green); }
.nav-item svg { width: 22px; height: 22px; }

.nav-fab {
    display: flex; align-items: center; justify-content: center;
    width: 50px; height: 50px; background: var(--green); border-radius: 50%;
    margin-top: -20px; box-shadow: 0 4px 20px rgba(29,158,117,0.3);
    color: white; transition: transform 0.1s;
}
.nav-fab:active { transform: scale(0.9); }
.nav-fab svg { width: 26px; height: 26px; }

.has-bottom-nav { padding-bottom: 76px; }
@media (min-width: 768px) {
    .bottom-nav { display: none; }
    .has-bottom-nav { padding-bottom: 2rem; }
}

/* ========== FULL SCREEN MODAL (mobile) ========== */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    z-index: 60;
    background: var(--bg-modal);
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}
.modal-content {
    width: 100%;
    min-height: 100%;
    max-width: 100%;
    overflow-x: hidden;
}
@media (min-width: 768px) {
    .modal-overlay {
        background: rgba(0,0,0,0.6);
        backdrop-filter: blur(6px);
        display: flex; align-items: center; justify-content: center;
        overflow: hidden;
    }
    .modal-content {
        background: var(--bg-modal);
        border: 1px solid var(--border);
        border-radius: 20px;
        max-width: 420px; width: 100%;
        min-height: auto;
        max-height: 90vh; overflow-y: auto;
    }
}

/* ========== CATEGORY GRID ========== */
.cat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}
@media (min-width: 640px) {
    .cat-grid { grid-template-columns: repeat(5, 1fr); }
}
.cat-item {
    display: flex; flex-direction: column; align-items: center;
    gap: 6px; padding: 14px 4px; border-radius: 14px;
    border: 2px solid transparent; background: var(--bg-input);
    cursor: pointer; transition: all 0.15s; text-align: center;
}
.cat-item:active { transform: scale(0.95); }
.cat-item.selected {
    border-color: var(--green);
    background: var(--green-glow);
}
.cat-item .cat-icon { font-size: 28px; line-height: 1; }
.cat-item .cat-name {
    font-size: 10px; color: var(--text2);
    line-height: 1.2; max-width: 100%;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ========== SWIPE ========== */
.swipe-container { position: relative; overflow: hidden; }
.swipe-item {
    position: relative; z-index: 2; background: var(--bg-card);
    transition: transform 0.25s ease; touch-action: pan-y;
}
.swipe-item.swiping { transition: none; }
.swipe-bg {
    position: absolute; top: 0; right: 0; bottom: 0; width: 100%;
    display: flex; align-items: center; justify-content: flex-end;
    padding-right: 20px; background: var(--red); color: white;
    font-size: 12px; font-weight: 600; gap: 6px; z-index: 1;
}

/* ========== QUICK AMOUNTS ========== */
.quick-amounts {
    display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px;
}
.quick-btn {
    padding: 8px 16px; border-radius: 10px; font-size: 13px;
    background: var(--bg-input); color: var(--text2); border: 1px solid var(--border);
    transition: all 0.1s; font-weight: 500;
}
.quick-btn:active { background: var(--green-glow); color: var(--green); border-color: var(--green); }

/* ========== REPEAT BTN ========== */
.btn-repeat {
    padding: 5px 10px; font-size: 13px; border-radius: 8px;
    background: var(--green-glow); color: var(--green);
    border: none; transition: all 0.1s; font-weight: 600;
}
.btn-repeat:active { background: var(--green); color: white; }

/* ========== PROGRESS BAR ========== */
.progress-bar { height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; }
.progress-fill { height: 100%; border-radius: 3px; transition: width 0.6s ease; }

/* ========== ANIMATIONS ========== */
.fade-up { animation: fadeUp 0.25s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* ========== TOAST ========== */
.toast {
    position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
    z-index: 100; padding: 14px 28px; border-radius: 14px;
    background: var(--green); color: white; font-size: 14px;
    font-weight: 500; box-shadow: 0 8px 30px rgba(0,0,0,0.5);
}

/* ========== SKELETON LOADING ========== */
.skeleton {
    background: linear-gradient(90deg, #1c1c1c 25%, #282828 50%, #1c1c1c 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: 8px;
}
@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
.skeleton-text { height: 14px; border-radius: 7px; }
.skeleton-text-sm { height: 12px; border-radius: 6px; }
.skeleton-circle { border-radius: 50%; }

/* ========== SPINNER ========== */
.spinner {
    display: inline-block; width: 16px; height: 16px;
    border: 2px solid rgba(255,255,255,0.2);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
.spinner-sm { width: 14px; height: 14px; border-width: 1.5px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ========== SEARCH BAR ========== */
.search-input {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.search-input:focus {
    border-color: var(--green);
    box-shadow: 0 0 0 3px var(--green-glow);
}
.search-input::placeholder { color: var(--text3); }

/* ========== FILTER ========== */
.filter-toggle-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 14px; border-radius: 10px;
    font-size: 12px; font-weight: 500;
    background: var(--bg-input); color: var(--text2);
    border: 1px solid var(--border);
    transition: all 0.15s; cursor: pointer;
}
.filter-toggle-btn:active { transform: scale(0.96); }
.filter-toggle-btn.active {
    color: var(--green); border-color: var(--green);
    background: var(--green-glow);
}
.filter-badge {
    background: var(--green); color: white;
    font-size: 10px; font-weight: 700;
    min-width: 18px; height: 18px; padding: 0 5px;
    border-radius: 9px;
    display: inline-flex; align-items: center; justify-content: center;
    line-height: 1;
}
.filter-chip {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 8px 14px; border-radius: 10px;
    font-size: 12px; white-space: nowrap; cursor: pointer;
    background: var(--bg-input); color: var(--text2);
    border: 1px solid var(--border);
    transition: all 0.15s; flex-shrink: 0;
}
.filter-chip:active { transform: scale(0.95); }
.filter-chip.active {
    background: var(--green-glow); color: var(--green);
    border-color: var(--green);
}
.filter-chips-scroll {
    scrollbar-width: none; -ms-overflow-style: none;
}
.filter-chips-scroll::-webkit-scrollbar { display: none; }

/* ========== CHART SKELETON ========== */
.chart-skeleton {
    position: relative; display: flex;
    align-items: center; justify-content: center;
    min-height: 180px;
}
.chart-skeleton-circle {
    width: 160px; height: 160px; border-radius: 50%;
    background: linear-gradient(90deg, #1c1c1c 25%, #282828 50%, #1c1c1c 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    position: relative;
}
.chart-skeleton-circle::after {
    content: ''; position: absolute;
    top: 30%; left: 30%; right: 30%; bottom: 30%;
    border-radius: 50%; background: var(--bg-card);
}
.chart-skeleton-bars {
    display: flex; align-items: flex-end; gap: 6px;
    height: 150px; width: 100%; padding: 0 4px;
}
.chart-skeleton-bar {
    flex: 1; border-radius: 4px;
    background: linear-gradient(90deg, #1c1c1c 25%, #282828 50%, #1c1c1c 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
}

/* ========== BUTTON LOADING ========== */
.btn-loading {
    position: relative; pointer-events: none; opacity: 0.7;
}
.btn-loading .btn-text { visibility: hidden; }
.btn-loading .btn-spinner {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
}

/* ========== ENHANCED ANIMATIONS ========== */
.fade-up-list > .fade-up-item {
    animation: fadeUp 0.35s ease both;
}
.fade-up-list > .fade-up-item:nth-child(1) { animation-delay: 0ms; }
.fade-up-list > .fade-up-item:nth-child(2) { animation-delay: 50ms; }
.fade-up-list > .fade-up-item:nth-child(3) { animation-delay: 100ms; }
.fade-up-list > .fade-up-item:nth-child(4) { animation-delay: 150ms; }
.fade-up-list > .fade-up-item:nth-child(5) { animation-delay: 200ms; }
.fade-up-list > .fade-up-item:nth-child(n+6) { animation-delay: 250ms; }

/* Smooth filter panel */
.filter-panel {
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.25s ease;
}
.filter-panel[data-closed] { max-height: 0; opacity: 0; }

/* Pulse on tap */
@keyframes tapPulse {
    0% { transform: scale(1); }
    50% { transform: scale(0.96); }
    100% { transform: scale(1); }
}
.tap-pulse:active { animation: tapPulse 0.15s ease; }
