:root {
    font-family: "Segoe UI", Inter, Arial, sans-serif;
    color: #182230;
    background: #eef2f6;
}

* { box-sizing: border-box; }
body { margin: 0; }
a { color: inherit; }

.app-shell {
    display: grid;
    grid-template-columns: 248px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 26px;
    padding: 24px 20px;
    background: #101828;
    color: #fff;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #fff;
    text-decoration: none;
}

.brand-logo {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: #14b8a6;
    font-weight: 900;
}

/* Real logo image used in the sidebar brand (replaces the old "DS" box). */
.brand-logo-img {
    width: 46px;
    height: 46px;
    border-radius: 10px;
    display: block;
}

/* Letterhead brand mark placed at the start of page headers. The sibling rule keeps
   the title block left-aligned and pushes any right-side actions to the far right. */
.brand-mark { flex: 0 0 auto; width: 42px; height: 42px; border-radius: 9px; display: block; }
.operator-topbar > .brand-mark + div,
.workspace-header > .brand-mark + div { margin-right: auto; }

/* Brand logo in the home hero */
.hero-logo { height: 46px; display: block; margin-bottom: 16px; }

.brand strong, .brand small { display: block; }
.brand small { color: #98a2b3; margin-top: 2px; }

.nav-menu {
    display: grid;
    gap: 8px;
}

.nav-section {
    margin-top: 8px;
    color: #98a2b3;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.nav-menu a {
    padding: 11px 12px;
    border-radius: 8px;
    color: #e4e7ec;
    text-decoration: none;
    font-weight: 700;
}

.nav-menu a:hover { background: #1d2939; }

/* Intestazione della sidebar (brand + toggle). Su desktop il toggle è nascosto. */
.sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.nav-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: 1px solid #233044;
    border-radius: 10px;
    background: #172033;
    color: #fff;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}
.nav-toggle:hover { background: #1d2939; }

/* Su desktop il wrapper del drawer è "trasparente": i figli restano nel flusso della sidebar. */
.sidebar-drawer { display: contents; }
.nav-backdrop { display: none; }

.profile-panel {
    display: grid;
    gap: 10px;
    padding: 12px;
    border: 1px solid #233044;
    border-radius: 8px;
    background: #172033;
}

.profile-panel span,
.profile-panel small {
    display: block;
    color: #98a2b3;
    font-size: 12px;
    font-weight: 800;
}

.profile-panel strong {
    display: block;
    margin-top: 2px;
    color: #ffffff;
}

.profile-panel label {
    margin: 0;
    color: #cbd5e1;
}

.profile-panel input {
    min-height: 36px;
    border-color: #344054;
    background: #0f172a;
    color: #ffffff;
}

.profile-panel .secondary-btn {
    min-height: 36px;
}

.profile-message,
.profile-error {
    margin: 0;
    font-size: 12px;
    font-weight: 800;
}

.profile-message { color: #86efac; }
.profile-error { color: #fecaca; }
.link-btn.light { color: #5eead4; justify-self: start; }

.powered {
    margin-top: auto;
    color: #98a2b3;
    font-size: 13px;
}

.powered a { color: #5eead4; }

/* "Powered by [CapoWeb]" credit in the sidebar footer (dark bg → light chip). */
a.powered {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    background: #fff;
    border-radius: 999px;
    padding: 7px 14px 7px 12px;
    align-self: flex-start;
}
a.powered span {
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .6px;
    text-transform: uppercase;
    color: #64748b;
}
a.powered img { height: 16px; width: auto; display: block; }

/* Login branding bits */
.login-tagline { color: #475467; font-size: 14px; margin: 10px 0 18px; }
.login-credit { display: inline-flex; align-items: center; gap: 8px; margin-top: 18px; }
.login-credit span { font-size: 9px; font-weight: 800; letter-spacing: .6px; text-transform: uppercase; color: #94a3b8; }
.login-credit img { height: 16px; width: auto; display: block; }

.main-content {
    width: 100%;
    max-width: 1680px;
    margin: 0 auto;
    padding: 30px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    /* Nessun pannello deve sforare orizzontalmente su mobile (altezza automatica:
       non compaiono scrollbar verticali). Garanzia trasversale per la PWA. */
    overflow-x: hidden;
}
.main-content-body { flex: 1 0 auto; }

/* Global app footer (appears on every shell page) */
.app-footer {
    flex-shrink: 0;
    margin-top: 28px;
    padding: 16px 4px 4px;
    border-top: 1px solid #e4e7ec;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    color: #98a2b3;
    font-size: 12.5px;
}
.app-footer .af-brand { font-weight: 700; color: #667085; }
.app-footer .af-credit { display: inline-flex; align-items: center; gap: 7px; text-decoration: none; }
.app-footer .af-credit span { font-size: 9px; font-weight: 800; letter-spacing: .6px; text-transform: uppercase; color: #98a2b3; }
.app-footer .af-credit img { height: 15px; width: auto; display: block; }

h1, h2, h3, p { margin-top: 0; }
h1 { font-size: 32px; line-height: 1.15; margin-bottom: 8px; }
h2 { font-size: 20px; margin-bottom: 8px; }
h3 { font-size: 16px; margin-bottom: 10px; }
.muted { color: #667085; }
.eyebrow {
    margin-bottom: 6px;
    color: #0f766e;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .06em;
    text-transform: uppercase;
}

button, .primary-btn, .secondary-btn {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 8px;
    padding: 10px 16px;
    font: inherit;
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
}

.primary-btn { background: #0f766e; color: #fff; }
.secondary-btn { background: #e4e7ec; color: #182230; }
button:disabled { opacity: .5; cursor: not-allowed; }

input, select {
    width: 100%;
    min-height: 40px;
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    padding: 9px 11px;
    font: inherit;
    background: #fff;
}

input[type="checkbox"] {
    width: auto;
    min-height: 0;
    margin-right: 8px;
}

label {
    display: block;
    margin-bottom: 5px;
    color: #344054;
    font-size: 13px;
    font-weight: 800;
}

code {
    display: inline-block;
    max-width: 100%;
    overflow-wrap: anywhere;
    padding: 3px 6px;
    border-radius: 6px;
    background: #eff6ff;
    color: #1d4ed8;
}

.alert {
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid;
}

.error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.success { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }

.home-hero {
    min-height: 360px;
    display: flex;
    align-items: center;
    padding: 44px;
    border-radius: 8px;
    background: #fff;
    border: 1px solid #d9e2ec;
}

.home-hero h1 { max-width: 760px; font-size: 42px; }
.hero-copy { max-width: 620px; color: #475467; font-size: 18px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 24px; }

.role-cards {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    margin-top: 18px;
}

.role-card {
    padding: 24px;
    border-radius: 8px;
    border: 1px solid #d9e2ec;
    background: #fff;
}

.role-icon {
    display: inline-flex;
    margin-bottom: 18px;
    padding: 6px 10px;
    border-radius: 999px;
    background: #e6fffb;
    color: #0f766e;
    font-weight: 900;
}

.workspace-header {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: flex-start;
    padding: 24px;
    margin-bottom: 18px;
    border-radius: 8px;
}

.operator-theme {
    background: #ffffff;
    border: 1px solid #d9e2ec;
}

.admin-theme {
    background: #172033;
    color: #ffffff;
}

.admin-theme h1, .admin-theme .muted { color: #ffffff; }

.operator-workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 310px;
    gap: 18px;
    align-items: start;
}

.process-panel, .operator-summary, .operator-documents, .management-panel {
    border: 1px solid #d9e2ec;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 10px 28px rgba(16, 24, 40, .06);
}

.process-panel { padding: 18px; }
.operator-summary { padding: 20px; position: sticky; top: 20px; }
.operator-documents { margin-top: 18px; padding: 20px; }

.wizard-steps {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 18px;
}

.wizard-steps button {
    justify-content: flex-start;
    gap: 10px;
    min-height: 68px;
    background: #f2f4f7;
    color: #344054;
}

.wizard-steps button span {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    background: #d0d5dd;
    font-weight: 900;
}

.wizard-steps button strong, .wizard-steps button small { display: block; }
.wizard-steps button small { color: #667085; font-size: 12px; }
.wizard-steps button.active { background: #0f766e; color: #fff; }
.wizard-steps button.active span { background: #ccfbf1; color: #0f766e; }
.wizard-steps button.active small { color: #d1faf3; }
.wizard-steps button.done { background: #e0f2fe; color: #075985; }

.step-card {
    padding: 20px;
    border: 1px solid #e4e7ec;
    border-radius: 8px;
    background: #fcfcfd;
}

.step-title p { color: #667085; }

.upload-zone {
    display: grid;
    place-items: center;
    gap: 5px;
    min-height: 150px;
    margin: 16px 0;
    border: 2px dashed #99f6e4;
    border-radius: 8px;
    background: #f0fdfa;
    color: #0f766e;
    cursor: pointer;
}

.upload-zone input { max-width: 260px; background: transparent; border: 0; }
.upload-zone span { font-size: 18px; font-weight: 900; }
.upload-zone small { color: #475467; }

.document-strip, .document-row {
    display: grid;
    grid-template-columns: minmax(160px, 1fr) auto minmax(180px, 2fr);
    gap: 10px;
    align-items: center;
    padding: 12px;
    border: 1px solid #e4e7ec;
    border-radius: 8px;
    background: #fff;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }

.consent-box {
    display: grid;
    gap: 10px;
    padding: 14px;
    margin: 16px 0;
    border-radius: 8px;
    background: #f8fafc;
}

.consent-box label {
    display: flex;
    align-items: center;
    margin: 0;
}

.actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 16px;
}

canvas.signature-pad {
    width: 100%;
    max-width: 720px;
    height: 230px;
    border: 2px dashed #98a2b3;
    border-radius: 8px;
    background: #fff;
    touch-action: none;
}

.signature-controls {
    margin-top: 10px;
}

.success-panel {
    display: grid;
    gap: 8px;
    align-items: start;
    margin-top: 14px;
    padding: 14px;
    border-radius: 8px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
}

.operator-summary dl { display: grid; gap: 12px; margin: 0; }
.operator-summary div {
    padding-bottom: 12px;
    border-bottom: 1px solid #e4e7ec;
}
.operator-summary dt {
    color: #667085;
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}
.operator-summary dd { margin: 3px 0 0; overflow-wrap: anywhere; }

.admin-metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.admin-metrics article {
    padding: 18px;
    border-radius: 8px;
    background: #ffffff;
    border: 1px solid #d9e2ec;
}

.admin-metrics span, .admin-metrics small {
    display: block;
    color: #667085;
}

.admin-metrics strong {
    display: block;
    margin: 8px 0;
    font-size: 34px;
}

.admin-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 18px;
    align-items: start;
    margin-bottom: 18px;
}

.management-panel { padding: 18px; }
.compact-panel + .compact-panel { margin-top: 18px; }

.section-heading {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
    margin-bottom: 16px;
}

.management-table {
    border: 1px solid #e4e7ec;
    border-radius: 8px;
    overflow: hidden;
}

.table-head, .table-row {
    display: grid;
    gap: 12px;
    align-items: center;
    padding: 11px 12px;
}

.table-head {
    background: #f2f4f7;
    color: #667085;
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.table-row {
    border-top: 1px solid #e4e7ec;
    background: #fff;
}

.table-head.users, .table-row.users { grid-template-columns: minmax(160px, 1fr) 120px minmax(200px, 1fr) 100px 80px; }
.table-head.documents, .table-row.documents { grid-template-columns: minmax(180px, 1.3fr) 150px 130px 100px 110px; }
.table-head.desks, .table-row.desks { grid-template-columns: minmax(160px, 1fr) 150px 90px 110px 80px; }
.table-head.roles, .table-row.roles { grid-template-columns: minmax(140px, .8fr) minmax(240px, 1.5fr) 90px 80px; }
.table-head.admin-documents, .table-row.admin-documents { grid-template-columns: minmax(180px, 1.25fr) 150px 130px 150px 100px 120px 120px; }

.status-pill {
    width: fit-content;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 900;
}

.status-pill.uploaded { background: #eef2ff; color: #3730a3; }
.status-pill.awaiting { background: #fffbeb; color: #92400e; }
.status-pill.signed { background: #dcfce7; color: #166534; }
.status-pill.cancelled { background: #fee2e2; color: #991b1b; }

.desk-list, .role-list {
    display: grid;
    gap: 10px;
}

.desk-list div, .role-list span {
    display: grid;
    gap: 3px;
    padding: 12px;
    border-radius: 8px;
    background: #f8fafc;
    border: 1px solid #e4e7ec;
}

.desk-list span, .desk-list small { color: #667085; }
.empty-state { color: #667085; margin-bottom: 0; }

@media (max-width: 1120px) {
    .app-shell { grid-template-columns: 1fr; }
    /* Barra in alto sticky: mostra solo brand + hamburger. */
    .sidebar {
        position: sticky;
        top: 0;
        z-index: 50;
        gap: 0;
        padding: 12px 16px;
    }
    .nav-toggle { display: inline-flex; }
    /* Il drawer è un pannello a comparsa sotto la barra. */
    .sidebar-drawer { display: none; }
    .sidebar.nav-open .sidebar-drawer {
        display: flex;
        flex-direction: column;
        gap: 14px;
        position: absolute;
        left: 0;
        right: 0;
        top: 100%;
        padding: 14px 16px;
        background: #101828;
        box-shadow: 0 16px 30px rgba(0, 0, 0, .35);
        max-height: calc(100vh - 68px);
        overflow-y: auto;
    }
    .sidebar.nav-open .nav-menu { display: grid; }
    .sidebar.nav-open .nav-section { display: block; }
    /* Sfondo oscurato dietro al drawer: tap per chiudere. */
    .nav-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, .45);
        z-index: 40;
    }
    .operator-workspace, .admin-grid, .role-cards {
        grid-template-columns: 1fr;
    }
    .operator-summary { position: static; }
    .admin-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
    .main-content { padding: 18px; }
    .home-hero { padding: 24px; }
    .home-hero h1 { font-size: 30px; }
    .workspace-header, .section-heading { flex-direction: column; }
    .wizard-steps, .form-grid, .form-grid.two, .admin-metrics, .document-strip, .document-row,
    .table-head.users, .table-row.users, .table-head.documents, .table-row.documents {
        grid-template-columns: 1fr;
    }
}

/* DeskSign operator workflow */
.operator-page {
    display: grid;
    gap: 18px;
}

.operator-topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 18px;
    padding: 22px 24px;
    border: 1px solid #d9e2ec;
    border-radius: 8px;
    background: #ffffff;
}

.signing-shell {
    display: grid;
    grid-template-columns: 230px minmax(420px, 1fr) minmax(360px, 42%);
    gap: 16px;
    align-items: start;
}

/* Anonymization: give the PDF preview more room, but keep the controls column wide
   enough that the add-form and toolbar buttons never get clipped. */
.signing-shell.wide-preview {
    grid-template-columns: 200px minmax(340px, 0.85fr) minmax(520px, 1.6fr);
}

.wizard-rail {
    display: grid;
    gap: 10px;
    padding: 14px;
    border: 1px solid #d9e2ec;
    border-radius: 8px;
    background: #ffffff;
}

.wizard-rail button {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr);
    grid-template-areas:
        "num title"
        "num desc";
    gap: 2px 10px;
    align-items: center;
    min-height: 72px;
    padding: 12px;
    border: 1px solid #e4e7ec;
    background: #f8fafc;
    color: #344054;
    text-align: left;
}

.wizard-rail button span {
    grid-area: num;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: #e4e7ec;
    font-weight: 900;
}

.wizard-rail button strong {
    grid-area: title;
    line-height: 1.1;
}

.wizard-rail button small {
    grid-area: desc;
    color: #667085;
}

.wizard-rail button.active {
    border-color: #0f766e;
    background: #ecfdf5;
    color: #0f766e;
}

.wizard-rail button.active span {
    background: #0f766e;
    color: #ffffff;
}

.wizard-rail button.done {
    border-color: #bfdbfe;
    background: #eff6ff;
    color: #1d4ed8;
}

.wizard-stage, .preview-panel, .signed-archive {
    border: 1px solid #d9e2ec;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 10px 28px rgba(16, 24, 40, .06);
}

.wizard-stage {
    min-height: 620px;
    padding: 18px;
}

.wizard-card {
    display: grid;
    gap: 16px;
}

.wizard-card-header, .preview-header {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: flex-start;
    padding-bottom: 14px;
    border-bottom: 1px solid #e4e7ec;
}

.dropzone {
    display: grid;
    place-items: center;
    gap: 6px;
    min-height: 190px;
    padding: 24px;
    border: 2px dashed #7dd3fc;
    border-radius: 8px;
    background: #f0f9ff;
    color: #075985;
    cursor: pointer;
    text-align: center;
}

.dropzone input {
    max-width: 300px;
    border: 0;
    background: transparent;
}

.dropzone strong {
    font-size: 20px;
}

.compact-document {
    display: grid;
    gap: 8px;
    padding: 12px;
    border: 1px solid #e4e7ec;
    border-radius: 8px;
    background: #fcfcfd;
}

.consent-panel {
    display: grid;
    gap: 10px;
    padding: 14px;
    border: 1px solid #e4e7ec;
    border-radius: 8px;
    background: #f8fafc;
}

.consent-field {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 190px;
    gap: 12px;
    align-items: center;
    padding: 10px;
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    background: #ffffff;
}

.consent-field label {
    margin: 0;
}

.consent-field select {
    min-height: 36px;
    font-weight: 800;
}

.consent-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    font-size: 14px;
    line-height: 1.4;
    width: 100%;
    border: 2px solid #d1d5db;
    background: #ffffff;
    color: #111;
    font-family: inherit;
}

.consent-btn.accepted {
    border-color: #16a34a;
    background: #f0fdf4;
}

.consent-btn .consent-icon {
    font-size: 1.6em;
    line-height: 1;
    color: #9ca3af;
}

.consent-btn.accepted .consent-icon {
    color: #16a34a;
}

.consent-btn .consent-text {
    flex: 1;
}

/* Anonymization module */
.match-toolbar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.match-table {
    display: grid;
    gap: 16px;
}

.match-group {
    display: grid;
    gap: 6px;
    padding: 12px;
    border: 1px solid #e4e7ec;
    border-radius: 8px;
    background: #fafbfc;
}

.match-group header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 13px;
    color: #475569;
}

.match-row {
    display: grid;
    grid-template-columns: 28px 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid #d1d5db;
    background: #ffffff;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    font-size: 13px;
    color: #111;
}

.match-row.selected {
    border-color: #f59e0b;
    background: #fffbeb;
}

.match-row .match-check {
    font-size: 1.3em;
    line-height: 1;
    color: #9ca3af;
}

.match-row.selected .match-check {
    color: #d97706;
}

.match-row .match-text {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
    word-break: break-all;
}

.match-row small {
    color: #6b7280;
}

.mode-picker {
    display: grid;
    gap: 10px;
    padding: 14px;
    border: 1px solid #e4e7ec;
    border-radius: 8px;
    background: #fafbfc;
}

.mode-picker > strong {
    font-size: 13px;
    color: #475569;
}

.mode-option {
    display: grid;
    grid-template-columns: 32px 1fr;
    gap: 12px;
    align-items: center;
    padding: 12px;
    border-radius: 8px;
    border: 2px solid #d1d5db;
    background: #ffffff;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
    color: #111;
}

.mode-option:hover {
    border-color: #94a3b8;
}

.mode-option.active {
    border-color: #0f766e;
    background: #f0fdfa;
}

.mode-option strong {
    display: block;
    font-size: 14px;
}

.mode-option small {
    display: block;
    color: #6b7280;
    font-size: 12px;
}

.mode-swatch {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1px solid #00000022;
}

.mode-swatch.yellow {
    background: #fde047;
}

.mode-swatch.black {
    background: #111111;
}

.manual-add {
    display: grid;
    gap: 8px;
    padding: 14px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #f8fafc;
}

.manual-add strong {
    font-size: 14px;
    color: #0f172a;
}

.manual-add .muted {
    font-size: 12px;
    margin: 0;
}

.manual-add-form {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.manual-add-form input {
    flex: 1 1 100%;
}

.manual-add-form select {
    flex: 1 1 140px;
    min-width: 0;
}

.manual-add-form button {
    flex: 0 0 auto;
    white-space: nowrap;
}

.manual-add-form input,
.manual-add-form select {
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
    font-family: inherit;
    font-size: 14px;
    min-height: 36px;
}

.match-row-wrap {
    display: grid;
    grid-template-columns: 1fr 32px;
    align-items: stretch;
    gap: 6px;
}

.match-delete {
    width: 32px;
    border-radius: 6px;
    border: 1px solid #fecaca;
    background: #fef2f2;
    color: #991b1b;
    cursor: pointer;
    font-size: 18px;
    font-weight: 700;
    line-height: 1;
    font-family: inherit;
}

.match-delete:hover:not(:disabled) {
    background: #fee2e2;
    border-color: #f87171;
}

.match-delete:disabled {
    opacity: 0.5;
    cursor: wait;
}

@media (max-width: 600px) {
    .manual-add-form {
        grid-template-columns: 1fr;
    }
}

/* Interactive PDF viewer for anonymization */
.anon-viewer {
    width: 100%;
    max-height: 75vh;
    overflow: auto;
    background: #e5e7eb;
    border-radius: 8px;
    padding: 12px;
}

.anon-viewer-host {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.anon-viewer-placeholder {
    padding: 24px;
    color: #6b7280;
    text-align: center;
}

.anon-page {
    background: #ffffff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
    margin: 0 auto 16px;
    user-select: none;
}

.anon-page-label {
    position: absolute;
    top: 4px;
    left: 6px;
    font-size: 11px;
    font-weight: 700;
    color: #475569;
    background: rgba(255, 255, 255, 0.85);
    padding: 2px 6px;
    border-radius: 4px;
    pointer-events: none;
}

.anon-overlay {
    touch-action: none;
}

.anon-match:hover {
    outline: 2px solid #16a34a;
}

.small-help {
    font-size: 12px;
    color: #475569;
    margin: 0 0 8px;
}

/* Super-admin (vendor) console */
.superadmin-shell {
    min-height: 100vh;
    background: #0f172a;
}

.superadmin-topbar {
    padding: 16px 28px;
    color: #e2e8f0;
    background: #111827;
    border-bottom: 1px solid #1f2937;
}

.superadmin-main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 28px;
}

.superadmin-page {
    display: grid;
    gap: 18px;
}

.superadmin-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    color: #e2e8f0;
}

.superadmin-header h1 { margin: 0; }

.auth-card {
    max-width: 380px;
    margin: 80px auto;
    background: #ffffff;
    border-radius: 12px;
    padding: 28px;
    display: grid;
    gap: 10px;
    box-shadow: 0 18px 40px rgba(0,0,0,.35);
}

.auth-card input {
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 14px;
}

.superadmin-page .card {
    background: #ffffff;
    border-radius: 12px;
    padding: 20px;
    display: grid;
    gap: 12px;
}

.superadmin-page textarea {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 8px 10px;
    font-family: ui-monospace, Menlo, monospace;
    font-size: 12px;
}

.tenant-table { display: grid; gap: 10px; }

.tenant-row {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 12px 14px;
    border: 1px solid #e4e7ec;
    border-radius: 8px;
}

.tenant-row.inactive { opacity: .6; }

.tenant-main, .tenant-license { display: flex; flex-direction: column; gap: 4px; }
.tenant-main { flex-direction: row; align-items: center; gap: 8px; flex-wrap: wrap; }
.tenant-actions { display: flex; gap: 8px; }

.tenant-license-edit {
    grid-column: 1 / -1;
    display: grid;
    gap: 8px;
    border-top: 1px solid #eef2f6;
    padding-top: 10px;
}

.module-checks {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.module-checks label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
}

/* License status page */
.license-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
}

.license-card {
    display: grid;
    gap: 6px;
    padding: 16px;
    border: 1px solid #e4e7ec;
    border-radius: 10px;
    background: #ffffff;
}

.license-card .license-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #667085;
}

.license-card strong {
    font-size: 20px;
}

.license-modules {
    margin-top: 20px;
    display: grid;
    gap: 10px;
}

.module-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.module-badge {
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
    border: 1px solid;
}

.module-badge.on {
    background: #f0fdf4;
    color: #166534;
    border-color: #bbf7d0;
}

.module-badge.off {
    background: #f8fafc;
    color: #94a3b8;
    border-color: #e2e8f0;
    text-decoration: line-through;
}

@media (max-width: 760px) {
    .tenant-row { grid-template-columns: 1fr; }
}

.readiness-panel,
.placement-instruction,
.placement-help {
    display: grid;
    gap: 4px;
    padding: 12px;
    border: 1px solid #fed7aa;
    border-radius: 8px;
    background: #fff7ed;
    color: #9a3412;
}

.readiness-panel.ready,
.placement-instruction,
.placement-help {
    border-color: #99f6e4;
    background: #ecfdf5;
    color: #0f766e;
}

.readiness-panel strong,
.placement-instruction strong,
.placement-help strong {
    font-size: 13px;
}

.readiness-panel span,
.placement-instruction span,
.placement-help span {
    color: #475467;
    font-size: 13px;
}

.signature-area {
    padding: 14px;
    border: 1px solid #e4e7ec;
    border-radius: 8px;
    background: #f8fafc;
}

.finish-card {
    min-height: 460px;
    place-items: center;
    text-align: center;
}

.finish-icon {
    width: 64px;
    height: 64px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: #dcfce7;
    color: #166534;
    font-size: 34px;
    font-weight: 900;
}

.preview-panel {
    position: sticky;
    top: 20px;
    display: grid;
    gap: 14px;
    padding: 16px;
}

.pdf-preview {
    width: 100%;
    height: 620px;
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    background: #f8fafc;
}

.empty-preview {
    height: 620px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 8px;
    padding: 24px;
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
    background: #f8fafc;
    color: #667085;
    text-align: center;
}

.practice-summary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin: 0;
}

.practice-summary div {
    padding: 10px;
    border-radius: 8px;
    background: #f8fafc;
}

.practice-summary dt {
    color: #667085;
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
}

.practice-summary dd {
    margin: 4px 0 0;
    overflow-wrap: anywhere;
}

.signed-archive {
    padding: 18px;
}

.archive-table {
    display: grid;
    gap: 8px;
}

.archive-row {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto 150px 80px;
    gap: 12px;
    align-items: center;
    padding: 12px;
    border: 1px solid #e4e7ec;
    border-radius: 8px;
    background: #fcfcfd;
}

.status-pill.neutral {
    background: #f2f4f7;
    color: #475467;
}

.admin-console {
    display: grid;
    gap: 18px;
}

.admin-section-tabs {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
}

.admin-section-tabs a {
    min-height: 58px;
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border: 1px solid #d9e2ec;
    border-radius: 8px;
    padding: 10px 16px;
    background: #fff;
    color: #344054;
    font-weight: 800;
    text-decoration: none;
}

.admin-section-tabs a.active {
    border-color: #0f766e;
    background: #ecfdf5;
    color: #0f766e;
}

.admin-section-tabs span {
    min-width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    background: #f2f4f7;
    color: #475467;
    font-size: 12px;
    font-weight: 900;
}

.admin-section-tabs a.active span {
    background: #0f766e;
    color: #fff;
}

.admin-workbench {
    display: grid;
    grid-template-columns: minmax(340px, .9fr) minmax(0, 1.6fr);
    gap: 18px;
    align-items: start;
}

.action-row {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 14px;
}

.inline-input {
    width: auto;
    min-width: 220px;
}

.row-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.row-actions a {
    color: #0f766e;
    font-weight: 900;
    text-decoration: none;
}

.operator-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.link-btn {
    min-height: auto;
    padding: 0;
    background: transparent;
    color: #0f766e;
    font-weight: 900;
}

.stacked-form {
    display: grid;
    gap: 10px;
    margin-bottom: 14px;
}

.checkbox-cloud {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin: 14px 0;
}

.checkbox-cloud label, .check-line {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    margin: 0;
    padding: 7px 10px;
    border: 1px solid #d9e2ec;
    border-radius: 8px;
    background: #f8fafc;
}

.edit-panel {
    margin-bottom: 18px;
    border-color: #99f6e4;
}

.login-help {
    margin: 14px 0 0;
    color: #667085;
    font-size: 13px;
}

.placement-picker {
    display: grid;
    gap: 12px;
}

.placement-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.placement-toolbar select {
    max-width: 150px;
}

.placement-surface {
    position: relative;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow: auto;
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    background: #f8fafc;
    max-height: 640px;
}

/* PDF.js renders the selected page into this canvas. It sits at the back of the
   placement-layer; the placement-box overlays it pixel-perfectly because the layer
   has the exact same dimensions as the canvas. */
.placement-pdf-canvas {
    display: block;
    background: #ffffff;
    box-shadow: 0 2px 8px rgba(15, 23, 42, .08);
    pointer-events: none;
}

.placement-layer {
    position: relative;
    cursor: crosshair;
    touch-action: none;
}

.placement-box {
    position: absolute;
    display: grid;
    place-items: center;
    border: 2px solid #0f766e;
    border-radius: 8px;
    background: rgba(20, 184, 166, .16);
    color: #0f766e;
    font-size: 12px;
    font-weight: 900;
    pointer-events: none;
    box-shadow: 0 8px 18px rgba(15, 118, 110, .18);
}

@media (max-width: 1280px) {
    .admin-workbench {
        grid-template-columns: 1fr;
    }

    .admin-section-tabs {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .signing-shell {
        grid-template-columns: 210px minmax(0, 1fr);
    }

    /* Higher specificity than the base .signing-shell.wide-preview, so it collapses too. */
    .signing-shell.wide-preview {
        grid-template-columns: 210px minmax(0, 1fr);
    }

    .preview-panel {
        position: static;
        grid-column: 1 / -1;
    }

    .pdf-preview, .empty-preview {
        height: 560px;
    }
}

@media (max-width: 860px) {
    .operator-topbar, .wizard-card-header, .preview-header {
        flex-direction: column;
    }

    .admin-section-tabs {
        grid-template-columns: 1fr;
    }

    .signing-shell {
        grid-template-columns: 1fr;
    }

    .signing-shell.wide-preview {
        grid-template-columns: 1fr;
    }

    .wizard-rail {
        grid-template-columns: 1fr;
    }

    .practice-summary, .archive-row,
    .table-head.desks, .table-row.desks,
    .table-head.roles, .table-row.roles,
    .table-head.admin-documents, .table-row.admin-documents {
        grid-template-columns: 1fr;
    }

    .pdf-preview, .empty-preview {
        height: 480px;
    }
}

/* ---- PDF tools ---- */
.tool-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    margin-top: 18px;
}

.tool-card {
    display: grid;
    gap: 6px;
    justify-items: start;
    text-align: left;
    padding: 18px;
    border: 1px solid #d9e2ec;
    border-radius: 12px;
    background: #fff;
    color: #182230;
    cursor: pointer;
    transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}

.tool-card:hover {
    border-color: #0f766e;
    box-shadow: 0 10px 24px rgba(15, 118, 110, .12);
    transform: translateY(-2px);
}

.tool-card strong {
    font-size: 16px;
}

.tool-card small {
    color: #667085;
    line-height: 1.35;
}

.tool-icon {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: #ecfdf5;
    color: #0f766e;
    font-size: 22px;
    line-height: 1;
}

.tool-panel {
    margin-top: 18px;
    max-width: 760px;
}

.tool-panel .form-grid {
    margin-top: 4px;
}

.file-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 6px;
}

.file-list li {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 12px;
    border: 1px solid #e4e7ec;
    border-radius: 8px;
    background: #fcfcfd;
    font-size: 14px;
}

.file-list li small {
    color: #667085;
}

/* ---- PDF tools: page thumbnails ---- */
.thumb-bar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid #e4e7ec;
    border-radius: 8px;
    background: #f8fafc;
}

.thumb-hint {
    font-size: 13px;
    color: #475467;
    max-width: 60ch;
}

.thumb-actions {
    display: inline-flex;
    align-items: center;
    gap: 14px;
}

.thumb-summary {
    font-size: 13px;
    font-weight: 700;
    color: #0f766e;
    white-space: nowrap;
}

.thumb-host {
    margin-top: 4px;
}

.thumb-loading, .thumb-error {
    padding: 24px;
    text-align: center;
    color: #667085;
}

.thumb-error {
    color: #991b1b;
}

.thumb-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 14px;
}

.pdf-thumb {
    position: relative;
    display: grid;
    justify-items: center;
    gap: 6px;
    padding: 10px 8px 8px;
    border: 2px solid #d9e2ec;
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
    user-select: none;
    transition: border-color .12s ease, box-shadow .12s ease, transform .12s ease;
}

.pdf-thumb:hover {
    border-color: #94a3b8;
    box-shadow: 0 6px 16px rgba(15, 23, 42, .08);
}

.pdf-thumb.selected {
    border-color: #0f766e;
    background: #ecfdf5;
}

.pdf-thumb.dragging {
    opacity: .5;
    transform: scale(.97);
}

.pdf-thumb-canvas {
    display: grid;
    place-items: center;
    width: 100%;
    height: 150px;
    overflow: hidden;
}

.pdf-thumb-canvas canvas {
    max-width: 100%;
    max-height: 150px;
    box-shadow: 0 1px 4px rgba(15, 23, 42, .18);
    transition: transform .15s ease;
}

.pdf-thumb-num {
    min-width: 22px;
    height: 22px;
    display: inline-grid;
    place-items: center;
    padding: 0 6px;
    border-radius: 999px;
    background: #f2f4f7;
    color: #344054;
    font-size: 12px;
    font-weight: 800;
}

.pdf-thumb.selected .pdf-thumb-num {
    background: #0f766e;
    color: #fff;
}

/* Green check shown on selected thumbnails (select mode). */
.pdf-thumb-check {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 22px;
    height: 22px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    background: #0f766e;
    color: #fff;
    font-size: 13px;
    font-weight: 900;
    opacity: 0;
    transform: scale(.6);
    transition: opacity .12s ease, transform .12s ease;
}

.pdf-thumb.selected .pdf-thumb-check {
    opacity: 1;
    transform: scale(1);
}

/* Rotate button (rotate mode). */
.pdf-thumb-rot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 26px;
    height: 26px;
    padding: 0;
    display: grid;
    place-items: center;
    border-radius: 999px;
    border: 1px solid #0f766e;
    background: #fff;
    color: #0f766e;
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
}

.pdf-thumb-rot:hover {
    background: #0f766e;
    color: #fff;
}

.pdf-thumb.rotated {
    border-color: #0f766e;
}

/* Section label above a checkbox cloud (roles / desks). */
.cloud-label {
    display: block;
    margin: 12px 0 6px;
    font-size: 13px;
    font-weight: 800;
    color: #344054;
}

/* ============================================================
   TEMPLATE LIBRARY (signature flow + admin management)
   ============================================================ */
.source-tabs { display: inline-flex; gap: 6px; padding: 4px; background: #f2f4f7; border-radius: 10px; margin-bottom: 14px; }
.source-tabs button { border: 0; background: transparent; padding: 8px 16px; border-radius: 8px; font-weight: 700; color: #475467; cursor: pointer; }
.source-tabs button.active { background: #fff; color: #0f2557; box-shadow: 0 1px 3px rgba(15,37,87,.12); }

.tpl-picker { display: grid; grid-template-columns: minmax(0,1.1fr) minmax(0,1fr); gap: 16px; align-items: start; }
.tpl-browser { border: 1px solid #e4e7ec; border-radius: 10px; padding: 10px 12px; max-height: 360px; overflow: auto; background: #fcfcfd; }
.tpl-fill { border: 1px solid #e4e7ec; border-radius: 10px; padding: 16px; background: #fff; }
.tpl-fill-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tpl-identity-mode { margin: 8px 0 12px; }
.tpl-identity-mode > label { display: block; font-weight: 700; font-size: 13px; margin-bottom: 4px; color: #344054; }

/* Step 1 senza anteprima → il wizard occupa tutta la larghezza disponibile. */
.signing-shell.no-preview { grid-template-columns: 230px 1fr; }
.signing-shell.no-preview .preview-panel { display: none; }

/* Form responsivo per i campi del template in step 1: 1-3 colonne in base alla larghezza. */
.tpl-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px 16px; margin-top: 4px; }
.tpl-field label { display: block; font-weight: 700; font-size: 13px; color: #344054; margin-bottom: 4px; }
.tpl-field input, .tpl-field select, .tpl-field textarea {
    width: 100%; padding: 11px 12px; font-size: 14.5px;
    border: 1px solid #d0d5dd; border-radius: 8px; background: #fff;
    box-sizing: border-box; font-family: inherit;
}
.tpl-field textarea { resize: vertical; min-height: 70px; }
.tpl-field input[type="checkbox"] { width: auto; vertical-align: middle; }
.tpl-field input:focus, .tpl-field select:focus, .tpl-field textarea:focus {
    outline: none; border-color: #1d4ed8; box-shadow: 0 0 0 3px rgba(29, 78, 216, .12);
}
.tpl-field .req { color: #dc2626; margin-left: 3px; }
.tpl-field .kind-hint {
    margin-left: 8px; font-size: 11px; font-weight: 500; color: #6b7280;
    text-transform: uppercase; letter-spacing: .4px;
}
.tpl-field .field-error {
    display: block; margin-top: 4px; color: #b42318; font-size: 12.5px; font-weight: 500;
}
.tpl-field.has-error input,
.tpl-field.has-error select,
.tpl-field.has-error textarea {
    border-color: #dc2626; background: #fef2f2;
}
.tpl-field.has-error input:focus,
.tpl-field.has-error select:focus,
.tpl-field.has-error textarea:focus {
    box-shadow: 0 0 0 3px rgba(220, 38, 38, .12);
}

/* Inline hint that explains the auto-fill from signer data. */
.tpl-hint { margin: 12px 0 0; padding: 10px 12px; background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 8px; font-size: 13px; color: #1e3a8a; }

/* Step 2: "Usa i dati anagrafici inseriti nel template" toggle. */
.signer-reuse { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; margin: 0 0 14px; background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 8px; cursor: pointer; }
.signer-reuse input[type=checkbox] { margin-top: 3px; width: 16px; height: 16px; }
.signer-reuse span { display: block; }
.signer-reuse strong { color: #1e3a8a; font-size: 13.5px; }
.signer-reuse small { display: block; color: #475569; font-size: 12px; margin-top: 2px; }

/* Sidebar profile chip (compact: link to /profilo + logout) */
.profile-panel.compact { display: grid; gap: 8px; margin-top: auto; }
.profile-link { display: block; padding: 10px 12px; border-radius: 8px; text-decoration: none; color: #fff; background: rgba(255,255,255,.06); }
.profile-link:hover { background: rgba(255,255,255,.12); }
.profile-link > span { display: block; font-size: 11px; color: #98a2b3; letter-spacing: .5px; text-transform: uppercase; font-weight: 700; }
.profile-link strong { display: block; }
.profile-link small { display: block; color: #98a2b3; margin-top: 2px; }

/* Link-style button variants */
.link-btn.danger { color: #b91c1c; }
.link-btn.danger:hover { color: #7f1d1d; }

/* Audit log table layout */
.table-head.audit, .table-row.audit {
    display: grid;
    grid-template-columns: 180px 200px 200px minmax(0, 1fr);
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid #eef2f6;
    align-items: center;
}
.table-head.audit { font-weight: 700; color: #475467; background: #f8fafc; }
.table-row.audit:hover { background: #fafbff; }
.table-row.audit span:last-child { color: #475467; font-size: 13px; }

/* License: days-remaining progress card */
.license-bar-card { margin: 18px 0 22px; padding: 18px; border: 1px solid #e4e7ec; border-radius: 10px; background: #fff; }
.license-bar-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; font-size: 14px; }
.license-bar-head strong { font-size: 20px; color: #0f2557; }
.license-bar-track { height: 12px; border-radius: 999px; background: #eef2f6; overflow: hidden; }
.license-bar-fill { height: 100%; border-radius: 999px; transition: width .3s ease; }
.license-bar-fill.ok { background: linear-gradient(90deg, #10b981, #34d399); }
.license-bar-fill.warn { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.license-bar-fill.danger { background: linear-gradient(90deg, #dc2626, #ef4444); }

/* License history table */
.license-history { margin-top: 18px; }
.table-head.license-hist, .table-row.license-hist {
    display: grid;
    grid-template-columns: 160px 140px minmax(0, 1fr) 120px 110px;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid #eef2f6;
    align-items: center;
}
.table-head.license-hist { font-weight: 700; color: #475467; background: #f8fafc; }
.table-row.license-hist:hover { background: #fafbff; }

.tpl-manage { border: 1px solid #e4e7ec; border-radius: 10px; padding: 12px 14px; background: #fcfcfd; margin-top: 4px; }

/* Tree */
.tpl-tree { list-style: none; margin: 0; padding: 0 0 0 2px; }
.tpl-tree .tpl-tree { padding-left: 16px; border-left: 1px dashed #e4e7ec; margin-left: 8px; }
.tpl-children { }
.tpl-row { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 8px; cursor: pointer; }
.tpl-row:hover { background: #eef4ff; }
.tpl-file.selected { background: #ecfdf5; outline: 1px solid #0f766e; }
.tpl-caret { width: 14px; color: #98a2b3; font-size: 11px; }
.tpl-ic { font-size: 15px; }
.tpl-name { font-size: 14px; color: #182230; }
.tpl-badge { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .4px; color: #0f766e; background: #ecfdf5; border: 1px solid #a7f3d0; padding: 1px 7px; border-radius: 999px; }
.tpl-actions { margin-left: auto; display: inline-flex; gap: 10px; }
.tpl-actions .link-btn { font-size: 12px; }
.link-btn.danger { color: #b42318; }
.tpl-empty { color: #98a2b3; font-size: 13px; padding: 4px 8px; list-style: none; }

/* Admin action bar */
.tpl-actionbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; background: #f3f7ff; border: 1px solid #e1e9fb; border-radius: 10px; margin-bottom: 14px; }
.tpl-target { font-size: 13px; color: #475467; }
.tpl-actionbar-controls { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.upload-inline { position: relative; overflow: hidden; cursor: pointer; }
.upload-inline input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.tpl-hint { margin-top: 14px; font-size: 12.5px; }
.tpl-hint code { background: #f2f4f7; padding: 1px 6px; border-radius: 5px; }

@media (max-width: 860px) {
    .tpl-picker { grid-template-columns: 1fr; }
}

/* ============================================================
   PUBLIC LANDING (page "/") — layout without the app sidebar
   ============================================================ */
.public-shell { display: flex; flex-direction: column; min-height: 100vh; background: #fff; }

.public-nav {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 40px; border-bottom: 1px solid #eef2f6;
    background: rgba(255,255,255,.92); backdrop-filter: saturate(140%) blur(6px);
}
.public-logo img { height: 38px; display: block; }
.public-nav-actions { display: flex; align-items: center; gap: 22px; }
.public-nav-actions a { color: #0f2557; text-decoration: none; font-weight: 600; font-size: 15px; }
.public-login { background: #1d4ed8; color: #fff !important; padding: 9px 20px; border-radius: 999px; }
.public-login:hover { background: #1e40af; }
.public-main { flex: 1 0 auto; }

.public-footer {
    flex-shrink: 0; background: #0f2557; color: #cdd9f0;
    display: flex; justify-content: space-between; gap: 30px; flex-wrap: wrap;
    padding: 36px 40px;
}
.public-footer .pf-left img { height: 34px; margin-bottom: 12px; display: block; }
.public-footer .pf-left p { max-width: 440px; color: #9fb3da; font-size: 14px; line-height: 1.5; margin: 0; }
.public-footer .pf-right { display: flex; flex-direction: column; align-items: flex-end; gap: 12px; }
.public-footer .pf-right > a { color: #cdd9f0; text-decoration: none; font-size: 14px; }
.public-footer .pf-credit { display: inline-flex; align-items: center; gap: 8px; background: #fff; border-radius: 999px; padding: 7px 14px 7px 12px; }
.public-footer .pf-credit span { font-size: 9px; font-weight: 800; letter-spacing: .6px; text-transform: uppercase; color: #64748b; }
.public-footer .pf-credit img { height: 16px; width: auto; }

/* Landing content */
.lp-hero { max-width: 1040px; margin: 0 auto; padding: 72px 40px 36px; text-align: center; }
.lp-eyebrow { text-transform: uppercase; letter-spacing: 2.5px; font-size: 12px; font-weight: 800; color: #2563eb; margin: 0 0 14px; }
.lp-hero h1 { font-size: 46px; line-height: 1.08; letter-spacing: -1px; color: #0f2557; margin: 0 0 18px; }
.lp-hero h1 .hl { color: #2563eb; }
.lp-hero > p { font-size: 19px; color: #475467; max-width: 720px; margin: 0 auto 28px; line-height: 1.5; }
.lp-cta { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.lp-btn { padding: 13px 26px; border-radius: 999px; font-weight: 700; text-decoration: none; font-size: 15px; display: inline-block; }
.lp-btn.primary { background: #1d4ed8; color: #fff; }
.lp-btn.primary:hover { background: #1e40af; }
.lp-btn.ghost { border: 1px solid #cbd5e1; color: #0f2557; }
.lp-btn.ghost:hover { border-color: #1d4ed8; color: #1d4ed8; }
.lp-btn.outline-light { border: 1px solid rgba(255,255,255,.6); color: #fff; }

.lp-section { max-width: 1100px; margin: 0 auto; padding: 36px 40px; }
.lp-kicker { text-align: center; text-transform: uppercase; letter-spacing: 2.5px; font-size: 12px; font-weight: 800; color: #2563eb; margin: 0 0 8px; }
.lp-h2 { text-align: center; font-size: 30px; color: #0f2557; margin: 0 0 30px; letter-spacing: -.5px; }

.lp-modules { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.lp-card { border: 1px solid #e3e8f2; border-radius: 16px; padding: 26px; background: #fff; box-shadow: 0 6px 22px rgba(15,37,87,.05); }
.lp-card .ic { width: 54px; height: 54px; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin-bottom: 16px; }
.lp-card .ic svg { width: 27px; height: 27px; stroke: #fff; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.lp-card.m1 .ic { background: linear-gradient(135deg,#2563eb,#3b82f6); }
.lp-card.m2 .ic { background: linear-gradient(135deg,#0ea5e9,#38bdf8); }
.lp-card.m3 .ic { background: linear-gradient(135deg,#1e40af,#2563eb); }
.lp-card h3 { color: #0f2557; font-size: 19px; margin: 0 0 8px; }
.lp-card p { color: #5b6b86; font-size: 14.5px; line-height: 1.5; margin: 0; }

.lp-why { background: #f3f7ff; border-top: 1px solid #e1e9fb; border-bottom: 1px solid #e1e9fb; }
.lp-why-grid { list-style: none; display: grid; grid-template-columns: 1fr 1fr; gap: 16px 36px; max-width: 1000px; margin: 0 auto; padding: 0; }
.lp-why-grid li { position: relative; padding-left: 34px; color: #243b63; font-size: 15px; line-height: 1.5; }
.lp-why-grid li b { color: #0f2557; }
.lp-why-grid li::before {
    content: ""; position: absolute; left: 0; top: 1px; width: 22px; height: 22px; border-radius: 50%; background: #2563eb;
    -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M5 12l4 4 10-11' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/></svg>") center/62% no-repeat;
    mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M5 12l4 4 10-11' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/></svg>") center/62% no-repeat;
}

.lp-pills { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.lp-pills span { border: 1px solid #d9e2ec; border-radius: 999px; padding: 8px 16px; color: #0f2557; font-weight: 600; font-size: 14px; background: #fff; }

.lp-final { text-align: center; background: linear-gradient(135deg,#13287a,#2563eb); color: #fff; border-radius: 22px; padding: 48px 40px; }
.lp-final h2 { font-size: 30px; margin: 0 0 10px; }
.lp-final p { color: #cfe0ff; margin: 0 0 24px; font-size: 16px; }
.lp-final .lp-btn.primary { background: #fff; color: #1d4ed8; }

/* --- Landing — extra sales sections --- */
.lp-hero-foot { margin-top: 18px; font-size: 13px; color: #64748b; }
.lp-trust { background: #0f2557; padding: 22px 20px; }
.lp-trust-grid {
    max-width: 1100px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 18px;
}
.lp-trust-grid > div { text-align: center; color: #cfe0ff; }
.lp-trust-grid strong { display: block; font-size: 18px; color: #fff; letter-spacing: .5px; }
.lp-trust-grid span { font-size: 12px; opacity: .85; }

.lp-modules-4 { grid-template-columns: repeat(4, 1fr); gap: 16px; }
.lp-modules-4 .lp-card { padding: 22px; position: relative; }
.lp-card.m4 .ic { background: linear-gradient(135deg,#0891b2,#06b6d4); }
.lp-card-badge {
    display: inline-block;
    margin-top: 12px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #dbeafe;
    text-transform: uppercase;
    letter-spacing: .3px;
}

.lp-value { background: #f3f7ff; border-top: 1px solid #e1e9fb; border-bottom: 1px solid #e1e9fb; }
.lp-value-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    max-width: 1100px;
    margin: 0 auto;
}
.lp-value-grid article {
    background: #fff;
    border: 1px solid #e3e8f2;
    border-radius: 14px;
    padding: 22px;
    box-shadow: 0 6px 18px rgba(15,37,87,.04);
}
.lp-value-ic { font-size: 30px; margin-bottom: 10px; }
.lp-value-grid h3 { color: #0f2557; font-size: 18px; margin: 0 0 12px; }
.lp-value-grid ul { margin: 0; padding-left: 18px; color: #3b4d6b; font-size: 14px; line-height: 1.6; }
.lp-value-grid ul li { margin-bottom: 4px; }
.lp-value-grid code { background: #eef4ff; color: #1d4ed8; padding: 1px 6px; border-radius: 4px; font-size: 12.5px; }

.lp-steps {
    list-style: none;
    counter-reset: lp;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}
.lp-steps li {
    background: #fff;
    border: 1px solid #e3e8f2;
    border-radius: 14px;
    padding: 22px;
    position: relative;
    box-shadow: 0 4px 14px rgba(15,37,87,.04);
}
.lp-step-num {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg,#1d4ed8,#3b82f6);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 16px;
    margin-bottom: 14px;
}
.lp-steps h4 { color: #0f2557; font-size: 16px; margin: 0 0 6px; }
.lp-steps p { color: #5b6b86; font-size: 13.5px; line-height: 1.5; margin: 0; }

.lp-pricing { background: linear-gradient(135deg,#0f2557,#1d4ed8); margin-top: 12px; }
.lp-pricing .lp-kicker { color: #93c5fd; }
.lp-pricing-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
    max-width: 1100px;
    margin: 0 auto;
}
.lp-price-card {
    background: rgba(255,255,255,.07);
    border: 1px solid rgba(255,255,255,.15);
    border-radius: 16px;
    padding: 26px 22px;
    color: #fff;
    position: relative;
    backdrop-filter: blur(4px);
}
.lp-price-card.featured {
    background: #fff;
    color: #0f2557;
    transform: translateY(-6px);
    box-shadow: 0 20px 40px rgba(0,0,0,.18);
}
.lp-price-card.featured h3, .lp-price-card.featured .lp-price-figure { color: #0f2557; }
.lp-price-card.featured ul { color: #3b4d6b; }
.lp-price-card h3 { color: #fff; margin: 0 0 6px; font-size: 19px; }
.lp-price-figure { font-size: 24px; font-weight: 800; margin: 0 0 16px; color: #93c5fd; }
.lp-price-card ul { margin: 0; padding-left: 18px; font-size: 14px; line-height: 1.6; color: #dbeafe; }
.lp-price-tag {
    position: absolute;
    top: -12px;
    right: 18px;
    background: #16a34a;
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    padding: 4px 10px;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: .4px;
}
.lp-pricing-foot {
    text-align: center;
    color: #cfe0ff;
    margin: 20px 0 0;
    font-size: 13.5px;
}

@media (max-width: 1024px) {
    .lp-modules-4 { grid-template-columns: repeat(2, 1fr); }
    .lp-steps { grid-template-columns: repeat(2, 1fr); }
    .lp-value-grid { grid-template-columns: repeat(2, 1fr); }
    .lp-pricing-grid { grid-template-columns: 1fr; }
    .lp-price-card.featured { transform: none; }
    .lp-trust-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 860px) {
    .public-nav { padding: 12px 20px; }
    .public-nav-actions { gap: 14px; }
    .lp-hero h1 { font-size: 32px; }
    .lp-hero { padding: 48px 22px 28px; }
    .lp-section { padding: 28px 22px; }
    .lp-modules, .lp-modules-4 { grid-template-columns: 1fr; }
    .lp-why-grid { grid-template-columns: 1fr; }
    .lp-value-grid, .lp-steps { grid-template-columns: 1fr; }
    .lp-trust-grid { grid-template-columns: repeat(2, 1fr); }
    .public-footer { flex-direction: column; }
    .public-footer .pf-right { align-items: flex-start; }
}

/* ============================================================
   SUPER-ADMIN — License dashboard (vista globale)
   ============================================================ */
.superadmin-topbar { display: flex; align-items: center; }
.superadmin-nav { margin-left: auto; display: flex; gap: 6px; }
.superadmin-nav a {
    color: #cbd5e1; text-decoration: none;
    padding: 6px 12px; border-radius: 8px;
    font-size: 14px; font-weight: 500;
}
.superadmin-nav a:hover { background: #1f2937; color: #fff; }
.superadmin-nav a.active { background: #2563eb; color: #fff; }
.header-actions { display: flex; gap: 8px; }

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}
.kpi-card {
    background: #fff;
    border-radius: 12px;
    padding: 16px 18px;
    display: flex; flex-direction: column; gap: 4px;
    border-left: 4px solid #cbd5e1;
}
.kpi-card.ok     { border-left-color: #10b981; }
.kpi-card.warn   { border-left-color: #f59e0b; }
.kpi-card.danger { border-left-color: #dc2626; }
.kpi-label { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: #64748b; }
.kpi-value { font-size: 26px; color: #0f2557; line-height: 1.1; }

.month-chart {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 6px;
    align-items: end;
    height: 160px;
    padding: 8px 4px 0;
}
.month-col { display: flex; flex-direction: column; align-items: center; height: 100%; }
.month-bar {
    width: 100%;
    min-height: 4px;
    background: linear-gradient(180deg, #3b82f6, #1d4ed8);
    border-radius: 6px 6px 0 0;
    position: relative;
    margin-top: auto;
    display: flex; align-items: flex-start; justify-content: center;
}
.month-count {
    position: absolute; top: -16px;
    font-size: 11px; font-weight: 700; color: #1d4ed8;
}
.month-label { font-size: 10.5px; color: #64748b; margin-top: 4px; text-transform: uppercase; }

.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; }
.filter-bar input, .filter-bar select {
    padding: 6px 10px; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 13px;
}

.table-head.license-board, .table-row.license-board {
    display: grid;
    grid-template-columns: minmax(160px, 1.4fr) 110px 100px 70px 110px minmax(120px, 1fr) 140px 90px;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid #eef2f6;
    align-items: center;
    font-size: 13.5px;
}
.table-head.license-board { font-weight: 700; color: #475467; background: #f8fafc; }
.table-row.license-board:hover { background: #fafbff; }
.table-row.license-board code { background: #f1f5f9; padding: 0 5px; border-radius: 4px; font-size: 11px; }

.secondary-btn.small { padding: 4px 10px; font-size: 12.5px; }
.section-heading .small { font-size: 12px; }

.status-pill.warn  { background: #fef3c7; color: #92400e; }
.status-pill.danger { background: #fee2e2; color: #991b1b; }

@media (max-width: 1100px) {
    .table-head.license-board, .table-row.license-board {
        grid-template-columns: 1.2fr 90px 90px 60px 90px 1fr 120px 80px;
        font-size: 12.5px;
    }
}

/* --- 2FA setup --- */
.totp-input {
    font-family: ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;
    letter-spacing: 4px;
    font-size: 22px;
    text-align: center;
    width: 100%;
    max-width: 200px;
}
.totp-setup {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 20px;
    align-items: start;
    margin-top: 8px;
}
.totp-qr {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8fafc;
    border: 1px solid #e4e7ec;
    border-radius: 12px;
    padding: 10px;
    min-height: 220px;
}
.totp-qr img { max-width: 220px; height: auto; }
.totp-meta label { display: block; font-weight: 600; margin-bottom: 6px; color: #475467; }
.totp-secret {
    display: block;
    font-family: ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;
    font-size: 16px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 10px 12px;
    word-break: break-all;
    letter-spacing: 1px;
}
@media (max-width: 700px) {
    .totp-setup { grid-template-columns: 1fr; }
    .totp-qr { min-height: auto; }
}

/* --- Login history table --- */
.table-head.login-hist, .table-row.login-hist {
    display: grid;
    grid-template-columns: 180px 160px 140px 130px minmax(0, 1fr);
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid #eef2f6;
    align-items: center;
    font-size: 13.5px;
}
.table-head.login-hist { font-weight: 700; color: #475467; background: #f8fafc; }
.table-row.login-hist:hover { background: #fafbff; }
.table-row.login-hist .ua { color: #64748b; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table-row.login-hist .mono { font-family: ui-monospace, "Cascadia Code", Menlo, Consolas, monospace; font-size: 12.5px; color: #475467; }

.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: flex-end;
    margin-bottom: 14px;
}
.filter-row > div { display: flex; flex-direction: column; }
.filter-row label { font-weight: 600; color: #475467; font-size: 12px; margin-bottom: 4px; }
.filter-row .filter-actions { display: flex; gap: 8px; margin-left: auto; }

.ghost-btn.danger { color: #b91c1c; border-color: #fecaca; }
.ghost-btn.danger:hover:not(:disabled) { background: #fef2f2; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; letter-spacing: .2px; }
.badge.ok { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.badge.neutral { background: #f1f5f9; color: #475467; border: 1px solid #e2e8f0; }
.badge.danger { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }

/* --- Super-admin tenant users panel --- */
.users-list { display: flex; flex-direction: column; gap: 8px; margin: 6px 0 12px; }
.user-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
    border: 1px solid #e4e7ec;
    border-radius: 8px;
    padding: 10px 12px;
    background: #fff;
}
.user-row .user-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.user-row .user-meta strong { font-size: 14px; color: #101828; }
.user-row .user-meta .muted { font-size: 13px; }
.user-row > button { align-self: flex-start; }
.user-reset {
    display: flex;
    flex-direction: column;
    gap: 6px;
    border-top: 1px dashed #e4e7ec;
    padding-top: 8px;
}
.user-reset label { font-weight: 600; font-size: 12.5px; color: #475467; }
.user-reset label.inline { display: flex; align-items: center; gap: 6px; font-weight: 500; }
.user-reset label.inline input[type="checkbox"] { margin: 0; }
.user-reset input[type="text"] { font-family: ui-monospace, "Cascadia Code", Menlo, Consolas, monospace; max-width: 320px; }

/* ============================================================
   VOLANTINO A4 — single-page flyer, print-ready
   ============================================================ */
.flyer-toolbar {
    max-width: 1100px;
    margin: 20px auto 12px;
    padding: 14px 22px;
    display: flex;
    gap: 12px;
    align-items: center;
    background: #f3f7ff;
    border: 1px solid #dbeafe;
    border-radius: 12px;
}
.flyer-toolbar-title { flex: 1; color: #1e40af; font-weight: 600; font-size: 14px; }

/* A4: 210 × 297 mm. Width fixed in mm, height grows but stays one page on print. */
.flyer-page {
    width: 210mm;
    min-height: 297mm;
    margin: 0 auto 40px;
    padding: 14mm 14mm 12mm;
    background: #fff;
    color: #0f2557;
    box-shadow: 0 14px 40px rgba(15,37,87,.12);
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    line-height: 1.4;
    display: flex;
    flex-direction: column;
    gap: 5mm;
}

/* HEADER */
.fly-head { display: flex; justify-content: space-between; align-items: center; border-bottom: 3px solid #1d4ed8; padding-bottom: 4mm; }
.fly-brand { display: flex; align-items: center; gap: 10px; }
.fly-brand img { height: 38px; }
.fly-brand h1 { margin: 0; font-size: 26px; color: #0f2557; letter-spacing: -.5px; }
.fly-tag { margin: 0; font-size: 11px; color: #2563eb; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; }
.fly-head-right { text-align: right; }
.fly-claim { margin: 0; font-size: 13.5px; color: #475467; line-height: 1.3; }
.fly-claim strong { color: #1d4ed8; }

/* HERO */
.fly-hero { text-align: center; padding: 2mm 0; }
.fly-hero h2 { margin: 0 0 4px; font-size: 19px; color: #0f2557; line-height: 1.25; font-weight: 700; }
.fly-hero h2 span { color: #2563eb; }
.fly-hero p { margin: 0; color: #475467; font-size: 11.5px; }

/* 4 MODULI */
.fly-modules {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 4mm;
}
.fly-modules article {
    border: 1px solid #dbeafe;
    border-radius: 8px;
    padding: 4mm;
    background: #f8faff;
}
.fly-mod-ic {
    width: 34px; height: 34px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 17px;
    margin-bottom: 3mm;
    background: linear-gradient(135deg, #2563eb, #3b82f6);
    color: #fff;
}
.fly-mod-ic.mod-anon { background: linear-gradient(135deg, #0ea5e9, #38bdf8); }
.fly-mod-ic.mod-time { background: linear-gradient(135deg, #0891b2, #06b6d4); }
.fly-mod-ic.mod-pdf { background: linear-gradient(135deg, #1e40af, #2563eb); }
.fly-mod-ic.mod-otp { background: linear-gradient(135deg, #059669, #10b981); }
.fly-modules h3 { margin: 0 0 2mm; font-size: 13px; color: #0f2557; }
.fly-modules ul { margin: 0; padding-left: 4mm; font-size: 10.5px; color: #3b4d6b; line-height: 1.45; }
.fly-modules ul li { margin-bottom: 1px; }

/* VALUE PROP */
.fly-value {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 3mm;
    background: #eff6ff;
    border-radius: 8px;
    padding: 4mm;
}
.fly-value h4 { margin: 0 0 2mm; font-size: 11px; color: #1d4ed8; font-weight: 700; }
.fly-value p { margin: 0; font-size: 10px; color: #3b4d6b; line-height: 1.4; }

/* WORKFLOW + SETTORI */
.fly-bottom {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4mm;
}
.fly-workflow, .fly-sectors {
    border: 1px solid #dbeafe;
    border-radius: 8px;
    padding: 4mm;
}
.fly-workflow h4, .fly-sectors h4 {
    margin: 0 0 2mm;
    font-size: 12px;
    color: #1d4ed8;
    text-transform: uppercase;
    letter-spacing: .5px;
}
.fly-workflow ol { margin: 0; padding-left: 5mm; font-size: 10.5px; color: #3b4d6b; line-height: 1.55; }
.fly-workflow ol b { color: #0f2557; }
.fly-sectors p { margin: 0; font-size: 10.5px; color: #3b4d6b; line-height: 1.55; }

/* CTA */
.fly-cta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4mm;
    background: linear-gradient(135deg, #1d4ed8, #2563eb);
    color: #fff;
    border-radius: 8px;
    padding: 4mm 5mm;
    margin-top: auto;
}
.fly-cta-block h3 { margin: 0 0 1mm; font-size: 14px; color: #fff; }
.fly-cta-block p { margin: 0; font-size: 11px; color: #cfe0ff; }
.fly-cta-contact { text-align: right; }
.fly-cta-contact p { margin: 0 0 1mm; font-size: 12px; color: #fff; }
.fly-cta-contact strong { color: #fff; }
.fly-cta-by { font-size: 9.5px !important; color: #93c5fd !important; margin-top: 2mm !important; opacity: .9; }

/* PRINT */
@media print {
    body, html { background: #fff; }
    .no-print, .public-nav, .public-footer { display: none !important; }
    .flyer-page {
        margin: 0;
        box-shadow: none;
        width: auto;
        min-height: auto;
        padding: 12mm;
    }
    @page { size: A4; margin: 0; }
}


/* ===== Importa audio chiamata (contratti a distanza) ===== */
.remember-device {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #334155;
    margin: 6px 0 4px;
    cursor: pointer;
}
.remember-device input { width: 16px; height: 16px; }

.audio-import .audio-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}
@media (max-width: 820px) {
    .audio-import .audio-grid { grid-template-columns: 1fr; }
}
.audio-import .pratica-list {
    margin-top: 10px;
    max-height: 320px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.audio-import .pratica-row {
    text-align: left;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.audio-import .pratica-row:hover { border-color: #93c5fd; }
.audio-import .pratica-row.selected { border-color: #1e40af; background: #eff6ff; }
.audio-import .pratica-row strong { font-size: 14px; color: #0f172a; }
.audio-import .pratica-row small { color: #64748b; font-size: 12px; }
/* I nomi file lunghi devono andare a capo, non sforare la larghezza (soprattutto su mobile). */
.audio-import .pratica-row strong,
.audio-import .pratica-row small { overflow-wrap: anywhere; word-break: break-word; min-width: 0; }
.audio-import .practice-summary dd { overflow-wrap: anywhere; word-break: break-word; }
.audio-import { overflow-x: hidden; }
.audio-import .wizard-card { min-width: 0; max-width: 100%; }
.audio-import .hash-box {
    display: block;
    word-break: break-all;
    background: #0f172a;
    color: #e2e8f0;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 12px;
    margin: 4px 0 12px;
}

/* Allegato audio facoltativo nel wizard di firma */
.audio-attach { margin: 14px 0; padding-top: 12px; border-top: 1px dashed #e2e8f0; }
.audio-attach > label { display:block; font-weight:600; color:#334155; margin-bottom:6px; }

/* Landing: modulo in evidenza "Audio chiamate" */
.lp-newmodule {
    margin-top: 22px;
    display: flex;
    gap: 20px;
    align-items: flex-start;
    background: linear-gradient(135deg, #eff6ff, #e0e7ff);
    border: 1px solid #c7d2fe;
    border-radius: 18px;
    padding: 24px 26px;
}
.lp-newmodule-ic {
    flex: 0 0 auto;
    width: 56px; height: 56px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 28px;
    background: linear-gradient(135deg, #4f46e5, #2563eb);
}
.lp-newmodule h3 { margin: 8px 0 6px; font-size: 20px; color: #0f2557; }
.lp-newmodule p { margin: 0; color: #3b4d6b; line-height: 1.55; }
@media (max-width: 640px) { .lp-newmodule { flex-direction: column; gap: 12px; } }

/* Volantino A4: riquadro compatto "Audio chiamate" */
.fly-newmod {
    margin: 3mm 0 0;
    display: flex;
    gap: 3mm;
    align-items: center;
    background: linear-gradient(135deg, #eef4ff, #e0e7ff);
    border: 1px solid #c7d2fe;
    border-radius: 3mm;
    padding: 2.6mm 3.5mm;
}
.fly-newmod-ic { font-size: 16px; flex: 0 0 auto; }
.fly-newmod p { margin: 0; font-size: 9.5px; line-height: 1.4; color: #243; }

/* Elenco audio collegato a una pratica (riascolto/scarico) */
.pratica-audio { margin-top: 6px; width: 100%; }
.pratica-audio .link-btn { font-size: 13px; color: #1e40af; }
.pratica-audio .link-btn.danger { color: #b91c1c; }
.pratica-audio .audio-row {
    margin: 8px 0;
    padding: 8px 10px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
}
.pratica-audio .audio-row-head { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.pratica-audio .audio-row-head strong { font-size: 13px; color: #0f172a; }
.pratica-audio .audio-row-head small { color: #64748b; font-size: 12px; }
.pratica-audio .audio-row audio { width: 100%; margin: 6px 0; height: 34px; }
.pratica-audio .audio-row-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.pratica-audio .audio-row-actions code { font-size: 11px; color: #475569; background: #eef2f6; padding: 1px 6px; border-radius: 5px; }

/* Chip "Audio chiamata" (mostrato solo quando esistono registrazioni) */
.pratica-audio .audio-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    color: #3730a3;
    border-radius: 999px;
    padding: 3px 10px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}
.pratica-audio .audio-chip:hover { background: #e0e7ff; }
.pratica-audio .audio-chip.open { background: #e0e7ff; border-color: #a5b4fc; }
.pratica-audio .audio-chip-ic { font-size: 13px; line-height: 1; }
.pratica-audio .audio-chip-caret { font-size: 10px; opacity: .7; }

/* Firma OTP — riusa lo stile delle righe audio con chip verde */
.pratica-otp { margin-top: 6px; width: 100%; }
.pratica-otp .link-btn { font-size: 13px; color: #1e40af; background: none; border: 0; cursor: pointer; padding: 0; }
.pratica-otp .audio-row { margin: 8px 0; padding: 8px 10px; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px; }
.pratica-otp .audio-row-head { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.pratica-otp .audio-row-head strong { font-size: 13px; color: #0f172a; }
.pratica-otp .audio-row-head small { color: #64748b; font-size: 12px; }
.pratica-otp .audio-row-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.pratica-otp .audio-row-actions code { font-size: 11px; color: #475569; background: #eef2f6; padding: 1px 6px; border-radius: 5px; }
.pratica-otp .audio-chip {
    display: inline-flex; align-items: center; gap: 6px;
    background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46;
    border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 600; cursor: pointer;
}
.pratica-otp .audio-chip:hover { background: #d1fae5; }
.pratica-otp .audio-chip.open { background: #d1fae5; border-color: #6ee7b7; }
.pratica-otp .audio-chip-ic { font-size: 13px; line-height: 1; }
.pratica-otp .audio-chip-caret { font-size: 10px; opacity: .7; }
.otp-badge { font-size: 11px; font-weight: 700; border-radius: 999px; padding: 2px 9px; }
.otp-badge.ok { background: #dcfce7; color: #166534; }
.otp-badge.err { background: #fee2e2; color: #991b1b; }
.otp-badge.wait { background: #fef9c3; color: #854d0e; }
.otp-new { margin-top: 10px; padding: 10px; border: 1px dashed #cbd5e1; border-radius: 8px; background: #fff; }
.otp-new-title { font-size: 13px; font-weight: 700; color: #0f172a; margin: 0 0 8px; }
.otp-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
.otp-grid label { display: flex; flex-direction: column; font-size: 12px; color: #475569; gap: 3px; }
.otp-grid input { padding: 6px 8px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 13px; }
.otp-new .btn { margin-top: 8px; }
.otp-credit { font-size: 12.5px; color: #334155; background: #f1f5f9; border: 1px solid #e2e8f0; border-radius: 6px; padding: 4px 10px; display: inline-block; margin: 4px 0; }
.otp-credit strong { color: #065f46; }

/* Scelta modalità nel flusso contratto a distanza */
.mode-choice { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.mode-option {
    text-align: left; display: flex; flex-direction: column; gap: 4px;
    padding: 14px 16px; border: 2px solid #e2e8f0; border-radius: 12px; background: #fff; cursor: pointer;
    transition: border-color .15s, background .15s;
}
.mode-option:hover { border-color: #cbd5e1; }
.mode-option.active { border-color: #10b981; background: #ecfdf5; }
.mode-option strong { font-size: 15px; color: #0f172a; }
.mode-option span { font-size: 12.5px; color: #64748b; }
.mode-option:disabled { opacity: .6; cursor: default; }

/* ---- Archivio contratti a distanza ---- */
.remote-contract-archive .filters-card { margin-bottom: 16px; }
.remote-contract-archive .filters-card .form-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    align-items: end;
}
.remote-contract-archive .filter-search { grid-column: span 2; }
.remote-contract-archive .filters-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    gap: 10px;
}
.remote-contract-archive .filters-footer > div { display: flex; gap: 8px; align-items: center; }

.fascicolo-row {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas: "main actions" "audio audio";
    gap: 10px 16px;
    margin-bottom: 12px;
}
.fascicolo-main { grid-area: main; }
.fascicolo-actions {
    grid-area: actions;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: stretch;
}
.fascicolo-audio { grid-area: audio; }
.fascicolo-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.fascicolo-head strong { overflow-wrap: anywhere; }
.fascicolo-meta {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin: 10px 0 0;
}
.fascicolo-meta div { padding: 8px 10px; border-radius: 8px; background: #f8fafc; }
.fascicolo-meta dt { color: #667085; font-size: 10px; font-weight: 900; text-transform: uppercase; }
.fascicolo-meta dd { margin: 3px 0 0; font-size: 13px; overflow-wrap: anywhere; }

@media (max-width: 900px) {
    .remote-contract-archive .filters-card .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .remote-contract-archive .filter-search { grid-column: span 2; }
    .fascicolo-row { grid-template-columns: 1fr; grid-template-areas: "main" "actions" "audio"; }
    .fascicolo-actions { flex-direction: row; flex-wrap: wrap; }
    .fascicolo-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---- Toolbar archivio riusabile (ArchiveControls) ---- */
.archive-controls { margin-bottom: 16px; }
.archive-controls .archive-controls-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px 14px;
    align-items: end;
}
.archive-controls .ac-search { grid-column: span 2; }
.archive-controls .archive-controls-grid > div > label {
    display: block;
    font-size: 11px;
    font-weight: 800;
    color: #667085;
    text-transform: uppercase;
    letter-spacing: .02em;
    margin-bottom: 4px;
}
.archive-controls .archive-controls-grid .input,
.archive-controls .archive-controls-grid select.input { width: 100%; }
.archive-controls-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
    flex-wrap: wrap;
}
.archive-controls-footer .ac-actions { display: flex; gap: 8px; align-items: center; }

/* ---- Lista documenti scalabile a schede (doc-list / doc-card) ---- */
.doc-list {
    max-height: 65vh;
    overflow-y: auto;
    padding-right: 4px;
}
.doc-card {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 14px;
    padding: 12px 14px;
    border: 1px solid #eef0f3;
    border-radius: 10px;
    background: #fff;
    margin-bottom: 8px;
}
.doc-card:hover { border-color: #d7dbe2; box-shadow: 0 1px 4px rgba(16, 24, 40, .05); }
.doc-card-main { min-width: 0; flex: 1; }
.doc-card-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.doc-card-head strong { overflow-wrap: anywhere; }
.doc-card-sub { color: #667085; font-size: 12px; margin-top: 4px; display: flex; gap: 6px; flex-wrap: wrap; }
.doc-card-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.doc-tag {
    font-size: 11px;
    font-weight: 700;
    color: #3730a3;
    background: #eef2ff;
    border: 1px solid #e0e7ff;
    border-radius: 999px;
    padding: 2px 8px;
}

@media (max-width: 700px) {
    .archive-controls .ac-search { grid-column: span 2; }
    .doc-card { flex-direction: column; }
    .doc-card-actions { justify-content: flex-start; }
    .doc-list { max-height: none; }
}

/* ============================================================
   Fix overflow "Firma allo sportello" su mobile (in coda: vince
   sulle varianti definite prima, es. .no-preview a 2 colonne)
   ============================================================ */
@media (max-width: 860px) {
    .signing-shell,
    .signing-shell.no-preview,
    .signing-shell.wide-preview {
        grid-template-columns: 1fr;
    }
    .signing-shell.no-preview .preview-panel { display: none; }

    .pdf-preview, .empty-preview { width: 100%; max-width: 100%; }
    .placement-surface { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .placement-toolbar { flex-wrap: wrap; }
    .placement-toolbar select { max-width: 100%; }

    code, .hash-box, .compact-document code {
        overflow-wrap: anywhere;
        word-break: break-word;
    }
}

/* Paginazione elenco documenti */
.pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-top: 16px;
    flex-wrap: wrap;
}
.pager-info { color: #64748b; font-size: 13px; }
