/* Base Variables */
:root {
    --accent-color: #006D77; /* Teal Green (Green with a note of blue) */
    --accent-dark: #004B52;
    --accent-light: #E6F2F2;
    --mint-bg: #F2F8F8;
    --text-main: #2C3E50;
    --text-muted: #607D8B;
    --border-color: #D1D9E0;
    --bg-gray: #F8FAFB;
}

[v-cloak] { display: none; }
.print-only { display: none; }

body {
    font-family: 'Inter', sans-serif;
    color: var(--text-main);
    margin: 0;
    padding: 0;
    background-color: var(--bg-gray);
    font-size: 0.9rem;
}

/* App Header (No Print) */
.app-header {
    background-color: white;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-header h1 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--accent-dark);
}

.header-actions {
    display: flex;
    gap: 1rem;
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    font-size: 0.9rem;
    border: none;
}

.btn-primary {
    background-color: var(--accent-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--accent-dark);
}

.btn-outline {
    background-color: transparent;
    border: 1px solid var(--accent-color);
    color: var(--accent-color);
}

.btn-outline:hover {
    background-color: var(--accent-light);
}

.btn-outline-danger {
    background-color: transparent;
    border: 1px solid #e57373;
    color: #c62828;
}

.btn-outline-danger:hover {
    background-color: #ffebee;
}

.btn-success {
    background-color: #2e7d32;
    color: white;
}
.btn-success:hover {
    background-color: #1b5e20;
}

.btn-danger {
    background-color: #d32f2f;
    color: white;
}
.btn-danger:hover {
    background-color: #c62828;
}

.btn-small {
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
}

.btn-full {
    width: 100%;
    margin-top: 1rem;
}

.btn-full--flush {
    margin-top: 0;
}

/* Layout */
.main-container {
    display: flex;
    gap: 2rem;
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

/* Sidebar */
.editor-sidebar {
    width: 350px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.panel {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.panel h3 {
    margin-top: 0;
    margin-bottom: 1rem;
    font-size: 1.1rem;
    color: var(--accent-dark);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-row {
    display: flex;
    gap: 1rem;
}

.form-row .form-group {
    flex: 1;
}

label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.4rem;
    color: var(--text-muted);
}

input[type="text"], input[type="email"], input[type="password"], input[type="date"], input[type="number"], select, textarea {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: inherit;
    box-sizing: border-box;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px var(--accent-light);
}

.toggle-group {
    margin-bottom: 0.8rem;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--text-main);
}

hr {
    border: 0;
    border-top: 1px solid var(--border-color);
    margin: 1.5rem 0;
}

/* Document Preview Wrapper */
.document-preview-wrapper {
    flex-grow: 1;
    display: flex;
    justify-content: center;
}

/* A4 Document */
.a4-document {
    background: white;
    width: 210mm;
    min-height: 297mm;
    padding: 20mm;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    box-sizing: border-box;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* Doc Header */
.doc-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 2rem;
    border-bottom: 2px solid var(--accent-color);
    padding-bottom: 1rem;
    align-items: flex-end;
}

.doc-meta-info {
    text-align: right;
}

.doc-badge {
    display: inline-block;
    color: var(--accent-dark);
    padding: 0;
    font-weight: 700;
    font-size: 1.2rem;
    letter-spacing: 1px;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
}

.proforma-warning {
    color: #d32f2f;
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
}

.meta-table {
    margin-left: auto;
    font-size: 0.85rem;
}

.meta-table td {
    padding: 0.2rem 0;
}

.meta-table td:first-child {
    color: var(--text-muted);
    padding-right: 1rem;
    text-align: right;
}

.doc-header--expense {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto;
    column-gap: 1.5rem;
    row-gap: 0.15rem;
    align-items: baseline;
}

.doc-header--expense .doc-type-info {
    grid-row: 1;
    grid-column: 1;
}

.doc-header--expense .doc-badge {
    margin-bottom: 0;
}

.expense-header-line {
    grid-column: 2;
    display: flex;
    justify-content: flex-end;
    align-items: baseline;
    flex-wrap: nowrap;
    gap: 1.5rem;
    font-size: 0.85rem;
}

.expense-header-line:not(.expense-header-line--end) {
    grid-row: 1;
}

.expense-header-line--end {
    grid-row: 2;
}

.expense-meta-chip {
    display: inline-flex;
    align-items: baseline;
    gap: 0.5rem;
    white-space: nowrap;
}

.expense-meta-chip .meta-label,
.doc-header--expense .meta-label {
    color: var(--text-muted);
    white-space: nowrap;
}

.expense-trip-date {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* Addresses Section */
.addresses-section {
    display: flex;
    justify-content: space-between;
    margin-bottom: 2rem;
    gap: 3rem;
}

.issuer-box, .client-box {
    flex: 1;
}

.address-label {
    margin: 0 0 0.3rem 0;
    color: var(--accent-color);
    font-size: 0.7rem;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 1px;
    border-bottom: 1px solid var(--accent-light);
    display: inline-block;
    padding-bottom: 2px;
}

.issuer-name, .client-name {
    margin: 0.5rem 0 0.5rem 0;
    font-size: 1rem;
    color: var(--text-main);
}

.issuer-box p, .client-box p {
    margin: 0;
    font-size: 0.8rem;
    line-height: 1.4;
    color: var(--text-muted);
}

/* Items Table */
.items-section {
    margin-bottom: 1.5rem;
}

.items-table {
    width: 100%;
    border-collapse: collapse;
}

.items-table th {
    background-color: var(--accent-light);
    color: var(--accent-dark);
    text-align: left;
    padding: 0.6rem;
    font-weight: 600;
    font-size: 0.8rem;
}

.items-table td {
    padding: 0.6rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: top;
    font-size: 0.8rem;
}

.items-table tbody tr:nth-child(even) {
    background-color: #fafbfa;
}

.col-um {
    width: 8%;
    text-align: center;
}

.col-qty, .col-price, .col-total {
    text-align: right;
    width: 13%;
}

.items-table th.col-um {
    text-align: center;
}

.items-table th.col-qty, .items-table th.col-price, .items-table th.col-total {
    text-align: right;
}

.col-actions {
    width: 5%;
    text-align: center;
}

/* Inline Inputs for Table */
.inline-input {
    border: 1px solid transparent;
    background: transparent;
    padding: 0.3rem;
    width: 100%;
    font-family: inherit;
    font-size: inherit;
    color: inherit;
}

.inline-input:focus, .inline-input:hover {
    border: 1px solid var(--border-color);
    background: white;
}

.desc-input {
    resize: none;
    overflow: hidden;
    min-height: 24px;
}

.um-input {
    text-align: center;
}

.num-input {
    text-align: right;
    -moz-appearance: textfield;
}

.num-input::-webkit-outer-spin-button,
.num-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.currency-input {
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.btn-icon {
    background: none;
    border: none;
    color: #f44336;
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0.5;
}

.btn-icon:hover {
    opacity: 1;
}

.add-row-wrapper {
    margin-top: 1rem;
}

/* Totals Section */
.totals-section {
    width: 100%;
    display: flex;
    justify-content: flex-end;
    margin-bottom: 2rem;
}

.totals-box {
    background-color: var(--mint-bg);
    border-radius: 8px;
    padding: 1.5rem;
    width: 50%;
}

/* Spacer */
.doc-spacer {
    flex-grow: 1;
}

/* Notes Section */
.notes-section {
    border-left: 4px solid var(--accent-color);
    padding-left: 1rem;
    width: 100%;
    margin-bottom: 2rem;
    page-break-inside: avoid;
}

.notes-label {
    font-weight: 600;
    color: var(--accent-dark);
    margin: 0 0 0.5rem 0;
    font-size: 0.8rem;
}

.banking-coords {
    margin-bottom: 0.75rem;
}

.banking-coords .coord-line {
    margin: 0 0 0.35rem 0;
    font-size: 0.8rem;
    line-height: 1.5;
}

.notes-extra-hint {
    margin: 0 0 0.25rem 0;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 400;
}

.notes-textarea {
    border: 1px solid transparent;
    background: transparent;
    width: 100%;
    resize: none;
    overflow: hidden;
    font-family: inherit;
    font-size: 0.8rem;
    line-height: 1.5;
    padding: 0;
    min-height: 1.5em;
}

.notes-textarea:focus, .notes-textarea:hover {
    border: 1px solid var(--border-color);
    background: #fff;
    padding: 0.5rem;
}

.total-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.8rem;
    font-size: 0.8rem;
    align-items: center;
}

.total-row span:last-child {
    white-space: nowrap;
}

.total-row:last-child {
    margin-bottom: 0;
}

.final-total {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 2px solid var(--accent-color);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent-dark);
}

/* Footer */
.doc-footer {
    margin-top: auto;
    border-top: 1px solid var(--border-color);
    padding-top: 1rem;
    font-size: 0.7rem;
    color: var(--text-muted);
    text-align: justify;
    page-break-inside: avoid;
}

.doc-footer p {
    margin: 0 0 0.4rem 0;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.pdf-generating-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(44, 62, 80, 0.32);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 2000;
    pointer-events: all;
}

.pdf-generating-overlay[hidden] {
    display: none !important;
}

.pdf-generating-overlay__card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.85rem;
    padding: 2rem 2.75rem;
    min-width: 260px;
    text-align: center;
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(0, 109, 119, 0.14);
    border-radius: 14px;
    box-shadow:
        0 1px 2px rgba(0, 77, 82, 0.06),
        0 16px 40px rgba(0, 0, 0, 0.14);
    animation: pdf-overlay-enter 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.pdf-generating-overlay__spinner {
    width: 38px;
    height: 38px;
    border: 2.5px solid var(--accent-light);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: pdf-overlay-spin 0.9s cubic-bezier(0.45, 0.05, 0.55, 0.95) infinite;
}

.pdf-generating-overlay__title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--accent-dark);
}

.pdf-generating-overlay__subtitle {
    margin: -0.35rem 0 0;
    font-size: 0.82rem;
    font-weight: 400;
    color: var(--text-muted);
    letter-spacing: 0.01em;
}

@keyframes pdf-overlay-spin {
    to { transform: rotate(360deg); }
}

@keyframes pdf-overlay-enter {
    from {
        opacity: 0;
        transform: scale(0.96) translateY(8px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content.large {
    max-width: 800px;
}

.history-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-top: 1rem;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.history-table th, .history-table td {
    padding: 0.65rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
    vertical-align: middle;
}

.history-table th {
    background: var(--accent-light);
    color: var(--accent-dark);
    font-weight: 600;
    font-size: 0.8rem;
}

.history-table tbody tr:hover {
    background-color: #fafbfa;
}

.history-table .col-total,
.history-table th.col-total {
    text-align: right;
    white-space: nowrap;
}

.history-table .col-actions,
.history-table th.col-actions {
    width: 1%;
    white-space: nowrap;
}

.page-note-spese .history-table .col-number,
.page-note-spese .history-table th.col-number {
    min-width: 14rem;
    white-space: nowrap;
}

.page-note-spese .history-table .col-period,
.page-note-spese .history-table th.col-period {
    min-width: 7.5rem;
}

.page-note-spese .history-table .actions-cell {
    white-space: nowrap;
    width: 1%;
}

.trip-period-lines {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    line-height: 1.35;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.currency-cell {
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.doc-type-badge {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.doc-type-badge--fattura {
    background: var(--accent-light);
    color: var(--accent-dark);
}

.doc-type-badge--proforma {
    background: #fff3e0;
    color: #e65100;
}

.history-actions {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.35rem;
    align-items: center;
}

.modal-content.doc-history-modal {
    padding: 1.25rem 2rem 2rem;
    max-width: 960px;
}

.modal-content.doc-history-modal h2 {
    margin: 0 0 0.35rem;
}

.doc-history-tabs {
    display: flex;
    gap: 0.35rem;
    margin: 1rem 0 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.doc-history-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    margin: 0 0 -1px;
    padding: 0.55rem 0.85rem;
    border: none;
    border-bottom: 2px solid transparent;
    background: none;
    color: var(--text-muted);
    font: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
}

.doc-history-tab:hover {
    color: var(--text-main);
}

.doc-history-tab--active {
    color: var(--accent-color);
    border-bottom-color: var(--accent-color);
}

.doc-history-tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.35rem;
    padding: 0.1rem 0.4rem;
    border-radius: 999px;
    background: var(--bg-gray);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
}

.doc-history-tab--active .doc-history-tab-count {
    background: var(--accent-light);
    color: var(--accent-dark);
}

.modal-actions {
    margin-top: 1.5rem;
}

.success-message {
    color: #2e7d32;
    font-size: 0.9rem;
    margin-top: 0.5rem;
    text-align: center;
    font-weight: 500;
}

/* Statistiche fatturato */
.modal-content.stats-modal {
    padding: 1.25rem 2rem 2rem;
    max-width: 1280px;
}

.modal-content.stats-modal h2 {
    margin: 0 0 0.35rem;
}

.stats-hint {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin: 0 0 1rem;
}

.stats-params {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1.25rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.stats-params .form-group {
    margin: 0;
    display: flex;
    flex-direction: column;
}

.stats-params label {
    font-size: 0.8rem;
    min-height: 2.6em;
    line-height: 1.3;
    margin-bottom: 0.4rem;
}

.stats-params input,
.stats-params select {
    width: 100%;
    box-sizing: border-box;
    height: 2.375rem;
    margin: 0;
    padding: 0.5rem;
    background-color: #fff;
}

@media (max-width: 640px) {
    .stats-params {
        grid-template-columns: 1fr;
    }
}

.stats-history-warning {
    margin-top: 0.75rem;
    line-height: 1.45;
}

.stats-history-save-error {
    margin-bottom: 1rem;
}

.stats-history-warning-link {
    display: inline;
    margin: 0;
    padding: 0;
    border: none;
    background: none;
    color: inherit;
    font: inherit;
    font-weight: 600;
    text-decoration: underline;
    cursor: pointer;
}

.stats-history-warning-link:hover {
    color: #bf360c;
}

.stats-prior-year-calc {
    margin-top: 1rem;
    padding: 0.85rem 1rem;
    background: var(--bg-gray);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.stats-prior-year-calc-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.stats-prior-year-calc-table {
    font-size: 0.8rem;
}

.stats-prior-year-calc-table td:not(:first-child) {
    color: var(--accent-dark);
    font-weight: 600;
}

.modal-content.stats-history-modal {
    padding: 1.25rem 2rem 2rem;
    max-width: 960px;
}

.stats-history-empty {
    margin-bottom: 1rem;
    padding: 0.85rem 1rem;
    background: var(--bg-gray);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.stats-history-year {
    margin-bottom: 1.25rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.stats-history-year:last-of-type {
    border-bottom: none;
}

.stats-history-year-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.stats-history-year-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--accent-dark);
}

.stats-history-fields {
    margin-bottom: 0.75rem;
    grid-template-columns: repeat(2, 1fr);
}

@media (max-width: 640px) {
    .stats-history-fields {
        grid-template-columns: 1fr;
    }
}

.stats-history-calc {
    margin-top: 0;
}

.stats-history-actions {
    margin: 1rem 0 1.5rem;
}

.stats-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.stats-deadlines {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    align-items: stretch;
    column-gap: 1rem;
    row-gap: 3.75rem;
    margin-bottom: 3.5rem;
}

.stats-deadlines + .stats-section-title {
    margin-top: 1.25rem;
}

@media (max-width: 720px) {
    .stats-deadlines {
        grid-template-columns: 1fr;
    }
}

.stats-deadline-card {
    background: var(--mint-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    height: 100%;
    min-height: 0;
}

.stats-deadline-card-body {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.stats-deadline-table-wrap {
    flex: 1 1 auto;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.stats-deadline-footer-wrap {
    flex-shrink: 0;
    margin-top: auto;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.stats-deadline-title {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--accent-dark);
}

.stats-deadline-card .stats-breakdown {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.stats-deadline-table {
    width: 100%;
    min-width: 28rem;
    table-layout: fixed;
    border-collapse: collapse;
    font-size: 0.7rem;
}

.stats-deadline-table-credit th:not(:first-child),
.stats-deadline-table-credit td:not(:first-child) {
    width: 14%;
}

.stats-deadline-col-label {
    width: 24%;
}

.stats-deadline-col-amount {
    width: 19%;
}

.stats-deadlines-hint {
    margin-top: -0.25rem;
    margin-bottom: 0.75rem;
}

.stats-compensato-col {
    color: var(--text-muted);
    font-size: 0.68rem;
}

.stats-compensato-used {
    color: var(--accent-dark);
}

.stats-compensato-gen {
    color: #2e7d32;
}

.stats-versare-col {
    font-weight: 600;
}

.stats-versare-total {
    font-size: 0.85rem;
    color: var(--accent-dark);
}

.stats-credit-col {
    color: var(--text-muted);
}

.stats-deadline-credit-row td {
    font-size: 0.68rem;
    color: var(--text-muted);
    border-top: 1px dashed var(--border-color);
}

.stats-deadline-credit-row .stats-credit-col,
.stats-deadline-credit-row .stats-versare-col {
    color: var(--accent-dark);
    font-weight: 600;
}

.stats-deadline-table th,
.stats-deadline-table td {
    padding: 0.35rem 0.4rem;
    text-align: right;
    vertical-align: top;
}

.stats-deadline-table th:not(:first-child),
.stats-deadline-table td:not(:first-child) {
    white-space: nowrap;
}

.stats-deadline-table thead th:not(:first-child) {
    white-space: normal;
    line-height: 1.25;
    font-size: 0.65rem;
    hyphens: auto;
}

.stats-deadline-table th:first-child,
.stats-deadline-table td:first-child {
    width: 30%;
    text-align: left;
    padding-left: 0;
    white-space: normal;
}

.stats-deadline-table thead th {
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
}

.stats-deadline-table th:last-child,
.stats-deadline-table td:last-child {
    font-weight: 600;
    color: var(--text-main);
}

.stats-deadline-label {
    color: var(--text-muted);
    padding-right: 0.5rem;
    line-height: 1.35;
}

.stats-deadline-total-row td {
    padding-top: 0.55rem;
    border-top: 1px solid var(--border-color);
    font-weight: 600;
    color: var(--accent-dark);
}

.stats-deadline-total-row td:last-child {
    font-size: 0.9rem;
}

.stats-card {
    background: var(--mint-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.stats-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

.stats-value {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--accent-dark);
}

.stats-formula {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.stats-breakdown {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.stats-breakdown-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.stats-breakdown-row span:last-child {
    font-weight: 600;
    color: var(--text-main);
}

.stats-section-title {
    margin: 0 0 1rem;
    font-size: 1rem;
    color: var(--accent-dark);
}

.stats-empty {
    color: var(--text-muted);
    text-align: center;
    padding: 1.5rem 0;
}

.stats-chart {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.stats-pie-layout {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 0.25rem;
}

.stats-modal-actions {
    margin-top: 2rem;
    padding-top: 0.25rem;
}

.stats-pie {
    width: 180px;
    height: 180px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06);
}

.stats-pie-legend {
    flex: 0 1 auto;
    width: max-content;
    max-width: 100%;
    min-width: 220px;
    display: table;
    border-collapse: collapse;
}

.stats-pie-legend-row {
    display: table-row;
    font-size: 0.85rem;
}

.stats-pie-name,
.stats-pie-pct,
.stats-pie-amount {
    display: table-cell;
    vertical-align: middle;
    padding: 0.35rem 0;
}

.stats-pie-name {
    font-weight: 500;
    white-space: nowrap;
    padding-right: 0.75rem;
}

.stats-pie-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    margin-right: 0.5rem;
    vertical-align: 0.08em;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.07);
}

.stats-pie-pct {
    font-weight: 600;
    color: var(--accent-dark);
    white-space: nowrap;
    padding-right: 0.75rem;
    text-align: right;
}

.stats-pie-amount {
    font-weight: 600;
    text-align: right;
    white-space: nowrap;
}

/* Print Styles */
    @media print {
    body {
        background-color: white;
    }
    .no-print {
        display: none !important;
    }
    .print-only {
        display: block !important;
    }
    .inline-input.print-only {
        display: inline !important;
    }
    .main-container {
        padding: 0;
        margin: 0;
        display: block;
        max-width: none;
    }
    .document-preview-wrapper {
        display: block;
    }
    .a4-document {
        box-shadow: none;
        width: 100%;
        height: auto;
        min-height: 0;
        padding: 0 !important;
        margin: 0;
        display: block;
    }

    .addresses-section {
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-between;
        gap: 2rem !important;
    }

    .issuer-box,
    .client-box {
        flex: 1;
        min-width: 0;
    }

    .monthly-recap-document,
    .monthly-recap-note-document {
        display: none !important;
    }

    /* flex-grow on spacer + min-height A4 causes an empty trailing page when content overflows */
    .doc-spacer {
        display: none;
    }

    .doc-footer {
        margin-top: 2rem;
    }

    @page {
        size: A4;
        margin: 20mm;
    }

    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        color-adjust: exact !important;
    }
    
    .inline-input, .notes-textarea {
        border: none !important;
        background: transparent !important;
        padding: 0 !important;
        resize: none !important;
    }

    /* Evita che il testo segnaposto compaia in anteprima/stampa (Safari/WebKit) */
    .notes-textarea::placeholder,
    .inline-input::placeholder {
        color: transparent !important;
        opacity: 0 !important;
    }
}

/* Header title with back link (fatturazione) */
.header-title {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.back-home {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
}

.back-home:hover {
    color: var(--accent-color);
}

/* Homepage */
.home-body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.home-body .home {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    margin: 0 auto;
}

.home {
    width: 100%;
    max-width: 720px;
    padding: 2rem 1.5rem;
}

.home-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.home-header h1 {
    margin: 0 0 0.5rem;
    font-size: 1.75rem;
    color: var(--accent-dark);
}

.home-subtitle {
    margin: 0;
    color: var(--text-muted);
    font-size: 1rem;
}

.home-nav {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.home-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
    padding: 1.25rem 1.5rem;
    background: white;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
}

.home-card:hover {
    border-color: var(--accent-color);
    box-shadow: 0 4px 16px rgba(0, 109, 119, 0.12);
    transform: translateY(-2px);
}

.home-card-icon {
    font-size: 1.5rem;
    line-height: 1;
}

.home-card-title {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--accent-dark);
}

.home-card-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* Note spese */
.status-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    margin-left: 0.5rem;
}
.status-badge--draft { background: #fff3e0; color: #e65100; }
.status-badge--locked { background: #e8f5e9; color: #2e7d32; }

.history-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
    align-items: center;
}
.history-filters input,
.history-filters select {
    flex: 1;
    min-width: 120px;
}

.history-filters__search {
    flex: 2 1 160px;
    min-width: 160px;
}

.history-filters__date {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex: 0 1 auto;
}

.history-filters__date-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted, #6b7280);
    white-space: nowrap;
}

.history-filters__date input[type="date"] {
    flex: 0 1 auto;
    min-width: 10.5rem;
    width: auto;
}

.modal-content.expense-history-modal {
    max-width: 1024px;
    width: min(96vw, 1024px);
}

.drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    font-size: 0.9rem;
    color: var(--text-muted);
}
.drop-zone:hover, .drop-zone--active {
    border-color: var(--accent-color);
    background: var(--accent-light);
}
.drop-zone--loading { opacity: 0.6; pointer-events: none; }
.drop-zone-hint { font-size: 0.8rem; }
.hidden-input { display: none; }
.field-hint { font-size: 0.75rem; color: var(--text-muted); margin: 0.25rem 0 0; }

.warning-banner {
    background: #fff3e0;
    color: #e65100;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    font-size: 0.85rem;
    margin-bottom: 1rem;
}
.info-banner {
    background: var(--accent-light);
    color: var(--accent-dark);
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

.error-message { color: #c62828; font-size: 0.85rem; margin-top: 0.5rem; }
.locked-notice { font-size: 0.9rem; color: var(--text-muted); margin: 0 0 1rem; }
.locked-sidebar { width: 280px; }

.expense-subtitle { margin: 0; font-size: 0.85rem; color: var(--text-muted); }
.trip-summary {
    margin-bottom: 1.5rem;
    font-size: 0.85rem;
    line-height: 1.5;
}
.trip-summary p { margin: 0.25rem 0; }

.expense-notes-section {
    margin: 0 0 1.5rem;
    padding-left: 0.75rem;
    border-left: 3px solid var(--accent-color);
    font-size: 0.8rem;
    line-height: 1.5;
    page-break-inside: avoid;
}
.expense-notes-section .notes-label {
    margin: 0 0 0.35rem;
    font-weight: 600;
    color: var(--accent-dark);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.expense-note-text {
    margin: 0;
    color: var(--text-muted);
}
.expense-note-text + .expense-note-text {
    margin-top: 0.5rem;
}

.expense-items-table { font-size: 0.75rem; }
.expense-items-table .col-date { width: 9%; }
.expense-items-table .col-desc { width: 28%; }
.expense-items-table .col-cat { width: 14%; }
.expense-items-table .col-loc { width: 14%; }
.expense-items-table .col-amount { width: 12%; text-align: right; }
.expense-items-table .col-rcpt { width: 8%; text-align: center; }

.monthly-recap-document {
    display: none;
}
.monthly-recap-note-document {
    display: none;
}
.recap-categories {
    margin-top: 1rem;
    font-size: 0.85rem;
}
.recap-categories h3 {
    margin: 0 0 0.5rem;
    font-size: 0.9rem;
}
.recap-categories ul {
    margin: 0;
    padding-left: 1.25rem;
}
.recap-total-row td {
    border-top: 2px solid var(--border-color);
    padding-top: 0.75rem;
}
.recap-categories--print {
    margin-top: 1.5rem;
    font-size: 0.8rem;
}

.declaration-section {
    border-top: 1px solid var(--border-color);
    padding-top: 1rem;
    font-size: 0.8rem;
    line-height: 1.5;
}
.declaration-text { text-align: justify; margin-bottom: 2rem; }
.signature-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 2.5rem;
    margin-top: 1.5rem;
}
.signature-block { flex: 1; min-width: 0; max-width: 48%; }
.signature-block--client { margin-left: auto; text-align: right; }
.signature-block--client .signature-line { margin-left: auto; }
.signature-party { margin: 0 0 0.25rem; font-weight: 600; }
.signature-line {
    margin-top: 2.5rem;
    border-top: 1px solid var(--text-main);
    width: 200px;
    max-width: 100%;
    padding-top: 0.25rem;
    font-size: 0.75rem;
}

.receipt-ok { color: #2e7d32; font-weight: 700; }
.receipt-upload-btn { cursor: pointer; font-size: 0.7rem; padding: 0.2rem 0.4rem; display: inline-flex; align-items: center; justify-content: center; }
.receipt-camera-btn { font-size: 0.75rem; padding: 0.2rem 0.35rem; vertical-align: middle; }
.receipt-files-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.receipt-file-row {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 0.5rem;
    background: var(--bg-gray);
    border-radius: 6px;
    border: 1px solid var(--border-color);
}
.receipt-file-name {
    font-size: 0.85rem;
    font-weight: 500;
    word-break: break-all;
}
.receipt-file-item {
    font-size: 0.75rem;
    color: var(--text-muted, #666);
}
.receipt-file-badge {
    font-size: 0.7rem;
    color: #e65100;
    font-weight: 500;
}
.receipt-file-actions {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}
.actions-cell {
    white-space: nowrap;
    width: 1%;
}

.upload-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin-top: 0.75rem;
}
.upload-actions .btn {
    min-height: 2.75rem;
    font-size: 0.9rem;
}

.expense-items-cards { display: none; }
.expense-item-card {
    background: var(--bg-gray);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
}
.expense-item-card__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}
.expense-item-card__n {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--accent-dark);
}
.expense-item-card__receipt {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin-top: 0.5rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
}

/* Note spese — layout responsive */
.page-note-spese {
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.page-note-spese .header-client-select {
    display: flex;
    align-items: center;
}

.page-note-spese .header-client-select__input {
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    border: 1px solid var(--border-color, #d1d5db);
    background: #fff;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    min-width: 11rem;
    max-width: 14rem;
    color: var(--text-color, #1f2937);
}

.page-note-spese .header-client-select__input:focus {
    outline: 2px solid var(--accent-color);
    outline-offset: 1px;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.page-note-spese .expense-editor-layout {
    align-items: start;
}

.page-note-spese .expense-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.page-note-spese .panel--save {
    padding: 1rem 1.5rem;
}

@media (min-width: 1400px) {
    .page-note-spese .expense-editor-layout {
        display: grid;
        grid-template-columns: 320px minmax(0, 1fr) 320px;
        gap: 1.5rem;
        max-width: 1680px;
    }

    .page-note-spese .expense-editor-layout .editor-sidebar {
        width: auto;
    }

    .page-note-spese .document-preview-wrapper {
        min-width: 0;
    }
}

.movement-section {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.movement-section__title {
    margin: 0 0 0.75rem;
    font-size: 0.95rem;
    font-weight: 600;
}

.movement-stop {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
}

.movement-segments-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.movement-segment__drag-handle {
    flex: 0 0 auto;
    align-self: center;
    margin-bottom: 0.35rem;
    padding: 0.15rem 0.35rem;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--text-muted, #64748b);
    font-size: 0.85rem;
    line-height: 1;
    cursor: grab;
    touch-action: none;
}

.movement-segment__drag-handle:active {
    cursor: grabbing;
}

.movement-segment--ghost {
    opacity: 0.45;
}

.movement-segment--chosen {
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.25);
    border-radius: 6px;
}

.movement-day-break .movement-segment__drag-handle {
    margin-bottom: 0;
}

.movement-stop__field {
    flex: 1;
    min-width: 0;
}

.movement-stop__btn {
    margin-bottom: 0.35rem;
    font-size: 1.25rem;
    line-height: 1;
}

.movement-add-stop {
    margin-bottom: 0;
}

.movement-stop-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.movement-day-break {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin: 0.35rem 0 0.75rem;
    padding: 0.35rem 0.65rem;
    border-left: 3px solid var(--primary-color, #2563eb);
    background: rgba(37, 99, 235, 0.06);
    border-radius: 0 4px 4px 0;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted, #64748b);
    cursor: grab;
    touch-action: none;
}

.movement-day-break:active {
    cursor: grabbing;
}

.movement-day-break-hint {
    margin: -0.35rem 0 0.75rem;
}

.movement-day-break__btn {
    font-size: 1.1rem;
    line-height: 1;
}

@media (max-width: 768px) {
    .history-table-wrap {
        margin: 0 -0.5rem;
    }
    .history-table {
        min-width: 640px;
        font-size: 0.8rem;
    }
    .history-actions .btn-small {
        padding: 0.25rem 0.45rem;
        font-size: 0.75rem;
    }
}

@media (max-width: 1399px) {
    .page-note-spese .main-container {
        flex-direction: column;
        padding: 1rem;
        gap: 1.25rem;
    }
    .page-note-spese .expense-editor-layout .expense-sidebar--primary {
        order: 1;
    }
    .page-note-spese .expense-editor-layout .expense-sidebar--secondary {
        order: 2;
    }
    .page-note-spese .expense-editor-layout .document-preview-wrapper {
        order: 3;
    }
    .page-note-spese .editor-sidebar,
    .page-note-spese .locked-sidebar {
        width: 100%;
        max-width: none;
    }
    .page-note-spese .document-preview-wrapper {
        justify-content: stretch;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .page-note-spese .a4-document {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        min-height: auto;
        padding: 1.25rem;
    }
    .page-note-spese .addresses-section {
        flex-direction: column;
        gap: 1rem;
    }
}

@media (max-width: 768px) {
    .page-note-spese .app-header {
        flex-direction: column;
        align-items: stretch;
        padding: 0.75rem 1rem;
        gap: 0.75rem;
    }
    .page-note-spese .header-title h1 {
        font-size: 1.2rem;
    }
    .page-note-spese .header-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }
    .page-note-spese .header-client-select {
        grid-column: 1 / -1;
    }
    .page-note-spese .header-client-select__input {
        width: 100%;
        max-width: none;
        min-height: 2.75rem;
    }
    .page-note-spese .header-actions .btn {
        width: 100%;
        min-height: 2.75rem;
        font-size: 0.8rem;
        padding: 0.5rem 0.4rem;
    }
    .page-note-spese .header-actions .btn-primary {
        grid-column: 1 / -1;
    }
    .page-note-spese .form-row {
        flex-direction: column;
        gap: 0;
    }
    .page-note-spese .drop-zone--desktop {
        display: none;
    }
    .page-note-spese .upload-actions {
        grid-template-columns: 1fr;
    }
    .page-note-spese .expense-items-table--desktop {
        display: none;
    }
    .page-note-spese .expense-items-cards {
        display: flex;
        flex-direction: column;
        gap: 1rem;
    }
    .page-note-spese .add-row-wrapper {
        margin-top: 0.5rem;
    }
    .page-note-spese .modal-content {
        width: calc(100% - 1.5rem);
        max-width: none;
        max-height: min(92vh, 900px);
        overflow-y: auto;
        margin: 0.75rem;
        padding: 1.25rem;
    }
    .page-note-spese .modal-content.large,
    .page-note-spese .modal-content.expense-history-modal {
        width: calc(100% - 1rem);
    }
    .page-note-spese .history-table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -0.5rem;
    }
    .page-note-spese .history-table {
        min-width: 720px;
        font-size: 0.8rem;
    }
    .page-note-spese .doc-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    .page-note-spese .doc-header--expense {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
    }
    .page-note-spese .doc-header--expense .expense-header-line {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
    }
    .page-note-spese .doc-header--expense .expense-header-line--end {
        padding-left: 4.5rem;
    }
    .page-note-spese .totals-box {
        width: 100%;
    }
}

@media (min-width: 769px) {
    .page-note-spese .expense-items-cards {
        display: none !important;
    }
}

@media (max-width: 480px) {
    .page-note-spese .main-container {
        padding: 0.75rem;
    }
    .page-note-spese .panel {
        padding: 1rem;
    }
    .page-note-spese .status-badge {
        display: inline-block;
        margin-left: 0;
        margin-top: 0.25rem;
    }
}

/* Home responsive */
@media (max-width: 480px) {
    .home {
        padding: 1.25rem 1rem;
    }
    .home-header h1 {
        font-size: 1.4rem;
    }
}

@media print {
    .page-note-spese .expense-items-cards {
        display: none !important;
    }
    .page-note-spese .expense-items-table--desktop {
        display: table !important;
    }
    .expense-items-table input,
    .expense-items-table select {
        display: none !important;
    }
    .expense-items-table .print-cell {
        display: table-cell !important;
    }
    body.printing-monthly-recap #printable-area {
        display: none !important;
    }
    body.printing-monthly-recap .monthly-recap-document,
    body.printing-monthly-recap .monthly-recap-note-document {
        display: block !important;
    }

    body.printing-monthly-recap .monthly-recap-note-document {
        page-break-before: always;
        break-before: page;
    }

    .monthly-recap-document .addresses-section,
    .monthly-recap-document .totals-section,
    .monthly-recap-document .recap-categories--print,
    .monthly-recap-document .declaration-section {
        page-break-inside: avoid;
        break-inside: avoid;
    }
    .monthly-recap-note-document .totals-section,
    .monthly-recap-note-document .expense-notes-section {
        page-break-inside: avoid;
        break-inside: avoid;
    }
    .monthly-recap-document .items-table thead {
        display: table-header-group;
    }
    .monthly-recap-document .items-table tr {
        page-break-inside: avoid;
        break-inside: avoid;
    }
}

/* Auth */
.auth-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f4f6f8;
    padding: 1rem;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: #fff;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
}

.auth-card h1 {
    margin: 0 0 0.25rem;
    font-size: 1.5rem;
}

.auth-subtitle {
    color: #666;
    margin: 0 0 1.5rem;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.auth-label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.auth-label input {
    padding: 0.6rem 0.75rem;
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    font-size: 1rem;
}

.auth-submit {
    margin-top: 0.5rem;
    width: 100%;
}

.auth-error {
    background: #fdecea;
    color: #b42318;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.auth-success {
    color: #027a48;
    margin: 1rem 0 0;
}

.app-user-bar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    width: 100%;
    padding: 0.625rem 1.5rem;
    background: #fff;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    font-size: 0.875rem;
    position: sticky;
    top: 0;
    z-index: 200;
    flex-shrink: 0;
    box-sizing: border-box;
}

.app-user-bar__name {
    color: #555;
}

.app-user-bar__actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.app-user-bar__logout {
    margin: 0;
}

.change-password-body {
    min-height: 100vh;
    background: var(--bg-gray, #f4f6f8);
}

.change-password-card {
    margin: 2rem auto;
}

.change-password-form-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.change-password-form-actions .auth-submit {
    margin-top: 0;
}

.change-password-cancel {
    text-align: center;
}

.change-password-actions {
    margin: 1.25rem 0 0;
}

.change-password-logout {
    margin: 1.5rem 0 0;
    text-align: center;
}

.account-settings-overlay .modal-content.account-settings-modal {
    max-width: 32rem;
    max-height: min(90vh, 52rem);
    overflow-y: auto;
}

.account-settings-section + .account-settings-section {
    margin-top: 1.75rem;
    padding-top: 1.75rem;
    border-top: 1px solid var(--border-color);
}

.account-settings-section h3 {
    margin: 0 0 1rem;
    font-size: 1rem;
    font-weight: 600;
}

.account-settings-hint {
    margin: -0.5rem 0 1rem;
    font-size: 0.875rem;
    color: var(--text-muted, #667085);
}

.account-settings-section-actions {
    margin-top: 0.25rem;
}

#account-settings-flash,
#account-settings-success {
    margin-bottom: 1rem;
}

.account-settings-modal textarea {
    min-height: 6.5rem;
    line-height: 1.5;
    resize: vertical;
}

.clients-overlay .modal-content.clients-modal {
    max-width: 52rem;
    max-height: min(90vh, 44rem);
    overflow-y: auto;
}

.clients-modal-layout {
    display: grid;
    grid-template-columns: minmax(11rem, 14rem) minmax(0, 1fr);
    gap: 1.25rem;
    align-items: start;
}

.clients-list-panel,
.clients-form-panel {
    min-width: 0;
}

.clients-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.clients-list-header h3,
.clients-form-panel h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.clients-list {
    list-style: none;
    margin: 0;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    max-height: 22rem;
    overflow-y: auto;
    background: #fff;
}

.clients-list-empty {
    padding: 0.85rem 1rem;
    color: var(--text-muted, #667085);
    font-size: 0.875rem;
}

.clients-list-item {
    display: block;
    width: 100%;
    padding: 0.7rem 0.85rem;
    border: 0;
    border-bottom: 1px solid var(--border-color);
    background: transparent;
    text-align: left;
    font: inherit;
    color: inherit;
    cursor: pointer;
}

.clients-list-item:last-child {
    border-bottom: 0;
}

.clients-list-item:hover,
.clients-list-item:focus-visible {
    background: var(--bg-gray, #f9fafb);
    outline: none;
}

.clients-list-item.is-selected {
    background: var(--accent-light, #eef4ff);
    color: var(--accent-dark, #1d4ed8);
    font-weight: 600;
}

.clients-form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 0.25rem;
}

.clients-delete-btn {
    color: #b42318;
    border-color: #fecdca;
}

#clients-flash,
#clients-success {
    margin-bottom: 1rem;
}

@media (max-width: 720px) {
    .clients-modal-layout {
        grid-template-columns: 1fr;
    }

    .clients-list {
        max-height: 12rem;
    }
}

.field-hint {
    margin: 0.35rem 0 0;
    font-size: 0.8rem;
    color: var(--text-muted, #667085);
    line-height: 1.4;
}

/* Admin */
.admin-body {
    min-height: 100vh;
    background: var(--bg-gray);
}

.admin-badge {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--accent-dark);
    background: var(--accent-light);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}

.admin-page {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem 1.5rem 3rem;
}

.admin-header h1 {
    margin: 0 0 0.35rem;
    font-size: 1.75rem;
    color: var(--accent-dark);
}

.admin-subtitle {
    margin: 0 0 2rem;
    color: var(--text-muted);
}

.admin-section {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
}

.admin-section h2 {
    margin: 0 0 1rem;
    font-size: 1.1rem;
    color: var(--text-main);
}

.admin-section--accounts {
    padding: 0;
    overflow: hidden;
}

.admin-section--accounts > h2 {
    padding: 1.25rem 1.5rem 0;
}

.admin-table-wrap {
    overflow-x: auto;
    margin-top: 1rem;
    -webkit-overflow-scrolling: touch;
}

.admin-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.875rem;
}

.admin-table th,
.admin-table td {
    text-align: left;
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.admin-table th {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: var(--mint-bg);
    border-bottom-color: var(--border-color);
    white-space: nowrap;
}

.admin-table th:first-child {
    padding-left: 1.5rem;
}

.admin-table td:first-child {
    padding-left: 1.5rem;
}

.admin-table th:last-child,
.admin-table td:last-child {
    padding-right: 1.5rem;
}

.admin-table tbody tr {
    transition: background-color 0.15s ease;
}

.admin-table tbody tr:hover {
    background: var(--mint-bg);
}

.admin-table tbody tr:last-child td {
    border-bottom: none;
}

.admin-account-user {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    white-space: nowrap;
}

.admin-user-avatar {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: var(--accent-light);
    color: var(--accent-dark);
    font-size: 0.8rem;
    font-weight: 600;
}

.admin-username {
    font-size: 0.85em;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    color: var(--text-main);
    background: none;
    padding: 0;
}

.admin-account-cell {
    min-width: 7rem;
}

.admin-cell-row {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    min-width: 0;
}

.admin-cell-value {
    min-width: 0;
    color: var(--text-main);
    line-height: 1.4;
}

.admin-icon-btn {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    padding: 0;
    border: none;
    border-radius: 4px;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}

.admin-table tbody tr:hover .admin-icon-btn,
.admin-icon-btn:focus-visible {
    opacity: 1;
}

.admin-icon-btn:hover {
    color: var(--accent-color);
    background: var(--accent-light);
}

.admin-icon-btn:focus-visible {
    opacity: 1;
    outline: 2px solid var(--accent-color);
    outline-offset: 1px;
}

.admin-icon {
    display: block;
}

@media (hover: none) {
    .admin-icon-btn {
        opacity: 1;
    }
}

.admin-tag {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.admin-tag--ok {
    color: #1b5e20;
    background: #e8f5e9;
}

.admin-tag--warn {
    color: #bf360c;
    background: #fff3e0;
}

.admin-tag--muted {
    color: #616161;
    background: #eeeeee;
}

.admin-tenant-status {
    display: flex;
    gap: 0.75rem;
}

.admin-tenant-item {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.admin-tenant-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

.admin-dot {
    display: inline-block;
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    flex-shrink: 0;
}

.admin-dot--ok {
    background: #43a047;
    box-shadow: 0 0 0 2px #e8f5e9;
}

.admin-dot--warn {
    background: #ef6c00;
    box-shadow: 0 0 0 2px #fff3e0;
}

.admin-password-status {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.admin-password-status--warn {
    color: #bf360c;
}

.admin-date {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.admin-password-modal {
    max-width: 420px;
}

.admin-password-modal h2 {
    margin: 0 0 0.5rem;
    font-size: 1.15rem;
}

.admin-password-hint {
    margin: 0 0 1rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.45;
}

.admin-password-modal .admin-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.admin-password-modal .admin-form > input:not([type="hidden"]) {
    padding: 0.6rem 0.75rem;
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
}

.modal-overlay[hidden] {
    display: none !important;
}

.admin-muted {
    color: var(--text-muted);
    font-size: 0.85em;
}

.admin-empty {
    margin: 0;
    color: var(--text-muted);
}

.admin-note {
    background: #fff;
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--accent-color);
    border-radius: 10px;
    padding: 1.25rem 1.5rem;
}

.admin-note h2 {
    margin: 0 0 0.75rem;
    font-size: 1rem;
}

.admin-note p {
    margin: 0 0 0.75rem;
    color: var(--text-main);
    line-height: 1.5;
}

.admin-note p:last-child {
    margin-bottom: 0;
}

.admin-cli {
    margin: 0 0 0.75rem;
    padding: 0.875rem 1rem;
    background: var(--bg-gray);
    border-radius: 6px;
    overflow-x: auto;
    font-size: 0.8rem;
    line-height: 1.6;
}

.admin-cli code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    white-space: pre;
}

.admin-flash {
    margin: 0 0 1.25rem;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
}

.admin-flash--ok {
    background: #e8f5e9;
    color: #1b5e20;
    border: 1px solid #a5d6a7;
}

.admin-flash--error {
    background: #ffebee;
    color: #c62828;
    border: 1px solid #ef9a9a;
}

.admin-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

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

.admin-form-options {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.admin-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-main);
    cursor: pointer;
}

.admin-expense-defaults-cell {
    max-width: 12rem;
}

.admin-expense-defaults-summary {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-muted);
    font-size: 0.85rem;
}
