:root {
    --bg-color: #0f172a;
    --card-bg: #1e293b;
    --primary: #0d9488;
    /* Teal */
    --primary-hover: #115e59;
    --expense: #ef4444;
    /* Red */
    --expense-hover: #b91c1c;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: #334155;
    --font-family: 'Outfit', sans-serif;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-main);
    height: 100vh;
    display: flex;
    justify-content: center;
    overflow: hidden;
    /* Prevent scroll on body, handle within containers if needed */
}

.app-container {
    width: 100%;
    max-width: 600px;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 2rem;
    position: relative;
}

header {
    text-align: center;
    margin-bottom: 2rem;
    padding-top: 1rem;
}

header h1 {
    font-weight: 600;
    font-size: 1.75rem;
    background: linear-gradient(to right, #2dd4bf, #a78bfa);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

header p {
    color: var(--text-muted);
    font-size: 0.9rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.balance-container {
    text-align: center;
    margin-bottom: 2rem;
}

.balance-label {
    color: var(--text-muted);
    font-size: 0.9rem;
    display: block;
    margin-bottom: 0.5rem;
}

#balance-amount {
    font-size: 3rem;
    font-weight: 600;
    color: var(--text-main);
    letter-spacing: -1px;
}

.main-actions {
    position: fixed;
    bottom: 2rem;
    left: auto;
    right: 1.5rem;
    width: auto;
    display: flex;
    flex-direction: row;
    /* Horizontal */
    justify-content: flex-end;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0;
    z-index: 40;
    pointer-events: none;
}

.action-btn {
    pointer-events: auto;
    /* Re-enable clicks on buttons */
}

/* History Section */
.history-section {
    width: 100%;
    margin-top: 1rem;
    flex: 1;
    overflow-y: auto;
    padding-bottom: 10rem;
    /* Reduced since buttons are on the side */
}

.history-section h3 {
    font-size: 1.1rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    text-align: center;
}

.transaction-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.transaction-table th,
.transaction-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.transaction-table th {
    color: var(--text-muted);
    font-weight: 500;
}

.transaction-table select {
    background: transparent;
    color: white;
    border: none;
}

.text-income {
    color: var(--primary);
}

.text-expense {
    color: var(--expense);
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-top: 1.5rem;
    padding-bottom: 1rem;
}

.page-btn {
    background: var(--card-bg);
    border: 1px solid var(--border);
    color: var(--text-main);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-delete-row {
    background: none;
    border: none;
    color: var(--expense);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.btn-delete-row:hover {
    background-color: rgba(239, 68, 68, 0.1);
}

.action-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    /* Softer shadow but visible */
    pointer-events: auto;
}

.action-btn svg {
    width: 28px;
    height: 28px;
}

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

.income {
    background: linear-gradient(135deg, #0d9488, #2dd4bf);
    color: white;
    box-shadow: 0 0 20px rgba(13, 148, 136, 0.4);
}

.expense {
    background: linear-gradient(135deg, #b91c1c, #ef4444);
    color: white;
    box-shadow: 0 0 20px rgba(185, 28, 28, 0.4);
}

.action-btn.delete {
    background-color: #3b82f6;
    /* Blue */
    color: white;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    /* Darker overlay */
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    /* Align to top */
    padding-top: 5rem;
    /* Space from top */
    z-index: 100;
    opacity: 1;
    transition: opacity 0.3s ease;
}

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

.modal {
    background-color: var(--card-bg);
    width: 90%;
    max-width: 340px;
    border-radius: 24px;
    padding: 1.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border);
    transform: translateY(0);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.hidden .modal {
    transform: translateY(-20px);
    /* Slide up when hiding */
}

.modal-header h2 {
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
    text-align: center;
    color: var(--text-main);
}

.input-group {
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.input-group label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.input-group input {
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    font-size: 1.5rem;
    /* Large text for numbers */
    color: var(--text-main);
    text-align: center;
    width: 100%;
    outline: none;
    transition: border-color 0.2s;
    font-family: var(--font-family);
}

.input-group input:focus {
    border-color: var(--primary);
}

#input-egreso-concepto {
    font-size: 1rem;
    text-align: left;
}

/* Compact inputs for Credit Modal */
#modal-credito .input-group input,
#modal-credito .input-group select {
    padding: 0.75rem;
    font-size: 1.1rem;
    border-radius: 10px;
}

#modal-credito .input-group {
    margin-bottom: 1rem;
}

.modal-footer {
    display: flex;
    gap: 1rem;
    justify-content: space-between;
}

button.btn-primary,
button.btn-secondary {
    flex: 1;
    padding: 0.75rem;
    border-radius: 12px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font-family);
    font-size: 0.95rem;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}

.btn-secondary {
    background-color: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

/* Install Prompt */
.install-prompt {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--card-bg);
    border: 1px solid var(--border);
    padding: 1rem;
    border-radius: 16px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    z-index: 50;
    transition: all 0.3s ease;
}

.install-prompt.hidden {
    transform: translate(-50%, 100%);
    opacity: 0;
    pointer-events: none;
}

.install-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.install-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
}

.install-text {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.install-text strong {
    font-size: 0.9rem;
}

.install-text span {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.install-btn {
    background-color: var(--text-main);
    color: var(--bg-color);
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
}

.close-install-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0 0.25rem;
}

/* Header Update */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
    padding-top: 1rem;
    position: relative;
}

.header-title {
    flex: 1;
    text-align: center;
    /* Center title but account for button space if needed */
    margin-right: 40px;
    /* Balance the left button */
}

/* Icon Buttons */
.icon-btn {
    background: none;
    border: none;
    color: var(--text-main);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: background 0.2s;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Sidebar Menu */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    z-index: 100;
    opacity: 1;
    transition: opacity 0.3s ease;
}

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

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100%;
    background: var(--card-bg);
    z-index: 101;
    transform: translateX(0);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
}

.sidebar.hidden {
    transform: translateX(-100%);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

/* Business Links */
.business-link {
    display: block;
    /* Full width */
    padding: 1rem;
    margin-bottom: 0.5rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-muted);
    text-decoration: none;
    transition: all 0.2s;
    font-weight: 500;
}

.business-link:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    transform: translateX(4px);
}

.business-link.active {
    background: var(--primary);
    /* Highlight active business */
    color: white;
    box-shadow: 0 4px 12px rgba(13, 148, 136, 0.3);
}

/* App Navigation Tabs */
.app-tabs {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 600px;
    background: var(--card-bg);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    padding: 0.75rem 1rem;
    z-index: 50;
    backdrop-filter: blur(10px);
}

.tab-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 500;
    transition: all 0.2s;
    flex: 1;
}

.tab-link svg {
    width: 24px;
    height: 24px;
}

.tab-link.active {
    color: var(--primary);
}

.tab-link:hover {
    color: var(--text-main);
}

/* App Views */
.app-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    animation: fadeIn 0.3s ease;
}

.app-view.hidden {
    display: none !important;
}

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

/* General Balance Grid */
.general-balance-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-top: 1rem;
    padding-bottom: 5rem;
}

#view-general .general-balance-grid {
    grid-template-columns: repeat(2, 1fr);
}

.balance-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    transition: transform 0.2s;
}

.balance-card:hover {
    transform: translateY(-2px);
    border-color: var(--primary);
}

.balance-card .btn-delete-asset {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border: none;
    color: var(--expense);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    z-index: 10;
}

.balance-card .btn-delete-asset:active {
    transform: scale(0.9);
}

.balance-card .btn-delete-asset svg {
    width: 18px;
    height: 18px;
}

.balance-card.total {
    background: linear-gradient(135deg, rgba(13, 148, 136, 0.1), rgba(167, 139, 250, 0.1));
    border-color: var(--primary);
    grid-column: span 2;
}

.card-label {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
}

.card-amount {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text-main);
}

.balance-card.total .card-amount {
    background: linear-gradient(to right, #2dd4bf, #a78bfa);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* New Virtual Credit Card Styling */
.credit-card-new {
    width: 100%;
    max-width: 380px;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border-radius: 28px;
    padding: 1.25rem;
    color: white;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    margin: 1.5rem auto;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.credit-card-new::before {
    content: '';
    position: absolute;
    top: -20%;
    right: -10%;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(37, 99, 235, 0.1) 0%, transparent 70%);
    z-index: 0;
}

.card-top {
    display: flex;
    justify-content: flex-end;
    align-items: flex-start;
    margin-bottom: 2rem;
    position: relative;
    z-index: 1;
}

.card-logo-circle {
    width: 42px;
    height: 42px;
    background-color: white;
    border-radius: 12px; /* Slightly rounded instead of full circle for modern look */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.card-type-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: #94a3b8;
    font-weight: 600;
}

.card-number-large {
    font-size: 1.3rem;
    font-weight: 500;
    letter-spacing: 2px;
    margin-bottom: 2rem;
    font-family: 'Courier New', Courier, monospace;
    position: relative;
    z-index: 1;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
    white-space: nowrap;
    text-align: center;
}

.card-details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    position: relative;
    z-index: 1;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.detail-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    color: #64748b;
    letter-spacing: 1px;
    font-weight: 600;
}

.detail-value {
    font-size: 1rem;
    font-weight: 600;
    color: #f8fafc;
}

.text-green {
    color: #10b981;
    text-shadow: 0 0 10px rgba(16, 185, 129, 0.2);
}

/* FAB positioning fix */
.main-actions-credit {
    position: fixed;
    bottom: 5.5rem; /* Above tabs */
    right: 1.5rem;
    z-index: 100;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: center;
}

.main-actions-credit .action-btn {
    width: 48px;
    height: 48px;
    pointer-events: auto;
}

.main-actions-credit .action-btn svg {
    width: 24px;
    height: 24px;
}