:root {
    --bg: #f4f7f5;
    --surface: #ffffff;
    --line: #dbe7df;
    --text: #17201b;
    --muted: #647067;
    --green: #166534;
    --green-soft: #eef6f0;
    --blue: #1267b1;
    --danger: #b91c1c;
    font-family: Arial, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
a { color: inherit; }
button, .btn, .icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 6px;
    background: var(--green);
    color: #fff;
    padding: 8px 11px;
    font: inherit;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}
.secondary { background: #475569; }
.danger { background: #b91c1c; }
.icon-btn { width: 34px; height: 34px; padding: 0; }
.sidebar-toggle {
    position: fixed;
    top: 28px;
    left: 8px;
    z-index: 30;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 1px solid #cbdccd;
    border-radius: 7px;
    background: #fff;
    color: #16351f;
    box-shadow: 0 6px 16px rgba(20,34,27,.12);
    font-size: 22px;
    line-height: 1;
}
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 250px;
    background: #fff;
    border-right: 1px solid var(--line);
    padding: 28px 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    transition: transform .2s ease;
}
.brand {
    color: var(--blue);
    font-weight: 800;
    text-decoration: none;
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 0;
    margin-left: 44px;
    min-height: 44px;
}
.brand-logo {
    display: block;
    width: 146px;
    max-width: 100%;
    height: auto;
}
.sidebar-logo-stack {
    align-items: center;
    background: #f7fbf8;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: flex;
    margin: -4px 0 2px 44px;
    max-width: 158px;
    padding: 7px;
}
.sidebar-logo-stack .project-logo {
    max-width: 140px;
    max-height: 46px;
}
.sidebar-logo-stack .partner-logo {
    border-top: 1px solid var(--line);
    margin-top: 5px;
    max-width: 112px;
    max-height: 30px;
    padding-top: 5px;
}
.sidebar-partner-logo-only .partner-logo {
    border-top: 0;
    margin-top: 0;
    max-width: 128px;
    max-height: 42px;
    padding-top: 0;
}
.app-name {
    display: none;
}
.sidebar nav { display: grid; gap: 6px; }
.sidebar nav a,
.sidebar-documents-link {
    border-radius: 6px;
    background: var(--green-soft);
    color: #234735;
    padding: 8px 10px;
    font-weight: 800;
    text-decoration: none;
}
.sidebar-service-links {
    display: block;
    margin-top: auto;
}
.sidebar-service-links {
    display: grid;
    gap: 6px;
}
.sidebar-documents-link {
    display: block;
}
.sidebar-documents-link.wish-alert-desiderata {
    background: #fce7f3;
    color: #9d174d;
}
.sidebar-documents-link.wish-alert-bug {
    background: #b91c1c;
    color: #fff;
}
.sidebar-group {
    display: grid;
    gap: 6px;
}
.sidebar-group summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    border-radius: 6px;
    background: var(--green-soft);
    color: #234735;
    padding: 8px 10px;
    font-weight: 800;
    cursor: pointer;
    list-style: none;
}
.sidebar-group summary::-webkit-details-marker { display: none; }
.group-symbol::before { content: "+"; font-size: 18px; line-height: 1; }
.sidebar-group[open] .group-symbol::before { content: "-"; }
.sidebar-subnav {
    display: grid;
    gap: 5px;
    padding-left: 14px;
}
.sidebar-subnav a {
    background: #f7fbf8 !important;
    border-left: 3px solid #89bfa5;
    color: #2f6f55 !important;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.nav-badge {
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--danger);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 800;
    line-height: 1;
}
.sidebar-user {
    margin-top: 8px;
    border-top: 1px solid var(--line);
    padding-top: 12px;
    color: var(--muted);
    font-size: 14px;
    text-decoration: none;
    display: block;
}
.sidebar-user:hover { color: var(--ink); }
.sidebar-user span { color: var(--green); font-weight: 800; }
.sidebar-import {
    display: grid;
    gap: 6px;
    border-top: 1px solid var(--line);
    padding-top: 10px;
    font-size: 12px;
}
.sidebar-import label {
    display: grid;
    gap: 4px;
    color: var(--muted);
    font-weight: 700;
}
.sidebar-import input {
    width: 100%;
    font-size: 12px;
}
.sidebar-import button {
    min-height: 30px;
    padding: 5px 8px;
    font-size: 13px;
}
.logout {
    display: block;
    border-radius: 6px;
    background: #475569;
    color: #fff;
    padding: 8px 10px;
    font-weight: 800;
    text-decoration: none;
}
.app-main {
    max-width: 1180px;
    margin-left: 250px;
    padding: 20px 18px 40px;
    transition: margin-left .2s ease, max-width .2s ease;
}
.app-main:has(.wide-page) {
    max-width: none;
    width: calc(100% - 250px);
    padding: 14px 10px 28px;
}
body.sidebar-collapsed .sidebar { transform: translateX(-250px); }
body.sidebar-collapsed .app-main {
    max-width: 1180px;
    margin-left: 0;
    padding-left: 62px;
}
body.sidebar-collapsed .app-main:has(.wide-page) {
    max-width: none;
    width: 100%;
    padding-left: 54px;
}
.login-main {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
}
.login-panel, .panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
    box-shadow: 0 6px 16px rgba(20,34,27,.045);
}
.login-panel { width: min(420px, 100%); }
.login-logo {
    display: block;
    width: min(200px, 100%);
    height: auto;
    margin: 0 0 14px;
}
.eyebrow {
    margin: 0 0 5px;
    color: var(--blue);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}
h1 { margin: 0 0 12px; font-size: 26px; }
h2 { margin: 0 0 12px; font-size: 19px; }
.page-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 12px;
}
.project-logo-head {
    justify-content: flex-start;
}
.table-logo {
    display: block;
    max-width: 72px;
    max-height: 32px;
    object-fit: contain;
}
.form-logo-preview {
    display: block;
    max-width: 180px;
    max-height: 70px;
    object-fit: contain;
}
.logo-preview-block {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.logo-stack {
    align-items: flex-start;
    display: inline-flex;
    flex-direction: column;
    gap: 4px;
    min-width: 88px;
}
.project-logo {
    display: block;
    max-width: 150px;
    max-height: 54px;
    object-fit: contain;
}
.partner-logo {
    display: block;
    max-width: 110px;
    max-height: 34px;
    object-fit: contain;
}
.kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}
.kpis article {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
}
.kpis strong { display: block; font-size: 34px; }
.kpis span { color: var(--muted); }
.project-kpis {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}
.project-kpi-card {
    background:
        linear-gradient(rgba(255,255,255,.58), rgba(255,255,255,.58)),
        var(--project-card-color, var(--green-soft));
    border-left: 8px solid var(--project-card-color, var(--green-soft));
    display: grid;
    gap: 3px;
    color: inherit;
    text-decoration: none;
}
.project-kpi-card:hover {
    background:
        linear-gradient(rgba(255,255,255,.42), rgba(255,255,255,.42)),
        var(--project-card-color, var(--green-soft));
}
.project-kpi-card .project-kpi-title {
    color: #073527;
    font-size: 20px;
    font-weight: 800;
    line-height: 1.05;
}
.project-kpi-card em {
    color: #40574c;
    font-size: 13px;
}
.project-kpi-card .project-kpi-main {
    color: #00140d;
    font-size: 34px;
    font-weight: 800;
    line-height: 1;
    margin-top: 4px;
}
.project-kpi-card span strong {
    display: inline;
    font-size: inherit;
}
.single-project-kpi {
    max-width: 520px;
}
.frontoffice-projects {
    margin-top: 8px;
}
.frontoffice-project-card {
    min-height: 210px;
    transition: transform .12s ease, box-shadow .12s ease;
}
.frontoffice-project-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(20,34,27,.10);
}
.frontoffice-budget-kpis {
    grid-template-columns: repeat(4, max-content);
}
.frontoffice-readonly-card > summary {
    grid-template-columns: minmax(260px, 1fr) repeat(2, minmax(140px, auto)) 28px;
}
.frontoffice-readonly-stats {
    display: grid;
    grid-template-columns: repeat(3, max-content);
    gap: 28px;
    align-items: center;
    padding: 4px 2px;
}
.frontoffice-readonly-stats span {
    display: grid;
    font-weight: 900;
}
.frontoffice-readonly-stats em {
    color: var(--muted);
    font-size: 12px;
    font-style: normal;
    font-weight: 700;
}
.reporting-sheet {
    overflow: auto;
}
.reporting-themed-page {
    background:
        linear-gradient(rgba(255,255,255,.76), rgba(255,255,255,.76)),
        var(--project-color, #eaf4ec);
    border-radius: 8px;
    padding: 8px;
}
.reporting-themed-page .reporting-sheet {
    background:
        linear-gradient(rgba(255,255,255,.82), rgba(255,255,255,.82)),
        var(--project-color, #eaf4ec);
}
.reporting-sheet-head {
    display: grid;
    grid-template-columns: minmax(220px, 420px);
    gap: 8px;
    margin-bottom: 8px;
}
.single-project-context {
    display: flex;
    align-items: center;
    gap: 10px;
    width: fit-content;
    max-width: 100%;
    margin-bottom: 8px;
    padding: 8px 11px;
    border: 1px solid color-mix(in srgb, var(--project-color, #eaf4ec) 65%, #b8c8be);
    border-radius: 6px;
    background:
        linear-gradient(rgba(255,255,255,.68), rgba(255,255,255,.68)),
        var(--project-color, #eaf4ec);
    color: #073b25;
    font-size: 13px;
}
.single-project-context span {
    font-weight: 800;
}
.single-project-context strong {
    font-size: 14px;
}
.reporting-entry-accordion {
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-bottom: 10px;
    overflow: hidden;
    background:
        linear-gradient(rgba(255,255,255,.72), rgba(255,255,255,.72)),
        var(--project-color, #eaf4ec);
}
.reporting-entry-toggle {
    border: 0;
    background: transparent;
    width: 100%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 7px 10px;
    color: #06382c;
    font-size: 16px;
    font-weight: 900;
    text-align: left;
}
.reporting-entry-accordion .accordion-symbol::before {
    content: "+";
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    min-height: 28px;
    border-radius: 7px;
    background: var(--green);
    color: #fff;
}
.reporting-entry-accordion.is-open .accordion-symbol::before {
    content: "-";
}
.reporting-entry-panel {
    display: none;
}
.reporting-entry-accordion.is-open .reporting-entry-panel {
    display: block;
}
.reporting-entry-accordion .reporting-entry-form {
    border-top: 1px solid var(--line);
    padding-top: 8px;
}
.reporting-sheet-grid {
    min-width: 980px;
    display: grid;
    gap: 0;
}
.reporting-sheet-row {
    display: grid;
    gap: 8px;
    align-items: start;
    padding: 6px 10px;
    border-bottom: 1px solid var(--line);
}
.reporting-row-main {
    grid-template-columns: 92px 98px 150px minmax(110px, .7fr) 150px 130px 132px 145px;
}
.reporting-row-labor {
    grid-template-columns: 560px 155px 155px;
}
.reporting-group-title {
    align-self: stretch;
    border: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    text-align: center;
}
.reporting-personnel-group {
    border: 2px solid rgba(75, 45, 80, .45);
    display: grid;
    gap: 4px 8px;
    grid-template-columns: 105px 150px 150px 105px;
    padding: 4px 6px;
}
.reporting-personnel-group span {
    color: #234735;
    font-size: 13px;
    font-weight: 900;
    line-height: 1.15;
}
.reporting-personnel-group input[type="date"] {
    max-width: 150px;
    min-width: 0;
}
.reporting-row-payment {
    grid-template-columns: 145px 220px minmax(170px, 1fr) 220px 250px 150px 42px;
}
.reporting-sheet-header {
    background:
        linear-gradient(rgba(255,255,255,.36), rgba(255,255,255,.36)),
        var(--project-color, var(--green-soft));
    color: #234735;
    font-size: 13px;
    font-weight: 900;
    line-height: 1.15;
}
.reporting-sheet-header span {
    min-width: 0;
    overflow-wrap: anywhere;
}
.reporting-sheet-row:not(.reporting-sheet-header) {
    background:
        linear-gradient(rgba(255,255,255,.72), rgba(255,255,255,.72)),
        var(--project-color, #fff);
}
.reporting-sheet-row input,
.reporting-sheet-row select,
.reporting-sheet-row textarea {
    width: 100%;
    min-width: 0;
    padding: 6px 7px;
    font-size: 13px;
}
.reporting-sheet-row .icon-action {
    border-radius: 999px;
    align-self: center;
}
.reporting-sheet-row .field-number,
.reporting-sheet-row .field-date {
    text-align: right;
}
.reporting-sheet-row .required-field {
    background: #fff8bf;
}
.reporting-sheet-head .required-field select {
    background: #fff8bf;
}
.budget-availability-box {
    display: none;
    margin: 8px 12px 0;
    padding: 8px 10px;
    border: 1px solid color-mix(in srgb, var(--project-color, #eaf4ec) 65%, #b8c8be);
    border-radius: 6px;
    background: color-mix(in srgb, var(--project-color, #eaf4ec) 28%, #fff);
    color: #073b25;
    font-size: 13px;
    font-weight: 900;
}
.budget-availability-box.is-visible {
    display: block;
}
.reporting-sheet-row input.missing-field,
.reporting-sheet-row select.missing-field,
.reporting-sheet-row textarea.missing-field {
    border: 2px solid var(--danger) !important;
    box-shadow: 0 0 0 2px rgba(185, 28, 28, .18) !important;
    outline: none;
}
.reporting-rows-table table {
    min-width: 1500px;
}
.reporting-rows-table th {
    padding: 6px 7px;
    font-size: 13px;
    line-height: 1.15;
    overflow-wrap: anywhere;
}
.reporting-rows-table td {
    font-size: 13px;
}
.reporting-rows-table tr.project-colored-row td {
    background:
        color-mix(in srgb, var(--project-row-color, #eaf4ec) 34%, #fff);
}
.reporting-rows-table tr.project-colored-row:nth-child(even) td {
    background:
        color-mix(in srgb, var(--project-row-color, #eaf4ec) 46%, #fff);
}
.reporting-rows-table tr.project-colored-row:hover td {
    background:
        color-mix(in srgb, var(--project-row-color, #eaf4ec) 58%, #fff);
}
.reporting-rows-table .num {
    text-align: right;
}
.reporting-rows-table .row-actions {
    min-width: 74px;
}
.reporting-rows-table .note-cell {
    width: 36px;
    min-width: 36px;
    text-align: center;
    vertical-align: middle;
}
.reporting-rows-table .document-cell {
    min-width: 110px;
}
.reporting-rows-table .icon-action {
    width: 30px;
    min-height: 30px;
    padding: 0;
}
.row-document-upload {
    display: flex;
    align-items: end;
    gap: 12px;
    flex-wrap: wrap;
    padding: 10px 12px;
    border-top: 1px solid var(--line);
    background: color-mix(in srgb, var(--project-color, #eaf4ec) 22%, #fff);
}
.row-document-upload label {
    display: grid;
    gap: 5px;
    min-width: 280px;
    font-size: 13px;
    font-weight: 800;
}
.sidebar-subnav .sidebar-icon-link {
    width: 38px;
    min-height: 34px;
    justify-content: center;
    font-size: 20px;
    line-height: 1;
}
.row-documents-list {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.row-document-link {
    display: inline-flex;
    align-items: center;
    max-width: 220px;
    padding: 4px 7px;
    border-radius: 6px;
    background: #edf7ef;
    color: var(--green);
    font-size: 12px;
    font-weight: 800;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.approval-note-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    min-width: 30px;
    border-radius: 999px;
    background: #facc15;
    color: #713f12;
    font-weight: 800;
    border: 1px solid #eab308;
    line-height: 1;
}
.approval-note-icon.lock-icon {
    background: #e2e8f0;
    border-color: #cbd5e1;
    color: #334155;
}
.approval-note-box {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 10px 0;
    padding: 10px 12px;
    border: 1px solid #facc15;
    border-radius: 8px;
    background: #fef9c3;
    color: #3f2f05;
}
.approval-note-box p {
    margin: 4px 0 0;
}
.approval-note-field {
    margin-top: 10px;
}
.approval-note-field textarea {
    width: 100%;
    min-height: 72px;
    resize: vertical;
}
.pivot-section {
    margin-top: 18px;
}
.section-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.pivot-project {
    margin-top: 10px;
    background:
        linear-gradient(rgba(255,255,255,.78), rgba(255,255,255,.78)),
        var(--project-color, #eaf4ec);
}
.pivot-project > summary,
.pivot-macro > summary,
.pivot-item > summary {
    cursor: pointer;
    display: grid;
    grid-template-columns: minmax(240px, 1fr) 150px 150px 150px 150px 24px;
    gap: 10px;
    align-items: center;
    padding: 8px 10px;
    list-style: none;
}
.pivot-project > summary::-webkit-details-marker,
.pivot-macro > summary::-webkit-details-marker,
.pivot-item > summary::-webkit-details-marker {
    display: none;
}
.pivot-project > summary {
    color: #06382c;
    font-size: 16px;
    font-weight: 900;
}
.pivot-macro {
    border-top: 1px solid var(--line);
}
.pivot-macro > summary {
    background:
        linear-gradient(rgba(255,255,255,.52), rgba(255,255,255,.52)),
        var(--project-color, var(--green-soft));
    font-weight: 800;
}
.pivot-item > summary {
    background: #f7fbf8;
    border-top: 1px solid var(--line);
}
.pivot-partner-row {
    display: grid;
    grid-template-columns: minmax(240px, 1fr) 150px 150px 150px 150px 24px;
    gap: 10px;
    align-items: center;
    padding: 7px 10px 7px 28px;
    border-top: 1px solid var(--line);
    background: #fff;
}
.pivot-section .num {
    text-align: right;
    font-weight: 900;
}
.pivot-section em {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-style: normal;
    font-weight: 700;
}
.pivot-project > summary::after,
.pivot-macro > summary::after,
.pivot-item > summary::after {
    content: "+";
    justify-self: end;
    grid-column: 6;
    grid-row: 1;
    font-weight: 900;
}
.pivot-project[open] > summary::after,
.pivot-macro[open] > summary::after,
.pivot-item[open] > summary::after {
    content: "-";
}
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px;
}
.form-wide { grid-column: span 2; }
.form-break { grid-column: 1 / -1; height: 1px; background: var(--line); margin: 4px 0; }
label { display: grid; gap: 4px; font-weight: 700; font-size: 14px; }
label em {
    color: var(--muted);
    font-weight: 400;
}
.field-tiny {
    max-width: 260px;
}
.field-tiny input {
    max-width: 72px;
}
.password-inline {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 34px;
    gap: 6px;
    align-items: center;
}
.mail-test-grid {
    display: grid;
    grid-template-columns: minmax(190px, 1fr) minmax(180px, 1fr) minmax(280px, 2fr) auto;
    gap: 10px;
    align-items: end;
}
.mail-test-grid .actions {
    margin: 0;
    align-self: end;
}
.mail-test-grid textarea {
    min-height: 38px;
    resize: vertical;
}
@media (max-width: 1000px) {
    .mail-test-grid {
        grid-template-columns: 1fr;
    }
}
.check-line {
    display: flex;
    align-items: center;
    gap: 8px;
    align-self: end;
    min-height: 38px;
}
.check-line input {
    width: 18px;
    height: 18px;
    accent-color: var(--green);
}
input, select {
    width: 100%;
    border: 1px solid #c9d6ce;
    border-radius: 6px;
    padding: 8px 9px;
    font: inherit;
    background: #fff;
}
.actions { display: flex; gap: 7px; align-items: end; flex-wrap: wrap; margin: 0; }
.row-actions {
    align-items: center;
    flex-wrap: nowrap;
    white-space: nowrap;
    min-width: 170px;
}
.row-actions form { margin: 0; }
.backoffice-links { display: flex; gap: 8px; flex-wrap: wrap; }
.table-panel { margin-top: 12px; overflow: auto; padding: 0; }
table { width: 100%; border-collapse: collapse; background: #fff; min-width: 780px; }
.wide-page table { min-width: 1120px; }
th, td { border-bottom: 1px solid #e2ebe5; text-align: left; padding: 8px 9px; vertical-align: top; }
th { background: var(--green-soft); color: #234735; }
tbody tr:nth-child(even) td { background: #f7fbf8; }
tbody tr:nth-child(odd) td { background: #ffffff; }
tbody tr:hover td { background: #eef6f0; }
.project-list-row td {
    background:
        linear-gradient(rgba(255,255,255,.78), rgba(255,255,255,.78)),
        var(--project-row-color, #fff) !important;
}
.project-list-row:hover td {
    background:
        linear-gradient(rgba(255,255,255,.62), rgba(255,255,255,.62)),
        var(--project-row-color, #fff) !important;
}
.table-filter-row th {
    background: var(--green-soft);
    padding: 5px 6px;
}
.table-filter-row input,
.table-filter-row select {
    min-width: 0;
    width: 100%;
    padding: 5px 6px;
    font-size: 13px;
}
.filter-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    min-width: 170px;
}
.filter-actions button,
.filter-actions .btn {
    min-height: 32px;
    padding: 6px 9px;
}
.sort-link {
    color: inherit;
    display: inline-block;
    text-decoration: none;
}
.sort-link:hover {
    text-decoration: underline;
}
.status-checkbox {
    width: 18px;
    height: 18px;
    accent-color: var(--green);
}
.badge {
    display: inline-flex;
    border-radius: 999px;
    background: var(--green-soft);
    color: var(--green);
    padding: 4px 9px;
    font-weight: 800;
    font-size: 12px;
}
.badge.inactive { background: #fff1f2; color: var(--danger); }
.badge.danger { background: #fee2e2; color: #991b1b; }
.badge.approved { background: #dbeafe; color: #1d4ed8; }
.flash {
    margin-bottom: 10px;
    padding: 9px 11px;
    border-radius: 6px;
    background: #e9f5e9;
    border: 1px solid #bad8c0;
    font-weight: 700;
}
.flash.error { background: #fff1f2; border-color: #fecdd3; color: #9f1239; }
.flash.warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.error-popup {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(15, 23, 42, 0.28);
}
.error-popup-card {
    width: min(460px, 100%);
    background: #fff;
    border: 1px solid #fecdd3;
    border-radius: 8px;
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.22);
    color: #7f1d1d;
}
.error-popup-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid #fecdd3;
    background: #fff1f2;
}
.error-popup-card p {
    margin: 0;
    padding: 14px;
}
.error-popup-card .actions {
    padding-top: 0;
    text-align: right;
}
.error-popup-close {
    width: 30px;
    min-height: 30px;
    padding: 0;
    background: #fff;
    color: #7f1d1d;
    border: 1px solid #fecdd3;
}
.error-popup-ok {
    min-height: 34px;
    padding: 7px 14px;
}

.wide-page .page-head { margin-bottom: 8px; }
.wide-page .page-head h1 { margin-bottom: 6px; }
.budget-head { align-items: end; }
.budget-head > div:first-child { flex: 0 0 auto; }
.budget-topline {
    display: grid;
    grid-template-columns: auto 1fr 40px;
    gap: 8px;
    align-items: stretch;
    margin-bottom: 6px;
}
.budget-kpis {
    grid-template-columns: repeat(3, max-content);
    gap: 6px;
    margin-bottom: 0;
}
.budget-kpis article {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto 1fr;
    align-items: center;
    column-gap: 8px;
    min-height: 58px;
    min-width: 220px;
    padding: 7px 10px;
}
.budget-kpis article span {
    grid-column: 1;
}
.budget-kpis strong {
    font-size: 24px;
    line-height: 1.05;
}
.budget-kpis span {
    font-size: 12px;
}
.budget-kpis button {
    grid-row: 1 / span 2;
    grid-column: 2;
    align-self: stretch;
}
.budget-kpis .icon-action { justify-self: end; align-self: center; }
.budget-kpis article:first-child .icon-action {
    grid-row: 1;
    grid-column: 2;
    align-self: start;
    margin-top: 0;
}
.wide-page > .panel {
    padding: 10px 12px;
}
.wide-page h2 {
    margin-bottom: 8px;
    font-size: 17px;
}
.wide-page input,
.wide-page select {
    padding: 6px 8px;
    min-height: 34px;
}
.wide-page label {
    gap: 3px;
    font-size: 13px;
}
.wide-page .btn,
.wide-page button {
    padding: 7px 10px;
}
.icon-action {
    width: 34px;
    height: 34px;
    min-width: 34px;
    padding: 0 !important;
    font-size: 16px;
    line-height: 1;
}
.budget-toolbar {
    display: grid;
    grid-template-columns: minmax(360px, 1fr) minmax(260px, 420px);
    gap: 8px;
    align-items: end;
    margin-bottom: 8px;
    padding: 8px 10px;
}
.budget-toolbar:not(:has(.budget-total-form)) {
    grid-template-columns: minmax(360px, 1fr);
}
.budget-toolbar-grid,
.budget-total-form,
.budget-filter-grid {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto;
    gap: 8px;
    align-items: end;
}
.budget-page .budget-project-context .budget-toolbar-grid {
    grid-template-columns: minmax(160px, 260px) 1fr;
}
.budget-page .budget-project-context .single-project-toolbar,
.project-context .single-project-toolbar {
    grid-template-columns: 1fr;
}
.budget-page .budget-partner-toolbar .budget-toolbar-grid {
    grid-template-columns: minmax(180px, 320px) auto;
    justify-content: start;
}
.budget-page .budget-project-context select,
.budget-page .budget-partner-toolbar select {
    width: 100%;
}
.backoffice-project-context .budget-toolbar-grid {
    grid-template-columns: minmax(170px, 300px) 1fr;
}
.backoffice-project-context select {
    width: 100%;
}
.budget-toolbar .filter-actions {
    min-width: 0;
}
.budget-toolbar .filter-actions .icon-action {
    flex: 0 0 auto;
}
.budget-toolbar .actions {
    flex-wrap: nowrap;
}
.budget-filters { margin-bottom: 8px; }
.project-themed-page {
    min-height: calc(100vh - 42px);
    margin: -14px -10px -28px;
    padding: 14px 10px 28px;
    background:
        linear-gradient(rgba(255,255,255,.72), rgba(255,255,255,.72)),
        var(--project-color, #eaf4ec);
}
.project-themed-page th,
.project-themed-page .table-filter-row th {
    background:
        linear-gradient(rgba(255,255,255,.30), rgba(255,255,255,.30)),
        var(--project-color, #eaf4ec);
    color: #173b29;
}
.project-themed-page tbody tr:nth-child(even) td {
    background:
        linear-gradient(rgba(255,255,255,.82), rgba(255,255,255,.82)),
        var(--project-color, #eaf4ec);
}
.project-themed-page tbody tr:nth-child(odd) td {
    background:
        linear-gradient(rgba(255,255,255,.94), rgba(255,255,255,.94)),
        var(--project-color, #eaf4ec);
}
.project-themed-page tbody tr:hover td {
    background:
        linear-gradient(rgba(255,255,255,.68), rgba(255,255,255,.68)),
        var(--project-color, #eaf4ec);
}
.project-themed-page .budget-accordion > summary,
.project-themed-page .budget-subcard > summary,
.project-themed-page .budget-item-card > summary {
    background:
        linear-gradient(rgba(255,255,255,.76), rgba(255,255,255,.76)),
        var(--project-color, #eaf4ec);
}
.project-themed-page .budget-accordion,
.project-themed-page .budget-subcard,
.project-themed-page .budget-item-card,
.project-themed-page .budget-empty {
    border-color:
        color-mix(in srgb, var(--project-color, #eaf4ec) 42%, #d7e3dc);
}
.project-context {
    border-left: 8px solid var(--project-color, #eaf4ec);
}
.project-context strong {
    color: #062f1d;
}
.color-swatch {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 1px solid var(--line);
    border-radius: 4px;
    vertical-align: middle;
}
.budget-accordions {
    display: grid;
    gap: 6px;
}
.budget-accordion,
.budget-subcard {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}
.budget-accordion > summary,
.budget-subcard > summary {
    display: grid;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    list-style: none;
}
.budget-accordion > summary {
    grid-template-columns: minmax(220px, 1fr) minmax(170px, auto) 40px repeat(3, minmax(130px, auto)) 28px;
    padding: 8px 10px;
    background: var(--green-soft);
    color: #173b29;
}
.budget-accordion > summary::-webkit-details-marker,
.budget-subcard > summary::-webkit-details-marker { display: none; }
.budget-accordion > summary::after,
.budget-subcard > summary::after {
    content: "+";
    font-weight: 900;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    justify-self: center;
    align-self: center;
    width: 24px;
    height: 24px;
    grid-column: -1;
    grid-row: 1;
}
.budget-accordion[open] > summary::after,
.budget-subcard[open] > summary::after { content: "-"; }
.budget-accordion summary span {
    display: grid;
    gap: 1px;
    font-weight: 900;
    line-height: 1.15;
    min-width: 0;
}
.budget-accordion > summary > span:not(:first-child) {
    justify-self: end;
    min-width: 130px;
}
.budget-accordion > summary > span:last-of-type {
    min-width: 160px;
}
.budget-accordion > summary > .icon-action {
    justify-self: center;
}
.budget-accordion > summary > .budget-summary-form {
    grid-column: 2 / span 2;
    justify-self: end;
}
.budget-accordion summary em {
    color: var(--muted);
    font-style: normal;
    font-size: 11px;
    font-weight: 700;
}
.budget-accordion-body,
.budget-subcard-body {
    display: grid;
    gap: 8px;
    padding: 8px 10px;
}
.budget-accordion-body {
    padding-top: 0;
}
.budget-summary-form {
    display: grid;
    grid-template-columns: minmax(120px, 170px) 34px 34px;
    gap: 6px;
    align-items: center;
}
.budget-summary-form input {
    min-height: 32px;
    padding: 5px 7px;
    font-weight: 800;
}
.budget-inline-form {
    align-items: end;
    grid-template-columns: minmax(220px, 1fr) minmax(140px, 220px) auto;
    gap: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--line);
}
.budget-subcard {
    background: #f9fcfa;
}
.budget-subcard > summary {
    grid-template-columns: 1fr auto auto;
    padding: 8px 10px;
    background: #eef6f0;
    color: #234735;
    font-weight: 900;
}
.budget-subtable {
    margin-top: 0;
    border: 1px solid var(--line);
    border-radius: 6px;
}
.budget-subtable table { min-width: 980px; }
.budget-nested-accordions {
    display: grid;
    gap: 6px;
}
.budget-empty {
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--muted);
    font-weight: 700;
}
.budget-item-card {
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    overflow: hidden;
}
.budget-item-card > summary {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) repeat(5, minmax(105px, auto)) auto 28px;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    list-style: none;
    cursor: pointer;
    background: #f7fbf8;
}
.budget-item-card > summary::-webkit-details-marker { display: none; }
.budget-item-card > summary::after {
    content: "+";
    font-weight: 900;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    justify-self: center;
    align-self: center;
    width: 24px;
    height: 24px;
    grid-column: -1;
    grid-row: 1;
}
.budget-item-card[open] > summary::after { content: "-"; }
.budget-item-card summary span {
    display: grid;
    gap: 1px;
    font-weight: 900;
    line-height: 1.15;
}
.budget-item-card summary em {
    color: var(--muted);
    font-style: normal;
    font-size: 11px;
    font-weight: 700;
}
.budget-item-body {
    display: grid;
    gap: 8px;
    padding: 8px 10px;
}
.budget-inline-note {
    margin: 0;
    color: var(--green);
    font-weight: 900;
    font-size: 13px;
}
.budget-subtable th,
.budget-subtable td {
    padding: 6px 7px;
    font-size: 13px;
}
.budget-item-card .btn,
.budget-item-card button,
.budget-subcard .btn,
.budget-subcard button {
    min-height: 30px;
    padding: 5px 8px;
    font-size: 13px;
}

@media (max-width: 820px) {
    .sidebar {
        z-index: 20;
        transform: translateX(-250px);
    }
    body:not(.sidebar-collapsed) .sidebar { transform: translateX(0); }
    .app-main {
        margin-left: 0;
        padding-top: 62px;
    }
    body.sidebar-collapsed .app-main { padding-left: 18px; }
    .form-wide { grid-column: 1; }
    .budget-topline,
    .budget-toolbar,
    .budget-toolbar-grid,
    .budget-total-form,
    .budget-filter-grid,
    .budget-accordion > summary,
    .budget-summary-form,
    .budget-item-card > summary {
        grid-template-columns: 1fr;
    }
}
