:root {
    --bg-dark: #0b0d17;
    --card-bg: rgba(255, 255, 255, 0.05);
    --sidebar-bg: #0f1220;
    --border-color: rgba(255, 255, 255, 0.1);
    --accent-purple: #7047eb;
    --accent-green: #00e676;
    --accent-blue: #00d2ff;
    --text-primary: #ffffff;
    --text-secondary: #a0aec0;
    --font-main: 'Outfit', sans-serif;
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html, body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-main);
    overflow-x: clip;
    width: 100%;
    min-height: 100vh;
}

/* Global Form Element Styling */
select, input, textarea {
    background-color: #1a1c23; /* Solid dark background */
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: #ffffff; /* Solid white text */
    font-family: inherit;
    padding: 12px 15px;
}

/* Specific fix for dropdown options which are often hard to style */
select option {
    background-color: #1a1c23 !important;
    color: #ffffff !important;
}

select:focus, input:focus {
    outline: none;
    border-color: var(--accent-purple);
    background-color: #252833; /* Slightly lighter on focus */
}

/* Hide content by default on protected pages to prevent flicker */
body:not(.auth-ready):not(.login-page) .container,
body:not(.auth-ready).login-page .login-container {
    opacity: 0;
    pointer-events: none;
}

.container, .login-container {
    transition: opacity 0.4s ease-in-out;
}

/* Background Effects */
.glow-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle at 10% 20%, rgba(112, 71, 235, 0.1) 0%, transparent 40%),
                radial-gradient(circle at 90% 80%, rgba(0, 210, 255, 0.1) 0%, transparent 40%);
    z-index: -1;
    pointer-events: none;
    will-change: transform;
    transform: translateZ(0); /* Hardware acceleration */
}

.glow-bg::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 600px;
    height: 600px;
    /* Replaced expensive filter: blur(250px) with a simple radial gradient */
    background: radial-gradient(circle, rgba(112, 71, 235, 0.05) 0%, transparent 70%);
    transform: translate(-50%, -50%) translateZ(0);
}

/* Layout Container */
.container {
    display: flex;
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    padding: 20px;
    gap: 30px;
    box-sizing: border-box;
}

/* Sidebar Styling */
spendly-sidebar, spendly-admin-sidebar {
    display: contents;
}
.sidebar {
    width: 280px;
    min-width: 280px;
    flex-shrink: 0;
    background: var(--sidebar-bg);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 30px;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 40px);
    position: sticky;
    top: 20px;
    overflow-y: auto;
    scrollbar-width: none; /* Firefox */
    align-self: flex-start;
}

.sidebar::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 40px;
}

.logo i {
    font-size: 28px;
    color: var(--accent-purple);
    text-shadow: 0 0 20px rgba(112, 71, 235, 0.6);
}

.logo h2 {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 20px;
    margin-bottom: 30px;
}

.avatar {
    width: 45px;
    height: 45px;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-blue));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.user-info .welcome {
    font-size: 11px;
    color: var(--text-secondary);
}

.user-info .username {
    font-weight: 600;
    font-size: 14px;
}

nav {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex-grow: 1;
}

.nav-category {
    font-size: 10px;
    font-weight: 800;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin: 20px 0 10px 20px;
    opacity: 0.6;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 14px 20px;
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 500;
    border-radius: 15px;
    transition: var(--transition-smooth);
}

.nav-item:hover, .nav-item.active {
    background: rgba(112, 71, 235, 0.1);
    color: var(--text-primary);
}

.nav-item.active {
    border: 1px solid rgba(112, 71, 235, 0.3);
}

.global-rate-box {
    margin-top: auto;
    padding: 20px;
    background: linear-gradient(to right bottom, rgba(112, 71, 235, 0.1), transparent);
    border-radius: 20px;
    text-align: center;
}

.global-rate-box p {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.rate-badge {
    color: var(--accent-purple);
    font-weight: 800;
    font-size: 18px;
}

/* Main Content Styling */
.content {
    flex-grow: 1;
    padding-top: 10px;
    min-width: 0;
    max-width: 100%;
}

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

header h2 {
    font-size: 14px;
    color: var(--accent-purple);
    font-weight: 600;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

header h1 {
    font-size: 32px;
    font-weight: 800;
    letter-spacing: -1px;
    margin-bottom: 5px;
}

header p {
    color: var(--text-secondary);
}

.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-right {
    gap: 10px;
}

.date-chip {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    padding: 10px 20px;
    border-radius: 30px;
    font-size: 14px;
    color: var(--text-secondary);
}

/* Base Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    padding: 25px;
    border-radius: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    transition: var(--transition-smooth);
}

.stat-card:hover {
    transform: translateY(-5px);
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.stat-icon.purple { background: rgba(112, 71, 235, 0.2); color: var(--accent-purple); }
.stat-icon.green { background: rgba(0, 230, 118, 0.2); color: var(--accent-green); }
.stat-icon.blue { background: rgba(0, 210, 255, 0.2); color: var(--accent-blue); }

.stat-info h3 {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 5px;
}

.stat-info .value {
    font-size: 24px;
    font-weight: 800;
}

/* Portfolio Utilization */
.utilization-section {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 30px;
    margin-bottom: 40px;
}

.util-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 20px;
}

.util-header h2 { font-size: 18px; }
.util-header .percentage { font-size: 38px; font-weight: 800; letter-spacing: -2px; }
.util-header .percentage.healthy { color: var(--accent-green); }
.util-header .percentage.warning { color: coral; }

.progress-container {
    height: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 15px;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(to right, var(--accent-purple), var(--accent-blue));
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(112, 71, 235, 0.5);
    transition: width 1s ease-in-out;
}

.util-footer {
    display: flex;
    justify-content: space-between;
    color: var(--text-secondary);
    font-size: 13px;
}

/* CC Grid Layout */
.section-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.section-title h2 { font-size: 22px; font-weight: 700; }

.btn-add {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 25px;
    background: var(--accent-purple);
    color: white;
    border: none;
    border-radius: 12px;
    font-weight: 700;
    font-family: inherit;
    font-size: 14px;
    text-decoration: none;
    cursor: pointer;
    transition: var(--transition-smooth);
    box-shadow: 0 10px 20px rgba(112, 71, 235, 0.2);
}

.btn-add:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 30px rgba(112, 71, 235, 0.4);
}

#btnGeneratePDF {
    background: rgba(0, 210, 255, 0.1);
    color: #00d2ff;
    border: 1px solid rgba(0, 210, 255, 0.2);
    box-shadow: none;
}

#btnGeneratePDF:hover {
    background: rgba(0, 210, 255, 0.2);
    box-shadow: 0 10px 25px rgba(0, 210, 255, 0.1);
}

.cc-grid {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    gap: 25px;
    padding: 10px 5px 25px 5px;
    width: 100%;
    justify-content: flex-start;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
    
    scrollbar-width: thin;
    scrollbar-color: rgba(139, 92, 246, 0.3) rgba(255, 255, 255, 0.02);
}

.cc-grid::-webkit-scrollbar {
    height: 8px;
}
.cc-grid::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
    border-radius: 6px;
}
.cc-grid::-webkit-scrollbar-thumb {
    background: rgba(139, 92, 246, 0.25);
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: background 0.3s;
}
.cc-grid::-webkit-scrollbar-thumb:hover {
    background: rgba(139, 92, 246, 0.5);
}

.cc-grid .card-item {
    flex: 0 0 310px;
    width: 310px;
    max-width: 310px;
    scroll-snap-align: start;
    margin: 0;
    box-sizing: border-box;
    transition: transform 0.3s ease, border-color 0.3s ease;
}
.cc-grid .card-item:hover {
    transform: translateY(-5px);
    border-color: rgba(139, 92, 246, 0.4);
}

/* Premium Scroll controls for Active Accounts */
.scroll-btn-premium {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-glass);
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.scroll-btn-premium:hover {
    background: rgba(139, 92, 246, 0.15);
    border-color: var(--accent-purple);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(139, 92, 246, 0.2);
}

.scroll-btn-premium:active {
    transform: translateY(0);
}

@media (max-width: 768px) {
    .scroll-controls-premium {
        display: none !important;
    }
}

.card-item {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.03) 100%);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 25px;
    position: relative;
    overflow: hidden;
}

.card-item::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100px;
    height: 100px;
    background: radial-gradient(circle at top right, rgba(255,255,255,0.05), transparent);
}

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

.owner-pill {
    background: rgba(255, 255, 255, 0.1);
    padding: 4px 12px;
    border-radius: 30px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
}

.card-actions {
    color: var(--text-secondary);
    cursor: pointer;
}

.bank-name {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 25px;
}

.card-balance {
    margin-bottom: 25px;
}

.card-balance .label {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.card-balance .val {
    font-size: 28px;
    font-weight: 800;
}

.card-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.detail .label {
    display: block;
    font-size: 10px;
    color: var(--text-secondary);
    margin-bottom: 2px;
}

.detail .val {
    font-weight: 600;
    font-size: 14px;
}

.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-footer p {
    font-size: 12px;
    color: var(--text-secondary);
}

.card-footer strong {
    color: var(--accent-green);
    font-size: 14px;
}

/* Animations */
@keyframes float {
    0% { transform: translateY(0px) rotate(0deg); }
    50% { transform: translateY(-5px) rotate(5deg); }
    100% { transform: translateY(0px) rotate(0deg); }
}

.animate-float {
    animation: float 4s ease-in-out infinite;
}

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

.animate-in {
    opacity: 0;
    animation: fadeIn 0.6s ease-out forwards;
    animation-delay: var(--d, 0s);
}

/* Login Page Specifics */
.login-page {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-container {
    width: 100%;
    max-width: 450px;
    padding: 20px;
}

.login-box {
    background: var(--card-bg);
    backdrop-filter: blur(40px);
    border: 1px solid var(--border-color);
    padding: 50px 40px;
    border-radius: 32px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.login-box .logo {
    justify-content: center;
    margin-bottom: 30px;
}

.login-box h1 {
    font-size: 32px;
    font-weight: 800;
    margin-bottom: 10px;
    letter-spacing: -1px;
}

.login-box .subtitle {
    color: var(--text-secondary);
    font-size: 15px;
    margin-bottom: 40px;
}



.btn-login {
    width: 100%;
    padding: 18px;
    background: linear-gradient(135deg, var(--accent-purple), #5c39c4);
    color: white;
    border: none;
    border-radius: 16px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 10px;
}

.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(112, 71, 235, 0.4);
}

.error-msg {
    background: rgba(255, 59, 48, 0.1);
    border: 1px solid rgba(255, 59, 48, 0.3);
    color: #ff3b30;
    padding: 15px;
    border-radius: 16px;
    font-size: 14px;
    margin-bottom: 30px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.footer-note {
    margin-top: 30px;
    font-size: 12px;
    color: var(--text-secondary);
    opacity: 0.6;
}

.main-footer {
    display: flex;
    justify-content: center;
    padding: 30px 20px 100px 20px; /* Space for mobile nav */
    border-top: 1px solid var(--border-color);
    margin-top: 60px;
}

.main-footer p {
    font-size: 13px;
    color: var(--text-secondary);
    opacity: 0.5;
    letter-spacing: 0.5px;
}

/* For mobile nav to not overlap on desktop, reduce padding */
@media (min-width: 993px) {
    .main-footer { padding: 30px 20px; }
}

/* Google Auth & Separator */
.separator {
    text-align: center;
    margin: 25px 0;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.separator::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    width: 100%;
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    z-index: 1;
}

.separator span {
    position: relative;
    background: #121212; /* Dark background matching the page */
    padding: 0 15px;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1.5px;
    z-index: 2;
    text-transform: uppercase;
}

.btn-google {
    width: 100%;
    padding: 14px;
    background: white;
    color: #1f1f1f;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    font-family: 'Outfit', sans-serif;
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    transition: all 0.3s ease;
}

.btn-google:hover {
    background: #f8f9fa;
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(255, 255, 255, 0.1);
}



.modal-overlay.active .modal-content {
    transform: scale(1) translateY(0);
    opacity: 1;
}

.modal-header {
    background: rgba(255, 255, 255, 0.02);
    padding: 35px 40px 25px 40px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.modal-header-text {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.modal-header h2 {
    font-size: 24px;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0;
    letter-spacing: -0.5px;
}

.modal-header h2 i {
    color: var(--accent-purple);
    background: rgba(112, 71, 235, 0.15);
    padding: 10px;
    border-radius: 12px;
    font-size: 18px;
    box-shadow: 0 0 15px rgba(112, 71, 235, 0.2);
}

.modal-header p {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0;
}

.btn-close {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition-smooth);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    transform: rotate(90deg);
}

.modal-body {
    padding: 30px 40px 40px 40px;
}

.input-modern {
    margin-bottom: 25px;
}

.input-modern label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.input-modern input {
    width: 100%;
    padding: 16px 20px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    color: white;
    font-family: inherit;
    font-size: 15px;
    transition: var(--transition-smooth);
}

.input-modern input:focus {
    outline: none;
    border-color: var(--accent-purple);
    background: rgba(255, 255, 255, 0.06);
    box-shadow: 0 0 20px rgba(112, 71, 235, 0.15);
}

.modal-footer {
    display: flex;
    gap: 15px;
    margin-top: 15px;
}

.btn-save-tx {
    flex-grow: 2;
    background: linear-gradient(135deg, var(--accent-purple), #5c39c4);
    color: white;
    border: none;
    padding: 16px;
    border-radius: 16px;
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: var(--transition-smooth);
    box-shadow: 0 10px 20px rgba(112, 71, 235, 0.2);
}

.btn-save-tx:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 30px rgba(112, 71, 235, 0.4);
}

.btn-save-tx:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.btn-delete-tx {
    flex-grow: 1;
    background: rgba(255, 59, 48, 0.05);
    color: #ff3b30;
    border: 1px solid rgba(255, 59, 48, 0.2);
    padding: 16px;
    border-radius: 16px;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-delete-tx:hover {
    background: rgba(255, 59, 48, 0.15);
    border-color: rgba(255, 59, 48, 0.4);
    transform: translateY(-2px);
}

.btn-delete-tx:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}
.btn-google img {
    height: 18px;
    width: 18px;
}

/* Custom Transaction Modal - Ultra Modern */
.tx-modal {
    padding: 0;
    max-width: 400px;
    background: radial-gradient(circle at top right, rgba(30,32,45,0.4), var(--bg-dark));
    border: 1px solid rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(20px);
}

.modal-header-centered {
    position: relative;
    padding: 30px 30px 15px;
    text-align: center;
}

.icon-circle {
    width: 60px;
    height: 60px;
    margin: 0 auto 15px;
    background: linear-gradient(135deg, rgba(112, 71, 235, 0.15), rgba(0, 210, 255, 0.1));
    border: 1px solid rgba(112, 71, 235, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-purple);
    font-size: 24px;
    box-shadow: 0 10px 30px rgba(112, 71, 235, 0.15);
}

.modal-header-centered h2 {
    font-size: 24px;
    font-weight: 800;
    margin: 0;
    letter-spacing: -0.5px;
}

.btn-close-abs {
    position: absolute;
    top: 25px;
    right: 25px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.05);
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.btn-close-abs:hover {
    background: rgba(255,255,255,0.1);
    color: white;
    transform: rotate(90deg);
}

.modal-body-pad {
    padding: 0 35px 25px;
}

.amount-display-group {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 20px;
    padding: 15px 20px;
    margin-bottom: 25px;
    transition: var(--transition-smooth);
}

.amount-display-group:focus-within {
    background: rgba(112, 71, 235, 0.05);
    border-color: rgba(112, 71, 235, 0.3);
}

.currency-symbol {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-secondary);
    margin-right: 15px;
}

.amount-huge {
    background: transparent;
    border: none;
    color: white;
    font-size: 42px;
    font-weight: 800;
    width: 160px;
    text-align: left;
    outline: none;
    font-family: inherit;
    padding: 0;
}

.amount-huge:focus {
    outline: none;
}
/* Hide arrows in number input */
.amount-huge::-webkit-outer-spin-button,
.amount-huge::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.input-stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.input-modern-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.input-modern-icon .icon-prefix {
    position: absolute;
    left: 20px;
    color: var(--text-secondary);
    font-size: 16px;
    pointer-events: none;
}

.input-modern-icon input, .input-modern-icon select {
    width: 100%;
    padding: 14px 20px 14px 45px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    color: white;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.3s;
    appearance: none;
    -webkit-appearance: none;
}

.input-modern-icon select option {
    background: var(--bg-dark);
    color: white;
}

.input-modern-icon input:focus, .input-modern-icon select:focus {
    border-color: var(--accent-purple);
    background: rgba(112, 71, 235, 0.05);
    outline: none;
    box-shadow: 0 0 20px rgba(112, 71, 235, 0.1);
}

.modal-actions-stacked {
    padding: 0 35px 35px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.btn-save-primary {
    width: 100%;
    padding: 15px;
    background: linear-gradient(135deg, var(--accent-purple), #5c39c4);
    color: white;
    border: none;
    border-radius: 14px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 10px 20px rgba(112, 71, 235, 0.2);
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-save-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 30px rgba(112, 71, 235, 0.4);
}

.btn-delete-ghost {
    width: 100%;
    padding: 12px;
    background: transparent;
    color: rgba(255, 59, 48, 0.7);
    border: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-delete-ghost:hover {
    color: #ff3b30;
    background: rgba(255, 59, 48, 0.05);
    border-radius: 12px;
}

.animate-in {
    opacity: 0;
    transform: translateY(20px);
    animation: slideUpFade 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    animation-delay: var(--d, 0s);
}

@keyframes slideUpFade {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
/* Responsive Design */
@media (max-width: 1200px) {
    .container {
        gap: 20px;
        padding: 15px;
        width: 100%;
        box-sizing: border-box;
    }
    .sidebar {
        width: 240px;
        min-width: 240px;
    }
}

/* Mobile Unified Top Nav - Ultra Compact */
.mobile-top-nav {
    display: none;
    position: sticky;
    top: 0;
    width: 100%;
    height: auto;
    min-height: 58px;
    padding: 10px 20px;
    background: rgba(11, 13, 23, 0.95);
    backdrop-filter: blur(25px) saturate(200%);
    border-bottom: 1px solid var(--border-color);
    z-index: 1000;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    justify-content: flex-start;
    align-items: center;
    gap: 15px;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.mobile-top-nav.nav-hidden-top {
    transform: translateY(-100%);
}

.mobile-top-nav .logo {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 8px;
    margin: 0 !important;
    padding: 0 !important;
}

.mobile-top-nav .logo i {
    font-size: 18px;
    color: var(--accent-purple);
    line-height: 1;
    display: flex;
    align-items: center;
}

.mobile-top-nav .logo span {
    font-weight: 800;
    font-size: 15px;
    letter-spacing: -0.5px;
    color: white;
    line-height: 1;
    display: flex;
    align-items: center;
    margin-top: 1px; /* Optical adjustment for Outfit font if needed */
}

/* Hamburger Layout Refinements */
.mobile-menu-btn {
    order: -1; 
    background: none !important;
    border: none !important;
    color: white !important;
    width: 32px;
    height: 32px;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 20px;
    cursor: pointer;
    padding: 0 !important;
    margin: 0 !important;
}

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

/* Grid Layout for Transaction Forms */
.grid-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 30px;
    align-items: start;
}

@media (max-width: 1150px) {
    .grid-layout {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .scanner-aside {
        order: -1; /* Put scanner/aside at top on mobile/tablet for easier access */
    }

    .form-container {
        padding: 25px !important;
    }
}

@media (max-width: 580px) {
    /* Stack all inline 2-column grids on mobile devices to prevent layout breaking */
    div[style*="grid-template-columns: 1fr 1fr"],
    div[style*="grid-template-columns:1fr 1fr"],
    div[style*="grid-template-columns: repeat(2, 1fr)"],
    div[style*="grid-template-columns:repeat(2, 1fr)"] {
        grid-template-columns: 1fr !important;
    }
    
    .grid-inputs {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(8px);
    z-index: 1050;
    opacity: 0;
    transition: var(--transition-smooth);
    pointer-events: none;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
    pointer-events: all;
}

@media (max-width: 1024px) {
    .mobile-top-nav {
        display: flex !important;
        align-items: center !important;
    }
    
    .container {
        flex-direction: column;
        padding: 15px;
        gap: 20px;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
    
    .mobile-menu-btn {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .sidebar {
        position: fixed !important;
        left: -300px !important;
        top: 0 !important;
        height: 100vh !important;
        width: 280px !important;
        z-index: 1100 !important;
        background: #0f1220 !important;
        transition: left 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
        border-radius: 0 24px 24px 0 !important;
        box-shadow: 20px 0 50px rgba(0,0,0,0.5);
    }
    
    .sidebar.active {
        left: 0 !important;
    }
    
    .content {
        width: 100% !important;
        max-width: 100% !important;
        padding: 20px !important;
        margin-top: 0 !important;
        box-sizing: border-box !important;
        overflow-x: hidden !important;
    }
    
    .content header {
        margin-top: 10px !important;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 15px !important;
    }

    .stat-card {
        padding: 15px !important;
        gap: 12px !important;
        flex-direction: column;
        text-align: center;
    }

    .stat-icon {
        width: 50px !important;
        height: 50px !important;
        font-size: 20px !important;
    }

    .stat-info .value {
        font-size: 20px !important;
    }
}

@media (max-width: 768px) {
    header {
        flex-direction: column !important;
        align-items: flex-start !important;
        margin-bottom: 30px !important;
        gap: 20px !important;
    }
    header h1 {
        font-size: 26px;
    }
    .header-left, .header-right {
        width: 100% !important;
    }
    .stats-grid {
        grid-template-columns: 1fr !important;
    }
    .util-header .percentage {
        font-size: 32px;
    }
    .header-right {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        gap: 12px !important;
        margin-top: 10px !important;
    }
    .quick-actions a, .header-right button, .header-right a {
        flex: 1 1 140px !important;
        min-width: 120px;
        justify-content: center;
        padding: 12px 15px !important;
    }
    .filters-container {
        grid-template-columns: 1fr !important;
    }
    
    .transactions-table-container {
        padding: 15px !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        background: rgba(255,255,255,0.02);
        border-radius: 16px;
    }
    
    .transactions-table-container table {
        min-width: 600px;
    }
    
    .cards-manage-grid, .admin-grid-aggregates, .admin-grid-main, .admin-grid-config {
        grid-template-columns: 1fr !important;
        width: 100% !important;
        justify-items: center;
    }

    .cc-grid {
        display: flex !important;
        flex-direction: row !important;
        overflow-x: auto !important;
        scroll-snap-type: x mandatory !important;
        gap: 20px !important;
        padding: 10px 5px 20px 5px !important;
        width: 100% !important;
        justify-content: flex-start !important;
        -webkit-overflow-scrolling: touch;
        
        scrollbar-width: thin;
        scrollbar-color: rgba(255, 255, 255, 0.2) rgba(255, 255, 255, 0.02);
    }
    .cc-grid::-webkit-scrollbar {
        height: 6px;
    }
    .cc-grid::-webkit-scrollbar-track {
        background: rgba(255, 255, 255, 0.02);
        border-radius: 4px;
    }
    .cc-grid::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.2);
        border-radius: 4px;
    }

    .cc-grid .card-item {
        flex: 0 0 290px !important;
        width: 290px !important;
        max-width: 290px !important;
        scroll-snap-align: start;
        margin: 0 !important;
    }

    .manage-card, .settings-card {
        width: 100% !important;
        max-width: 500px !important;
        margin: 0 auto !important;
    }
}


@media (max-width: 480px) {
    .stat-card {
        padding: 20px;
    }
    .stat-info .value {
        font-size: 22px !important;
    }
    .card-balance .val {
        font-size: 24px;
    }
    .content {
        padding-bottom: 80px !important; /* Space for bottom nav */
        padding-top: 15px !important;
    }
    header:not(.mobile-top-nav) {
        display: none !important;
    }
}

/* Mobile Bottom Tab Bar Styles */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 65px;
    background: rgba(15, 18, 32, 0.85);
    backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-color);
    z-index: 1000;
    justify-content: space-around;
    align-items: center;
    padding: 0 10px;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.mobile-bottom-nav.nav-hidden-bottom {
    transform: translateY(100%);
}

.nav-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 600;
    gap: 4px;
    transition: var(--transition-smooth);
}

.nav-tab i {
    font-size: 20px;
}

.nav-tab.active {
    color: var(--accent-purple);
}

.tab-center-icon {
    width: 45px;
    height: 45px;
    background: var(--accent-purple);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 5px 15px rgba(112, 71, 235, 0.4);
    transform: translateY(-5px);
}

@media (max-width: 1024px) {
    .mobile-bottom-nav {
        display: flex;
    }
    .content {
        padding-bottom: 100px !important;
    }
    .grid-inputs {
        grid-template-columns: 1fr !important;
    }
}

.btn-gen-bill-tiny {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--text-secondary);
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 10px;
    cursor: pointer;
    transition: 0.3s;
}
.btn-gen-bill-tiny:hover {
    background: var(--accent-purple);
    color: white;
}
.owner-pill {
    background: rgba(112, 71, 235, 0.15);
    color: var(--accent-purple);
    border-radius: 12px;
    display: inline-block;
}

/* Nuclear Modal System for Spendly */
.sp-modal {
    display: none;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(11, 13, 23, 0.95) !important;
    backdrop-filter: blur(25px) !important;
    z-index: 99999 !important;
    margin: 0 !important;
    padding: 0 !important;
}

.sp-modal.active {
    display: block !important;
}

.sp-modal-content {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    background: #111422 !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    padding: 40px !important;
    border-radius: 32px !important;
    width: 90% !important;
    max-width: 500px !important;
    max-height: 85vh !important;
    overflow-y: auto !important;
    box-shadow: 0 50px 100px rgba(0, 0, 0, 0.9) !important;
    box-sizing: border-box !important;
}

@media (max-width: 768px) {
    .sp-modal-content {
        padding: 25px !important;
        border-radius: 24px !important;
        max-height: 90vh !important;
    }
}

.sp-modal-close {
    position: absolute !important;
    top: 25px !important;
    right: 25px !important;
    background: rgba(255, 255, 255, 0.05) !important;
    border: none !important;
    color: var(--text-secondary) !important;
    width: 32px !important;
    height: 32px !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    transition: 0.2s !important;
    z-index: 10 !important;
}

.sp-modal-close:hover {
    background: rgba(255, 85, 85, 0.1) !important;
    color: #ff5555 !important;
}


/* Badge System */
.type-badge {
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-block;
    background: rgba(255,255,255,0.05);
}

.card-box {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 25px;
    transition: var(--transition-smooth);
}

.card-box:hover {
    border-color: rgba(112,71,235,0.3);
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(0,0,0,0.3);
}


/* Modern Input Group System */
.input-group-modern {
    margin-bottom: 25px;
}

.input-group-modern label {
    display: block;
    margin-bottom: 10px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.input-group-modern input,
.input-group-modern select {
    width: 100%;
    padding: 16px;
    background-color: #1a1c23;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    color: white;
    font-family: inherit;
    font-size: 15px;
    transition: var(--transition-smooth);
}

.input-group-modern input:focus,
.input-group-modern select:focus {
    outline: none;
    border-color: var(--accent-purple);
    background-color: #252833;
    box-shadow: 0 0 0 4px rgba(112, 71, 235, 0.15);
}

/* Animations */
@keyframes fadeInScale {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.animate-in {
    animation: fadeInScale 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* --- PREMIUM MOBILE SPLASH SCREEN --- */
#spendly-splash {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #0f111a;
    z-index: 999999;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1), transform 0.8s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.8s;
}

#spendly-splash.hidden {
    opacity: 0;
    visibility: hidden;
    transform: scale(1.05);
    pointer-events: none;
}

.splash-logo-container {
    position: relative;
    width: 120px;
    height: 120px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 25px;
}

.splash-logo {
    font-size: 52px;
    color: var(--accent-purple, #7047eb);
    z-index: 2;
    animation: splashPulse 2s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

.splash-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 3px solid rgba(112, 71, 235, 0.1);
    border-top-color: var(--accent-purple, #7047eb);
    animation: splashSpin 1.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite;
}

.splash-ring:nth-child(2) {
    width: 80%;
    height: 80%;
    border: 3px solid rgba(0, 229, 255, 0.1);
    border-bottom-color: var(--accent-blue, #00e5ff);
    animation: splashSpinReverse 2s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite;
}

.splash-text {
    font-family: 'Outfit', sans-serif;
    font-size: 28px;
    font-weight: 800;
    color: white;
    letter-spacing: 4px;
    background: linear-gradient(to right, #ffffff, #9ca3af);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: slideUpFade 0.8s ease-out forwards;
    opacity: 0;
    transform: translateY(20px);
}

@keyframes splashSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes splashSpinReverse {
    0% { transform: rotate(360deg); }
    100% { transform: rotate(0deg); }
}

@keyframes splashPulse {
    0% { transform: scale(1); filter: drop-shadow(0 0 10px rgba(112,71,235,0.4)); }
    50% { transform: scale(1.15); filter: drop-shadow(0 0 30px rgba(112,71,235,0.9)); color: var(--accent-blue); }
    100% { transform: scale(1); filter: drop-shadow(0 0 10px rgba(112,71,235,0.4)); }
}


/* Stat Card Fix */
.stat-card { padding: 20px; border-radius: 20px; display: flex; align-items: center; gap: 15px; transition: transform 0.3s ease; }
.stat-card:hover { transform: translateY(-5px); }
.stat-icon { width: 48px; height: 48px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 20px; color: #fff; flex-shrink: 0; }
.stat-info { display: flex; flex-direction: column; }
.stat-info .label { font-size: 12px; font-weight: 600; text-transform: uppercase; color: var(--text-secondary); margin-bottom: 5px; letter-spacing: 0.5px; }
.stat-info .value { font-size: 24px; font-weight: 800; color: #fff; margin: 0; }

/* Hide modal before JS initialization */
spendly-modal:not([initialized]) { display: none !important; }

/* Fix Custom Element Flex Gaps */
spendly-mobile-top-nav, spendly-mobile-bottom-nav { display: contents; }
