/* Welkey — componenti comuni: pulsanti, campi, schede, avvisi, menu, finestre, pannello aiuto. */

/* ---------- Marchio ---------- */

/* Logo: partials/logo.html (chiave con l'anello a O + scritta in tracciati) */
.wk-logo {
    display: inline-flex;
    align-items: center;
    color: var(--wk-ink);
    text-decoration: none;
}

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

.wk-logo__svg {
    display: block;
    height: 28px;
    width: auto;
}

.wk-logo__key {
    fill: none;
    stroke: var(--wk-brand);
    stroke-width: 3.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.wk-logo__dot {
    fill: var(--wk-accent);
}

.wk-logo__word {
    fill: currentColor;
}

/* ---------- Pulsanti ---------- */

.wk-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--wk-space-2);
    min-height: var(--wk-control-height);
    padding: 0 var(--wk-space-4);
    border: 1px solid transparent;
    border-radius: var(--wk-radius);
    font: inherit;
    font-weight: 600;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
    background: var(--wk-surface);
    color: var(--wk-ink);
    border-color: var(--wk-border-strong);
    transition: background-color 120ms ease, border-color 120ms ease;
}

.wk-btn:hover {
    background: var(--wk-surface-2);
    color: var(--wk-ink);
}

.wk-btn--primary {
    background: var(--wk-brand);
    border-color: var(--wk-brand);
    color: var(--wk-ink-inverse);
}

.wk-btn--primary:hover {
    background: var(--wk-brand-hover);
    border-color: var(--wk-brand-hover);
    color: var(--wk-ink-inverse);
}

.wk-btn--danger {
    color: var(--wk-danger);
    border-color: var(--wk-danger);
}

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

.wk-btn--ghost {
    background: transparent;
    border-color: transparent;
}

.wk-btn--block {
    width: 100%;
}

.wk-btn--sm {
    min-height: 30px;
    padding: 0 var(--wk-space-3);
    font-size: var(--wk-text-sm);
}

.wk-btn[disabled] {
    opacity: 0.55;
    cursor: not-allowed;
}

/* Solo icona: serve sempre aria-label con il testo tradotto */
.wk-btn--icon {
    width: var(--wk-control-height);
    padding: 0;
}

.wk-btn--icon.wk-btn--sm {
    width: 30px;
}

/* Operazione in corso: il testo resta (per la larghezza) ma non si vede; niente doppi clic */
.wk-btn[aria-busy="true"] {
    position: relative;
    color: transparent;
    pointer-events: none;
}

.wk-btn[aria-busy="true"]::after {
    content: "";
    position: absolute;
    width: 14px;
    height: 14px;
    border: 2px solid var(--wk-ink-muted);
    border-right-color: transparent;
    border-radius: 50%;
    animation: wk-spin 700ms linear infinite;
}

.wk-btn--primary[aria-busy="true"]::after {
    border-color: var(--wk-ink-inverse);
    border-right-color: transparent;
}

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

/* ---------- Icone (sprite assets/img/icons.svg, partial partials/icons.html) ---------- */

.wk-icon {
    width: 16px;
    height: 16px;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    vertical-align: -3px;
}

.wk-link-btn {
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    color: var(--wk-brand);
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
}

/* ---------- Campi ---------- */

.wk-field {
    display: grid;
    align-content: start; /* in una griglia con campi più alti accanto, etichetta e campo restano in alto */
    gap: var(--wk-space-1);
    margin-bottom: var(--wk-space-3);
}

.wk-field label {
    font-weight: 600;
    font-size: var(--wk-text-sm);
}

.wk-field__hint {
    font-size: var(--wk-text-xs);
    color: var(--wk-ink-muted);
}

.wk-input,
.wk-select,
.wk-textarea {
    width: 100%;
    padding: 0 var(--wk-space-3);
    border: 1px solid var(--wk-border-strong);
    border-radius: var(--wk-radius);
    background: var(--wk-surface);
    color: var(--wk-ink);
    font: inherit;
    line-height: 1.4;
}

/* Campi su una riga: tutti alti uguali (testo, numeri, date, menu), qualunque sia il tipo o il browser */
.wk-input,
.wk-select {
    height: var(--wk-control-height);
}

.wk-input[type="file"] {
    height: auto;
    padding: var(--wk-space-1) var(--wk-space-2);
}

.wk-textarea {
    min-height: 64px;
    padding: var(--wk-space-2) var(--wk-space-3);
    resize: vertical;
}

.wk-input:focus,
.wk-select:focus,
.wk-textarea:focus {
    border-color: var(--wk-brand);
    outline: 2px solid var(--wk-brand-soft);
    outline-offset: 0;
}

/* Codici da digitare (2FA, codici di backup): grandi e spaziati */
.wk-input--code {
    height: auto;
    min-height: 44px;
    font-family: var(--wk-font-mono);
    font-size: var(--wk-text-xl);
    letter-spacing: 0.3em;
    text-align: center;
}

/* Valori tecnici (chiavi, prefissi, valute, IBAN): carattere a larghezza fissa, stessa altezza degli altri campi */
.wk-input--mono {
    font-family: var(--wk-font-mono);
    font-size: var(--wk-text-sm);
}

/* Freccia del select disegnata con le variabili (niente immagini, niente colori fissi) */
.wk-select {
    appearance: none;
    padding-right: var(--wk-space-6);
    background-image:
        linear-gradient(45deg, transparent 50%, var(--wk-ink-muted) 50%),
        linear-gradient(135deg, var(--wk-ink-muted) 50%, transparent 50%);
    background-position: calc(100% - 17px) 55%, calc(100% - 12px) 55%;
    background-size: 5px 5px;
    background-repeat: no-repeat;
    cursor: pointer;
}

.wk-input:disabled,
.wk-select:disabled,
.wk-textarea:disabled {
    background-color: var(--wk-surface-2);
    color: var(--wk-ink-muted);
    cursor: not-allowed;
}

/* Errore: aria-invalid="true" sul campo + aria-describedby verso il messaggio */
.wk-input[aria-invalid="true"],
.wk-select[aria-invalid="true"],
.wk-textarea[aria-invalid="true"] {
    border-color: var(--wk-danger);
}

.wk-input[aria-invalid="true"]:focus,
.wk-select[aria-invalid="true"]:focus,
.wk-textarea[aria-invalid="true"]:focus {
    outline-color: var(--wk-danger-soft);
}

.wk-field__error {
    display: flex;
    align-items: center;
    gap: var(--wk-space-1);
    font-size: var(--wk-text-xs);
    font-weight: 600;
    color: var(--wk-danger);
}

/* Checkbox e radio: controllo nativo nel colore del marchio */
.wk-check {
    display: inline-flex;
    align-items: center;
    gap: var(--wk-space-2);
    min-height: 28px;
    cursor: pointer;
}

.wk-check input {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--wk-brand);
    cursor: pointer;
}

/* Interruttore: <label class="wk-switch"><input type="checkbox" role="switch"> testo</label> */
.wk-switch {
    display: inline-flex;
    align-items: center;
    gap: var(--wk-space-2);
    min-height: 28px;
    cursor: pointer;
}

.wk-switch input {
    appearance: none;
    position: relative;
    flex: none;
    width: 40px;
    height: 22px;
    margin: 0;
    border: 1px solid var(--wk-border-strong);
    border-radius: 999px;
    background: var(--wk-surface-2);
    cursor: pointer;
    transition: background-color 120ms ease, border-color 120ms ease;
}

/* Spento: pallino grigio a sinistra su fondo chiaro. Acceso: fondo verde pieno, pallino bianco a destra.
   Colori ben diversi (decisione del 20/10/2026): non si deve indovinare da che parte è il pallino. */
.wk-switch input::before {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--wk-ink-muted);
    transition: transform 120ms ease, background-color 120ms ease;
}

.wk-switch input:checked {
    border-color: var(--wk-success);
    background: var(--wk-success);
}

.wk-switch input:checked::before {
    background: #ffffff;
    transform: translateX(18px);
}

.wk-switch input:focus-visible {
    outline: 2px solid var(--wk-focus);
    outline-offset: 2px;
}

.wk-switch input:disabled,
.wk-check input:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.wk-choices {
    display: grid;
    gap: var(--wk-space-1);
    margin: 0;
    padding: 0;
    border: 0;
}

.wk-choices legend {
    margin-bottom: var(--wk-space-1);
    font-weight: 600;
    font-size: var(--wk-text-sm);
}

/* Dentro un .wk-field le etichette sono in grassetto: le scelte no */
.wk-field label.wk-check,
.wk-field label.wk-switch {
    font-weight: 400;
    font-size: inherit;
}

.wk-form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--wk-space-2);
    align-items: center;
    margin-top: var(--wk-space-4);
}

/* ---------- Schede ---------- */

.wk-card {
    background: var(--wk-surface);
    border: 1px solid var(--wk-border);
    border-radius: var(--wk-radius-lg);
    padding: var(--wk-space-5);
    box-shadow: var(--wk-shadow);
}

.wk-card + .wk-card {
    margin-top: var(--wk-space-4);
}

.wk-card__title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--wk-space-3);
    margin-bottom: var(--wk-space-3);
    font-size: var(--wk-text-lg);
}

.wk-card--compact {
    padding: var(--wk-space-4);
}

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

.wk-alert {
    padding: var(--wk-space-3) var(--wk-space-4);
    border-radius: var(--wk-radius);
    border-left: 4px solid var(--wk-border-strong);
    background: var(--wk-surface-2);
    margin-bottom: var(--wk-space-4);
}

.wk-alert--success { border-color: var(--wk-success); background: var(--wk-success-soft); }
.wk-alert--warning { border-color: var(--wk-warning); background: var(--wk-warning-soft); }
.wk-alert--error   { border-color: var(--wk-danger);  background: var(--wk-danger-soft); }
.wk-alert--info    { border-color: var(--wk-info);    background: var(--wk-info-soft); }

.wk-alert ul {
    margin: 0;
    padding-left: var(--wk-space-4);
}

/* ---------- Etichette ---------- */

.wk-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px var(--wk-space-2);
    border-radius: 999px;
    font-size: var(--wk-text-xs);
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
    background: var(--wk-surface-2);
    border: 1px solid var(--wk-border);
    color: var(--wk-ink-muted);
}

/* Stati: colore + pallino, così si distinguono anche senza vedere bene i colori */
.wk-badge--ok { background: var(--wk-success-soft); color: var(--wk-success); border-color: transparent; }
.wk-badge--warn { background: var(--wk-warning-soft); color: var(--wk-warning); border-color: transparent; }
.wk-badge--danger { background: var(--wk-danger-soft); color: var(--wk-danger); border-color: transparent; }
.wk-badge--info { background: var(--wk-info-soft); color: var(--wk-info); border-color: transparent; }
.wk-badge--accent { background: var(--wk-accent-soft); color: var(--wk-accent); border-color: transparent; }

.wk-badge--ok::before,
.wk-badge--warn::before,
.wk-badge--danger::before,
.wk-badge--info::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

/* Errore: pallino quadrato, per distinguerlo da "ok" anche in bianco e nero */
.wk-badge--danger::before {
    border-radius: 1px;
}

/* ---------- Schede di scelta (metodo 2FA) ---------- */

.wk-segmented {
    display: flex;
    gap: var(--wk-space-1);
    padding: var(--wk-space-1);
    margin-bottom: var(--wk-space-4);
    background: var(--wk-surface-2);
    border: 1px solid var(--wk-border);
    border-radius: var(--wk-radius);
}

.wk-segmented a {
    flex: 1;
    padding: var(--wk-space-2);
    border-radius: var(--wk-radius-sm);
    text-align: center;
    text-decoration: none;
    font-size: var(--wk-text-sm);
    font-weight: 600;
    color: var(--wk-ink-muted);
}

.wk-segmented a[aria-current="page"] {
    background: var(--wk-surface);
    color: var(--wk-ink);
    box-shadow: var(--wk-shadow);
}

/* ---------- Tabelle e liste ---------- */

.wk-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--wk-text-sm);
}

.wk-table th,
.wk-table td {
    padding: var(--wk-space-2) var(--wk-space-3);
    border-bottom: 1px solid var(--wk-border);
    text-align: left;
    vertical-align: middle;
}

/* Intestazioni in minuscolo normale: in tedesco o portoghese il MAIUSCOLO diventa illeggibile */
.wk-table th {
    font-weight: 600;
    color: var(--wk-ink-muted);
    font-size: var(--wk-text-sm);
    white-space: nowrap;
}

.wk-table tbody tr:hover {
    background: var(--wk-surface-2);
}

.wk-table tbody tr[aria-selected="true"] {
    background: var(--wk-info-soft);
}

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

/* Numeri e importi: allineati a destra, cifre della stessa larghezza */
.wk-table .wk-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Colonna delle azioni (menu "⋯"): stretta e a destra */
.wk-table .wk-actions {
    width: 1%;
    white-space: nowrap;
    text-align: right;
}

/* Sul telefono la tabella scorre in orizzontale dentro il suo riquadro, non tutta la pagina */
.wk-table-wrap {
    /* relative: anche i testi nascosti per i lettori di schermo (position: absolute) restano dentro lo scorrimento */
    position: relative;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.wk-empty {
    padding: var(--wk-space-6) var(--wk-space-4);
    text-align: center;
    color: var(--wk-ink-muted);
}

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

.wk-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--wk-space-3);
    padding: var(--wk-space-2) 0;
    border-bottom: 1px solid var(--wk-border);
}

.wk-list li:last-child {
    border-bottom: 0;
}

/* ---------- Riquadri numerici ---------- */

.wk-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: var(--wk-space-3);
    margin-bottom: var(--wk-space-4);
}

.wk-stat {
    padding: var(--wk-space-4);
    background: var(--wk-surface);
    border: 1px solid var(--wk-border);
    border-radius: var(--wk-radius-lg);
}

.wk-stat__value {
    display: block;
    font-size: var(--wk-text-2xl);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.wk-stat__label {
    color: var(--wk-ink-muted);
    font-size: var(--wk-text-sm);
}

/* ---------- Codici di backup e QR ---------- */

.wk-codes {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--wk-space-2);
    margin: var(--wk-space-4) 0;
    padding: var(--wk-space-4);
    list-style: none;
    background: var(--wk-surface-2);
    border: 1px dashed var(--wk-border-strong);
    border-radius: var(--wk-radius);
    font-family: var(--wk-font-mono);
    font-size: var(--wk-text-lg);
    text-align: center;
}

.wk-qr {
    display: block;
    width: 200px;
    height: 200px;
    margin: var(--wk-space-3) auto;
    padding: var(--wk-space-2);
    background: var(--wk-qr-bg); /* il QR deve restare leggibile anche nel tema scuro */
    border-radius: var(--wk-radius);
}

.wk-secret {
    display: block;
    padding: var(--wk-space-2);
    text-align: center;
    word-break: break-all;
    background: var(--wk-surface-2);
    border-radius: var(--wk-radius-sm);
}

/* ---------- Menu a tendina (details/summary) ---------- */

.wk-menu {
    position: relative;
}

.wk-menu > summary {
    display: inline-flex;
    align-items: center;
    gap: var(--wk-space-2);
    min-height: 34px;
    padding: 0 var(--wk-space-3);
    border-radius: var(--wk-radius);
    cursor: pointer;
    list-style: none;
    font-weight: 600;
    user-select: none;
}

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

.wk-menu > summary::after {
    content: "";
    width: 6px;
    height: 6px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg) translateY(-2px);
    opacity: 0.6;
}

.wk-menu > summary:hover,
.wk-menu[open] > summary {
    background: var(--wk-surface-2);
}

.wk-menu__panel {
    position: absolute;
    z-index: 30;
    top: calc(100% + 4px);
    min-width: 220px;
    padding: var(--wk-space-2);
    background: var(--wk-surface);
    border: 1px solid var(--wk-border);
    border-radius: var(--wk-radius);
    box-shadow: var(--wk-shadow-lg);
}

.wk-menu--end .wk-menu__panel {
    right: 0;
}

.wk-menu__item {
    display: block;
    width: 100%;
    padding: var(--wk-space-2) var(--wk-space-3);
    border: 0;
    border-radius: var(--wk-radius-sm);
    background: none;
    font: inherit;
    text-align: left;
    text-decoration: none;
    color: var(--wk-ink);
    cursor: pointer;
}

.wk-menu__item:hover,
.wk-menu__item:focus-visible {
    background: var(--wk-surface-2);
    color: var(--wk-ink);
}

.wk-menu__item[aria-current="page"] {
    color: var(--wk-brand);
    font-weight: 600;
}

.wk-menu__item {
    display: flex;
    align-items: center;
    gap: var(--wk-space-2);
}

.wk-menu__item--danger,
.wk-menu__item--danger:hover,
.wk-menu__item--danger:focus-visible {
    color: var(--wk-danger);
}

/* Menu "⋯" (azioni di una riga): solo icona, senza freccia; serve aria-label sul summary */
.wk-menu--icon > summary {
    justify-content: center;
    width: 32px;
    min-height: 30px;
    padding: 0;
    color: var(--wk-ink-muted);
}

.wk-menu--icon > summary::after {
    display: none;
}

/* Pannello aperto sopra tutto (menu dentro una tabella che scorre): posizione data da menu.js */
.wk-menu__panel--floating {
    position: fixed;
    z-index: 40;
}

.wk-menu__label {
    display: block;
    padding: var(--wk-space-2) var(--wk-space-3) var(--wk-space-1);
    font-size: var(--wk-text-xs);
    font-weight: 600;
    color: var(--wk-ink-muted);
}

.wk-menu__sep {
    height: 1px;
    margin: var(--wk-space-2) 0;
    background: var(--wk-border);
}

/* ---------- Finestre (sostituiscono alert/confirm del browser) ---------- */

.wk-dialog {
    width: min(420px, calc(100vw - 2rem));
    padding: var(--wk-space-5);
    border: 1px solid var(--wk-border);
    border-radius: var(--wk-radius-lg);
    background: var(--wk-surface);
    color: var(--wk-ink);
    box-shadow: var(--wk-shadow-lg);
}

.wk-dialog::backdrop {
    background: var(--wk-overlay);
}

.wk-dialog__actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: var(--wk-space-2);
    margin-top: var(--wk-space-5);
}

.wk-dialog__title {
    margin-bottom: var(--wk-space-3);
    font-size: var(--wk-text-lg);
}

/* Finestra del QR (partials/qr_dialog.html): un po' più larga, i tre pulsanti in una riga al centro. */
.wk-qr-dialog {
    width: min(480px, calc(100vw - 2rem));
    text-align: center;
}

.wk-qr-dialog__img {
    width: 260px;
    max-width: 100%;
    height: auto;
    aspect-ratio: 1;
}

.wk-qr-dialog__actions {
    justify-content: center;
}

.wk-dialog--wide {
    width: min(560px, calc(100vw - 2rem));
}

.wk-dialog[open] {
    animation: wk-pop-in 140ms ease-out;
}

@keyframes wk-pop-in {
    from { opacity: 0; transform: translateY(6px) scale(0.98); }
}

/* ---------- Notifiche (toast.js) ---------- */

/* Notifiche al centro dello schermo (decisione del 20/10/2026): su un monitor grande quelle in basso a destra
   non si vedevano. Non bloccano la pagina: si clicca attraverso lo spazio intorno. */
.wk-toasts {
    position: fixed;
    z-index: 60;
    top: 50%;
    left: 50%;
    display: grid;
    gap: var(--wk-space-2);
    width: min(440px, calc(100vw - 2rem));
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.wk-toasts > * {
    pointer-events: auto;
}

.wk-toast {
    display: flex;
    align-items: flex-start;
    gap: var(--wk-space-2);
    padding: var(--wk-space-4);
    background: var(--wk-surface);
    color: var(--wk-ink);
    border: 1px solid var(--wk-border);
    border-left: 4px solid var(--wk-info);
    border-radius: var(--wk-radius);
    box-shadow: var(--wk-shadow-lg);
    animation: wk-toast-in 160ms ease-out;
}

.wk-toast__icon {
    margin-top: 2px;
    color: var(--wk-info);
}

.wk-toast__text {
    flex: 1;
    margin: 0;
    font-size: var(--wk-text-lg);
    font-weight: 600;
}

.wk-toast--success { border-left-color: var(--wk-success); }
.wk-toast--success .wk-toast__icon { color: var(--wk-success); }
.wk-toast--warning { border-left-color: var(--wk-warning); }
.wk-toast--warning .wk-toast__icon { color: var(--wk-warning); }
.wk-toast--error { border-left-color: var(--wk-danger); }
.wk-toast--error .wk-toast__icon { color: var(--wk-danger); }

@keyframes wk-toast-in {
    from { opacity: 0; transform: scale(0.94); }
}

/* ---------- Pannello laterale dell'aiuto ---------- */

.wk-help-panel {
    position: fixed;
    z-index: 50;
    top: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    width: min(var(--wk-panel-width), 100vw);
    background: var(--wk-surface);
    border-left: 1px solid var(--wk-border);
    box-shadow: var(--wk-shadow-lg);
}

.wk-help-panel__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--wk-space-3);
    padding: var(--wk-space-3) var(--wk-space-4);
    border-bottom: 1px solid var(--wk-border);
}

.wk-help-panel__search {
    padding: var(--wk-space-3) var(--wk-space-4);
    border-bottom: 1px solid var(--wk-border);
}

.wk-help-panel__body {
    flex: 1;
    overflow-y: auto;
    padding: var(--wk-space-4);
}

.wk-help-panel__body h1,
.wk-help-panel__body h2 {
    font-size: var(--wk-text-lg);
}

.wk-help-results {
    list-style: none;
    margin: 0;
    padding: 0;
}

.wk-help-results li + li {
    margin-top: var(--wk-space-3);
}

.wk-help-results mark {
    background: var(--wk-accent-soft);
    color: inherit;
}

.wk-help-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid var(--wk-border-strong);
    border-radius: 50%;
    background: var(--wk-surface);
    color: var(--wk-ink);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.wk-help-btn:hover {
    border-color: var(--wk-brand);
    color: var(--wk-brand);
}

.wk-help-panel:not([hidden]) {
    animation: wk-slide-in 180ms ease-out;
}

@keyframes wk-slide-in {
    from { opacity: 0; transform: translateX(24px); }
}

/* ---------- Password con pulsante mostra/nascondi (partials/password.html) ---------- */

/* Il pulsante parte nascosto (hidden) e lo mostra password.js: senza JavaScript resta un campo normale. */
.wk-password {
    position: relative;
}

.wk-password .wk-input {
    padding-right: 44px;
}

.wk-password__toggle {
    position: absolute;
    top: 50%;
    right: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: var(--wk-radius-sm);
    background: transparent;
    color: var(--wk-ink-muted);
    cursor: pointer;
    transform: translateY(-50%);
}

.wk-password__toggle:hover {
    color: var(--wk-ink);
    background: var(--wk-surface-2);
}

.wk-password__toggle[hidden] {
    display: none;
}

/* ---------- Elenco di scelte grandi (es. scelta del cliente) ---------- */

/* Ogni riga è un unico pulsante: tutta la riga si tocca, non un piccolo bottone in fondo. */
.wk-choice-list {
    display: grid;
    gap: var(--wk-space-2);
    margin: 0;
    padding: 0;
    list-style: none;
}

.wk-choice-list form {
    margin: 0;
}

.wk-choice {
    display: flex;
    align-items: center;
    gap: var(--wk-space-3);
    width: 100%;
    padding: var(--wk-space-3);
    border: 1px solid var(--wk-border);
    border-radius: var(--wk-radius);
    background: var(--wk-surface);
    color: var(--wk-ink);
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.15s, background-color 0.15s;
}

.wk-choice:hover {
    border-color: var(--wk-brand);
    background: var(--wk-surface-2);
}

.wk-choice .wk-avatar {
    width: 36px;
    height: 36px;
    font-size: var(--wk-text-sm);
}

.wk-choice__text {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
}

.wk-choice__title {
    overflow: hidden;
    font-weight: 600;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.wk-choice__meta {
    font-size: var(--wk-text-sm);
    color: var(--wk-ink-muted);
}

/* Inviti da accettare (pagina "Scegli il cliente", modulo Team) */
.wk-invitations {
    margin-bottom: var(--wk-space-5);
}

.wk-invitations__title {
    margin: 0 0 var(--wk-space-2);
    font-size: var(--wk-text-lg);
}

.wk-invitations__list {
    display: grid;
    gap: var(--wk-space-2);
    margin: 0;
    padding: 0;
    list-style: none;
}

.wk-invitation {
    display: flex;
    flex-wrap: wrap;
    gap: var(--wk-space-3);
    align-items: center;
    justify-content: space-between;
    padding: var(--wk-space-3);
    border: 1px solid var(--wk-brand);
    border-radius: var(--wk-radius);
    background: var(--wk-surface-2);
}

.wk-invitation__text {
    display: flex;
    flex: 1 1 12rem;
    flex-direction: column;
    min-width: 0;
}

.wk-invitation__actions {
    display: flex;
    gap: var(--wk-space-2);
}

.wk-invitation__actions form {
    margin: 0;
}

.wk-choice > .wk-icon {
    color: var(--wk-ink-muted);
}
/* ---------- Codice QR con chiave da copiare (attivazione e cambio della 2FA) ---------- */

.wk-qr-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--wk-space-2);
    margin: 0 0 var(--wk-space-4);
    padding: var(--wk-space-3);
    border: 1px solid var(--wk-border);
    border-radius: var(--wk-radius);
    background: var(--wk-surface-2);
}

.wk-qr-box .wk-qr {
    margin: 0;
}

.wk-qr-box p {
    margin: 0;
    font-size: var(--wk-text-sm);
    text-align: center;
}

/* Testo da copiare + pulsante con data-copy-text="id" (assets/js/copy.js) */
.wk-copy-field {
    display: flex;
    align-items: center;
    gap: var(--wk-space-2);
    width: 100%;
}

.wk-copy-field .wk-secret {
    flex: 1;
    background: var(--wk-surface);
}

/* ---------- Impostazioni: testo a sinistra, azione a destra ---------- */

.wk-setting {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: var(--wk-space-3) var(--wk-space-5);
}

/* Titolo della scheda con l'icona in un quadratino (20/10/2026, dallo stile del mock-up D3) */
.wk-card__title--icon {
    justify-content: flex-start;
}

.wk-card__icon {
    display: inline-grid;
    flex: 0 0 auto;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: var(--wk-radius);
    color: var(--wk-ink);
    background: var(--wk-surface-2);
}

.wk-card__icon--brand {
    color: var(--wk-brand);
    background: var(--wk-brand-soft);
}

.wk-card__icon .wk-icon {
    width: 18px;
    height: 18px;
}

.wk-setting .wk-card__title {
    justify-content: flex-start;
    margin-bottom: var(--wk-space-1);
}

.wk-setting p {
    margin: 0;
}

.wk-setting form {
    margin: 0;
}

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

    .wk-setting > :last-child {
        justify-self: start;
    }
}

/* Intestazione di scheda con azione a destra (es. "Sessioni aperte" + "Chiudi le altre") */
.wk-card__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--wk-space-3);
    margin-bottom: var(--wk-space-3);
}

.wk-card__head .wk-card__title,
.wk-card__head form {
    margin: 0;
}

/* Scheda stretta: per pagine con una sola domanda (es. conferma 2FA) */
.wk-card--narrow {
    max-width: 480px;
}

/* Due colonne affiancate dal tablet in su (es. QR a sinistra, modulo a destra) */
.wk-split {
    display: grid;
    gap: var(--wk-space-5);
}

.wk-split .wk-qr-box {
    margin-bottom: 0;
}

/* Riquadri affiancati: lo spazio tra loro lo dà la griglia (niente margine in più a destra),
   e prima/dopo la coppia c'è lo stesso spazio che tra due riquadri uno sotto l'altro. */
.wk-split > .wk-card {
    margin-top: 0;
}

.wk-split + .wk-card,
.wk-card + .wk-split,
.wk-split + .wk-split {
    margin-top: var(--wk-space-4);
}

@media (min-width: 900px) {
    .wk-split {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        align-items: start;
    }
}
/* ---------- Persona: iniziali + nome (team, utenti) ---------- */

.wk-person {
    display: inline-flex;
    align-items: center;
    gap: var(--wk-space-2);
    min-width: 0;
}

/* Riquadro numerico da guardare (es. accessi falliti > 0) */
.wk-stat--warn {
    border-color: var(--wk-warning);
    background: var(--wk-warning-soft);
}

.wk-stat--warn .wk-stat__value {
    color: var(--wk-warning);
}

.wk-stat--warn .wk-stat__label {
    color: var(--wk-ink);
}

.wk-stat--danger {
    border-color: var(--wk-danger);
    background: var(--wk-danger-soft);
}

.wk-stat--danger .wk-stat__value {
    color: var(--wk-danger);
}

.wk-stat--danger .wk-stat__label {
    color: var(--wk-ink);
}

/* Nome tecnico (es. azione del log di audit): piccolo e leggibile, va a capo se serve */
.wk-code {
    padding: 1px 6px;
    border-radius: var(--wk-radius-sm);
    background: var(--wk-surface-2);
    font-family: var(--wk-font-mono);
    font-size: var(--wk-text-xs);
    overflow-wrap: anywhere;
}
/* Pulsanti di salvataggio sempre visibili in fondo alle pagine lunghe (es. editor degli articoli) */
.wk-form-actions--sticky {
    position: sticky;
    bottom: 0;
    z-index: 5;
    padding: var(--wk-space-3) 0;
    background: linear-gradient(180deg, transparent, var(--wk-bg) 35%);
}

/* ---------- Condividi link: QR + link + azioni (views/partials/share_link.html) ---------- */

.wk-share {
    display: grid;
    gap: var(--wk-space-4);
    align-items: center;
}

.wk-share__qr {
    justify-self: center;
    border-radius: var(--wk-radius);
}

.wk-share__qr .wk-qr {
    width: 168px;
    height: 168px;
    margin: 0;
}

.wk-share__body {
    display: grid;
    gap: var(--wk-space-3);
    min-width: 0;
}

.wk-share__url {
    font-size: var(--wk-text-sm);
    text-align: left;
}

.wk-share__actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--wk-space-2);
}

.wk-share__hint {
    margin: 0;
    font-size: var(--wk-text-sm);
}

.wk-share--expired .wk-share__qr,
.wk-share--expired .wk-share__url {
    opacity: 0.45;
}

@media (min-width: 640px) {
    .wk-share {
        grid-template-columns: auto minmax(0, 1fr);
    }
}

/* Telefono: menu del prefisso (bandiera, Paese, +NN) e numero sulla stessa riga */
.wk-phone__row {
    display: grid;
    grid-template-columns: minmax(7rem, 40%) minmax(0, 1fr);
    gap: var(--wk-space-2);
}

.wk-phone__country {
    min-width: 0;
    text-overflow: ellipsis;
}

/* Pulsante dentro un modulo (es. "Email" nella riga dei pulsanti del link) */
.wk-share__form {
    display: contents;
}

/* Dati in coppie etichetta/valore su due colonne (una sul telefono), ogni riga su un fondo leggero.
   Uso: <dl class="wk-facts"><div><dt>Etichetta</dt><dd>Valore</dd></div>…</dl>
   (decisione del 20/10/2026: le schede con molti dati non devono diventare una colonna lunga e vuota a destra) */
.wk-facts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, max(300px, 40%)), 1fr)); /* al massimo 2 colonne */
    gap: var(--wk-space-1) var(--wk-space-5);
    margin: 0;
}

.wk-facts > div {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--wk-space-3);
    min-width: 0;
    padding: 6px var(--wk-space-3);
    border-radius: var(--wk-radius-sm);
    background: var(--wk-surface-2);
}

.wk-facts dt {
    flex: 0 0 auto;
    color: var(--wk-ink-muted);
    font-size: var(--wk-text-sm);
}

.wk-facts dd {
    min-width: 0;
    margin: 0;
    font-weight: 600;
    text-align: right;
    overflow-wrap: anywhere;
}
