:root {
    --primary-color: #2c3e50;
    --accent-color: #3498db;
    --bg-color: #f4f7f6;
    --card-bg: #ffffff;
    --text-color: #333;
    --success-color: #27ae60;
    --error-color: #e74c3c;
    --sidebar-width: 250px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Sidebar Styling */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--primary-color);
    color: white;
    padding: 20px;
    height: 100vh;
    position: fixed;
    transition: all 0.3s;
    z-index: 1000;
}

.sidebar h2 {
    margin-bottom: 30px;
    text-align: center;
}

.sidebar a {
    color: #bdc3c7;
    text-decoration: none;
    display: block;
    padding: 12px;
    border-radius: 5px;
    margin-bottom: 5px;
}

.sidebar a:hover, .sidebar a.active {
    background-color: var(--accent-color);
    color: white;
}

/* Main Content Area */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 20px;
    transition: all 0.3s;
    width: calc(100% - var(--sidebar-width));
    min-width: 0;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    background: white;
    padding: 15px 25px;
    border-radius: 10px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    gap: 14px;
}

.top-bar-title {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1 1 auto;
}

.top-bar-title h1 {
    margin: 0;
    line-height: 1.15;
}

.top-bar-cycle {
    margin-top: 4px;
    font-size: 0.92rem;
    color: #5f6973;
}

.top-bar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

.topbar-action-link {
    white-space: nowrap;
    padding: 8px 12px;
    font-size: 0.9rem;
}

.hamburger {
    display: none;
    font-size: 24px;
    cursor: pointer;
}

/* Cards & Layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.card {
    background: var(--card-bg);
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.stat-card {
    text-align: center;
}

.stat-card h3 {
    font-size: 0.9em;
    color: #7f8c8d;
    margin-bottom: 10px;
}

.amount {
    font-size: 1.8em;
    font-weight: bold;
}

.positive { color: var(--success-color); }
.negative { color: var(--error-color); }

/* Forms */
.grid-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    align-items: end;
}

.funding-form {
    grid-template-columns: minmax(0, 1fr) 170px auto auto;
}

.manual-funding-form {
    grid-template-columns: minmax(0, 1fr) 170px auto;
}

input, select, button {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
}

.btn {
    background-color: var(--accent-color);
    color: white;
    border: none;
    cursor: pointer;
    font-weight: bold;
}

.btn:hover { background-color: #2980b9; }

/* Tables */
.responsive-table {
    width: 100%;
    border-collapse: collapse;
}

.responsive-table th, .responsive-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.btn-table {
    padding: 5px 10px;
    font-size: 12px;
    cursor: pointer;
}

.btn-reset {
    background-color: var(--error-color);
    color: white;
    border: none;
}

/* Mobile Responsive */
/* Filtry w tabeli */
.filter-input {
    width: 100%;
    padding: 5px;
    font-size: 0.8em;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-sizing: border-box;
}
.filter-row th {
    padding: 5px !important;
    background: #f9f9f9 !important;
}

.mobile-filter-panel {
    display: none;
}

@media (max-width: 768px) {
    .sidebar {
        left: 0;
        transform: translateX(-102%);
        pointer-events: none;
    }
    
    .sidebar.active {
        transform: translateX(0);
        pointer-events: auto;
    }
    
    .main-content {
        margin-left: 0;
        width: 100%;
    }
    
    .top-bar {
        display: grid;
        grid-template-columns: auto 1fr;
        align-items: center;
        gap: 10px;
        padding: 12px 14px;
    }

    .top-bar-title {
        grid-column: 2 / -1;
    }

    .top-bar-actions {
        grid-column: 1 / -1;
        justify-content: flex-end;
        flex-wrap: wrap;
    }

    .topbar-action-link {
        flex: 0 1 auto;
    }

    .top-bar h1 {
        margin: 0;
        font-size: clamp(1.55rem, 6vw, 2.15rem);
        line-height: 1.15;
        overflow-wrap: anywhere;
    }

    .top-bar .user-info {
        grid-column: 1 / -1;
        justify-self: end;
        font-size: 0.9rem;
        overflow-wrap: anywhere;
        text-align: right;
    }

    .hamburger {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 44px;
        min-height: 44px;
        line-height: 1;
        position: relative;
        z-index: 1205;
    }

    .responsive-table thead {
        display: none;
    }

    .mobile-filter-panel {
        display: grid;
        gap: 8px;
        margin-bottom: 12px;
    }

    .mobile-filter-panel input {
        width: 100%;
    }

    .responsive-table tr {
        display: block;
        margin-bottom: 15px;
        border: 1px solid #ddd;
        border-radius: 5px;
        padding: 10px;
    }

    .responsive-table td {
        display: block;
        text-align: right;
        border: none;
        padding: 5px 0;
    }

    .responsive-table td::before {
        content: attr(data-label);
        float: left;
        font-weight: bold;
    }

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

    .funding-form,
    .manual-funding-form,
    #recurring-form,
    #bank-form,
    #account-form {
        grid-template-columns: 1fr !important;
    }

    .form-actions-row,
    .recurring-form-actions {
        grid-column: 1 / -1 !important;
        flex-direction: column !important;
        align-items: stretch;
    }

    .form-actions-row > *,
    .recurring-form-actions > * {
        width: 100%;
    }

    .grid-form > * {
        min-width: 0;
        grid-column: 1 / -1 !important;
    }

    .grid-form input,
    .grid-form select,
    .grid-form button {
        width: 100%;
    }

    .form-group {
        width: 100%;
        grid-column: span 1 !important;
    }

    .btn {
        grid-column: span 1 !important;
    }

    .sidebar-install-box {
        margin: 16px 8px 8px;
    }
}

/* Auth Pages */
.login-container {
    width: 100%;
    max-width: 400px;
    margin: 100px auto;
    padding: 30px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    text-align: center;
}

.login-container h1 { margin-bottom: 25px; }
.login-container input { width: 100%; margin-bottom: 15px; }
.login-container .btn { width: 100%; padding: 12px; }

.login-brand-label {
    margin: -6px 0 18px;
    font-size: 0.88rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #5f6a72;
}

.error { color: var(--error-color); margin-bottom: 15px; font-size: 0.9em; }
.success { color: var(--success-color); margin-bottom: 15px; font-size: 0.9em; }

/* Sidebar Styles Updates */
.sidebar {
    display: flex !important;
    flex-direction: column !important;
}

.sidebar h2 {
    margin-bottom: 20px;
}

.sidebar-stats {
    transition: background 0.3s;
}

.sidebar-stats:hover {
    background: rgba(255,255,255,0.1) !important;
}

.sidebar-stats strong {
    font-family: 'Courier New', Courier, monospace;
}

.sidebar a.active {
    background: var(--primary);
    color: white;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1200;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    background-color: var(--card-bg);
    margin: 5% auto;
    padding: 25px;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    position: relative;
    animation: modalFadeIn 0.3s ease-out;
}

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

.close-modal {
    position: absolute;
    right: 20px;
    top: 15px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: #999;
}

.close-modal:hover {
    color: var(--error-color);
}

.modal h3 {
    margin-bottom: 20px;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

.modal-group {
    margin-bottom: 15px;
}

.modal-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 0.9em;
    font-weight: 600;
    color: #555;
}

.modal-group select, .modal-group input {
    width: 100%;
}

/* Login page custom scene */
body.login-page {
    display: block;
    min-height: 100vh;
    background-color: #d7d7d7;
    position: relative;
    overflow-x: hidden;
}

body.login-page::before {
    content: "";
    position: fixed;
    inset: 0;
    background-image: url('login-bg-art.svg');
    background-repeat: no-repeat;
    background-size: min(900px, 95vw) auto;
    background-position: center 44%;
    opacity: 0.3;
    pointer-events: none;
    z-index: 0;
}

.login-screen {
    position: relative;
    min-height: 100vh;
    z-index: 1;
    display: flex;
    flex-direction: column;
}

.login-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 36px 20px 22px;
    gap: 14px;
}

body.login-page .login-container {
    margin: 0;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(0, 0, 0, 0.07);
    backdrop-filter: blur(2px);
}

.pwa-install-box {
    width: 100%;
    max-width: 400px;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(44, 62, 80, 0.18);
    border-radius: 10px;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.1);
    padding: 14px 16px;
    text-align: center;
}

.pwa-install-box p {
    margin: 8px 0 12px;
    font-size: 0.9rem;
    color: #4f5b66;
}

.pwa-install-box .btn {
    width: 100%;
}

.demo-login-box {
    width: 100%;
    max-width: 400px;
    background: rgba(255, 248, 225, 0.94);
    border: 1px solid rgba(192, 157, 45, 0.35);
    border-radius: 10px;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.08);
    padding: 14px 16px;
    text-align: left;
    color: #4d3b17;
}

.demo-login-box strong {
    display: block;
    margin-bottom: 8px;
    font-size: 0.95rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.demo-login-box p {
    margin: 4px 0;
    font-size: 0.92rem;
    color: #4d3b17;
}

.sidebar-install-box {
    margin: 18px 10px 8px;
    width: auto;
}

.sidebar-install-box p {
    color: #c9d2db;
    font-size: 0.84rem;
    line-height: 1.45;
}

.login-footer {
    text-align: center;
    font-size: 0.88rem;
    color: #3f454a;
    padding: 10px 12px 8px;
}

.login-footer a {
    color: #2b4f74;
    text-decoration: none;
    font-weight: 600;
}

.login-footer a:hover {
    text-decoration: underline;
}

.password-visibility-row {
    margin: -8px 0 10px;
}

.password-visibility-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    color: #5f6973;
    user-select: none;
}

.password-visibility-toggle input[type="checkbox"] {
    width: 14px;
    height: 14px;
    padding: 0;
    margin: 0;
}

.help-hero {
    margin-bottom: 20px;
}

.help-hero p {
    line-height: 1.7;
    color: #4d5964;
}

.help-toc {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px;
}

.help-toc a {
    display: block;
    padding: 12px 14px;
    border-radius: 10px;
    background: #f7f9fb;
    color: #2c3e50;
    text-decoration: none;
    border: 1px solid #e3e8ee;
    font-weight: 600;
}

.help-toc a:hover {
    background: #edf5fb;
    border-color: #cfe2f3;
}

.help-section {
    scroll-margin-top: 18px;
}

.help-section h3 {
    margin-bottom: 12px;
}

.help-list {
    margin: 0;
    padding-left: 20px;
    line-height: 1.7;
    color: #38434f;
}

.help-list li + li {
    margin-top: 8px;
}

.help-note {
    background: #f4f8ff;
    border-left: 4px solid #3498db;
    padding: 14px 16px;
    border-radius: 10px;
    color: #37506b;
}

.help-tip {
    margin-top: 12px;
    font-size: 0.95rem;
    color: #66737f;
}

.scroll-top-btn {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 1100;
    min-width: 58px;
    padding: 10px 14px;
    border-radius: 999px;
    border: none;
    background: #1f6aa5;
    color: #fff;
    font-weight: 700;
    font-size: 0.9rem;
    letter-spacing: 0.2px;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
    cursor: pointer;
}

.scroll-top-btn:hover {
    background: #14507f;
}

@media (max-width: 768px) {
    .scroll-top-btn {
        right: 14px;
        bottom: 14px;
        min-width: 48px;
        width: 48px;
        height: 48px;
        padding: 0;
        border-radius: 50%;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        opacity: 0;
        transform: translateY(10px);
        pointer-events: none;
        transition: opacity 0.2s ease, transform 0.2s ease;
    }

    .scroll-top-btn.is-visible {
        opacity: 0.95;
        transform: translateY(0);
        pointer-events: auto;
    }
}

@media (max-width: 768px) {
    body.login-page::before {
        background-size: min(640px, 100vw) auto;
        background-position: center 40%;
    }

    .login-main {
        justify-content: flex-start;
        padding-top: 48px;
    }

    .login-footer {
        padding: 8px 12px 4px;
        margin-top: -8px;
    }
}

@media (max-width: 900px) {
    #recurring-form {
        grid-template-columns: 1fr !important;
    }

    #recurring-form .form-group {
        grid-column: 1 / -1 !important;
    }

    #recurring-form .recurring-form-actions {
        grid-column: 1 / -1 !important;
        flex-direction: column;
    }

    #recurring-form .recurring-form-actions .btn {
        width: 100%;
    }

    .funding-form,
    .manual-funding-form {
        grid-template-columns: 1fr !important;
    }

    .funding-form .btn,
    .manual-funding-form .btn {
        width: 100%;
    }
}
