:root {
    --font-family-base: Arial, sans-serif;
    --heading-color: #14213d;
    --heading-line-height: 1.2;
    --heading-weight: 700;
    --heading-margin-bottom: 0.75rem;
}

body {
    font-family: var(--font-family-base);
    margin: 0;
    color: #14213d;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-family-base);
    color: var(--heading-color);
    line-height: var(--heading-line-height);
    font-weight: var(--heading-weight);
    margin: 0 0 var(--heading-margin-bottom) 0;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.4rem; }
h4 { font-size: 1.15rem; }
h5 { font-size: 1rem; }
h6 { font-size: 0.95rem; }

.modal-header h3,
.project-folder-group h4,
.login-header h1,
.card h3,
.card h4,
.section-title,
.page-title {
    font-family: var(--font-family-base);
    color: var(--heading-color);
    line-height: var(--heading-line-height);
    font-weight: var(--heading-weight);
    margin: 0 0 var(--heading-margin-bottom) 0;
}

.layout {
    min-height: 100vh;
    background: transparent;
}

.layout.login-background {
    background-image: url('/tlo_page_login.jpg');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    background-repeat: no-repeat;
}

.layout.soft-background {
    background: radial-gradient(circle at top center, rgba(14, 29, 57, 0.08), transparent 30%),
                linear-gradient(180deg, rgba(4, 10, 24, 0.04), rgba(6, 16, 34, 0.07));
}

.login-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 24px 120px 24px 24px;
}

.login-card {
    width: min(420px, 100%);
    background: linear-gradient(180deg, rgba(5, 16, 35, 0.92) 0%, rgba(13, 29, 56, 0.96) 100%);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 32px;
    box-shadow: 0 42px 100px rgba(0, 0, 0, 0.36);
    overflow: hidden;
    backdrop-filter: blur(28px);
}

.login-panel {
    display: grid;
    gap: 24px;
    padding: 32px;
}

.login-form {
    display: grid;
    gap: 18px;
}

.input-group {
    display: grid;
    gap: 8px;
}

.input-group label {
    color: #d3d7e1;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.input-group input {
    width: 100%;
    max-width: 100%;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.12);
    color: white;
    outline: none;
    box-sizing: border-box;
}

.input-group input::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

.btn-primary {
    width: 100%;
    padding: 16px 0;
    border: none;
    border-radius: 16px;
    background: linear-gradient(135deg, #f2c777 0%, #b38a46 100%);
    color: #09111a;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    cursor: pointer;
    box-shadow: 0 20px 40px rgba(17, 25, 51, 0.22);
}

.btn-primary:hover {
    filter: brightness(1.03);
}

.login-footer {
    text-align: center;
    color: #d3d7e1;
    font-size: 0.95rem;
}

.login-footer span {
    text-decoration: underline;
    cursor: pointer;
}

.layout {
    min-height: 100vh;
    background: transparent;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    padding: 12px 0 18px;
    border-bottom: 1px solid rgba(20, 33, 61, 0.1);
}

.userbar {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

.user-role {
    color: #5b6472;
    font-weight: 500;
}

.topnav ul {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    list-style: none;
    padding: 0;
    margin: 0;
}

.topnav .nav-link {
    color: #14213d;
    font-weight: 600;
}

.sidebar h1 {
    margin: 0 0 8px;
}

.subtitle {
    color: #9fb4cf;
    margin-bottom: 24px;
}

.userbox {
    background: rgba(255,255,255,0.09);
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 16px;
}

nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-link {
    color: white;
    text-decoration: none;
    display: block;
    padding: 8px 0;
}

.main-content {
    padding: 24px;
}

.content {
    display: grid;
    gap: 16px;
}

.card, .stat {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

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

form {
    display: grid;
    gap: 10px;
    max-width: 640px;
}

input, select, textarea, button {
    font: inherit;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid #d0d7de;
}

button {
    background: #2f6fed;
    color: white;
    border: none;
    cursor: pointer;
}

/* Ensure action buttons in investments list use consistent font and weight */
.investment-list button,
.investment-list .btn-secondary,
.investment-list .btn-primary,
.investment-list .edit-investment-row-btn,
.investment-list .manage-subcontractors-row-btn {
    font-family: Arial, sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
}

.btn-secondary {
    background: #ffffff;
    color: #14213d;
    border: 1px solid #d0d7de;
    padding: 10px 18px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 700;
}

.table-action-button,
.table-action-button:link,
.table-action-button:visited,
.table-action-button:hover,
.table-action-button:focus {
    min-height: 28px;
    padding: 6px 12px;
    line-height: 1.1;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

.modal .btn-secondary,
.modal .btn-primary {
    min-height: 32px;
    padding: 6px 12px;
    line-height: 1.2;
}

.section-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 16px;
}

.investment-card-link {
    color: inherit;
    text-decoration: none;
}

.investment-card-link .card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.investment-card-link .card:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 18px rgba(0,0,0,0.12);
}

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
}

.investment-nav {
    background: #f8fafc;
    border-bottom: 1px solid #e6eef8;
    padding: 8px 16px;
    margin-bottom: 14px;
}
.investment-nav-inner {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}
.investment-nav .nav-link {
    display: inline-block;
    padding: 8px 12px;
    border-radius: 12px;
    background: transparent;
    color: #14213d;
    text-decoration: none;
    font-weight: 600;
    border: 1px solid transparent;
    touch-action: manipulation;
}
.investment-nav .nav-link.assigned {
    background: #ffffff;
    border-color: #d0d7de;
}
.investment-nav .nav-link.unassigned {
    opacity: 0.6;
    color: #6b7280;
}

.tab-button {
    padding: 10px 18px;
    border-radius: 12px;
    border: 1px solid #d0d7de;
    background: #ffffff;
    color: #14213d;
    cursor: pointer;
    font-weight: 600;
}

.tab-button.active {
    background: #2f6fed;
    color: white;
    border-color: #2f6fed;
}

/* Unassigned modules appear muted and open assignment modal when clicked */
.tab-button.unassigned {
    opacity: 0.55;
    filter: grayscale(10%);
}
.tab-button.unassigned:hover {
    opacity: 0.85;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(8, 17, 34, 0.75);
    z-index: 1000;
    padding: 24px;
}

.modal.hidden {
    display: none;
}

.modal-content {
    width: min(860px, calc(100% - 48px));
    max-width: 860px;
    max-height: calc(100vh - 64px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 24px 70px rgba(0,0,0,0.18);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

/* Align percent form controls inside modal */
.modal .task-percent-form {
    display: flex !important;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}
.modal .task-percent-form output {
    width: 44px;
    text-align: center;
}
.modal .task-percent-form input[type=range] {
    appearance: none;
    height: 6px;
    border-radius: 6px;
}
.modal .task-percent-form button.btn-primary {
    min-width: 140px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 28px;
    border-bottom: 1px solid #e9ecef;
    flex-shrink: 0;
}

.modal-body {
    overflow-y: auto;
    padding: 20px 24px 54px; /* increased bottom padding to ensure visible gap above footer */
    flex: 1 1 auto;
}

/* Scrollable modal body variant with height cap for upload form */
.modal-body-scroll {
    max-height: calc(100vh - 180px);
    overflow-y: auto;
}

/* Custom scrollbar styling */
.modal-body-scroll::-webkit-scrollbar {
    width: 10px;
}
.modal-body-scroll::-webkit-scrollbar-track {
    background: transparent;
}
.modal-body-scroll::-webkit-scrollbar-thumb {
    background: rgba(16,24,40,0.15);
    border-radius: 8px;
}
.modal-body-scroll::-webkit-scrollbar-thumb:hover {
    background: rgba(16,24,40,0.25);
}
/* Firefox */
.modal-body-scroll {
    scrollbar-width: thin;
    scrollbar-color: rgba(16,24,40,0.15) transparent;
}

/* Ensure producers list leaves space above modal footer */
.producers-list {
    padding-bottom: 30px;
    border-bottom: none !important; /* remove any visible divider on the container */
}

/* Ensure last list item doesn't draw a border flush with the footer and add extra bottom space */
.producers-list ul {
    padding-bottom: 30px;
}
.producers-list ul li:last-child {
    border-bottom: none !important;
}

/* add explicit spacer at end of producers list to guarantee gap above footer */
.producers-list::after {
    content: '';
    display: block;
    height: 15px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    padding: 15px 24px 24px; /* 15px top spacing per request */
    margin-top: 15px; /* ensure visible gap between content divider and footer */
    gap: 10px;
}

.modal-footer .btn-secondary {
    padding: 0.35rem 0.7rem;
    font-size: 0.8rem;
    min-height: 24px;
    line-height: 1.05;
}

/* Ensure footer close buttons use normal button sizing instead of header close styling */
.modal-footer .modal-close {
    font-size: 0.8rem;
    background: #f8fafc;
    border: 1px solid #d1d5db;
    padding: 0.35rem 0.7rem;
    border-radius: 8px;
    color: inherit;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.2rem;
    font-family: var(--font-family-base);
    font-weight: var(--heading-weight);
    color: var(--heading-color);
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
}

.modal .btn-secondary {
    padding: 0.6rem 1rem;
    border-radius: 8px;
    border: 1px solid #d1d5db;
    background: #f8fafc;
    color: #0f172a;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
    min-height: 40px;
}

.modal .btn-secondary:hover {
    background: #e2e8f0;
    border-color: #cbd5e1;
}

.modal .btn-primary {
    min-height: 40px;
    padding: 0.6rem 1rem;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.2;
}

.modal form {
    padding: 20px 24px 24px;
    gap: 12px;
    display: grid;
}

.modal input,
.modal select,
.modal textarea {
    font-size: 0.98rem;
    padding: 10px 12px;
}

.modal textarea {
    min-height: 120px;
}

.modal button[type="submit"] {
    padding: 12px 18px;
    font-size: 0.98rem;
    color: white;
    background: #2f6fed;
    border: none;
    border-radius: 10px;
    cursor: pointer;
}

.table-error-message {
    color: #a4262c;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

th, td {
    padding: 12px;
    border-bottom: 1px solid #e9ecef;
    text-align: left;
}

th {
    background: #f2f5f8;
}

.module-assignment-form {
    max-width: none;
    gap: 14px;
}

.module-button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.module-choice-btn {
    display: grid;
    gap: 4px;
    justify-items: start;
    padding: 12px 14px;
    border: 1px solid #d0d7de;
    border-radius: 999px;
    background: #f8fafc;
    color: #14213d;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

/* hide native checkbox inputs used for module selection */
.module-button-row input[type="checkbox"] { display: none; }

/* style label when its preceding checkbox is checked */
.module-button-row input[type="checkbox"]:checked + label.module-choice-btn,
.module-choice-btn.active {
    background: #2f6fed;
    border-color: #2f6fed;
    color: white;
}

.module-choice-btn:hover {
    transform: translateY(-1px);
}

.module-choice-btn.active {
    background: #2f6fed;
    border-color: #2f6fed;
    color: white;
}

.project-folder-group {
    margin-bottom: 18px;
    border: 1px solid #e9ecef;
    border-radius: 14px;
    overflow: hidden;
}

.folder-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #f8fafc;
    border-bottom: 1px solid #e9ecef;
    cursor: pointer;
}

.folder-header span {
    font-weight: 700;
}

.folder-toggle {
    background: transparent;
    border: none;
    color: #2f6fed;
    font-weight: 700;
    cursor: pointer;
}

.folder-body {
    overflow: hidden;
}

.project-folder-group.collapsed .folder-body {
    display: none;
}

.project-folder-group .project-folder-group {
    margin: 0;
    margin-left: 16px;
    border-color: #dfe7ef;
    background: #fbfcfd;
}

.folder-body {
    overflow: hidden;
}

.project-file-row {
    transition: background 0.2s ease, transform 0.2s ease;
}

.project-file-row.dragging {
    opacity: 0.5;
}

.project-file-row.drag-over {
    outline: 2px dashed #2f6fed;
}

.drag-handle {
    width: 30px;
    text-align: center;
    cursor: grab;
    color: #2f6fed;
}

.drag-handle:active {
    cursor: grabbing;
}

.module-choice-title {
    font-weight: 700;
}

.module-choice-desc {
    font-size: 0.9rem;
    opacity: 0.9;
}

.project-module-panel {
    display: grid;
    gap: 16px;
}

.project-upload-card {
    display: grid;
    gap: 12px;
}

.project-upload-card form {
    display: grid;
    gap: 12px;
}

.project-file-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
    min-width: 640px;
}

.project-file-table th,
.project-file-table td {
    padding: 5px 8px;
    border: 1px solid #e9ecef;
    vertical-align: middle;
    white-space: nowrap;
    line-height: 1.18;
}

.project-file-table .btn-secondary {
    padding: 0.25rem 0.45rem;
    font-size: 0.72rem;
    min-height: 24px;
    line-height: 1.05;
}

.file-status-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.8rem;
    color: #ffffff;
}

.project-file-table .drag-handle {
    padding: 6px 8px;
}

.project-file-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.project-file-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.project-file-actions form {
    display: inline-flex;
    margin: 0;
}

@media (max-width: 768px) {
    .modal {
        padding: 8px;
        font-size: 0.95rem;
    }

    .modal-content {
        width: 100%;
        max-width: 100%;
        border-radius: 12px;
    }

    .modal-header,
    .modal-body,
    .modal-footer,
    .modal form {
        padding-left: 8px;
        padding-right: 5px;
    }

    .modal-body {
        max-height: calc(100vh - 88px);
        overflow-x: hidden;
    }

    .modal-body-scroll {
        max-height: calc(100vh - 128px);
    }

    .modal-footer {
        padding-bottom: 14px;
    }

    .modal form {
        gap: 12px;
    }

    .modal input,
    .modal select,
    .modal textarea,
    .modal button {
        width: 100%;
        box-sizing: border-box;
    }

    .modal textarea {
        min-height: 100px;
    }

    .modal-header h3 {
        font-size: 1.1rem;
    }

    #material-cards-container table,
    #material-cards-container thead,
    #material-cards-container tbody,
    #material-cards-container tr,
    #material-cards-container th,
    #material-cards-container td {
        width: 100%;
        display: block;
    }

    #material-cards-container thead {
        display: none;
    }

    #material-cards-container tr {
        border: 1px solid #e2e8f0;
        border-radius: 14px;
        margin-bottom: 14px;
        padding: 14px;
        background: #fff;
    }

    #material-cards-container td {
        padding: 10px 0;
        border: none;
        white-space: normal;
        word-break: break-word;
    }

    #material-cards-container td[data-label]:before {
        content: attr(data-label) ":";
        display: block;
        font-weight: 700;
        margin-bottom: 4px;
        color: #334155;
    }

    #material-cards-container td[data-label="Akcja"] {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

    #material-cards-container .table-action-button {
        width: 100%;
        justify-content: center;
        padding: 10px 12px;
    }

    .project-file-table {
        min-width: 0;
    }

    .project-file-table thead {
        display: none;
    }

    .project-file-table tr {
        display: block;
        margin-bottom: 10px;
        border: 1px solid #e9ecef;
        border-radius: 10px;
        padding: 10px;
        background: #fff;
    }

    .project-file-table td {
        display: block;
        border: none;
        padding: 4px 0;
        white-space: normal;
    }

    .project-file-table td:first-child {
        display: none;
    }

    .project-file-table td:last-child {
        padding-top: 8px;
    }

    .project-file-actions {
        flex-direction: column;
        align-items: flex-start;
    }
}

.project-folder-group {
    margin-bottom: 18px;
}

.project-folder-group h4 {
    margin: 0 0 10px;
    font-size: 1rem;
    color: var(--heading-color);
    font-family: var(--font-family-base);
    font-weight: var(--heading-weight);
}

.project-file-description {
    margin-top: 6px;
    font-size: 0.9rem;
    color: #52607a;
}

.upload-progress {
    width: 100%;
    height: 12px;
    background: #e9ecef;
    border-radius: 999px;
    overflow: hidden;
    margin-top: 8px;
}

.upload-progress.hidden {
    display: none;
}

.upload-progress-bar {
    width: 0;
    height: 100%;
    background: #2f6fed;
    transition: width 0.2s ease;
}

.upload-progress-text {
    font-size: 0.95rem;
    color: #14213d;
    margin-top: 6px;
}

.card-error-message {
    padding: 14px;
    border-radius: 12px;
    border: 1px solid #f1c0b6;
    background: #fff2f0;
    color: #a4262c;
}

@media (max-width: 900px) {
    .layout.login-background {
        background-image: url('/tlo_page_login_mobile.jpg');
    }

    .layout.soft-background {
        background: linear-gradient(180deg, rgba(4, 10, 24, 0.06), rgba(6, 16, 34, 0.10));
    }

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

    .login-shell {
        padding: 16px;
    }

    .login-card {
        width: 100%;
        min-height: auto;
    }

    .login-panel {
        padding: 24px;
    }

    .login-icon {
        width: 60px;
        height: 60px;
        font-size: 1.5rem;
    }

    .login-header h1 {
        font-size: 1.5rem;
        font-family: var(--font-family-base);
        font-weight: var(--heading-weight);
        color: var(--heading-color);
    }

    .input-group input {
        padding: 14px 16px;
    }

    .btn-primary {
        padding: 14px 0;
        border-radius: 14px;
    }
}

@media (min-width: 901px) {
    .login-hero {
        background-image: url('/tlo_page_login.png');
        background-size: cover;
        background-position: center;
        background-repeat: no-repeat;
    }
}

/* Normalize action buttons across lists and tables */
.table-action-button,
table .btn-secondary,
table .btn-primary,
.project-file-actions button,
.project-file-table .btn-secondary,
.section-toolbar button,
.investment-list button,
.investment-list .btn-secondary,
.investment-list .btn-primary,
.module-choice-btn,
.edit-investment-row-btn,
.manage-subcontractors-row-btn {
    font-family: Arial, sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    padding: 6px 12px;
    border-radius: 10px;
    line-height: 1.1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.table-action-button {
    min-height: 32px;
}

.table-action-button .btn-secondary,
.table-action-button .btn-primary {
    padding: 6px 10px;
}
