:root {
    --ink: #14211f;
    --muted: #62716c;
    --line: #dce7e1;
    --paper: #f7faf8;
    --card: #fff;
    --brand: #075f4e;
    --accent: #c9f36b;
    --danger: #a42c2c;
    --radius: 18px;
    --shadow: 0 16px 42px rgba(18, 43, 35, 0.09);
}
* {
    box-sizing: border-box;
}
body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font:
        16px/1.5 Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        'Segoe UI',
        sans-serif;
}
.construction {
    background: var(--ink);
    color: #e7f1ec;
    text-align: center;
    padding: 9px 20px;
    font-size: 0.88rem;
}
.construction span {
    color: var(--accent);
}
.construction a {
    color: var(--accent);
    font-weight: 800;
    margin-left: 8px;
}
.site-header {
    height: 76px;
    max-width: 1160px;
    margin: auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.brand {
    font-size: 1.3rem;
    font-weight: 900;
    letter-spacing: -0.05em;
    color: var(--ink);
    text-decoration: none;
}
.brand span {
    display: inline-grid;
    place-items: center;
    width: 29px;
    height: 29px;
    color: var(--ink);
    background: var(--accent);
    border-radius: 9px;
    margin-right: 5px;
}
nav {
    display: flex;
    align-items: center;
    gap: 23px;
}
nav a {
    color: var(--ink);
    text-decoration: none;
    font-weight: 700;
}
main {
    max-width: 1160px;
    margin: 0 auto;
    padding: 22px 24px 92px;
}
h1,
h2,
h3 {
    letter-spacing: -0.055em;
    line-height: 1.04;
}
h1 {
    font-size: clamp(2.55rem, 6vw, 5.4rem);
    max-width: 850px;
    margin: 0.35em 0;
}
h2 {
    font-size: 2rem;
}
.eyebrow {
    font-size: 0.78rem;
    letter-spacing: 0.12em;
    font-weight: 900;
    color: var(--brand);
    text-transform: uppercase;
}
.lead {
    font-size: 1.2rem;
    max-width: 650px;
    color: var(--muted);
}
.button,
button {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    background: var(--brand);
    color: #fff;
    border: 0;
    border-radius: 10px;
    padding: 14px 20px;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
}
.button:hover,
button:hover {
    filter: brightness(1.08);
}
.button.alt {
    background: var(--accent);
    color: var(--ink);
}
.button.ghost {
    background: transparent;
    color: var(--brand);
    border: 1px solid var(--line);
}
.button.small {
    padding: 10px 15px;
    font-size: 0.88rem;
}
.hero {
    padding: 68px 0 45px;
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: 38px;
    align-items: center;
}
.actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 28px;
}
.trust {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    font-size: 0.88rem;
    font-weight: 800;
    margin-top: 32px;
}
.trust span:before {
    content: '✓';
    color: var(--brand);
    margin-right: 5px;
}
.dashboard-preview,
.card,
.form-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.dashboard-preview {
    padding: 22px;
}
.metric-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.metric {
    padding: 15px;
    background: #eff6f2;
    border-radius: 12px;
}
.metric b {
    font-size: 1.25rem;
    display: block;
}
.tiny-table {
    width: 100%;
    margin-top: 18px;
    border-collapse: collapse;
    font-size: 0.85rem;
}
.tiny-table td,
.tiny-table th {
    padding: 10px 3px;
    border-bottom: 1px solid var(--line);
    text-align: left;
}
.status {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 999px;
    background: #e5f5dd;
    color: var(--brand);
    font-size: 0.75rem;
    font-weight: 800;
}
.section {
    padding: 56px 0;
}
.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
}
.card {
    padding: 23px;
}
.card .icon {
    font-size: 1.6rem;
    background: #e5f5dd;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: grid;
    place-items: center;
}
.card h3 {
    font-size: 1.25rem;
    margin: 18px 0 8px;
}
.card p,
.muted {
    color: var(--muted);
}
.flash {
    max-width: 1112px;
    margin: 9px auto;
    padding: 12px 16px;
    border-radius: 10px;
    font-weight: 700;
}
.flash.error {
    background: #ffe8e8;
    color: var(--danger);
}
.flash.success {
    background: #e3f5e9;
    color: var(--brand);
}
.form-wrap {
    max-width: 700px;
    margin: 30px auto;
}
.form-card {
    padding: 32px;
}
.form-card h1 {
    font-size: 2.5rem;
    margin-top: 0;
}
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.form-grid .wide {
    grid-column: 1/-1;
}
label {
    display: block;
    font-weight: 800;
    font-size: 0.9rem;
    margin-bottom: 5px;
}
input,
select,
textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #cbd9d2;
    border-radius: 9px;
    background: #fff;
    font: inherit;
}
input:focus,
select:focus,
textarea:focus {
    outline: 3px solid #c9f36b;
    border-color: var(--brand);
}
.hint {
    font-size: 0.85rem;
    color: var(--muted);
}
.account {
    display: grid;
    grid-template-columns: 235px 1fr;
    gap: 24px;
}
.sidebar {
    padding: 15px;
}
.sidebar a {
    display: block;
    padding: 11px 12px;
    color: var(--ink);
    text-decoration: none;
    border-radius: 9px;
    font-weight: 750;
}
.sidebar a.active,
.sidebar a:hover {
    background: #e5f5dd;
    color: var(--brand);
}
.panel {
    padding: 28px;
}
.panel h1 {
    font-size: 2.5rem;
    margin-top: 0;
}
.key {
    display: flex;
    gap: 8px;
    padding: 13px;
    background: var(--ink);
    color: var(--accent);
    border-radius: 10px;
    align-items: center;
    overflow: auto;
    font-family: ui-monospace, monospace;
}
.key code {
    flex: 1;
    white-space: nowrap;
}
.invoice-editor {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 20px;
}
.line-row {
    display: grid;
    grid-template-columns: 1fr 90px 130px 40px;
    gap: 8px;
    margin-bottom: 8px;
}
.summary {
    padding: 20px;
    position: sticky;
    top: 12px;
    height: max-content;
}
.whatsapp {
    position: fixed;
    right: 22px;
    bottom: 22px;
    background: #25d366;
    color: #073c21;
    text-decoration: none;
    border-radius: 999px;
    padding: 13px 17px;
    font-weight: 900;
    box-shadow: var(--shadow);
}
footer {
    max-width: 1160px;
    margin: auto;
    padding: 30px 24px;
    color: var(--muted);
    border-top: 1px solid var(--line);
    font-size: 0.85rem;
}
@media (max-width: 780px) {
    .hero,
    .account,
    .invoice-editor {
        grid-template-columns: 1fr;
    }
    .grid-3 {
        grid-template-columns: 1fr;
    }
    .form-grid {
        grid-template-columns: 1fr;
    }
    .form-grid .wide {
        grid-column: auto;
    }
    .site-header {
        padding: 0 16px;
    }
    main {
        padding-left: 16px;
        padding-right: 16px;
    }
    nav {
        gap: 13px;
    }
    .whatsapp span {
        display: none;
    }
    .line-row {
        grid-template-columns: 1fr 65px 90px 36px;
    }
}
/* Invoice editor and archive */
.account { grid-template-columns: 210px minmax(0, 1fr); }
.panel, .form-grid > *, .invoice-line-fields > * { min-width: 0; }
.invoice-body { border: 0; padding: 0; margin: 0; min-width: 0; }
.invoice-section { margin-top: 30px; padding-top: 24px; border-top: 1px solid var(--line); }
.invoice-section h2 { font-size: 1.35rem; margin: 0 0 20px; letter-spacing: -0.025em; }
.invoice-toolbar, .line-bottom { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.invoice-line { min-width: 0; margin: 18px 0; padding: 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); }
.invoice-line legend { padding: 0 8px; color: var(--brand); font-weight: 800; }
.invoice-line-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.invoice-line-fields .line-description { grid-column: 1 / -1; }
.invoice-line label > input, .invoice-line label > select, .archive-filters select { margin-top: 5px; }
.line-bottom { margin-top: 14px; font-size: .9rem; }
.table-scroll { max-width: 100%; overflow-x: auto; }
.invoice-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.invoice-table th, .invoice-table td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.invoice-table th { background: var(--paper); }
.invoice-table .amount { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.invoice-table small { display: block; color: var(--muted); margin-top: 5px; }
.invoice-table tfoot { font-weight: 800; }
.invoice-grand-totals { max-width: 440px; margin: 20px 0 0 auto; padding: 12px 18px; background: var(--paper); border-radius: 12px; }
.invoice-grand-totals p { display: flex; justify-content: space-between; gap: 20px; }
.archive-filters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) auto; align-items: end; gap: 14px; margin-top: 28px; }
.archive-filters label { margin: 0; }
.check-field { display: flex; align-items: center; gap: 10px; margin-top: 20px; }
input[type=checkbox], input[type=radio] { width: auto; padding: 0; }
.notice { padding: 14px 18px; background: #fff5d7; color: #644c10; border-radius: 10px; }
button:disabled { opacity: .55; cursor: not-allowed; filter: none; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 3px; }
.receipt-link { display: block; margin-top: 8px; }
.status-generata { background: #e8eef4; color: #31465a; }
.status-inviata_sdi { background: #e3edff; color: #244984; }
.status-rifiutata, .status-respinta { background: #ffe8e8; color: var(--danger); }
.status-non_consegnata { background: #fff0c4; color: #72520c; }
.status-legend li { margin: 10px 0; }
@media (max-width: 1000px) { .account { grid-template-columns: 1fr; } .archive-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 540px) {
    .panel { padding: 18px; }
    .panel h1 { font-size: 2rem; }
    .invoice-line-fields, .archive-filters { grid-template-columns: 1fr; }
    .invoice-line { padding: 12px; }
    .site-header { height: auto; min-height: 76px; gap: 14px; flex-wrap: wrap; padding-top: 12px; padding-bottom: 12px; }
}
#customer-dialog { width: min(1000px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 28px; color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
#customer-dialog::backdrop { background: rgba(20,33,31,.55); }
#customer-dialog [hidden] { display: none !important; }
.dialog-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.dialog-heading h2 { font-size: 1.5rem; }
.customer-search { display: flex; align-items: end; gap: 12px; flex-wrap: wrap; }
.customer-search label { flex: 1 1 250px; margin: 0; }
#customer-results-wrap { max-height: 300px; margin-top: 16px; }
#customer-message { color: var(--brand); font-weight: 700; }
#customer-results td { overflow-wrap: anywhere; }
@media (max-width: 540px) { #customer-dialog { padding: 16px; } }
#proforma-dialog { width: min(640px, calc(100vw - 32px)); max-height: 90vh; overflow: auto; border: 1px solid var(--line, #ddd); border-radius: 18px; padding: 28px; }
#proforma-dialog::backdrop { background: rgba(15, 23, 42, .55); }
#proforma-upload-form { display: grid; gap: 16px; }
#proforma-upload-result, .document-id { overflow-wrap: anywhere; }
.document-id { display: block; font-family: monospace; margin-top: 6px; }
