/* Professional231: il fascicolo.
   Verde bottiglia e ottone delle rilegature, carta fredda, ceralacca per ciò che è urgente. */

@font-face {
    font-family: "Source Sans 3";
    src: url("../fonts/source-sans-3.woff2") format("woff2");
    font-weight: 200 800;
    font-display: swap;
}

@font-face {
    font-family: "Spectral";
    src: url("../fonts/spectral-500.woff2") format("woff2");
    font-weight: 500;
    font-display: swap;
}

@font-face {
    font-family: "Spectral";
    src: url("../fonts/spectral-600.woff2") format("woff2");
    font-weight: 600;
    font-display: swap;
}

:root {
    --green: #17382f;
    --green-deep: #0f2921;
    --green-tab: #274d42;
    --green-mist: #c6d4cd;
    --brass: #a8843a;
    --paper: #f2f4f2;
    --sheet: #ffffff;
    --hover: #f7f8f7;
    --ink: #1d2623;
    --muted: #56635e;
    --line: #d7dcd9;
    --line-strong: #aeb8b2;
    --red: #8e2b2b;
    --red-soft: #f8ebe9;
    --amber: #76560f;
    --amber-soft: #f6efdc;
    --blue: #2c5270;
    --blue-soft: #e5edf3;
    --ok: #27634a;
    --ok-soft: #e4f0ea;
    --serif: "Spectral", Georgia, "Times New Roman", serif;
    --sans: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
    --radius: 4px;
    --gutter: 24px;
    --nav-height: 64px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font: 17px/1.5 var(--sans);
}

h1,
h2,
h3 {
    margin: 0;
    font-family: var(--serif);
    font-weight: 500;
    line-height: 1.2;
}

h1 {
    font-size: 32px;
}

h2 {
    font-size: 21px;
}

h3 {
    font-size: 18px;
}

p {
    margin: 0;
}

a {
    color: var(--green);
    text-underline-offset: 2px;
}

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

[hidden] {
    display: none !important;
}

:focus-visible {
    outline: 2px solid var(--brass);
    outline-offset: 2px;
}

.muted {
    color: var(--muted);
}

.icon {
    flex: none;
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.skip-link {
    position: absolute;
    left: -9999px;
}

.skip-link:focus {
    left: 16px;
    top: 8px;
    z-index: 20;
    padding: 8px 12px;
    background: var(--sheet);
}

.wrap {
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 var(--gutter);
}

/* ---------- Barra superiore e navigazione ---------- */

.topbar {
    background: var(--green-deep);
    color: #fff;
}

.topbar-row {
    display: flex;
    align-items: center;
    gap: 40px;
    min-height: 60px;
}

.brand {
    color: #fff;
    font: 600 21px/1 var(--serif);
    text-decoration: none;
}

.mainnav {
    display: flex;
    flex: 1;
    align-self: stretch;
    gap: 4px;
}

.mainnav-link {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0 14px;
    color: var(--green-mist);
    text-decoration: none;
}

.mainnav-link:hover {
    color: #fff;
}

.mainnav-link.active {
    color: #fff;
    box-shadow: inset 0 -3px 0 var(--brass);
}

.logout {
    margin: 0;
}

.count {
    min-width: 22px;
    padding: 0 6px;
    border-radius: 11px;
    background: var(--red);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    line-height: 22px;
    text-align: center;
}

/* ---------- Testata di pagina e linguette del fascicolo ---------- */

.band {
    padding: 28px 0;
    background: var(--green);
    color: #fff;
}

.band-file {
    padding-bottom: 0;
}

.band-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.band-sub {
    margin-top: 4px;
    color: var(--green-mist);
}

.band-sub:first-letter {
    text-transform: uppercase;
}

.band-facts {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 20px;
}

.band-back {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin: -8px 0 8px -5px;
    color: var(--green-mist);
    font-size: 15px;
    text-decoration: none;
}

.band-back:hover {
    color: #fff;
}

.file-tabs {
    display: flex;
    gap: 4px;
    margin-top: 24px;
    overflow-x: auto;
    scrollbar-width: none;
}

.file-tab {
    display: inline-flex;
    flex: none;
    align-items: center;
    gap: 8px;
    padding: 11px 18px 12px;
    border-top: 3px solid transparent;
    border-radius: 6px 6px 0 0;
    background: var(--green-tab);
    color: #e3ebe7;
    text-decoration: none;
}

.file-tab:hover {
    color: #fff;
    background: #2f5a4e;
}

.file-tab.active {
    border-top-color: var(--brass);
    background: var(--paper);
    color: var(--ink);
    font-weight: 600;
}

/* ---------- Pagine, sezioni e griglie ---------- */

.page {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding-top: 24px;
    padding-bottom: 56px;
}

.page > * {
    min-width: 0;
}

.page-narrow {
    max-width: 860px;
}

.stack {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.columns {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    align-items: start;
}

.desk {
    display: grid;
    grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
    grid-template-areas: "deadlines mail" "companies mail";
    grid-template-rows: auto 1fr;
    align-items: start;
}

.desk-deadlines {
    grid-area: deadlines;
}

.desk-mail {
    grid-area: mail;
}

.desk-companies {
    grid-area: companies;
}

.sheet {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--sheet);
}

.sheet-pad {
    padding: 24px;
}

.sheet-pad summary {
    font-weight: 600;
}

.sheet-pad h3 {
    margin: 24px 0 12px;
}

.sheet-title {
    margin-bottom: 20px;
}

.sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--line);
}

.sheet-head p {
    margin-top: 2px;
    color: var(--muted);
    font-size: 15px;
}

.sheet-link {
    flex: none;
    font-size: 15px;
}

.empty {
    padding: 28px 20px;
    color: var(--muted);
}

.empty .btn {
    margin-top: 12px;
}

.notice {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px 24px;
    padding: 16px 20px;
    border-left: 4px solid var(--brass);
    border-radius: var(--radius);
    background: var(--amber-soft);
}

.danger-zone p {
    margin-bottom: 16px;
    color: var(--muted);
}

.back {
    display: inline-flex;
    align-items: center;
    align-self: flex-start;
    gap: 4px;
    margin-left: -5px;
    text-decoration: none;
}

/* ---------- Righe: elenco unico per messaggi, aziende, documenti e scadenze ---------- */

.rows {
    margin: 0;
    padding: 0;
    list-style: none;
}

.row {
    position: relative;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 20px;
    border-top: 1px solid var(--line);
}

.row:first-child {
    border-top: none;
}

.row:has(.row-link):hover {
    background: var(--hover);
}

.row-main {
    flex: 1;
    min-width: 0;
}

.row-title {
    display: block;
    color: var(--ink);
    font-weight: 600;
    overflow-wrap: anywhere;
}

.row-title-serif {
    font: 500 19px/1.3 var(--serif);
}

.row-link {
    text-decoration: none;
}

.row-link::after {
    content: "";
    position: absolute;
    inset: 0;
}

.row-link:hover {
    text-decoration: underline;
}

.row-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px 14px;
    margin-top: 2px;
    color: var(--muted);
    font-size: 15px;
    overflow-wrap: anywhere;
}

.row-note {
    display: block;
    margin-top: 4px;
    font-size: 15px;
}

.row-company {
    color: var(--ink);
}

.row-date {
    flex: none;
    align-self: flex-start;
    color: var(--muted);
    font-size: 15px;
}

.row-side {
    display: flex;
    flex: none;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.row-next {
    flex: none;
    color: var(--muted);
    font-size: 15px;
}

.row-next.soon {
    color: var(--red);
    font-weight: 600;
}

.count-text {
    padding: 0 10px;
}

.document-row > .icon {
    align-self: flex-start;
    margin-top: 3px;
    color: var(--muted);
}

.message-row {
    border-left: 3px solid transparent;
}

.message-row .row-title {
    font-weight: 400;
}

.message-row.unread {
    border-left-color: var(--red);
}

.message-row.unread .row-title {
    font-weight: 700;
}

.attached {
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.attached .icon {
    width: 15px;
    height: 15px;
}

.date-tile {
    display: flex;
    flex: none;
    flex-direction: column;
    align-items: center;
    width: 48px;
    padding: 4px 0 5px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--paper);
    color: var(--muted);
    font-size: 13px;
    line-height: 1.1;
}

.date-tile b {
    color: var(--ink);
    font: 600 21px/1.1 var(--serif);
}

.agenda-row .cal-event {
    flex: 1;
    min-width: 0;
    padding: 2px 0 2px 12px;
    background: none;
    color: var(--ink);
    font-size: 16px;
}

.agenda-row .cal-event:hover .cal-event-title {
    text-decoration: underline;
}

.agenda-row .cal-event-title {
    font-weight: 600;
    white-space: normal;
}

.agenda-row .cal-event-meta,
.agenda-row .cal-event-company {
    color: var(--muted);
    font-size: 15px;
}

/* ---------- Pulsanti, etichette e menu ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    padding: 8px 16px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: var(--sheet);
    color: var(--ink);
    cursor: pointer;
    font-weight: 500;
    line-height: 1.2;
    text-decoration: none;
    white-space: nowrap;
}

.btn:hover {
    background: var(--paper);
    border-color: var(--muted);
}

.btn-sm {
    min-height: 36px;
    padding: 5px 12px;
    font-size: 15px;
}

.btn-icon {
    width: 36px;
    padding: 0;
}

.btn-primary {
    border-color: var(--green);
    background: var(--green);
    color: #fff;
}

.btn-primary:hover {
    border-color: var(--green-deep);
    background: var(--green-deep);
}

.btn-light {
    border-color: #fff;
}

.btn-light:hover {
    background: var(--paper);
}

.btn-dark {
    border-color: var(--green-tab);
    background: transparent;
    color: var(--green-mist);
}

.btn-dark:hover {
    border-color: var(--green-mist);
    background: transparent;
    color: #fff;
}

.btn-danger {
    border-color: #d9b6b2;
    color: var(--red);
}

.btn-danger:hover {
    border-color: var(--red);
    background: var(--red-soft);
}

.btn-quiet {
    border-color: transparent;
    background: none;
}

.btn-block {
    width: 100%;
}

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

.actions form {
    margin: 0;
}

.badge {
    display: inline-block;
    padding: 0 8px;
    border-radius: var(--radius);
    background: var(--blue-soft);
    color: var(--blue);
    font: 500 14px/22px var(--sans);
    vertical-align: 1px;
}

.badge-ok {
    background: var(--ok-soft);
    color: var(--ok);
}

.badge-off {
    background: #e7eae8;
    color: var(--muted);
}

.badge-warn {
    background: var(--amber-soft);
    color: var(--amber);
}

.info {
    display: inline-flex;
    position: relative;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    margin-left: 4px;
    border: 1px solid var(--muted);
    border-radius: 50%;
    background: var(--sheet);
    color: var(--muted);
    cursor: help;
    font: italic 500 13px/1 var(--serif);
    vertical-align: 2px;
}

/* Al tocco e da tastiera il title nativo non compare: lo mostra questo riquadro */
.info:focus::after {
    content: attr(title);
    position: absolute;
    z-index: 10;
    top: calc(100% + 6px);
    left: -8px;
    width: 260px;
    padding: 10px 12px;
    border-radius: var(--radius);
    background: var(--green-deep);
    color: #fff;
    font: 400 15px/1.4 var(--sans);
}

.menu {
    position: relative;
}

.menu summary {
    list-style: none;
}

.menu summary::-webkit-details-marker {
    display: none;
}

.menu-list {
    position: absolute;
    z-index: 5;
    top: calc(100% + 4px);
    right: 0;
    min-width: 230px;
    max-height: 60vh;
    padding: 4px;
    overflow: auto;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: var(--sheet);
    box-shadow: 0 8px 24px rgba(15, 41, 33, .16);
    color: var(--ink);
}

.menu-form {
    margin: 0;
}

.menu-item {
    display: block;
    width: 100%;
    padding: 8px 12px;
    border: none;
    background: none;
    color: var(--ink);
    cursor: pointer;
    text-align: left;
    text-decoration: none;
}

.menu-item:hover {
    background: var(--paper);
}

.menu-item.danger {
    color: var(--red);
}

.menu-label {
    padding: 6px 12px;
    color: var(--muted);
    font-size: 14px;
}

.subtabs {
    display: flex;
    gap: 4px 20px;
    overflow-x: auto;
    scrollbar-width: none;
    border-bottom: 1px solid var(--line);
}

.subtab {
    display: inline-flex;
    flex: none;
    align-items: center;
    gap: 6px;
    margin-bottom: -1px;
    padding: 8px 2px 9px;
    border-bottom: 3px solid transparent;
    color: var(--muted);
    text-decoration: none;
}

.subtab:hover {
    color: var(--ink);
}

.subtab.active {
    border-bottom-color: var(--green);
    color: var(--ink);
    font-weight: 600;
}

.subtab-count {
    color: var(--muted);
    font-size: 14px;
    font-weight: 400;
}

.mail-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px 24px;
}

.mail-bar .subtabs {
    flex: 0 1 auto;
    min-width: 0;
}

.shortcuts {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--sheet);
}

.shortcut {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 56px;
    padding: 8px 12px;
    border-left: 1px solid var(--line);
    color: var(--ink);
    font-weight: 500;
    text-align: center;
    text-decoration: none;
}

.shortcut:first-child {
    border-left: none;
}

.shortcut:hover {
    background: var(--hover);
    color: var(--green);
}

.shortcut .icon {
    color: var(--brass);
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 20px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 15px;
}

/* ---------- Form ---------- */

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

.form-grid-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.span-2 {
    grid-column: 1 / -1;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 16px;
    min-width: 0;
}

.field label,
.field-label {
    font-weight: 600;
}

.required {
    color: var(--red);
}

input:not([type="checkbox"], [type="file"]),
select,
textarea {
    width: 100%;
    min-height: 44px;
    padding: 9px 12px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: var(--sheet);
}

textarea {
    min-height: 0;
    resize: vertical;
}

input::placeholder,
textarea::placeholder {
    color: #76827d;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--green);
    outline: 2px solid var(--green);
    outline-offset: -1px;
}

.check {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 32px;
    margin-bottom: 8px;
}

.check input {
    flex: none;
    width: 20px;
    height: 20px;
    accent-color: var(--green);
}

.hint {
    color: var(--muted);
    font-size: 15px;
}

.error {
    color: var(--red);
    font-size: 15px;
    font-weight: 500;
}

fieldset {
    margin: 8px 0 20px;
    padding: 0;
    border: none;
    border-top: 1px solid var(--line);
    min-width: 0;
}

legend {
    padding: 12px 8px 4px 0;
    font: 500 18px/1.2 var(--serif);
}

#calendarFields {
    padding-top: 12px;
}

details summary {
    cursor: pointer;
}

.advanced {
    margin-bottom: 16px;
}

.advanced summary,
.filters summary {
    color: var(--green);
    font-size: 15px;
}

.advanced[open] summary,
.filters[open] summary {
    margin-bottom: 12px;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.search {
    display: flex;
    gap: 8px;
}

.search input {
    flex: 1;
    min-width: 0;
}

.search-filters {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.current-file {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 12px;
    overflow-wrap: anywhere;
}

.file-pick {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 12px;
    cursor: pointer;
}

.file-pick-input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.file-pick-input:focus-visible + .btn {
    outline: 2px solid var(--brass);
    outline-offset: 2px;
}

.file-pick-name {
    color: var(--muted);
    font-size: 15px;
    overflow-wrap: anywhere;
}

.seed-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
    gap: 0 12px;
    align-items: center;
}

.seed-row .btn {
    margin-top: 12px;
}

details .stack {
    gap: 4px;
}

/* ---------- Modali ---------- */

.dialog {
    width: min(620px, calc(100vw - 32px));
    max-height: calc(100dvh - 48px);
    padding: 0;
    border: none;
    border-radius: 6px;
    color: var(--ink);
    box-shadow: 0 24px 64px rgba(15, 41, 33, .32);
}

.dialog-wide {
    width: min(760px, calc(100vw - 32px));
}

.dialog[open] {
    display: flex;
    flex-direction: column;
    animation: dialog-in .14s ease-out;
}

.dialog h2:focus {
    outline: none;
}

.dialog::backdrop {
    background: rgba(15, 41, 33, .55);
}

@keyframes dialog-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
}

.dialog-form {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-height: 0;
    margin: 0;
}

.dialog-head,
.dialog-foot {
    display: flex;
    flex: none;
    align-items: center;
    gap: 8px;
    padding: 14px 24px;
}

.dialog-head {
    justify-content: space-between;
    border-bottom: 1px solid var(--line);
}

.dialog-foot {
    justify-content: flex-end;
    border-top: 1px solid var(--line);
    background: var(--paper);
}

.dialog-foot .btn-danger {
    margin-right: auto;
}

.dialog-body {
    flex: 1;
    min-height: 0;
    padding: 20px 24px;
    overflow: auto;
}

.dialog-close {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: var(--radius);
    background: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 24px;
    line-height: 36px;
    text-align: center;
    text-decoration: none;
}

.dialog-close:hover {
    background: var(--paper);
    color: var(--ink);
}

/* ---------- Avvisi ---------- */

.toasts {
    position: fixed;
    z-index: 30;
    right: 24px;
    bottom: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: min(440px, calc(100vw - 32px));
}

.toast {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 8px 12px 16px;
    border-left: 4px solid var(--ok);
    border-radius: var(--radius);
    background: var(--sheet);
    box-shadow: 0 8px 24px rgba(15, 41, 33, .2);
}

.toast-error {
    border-left-color: var(--red);
}

.toast-close {
    flex: none;
    width: 28px;
    height: 28px;
    border: none;
    background: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
}

/* ---------- Messaggio ---------- */

.message-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px 24px;
    padding: 20px 24px;
    border-bottom: 1px solid var(--line);
}

.message-head h2 {
    flex: 1 1 320px;
    font-size: 24px;
    overflow-wrap: anywhere;
}

.message-facts {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 4px 12px;
    margin: 0;
    padding: 16px 24px;
    border-bottom: 1px solid var(--line);
}

.message-facts dt {
    color: var(--muted);
}

.message-facts dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.message-files {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 16px 24px;
    border-bottom: 1px solid var(--line);
}

.file-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    padding: 6px 12px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    color: var(--ink);
    overflow-wrap: anywhere;
    text-decoration: none;
}

.file-chip:hover {
    background: var(--paper);
}

.message-body {
    padding: 20px 24px;
}

.message-body pre {
    margin: 0;
    font: inherit;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.message-body details {
    margin-top: 12px;
    color: var(--muted);
}

.mail-frame {
    display: block;
    width: 100%;
    min-height: 420px;
    border: none;
}

.message-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 12px;
    padding: 12px 24px;
    border-top: 1px solid var(--line);
    font-size: 14px;
    overflow-wrap: anywhere;
}

/* ---------- Calendario ---------- */

.cal-type-scadenza {
    --cal-accent: var(--red);
    --cal-soft: var(--red-soft);
}

.cal-type-promemoria {
    --cal-accent: var(--brass);
    --cal-soft: var(--amber-soft);
}

.cal-type-meeting {
    --cal-accent: var(--blue);
    --cal-soft: var(--blue-soft);
}

.cal-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 20px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--line);
}

.cal-nav {
    display: flex;
    gap: 4px;
}

.cal-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 16px;
    margin: 0 0 0 auto;
    padding: 0;
    color: var(--muted);
    font-size: 15px;
    list-style: none;
}

.cal-legend li {
    padding-left: 10px;
    border-left: 4px solid var(--cal-accent);
}

.cal-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.cal-filters select {
    width: auto;
    max-width: 260px;
}

.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
}

.cal-weekday {
    padding: 6px 10px;
    border-bottom: 1px solid var(--line);
    color: var(--muted);
    font-size: 15px;
}

.cal-day {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    min-height: 128px;
    padding: 6px;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    cursor: pointer;
}

.cal-day:nth-child(7n) {
    border-right: none;
}

.cal-day:nth-last-child(-n + 7) {
    border-bottom: none;
}

.cal-day:hover {
    background: var(--hover);
}

.cal-day-outside {
    background: var(--paper);
}

.cal-day-outside .cal-day-number {
    color: var(--muted);
}

.cal-day-head {
    display: flex;
    align-items: center;
}

.cal-day-name {
    display: none;
}

.cal-day-number {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: none;
    cursor: pointer;
    font-family: var(--serif);
    font-size: 17px;
    font-weight: 600;
}

.cal-day-today .cal-day-number {
    background: var(--green);
    color: #fff;
}

.cal-day-events {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.cal-event {
    display: block;
    width: 100%;
    padding: 4px 6px;
    border: none;
    border-left: 3px solid var(--cal-accent);
    border-radius: 2px;
    background: var(--cal-soft);
    cursor: pointer;
    font-size: 14px;
    line-height: 1.3;
    text-align: left;
}

.cal-event-title,
.cal-event-company {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cal-event-title {
    font-weight: 600;
}

.cal-event-general-label {
    color: var(--muted);
    font-style: italic;
}

.cal-event-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0 8px;
    color: var(--muted);
}

.cal-empty {
    display: none;
}

/* ---------- Accesso ed errori ---------- */

.login {
    display: grid;
    grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
    min-height: 100vh;
}

.login-cover {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 56px;
    background: var(--green);
    color: #fff;
}

.login-cover .brand {
    margin-bottom: auto;
    font-size: 25px;
}

.login-citation {
    max-width: 16em;
    padding-top: 14px;
    border-top: 3px solid var(--brass);
    font: 500 32px/1.2 var(--serif);
}

.login-claim {
    max-width: 30em;
    margin-top: 16px;
    color: var(--green-mist);
    font-size: 18px;
}

.login-form {
    display: flex;
    flex-direction: column;
    justify-content: center;
    width: 100%;
    max-width: 440px;
    margin: 0 auto;
    padding: 40px 24px;
}

.login-form h1 {
    margin-bottom: 24px;
}

.login-form form {
    margin: 0;
}

.login-alert {
    margin-bottom: 16px;
    padding: 10px 14px;
    border-left: 4px solid var(--ok);
    background: var(--ok-soft);
}

.login-alert-error {
    border-left-color: var(--red);
    background: var(--red-soft);
}

.error-page {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 20px;
    max-width: 560px;
    margin: 0 auto;
    padding: 96px 24px;
}

.error-page p {
    margin-top: 8px;
    color: var(--muted);
}

/* ---------- Schermi medi e piccoli ---------- */

@media (max-width: 960px) {
    .desk {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas: "deadlines" "mail" "companies";
        grid-template-rows: none;
    }

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

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

    .login {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto 1fr;
    }

    .login-cover {
        padding: 24px;
    }

    .login-cover .brand {
        margin-bottom: 32px;
    }

    .login-citation {
        font-size: 24px;
    }

    .login-claim {
        font-size: 16px;
    }

    .login-form {
        justify-content: flex-start;
    }
}

@media (max-width: 720px) {
    :root {
        --gutter: 16px;
    }

    body:not(.body-bare) {
        padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom));
    }

    h1 {
        font-size: 26px;
    }

    .band {
        padding: 20px 0;
    }

    .band-file {
        padding-bottom: 0;
    }

    .file-tabs {
        margin-top: 16px;
        margin-right: calc(var(--gutter) * -1);
        padding-right: var(--gutter);
    }

    .file-tab {
        padding: 9px 14px 10px;
    }

    .topbar-row {
        justify-content: space-between;
        min-height: 52px;
    }

    .mainnav {
        position: fixed;
        z-index: 15;
        right: 0;
        bottom: 0;
        left: 0;
        gap: 0;
        height: calc(var(--nav-height) + env(safe-area-inset-bottom));
        padding-bottom: env(safe-area-inset-bottom);
        border-top: 1px solid var(--line-strong);
        background: var(--sheet);
    }

    .mainnav-link {
        flex: 1;
        flex-direction: column;
        justify-content: center;
        gap: 2px;
        padding: 0;
        color: var(--muted);
        font-size: 13px;
    }

    .mainnav-link:hover {
        color: var(--muted);
    }

    .mainnav-link.active {
        color: var(--green);
        font-weight: 600;
        box-shadow: inset 0 3px 0 var(--brass);
    }

    .mainnav-link .icon {
        width: 22px;
        height: 22px;
    }

    .mainnav-link .count {
        position: absolute;
        top: 6px;
        left: calc(50% + 6px);
        min-width: 18px;
        padding: 0 4px;
        font-size: 12px;
        line-height: 18px;
    }

    .toasts {
        right: 16px;
        bottom: calc(var(--nav-height) + 12px + env(safe-area-inset-bottom));
    }

    .btn {
        min-height: 44px;
    }

    .form-grid,
    .form-grid-4,
    .seed-row {
        grid-template-columns: minmax(0, 1fr);
    }

    .seed-row {
        padding-bottom: 12px;
        border-bottom: 1px solid var(--line);
    }

    .seed-row .btn {
        margin-top: 0;
        justify-self: start;
    }

    .sheet-pad {
        padding: 16px;
    }

    .sheet-head,
    .row,
    .pagination {
        padding-right: 16px;
        padding-left: 16px;
    }

    .sheet-head {
        flex-wrap: wrap;
        gap: 8px 16px;
    }

    .row {
        flex-wrap: wrap;
    }

    .row > .actions {
        width: 100%;
    }

    .row-side {
        flex: 1 0 100%;
        flex-direction: row;
        align-items: center;
        flex-wrap: wrap;
        gap: 4px 12px;
    }

    .agenda-row {
        flex-wrap: nowrap;
        align-items: flex-start;
    }

    .agenda-row .cal-event {
        padding-left: 10px;
    }

    .agenda-row .row-next {
        display: none;
    }

    .message-row {
        flex-wrap: nowrap;
    }

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

    .shortcut:nth-child(odd) {
        border-left: none;
    }

    .shortcut:nth-child(n + 3) {
        border-top: 1px solid var(--line);
    }

    .mail-bar {
        flex-flow: column nowrap;
        align-items: stretch;
    }

    .mail-bar .actions > * {
        flex: 1;
    }

    .mail-bar .actions .btn {
        width: 100%;
    }

    .menu-list {
        position: fixed;
        top: auto;
        right: 16px;
        bottom: calc(var(--nav-height) + 16px);
        left: 16px;
    }

    .dialog,
    .dialog-wide {
        width: 100vw;
        max-width: 100vw;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
    }

    .dialog-head,
    .dialog-foot,
    .dialog-body {
        padding-right: 16px;
        padding-left: 16px;
    }

    .message-head,
    .message-facts,
    .message-files,
    .message-body,
    .message-foot {
        padding-right: 16px;
        padding-left: 16px;
    }

    .message-head .actions {
        width: 100%;
    }

    .message-head .actions .btn {
        flex: 1;
    }

    .info:focus::after {
        position: fixed;
        top: auto;
        right: 16px;
        bottom: calc(var(--nav-height) + 16px);
        left: 16px;
        width: auto;
        padding: 14px 16px;
    }

    /* Il mese diventa un elenco dei giorni con eventi e del giorno corrente */
    .cal-grid {
        display: block;
    }

    .cal-weekday,
    .cal-day {
        display: none;
    }

    .cal-day.cal-day-busy:not(.cal-day-outside),
    .cal-day.cal-day-today:not(.cal-day-outside) {
        display: grid;
        grid-template-columns: 64px minmax(0, 1fr);
        min-height: 0;
        padding: 10px 16px;
        border-right: none;
        border-bottom: 1px solid var(--line);
    }

    .cal-day-head {
        flex-direction: column;
        align-items: flex-start;
    }

    .cal-day-name {
        display: block;
        color: var(--muted);
        font-size: 13px;
        white-space: nowrap;
    }

    .cal-day:has(.cal-event) {
        cursor: default;
    }

    .cal-event {
        padding: 8px 10px;
        font-size: 15px;
    }

    .cal-event-title {
        white-space: normal;
    }

    .cal-empty {
        display: block;
    }

    .cal-filters,
    .cal-filters select {
        width: 100%;
        max-width: none;
    }

    .cal-legend {
        width: 100%;
        margin-left: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .dialog[open] {
        animation: none;
    }
}
