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

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --success: #16a34a;
    --success-light: #dcfce7;
    --warning: #d97706;
    --warning-light: #fef3c7;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --sidebar-width: 240px;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    display: flex;
    min-height: 100vh;
}

/* ========== SETUP SCREEN ========== */
.setup-overlay {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, #1e3a5f 0%, #111827 100%);
    z-index: 5000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.setup-overlay.hidden {
    display: none;
}

.setup-card {
    background: #fff;
    border-radius: 16px;
    padding: 32px;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.setup-card h1 {
    font-size: 28px;
    color: var(--primary);
    text-align: center;
}

.setup-subtitle {
    text-align: center;
    color: var(--gray-500);
    margin-bottom: 24px;
}

.setup-step {
    display: none;
}

.setup-step.active {
    display: block;
}

.setup-step h3 {
    font-size: 18px;
    margin-bottom: 8px;
}

.setup-step p {
    color: var(--gray-600);
    font-size: 14px;
    margin-bottom: 16px;
    line-height: 1.5;
}

.setup-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
}

.setup-error {
    color: var(--danger);
    font-size: 13px;
    margin-top: 12px;
    min-height: 20px;
}

.setup-hint {
    background: var(--primary-light);
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    color: var(--primary-dark);
    margin-top: 8px;
}

.setup-instructions {
    font-size: 13px;
    color: var(--gray-600);
    line-height: 1.7;
    padding-left: 20px;
    margin-bottom: 16px;
}

.setup-instructions li {
    margin-bottom: 6px;
}

/* ========== SIDEBAR ========== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--gray-900);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform 0.3s;
}

.sidebar-header {
    padding: 24px 20px 16px;
    border-bottom: 1px solid var(--gray-700);
}

.sidebar-header h1 {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.subtitle {
    font-size: 12px;
    color: var(--gray-400);
    margin-top: 2px;
}

.sync-status {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    font-size: 12px;
}

.sync-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.sync-dot.online { background: var(--success); }
.sync-dot.offline { background: var(--gray-500); }
.sync-dot.syncing { background: var(--warning); animation: pulse 1s infinite; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.sync-text {
    color: var(--gray-400);
}

.nav-menu {
    list-style: none;
    padding: 12px 0;
    flex: 1;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    cursor: pointer;
    font-size: 14px;
    color: var(--gray-300);
    transition: background 0.2s, color 0.2s;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: var(--gray-800);
    color: #fff;
}

.nav-item.active {
    background: var(--gray-800);
    color: #fff;
    border-left-color: var(--primary);
}

.nav-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--gray-700);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.menu-toggle {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 200;
    background: var(--gray-900);
    color: #fff;
    border: none;
    padding: 8px 12px;
    border-radius: var(--radius);
    font-size: 20px;
    cursor: pointer;
}

/* ========== FAB (Floating Action Button) ========== */
.fab {
    display: none;
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    border: none;
    font-size: 28px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(37,99,235,0.4);
    z-index: 90;
    transition: transform 0.2s;
}

.fab:active {
    transform: scale(0.95);
}

/* ========== CONTENT ========== */
.content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 24px 32px;
    max-width: 1200px;
}

.view {
    display: none;
}

.view.active {
    display: block;
}

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

.view-header h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-900);
}

.view-description {
    color: var(--gray-500);
    margin-bottom: 24px;
    font-size: 14px;
}

/* ========== BUTTONS ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s;
    text-decoration: none;
    gap: 6px;
    white-space: nowrap;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-outline {
    background: transparent;
    border-color: var(--gray-500);
    color: var(--gray-300);
}

.btn-outline:hover {
    background: var(--gray-800);
}

.btn-outline-dark {
    background: transparent;
    border-color: var(--gray-300);
    color: var(--gray-600);
}

.btn-outline-dark:hover {
    background: var(--gray-100);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    background: #b91c1c;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 13px;
}

.btn-lg {
    padding: 12px 20px;
    font-size: 16px;
}

.btn-icon {
    padding: 6px 8px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    color: var(--gray-500);
    border-radius: 4px;
}

.btn-icon:hover {
    background: var(--gray-100);
    color: var(--gray-800);
}

.full-width {
    width: 100%;
}

/* ========== INPUTS ========== */
.input {
    padding: 10px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 14px;
    color: var(--gray-800);
    background: #fff;
    transition: border-color 0.2s;
    width: 100%;
}

.input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.input-lg {
    padding: 12px 16px;
    font-size: 16px;
}

select.input {
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236b7280' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

/* ========== STATS ========== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.stat-label {
    font-size: 13px;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--gray-900);
}

.stat-value.positive { color: var(--success); }
.stat-value.negative { color: var(--danger); }

/* ========== CHARTS ========== */
.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.chart-card {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.chart-card h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--gray-700);
}

.chart-card.full-width {
    margin-bottom: 16px;
}

.top-items-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* ========== TABLE ========== */
.filters-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.filters-bar .input {
    flex: 1;
    min-width: 150px;
}

.table-container {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    overflow-x: auto;
    box-shadow: var(--shadow);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table th {
    background: var(--gray-50);
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    color: var(--gray-600);
    border-bottom: 2px solid var(--gray-200);
    white-space: nowrap;
}

.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--gray-100);
    vertical-align: middle;
}

.data-table tr:hover {
    background: var(--gray-50);
}

.data-table .actions {
    display: flex;
    gap: 4px;
}

.table-footer {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    font-size: 14px;
    color: var(--gray-500);
}

.table-footer span:last-child {
    font-weight: 600;
    color: var(--gray-800);
}

.tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.tag-carnes { background: #fecaca; color: #991b1b; }
.tag-huevos { background: #fed7aa; color: #9a3412; }
.tag-lacteos { background: #bfdbfe; color: #1e40af; }
.tag-despensa { background: #d9f99d; color: #3f6212; }
.tag-aseo { background: #e9d5ff; color: #6b21a8; }
.tag-frutas { background: #bbf7d0; color: #166534; }
.tag-verduras { background: #a7f3d0; color: #065f46; }
.tag-bebidas { background: #fde68a; color: #92400e; }
.tag-otro { background: var(--gray-200); color: var(--gray-700); }

/* ========== MOBILE CARDS (replaces table on mobile) ========== */
.cards-container {
    display: none;
}

.item-card {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 10px;
    box-shadow: var(--shadow);
}

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

.item-card-header h4 {
    font-size: 15px;
    font-weight: 600;
}

.item-card-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    font-size: 13px;
    color: var(--gray-600);
}

.item-card-body .label {
    color: var(--gray-400);
}

.item-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--gray-100);
}

.item-card-price {
    font-size: 18px;
    font-weight: 700;
    color: var(--gray-900);
}

/* ========== ADD FLOW (Steps) ========== */
.add-step {
    display: none;
}

.add-step.active {
    display: block;
}

.btn-back {
    background: none;
    border: 1px solid var(--gray-300);
    color: var(--gray-600);
    font-size: 14px;
    padding: 6px 12px;
}

.btn-back:hover {
    background: var(--gray-100);
}

/* Category Grid */
.cat-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.cat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px 12px;
    background: var(--cat-bg, #f9fafb);
    border: 2px solid transparent;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
    font-weight: 600;
    color: var(--cat-color, var(--gray-700));
    -webkit-tap-highlight-color: transparent;
}

.cat-card:hover, .cat-card:active {
    border-color: var(--cat-color, var(--gray-300));
    transform: scale(0.97);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.cat-emoji {
    font-size: 36px;
    line-height: 1;
}

.cat-card-new {
    border: 2px dashed var(--gray-300);
    background: var(--gray-50);
}

/* Product List */
.prod-search {
    margin-bottom: 12px;
}

.prod-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 55vh;
    overflow-y: auto;
}

.prod-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.prod-item:hover, .prod-item:active {
    background: var(--primary-light);
    border-color: var(--primary);
}

.prod-item-name {
    font-size: 15px;
    font-weight: 500;
    color: var(--gray-800);
}

.prod-item-info {
    font-size: 12px;
    color: var(--gray-400);
    margin-top: 2px;
}

.prod-item-arrow {
    color: var(--gray-300);
    font-size: 18px;
    flex-shrink: 0;
}

/* Selected Product Banner */
.selected-product-banner {
    background: var(--primary-light);
    color: var(--primary-dark);
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 16px;
    display: none;
}

.selected-product-banner.visible {
    display: block;
}

/* ========== FORM CARD ========== */
.form-card {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    max-width: 600px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 14px;
}

.form-group label {
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-600);
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

/* ========== MONTH SELECTOR ========== */
.month-selector {
    display: flex;
    align-items: center;
    gap: 12px;
}

.month-selector span {
    font-weight: 600;
    min-width: 140px;
    text-align: center;
}

/* ========== COMPARADOR ========== */
.comparador-controls {
    max-width: 400px;
    margin-bottom: 24px;
}

.comparador-results {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.store-card {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}

.store-card.best {
    border-color: var(--success);
    background: var(--success-light);
}

.store-card h4 { font-size: 16px; margin-bottom: 8px; }
.store-card .price { font-size: 28px; font-weight: 700; }

.store-card .best-label {
    display: inline-block;
    background: var(--success);
    color: #fff;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    margin-left: 8px;
}

.store-card .details {
    margin-top: 8px;
    font-size: 13px;
    color: var(--gray-500);
}

/* ========== HISTORIAL ========== */
.historial-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin-top: 24px;
}

.month-card {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.month-card h4 { font-size: 16px; margin-bottom: 12px; color: var(--gray-700); }
.month-card .total { font-size: 28px; font-weight: 700; margin-bottom: 16px; }

.month-card .breakdown { list-style: none; }

.month-card .breakdown li {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 13px;
    color: var(--gray-600);
    border-bottom: 1px solid var(--gray-100);
}

.month-card .breakdown li:last-child { border-bottom: none; }

.month-diff { font-size: 14px; font-weight: 600; margin-top: 8px; }

/* ========== TIPS ========== */
.tips-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 16px;
}

.tip-card {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--primary);
}

.tip-card.tip-saving { border-left-color: var(--success); }
.tip-card.tip-warning { border-left-color: var(--warning); }
.tip-card.tip-info { border-left-color: var(--primary); }

.tip-card h4 { font-size: 15px; margin-bottom: 8px; color: var(--gray-800); }
.tip-card p { font-size: 14px; color: var(--gray-600); line-height: 1.5; }

.tip-card .tip-impact {
    margin-top: 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--success);
}

/* ========== TOP ITEMS ========== */
.top-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--gray-100);
    font-size: 14px;
}

.top-item:last-child { border-bottom: none; }
.top-item .rank { width: 24px; font-weight: 700; color: var(--gray-400); }
.top-item .name { flex: 1; margin-left: 8px; }
.top-item .value { font-weight: 600; }

/* ========== MODAL ========== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active { display: flex; }

.modal {
    background: #fff;
    border-radius: 12px;
    width: 90%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.modal-sm { max-width: 380px; }

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-200);
}

.modal-header h3 { font-size: 18px; }

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--gray-400);
    padding: 4px;
}

.modal-close:hover { color: var(--gray-800); }
.modal-body { padding: 24px; }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 20px;
}

/* ========== MOBILE HEADER ========== */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 52px;
    background: var(--gray-900);
    color: #fff;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 150;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.mobile-header h1 {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.sync-status-mobile {
    display: flex;
    align-items: center;
    gap: 6px;
}

.install-btn {
    background: #fbbf24;
    color: #92400e;
    border: none;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.install-banner {
    position: fixed;
    top: 52px;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #1e40af, #2563eb);
    color: #fff;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 140;
    font-size: 13px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.install-banner span:first-child {
    flex: 1;
}

.install-banner .btn {
    background: #fff;
    color: var(--primary);
    font-weight: 600;
}

.install-banner-close {
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    font-size: 20px;
    cursor: pointer;
    padding: 0 4px;
}

/* ========== BOTTOM NAV ========== */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: #fff;
    border-top: 1px solid var(--gray-200);
    z-index: 150;
    justify-content: space-around;
    align-items: center;
    padding: 0 4px;
    padding-bottom: env(safe-area-inset-bottom, 0);
    box-shadow: 0 -2px 10px rgba(0,0,0,0.06);
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--gray-400);
    font-size: 10px;
    font-weight: 500;
    padding: 6px 8px;
    border-radius: 8px;
    transition: color 0.2s;
    min-width: 56px;
    -webkit-tap-highlight-color: transparent;
}

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

.bottom-nav-item svg {
    width: 22px;
    height: 22px;
}

.bottom-nav-item.fab-nav {
    position: relative;
    color: var(--gray-400);
}

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

.fab-circle {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    font-weight: 300;
    margin-top: -20px;
    box-shadow: 0 4px 12px rgba(37,99,235,0.35);
    transition: transform 0.15s;
}

.bottom-nav-item.fab-nav:active .fab-circle {
    transform: scale(0.92);
}

/* ========== TOAST ========== */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--gray-900);
    color: #fff;
    padding: 12px 24px;
    border-radius: 24px;
    font-size: 14px;
    box-shadow: var(--shadow-md);
    z-index: 2000;
    opacity: 0;
    transition: all 0.3s;
    white-space: nowrap;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.no-data {
    text-align: center;
    padding: 40px;
    color: var(--gray-400);
    font-size: 14px;
}

/* ========== RESPONSIVE - MOBILE ========== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .menu-toggle {
        display: none;
    }

    .mobile-header {
        display: flex;
    }

    .bottom-nav {
        display: flex;
    }

    .fab {
        display: none;
    }

    .content {
        margin-left: 0;
        padding: 12px 14px;
        padding-top: 60px;
        padding-bottom: 76px;
    }

    .view-header {
        margin-bottom: 16px;
    }

    .view-header h2 {
        font-size: 20px;
    }

    .charts-grid,
    .top-items-section {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .stat-card {
        padding: 14px;
    }

    .stat-label {
        font-size: 11px;
    }

    .stat-value {
        font-size: 18px;
    }

    .chart-card {
        padding: 14px;
    }

    .chart-card h3 {
        font-size: 14px;
        margin-bottom: 10px;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .filters-bar {
        flex-direction: column;
        gap: 8px;
    }

    .filters-bar .input {
        min-width: unset;
    }

    .table-container {
        display: none;
    }

    .cards-container {
        display: block;
    }

    .view-header .btn-primary {
        display: none;
    }

    .form-card {
        padding: 16px;
        border: none;
        box-shadow: none;
        max-width: 100%;
    }

    .form-actions {
        flex-direction: column;
    }

    .input {
        padding: 12px;
        font-size: 16px;
    }

    .comparador-controls {
        max-width: 100%;
    }

    .comparador-results {
        grid-template-columns: 1fr;
    }

    .tips-grid {
        grid-template-columns: 1fr;
    }

    .historial-grid {
        grid-template-columns: 1fr;
    }

    .month-selector {
        gap: 8px;
    }

    .month-selector span {
        font-size: 14px;
        min-width: 120px;
    }

    .view-description {
        font-size: 13px;
        margin-bottom: 16px;
    }

    .item-card {
        border-radius: 12px;
    }

    .store-card .price {
        font-size: 24px;
    }

    .month-card .total {
        font-size: 24px;
    }
}

@media (min-width: 769px) {
    .cards-container {
        display: none !important;
    }

    .mobile-header {
        display: none !important;
    }

    .bottom-nav {
        display: none !important;
    }
}

/* ========== BUDGET / PRESUPUESTO ========== */
.budget-summary {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.budget-total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 14px;
    color: var(--gray-600);
}

.budget-total-amount {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-900);
}

.progress-bar-container {
    background: var(--gray-100);
    border-radius: 8px;
    height: 12px;
    overflow: hidden;
    position: relative;
}

.progress-bar-fill {
    height: 100%;
    border-radius: 8px;
    transition: width 0.4s ease, background 0.3s;
    min-width: 2px;
}

.progress-green { background: var(--success); }
.progress-yellow { background: var(--warning); }
.progress-red { background: var(--danger); }

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

.budget-card {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}

.budget-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.budget-card-header h4 {
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.budget-card-amounts {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--gray-500);
    margin-bottom: 6px;
}

.budget-card-amounts .spent {
    font-weight: 600;
    color: var(--gray-800);
}

.budget-card-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.budget-edit-row {
    display: none;
    gap: 8px;
    margin-top: 10px;
    align-items: flex-end;
}

.budget-edit-row.active {
    display: flex;
    flex-wrap: wrap;
}

.budget-edit-row .form-group {
    flex: 1;
    min-width: 100px;
    margin-bottom: 0;
}

.budget-edit-row .form-group label {
    font-size: 11px;
}

.budget-edit-row .input {
    padding: 8px;
    font-size: 14px;
}

.budget-pct {
    font-size: 13px;
    font-weight: 700;
    min-width: 45px;
    text-align: right;
}

.budget-alert-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    background: var(--danger-light);
    color: var(--danger);
}

.section-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 12px;
}

@media (max-width: 768px) {
    .budget-total-amount {
        font-size: 20px;
    }
    .budget-card {
        padding: 14px;
    }
    .budget-edit-row .form-group {
        min-width: 80px;
    }
}

/* ========== TAGS NUEVAS CATEGORIAS ========== */
.tag-transporte { background: #e0f2fe; color: #0369a1; }
.tag-farmacia   { background: #fce7f3; color: #9d174d; }

/* ========== FOTO ADJUNTA (FORMULARIO) ========== */
.foto-area {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.foto-upload-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border: 2px dashed var(--gray-300);
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    color: var(--gray-600);
    transition: border-color 0.15s, background 0.15s;
    user-select: none;
}

.foto-upload-label:hover,
.foto-upload-label:active {
    border-color: var(--primary);
    background: #eff6ff;
    color: var(--primary);
}

.foto-upload-label.hidden { display: none; }

.foto-preview-wrap {
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--gray-200);
}

.foto-preview-wrap img {
    width: 100%;
    max-height: 220px;
    object-fit: cover;
    display: block;
}

.foto-preview-wrap.hidden { display: none; }

.foto-preview-actions {
    display: flex;
    gap: 8px;
    padding: 8px;
    background: rgba(0,0,0,0.04);
}

.btn-danger-outline {
    background: none;
    border: 1px solid var(--danger);
    color: var(--danger);
    border-radius: 6px;
    padding: 5px 10px;
    font-size: 13px;
    cursor: pointer;
}

/* ========== CARD FOTO BUTTON ========== */
.card-btn-foto {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    background: #eff6ff;
    color: var(--primary);
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    font-size: 12px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

/* ========== FOTO LIGHTBOX ========== */
.foto-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.92);
    z-index: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.foto-lightbox.hidden { display: none; }

.foto-lb-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    font-size: 28px;
    line-height: 1;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.foto-lb-spinner {
    width: 44px;
    height: 44px;
    border: 4px solid rgba(255,255,255,0.2);
    border-top-color: #fff;
    border-radius: 50%;
    animation: ocr-spin 0.9s linear infinite;
}

.foto-lb-img {
    max-width: 100%;
    max-height: 90vh;
    border-radius: 8px;
    object-fit: contain;
}

.foto-lb-img.hidden { display: none; }

/* ========== BOLETA UPLOAD ========== */
.boleta-section {
    margin-bottom: 20px;
}

.boleta-desc {
    font-size: 13px;
    color: var(--gray-500);
    text-align: center;
    margin-bottom: 12px;
    line-height: 1.4;
}

.boleta-btns-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.boleta-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    border-radius: 14px;
    padding: 18px 12px;
    cursor: pointer;
    text-align: center;
    user-select: none;
    transition: opacity 0.15s, transform 0.1s;
    -webkit-tap-highlight-color: transparent;
    color: #fff;
    font-weight: 600;
}

.boleta-btn:active {
    opacity: 0.88;
    transform: scale(0.97);
}

.boleta-btn-cam {
    background: linear-gradient(135deg, #1e40af, #3b82f6);
}

.boleta-btn-gal {
    background: linear-gradient(135deg, #0f766e, #14b8a6);
}

.boleta-icon {
    font-size: 30px;
    line-height: 1;
}

.boleta-btn span:not(.boleta-icon) {
    font-size: 14px;
    font-weight: 700;
}

.boleta-btn small {
    font-size: 11px;
    opacity: 0.85;
    font-weight: 400;
}

.boleta-divider {
    text-align: center;
    margin: 18px 0 8px;
    color: var(--gray-400);
    font-size: 13px;
    position: relative;
}

.boleta-divider::before,
.boleta-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 38%;
    height: 1px;
    background: var(--gray-200);
}

.boleta-divider::before { left: 0; }
.boleta-divider::after { right: 0; }

/* ========== OCR OVERLAY ========== */
.ocr-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 500;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    overflow-y: auto;
}

.ocr-overlay.hidden {
    display: none;
}

.ocr-modal {
    background: #fff;
    width: 100%;
    max-width: 640px;
    min-height: 100dvh;
    padding: 20px 16px 100px;
}

@media (min-width: 640px) {
    .ocr-modal {
        min-height: auto;
        margin: 32px auto;
        border-radius: 14px;
        padding: 24px;
        max-height: 88vh;
        overflow-y: auto;
    }
}

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

.ocr-header h2 {
    font-size: 20px;
    font-weight: 700;
}

.ocr-close {
    background: none;
    border: none;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    color: var(--gray-500);
    padding: 0 4px;
}

.ocr-loading {
    text-align: center;
    padding: 60px 20px;
}

.ocr-spinner {
    width: 52px;
    height: 52px;
    border: 5px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: ocr-spin 0.9s linear infinite;
    margin: 0 auto 20px;
}

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

.ocr-hint {
    color: var(--gray-400);
    font-size: 12px;
    margin-top: 8px;
}

.ocr-meta {
    margin-bottom: 16px;
}

.ocr-count {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13px;
    color: var(--gray-600);
    margin-bottom: 16px;
}

.ocr-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ocr-item {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 10px;
    padding: 12px;
    transition: opacity 0.2s;
}

.ocr-item.ocr-item-disabled {
    opacity: 0.35;
}

.ocr-item-check {
    padding-top: 6px;
    flex-shrink: 0;
}

.ocr-item-check input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--primary);
}

.ocr-item-fields {
    flex: 1;
    min-width: 0;
}

.ocr-item-fields .form-group {
    margin-bottom: 6px;
}

.ocr-item-fields label {
    font-size: 11px;
    color: var(--gray-500);
    margin-bottom: 2px;
}

.ocr-item-fields .input {
    padding: 6px 8px;
    font-size: 13px;
}

.ocr-raw-details {
    margin-top: 12px;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    overflow: hidden;
}

.ocr-raw-details summary {
    padding: 10px 14px;
    cursor: pointer;
    font-size: 13px;
    color: var(--primary);
    background: var(--gray-50);
    user-select: none;
}

.ocr-raw-text {
    padding: 12px 14px;
    font-size: 11px;
    font-family: monospace;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 300px;
    overflow-y: auto;
    background: #fff;
    color: var(--gray-700);
    margin: 0;
}

.ocr-boleta-sep {
    font-size: 12px;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 6px 0 2px;
    border-top: 1px solid var(--gray-200);
    margin-top: 4px;
}

.ocr-total-field {
    background: var(--gray-100) !important;
    color: var(--gray-600);
}

.ocr-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 14px 16px;
    background: #fff;
    border-top: 1px solid var(--gray-200);
    display: flex;
    gap: 10px;
    z-index: 10;
}

.ocr-footer .btn {
    flex: 1;
}

@media (min-width: 640px) {
    .ocr-footer {
        position: sticky;
        bottom: 0;
        margin: 20px -24px -24px;
        padding: 16px 24px;
        border-radius: 0 0 14px 14px;
    }
}

/* ========== CARD ACTIONS (mobile compras) ========== */
.card-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.card-btn-edit {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.card-btn-delete {
    padding: 6px 10px;
    background: none;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    color: var(--danger);
    -webkit-tap-highlight-color: transparent;
}

/* ========== SCROLLBAR ========== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--gray-100); }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }

/* ========== SAFE AREAS (notch phones) ========== */
@supports (padding: env(safe-area-inset-bottom)) {
    .bottom-nav {
        padding-bottom: env(safe-area-inset-bottom);
    }
    .mobile-header {
        padding-top: env(safe-area-inset-top);
    }
}
