/* Control center Movimenta 2.0 (docs/26): design system dal prototipo Claude Design
   (frontend-moviementa-2-0). Tema chiaro/scuro via variabili CSS. Nessun framework.
   Solo sezioni reali: Dashboard, Monitor lavorazioni, Log letture, Log operativi,
   Operatori, Tipologie documento. */

:root {
    --bg: #eef1f6; --surface: #ffffff; --surface-2: #f6f8fc; --surface-3: #eef2f8;
    --border: #e4e8f0; --border-strong: #d3dae5;
    --text: #1b2430; --muted: #5b6675; --faint: #8b95a6;
    --primary: #0057B8; --primary-700: #00489a; --primary-weak: #e7f0fb;
    --success: #16a34a; --success-weak: #dcfce7;
    --warning: #d97706; --warning-weak: #fef3c7;
    --danger: #dc2626; --danger-weak: #fee2e2;
    --shadow-sm: 0 1px 2px rgba(16,24,40,.05);
    --shadow: 0 1px 3px rgba(16,24,40,.08), 0 1px 2px rgba(16,24,40,.04);
}

[data-theme="dark"] {
    --bg: #0a1017; --surface: #121b28; --surface-2: #0e1622; --surface-3: #1a2636;
    --border: #233145; --border-strong: #32435e;
    --text: #e8edf4; --muted: #9db0c6; --faint: #67788e;
    --primary: #4c9dff; --primary-700: #7bb6ff; --primary-weak: #16273f;
    --success: #4ade80; --success-weak: #0f2d1c;
    --warning: #fbbf24; --warning-weak: #33270a;
    --danger: #f87171; --danger-weak: #3a1414;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
    --shadow: 0 2px 8px rgba(0,0,0,.45);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", Roboto, Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
    font-size: 14px;
}

.hidden { display: none !important; }

/* ---------- top bar ---------- */
.cc-topbar {
    display: flex;
    align-items: center;
    gap: 14px;
    height: 60px;
    padding: 0 18px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    flex-wrap: wrap;
}
.cc-brand { display: flex; align-items: center; gap: 12px; }
.cc-logo { height: 30px; width: auto; display: block; }
.cc-brand-titles { display: flex; flex-direction: column; line-height: 1.15; }
.cc-brand-name { font-size: 15px; font-weight: 650; letter-spacing: -.2px; }
.cc-brand-sub { font-size: 11px; color: var(--muted); font-weight: 500; }
.cc-topbar-spacer { flex: 1; }

.cc-company { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; color: var(--muted); }
.cc-company select, .cc-company input {
    height: 34px; padding: 0 10px; border: 1px solid var(--border-strong);
    border-radius: 8px; background: var(--surface-2); color: var(--text);
    font-size: 13px; font-family: inherit; outline: none; min-width: 200px;
}

.cc-icon-btn {
    height: 34px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--border);
    background: var(--surface); color: var(--muted); cursor: pointer;
    font-size: 13px; font-weight: 600; font-family: inherit;
}
.cc-icon-btn:hover { background: var(--surface-3); color: var(--text); }

/* Badge utente loggato in topbar (docs/36 §Utenti portale). */
.cc-user { color: var(--muted); font-size: 13px; margin-right: 6px; white-space: nowrap; }

/* Banner ambiente di test: compatto, sotto la top bar, non invade sidebar/contenuto. */
.cc-testbar {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 18px; background: var(--warning-weak); color: var(--warning);
    border-bottom: 1px solid var(--warning);
    font-size: 12.5px; line-height: 1.3;
}
.cc-testbar-tag {
    flex: 0 0 auto; background: var(--warning); color: #fff;
    padding: 2px 9px; border-radius: 20px; font-weight: 700; font-size: 11px;
    text-transform: uppercase; letter-spacing: .3px;
}
.cc-testbar-text { font-weight: 600; }

/* ---------- layout ---------- */
.cc-body { display: flex; min-height: calc(100vh - 60px); }

.cc-sidebar {
    flex: 0 0 220px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 14px 10px;
}
.cc-nav-group { margin-bottom: 10px; }
.cc-nav-label {
    padding: 8px 12px 5px; font-size: 10.5px; font-weight: 700;
    letter-spacing: .5px; text-transform: uppercase; color: var(--faint);
}
.cc-nav-item {
    display: block; width: 100%; text-align: left;
    padding: 9px 12px; margin-bottom: 3px; border: none; border-radius: 9px;
    background: transparent; color: var(--muted); cursor: pointer;
    font-size: 13.5px; font-weight: 520; font-family: inherit;
}
.cc-nav-item:hover { background: var(--surface-3); color: var(--text); }
.cc-nav-item.active {
    background: var(--primary-weak); color: var(--primary);
    font-weight: 600; box-shadow: inset 3px 0 0 var(--primary);
}

.cc-main { flex: 1; min-width: 0; padding: 24px 28px 60px; overflow-x: hidden; }
.cc-view-head {
    display: flex; align-items: flex-end; justify-content: space-between;
    gap: 16px; flex-wrap: wrap; margin-bottom: 18px;
}
h1 { margin: 0 0 4px; font-size: 22px; font-weight: 700; letter-spacing: -.3px; }
h2 { font-size: 18px; margin-top: 0; }
h3 { margin: 0 0 12px; font-size: 15px; font-weight: 650; }
.subtitle { margin: 0; color: var(--muted); font-size: 13px; }

/* ---------- buttons ---------- */
button {
    border: 1px solid var(--border-strong); background: var(--surface);
    color: var(--text); border-radius: 8px; padding: 8px 14px;
    font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit;
}
button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
button.primary:hover:not(:disabled) { background: var(--primary-700); }
button.inline { padding: 5px 10px; font-size: 12px; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button:hover:not(:disabled):not(.primary) { background: var(--surface-3); }

/* ---------- KPI grid ---------- */
.cc-kpi-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px; margin-bottom: 18px;
}
.cc-kpi {
    background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
    padding: 16px 17px; box-shadow: var(--shadow-sm);
}
.cc-kpi .cc-kpi-label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.cc-kpi .cc-kpi-value { font-size: 28px; font-weight: 750; letter-spacing: -.5px; margin-top: 8px; }
.cc-kpi .cc-kpi-sub { font-size: 11.5px; color: var(--faint); margin-top: 6px; }

.cc-cards-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
@media (max-width: 900px) { .cc-cards-2 { grid-template-columns: 1fr; } }
.cc-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
    padding: 16px 18px; box-shadow: var(--shadow-sm);
    /* Respiro verticale tra i riquadri bianchi in TUTTO il portale: prima le card non avevano
       alcun margine e risultavano attaccate quando impilate nella stessa vista. */
    margin-bottom: 20px;
}
/* Dentro la griglia il distacco lo dà il gap: niente margine doppio. */
.cc-cards-2 > .cc-card { margin-bottom: 0; }
.cc-card:last-child { margin-bottom: 0; }
.cc-statline {
    display: flex; align-items: center; justify-content: space-between;
    padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px;
}
.cc-statline:last-child { border-bottom: none; }
.cc-statline .cc-statval { font-weight: 700; font-variant-numeric: tabular-nums; }

/* Key/value impostazioni generali */
.cc-kv { display: grid; grid-template-columns: 220px 1fr; gap: 4px 16px; font-size: 13.5px; }
.cc-kv .cc-kv-key { color: var(--muted); font-weight: 600; padding: 6px 0; border-bottom: 1px solid var(--border); }
.cc-kv .cc-kv-val { font-weight: 600; padding: 6px 0; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }

/* Sintesi esiti letture (qualità letture) */
.cc-summary { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.cc-summary .cc-summary-item {
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
    padding: 10px 16px; box-shadow: var(--shadow-sm); min-width: 120px;
}
.cc-summary .cc-summary-label { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.cc-summary .cc-summary-value { font-size: 22px; font-weight: 750; margin-top: 2px; font-variant-numeric: tabular-nums; }

/* ---------- filters ---------- */
.cc-filters {
    display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end;
    background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
    padding: 14px 16px; box-shadow: var(--shadow-sm); margin-bottom: 14px;
}
.cc-filters label { display: flex; flex-direction: column; gap: 4px; font-size: 11.5px; font-weight: 600; color: var(--muted); }
.cc-filters input, .cc-filters select {
    height: 34px; padding: 0 10px; border: 1px solid var(--border-strong);
    border-radius: 8px; background: var(--surface-2); color: var(--text);
    font-size: 12.5px; font-family: inherit; outline: none; min-width: 130px;
}
/* Campo che occupa lo spazio libero della riga filtri (es. note). */
.cc-filters label.cc-grow { flex: 1 1 260px; }
/* Checkbox standard con etichetta accanto, allineata ai campi (altezza 34px). */
.cc-filters label.cc-check { flex-direction: row; align-items: center; gap: 6px; height: 34px; font-size: 12.5px; color: var(--text); }
.cc-filters input[type="checkbox"], .cc-table input[type="checkbox"] { min-width: 0; width: 16px; height: 16px; padding: 0; margin: 0; accent-color: var(--primary); }
.cc-filters input[type="file"] { padding: 5px 8px; min-width: 260px; }
.cc-hint { margin: -6px 0 14px; font-size: 12px; color: var(--muted); }
/* Celle azioni compatte (pulsanti "inline" affiancati). */
.cc-actions { white-space: nowrap; }
.cc-actions button + button { margin-left: 6px; }
.cc-sub { display: block; font-size: 11px; color: var(--muted); }
/* Etichetta (.chip) su una riga propria sotto il valore della cella: solo spaziatura. */
.cc-cell-chip { margin-top: 4px; }

/* ---------- tables ---------- */
.cc-table-wrap {
    background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
    box-shadow: var(--shadow-sm); overflow: hidden;
}
.cc-table { width: 100%; border-collapse: collapse; }
.cc-table thead tr { background: var(--surface-2); }
.cc-table th {
    text-align: left; padding: 11px 14px; font-size: 11px; font-weight: 700;
    letter-spacing: .3px; text-transform: uppercase; color: var(--faint);
    border-bottom: 1px solid var(--border); white-space: nowrap;
}
.cc-table td { padding: 10px 14px; font-size: 12.5px; border-bottom: 1px solid var(--border); }
.cc-table tbody tr:hover { background: var(--surface-2); }
.cc-mono { font-variant-numeric: tabular-nums; }
.cc-empty { padding: 24px; text-align: center; color: var(--faint); }

/* status chips */
.chip {
    display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px;
    border-radius: 20px; font-size: 11.5px; font-weight: 700; white-space: nowrap;
}
.chip.success { background: var(--success-weak); color: var(--success); }
.chip.warning { background: var(--warning-weak); color: var(--warning); }
.chip.danger { background: var(--danger-weak); color: var(--danger); }
.chip.neutral { background: var(--surface-3); color: var(--muted); }
.chip.info { background: var(--primary-weak); color: var(--primary); }

/* ---------- messages ---------- */
.message { margin: 0 0 14px; padding: 10px 14px; border-radius: 10px; font-weight: 600; }
.message.success { background: var(--success-weak); color: var(--success); border: 1px solid var(--success); }
.message.error { background: var(--danger-weak); color: var(--danger); border: 1px solid var(--danger); }

/* ---------- operatori (layout preservato, temizzato) ---------- */
.cc-operators { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.operators-panel { flex: 0 0 320px; }
.detail-panel { flex: 1; min-width: 320px; }
.operators-panel, .detail-panel {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 12px; padding: 14px;
}
.panel-actions { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; align-items: center; }
.combo-row { display: flex; gap: 6px; align-items: center; margin-top: 3px; }
.combo-row select { flex: 1; margin-top: 0; }

.operator-list { list-style: none; margin: 0; padding: 0; max-height: 480px; overflow-y: auto; }
.operator-list li {
    border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
    margin-bottom: 6px; cursor: pointer;
}
.operator-list li:hover { border-color: var(--primary); }
.operator-list li.selected { border-color: var(--primary); background: var(--primary-weak); }
.operator-list .op-title { font-weight: 700; }
.operator-list .op-meta { font-size: 12px; color: var(--muted); }

.badge {
    display: inline-block; font-size: 11px; font-weight: 700; border-radius: 6px;
    padding: 1px 6px; margin-left: 6px; vertical-align: middle;
}
.badge.supervisor { background: var(--primary); color: #fff; }
.badge.disabled { background: var(--danger); color: #fff; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 20px; margin-bottom: 12px; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }
/* Campi del form operatore: etichetta SOPRA il campo, controllo a piena larghezza
   (i fieldset a checkbox non usano .form-grid e restano in riga). */
.form-grid label { display: flex; flex-direction: column; align-items: stretch; gap: 4px; margin: 0; }
.form-grid label > input[type="text"], .form-grid label > input[type="password"],
.form-grid label > select { width: 100%; box-sizing: border-box; }
.form-grid .hint { font-size: 12px; line-height: 1.35; }
label { display: block; font-size: 13px; font-weight: 600; }
input[type="text"], input[type="password"], input[type="number"], select {
    width: 100%; margin-top: 3px; padding: 7px 9px;
    border: 1px solid var(--border-strong); border-radius: 7px; font-size: 14px;
    background: var(--surface-2); color: var(--text); font-family: inherit;
}
input[readonly] { background: var(--surface-3); color: var(--muted); }

fieldset { border: 1px solid var(--border); border-radius: 8px; margin: 0 0 12px; padding: 10px 12px; }
legend { font-weight: 700; font-size: 13px; padding: 0 6px; }
fieldset label { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; margin: 4px 16px 4px 0; }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.hint { color: var(--muted); font-size: 13px; }

/* Sezioni ordinate del dettaglio operatore (card con titolo numerato) */
.cc-section { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; margin-bottom: 18px; padding: 12px 14px; }
.cc-section > legend { color: var(--primary); font-size: 13px; font-weight: 700; }
.cc-section > label { display: block; }
.cc-section .form-grid { margin-bottom: 6px; }
.cc-inline-check { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
.operators-panel .panel-actions #op-search { flex: 1; min-width: 160px; margin-top: 0; }

/* ---------- tipologie documento ---------- */
.doctypes-panel {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 12px; padding: 14px;
}
.doctypes-panel .panel-actions label {
    display: flex; flex-direction: column; font-size: 12px; font-weight: 600; gap: 3px;
}
.doctypes-panel .panel-actions input,
.doctypes-panel .panel-actions select { width: 140px; margin-top: 0; }
.doctypes-panel .panel-actions #dt-search { width: 200px; }

.dt-table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 14px; }
.dt-table th, .dt-table td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--border); }
.dt-table th { color: var(--muted); font-size: 12px; text-transform: uppercase; }
.dt-table td:first-child { font-weight: 700; }

/* Toolbar tipologie: pulsanti allineati all'altezza dei campi, non pesanti */
.doctypes-panel .panel-actions { align-items: flex-end; }
.doctypes-panel .panel-actions button { height: 34px; padding: 0 12px; }
.cc-toolbar-spacer { flex: 1; }
.cc-btn-accent { border-color: var(--primary); color: var(--primary); font-weight: 600; }
.cc-btn-accent:hover:not(:disabled) { background: var(--primary-weak); }
.cc-empty-state {
    background: var(--surface); border: 1px dashed var(--border-strong); border-radius: 12px;
    padding: 22px; text-align: center; color: var(--muted); font-size: 13.5px; margin-top: 12px;
}

/* Campi numerici compatti (Giorni picking / Mesi in linea sulla stessa riga) */
.cc-num-row { grid-column: 1 / -1; display: flex; gap: 24px; flex-wrap: wrap; }
.cc-num { flex: 0 0 auto; min-width: 160px; }
.cc-num-input { width: 140px; }

/* Valori dashboard cliccabili (drill-down verso monitor/log) */
.cc-clickable { cursor: pointer; }
.cc-statline.cc-clickable:hover { background: var(--surface-2); }
.cc-statline.cc-clickable:hover .cc-statval { color: var(--primary); text-decoration: underline; }
.cc-kpi.cc-clickable:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.cc-kpi.cc-clickable:hover .cc-kpi-value { color: var(--primary); }

/* Drawer timeline movimentazioni documento */
.cc-drawer-overlay { position: fixed; inset: 0; background: rgba(12,18,28,.45); z-index: 80; }
.cc-drawer {
    position: fixed; top: 0; right: 0; bottom: 0; width: 480px; max-width: 96vw;
    background: var(--surface); border-left: 1px solid var(--border);
    box-shadow: -8px 0 30px rgba(0,0,0,.18); z-index: 90; display: flex; flex-direction: column;
}
.cc-drawer-head {
    flex: 0 0 auto; display: flex; align-items: flex-start; justify-content: space-between;
    gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--border);
}
.cc-drawer-title { font-size: 16px; font-weight: 700; color: var(--primary); font-variant-numeric: tabular-nums; }
.cc-drawer-meta { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.cc-drawer-body { flex: 1; overflow-y: auto; padding: 16px 18px; }
.cc-drawer-section-title {
    font-size: 11px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase;
    color: var(--faint); margin: 6px 0 10px;
}

/* Timeline verticale leggera (HTML/CSS, nessuna libreria) */
.cc-timeline { position: relative; margin: 0 0 18px; padding-left: 6px; }
.cc-tl-node {
    position: relative; padding: 0 0 16px 22px; border-left: 2px solid var(--border); cursor: pointer;
}
.cc-tl-node:last-child { border-left-color: transparent; }
.cc-tl-node::before {
    content: ""; position: absolute; left: -7px; top: 2px; width: 12px; height: 12px;
    border-radius: 50%; background: var(--faint); border: 2px solid var(--surface);
}
.cc-tl-node.tl-created::before, .cc-tl-node.tl-imported::before { background: var(--primary); }
.cc-tl-node.tl-taken::before, .cc-tl-node.tl-reassigned::before { background: var(--secondary, var(--primary)); }
.cc-tl-node.tl-closed::before, .cc-tl-node.tl-processed::before,
.cc-tl-node.tl-readingsucceeded::before { background: var(--success); }
.cc-tl-node.tl-canceled::before, .cc-tl-node.tl-readingcanceled::before { background: var(--warning); }
.cc-tl-node.tl-readingfailed::before { background: var(--danger); }
.cc-tl-node.selected { background: var(--surface-2); border-radius: 8px; }
.cc-tl-title { font-size: 13.5px; font-weight: 650; }
.cc-tl-time { font-size: 11.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.cc-tl-desc { font-size: 12.5px; color: var(--muted); margin-top: 2px; line-height: 1.4; }
.cc-event-detail { grid-template-columns: 160px 1fr; }

/* Sezioni della card "Barcode di prova" (docs/34): separatori leggeri, campi non compressi. */
.bc-gen-section { border-top: 1px solid var(--border, rgba(128, 128, 128, 0.3)); margin-top: 12px; padding-top: 8px; }
.bc-gen-section:first-of-type { border-top: none; margin-top: 4px; }
.bc-gen-section h4 { margin: 0 0 6px; }
.bc-gen-card select, .bc-gen-card input[type="text"], .bc-gen-card input[type="number"] { max-width: 100%; }

/* ===== Sicurezza API e palmari (docs/36) =====
   Blocchi ben separati, pulsanti mai appiccicati a campi/testi, tabella chiavi leggibile.
   Il payload (che contiene la chiave API) non è mai a vista: sta dietro un <details>. */
.sec-card { margin-bottom: 22px; padding: 18px 20px; }
.sec-card > h3 { margin: 0 0 10px; }
.sec-card > .hint { margin: 0 0 14px; line-height: 1.5; }

/* Campo = label + input + hint, con respiro verticale. */
.sec-field { margin: 0 0 16px; }
.sec-field > label { margin-bottom: 5px; }
.sec-field > .hint { margin: 6px 0 0; }
.sec-field:last-child { margin-bottom: 0; }

/* Ogni gruppo di pulsanti della sezione usa lo STESSO pattern: mai bottoni incollati
   (né tra loro né al campo/testo sopra), con wrap su schermi stretti. */
.sec-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 16px; }
.sec-actions:first-child { margin-top: 0; }
/* Gruppo pulsanti in coda a un blocco (es. QR: Scarica SVG / Scarica PNG). */
.sec-actions + .sec-details { margin-top: 18px; }

/* Input + pulsante affiancati senza incollarsi (es. "Copia chiave", "Test chiave"):
   su schermo stretto il bottone va a capo mantenendo il gap. */
.sec-inline { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.sec-inline input[type="text"] { flex: 1 1 320px; margin-top: 0; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }
.sec-inline button { flex: 0 0 auto; }

/* Esito del "Test chiave": verde se valida, rosso se non valida/revocata, giallo se non
   verificabile (rete/backend). */
.sec-test-result { margin: 10px 0 0; font-size: 13px; font-weight: 700; }
.sec-test-result.ok { color: var(--success); }
.sec-test-result.ko { color: var(--danger); }
.sec-test-result.warn { color: var(--warning); }

.sec-grid { gap: 14px 20px; margin-bottom: 0; }

/* Card della chiave appena generata: evidenziata, è l'unica volta che si vede il valore. */
.sec-highlight { border-color: var(--primary); background: var(--primary-weak); }
.sec-warn { color: var(--warning); font-weight: 600; }

/* Tabella chiavi: scrollabile su schermi stretti, righe respirate. */
.sec-table-wrap { overflow-x: auto; }
.sec-table-wrap table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.sec-table-wrap th, .sec-table-wrap td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.sec-table-wrap th { color: var(--muted); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
.sec-table-wrap tr.sec-row-revoked td { color: var(--muted); }
.sec-table-wrap td.sec-alias { font-weight: 700; white-space: normal; min-width: 180px; }
.sec-table-wrap td.sec-cell-actions { text-align: right; }
/* Chiave palmari attiva = utilizzabile in "Configura palmare". */
.sec-table-wrap tr.sec-row-usable { background: var(--primary-weak); }

.badge.ok { background: var(--success); color: #fff; }
.badge.revoked { background: var(--danger); color: #fff; }
.badge.config { background: var(--warning); color: #fff; }
.badge.scope { background: var(--surface-3); color: var(--text); border: 1px solid var(--border-strong); }
.badge.plain { margin-left: 0; }

/* QR e barcode: immagini su fondo bianco (leggibilità scanner anche in dark mode). */
.sec-code { display: inline-block; background: #fff; padding: 12px; border-radius: 8px; border: 1px solid var(--border); }
.sec-code svg { display: block; max-width: 100%; height: auto; }

.sec-details { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 12px; }
.sec-details > summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--muted); }
.sec-payload {
    margin: 10px 0 0; padding: 10px 12px; background: var(--surface-3); border: 1px solid var(--border);
    border-radius: 8px; font-size: 12.5px; white-space: pre-wrap; word-break: break-all;
    font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
}

/* Barcode lineari: uno per campo, ciascuno con etichetta. */
.sec-barcode { margin-bottom: 18px; }
.sec-barcode:last-child { margin-bottom: 0; }
.sec-barcode-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.sec-barcode-label { font-weight: 700; font-size: 13.5px; }
.sec-barcode-value { color: var(--muted); font-size: 12.5px; word-break: break-all; font-family: ui-monospace, Consolas, monospace; }

/* ===== Accesso admin (docs/36) =====
   Il portale (#admin-shell) resta display:none finché la chiave admin non è verificata: nessun
   contenuto è visibile dietro la richiesta di accesso (non è un overlay trasparente). */
.admin-auth {
    position: fixed; inset: 0; z-index: 1000;
    display: flex; align-items: center; justify-content: center;
    padding: 24px; background: var(--surface-2);
}
.admin-auth.hidden { display: none; }
.admin-auth-card {
    width: 100%; max-width: 380px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
    padding: 28px; box-shadow: var(--shadow-sm); text-align: center;
}
.admin-auth-logo { height: 40px; margin-bottom: 16px; }
.admin-auth-card h1 { margin: 0 0 8px; font-size: 18px; }
.admin-auth-card .hint { margin: 0 0 20px; line-height: 1.5; }
.admin-auth-card label { text-align: left; margin-bottom: 6px; }
.admin-auth-card input { margin-bottom: 16px; }
.admin-auth-card button { width: 100%; justify-content: center; }
.admin-auth-error { margin: 0 0 16px; color: var(--danger); font-size: 13px; font-weight: 700; }
.admin-auth-error.hidden { display: none; }

/* ---------- Orchestrator (unica aggiunta rispetto ad admin.css del backend) ---------- */
/* Codice di registrazione mostrato una sola volta: grande e copiabile. */
.cc-code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 20px; font-weight: 700; letter-spacing: 1px; margin: 4px 0 8px; user-select: all; }
/* Riga in modifica nelle tabelle anagrafiche. */
.cc-table tr.cc-row-selected td { background: var(--primary-weak); }
/* QR della MFA al primo accesso (SVG generato dal server). */
.cc-qr { display: flex; justify-content: center; margin: 0 0 8px; }
.cc-qr svg { width: 200px; height: 200px; }
.cc-code-small { font-size: 14px; word-break: break-all; }
/* Visibilità per ruolo: classi sul body impostate dopo l'accesso. */
body:not(.role-Admin) .req-admin { display: none !important; }
body.role-ReadOnly .req-tech { display: none !important; }
/* Password provvisoria: solo "Il mio profilo". */
body.must-change .cc-nav-item:not([data-view="profile"]), body.must-change .cc-nav-label { display: none !important; }
/* Ruolo modificabile nella tabella utenti; azioni su più righe se lo spazio non basta. */
.cc-table select.cc-role { width: 150px; margin: 0; }
#users-tbody .cc-actions { white-space: normal; }
#users-tbody .cc-actions button { margin: 2px 6px 2px 0; white-space: nowrap; }
#users-tbody .cc-actions button + button { margin-left: 0; }
