:root {
    color-scheme: light;
    --ink: #17202a;
    --muted: #657487;
    --line: #d9e0e8;
    --surface: #ffffff;
    --canvas: #eef3f6;
    --accent: #0f766e;
    --accent-dark: #115e59;
    --accent-soft: #dff4ef;
    --nav: #22313f;
    --nav-muted: #aebbc9;
    --danger: #b42318;
    --warning: #946200;
}

* {
    box-sizing: border-box;
}

html {
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background: var(--canvas);
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    min-height: 31px;
    border: 0;
    border-radius: 4px;
    padding: 0 12px;
    color: #ffffff;
    font-size: 0.875rem;
    font-weight: 700;
    background: var(--accent);
    cursor: pointer;
}

button:hover {
    background: var(--accent-dark);
}

a {
    color: inherit;
    text-decoration: none;
}

.guest-shell button {
    min-height: 42px;
    border-radius: 6px;
    padding: 0 18px;
    font-size: 1rem;
}

.guest-shell,
.app-shell {
    min-height: 100vh;
}

.app-shell {
    display: grid;
    grid-template-columns: 248px minmax(0, 1fr);
    background: var(--canvas);
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-panel {
    width: min(100%, 420px);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 30px;
    background: var(--surface);
    box-shadow: 0 18px 44px rgba(21, 31, 42, 0.12);
}

.login-heading {
    margin-bottom: 24px;
}

.login-heading p,
.page-heading p,
.module-list header p {
    margin: 0 0 6px;
    color: var(--accent-dark);
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0;
}

.login-heading h1,
.page-heading h1 {
    margin: 0;
    font-size: 1.65rem;
    line-height: 1.2;
}

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

.login-form label {
    color: var(--muted);
    font-size: 0.92rem;
    font-weight: 650;
}

.login-form input[type="email"],
.login-form input[type="password"] {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0 12px;
    color: var(--ink);
    background: #ffffff;
}

.login-form input:focus {
    border-color: var(--accent);
    outline: 3px solid rgba(15, 118, 110, 0.16);
}

.checkbox-row {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    margin: 4px 0 8px;
}

.checkbox-row input {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
}

.form-error {
    margin: 2px 0 8px;
    color: var(--danger);
    font-size: 0.92rem;
}

.sidebar {
    position: relative;
    min-height: 100vh;
    padding: 22px 18px;
    color: #ffffff;
    background: var(--nav);
}

.sidebar-toggle,
.sidebar-close,
.sidebar-backdrop {
    display: none;
}

.brand {
    display: block;
    padding: 2px 6px 0;
    text-align: center;
}

.brand strong,
.brand span {
    display: block;
}

.brand strong {
    font-size: 1.05rem;
}

.brand span {
    color: var(--nav-muted);
    font-size: 0.86rem;
}

.sidebar-nav {
    display: grid;
    gap: 5px;
    margin-top: 22px;
}

.sidebar-nav a,
.sidebar-nav span {
    min-height: 40px;
    display: flex;
    align-items: center;
    border-radius: 6px;
    padding: 0 12px;
    color: var(--nav-muted);
    font-weight: 650;
}

.sidebar-nav a.active {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.12);
}

.sidebar-group {
    display: grid;
    gap: 4px;
    margin-top: 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 12px;
}

.sidebar-group strong {
    padding: 0 12px 4px;
    color: #ffffff;
    font-size: 0.78rem;
    text-transform: uppercase;
}

.sidebar-group span,
.sidebar-group a {
    min-height: 34px;
    padding-left: 20px;
    font-size: 0.92rem;
}

.sidebar-group > span {
    opacity: 0.58;
}

.user-shell .sidebar {
    background: #28465f;
}

.workspace {
    min-width: 0;
}

.topbar {
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 0 24px;
    border-bottom: 1px solid var(--line);
    background: #ffffff;
}

.topbar strong,
.topbar span {
    display: block;
}

.topbar span {
    color: var(--muted);
    font-size: 0.86rem;
}

.topbar-account {
    min-width: 0;
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
}

.profile-avatar,
.topbar .profile-avatar {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 0;
    border-radius: 50%;
    color: #ffffff;
    font-weight: 800;
    letter-spacing: 0.02em;
    line-height: 1;
    background: var(--accent, #0f766e);
}

.profile-avatar > span,
.topbar .profile-avatar > span {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: inherit;
    font-size: inherit;
    font-weight: inherit;
    line-height: 1;
    text-align: center;
}

.profile-avatar img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    object-position: center;
    image-rendering: auto;
}

.profile-avatar-small { width: 32px; height: 32px; font-size: 0.72rem; }
.profile-avatar-medium { width: 40px; height: 40px; font-size: 0.78rem; }
.profile-avatar-large { width: 76px; height: 76px; font-size: 1.35rem; }

.company-logo {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 0;
    border-radius: 50%;
    color: #ffffff;
    font-weight: 800;
    line-height: 1;
    background: var(--accent, #0f766e);
}

.company-logo img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    object-position: center;
    background: #ffffff;
}

.company-logo-small { width: 32px; height: 32px; font-size: 0.72rem; }
.company-logo-large { width: 76px; height: 76px; font-size: 1.35rem; }

.company-logo-cell {
    width: 52px;
    vertical-align: middle;
}

.companies-table td {
    vertical-align: middle;
}

.company-cell,
.company-heading {
    display: flex;
    align-items: center;
    gap: 10px;
}

.company-cell > span {
    white-space: nowrap;
}

.avatar-cell {
    width: 48px;
}

.users-table td {
    vertical-align: middle;
}

.profile-detail-heading {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--line);
}

.profile-detail-heading p,
.profile-detail-heading h2 {
    margin: 0;
}

.profile-detail-heading p {
    color: var(--accent, #0f766e);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.profile-detail-heading h2 {
    font-size: 1.25rem;
}

.profile-detail-heading span {
    color: var(--muted);
    font-size: 0.86rem;
}

.profile-detail-heading .profile-avatar > span {
    color: #ffffff;
    font-size: inherit;
}

.button-secondary {
    min-height: 31px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 4px;
    padding: 0 12px;
    color: var(--ink);
    font-size: 0.875rem;
    font-weight: 700;
    line-height: 1;
    text-decoration: none;
    background: #f3f6f8;
    cursor: pointer;
}

.button-secondary:hover {
    background: #e7edf2;
}

.button-danger {
    min-height: 31px;
    color: #ffffff;
    background: var(--danger);
}

.button-danger:hover {
    background: #8f1c14;
}

.app-main {
    width: 100%;
    margin: 0 auto;
    padding: 32px 24px;
}

.page-heading,
.module-list,
.data-panel,
.form-panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 28px;
    background: #ffffff;
}

.page-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.page-heading + .record-form,
.page-heading + .form-panel,
.page-heading + .data-panel,
.page-heading + .detail-panel {
    margin-top: 28px;
}

.button-link {
    min-height: 31px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    padding: 0 12px;
    color: #ffffff;
    font-size: 0.875rem;
    font-weight: 700;
    background: var(--accent);
}

.button-link:hover {
    background: var(--accent-dark);
}

.button-link.secondary {
    color: var(--ink);
    background: #f3f6f8;
}

.button-link.secondary:hover {
    background: #e7edf2;
}

.heading-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.heading-actions form {
    margin: 0;
}

.notice {
    margin-top: 18px;
    margin-bottom: 18px;
    border: 1px solid #a7dbc8;
    border-radius: 8px;
    padding: 14px 18px;
    color: var(--accent-dark);
    background: var(--accent-soft);
    font-weight: 650;
}

.notice.danger,
.notice.error {
    border-color: #f1b8b3;
    color: var(--danger);
    background: #fff0ef;
}

.status-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-top: 18px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-top: 18px;
}

.stat-card {
    min-height: 92px;
    display: flex;
    align-items: center;
    gap: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
    background: #ffffff;
}

.stat-icon {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    color: var(--accent-dark);
    font-size: 0.72rem;
    font-weight: 800;
    background: var(--accent-soft);
}

.stat-card span:not(.stat-icon) {
    display: block;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 750;
    text-transform: uppercase;
}

.stat-card strong {
    display: block;
    margin-top: 4px;
    font-size: 1.18rem;
    line-height: 1.2;
}

.status-card {
    min-height: 168px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 22px;
    background: #ffffff;
}

.status-card span {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    border-radius: 999px;
    padding: 0 10px;
    font-size: 0.78rem;
    font-weight: 750;
}

.status-card.ready span {
    color: var(--accent-dark);
    background: var(--accent-soft);
}

.status-card.next span {
    color: var(--warning);
    background: #fff2c6;
}

.status-card h2,
.module-list h2 {
    margin: 14px 0 8px;
    font-size: 1.08rem;
    line-height: 1.25;
}

.status-card p,
.module-list p,
.module-row span {
    margin: 0;
    color: var(--muted);
}

.module-list,
.data-panel,
.form-panel {
    margin-top: 18px;
    padding: 0;
    overflow: hidden;
}

.form-panel {
    padding: 22px;
}

.record-form {
    display: grid;
    gap: 16px;
}

.multi-invoice-list {
    display: grid;
    gap: 20px;
}

.multi-invoice-card {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #ffffff;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

.multi-invoice-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(135deg, #f4fbfa 0%, #f8fafc 100%);
}

.multi-invoice-card-header p,
.multi-invoice-card-header h2 {
    margin: 0;
}

.multi-invoice-card-header p {
    color: var(--accent-dark);
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.multi-invoice-card-header h2 {
    margin-top: 3px;
    color: var(--ink);
    font-size: 1.05rem;
    overflow-wrap: anywhere;
}

.multi-invoice-match {
    flex: 0 0 auto;
    border-radius: 999px;
    padding: 5px 10px;
    font-size: 0.72rem;
    font-weight: 750;
}

.multi-invoice-match.matched {
    color: #166534;
    background: #dcfce7;
}

.multi-invoice-match.unmatched {
    color: #9a3412;
    background: #ffedd5;
}

.multi-invoice-card-body {
    padding: 18px 20px 22px;
}

.multi-invoice-completion {
    margin: 0;
    color: #9a3412;
    font-size: 0.82rem;
    font-weight: 700;
}

.multi-invoice-completion.complete {
    color: #166534;
}

.form-actions:has(.multi-invoice-completion) {
    justify-content: space-between;
}

.form-actions button:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.form-section-heading {
    grid-column: 1 / -1 !important;
    width: 100%;
    min-width: 0;
    margin: 8px 0 0;
    padding: 0 0 7px;
    border-bottom: 1px solid var(--line);
}

.form-section-heading:first-child {
    margin-top: 0;
}

.form-section-heading p {
    margin: 0 0 1px;
    color: var(--accent-dark);
    font-size: 0.64rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.form-section-heading h2 {
    margin: 0;
    color: var(--ink);
    font-size: 0.82rem;
    font-weight: 700;
    line-height: 1.3;
}

.record-form label {
    display: grid;
    gap: 5px;
}

.form-grid label:has(textarea) {
    grid-column: 1 / -1;
}

.form-grid .span-2 {
    grid-column: 1 / -1;
    width: 100%;
}

.record-form label span {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
}

label:has(> input[required]) > span:first-child::after,
label:has(> select[required]) > span:first-child::after,
label:has(> textarea[required]) > span:first-child::after,
.form-label:has(+ input[required])::after,
.form-label:has(+ select[required])::after,
.form-label:has(+ textarea[required])::after {
    content: " *";
    color: var(--danger);
}

.record-form input,
.record-form select,
.record-form textarea,
.form-control-sm,
.form-select-sm {
    width: 100%;
    min-height: 31px;
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--ink);
    background: #ffffff;
}

.record-form select,
.form-select-sm {
    padding-right: 1.75rem;
}

.record-form .form-control-uniform {
    height: 31px;
    min-height: 31px;
}

.record-form textarea {
    min-height: 76px;
    padding: 0.35rem 0.5rem;
    resize: vertical;
}

.record-form input:focus,
.record-form select:focus,
.record-form textarea:focus {
    border-color: var(--accent);
    outline: 3px solid rgba(15, 118, 110, 0.16);
}

.record-form small {
    color: var(--danger);
    font-weight: 650;
}

.record-form .form-check-label-inline {
    grid-template-columns: 18px minmax(0, 1fr);
    align-content: center;
    align-items: center;
    column-gap: 8px;
    min-height: 54px;
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 8px 10px;
    background: #f8fafb;
}

.record-form .form-check-label-inline input[type="checkbox"] {
    width: 16px;
    min-height: 16px;
    height: 16px;
    margin: 0;
    padding: 0;
}

.record-form .form-check-label-inline .form-hint {
    grid-column: 2;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 500;
}
.record-form small.form-hint {
    color: var(--muted);
    font-weight: 500;
}

.sede-position-map,
.azienda-position-map {
    display: grid;
    gap: 6px;
}

#sede-position-map,
#azienda-position-map {
    width: 100%;
    height: 360px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #f7fafb;
}

.sede-position-map p,
.azienda-position-map p {
    margin: 0;
    color: var(--muted);
    font-size: 0.75rem;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
}

.invoice-dropzone {
    display: flex;
    min-height: 190px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 7px;
    padding: 24px;
    border: 2px dashed var(--line);
    border-radius: 8px;
    color: var(--muted);
    background: #f8fafc;
    cursor: pointer;
    text-align: center;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.invoice-dropzone:hover,
.invoice-dropzone:focus,
.invoice-dropzone.is-dragging {
    border-color: var(--accent);
    outline: none;
    background: var(--accent-soft);
}

.invoice-dropzone.is-uploading {
    cursor: wait;
    opacity: 0.75;
    pointer-events: none;
}

.invoice-dropzone-icon {
    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;
    border-radius: 50%;
    color: var(--accent-dark);
    background: var(--accent-soft);
    font-size: 1.3rem;
    font-weight: 800;
}

.invoice-dropzone strong {
    color: var(--ink);
}

.invoice-dropzone small {
    color: var(--muted);
}

.invoice-selected-file {
    max-width: 100%;
    margin-top: 5px;
    padding: 6px 10px;
    border-radius: 4px;
    color: var(--accent-dark);
    background: var(--accent-soft);
    font-size: 0.82rem;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.invoice-upload-error {
    color: var(--danger);
    font-weight: 650;
}

.invoice-upload-progress .progress {
    height: 9px;
}

.invoice-upload-progress span,
.invoice-upload-progress strong {
    font-size: 0.82rem;
}

.invoice-upload-status-wrap {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.invoice-upload-status-wrap .spinner-border {
    width: 0.85rem;
    height: 0.85rem;
    border-width: 0.13em;
    color: var(--accent);
}

.detail-panel {
    margin-top: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 28px;
    background: #ffffff;
}

.map-panel {
    margin-top: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    background: #ffffff;
}

.map-panel header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 18px 22px;
    border-bottom: 1px solid var(--line);
}

.map-panel header p {
    margin: 0 0 5px;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 750;
    text-transform: uppercase;
}

.map-panel h2 {
    margin: 0;
    font-size: 1.08rem;
}

.map-panel iframe {
    width: 100%;
    height: 360px;
    display: block;
    border: 0;
    background: #f7fafb;
}

.map-panel-compact {
    height: 100%;
    margin-top: 0;
    display: flex;
    flex-direction: column;
}

.map-panel-compact header {
    padding: 14px 16px;
}

.map-panel-compact iframe {
    min-height: 300px;
    flex: 1;
}

.map-panel-company header {
    padding: 14px 16px;
}

.map-panel-company iframe {
    height: 260px;
}

.company-media-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
    gap: 16px;
}

.company-photo-card,
.company-map-column,
.company-map-column .map-panel-company {
    height: 100%;
}

.company-map-column .map-panel-company {
    display: flex;
    flex-direction: column;
}

.company-map-column .map-panel-company iframe {
    min-height: 260px;
    flex: 1;
}

.azienda-photo,
.azienda-photo-placeholder {
    width: 100%;
    height: 180px;
    display: block;
    border: 1px solid var(--line);
    border-radius: 6px;
    object-fit: cover;
    background: #f7fafb;
}

.azienda-photo-placeholder {
    display: grid;
    place-items: center;
    color: var(--muted);
    font-size: 0.875rem;
    font-weight: 700;
}

.agenda-modal .modal-header,
.agenda-modal .modal-footer {
    border-color: var(--line);
}

.agenda-modal .modal-header p {
    margin: 0 0 4px;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 750;
    text-transform: uppercase;
}

.agenda-modal .modal-title {
    margin: 0;
    font-size: 1.16rem;
    font-weight: 800;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin: 0;
}

.detail-grid div {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
    background: #f9fbfc;
}

.detail-grid dt {
    margin: 0 0 5px;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 750;
    text-transform: uppercase;
}

.detail-grid dd {
    margin: 0;
    font-weight: 650;
    overflow-wrap: anywhere;
}

.detail-grid a {
    color: var(--accent-dark);
}

.detail-notes {
    margin-top: 22px;
    border-top: 1px solid var(--line);
    padding-top: 22px;
}

.detail-notes h2 {
    margin: 0 0 8px;
    font-size: 1.08rem;
}

.detail-notes p {
    margin: 0;
    color: var(--muted);
}

.invoice-detail-panel {
    display: grid;
    gap: 24px;
    padding: 22px;
}

.invoice-overview {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.invoice-highlight {
    display: grid;
    align-content: space-between;
    min-height: 112px;
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 14px;
    background: #f8fafb;
}

.invoice-highlight.primary {
    border-color: #a7ded5;
    background: var(--accent-soft);
}

.invoice-highlight span,
.invoice-highlight small {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
}

.invoice-highlight strong {
    margin: 6px 0;
    color: var(--ink);
    font-size: 1.28rem;
    line-height: 1.2;
    overflow-wrap: anywhere;
}

.invoice-highlight.primary strong {
    color: var(--accent-dark);
    font-size: 1.55rem;
}

.invoice-highlight .invoice-status-value {
    font-size: 1rem;
}

.invoice-detail-section {
    display: grid;
    gap: 12px;
}

.invoice-detail-section > header {
    padding-bottom: 7px;
    border-bottom: 1px solid var(--line);
}

.invoice-detail-section > header p,
.invoice-notes > p {
    margin: 0 0 1px;
    color: var(--accent-dark);
    font-size: 0.64rem;
    font-weight: 800;
    letter-spacing: 0.05em;
}

.invoice-detail-section > header h2,
.invoice-notes h2 {
    margin: 0;
    font-size: 0.82rem;
    font-weight: 700;
}

.invoice-detail-section .detail-grid {
    gap: 10px;
}

.invoice-detail-section .detail-grid div {
    border: 0;
    border-radius: 0;
    padding: 5px 0;
    background: transparent;
}

.invoice-detail-section .detail-grid dt {
    margin-bottom: 3px;
    font-size: 0.7rem;
}

.invoice-detail-section .detail-grid dd {
    font-size: 0.9rem;
}

.invoice-detail-section .detail-grid .span-2 {
    grid-column: span 2;
}

.invoice-cost-grid dd {
    font-variant-numeric: tabular-nums;
}

.invoice-band-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.invoice-band-grid div {
    display: grid;
    gap: 3px;
    border-left: 3px solid var(--accent);
    padding: 8px 10px;
    background: #f8fafb;
}

.invoice-band-grid span {
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 800;
}

.invoice-band-grid strong {
    font-size: 0.9rem;
}

.secondary-information {
    color: #354454;
}

.invoice-notes {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
}

.invoice-notes > div {
    margin-top: 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 12px;
    color: var(--muted);
    font-size: 0.88rem;
    white-space: pre-wrap;
}

.module-list header,
.data-panel header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
}

.data-panel header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.data-panel header > div {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 6px;
}

.data-panel header h2 {
    order: 2;
}

.panel-header-total {
    order: 3;
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 500;
}

.data-panel header p {
    order: 1;
    flex-basis: 100%;
}

.data-panel header > .btn,
.data-panel header > .button-link,
.data-panel header > form,
.data-panel header > .inline-search {
    margin-left: auto;
}

.data-panel .panel-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding-bottom: 18px;
}

.module-list h2,
.data-panel h2 {
    margin: 0;
    font-size: 1rem;
}

.data-panel header p {
    margin: 0;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0;
}

.panel-filters {
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    background: #fbfdfe;
}

.panel-summary {
    display: flex;
    align-items: baseline;
    gap: 7px;
    padding: 10px 16px 0;
    color: var(--muted);
    font-size: 0.84rem;
    font-weight: 700;
    text-transform: uppercase;
}

.panel-summary strong {
    color: var(--ink);
    font-size: 1.06rem;
}

.data-panel header:has(.inline-search),
.data-panel header:has(.button-link) {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.inline-search {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.inline-search label {
    display: grid;
    gap: 3px;
    margin: 0;
}

.inline-search label > span {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
}

.inline-search .filter-grow {
    flex: 1 1 280px;
}

.inline-search .filter-grow input {
    width: 100%;
}

.inline-search .filter-actions {
    display: flex;
    align-items: end;
    gap: 8px;
    padding-top: 20px;
}

.inline-search input,
.inline-search select,
.inline-search .form-control-sm,
.inline-search .form-select-sm {
    min-height: 31px;
    width: min(220px, 100%);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
    line-height: 1.5;
}

.inline-search button {
    min-height: 31px;
    padding: 0 12px;
    font-size: 0.875rem;
}

.panel-filters .inline-search input[name="search"] {
    width: min(300px, 100%);
}

.inline-search input:focus,
.inline-search select:focus {
    border-color: var(--accent);
    outline: 3px solid rgba(15, 118, 110, 0.16);
}

.table-scroll {
    overflow-x: auto;
    padding: 12px 16px 16px;
}

table {
    width: 100%;
    border: 1px solid var(--line);
    border-collapse: separate;
    border-spacing: 0;
    border-radius: 6px;
    overflow: hidden;
}

.table-responsive {
    padding: 1rem;
}

.table-responsive > .table {
    margin-bottom: 0;
}

th,
td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--line);
    font-size: 0.875rem;
    line-height: 1.35;
    text-align: left;
    vertical-align: top;
    white-space: nowrap;
}

th {
    color: var(--muted);
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0;
    background: #f7fafb;
}

td {
    color: var(--ink);
}

tbody tr:last-child td {
    border-bottom: 0;
}

.table-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.table-actions a,
.table-actions .table-action-button {
    min-height: 26px;
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 0 8px;
    color: var(--accent-dark);
    font-size: 0.78rem;
    font-weight: 700;
    background: #ffffff;
}

.table-actions a:hover,
.table-actions .table-action-button:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.table-actions form {
    margin: 0;
}

.table-actions .button-danger {
    min-height: 26px;
    padding: 0 8px;
    font-size: 0.78rem;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    border-radius: 999px;
    padding: 0 8px;
    color: var(--accent-dark);
    font-size: 0.76rem;
    font-weight: 750;
    background: var(--accent-soft);
}

.semantic-status-badge {
    display: inline-flex;
    min-height: 21px;
    align-items: center;
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 1px 8px;
    font-size: 0.7rem;
    font-weight: 750;
    line-height: 1.25;
    white-space: nowrap;
}

.semantic-status-badge.is-success {
    border-color: #a7f3d0;
    color: #065f46;
    background: #ecfdf5;
}

.semantic-status-badge.is-danger {
    border-color: #fecaca;
    color: #991b1b;
    background: #fef2f2;
}

.semantic-status-badge.is-warning {
    border-color: #fde68a;
    color: #854d0e;
    background: #fffbeb;
}

.semantic-status-badge.is-info {
    border-color: #bfdbfe;
    color: #1e40af;
    background: #eff6ff;
}

.semantic-status-badge.is-neutral {
    border-color: #d1d5db;
    color: #4b5563;
    background: #f9fafb;
}

.delete-confirmation-popup {
    border-top: 4px solid var(--danger);
    border-radius: 8px;
    font-family: inherit;
}

.anomaly-badge {
    display: inline-flex;
    min-height: 21px;
    align-items: center;
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 1px 8px;
    font-size: 0.7rem;
    font-weight: 750;
    line-height: 1.25;
    white-space: nowrap;
}

.anomaly-badge.severity-critical,
.anomaly-badge.severity-high {
    border-color: #fecaca;
    color: #991b1b;
    background: #fef2f2;
}

.anomaly-badge.severity-medium,
.anomaly-badge.status-reviewing {
    border-color: #fde68a;
    color: #854d0e;
    background: #fffbeb;
}

.anomaly-badge.severity-low {
    border-color: #bfdbfe;
    color: #1e40af;
    background: #eff6ff;
}

.anomaly-badge.status-open {
    border-color: #fed7aa;
    color: #9a3412;
    background: #fff7ed;
}

.anomaly-badge.status-resolved {
    border-color: #a7f3d0;
    color: #065f46;
    background: #ecfdf5;
}

.anomaly-badge.status-ignored {
    border-color: #d1d5db;
    color: #4b5563;
    background: #f9fafb;
}

.document-status-badge {
    display: inline-flex;
    min-height: 21px;
    align-items: center;
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 1px 8px;
    font-size: 0.7rem;
    font-weight: 750;
    line-height: 1.25;
    white-space: nowrap;
}

.document-status-badge.status-uploaded,
.document-status-badge.status-queued {
    border-color: #bfdbfe;
    color: #1e40af;
    background: #eff6ff;
}

.document-status-badge.status-processing {
    border-color: #fde68a;
    color: #854d0e;
    background: #fffbeb;
}

.document-status-badge.status-review {
    border-color: #a7f3d0;
    color: #065f46;
    background: #ecfdf5;
}

.document-status-badge.status-failed {
    border-color: #fecaca;
    color: #991b1b;
    background: #fef2f2;
}

.view-switch {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 3px;
    background: #f7fafb;
}

.view-switch button {
    min-height: 28px;
    border-radius: 4px;
    padding: 0 12px;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 750;
    background: transparent;
}

.view-switch button:hover,
.view-switch button.active {
    color: #ffffff;
    background: var(--accent);
}

.calendar-panel {
    padding: 18px 28px 28px;
}

#agenda-calendar {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
    background: #fbfdfe;
}

#agenda-calendar .fc-header-toolbar,
#agenda-calendar .genko-calendar-toolbar {
    display: grid;
    grid-template-columns: minmax(170px, auto) minmax(0, 1fr) minmax(260px, auto);
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    background: #ffffff;
}

#agenda-calendar .fc .fc-toolbar,
#agenda-calendar .fc-toolbar {
    display: grid;
    grid-template-columns: minmax(170px, auto) minmax(0, 1fr) minmax(260px, auto);
    align-items: center;
    gap: 12px;
}

#agenda-calendar .fc-header-toolbar .fc-toolbar-chunk {
    display: flex;
    align-items: center;
    gap: 6px;
}

#agenda-calendar .fc-header-toolbar .fc-toolbar-chunk:nth-child(2) {
    justify-content: center;
}

#agenda-calendar .fc-header-toolbar .fc-toolbar-chunk:nth-child(3) {
    justify-content: flex-end;
}

#agenda-calendar .fc-toolbar-title {
    color: var(--ink);
    font-size: 1.08rem;
    font-weight: 800;
}

#agenda-calendar .fc-button {
    border: 1px solid var(--line);
    border-radius: 4px;
    min-height: 31px;
    padding: 0.22rem 0.58rem;
    color: var(--ink);
    font-size: 0.8rem;
    font-weight: 750;
    background: #ffffff !important;
    box-shadow: none;
}

#agenda-calendar .fc-button-group {
    display: inline-flex;
    gap: 3px;
}

#agenda-calendar .fc-button-primary:not(:disabled).fc-button-active,
#agenda-calendar .fc-button-primary:not(:disabled):active,
#agenda-calendar .fc-button:hover {
    border-color: var(--accent);
    color: #ffffff;
    background: var(--accent) !important;
}

#agenda-calendar .fc-button-primary:not(:disabled).fc-button-active {
    border-color: var(--accent-dark) !important;
    color: #ffffff !important;
    background: var(--accent-dark) !important;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2), 0 6px 14px rgba(15, 118, 110, 0.2);
}

#agenda-calendar .fc-event {
    border: 0 !important;
    border-left: 4px solid var(--genko-event-border, rgba(15, 118, 110, 0.95)) !important;
    border-radius: 6px;
    padding: 3px 6px;
    color: #ffffff !important;
    font-size: 0.76rem;
    font-weight: 750;
    line-height: 1.2;
    background: linear-gradient(135deg, var(--genko-event-start, #0f766e), var(--genko-event-end, #168a5b)) !important;
    box-shadow: 0 7px 14px rgba(15, 23, 42, 0.12);
}

#agenda-calendar .fc-event:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 18px rgba(15, 23, 42, 0.16);
}

#agenda-calendar .fc-event-main,
#agenda-calendar .fc-event-title,
#agenda-calendar .fc-event-time,
#agenda-calendar .fc-daygrid-event-dot,
#agenda-calendar .fc-event-title-container {
    color: #ffffff !important;
}

#agenda-calendar .fc-daygrid-dot-event .fc-event-title,
#agenda-calendar .fc-daygrid-dot-event .fc-event-time {
    color: #ffffff !important;
}

#agenda-calendar .fc-daygrid-event-dot {
    display: none;
}

#agenda-calendar .genko-event-content {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 5px;
}

#agenda-calendar .genko-event-time {
    flex: 0 0 auto;
    font-weight: 850;
    opacity: 0.9;
}

#agenda-calendar .genko-event-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#agenda-calendar .fc-daygrid-event {
    margin: 2px 5px 3px;
}

#agenda-calendar .fc-timegrid-event {
    min-height: 24px;
}

#agenda-calendar .genko-event-status-confermato {
    border-left-color: #064e3b !important;
    background: linear-gradient(135deg, var(--genko-event-start, #0f766e), var(--genko-event-end, #16a34a)) !important;
}

#agenda-calendar .genko-event-status-rimandato {
    border-left-color: #92400e !important;
    background: linear-gradient(135deg, var(--genko-event-start, #b7791f), var(--genko-event-end, #d97706)) !important;
}

#agenda-calendar .genko-event-status-annullato {
    border-left-color: #7f1d1d !important;
    background: linear-gradient(135deg, var(--genko-event-start, #b42318), var(--genko-event-end, #dc2626)) !important;
}

#agenda-calendar.fc-theme-standard .fc-scrollgrid,
#agenda-calendar.fc-theme-standard .fc-scrollgrid-section > td,
#agenda-calendar.fc-theme-standard td,
#agenda-calendar.fc-theme-standard th,
#agenda-calendar .fc-theme-standard .fc-scrollgrid,
#agenda-calendar .fc-theme-standard .fc-scrollgrid-section > td,
#agenda-calendar .fc-theme-standard td,
#agenda-calendar .fc-theme-standard th,
#agenda-calendar .fc table,
#agenda-calendar .fc td,
#agenda-calendar .fc th,
#agenda-calendar .fc-scrollgrid,
#agenda-calendar .fc-scrollgrid-section > td {
    border-color: #c7d2dc !important;
}

#agenda-calendar .fc-daygrid-day,
#agenda-calendar .fc-timegrid-slot,
#agenda-calendar .fc-timegrid-col {
    border: 1px solid #c7d2dc !important;
}

#agenda-calendar .fc-daygrid-day-frame {
    min-height: 106px;
    border: 0;
}

#agenda-calendar .fc-col-header-cell {
    background: #f7fafb;
}

#agenda-calendar .fc-daygrid-day-number,
#agenda-calendar .fc-col-header-cell-cushion {
    color: var(--ink);
    font-size: 0.82rem;
    font-weight: 750;
}

#agenda-calendar .fc-day-today,
#agenda-calendar .fc .fc-day-today,
#agenda-calendar td.fc-day-today,
#agenda-calendar th.fc-day-today {
    position: relative;
    background-color: #d9f8ec !important;
    background-image: linear-gradient(180deg, rgba(15, 118, 110, 0.18), rgba(15, 118, 110, 0.05)) !important;
    box-shadow: none;
}

#agenda-calendar .fc-day-today .fc-daygrid-day-frame {
    background: transparent;
}

#agenda-calendar .fc-day-today .fc-daygrid-day-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    margin: 6px 6px 0 0;
    border-radius: 999px;
    color: #ffffff;
    background: var(--accent);
    box-shadow: 0 8px 16px rgba(15, 118, 110, 0.22);
}

#agenda-calendar .fc-timegrid-col.fc-day-today {
    background: #e9fbf5 !important;
}

#agenda-calendar .fc-timegrid-now-indicator-line {
    border-color: #b42318;
    border-width: 2px 0 0;
}

#agenda-calendar .fc-timegrid-now-indicator-arrow {
    border-color: #b42318;
}

.empty-state {
    padding: 34px 28px;
}

.empty-state h2 {
    margin: 0 0 8px;
    font-size: 1.12rem;
}

.empty-state p {
    margin: 0;
    color: var(--muted);
}

nav[role="navigation"] {
    padding: 16px 28px 22px;
}

nav[role="navigation"] > div:first-child {
    display: none;
}

nav[role="navigation"] > div:last-child {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    color: var(--muted);
    font-size: 0.9rem;
}

nav[role="navigation"] a,
nav[role="navigation"] span[aria-current="page"] span,
nav[role="navigation"] span[aria-disabled="true"] span {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0 10px;
    background: #ffffff;
}

nav[role="navigation"] span[aria-current="page"] span {
    color: #ffffff;
    border-color: var(--accent);
    background: var(--accent);
}

.module-row {
    display: grid;
    grid-template-columns: minmax(220px, 0.85fr) minmax(0, 1.15fr);
    gap: 20px;
    padding: 18px 28px;
    border-bottom: 1px solid var(--line);
}

.module-row:last-child {
    border-bottom: 0;
}

@media (max-width: 991.98px) {
    .multi-invoice-card-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .multi-invoice-card-body {
        padding: 16px;
    }

    .multi-invoice-match {
        white-space: normal;
    }

    .invoice-overview {
        grid-template-columns: 1fr;
    }

    .invoice-band-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .invoice-detail-panel {
        padding: 16px;
    }

    .invoice-detail-section .detail-grid .span-2 {
        grid-column: auto;
    }

    .app-shell {
        display: block;
    }

    .sidebar {
        position: fixed;
        z-index: 1051;
        inset: 0 auto 0 0;
        width: min(86vw, 310px);
        min-height: 100dvh;
        padding: 18px;
        overflow-y: auto;
        transform: translateX(-105%);
        transition: transform 180ms ease-out;
        box-shadow: 14px 0 36px rgba(15, 23, 42, 0.24);
    }

    .sidebar-open {
        overflow: hidden;
    }

    .sidebar-open .sidebar {
        transform: translateX(0);
    }

    .sidebar-backdrop {
        position: fixed;
        z-index: 1050;
        inset: 0;
        width: 100%;
        height: 100%;
        min-height: 100dvh;
        border: 0;
        border-radius: 0;
        padding: 0;
        background: rgba(15, 23, 42, 0.58);
        opacity: 0;
        pointer-events: none;
        transition: opacity 180ms ease-out;
    }

    .sidebar-open .sidebar-backdrop {
        display: block;
        opacity: 1;
        pointer-events: auto;
    }

    .sidebar-backdrop:hover,
    .sidebar-backdrop:focus {
        background: rgba(15, 23, 42, 0.58);
    }

    .sidebar-close {
        position: absolute;
        top: 12px;
        right: 12px;
        width: 34px;
        height: 34px;
        min-height: 34px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 0;
        color: #ffffff;
        font-size: 1.65rem;
        line-height: 1;
        background: rgba(255, 255, 255, 0.1);
    }

    .sidebar-close:hover,
    .sidebar-close:focus {
        background: rgba(255, 255, 255, 0.18);
    }

    .sidebar-toggle {
        width: 38px;
        height: 38px;
        min-height: 38px;
        flex: 0 0 38px;
        display: inline-flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        padding: 0;
    }

    .sidebar-toggle span {
        width: 18px;
        height: 2px;
        display: block;
        border-radius: 2px;
        background: #ffffff;
    }

    .topbar-identity {
        min-width: 0;
        flex: 1;
    }

    .brand {
        padding-right: 40px;
    }

    .sidebar-nav {
        grid-template-columns: 1fr;
        margin-top: 18px;
    }

    .login-panel {
        padding: 24px;
    }

    .topbar {
        position: sticky;
        z-index: 100;
        top: 0;
        min-height: 60px;
        display: flex;
        align-items: center;
        flex-direction: row;
        gap: 12px;
        padding: 10px 16px;
    }

    .topbar form {
        flex: 0 0 auto;
        margin: 0;
    }

    .topbar form button {
        width: auto;
    }

    .app-main {
        padding: 18px 16px;
    }

    .page-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .data-panel header:has(.inline-search),
    .data-panel header:has(.button-link),
    .inline-search {
        align-items: stretch;
        flex-direction: column;
    }

    .inline-search input,
    .inline-search select,
    .inline-search button {
        width: 100%;
    }

    .button-link {
        width: 100%;
    }

    .heading-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .map-panel header {
        align-items: stretch;
        flex-direction: column;
    }

    .map-panel iframe {
        height: 300px;
    }

    .company-media-grid {
        grid-template-columns: 1fr;
    }

    .status-grid,
    .stats-grid,
    .module-row,
    .form-grid,
    .detail-grid {
        grid-template-columns: 1fr;
    }

    .page-heading,
    .module-list header {
        padding: 22px;
    }

    .data-panel header {
        padding: 12px 16px;
    }

    .panel-filters,
    .panel-summary,
    .calendar-panel {
        padding-right: 16px;
        padding-left: 16px;
    }

    .data-panel .panel-title {
        align-items: stretch;
        flex-direction: column;
    }

    .view-switch,
    .view-switch button {
        width: 100%;
    }

    #agenda-calendar {
        padding: 10px;
    }

    #agenda-calendar .fc-header-toolbar {
        grid-template-columns: 1fr;
    }

    #agenda-calendar .fc-header-toolbar .fc-toolbar-chunk,
    #agenda-calendar .fc-header-toolbar .fc-toolbar-chunk:nth-child(2),
    #agenda-calendar .fc-header-toolbar .fc-toolbar-chunk:nth-child(3) {
        justify-content: center;
        flex-wrap: wrap;
    }

    .module-row {
        gap: 6px;
        padding: 16px 22px;
    }

    th,
    td {
        padding: 8px 10px;
    }

    .table-scroll {
        padding: 12px 16px 16px;
    }

    .empty-state {
        padding: 26px 22px;
    }

    .form-panel {
        padding: 22px;
    }

    .form-actions,
    .form-actions button {
        width: 100%;
    }
}
