:root {
    --bg-dark: #0a0c10;
    --sidebar-bg: #11141b;
    --card-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.08);
    --primary-color: #7c3aed;
    --primary-light: #a78bfa;
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --text-main: #f8fafc;
    --text-secondary: #94a3b8;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
    --bg-dark: #f0f2f5;
    --sidebar-bg: #ffffff;
    --card-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(0, 0, 0, 0.08);
    --text-main: #1e293b;
    --text-secondary: #64748b;
    --primary-color: #6d28d9;
}

/* Lightmode specific adjustments */
[data-theme="light"] input,
[data-theme="light"] select {
    background: rgba(0, 0, 0, 0.04) !important;
    color: #1e293b !important;
}

[data-theme="light"] select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

[data-theme="light"] select option {
    background-color: #ffffff;
    color: #1e293b;
}

[data-theme="light"] .input-with-currency span {
    color: #64748b;
}

/* Lightmode specific overrides for inputs with !important */
[data-theme="light"] .input-with-currency input,
[data-theme="light"] .quick-add input,
[data-theme="light"] .quick-add select {
    background: rgba(0, 0, 0, 0.04) !important;
    color: #1e293b !important;
    border-color: rgba(0, 0, 0, 0.1) !important;
}


* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    overflow: hidden;
    transition: background-color var(--transition), color var(--transition);
}

.glass,
.stat-card,
.sidebar,
.nav-item,
.info-box,
.chart-box,
.config-card,
.modal {
    transition: background var(--transition), border var(--transition), color var(--transition), box-shadow var(--transition);
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    padding: 2rem 1.5rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0 0.5rem 2.5rem;
}

.logo i {
    color: var(--primary-color);
    width: 32px;
    height: 32px;
}

.logo span {
    font-family: 'Outfit', sans-serif;
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.nav-menu {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 12px;
    transition: all 0.2s;
    font-weight: 500;
}

.nav-item i {
    width: 20px;
    height: 20px;
}

.nav-item:hover,
.nav-item.active {
    background: rgba(124, 58, 237, 0.1);
    color: var(--text-main);
}

.nav-item.active i {
    color: var(--primary-color);
}

.user-profile {
    margin-top: auto;
    background: rgba(255, 255, 255, 0.03);
    padding: 1rem;
    border-radius: 16px;
    display: flex;
    align-items: center;
    gap: 1rem;
    border: 1px solid var(--glass-border);
}

.avatar {
    width: 42px;
    height: 42px;
    background: var(--primary-color);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: white;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.user-status.connected {
    color: #10b981;
    font-weight: 600;
}

.user-status.local {
    color: #ef4444;
    font-weight: 600;
}

.file-connection {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--glass-border);
    width: 100%;
}

.version-tag {
    font-size: 0.7rem;
    color: var(--text-secondary);
    opacity: 0.4;
    text-align: center;
    margin-top: 1rem;
    font-family: 'Outfit', sans-serif;
    letter-spacing: 0.05em;
}

.btn-icon:hover i {
    transform: rotate(15deg) scale(1.1);
}

.btn-link {
    background: none;
    border: none;
    color: var(--primary-light);
    font-size: 0.75rem;
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.btn-link:hover {
    color: white;
}

/* Main Content */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 2.5rem 3.5rem;
}

.view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
}

.view-title {
    font-family: 'Outfit', sans-serif;
    font-size: 2rem;
    font-weight: 700;
}

.view-subtitle {
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.header-actions {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.85rem;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
    min-width: 220px;
}

.search-box i {
    width: 16px;
    height: 16px;
    color: var(--text-secondary);
}

.search-box input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-main);
    font-size: 0.9rem;
    width: 100%;
}

.search-results {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    width: 320px;
    background: var(--sidebar-bg);
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    padding: 0.4rem;
    display: none;
    z-index: 20;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.search-results.active {
    display: block;
}

.search-item {
    width: 100%;
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    align-items: center;
    padding: 0.65rem 0.75rem;
    border-radius: 10px;
    background: transparent;
    border: none;
    color: var(--text-main);
    cursor: pointer;
    font-size: 0.85rem;
}

.search-item:hover {
    background: rgba(255, 255, 255, 0.06);
}

.search-title {
    font-weight: 600;
    text-align: left;
}

.search-meta {
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.search-empty {
    padding: 0.75rem 0.85rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* Autosave Status */
.autosave-indicator {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.03);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    border: 1px solid var(--glass-border);
}

.save-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success-color);
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.3);
}

.save-dot.syncing {
    background: var(--warning-color);
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% {
        opacity: 0.5;
        transform: scale(0.8);
    }

    50% {
        opacity: 1;
        transform: scale(1.1);
    }

    100% {
        opacity: 0.5;
        transform: scale(0.8);
    }
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.stat-card {
    padding: 1.75rem;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
}

.stat-card.highlight {
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.1), rgba(16, 185, 129, 0.05));
    border: 1px solid rgba(124, 58, 237, 0.2);
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon i {
    width: 28px;
    height: 28px;
}

.stat-icon.income {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
}

.stat-icon.expense {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error-color);
}

.stat-icon.balance {
    background: rgba(124, 58, 237, 0.1);
    color: var(--primary-color);
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.chart-box,
.info-box,
.glass {
    padding: 2.5rem;
    border-radius: 24px;
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
}

.glass {
    padding: 0;
    /* Let children handle padding or set specifically */
}

.section-title {
    font-family: 'Outfit', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 1.25rem;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.stat-meta {
    margin-top: 0.35rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.value-mask {
    transition: color 0.2s ease, text-shadow 0.2s ease;
}

.hide-values .value-mask {
    color: rgba(255,255,255,0.2);
    text-shadow: 0 0 14px rgba(255,255,255,0.95);
    filter: blur(6px);
}

.hide-values input[type="number"] {
    color: rgba(255,255,255,0.2);
    text-shadow: 0 0 14px rgba(255,255,255,0.95);
    filter: blur(6px);
}

.alert-list {
    display: grid;
    gap: 0.75rem;
}

.alert-item {
    padding: 0.75rem 1rem;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    background: rgba(255,255,255,0.02);
    font-size: 0.9rem;
}

.alert-glass.warning {
    border-color: rgba(245, 158, 11, 0.25);
    box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.05) inset;
}

.alert-glass.danger {
    border-color: rgba(239, 68, 68, 0.25);
    box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.05) inset;
}

.alert-item.warning {
    border-color: rgba(245, 158, 11, 0.4);
    color: #f59e0b;
}

.alert-item.danger {
    border-color: rgba(239, 68, 68, 0.4);
    color: #ef4444;
}

.cashflow-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.cashflow-nav {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.cashflow-title {
    font-size: 1.1rem;
    font-weight: 700;
}

.cashflow-summary {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.cashflow-summary .net {
    color: var(--text-main);
    font-weight: 700;
}

.cashflow-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(120px, 1fr));
    gap: 0.75rem;
}

.cashflow-day-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    padding: 0.25rem 0.5rem;
}

.cashflow-cell {
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    padding: 0.75rem;
    min-height: 120px;
    background: rgba(255,255,255,0.02);
}

.cashflow-cell.empty {
    background: transparent;
    border: 1px dashed rgba(255,255,255,0.06);
}

.cashflow-day {
    font-weight: 700;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.cashflow-events {
    display: grid;
    gap: 0.35rem;
}

.cashflow-event {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    gap: 0.5rem;
    min-width: 0;
}

.cashflow-event span:first-child {
    min-width: 0;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cashflow-event .value-mask,
.cashflow-event span:last-child {
    flex-shrink: 0;
}

.cashflow-event.income {
    color: #10b981;
}

.cashflow-event.expense {
    color: #ef4444;
}

.cashflow-more {
    font-size: 0.7rem;
    color: var(--text-secondary);
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    text-align: left;
}

.cashflow-day-list {
    display: grid;
    gap: 0.5rem;
}

.cashflow-day-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    border-radius: 10px;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--glass-border);
}

.cashflow-day-row.income {
    color: #10b981;
}

.cashflow-day-row.expense {
    color: #ef4444;
}

.cashflow-day-row.clickable {
    cursor: pointer;
}

.sort-toggle {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.budget-overview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}

.budget-card {
    border: 1px solid var(--glass-border);
    background: rgba(255,255,255,0.03);
    border-radius: 16px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    position: relative;
    overflow: hidden;
    min-width: 0;
    min-height: 130px;
}

.budget-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    font-weight: 600;
}

.budget-title {
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.budget-title .theme-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.22rem 0.55rem;
    min-height: 24px;
    font-size: 0.65rem;
    border-radius: 999px;
    line-height: 1.2;
    box-sizing: border-box;
}

.budget-pct {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.budget-amounts {
    font-size: 1rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.budget-amounts .muted {
    color: var(--text-secondary);
    font-weight: 500;
}

.budget-bar {
    height: 8px;
    background: rgba(255,255,255,0.06);
    border-radius: 999px;
    overflow: hidden;
    position: relative;
}

.budget-bar-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, rgba(124,58,237,0.9), rgba(59,130,246,0.9));
}

.budget-bar-over {
    position: absolute;
    right: 0;
    top: 0;
    height: 100%;
    background: linear-gradient(90deg, rgba(239,68,68,0.9), rgba(245,158,11,0.9));
}


.range-toggle {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.pill {
    padding: 0.4rem 0.8rem;
    border-radius: 999px;
    border: 1px solid var(--glass-border);
    background: rgba(255,255,255,0.03);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.8rem;
}

.pill.active {
    color: var(--text-main);
    border-color: rgba(124, 58, 237, 0.4);
    background: rgba(124, 58, 237, 0.12);
}

.header-hint {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    border: 1px solid var(--glass-border);
    background: rgba(255,255,255,0.03);
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.header-hint .muted {
    opacity: 0.7;
}

.header-hint .hint-badge {
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    background: rgba(124, 58, 237, 0.2);
    color: var(--text-main);
    font-weight: 700;
}

.header-hint .hint-badge.ok {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
}

.header-hint.warning {
    border-color: rgba(245, 158, 11, 0.25);
}

.header-hint.danger {
    border-color: rgba(239, 68, 68, 0.25);
}

.value-link {
    background: none;
    border: none;
    padding: 0;
    color: inherit;
    font: inherit;
    cursor: pointer;
}

.value-link.forecast-positive {
    color: var(--success-color);
}

.value-link.forecast-negative {
    color: var(--error-color);
}

.data-table th {
    cursor: pointer;
    user-select: none;
}

.data-table.uniform {
    table-layout: fixed;
}

.data-table.uniform th,
.data-table.uniform td {
    padding: 0.7rem 0.8rem;
    font-size: 0.78rem;
}

.data-table.uniform th {
    white-space: normal;
    line-height: 1.1;
}

.data-table.uniform td {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.data-table.uniform td:nth-child(2) {
    white-space: normal;
    line-height: 1.2;
}

.table-switch {
    display: inline-flex;
    align-items: center;
    position: relative;
}

.table-switch input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    appearance: none;
    -webkit-appearance: none;
}

.table-switch .table-slider {
    width: 30px;
    height: 16px;
    border-radius: 999px;
    background: rgba(255,255,255,0.12);
    position: relative;
    transition: background 0.2s ease;
}

.table-switch .table-slider::after {
    content: '';
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #fff;
    position: absolute;
    top: 2px;
    left: 2px;
    transition: transform 0.2s ease;
}

.table-switch input:checked + .table-slider {
    background: rgba(124, 58, 237, 0.6);
}

.table-switch input:checked + .table-slider::after {
    transform: translateX(14px);
}

.cell-center {
    text-align: center;
    vertical-align: middle;
}

.modal-compact {
    max-width: 560px;
    max-height: 70vh;
    overflow: hidden;
}

.modal-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    gap: 1rem;
}

.section-meta {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.debit-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}

.debit-card {
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.03);
    border-radius: 16px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.debit-card.clickable {
    cursor: pointer;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.debit-card.clickable:hover {
    transform: translateY(-2px);
    border-color: rgba(124, 58, 237, 0.35);
}

.debit-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.debit-title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.debit-top .badge {
    flex-shrink: 0;
}

.debit-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.3rem 0.4rem;
    flex-wrap: wrap;
}

.debit-meta .theme-badge {
    padding: 0.18rem 0.5rem;
    font-size: 0.65rem;
    border-radius: 999px;
}

.debit-meta .debit-dot {
    opacity: 0.5;
}

.debit-amount {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
}

.canvas-wrapper {
    position: relative;
    height: 300px;
    width: 100%;
}

.progress-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Budget Bars Display */
.budget-bars-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.budget-bar-item {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.bar-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    font-weight: 500;
}

.bar-track {
    height: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    border-radius: 10px;
    transition: width 1s cubic-bezier(0.19, 1, 0.22, 1);
}

.bar-fill.safe {
    background: linear-gradient(90deg, #10b981, #34d399);
}

.bar-fill.warning {
    background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.bar-fill.danger {
    background: linear-gradient(90deg, #ef4444, #f87171);
}

/* Buttons */
.btn {
    padding: 0.85rem 1.75rem;
    border-radius: 14px;
    cursor: pointer;
    border: none;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(124, 58, 237, 0.3);
}

.btn-icon-only {
    padding: 0.85rem;
    border-radius: 12px;
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 8px;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--primary-color);
}

.btn-icon.delete:hover {
    color: var(--error-color);
    background: rgba(239, 68, 68, 0.1);
}

/* Config Design */
.config-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.config-card {
    padding: 2rem;
    border-radius: 24px;
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 2rem;
    color: var(--primary-color);
}

.budget-inputs {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

input,
select {
    background: rgba(255, 255, 255, 0.04) !important;
    border: 1px solid var(--glass-border) !important;
    padding: 0.85rem 1rem;
    border-radius: 12px;
    color: var(--text-main) !important;
    outline: none;
    font-size: 1rem;
    transition: all 0.2s;
    width: 100%;
}

select {
    appearance: none;
    cursor: pointer;
    padding-right: 2.5rem !important;
}

input:focus,
select:focus {
    border-color: var(--primary-color) !important;
    background: rgba(255, 255, 255, 0.08) !important;
    box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.1);
}

select option {
    background-color: var(--sidebar-bg);
    color: var(--text-main);
}

/* Hide native arrows */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -webkit-appearance: none;
    -moz-appearance: textfield;
    appearance: none;
}

/* Custom Steppers */
.input-stepper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.stepper-btns {
    position: absolute;
    right: 0.5rem;
    /* Move to right */
    display: flex;
    flex-direction: column;
    gap: 2px;
    z-index: 5;
    opacity: 0;
    transition: opacity 0.2s;
}

.input-stepper:hover .stepper-btns {
    opacity: 1;
}

.stepper-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    width: 20px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    cursor: pointer;
    padding: 0;
}

.stepper-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.stepper-btn i {
    width: 12px;
    height: 12px;
}

.input-stepper input {
    padding-left: 1rem !important;
    /* Normal padding on left */
    padding-right: 3rem !important;
    /* Space for buttons on right */
}

.input-row {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.input-with-currency {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1;
}

.input-with-currency input {
    width: 100%;
    background: rgba(255, 255, 255, 0.04) !important;
    border: 1px solid var(--glass-border) !important;
    padding: 0.85rem 3rem 0.85rem 1rem !important;
    /* Adjusted padding */
    border-radius: 12px;
    color: white !important;
    outline: none;
    font-size: 1rem;
}

.input-with-currency span {
    position: absolute;
    right: 2.25rem;
    /* Left of the buttons */
    color: var(--text-secondary);
    font-weight: 600;
    pointer-events: none;
    font-size: 0.8rem;
    opacity: 0.7;
}

.quick-add {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.75rem;
    padding-top: 1.75rem;
    border-top: 1px solid var(--glass-border);
}

.quick-add input,
.quick-add select {
    background: rgba(255, 255, 255, 0.04) !important;
    border: 1px solid var(--glass-border) !important;
    padding: 0.85rem 1rem;
    border-radius: 12px;
    color: white !important;
    outline: none;
    font-size: 0.95rem;
    flex: 1;
    min-width: 0;
}

.quick-add input[type="text"] {
    flex: 2;
}

.quick-add .input-with-currency {
    flex: 1;
}


/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.modal {
    width: 100%;
    max-width: 500px;
    background: var(--sidebar-bg);
    border: 1px solid var(--glass-border);
    border-radius: 28px;
    overflow: hidden;
    animation: pop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    flex-direction: column;
}

@keyframes pop {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    padding: 1.5rem 2.5rem;
    border-bottom: 1px solid var(--glass-border);
}

.modal-body {
    padding: 2.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Custom Toggle Switch */
.toggle-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.03);
    padding: 1rem 1.25rem;
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    cursor: pointer;
    transition: all 0.2s;
}

.toggle-wrapper:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.2);
}

.toggle-label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.toggle-label .title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-main);
}

.toggle-label .sub {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    transition: .4s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

input:checked+.slider {
    background-color: var(--primary-color);
}

input:focus+.slider {
    box-shadow: 0 0 1px var(--primary-color);
}

input:checked+.slider:before {
    transform: translateX(20px);
}

/* Red-ish toggle when 'Deactivate' is active? No, let's stick to primary unless it's a danger state.
   Actually, since the user asked for "Deaktivieren", maybe a warning color when checked?
   Let's use a subtle red for "Deactivated" state if we want to be fancy.
*/
.switch.danger input:checked+.slider {
    background-color: var(--error-color);
}


.modal-footer {
    padding: 1.5rem 2.5rem;
    background: rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

/* Utility */
.tag-manager {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.tag {
    background: rgba(124, 58, 237, 0.08);
    color: var(--primary-color);
    padding: 0.6rem 0.9rem;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid rgba(124, 58, 237, 0.15);
}

.tag button {
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    font-size: 1rem;
}

.table-container {
    border-radius: 24px;
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    overflow-x: hidden;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.data-table th {
    text-align: left;
    padding: 1.25rem 1.5rem;
    background: rgba(255, 255, 255, 0.02);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
}

.data-table td {
    padding: 1.25rem 1.5rem;
    border-top: 1px solid var(--glass-border);
    overflow: hidden;
    text-overflow: ellipsis;
}

.data-table th:first-child,
.data-table td:first-child {
    width: 36px;
    min-width: 36px;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
    overflow: visible;
}

.data-table.uniform th:last-child,
.data-table.uniform td:last-child {
    padding-right: 0.35rem;
    padding-left: 0.6rem;
}

@media (max-width: 1600px) {
    .data-table th,
    .data-table td {
        padding: 0.85rem 1rem;
        font-size: 0.8rem;
    }

    .data-table th {
        letter-spacing: 0.5px;
    }

    .badge,
    .user-pill,
    .theme-pill {
        padding: 0.25rem 0.6rem;
        font-size: 0.7rem;
    }

    .table-switch .table-slider {
        width: 26px;
        height: 14px;
    }

    .table-switch .table-slider::after {
        width: 10px;
        height: 10px;
        top: 2px;
        left: 2px;
    }

    .table-switch input:checked + .table-slider::after {
        transform: translateX(12px);
    }
}

@media (max-width: 1350px) {
    .data-table th,
    .data-table td {
        padding: 0.6rem 0.7rem;
        font-size: 0.74rem;
    }

    .data-table th {
        white-space: normal;
        line-height: 1.1;
    }

    .badge,
    .user-pill,
    .theme-pill {
        padding: 0.2rem 0.5rem;
        font-size: 0.68rem;
    }
}

@media (max-width: 1400px) {
    .cashflow-header {
        flex-wrap: wrap;
        gap: 1rem;
    }

    .cashflow-summary {
        flex-wrap: wrap;
        justify-content: flex-start;
        gap: 0.75rem 1.25rem;
        font-size: 0.85rem;
    }

    .cashflow-grid {
        grid-template-columns: repeat(7, minmax(150px, 1fr));
        gap: 0.75rem;
    }

    .cashflow-cell {
        min-height: 120px;
    }

    .cashflow-day {
        font-size: 0.8rem;
    }

    .cashflow-event {
        font-size: 0.7rem;
    }
}

@media (max-width: 1500px) {
    .budget-overview-grid {
        grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    }

    .budget-card {
        padding: 0.85rem;
    }
}

@media (max-width: 1100px) {
    .cashflow-grid {
        grid-auto-flow: column;
        grid-auto-columns: minmax(180px, 1fr);
        overflow-x: auto;
        padding-bottom: 0.5rem;
        -webkit-overflow-scrolling: touch;
    }
}

.user-pill {
    background: rgba(255, 255, 255, 0.05);
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.badge {
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.badge.secondary {
    background: rgba(124, 58, 237, 0.1);
    color: var(--primary-color);
}

.theme-badge,
.theme-pill {
    border: 1px solid transparent;
}

.theme-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.theme-color-input {
    width: 26px;
    height: 22px;
    border: none;
    padding: 0;
    background: transparent;
    cursor: pointer;
}

.theme-color-input::-webkit-color-swatch-wrapper {
    padding: 0;
}

.theme-color-input::-webkit-color-swatch {
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.text-right {
    text-align: right;
}

.text-center {
    text-align: center;
}

.font-bold {
    font-weight: 700;
}

.font-medium {
    font-weight: 600;
}

/* Startup Modal Specifics */
.startup-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-top: 1rem;
}

.option-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    padding: 1.5rem;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    text-align: center;
}

.option-card:hover {
    background: rgba(124, 58, 237, 0.08);
    border-color: var(--primary-color);
    transform: translateY(-4px);
}

.option-card i {
    width: 32px;
    height: 32px;
    color: var(--primary-color);
}

.option-card h4 {
    font-size: 1rem;
    font-weight: 700;
}

.option-card p {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Row states */
.row-inactive {
    opacity: 0.4;
    filter: grayscale(0.5);
}

.row-locked {
    background: rgba(0, 0, 0, 0.1);
}

.search-highlight {
    animation: searchGlow 1.6s ease;
    box-shadow: inset 0 0 0 2px rgba(124, 58, 237, 0.6);
    border-radius: 10px;
}

@keyframes searchGlow {
    0% {
        background: rgba(124, 58, 237, 0.2);
    }
    100% {
        background: transparent;
    }
}

/* Unified Config Item Design */
.config-item-card {
    background: rgba(255, 255, 255, 0.02);
    padding: 1.25rem;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.04);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    transition: all 0.3s ease;
}

.config-item-card:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.08);
}

.config-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.25rem;
}

.config-item-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--primary-color);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.config-item-name-input {
    background: transparent !important;
    border: none !important;
    border-bottom: 1px solid var(--glass-border) !important;
    border-radius: 0 !important;
    padding: 0.25rem 0 !important;
    font-weight: 600 !important;
    font-size: 0.95rem !important;
    color: var(--text-main) !important;
    width: auto !important;
    min-width: 150px;
}

.config-item-name-input:focus {
    border-bottom-color: var(--primary-color) !important;
}

.config-item-body {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.transfer-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
}

.transfer-row select {
    flex: 1;
    min-width: 0;
    /* Allow shrinking */
}

.transfer-row i {
    flex-shrink: 0;
}

.transfer-row i {
    width: 16px;
    height: 16px;
    opacity: 0.5;
    color: var(--primary-color);
}

/* Drag and Drop Styles */
.drag-handle {
    cursor: grab;
    color: var(--text-secondary);
    opacity: 0.3;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    touch-action: none;
}

.drag-handle:hover {
    opacity: 1;
    color: var(--primary-color);
}

.drag-handle:active {
    cursor: grabbing;
}

.sortable-ghost {
    opacity: 0.4;
    background: var(--primary-color) !important;
    border: 2px dashed var(--primary-color) !important;
}

.sortable-chosen {
    background: rgba(255, 255, 255, 0.05) !important;
}

/* Specific adjustments for handles in different views */
.expenses-table th:first-child,
.expenses-table td:first-child {
    width: 40px;
    text-align: center;
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 1.5rem;
    left: 1.5rem;
    z-index: 10000;
    background: var(--primary-color);
    border: none;
    border-radius: 12px;
    padding: 0.75rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
    transition: all 0.3s;
}

.mobile-menu-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(124, 58, 237, 0.4);
}

.mobile-menu-toggle i {
    width: 24px;
    height: 24px;
    color: white;
}

/* Mobile Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 9998;
    opacity: 0;
    transition: opacity 0.3s;
}

.sidebar-overlay.active {
    opacity: 1;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    body {
        overflow: auto;
        /* Allow native scrolling */
    }

    .app-container {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
        overflow: visible;
    }

    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        height: 100vh;
        z-index: 9999;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        overflow-y: auto;
        box-shadow: 2px 0 20px rgba(0, 0, 0, 0.5);
    }

    .sidebar.active {
        left: 0;
    }

    .sidebar-overlay {
        display: block;
        pointer-events: none;
        /* Don't block clicks when hidden */
        opacity: 0;
    }

    .sidebar-overlay.active {
        pointer-events: auto;
        /* Block clicks when visible */
        opacity: 1;
    }

    /* Fix Layout on Mobile */
    .overview-details-grid {
        grid-template-columns: 1fr !important;
        gap: 1.5rem !important;
    }

    .glass {
        padding: 1.25rem !important;
        /* Reduce padding on mobile */
    }

    .bar-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
        margin-bottom: 0.5rem;
        width: 100%;
    }

    .bar-info span {
        word-break: break-word;
        /* Allow wrap to ensure text is visible */
        line-height: 1.3;
    }

    .budget-bar-item {
        min-width: 0;
        /* Prevent flexbox overflow issues */
    }

    .main-content {
        width: 100%;
        padding: 5rem 1.5rem 6rem 1.5rem;
        /* More bottom padding for mobile */
        overflow: visible;
        height: auto;
        flex: none;
    }

    .view-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .header-actions {
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
        gap: 1rem;
    }

    .stats-grid {
        grid-template-columns: 1fr !important;
    }

    .dashboard-grid {
        grid-template-columns: 1fr !important;
    }

    .config-layout {
        grid-template-columns: 1fr !important;
    }

    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-right: -1rem;
        /* Allow scroll to edge */
        padding-right: 1rem;
    }

    .data-table {
        min-width: 900px;
    }

    /* Compact tables on mobile: keep first 3 columns + actions */
    .data-table th:nth-child(n + 4):not(:last-child),
    .data-table td:nth-child(n + 4):not(:last-child) {
        display: none;
    }

    .modal {
        max-width: 90% !important;
        margin: 1rem;
        max-height: 90vh;
        overflow-y: auto;
    }

    .form-row {
        grid-template-columns: 1fr !important;
    }

    .debit-grid {
        grid-auto-flow: column;
        grid-auto-columns: minmax(220px, 1fr);
        overflow-x: auto;
        padding-bottom: 0.5rem;
        -webkit-overflow-scrolling: touch;
    }

    .cashflow-grid {
        grid-auto-flow: column;
        grid-auto-columns: minmax(220px, 1fr);
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 0.5rem;
    }

    /* Better touch targets */
    .btn,
    .btn-icon,
    .nav-item {
        min-height: 44px;
    }
}

@media (max-width: 1200px) {
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-right: -1rem;
        padding-right: 1rem;
    }

    .data-table {
        min-width: 780px;
    }

    .value-mask {
        display: none !important;
    }
}
