/* Add viewport height CSS custom property support */
:root {
    --vh: 1vh;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

/* === AUTHENTICATION STYLES === */

.auth-container {
    max-width: 400px;
    margin: 50px auto;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.auth-logo {
    text-align: center;
    margin-bottom: 30px;
}

.logo-image {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    transition: transform 0.3s ease;
}

.logo-image:hover {
    transform: scale(1.05);
}

.auth-container h2 {
    color: #2c3e50;
    margin-bottom: 30px;
    font-size: 2rem;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.auth-form .form-group {
    text-align: left;
}

.auth-form .form-group label {
    display: block;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.auth-form .form-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.auth-form .form-group input:focus {
    outline: none;
    border-color: #4facfe;
    box-shadow: 0 0 0 3px rgba(79, 172, 254, 0.1);
}

.auth-btn {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    border: none;
    padding: 15px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.auth-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(79, 172, 254, 0.3);
}

.auth-btn:disabled {
    background: #95a5a6;
    cursor: not-allowed;
    transform: none;
}

.auth-btn.secondary {
    background: #95a5a6;
    margin-top: 10px;
}

.auth-btn.secondary:hover {
    background: #7f8c8d;
}

.auth-btn.google {
    background: #db4437;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.auth-btn.google:hover {
    background: #c23321;
    box-shadow: 0 8px 25px rgba(219, 68, 55, 0.3);
}

.auth-toggle {
    margin-top: 20px;
    color: #666;
}

.auth-toggle a {
    color: #4facfe;
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
}

.auth-toggle a:hover {
    text-decoration: underline;
}

.loading {
    display: none;
    text-align: center;
    padding: 20px;
    color: #666;
}

.error {
    background: #f8d7da;
    color: #721c24;
    padding: 10px;
    border-radius: 4px;
    margin: 10px 0;
    border: 1px solid #f5c6cb;
}

.success {
    background: #d4edda;
    color: #155724;
    border-radius: 4px;
    border: 1px solid #c3e6cb;
}

.hidden {
    display: none;
}

/* === MAIN APPLICATION STYLES === */

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.header {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    padding: 30px;
    text-align: center;
    position: relative;
}

.header-content {
    position: relative;
    z-index: 10;
}

.header-logo {
    height: 120px;
    width: auto;
    margin-bottom: 0px;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 10px;
}

.header p {
    font-size: 1.1rem;
    opacity: 0.9;
    font-weight: 500;
    margin-top: 10px;
}

.default-indicator {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    padding: 6px 12px;
    border-radius: 15px;
    font-size: 0.85rem;
    font-weight: 600;
    display: inline-block;
    border: 1px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(5px);
}

.default-indicator::before {
    content: "⭐ ";
    margin-right: 4px;
}

/* === SYNC INDICATOR === */

.sync-indicator {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    z-index: 20;
}

.sync-indicator.synced {
    background: #27ae60;
    box-shadow: 0 0 0 2px rgba(39, 174, 96, 0.3);
}

.sync-indicator.syncing {
    background: #f39c12;
    box-shadow: 0 0 0 2px rgba(243, 156, 18, 0.3);
    animation: pulse 1.5s infinite;
}

.sync-indicator.offline {
    background: #e74c3c;
    box-shadow: 0 0 0 2px rgba(231, 76, 60, 0.3);
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.1); }
}

/* === HAMBURGER MENU - FIXED VERSION === */

.menu-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px;
    border-radius: 8px;
    transition: all 0.3s ease;
    z-index: 30;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.menu-toggle span {
    width: 25px;
    height: 3px;
    background: white;
    transition: all 0.3s ease;
    border-radius: 2px;
}

.menu-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
}

.menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
}

.menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

.menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    height: 100vh;
    height: calc(var(--vh, 1vh) * 100);
    background: rgba(0, 0, 0, 0.5);
    z-index: 15;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.menu-overlay.active {
    opacity: 1;
    visibility: visible;
}

.header-controls {
    position: fixed;
    top: 0;
    right: -300px;
    width: 280px;
    height: 100vh;
    height: calc(var(--vh, 1vh) * 100);
    max-height: 100vh;
    max-height: calc(var(--vh, 1vh) * 100);
    background: white;
    z-index: 20;
    transition: right 0.3s ease;
    box-shadow: -5px 0 15px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.header-controls.menu-open {
    right: 0;
}

/* Header area with close button space */
.header-controls::before {
    content: '';
    flex-shrink: 0;
    height: 70px;
    background: transparent;
}

/* Scrollable content area */
.header-controls-content {
    flex: 1;
    overflow-y: auto;
    padding: 10px 20px 20px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* If the content wrapper doesn't exist, apply scrolling to direct children */
.header-controls:not(:has(.header-controls-content)) {
    padding: 70px 20px 20px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.nav-section {
    margin-bottom: 25px;
    flex-shrink: 0;
}

.nav-label {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #7f8c8d;
    margin-bottom: 10px;
    padding-left: 10px;
}

.header-btn {
    width: 100%;
    background: #f8f9fa;
    color: #495057;
    border: 2px solid #dee2e6;
    padding: 15px 20px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    margin-bottom: 8px;
    text-align: left;
    font-size: 0.95rem;
    flex-shrink: 0;
}

.header-btn:hover {
    background: #e9ecef;
    border-color: #4facfe;
    transform: translateX(5px);
}

.header-btn.active {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    border-color: transparent;
}

.header-btn.sign-out-menu {
    background: #fee;
    color: #e74c3c;
    border-color: #f8d7da;
}

.header-btn.sign-out-menu:hover {
    background: #f8d7da;
    border-color: #e74c3c;
}

.current-account {
    padding: 8px 15px;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.7);
    text-align: center;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin-top: 10px;
    background: #495057;
    border-radius: 8px;
    flex-shrink: 0;
}

.current-account::before {
    content: "👤 ";
    margin-right: 4px;
}

/* === LINK STATUS INDICATOR === */

.link-status-indicator {
    position: absolute;
    top: 20px;
    right: 70px;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.3s ease;
    z-index: 25;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.link-status-indicator.linked {
    background: linear-gradient(135deg, #27ae60, #2ecc71);
    color: white;
}

.link-status-indicator.pending {
    background: linear-gradient(135deg, #f39c12, #e67e22);
    color: white;
}

.link-status-indicator.timeout {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: white;
}

.link-status-indicator.hidden {
    display: none;
}

.link-status-indicator:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.link-tooltip {
    position: absolute;
    bottom: -35px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 1000;
}

.link-status-indicator:hover .link-tooltip {
    opacity: 1;
}

.content {
    padding: 30px;
}

.version-controls {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.version-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.version-name {
    font-weight: 600;
    color: #2c3e50;
}

.version-actions {
    display: flex;
    gap: 10px;
}

.version-btn {
    background: #3498db;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.version-btn:hover {
    background: #2980b9;
    transform: translateY(-1px);
}

.version-btn.danger {
    background: #e74c3c;
}

.version-btn.danger:hover {
    background: #c0392b;
}

.version-btn.success {
    background: #27ae60;
}

.version-btn.success:hover {
    background: #229954;
}

.version-btn.warning {
    background: #f39c12;
}

.version-btn.warning:hover {
    background: #e67e22;
}

.compare-mode {
    display: none;
}

.compare-mode.active {
    display: block;
}

.expense-tracker-mode {
    display: none;
}

.expense-tracker-mode.active {
    display: block;
}

.progress-view-mode {
    display: none;
}

.progress-view-mode.active {
    display: block;
}

.sankey-mode {
    display: none;
}

.sankey-mode.active {
    display: block;
}

.single-mode.compare-active,
.single-mode.expense-tracker-active,
.single-mode.progress-active,
.single-mode.sankey-active {
    display: none;
}

.comparison-container {
    display: block;
}

.budget-version {
    border: 2px solid #dee2e6;
    border-radius: 15px;
    padding: 20px;
    background: white;
}

.budget-version h3 {
    text-align: center;
    margin-bottom: 20px;
    padding: 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 8px;
}

.comparison-summary {
    grid-column: 1 / -1;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 15px;
    margin-top: 20px;
}

.comparison-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.comparison-item {
    background: rgba(255, 255, 255, 0.1);
    padding: 15px;
    border-radius: 8px;
    text-align: center;
}

.comparison-item h4 {
    font-size: 0.8rem;
    margin-bottom: 8px;
    opacity: 0.8;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.comparison-item .amount {
    font-size: 1.5rem;
    font-weight: 700;
}

.saved-versions {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 20px;
}

.saved-versions h4 {
    color: #2c3e50;
    margin-bottom: 15px;
}

.version-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.version-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background: white;
    border-radius: 6px;
    border: 1px solid #dee2e6;
    transition: all 0.3s ease;
}

.version-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.version-item.default-version {
    background: linear-gradient(135deg, #fff8e1 0%, #fffde7 100%);
    border-color: #ffc107;
    border-width: 2px;
}

.version-item-info {
    flex: 1;
}

.version-item-name {
    font-weight: 600;
    color: #2c3e50;
    display: flex;
    align-items: center;
    gap: 8px;
}

.default-badge {
    background: #ffc107;
    color: #212529;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.version-item-date {
    font-size: 0.8rem;
    color: #7f8c8d;
}

.version-item-actions {
    display: flex;
    gap: 5px;
}

.version-item-btn {
    background: #95a5a6;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.3s ease;
}

.version-item-btn:hover {
    background: #7f8c8d;
    transform: translateY(-1px);
}

.version-item-btn.primary {
    background: #3498db;
}

.version-item-btn.primary:hover {
    background: #2980b9;
}

.version-item-btn.success {
    background: #27ae60;
}

.version-item-btn.success:hover {
    background: #229954;
}

.version-item-btn.warning {
    background: #f39c12;
}

.version-item-btn.warning:hover {
    background: #e67e22;
}

.version-item-btn.danger {
    background: #e74c3c;
}

.version-item-btn.danger:hover {
    background: #c0392b;
}

.budget-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 30px;
}

.section {
    background: white;
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
    border: 1px solid #e1e5e9;
}

.section h2 {
    color: #2c3e50;
    font-size: 1.5rem;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 3px solid #3498db;
}

.income h2 {
    border-bottom-color: #27ae60;
}

.expenses h2 {
    border-bottom-color: #e74c3c;
}

.category-section {
    margin-bottom: 25px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
    border-left: 4px solid #e74c3c;
    position: relative;
    border: 2px solid transparent;
    transition: all 0.3s ease;
    z-index: 1;
    cursor: grab;
}

.category-section:active {
    cursor: grabbing;
}

.category-section.dragging {
    opacity: 0.5;
    transform: rotate(2deg);
    border-color: #4facfe;
    z-index: 50;
}

.category-section.drag-over {
    border: 2px dashed #4facfe;
    background: rgba(79, 172, 254, 0.05);
    transform: scale(1.02);
}

.category-section:hover:not(.dragging) {
    border-color: #dee2e6;
    transform: translateY(-1px);
}

.category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    min-height: 40px;
}

.category-controls {
    display: flex;
    gap: 6px; /* Reduced gap for better clustering */
    align-items: center;
}

.add-to-category, .remove-category {
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.add-to-category {
    background: #e74c3c;
    color: white;
}

.add-to-category:hover {
    background: #c0392b;
    transform: translateY(-1px);
}

.remove-category {
    background: #95a5a6;
    color: white;
}

.remove-category:hover {
    background: #7f8c8d;
    transform: translateY(-1px);
}

.category-subtotal {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    color: white;
    padding: 8px 15px;
    border-radius: 6px;
    font-weight: 600;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.input-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding: 10px;
    background: #ffffff;
    border-radius: 8px;
    transition: all 0.3s ease;
    cursor: grab;
    position: relative;
    border: 2px solid transparent;
    z-index: 10;
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
}

.input-group:active {
    cursor: grabbing;
}

.input-group.dragging {
    opacity: 0.5;
    transform: rotate(1deg);
    border-color: #4facfe;
    z-index: 100;
}

.input-group.drag-over {
    border: 2px dashed #4facfe;
    background: rgba(79, 172, 254, 0.1);
    transform: scale(1.02);
}

.input-group:hover:not(.dragging) {
    background: #f8f9fa;
    transform: translateY(-1px);
    border-color: #dee2e6;
}

.input-group label {
    font-weight: 600;
    color: #495057;
    flex: 1;
    cursor: text;
    transition: color 0.2s ease;
}

.input-group label:hover {
    background: rgba(52, 152, 219, 0.1);
    border-radius: 4px;
    padding: 2px 4px;
}

.input-group label[style*="color: rgb(153, 153, 153)"],
.input-group label[style*="color:#999"] {
    font-style: italic;
    opacity: 0.8;
}

.category-header h3 {
    color: #2c3e50;
    margin: 0;
    transition: color 0.2s ease;
    cursor: text;
}

.category-header h3[style*="color: rgb(153, 153, 153)"],
.category-header h3[style*="color:#999"] {
    font-style: italic;
    opacity: 0.8;
}

.input-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.input-group input {
    width: 140px;
    padding: 8px 12px;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    font-size: 1rem;
    text-align: right;
    transition: border-color 0.3s ease;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
}

.input-group input:focus {
    outline: none;
    border-color: #4facfe;
    box-shadow: 0 0 0 3px rgba(79, 172, 254, 0.1);
}

.input-group input[type="number"],
.input-group input[type="text"] {
    width: 140px;
    padding: 8px 12px;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    font-size: 1rem;
    text-align: right;
    transition: border-color 0.3s ease;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
}

.input-group input[type="number"]:focus,
.input-group input[type="text"]:focus {
    outline: none;
    border-color: #4facfe;
    box-shadow: 0 0 0 3px rgba(79, 172, 254, 0.1);
}

.remove-item {
    background: #95a5a6;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.7rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.remove-item:hover {
    background: #7f8c8d;
    transform: translateY(-1px);
}

.drag-handle {
    color: #95a5a6;
    cursor: grab;
    font-size: 1.2rem;
    margin-right: 5px;
    user-select: none;
}

.drag-handle:hover {
    color: #7f8c8d;
}

[contenteditable="true"]:focus {
    outline: 2px solid #4facfe;
    border-radius: 4px;
    padding: 2px 4px;
    background: rgba(79, 172, 254, 0.1);
    cursor: text;
}

.total-row {
    margin-top: 20px;
    padding: 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 700;
    font-size: 1.2rem;
}

.summary {
    grid-column: 1 / -1;
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    color: white;
}

.summary h2 {
    color: white;
    border-bottom-color: rgba(255, 255, 255, 0.3);
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.summary-item {
    background: rgba(255, 255, 255, 0.1);
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    backdrop-filter: blur(10px);
}

.summary-item h3 {
    font-size: 0.9rem;
    margin-bottom: 10px;
    opacity: 0.8;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.summary-item .amount {
    font-size: 2rem;
    font-weight: 700;
}

.positive {
    color: #27ae60;
}

.negative {
    color: #e74c3c;
}

.add-item {
    background: #3498db;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    margin-top: 10px;
    transition: all 0.3s ease;
}

.add-item:hover {
    background: #2980b9;
    transform: translateY(-2px);
}

/* === COMPARISON STYLES === */

.line-by-line-comparison {
    background: white;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
}

.comparison-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    text-align: center;
}

.comparison-header h3 {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 600;
}

.comparison-table {
    padding: 0;
}

.comparison-table-header {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    background: #f8f9fa;
    padding: 15px 20px;
    border-bottom: 2px solid #dee2e6;
    font-weight: 700;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #495057;
}

.section-header {
    grid-column: 1 / -1;
    padding: 15px 20px;
    font-weight: 700;
    font-size: 1.1rem;
    background: #e9ecef;
    border-bottom: 1px solid #dee2e6;
    color: #495057;
}

.income-header {
    background: linear-gradient(135deg, #27ae60, #2ecc71);
    color: white;
}

.expense-header {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: white;
}

.comparison-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    padding: 12px 20px;
    border-bottom: 1px solid #f1f3f4;
    align-items: center;
    transition: background-color 0.2s ease;
}

.comparison-row:hover {
    background: #f8f9fa;
}

.comparison-row.new-item {
    background: rgba(39, 174, 96, 0.05);
    border-left: 4px solid #27ae60;
}

.comparison-row.removed-item {
    background: rgba(231, 76, 60, 0.05);
    border-left: 4px solid #e74c3c;
}

.category-header-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    padding: 15px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    border-top: 2px solid #dee2e6;
    font-weight: 600;
    color: #2c3e50;
}

.category-name {
    font-size: 1rem;
    color: #e74c3c;
}

.category-spacer {
    /* Empty spacer for alignment */
}

.comparison-row.category-item .item-name.indent {
    margin-left: 20px;
    color: #6c757d;
}

.comparison-row.subtotal-row {
    background: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
    font-style: italic;
}

.comparison-row.total-row {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border-bottom: none;
    font-size: 1.1rem;
}

.comparison-row.net-row {
    background: linear-gradient(135deg, #11998e, #38ef7d);
    color: white;
    border-bottom: none;
    font-size: 1.2rem;
}

.comparison-row.savings-rate-row {
    background: linear-gradient(135deg, #4facfe, #00f2fe);
    color: white;
    border-bottom: none;
    font-size: 1.1rem;
}

.item-name {
    font-weight: 500;
    color: #495057;
}

.budget-amount {
    text-align: right;
    font-weight: 600;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
}

.budget-amount.missing {
    color: #adb5bd;
    font-style: italic;
}

.budget-amount.missing::after {
    content: " (not present)";
    font-size: 0.8rem;
    font-weight: normal;
}

.difference {
    text-align: right;
    font-weight: 700;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
}

.difference.positive {
    color: #27ae60;
}

.difference.negative {
    color: #e74c3c;
}

.difference.neutral {
    color: #6c757d;
}

.net-amount.positive {
    color: #27ae60;
}

.net-amount.negative {
    color: #e74c3c;
}

/* === PROGRESS VIEW STYLES === */

.progress-view-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 20px;
}

.progress-summary-section {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 15px;
    padding: 25px;
    margin-bottom: 30px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
}

.progress-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px;
}

.progress-summary-item {
    background: rgba(255, 255, 255, 0.1);
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    backdrop-filter: blur(10px);
}

.progress-summary-item h3 {
    font-size: 0.9rem;
    margin-bottom: 10px;
    opacity: 0.8;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.summary-amount {
    font-size: 1.8rem;
    font-weight: 700;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
}

.category-progress-section {
    background: white;
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
}

.category-progress-item {
    background: #f8f9fa;
    border-radius: 12px;
    margin-bottom: 20px;
    border-left: 4px solid #3498db;
    overflow: hidden;
    transition: all 0.3s ease;
}

.category-progress-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.category-progress-header {
    padding: 20px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
}

.category-progress-header:hover {
    background: #f8f9fa;
}

.category-progress-info {
    flex: 1;
}

.category-progress-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 8px;
}

.category-progress-summary {
    font-size: 0.9rem;
    color: #6c757d;
    margin-bottom: 12px;
}

.category-progress-bar-container {
    position: relative;
    background: #e9ecef;
    border-radius: 10px;
    height: 12px;
    overflow: hidden;
    margin-bottom: 8px;
}

.category-progress-bar {
    height: 100%;
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    border-radius: 10px;
    transition: width 0.5s ease;
    position: relative;
}

.category-progress-bar.over-budget {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
}

.category-progress-bar.warning {
    background: linear-gradient(135deg, #ffc107 0%, #e0a800 100%);
}

.category-progress-percentage {
    position: absolute;
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.category-expand-icon {
    font-size: 1.2rem;
    color: #6c757d;
    transition: transform 0.3s ease;
}

.category-progress-item.expanded .category-expand-icon {
    transform: rotate(180deg);
}

.category-progress-details {
    display: none;
    padding: 0 20px 20px 20px;
    background: white;
}

.category-progress-item.expanded .category-progress-details {
    display: block;
}

.line-item-progress {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #f1f3f4;
}

.line-item-progress:last-child {
    border-bottom: none;
}

.line-item-info {
    flex: 1;
}

.line-item-name {
    font-weight: 500;
    color: #495057;
    margin-bottom: 4px;
}

.line-item-summary {
    font-size: 0.85rem;
    color: #6c757d;
}

.line-item-amounts {
    text-align: right;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    font-size: 0.9rem;
}

.line-item-spent {
    font-weight: 600;
    color: #2c3e50;
}

.line-item-budget {
    font-size: 0.8rem;
    color: #6c757d;
}

.line-item-over-budget {
    color: #dc3545;
}

.line-item-under-budget {
    color: #28a745;
}

.no-expenses-message {
    text-align: center;
    color: #6c757d;
    padding: 40px 20px;
    font-style: italic;
    background: #f8f9fa;
    border-radius: 8px;
    margin: 20px 0;
}

/* === EXPENSE TRACKER STYLES === */

.expense-tracker-container {
    max-width: 500px;
    margin: 0 auto;
    padding: 0 10px;
}

.overall-progress-section {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
}

.overall-progress-container {
    margin-top: 10px;
}

.overall-progress-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.progress-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
}

.progress-label span {
    color: white;
    font-weight: 700;
}

.overall-progress-bar-container {
    position: relative;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 25px;
    height: 20px;
    overflow: hidden;
}

.overall-progress-bar {
    height: 100%;
    background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
    border-radius: 25px;
    transition: width 0.5s ease, background 0.3s ease;
    min-width: 0%;
    max-width: 100%;
}

.overall-progress-bar.over-budget {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
}

.progress-percentage {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.8rem;
    font-weight: 700;
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.quick-add-section {
    background: white;
    border-radius: 15px;
    padding: 25px 20px;
    margin-bottom: 20px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
}

.expense-form {
    margin-bottom: 0;
}

.expense-form .form-group {
    margin-bottom: 20px;
}

.expense-form .form-group label {
    display: block;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.expense-form .form-group input,
.expense-form .form-group select {
    width: 100%;
    padding: 15px;
    border: 2px solid #dee2e6;
    border-radius: 10px;
    font-size: 1.1rem;
    transition: all 0.3s ease;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.expense-form .form-group input:focus,
.expense-form .form-group select:focus {
    outline: none;
    border-color: #4facfe;
    box-shadow: 0 0 0 3px rgba(79, 172, 254, 0.1);
}

.expense-form .form-group select {
    background: white url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e") no-repeat right 12px center;
    background-size: 16px;
    cursor: pointer;
}

.expense-form .form-group select:disabled {
    background-color: #f8f9fa;
    color: #6c757d;
    cursor: not-allowed;
}

.amount-input-container {
    position: relative;
    display: flex;
    align-items: center;
}

.currency-symbol {
    position: absolute;
    left: 15px;
    font-size: 1.2rem;
    font-weight: 600;
    color: #495057;
    z-index: 1;
}

.amount-input-container input {
    padding-left: 35px;
    text-align: right;
    font-weight: 600;
    font-size: 1.3rem;
    color: #2c3e50;
}

.submit-expense-btn {
    width: 100%;
    background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
    color: white;
    border: none;
    padding: 18px;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.submit-expense-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(39, 174, 96, 0.3);
}

.submit-expense-btn:disabled {
    background: #95a5a6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.expense-summary-section {
    background: white;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
}

.summary-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.summary-btn {
    flex: 1;
    background: #3498db;
    color: white;
    border: none;
    padding: 12px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.summary-btn:hover {
    transform: translateY(-1px);
}

.summary-btn.danger {
    background: #e74c3c;
}

.summary-btn.danger:hover {
    background: #c0392b;
}

.spending-overview {
    max-height: 400px;
    overflow-y: auto;
}

.category-spending {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 15px;
    border-left: 4px solid #e74c3c;
}

.category-spending-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.category-name-spending {
    font-weight: 600;
    color: #2c3e50;
    font-size: 1rem;
}

.category-total-spending {
    font-weight: 700;
    color: #e74c3c;
}

.category-progress {
    background: #dee2e6;
    border-radius: 10px;
    height: 8px;
    margin-bottom: 10px;
    overflow: hidden;
}

.category-progress-bar {
    height: 100%;
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    border-radius: 10px;
    transition: width 0.3s ease;
}

.category-progress-bar.over-budget {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
}

.category-progress-bar.under-budget {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
}

.item-spending {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #dee2e6;
}

.item-spending:last-child {
    border-bottom: none;
}

.item-name-spending {
    color: #495057;
    font-size: 0.9rem;
}

.item-amount-spending {
    font-weight: 600;
    color: #2c3e50;
    font-size: 0.9rem;
}

.budget-comparison {
    font-size: 0.8rem;
    color: #6c757d;
    margin-top: 5px;
}

.over-budget-text {
    color: #dc3545;
    font-weight: 600;
}

.under-budget-text {
    color: #28a745;
    font-weight: 600;
}

/* === EXPENSE LIST MODAL === */

.expense-list-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    overflow-y: auto;
    padding: 20px;
}

.modal-content {
    background: white;
    border-radius: 15px;
    max-width: 600px;
    margin: 0 auto;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

.modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 15px 15px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.3rem;
}

.close-modal-btn {
    background: none;
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-body {
    padding: 20px;
    max-height: calc(80vh - 120px);
    overflow-y: auto;
}

.expense-filters {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 20px;
}

.expense-item {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 10px;
    border-left: 4px solid #3498db;
    position: relative;
}

.expense-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.expense-description {
    font-weight: 600;
    color: #2c3e50;
    flex: 1;
}

.expense-amount {
    font-weight: 700;
    color: #e74c3c;
    font-size: 1.1rem;
}

.expense-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: #6c757d;
}

.expense-category-item {
    background: #e3f2fd;
    color: #1976d2;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.delete-expense-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 5px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    position: absolute;
    top: 10px;
    right: 10px;
}

.empty-state {
    text-align: center;
    color: #6c757d;
    padding: 40px 20px;
    font-style: italic;
}

/* === SANKEY CHART STYLES === */

.sankey-view {
    background: white;
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
    border: 1px solid #e1e5e9;
}

.sankey-header {
    text-align: center;
    margin-bottom: 30px;
}

.sankey-header h2 {
    color: #2c3e50;
    font-size: 2rem;
    margin-bottom: 10px;
    border-bottom: 3px solid #4facfe;
    display: inline-block;
    padding-bottom: 8px;
}

.sankey-header p {
    color: #7f8c8d;
    font-size: 1.1rem;
    margin-top: 15px;
}

.sankey-container {
    width: 100%;
    height: 600px;
    background: #f8f9fa;
    border-radius: 10px;
    border: 2px solid #e9ecef;
    position: relative;
    overflow: hidden;
    margin-bottom: 20px;
    min-width: 0;
}

.sankey-tooltip {
    position: absolute;
    padding: 10px 15px;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    pointer-events: none;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
}

.sankey-legend {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    background: #f8f9fa;
    border-radius: 25px;
    border: 2px solid #dee2e6;
    transition: all 0.3s ease;
    font-weight: 600;
    color: #495057;
}

.legend-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-color: #4facfe;
}

.legend-color {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.legend-item.income .legend-color {
    background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
}

.legend-item.categories .legend-color {
    background: linear-gradient(135deg, #3498db 0%, #5dade2 100%);
}

.legend-item.items .legend-color {
    background: linear-gradient(135deg, #e74c3c 0%, #ec7063 100%);
}

.sankey-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 25px 20px;
    border-radius: 15px;
    text-align: center;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.stat-card h4 {
    font-size: 0.9rem;
    margin-bottom: 12px;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.stat-card .value {
    font-size: 1.8rem;
    font-weight: 700;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
}

.sankey-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #7f8c8d;
    font-size: 1.2rem;
    text-align: center;
    padding: 40px 20px;
}

.sankey-empty-state .icon {
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: 0.5;
}

.sankey-empty-state .message {
    font-weight: 600;
    margin-bottom: 10px;
}

.sankey-empty-state .submessage {
    font-size: 1rem;
    opacity: 0.8;
}

.sankey-node {
    cursor: pointer;
    transition: all 0.3s ease;
}

.sankey-node:hover {
    filter: brightness(1.1);
}

.sankey-link {
    cursor: pointer;
    transition: all 0.3s ease;
}

.sankey-link:hover {
    stroke-opacity: 0.8 !important;
}

.sankey-node-label {
    font-weight: 600;
    font-size: 12px;
    fill: #2c3e50;
    pointer-events: none;
}

/* === ICON PICKER MODAL STYLES === */

.icon-picker-modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    background: rgba(0, 0, 0, 0.6) !important;
    z-index: 10000 !important;
    overflow-y: auto !important;
    padding: 20px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.icon-picker-content {
    background: white !important;
    border-radius: 15px !important;
    max-width: 600px !important;
    width: 100% !important;
    max-height: 80vh !important;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3) !important;
    display: flex !important;
    flex-direction: column !important;
    position: relative !important;
}

.icon-picker-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: white !important;
    padding: 20px !important;
    border-radius: 15px 15px 0 0 !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
}

.icon-picker-header h3 {
    margin: 0 !important;
    font-size: 1.3rem !important;
    color: white !important;
}

.icon-picker-body {
    padding: 20px !important;
    overflow-y: auto !important;
    flex: 1 !important;
}

.icon-category-section {
    margin-bottom: 25px !important;
}

.icon-category-section h4 {
    color: #2c3e50 !important;
    margin-bottom: 15px !important;
    font-size: 1rem !important;
    font-weight: 600 !important;
    border-bottom: 2px solid #e9ecef !important;
    padding-bottom: 8px !important;
}

.icon-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(50px, 1fr)) !important;
    gap: 8px !important;
}

.icon-option {
    width: 50px !important;
    height: 50px !important;
    border: 2px solid #dee2e6 !important;
    background: white !important;
    border-radius: 8px !important;
    cursor: pointer !important;
    font-size: 1.5rem !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.3s ease !important;
    position: relative !important;
}

.icon-option:hover {
    border-color: #4facfe !important;
    background: #f8f9fa !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 12px rgba(79, 172, 254, 0.2) !important;
}

.icon-option:active {
    transform: translateY(0) !important;
}

.icon-option.selected {
    border-color: #4facfe !important;
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%) !important;
    color: white !important;
    box-shadow: 0 4px 12px rgba(79, 172, 254, 0.3) !important;
}

.category-title-section {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    flex: 1 !important;
}

.category-icon-picker-btn {
    background: #f39c12 !important; /* Changed from blue gradient to orange */
    border: none !important;
    border-radius: 4px !important; /* Changed from 6px to match other buttons */
    padding: 5px 10px !important; /* Match other buttons */
    cursor: pointer !important;
    font-size: 0.8rem !important; /* Match other buttons */
    color: white !important;
    font-weight: 600 !important; /* Match other buttons */
    transition: all 0.3s ease !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-width: auto !important;
    height: auto !important;
    margin-left: 0 !important; /* Remove left margin */
    margin-right: 0 !important;
    box-shadow: none !important;
}

.category-icon-picker-btn:hover {
    background: #e67e22 !important; /* Darker orange on hover */
    transform: translateY(-1px) !important;
}

.category-icon-picker-btn:active {
    transform: translateY(0) !important;
}

.close-modal-btn {
    background: none !important;
    border: none !important;
    color: white !important;
    font-size: 2rem !important;
    cursor: pointer !important;
    padding: 0 !important;
    width: 30px !important;
    height: 30px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 50% !important;
    transition: background 0.3s ease !important;
}

.close-modal-btn:hover {
    background: rgba(255, 255, 255, 0.2) !important;
}

/* === LINKING INTERFACE STYLES === */

.link-code-modal,
.link-redemption-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.link-code-modal.active,
.link-redemption-modal.active {
    display: flex;
}

.link-code-content,
.link-redemption-content {
    background: white;
    border-radius: 15px;
    width: 100%;
    max-width: 500px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    position: relative;
    overflow: hidden;
}

.link-code-header,
.link-redemption-header {
    background: linear-gradient(135deg, #4caf50, #45a049);
    color: white;
    padding: 20px;
    text-align: center;
    position: relative;
}

.link-redemption-header {
    background: linear-gradient(135deg, #667eea, #764ba2);
}

.link-code-header h3,
.link-redemption-header h3 {
    margin: 0;
    font-size: 1.3rem;
}

.link-code-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease;
}

.link-code-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.link-code-body,
.link-redemption-body {
    padding: 25px;
}

.generated-code-display {
    text-align: center;
    margin: 20px 0;
}

.code-digits {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 20px 0;
}

.code-digit {
    width: 50px;
    height: 50px;
    background: #f8f9fa;
    border: 2px solid #4caf50;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    font-weight: 700;
    color: #2c3e50;
    font-family: 'Courier New', monospace;
}

.code-input-container {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 25px 0;
}

.code-input-box {
    width: 50px;
    height: 50px;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    text-align: center;
    font-size: 1.8rem;
    font-weight: 700;
    color: #2c3e50;
    font-family: 'Courier New', monospace;
    transition: all 0.3s ease;
    background: white;
}

.code-input-box:focus {
    outline: none;
    border-color: #4facfe;
    box-shadow: 0 0 0 3px rgba(79, 172, 254, 0.2);
    background: #f8f9fa;
}

.code-input-box.filled {
    border-color: #27ae60;
    background: #e8f5e8;
}

.code-input-box.error {
    border-color: #e74c3c;
    background: #ffeaa7;
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.link-redemption-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.link-action-btn {
    flex: 1;
    background: linear-gradient(135deg, #4facfe, #00f2fe);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.link-action-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(79, 172, 254, 0.4);
}

.link-action-btn:disabled {
    background: #95a5a6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.link-action-btn.secondary {
    background: #6c757d;
}

.link-action-btn.secondary:hover {
    background: #5a6268;
}

.link-instructions {
    text-align: center;
    color: #6c757d;
    font-size: 0.9rem;
    margin-bottom: 15px;
}

.link-security-note {
    background: #e3f2fd;
    border: 1px solid #2196f3;
    border-radius: 8px;
    padding: 12px;
    margin: 15px 0;
    font-size: 0.85rem;
    color: #1976d2;
}

.link-error-message {
    background: #ffebee;
    border: 1px solid #f44336;
    border-radius: 8px;
    padding: 12px;
    margin: 15px 0;
    font-size: 0.9rem;
    color: #c62828;
    display: none;
}

.link-error-message.show {
    display: block;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* === MOBILE OPTIMIZATIONS === */

@media (max-width: 768px) {
    /* Adjust header for mobile */
    .header {
        padding: 20px;
    }
    
    .header-logo {
        height: 45px;
        margin-bottom: 0px;
    }
    
    .tagline {
        font-size: 1rem;
    }
    
    /* Adjust sync indicator for mobile */
    .sync-indicator {
        top: 15px;
        left: 15px;
        width: 10px;
        height: 10px;
    }
    
    /* Adjust link status indicator for mobile */
    .link-status-indicator {
        top: 15px;
        right: 60px;
        width: 28px;
        height: 28px;
        font-size: 14px;
    }
    
    /* Adjust menu toggle for mobile */
    .menu-toggle {
        top: 15px;
        right: 15px;
        padding: 8px;
    }

    .menu-toggle span {
        width: 22px;
        height: 2.5px;
    }

    /* Adjust menu for mobile */
    .header-controls {
        width: min(280px, 85vw);
    }
    
    .header-controls::before {
        height: 60px;
    }
    
    .header-controls:not(:has(.header-controls-content)) {
        padding: 60px 15px 15px;
    }
    
    .header-controls-content {
        padding: 10px 15px 15px;
    }

    .nav-section {
        margin-bottom: 20px;
    }

    .header-btn {
        padding: 12px 15px;
        font-size: 0.9rem;
        margin-bottom: 6px;
    }

    .current-account {
        font-size: 0.75rem;
        padding: 6px 12px;
    }

    .budget-grid {
        grid-template-columns: 1fr;
    }
    
    .content {
        padding: 20px;
    }
    
    .comparison-table-header,
    .comparison-row,
    .category-header-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .comparison-table-header {
        display: none;
    }
    
    .comparison-row {
        padding: 15px;
        border-radius: 8px;
        margin-bottom: 8px;
        background: white;
        border: 1px solid #dee2e6;
    }
    
    .item-name::before {
        content: "Item: ";
        font-weight: 600;
        color: #6c757d;
        font-size: 0.8rem;
    }
    
    .budget-amount::before {
        content: "Amount: ";
        font-weight: 600;
        color: #6c757d;
        font-size: 0.8rem;
    }
    
    .difference::before {
        content: "Difference: ";
        font-weight: 600;
        color: #6c757d;
        font-size: 0.8rem;
    }
    
    .comparison-row.category-item .item-name.indent {
        margin-left: 0;
    }

    .version-actions {
        flex-direction: column;
        gap: 8px;
    }

    .version-btn {
        padding: 6px 12px;
        font-size: 0.8rem;
    }

    .default-indicator {
        font-size: 0.75rem;
        padding: 4px 8px;
    }

    .expense-tracker-container {
        padding: 0 5px;
    }
    
    .overall-progress-section {
        padding: 15px;
        margin-bottom: 15px;
    }
    
    .overall-progress-info {
        font-size: 0.8rem;
        gap: 5px;
    }
    
    .overall-progress-bar-container {
        height: 16px;
    }
    
    .progress-percentage {
        font-size: 0.7rem;
    }
    
    .quick-add-section {
        padding: 20px 15px;
        margin-bottom: 15px;
    }
    
    .expense-form .form-group input,
    .expense-form .form-group select {
        padding: 12px;
        font-size: 1rem;
    }
    
    .submit-expense-btn {
        padding: 15px;
        font-size: 1rem;
    }
    
    .expense-summary-section {
        padding: 15px;
    }
    
    .modal-content {
        margin: 10px auto;
        border-radius: 10px;
    }
    
    .modal-header {
        padding: 15px;
        border-radius: 10px 10px 0 0;
    }
    
    .modal-body {
        padding: 15px;
        max-height: calc(90vh - 100px);
    }
    
    .expense-filters {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .expense-item {
        padding: 12px;
    }

    /* Progress view mobile styles */
    .progress-view-container {
        padding: 0 5px;
    }
    
    .progress-summary-section {
        padding: 15px;
        margin-bottom: 15px;
    }
    
    .progress-summary-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
    
    .progress-summary-item {
        padding: 15px 10px;
    }
    
    .progress-summary-item h3 {
        font-size: 0.8rem;
    }
    
    .summary-amount {
        font-size: 1.4rem;
    }
    
    .category-progress-section {
        padding: 15px;
    }
    
    .category-progress-header {
        padding: 15px;
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .category-progress-info {
        width: 100%;
    }
    
    .category-progress-name {
        font-size: 1rem;
    }
    
    .category-progress-summary {
        font-size: 0.8rem;
    }
    
    .line-item-progress {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .line-item-amounts {
        width: 100%;
        text-align: left;
    }

    .auth-container {
        margin: 20px auto;
        padding: 30px 20px;
    }

    .auth-container h2 {
        font-size: 1.5rem;
    }

    .logo-image {
        width: 100px;
        height: 100px;
    }

    /* Sankey view mobile styles */
    .sankey-header h2 {
        font-size: 1.5rem;
    }
    
    .sankey-header p {
        font-size: 1rem;
    }
    
    .sankey-container {
        height: 400px;
        margin-bottom: 15px;
    }
    
    .sankey-legend {
        flex-direction: column;
        align-items: center;
        gap: 15px;
        margin-bottom: 20px;
    }
    
    .legend-item {
        padding: 8px 16px;
        gap: 8px;
    }
    
    .legend-color {
        width: 14px;
        height: 14px;
    }
    
    .sankey-stats {
        grid-template-columns: 1fr 1fr;
        gap: 15px;
    }
    
    .stat-card {
        padding: 20px 15px;
    }
    
    .stat-card h4 {
        font-size: 0.8rem;
        margin-bottom: 8px;
    }
    
    .stat-card .value {
        font-size: 1.4rem;
    }
    
    .sankey-tooltip {
        font-size: 11px;
        padding: 8px 12px;
    }
    
    .sankey-empty-state {
        padding: 20px 15px;
        font-size: 1rem;
    }
    
    .sankey-empty-state .icon {
        font-size: 3rem;
        margin-bottom: 15px;
    }
    
    .sankey-node-label {
        font-size: 10px;
    }
    /* Sankey chart mobile fixes */
    .sankey-container {
        height: 350px;
        margin-bottom: 15px;
        min-height: 350px;
        box-sizing: border-box;
    }
    
    .sankey-view {
        padding: 15px;
        overflow-x: auto;
    }
    
    /* Input group mobile fixes */
    .input-group {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 12px;
    }
    
    .input-group label {
        margin-bottom: 5px;
        text-align: left;
    }
    
    .input-controls {
        justify-content: space-between;
        width: 100%;
        flex-shrink: 0;
    }
    
    .input-group input {
        width: calc(100% - 80px); /* Leave space for remove button */
        min-width: 120px;
        max-width: 200px;
        flex: 1;
    }
    
    .remove-item {
        flex-shrink: 0;
        width: 60px;
        padding: 8px 12px;
        font-size: 0.9rem;
    }
    
    .drag-handle {
        align-self: flex-start;
        margin-bottom: 5px;
    }
    
    /* Category section mobile fixes */
    .category-section {
        margin-bottom: 20px;
        padding: 12px;
    }
    
    .category-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        min-height: auto;
    }
    
    .category-title-container {
        width: 100%;
        justify-content: flex-start;
    }
    
    .category-controls {
        align-self: flex-start;
        flex-wrap: wrap;
        gap: 6px;
    }
    
    .category-icon-picker-btn {
        font-size: 0.75rem !important;
        padding: 4px 8px !important;
    }
    
    .add-to-category, 
    .remove-category {
        font-size: 0.75rem;
        padding: 4px 8px;
    }
    
    /* Section and content mobile fixes */
    .section {
        padding: 20px 15px;
        margin-bottom: 20px;
        box-sizing: border-box;
        width: 100%;
        min-width: 0;
    }
    
    .content {
        padding: 15px 10px;
    }
    
    .version-controls {
        padding: 15px;
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    
    .version-actions {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
        justify-content: stretch;
    }
    
    .version-btn {
        flex: 1;
        min-width: 0;
        font-size: 0.75rem;
        padding: 8px 10px;
    }
    
    /* Prevent horizontal scrolling */
    .container {
        margin: 0 auto;
        max-width: 100%;
        overflow-x: hidden;
    }
    
    body {
        overflow-x: hidden;
        padding: 10px;
    }
    
    /* Ensure box-sizing for all elements */
    * {
        box-sizing: border-box;
    }

    /* Icon picker mobile styles */
    .icon-picker-modal {
        padding: 10px !important;
    }
    
    .icon-picker-content {
        max-height: 90vh !important;
        border-radius: 10px !important;
    }
    
    .icon-picker-header {
        padding: 15px !important;
        border-radius: 10px 10px 0 0 !important;
    }
    
    .icon-picker-header h3 {
        font-size: 1.1rem !important;
    }
    
    .icon-picker-body {
        padding: 15px !important;
    }
    
    .icon-grid {
        grid-template-columns: repeat(auto-fill, minmax(45px, 1fr)) !important;
        gap: 6px !important;
    }
    
    .icon-option {
        width: 45px !important;
        height: 45px !important;
        font-size: 1.3rem !important;
    }
    
    .category-icon-picker-btn {
        font-size: 0.9rem !important;
        padding: 3px 6px !important;
        min-width: 28px !important;
        height: 24px !important;
    }
    
    .category-title-section {
        gap: 6px !important;
    }

    /* Link modal mobile styles */
    .link-code-content,
    .link-redemption-content {
        margin: 10px;
        border-radius: 10px;
        max-width: 450px;
    }
    
    .link-code-header,
    .link-redemption-header {
        padding: 15px;
    }
    
    .link-code-body,
    .link-redemption-body {
        padding: 20px;
    }
    
    .code-digit,
    .code-input-box {
        width: 40px;
        height: 40px;
        font-size: 1.4rem;
    }
    
    .code-input-container,
    .code-digits {
        gap: 6px;
    }
}

/* For landscape orientation on mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .header-controls::before {
        height: 45px;
    }
    
    .header-controls:not(:has(.header-controls-content)) {
        padding: 45px 15px 10px;
    }
    
    .nav-section {
        margin-bottom: 15px;
    }
    
    .header-btn {
        padding: 10px 15px;
        margin-bottom: 4px;
    }
}

/* For very short screens */
@media (max-height: 500px) {
    .header-controls::before {
        height: 50px;
    }
    
    .header-controls:not(:has(.header-controls-content)) {
        padding: 50px 20px 15px;
    }
    
    .header-controls-content {
        padding: 5px 20px 15px;
    }

    .nav-section {
        margin-bottom: 15px;
    }

    .header-btn {
        padding: 10px 15px;
        margin-bottom: 5px;
    }

    .nav-label {
        margin-bottom: 8px;
        font-size: 0.75rem;
    }
}

/* Very small mobile screens */
@media (max-width: 480px) {
    .sankey-stats {
        grid-template-columns: 1fr;
    }
    
    .sankey-container {
        height: 350px;
    }
    
    .sankey-header h2 {
        font-size: 1.3rem;
    }
    
    .stat-card .value {
        font-size: 1.2rem;
    }

    .header-controls {
        width: min(260px, 90vw);
    }
}