/* ============================================================
   app_components.css — stili per overlay, modal, tabelle
   ============================================================ */

/* === LAYOUT PANNELLO PAGINA ================================= */
.page-panel {
    flex: 1;
    min-height: 100%;
    display: flex;
    flex-direction: column;
    padding: 10px 13px 7px;
    overflow: hidden;
}
.page-header {
    flex-shrink: 0;
    display: flex;
    align-items: baseline;
    gap: 12px;
    padding-bottom: 10px;
    position: relative;
    height: 50px;
}
.page-header h2 {
    margin: 0;
    font-size: 1.2rem;
}
.page-header .close {
    margin-left: auto;
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    padding: 2px 8px;
    font-size: 12px;
    color: var(--text2);
    flex-shrink: 0;
}
.page-header .close:hover { background: rgba(0,0,0,0.06); }
.page-msg {
    flex-shrink: 0;
    min-height: 1.4em;
    font-size: 0.88em;
    padding: 2px 0 4px;
}
.page-body {
    flex: 1;
    max-height: calc( 100vh - 240px);
    overflow-y: auto;
    scrollbar-width: thin;
}
.page-footer {
    flex-shrink: 0;
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    align-items: center;
    margin-top: 12px;
    padding: 14px 16px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: linear-gradient(
        165deg,
        rgba(0, 0, 0, 0.28) 0%,
        rgba(20, 40, 24, 0.35) 100%
    );
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

@media (min-width: 900px) {
    .page-footer {
        grid-template-columns: minmax(0, 1fr) minmax(0, 0.7fr) auto;
        gap: 16px 20px;
    }
}

/* ── zone footer (legacy) ── */
.footer-left   { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.footer-center { display: flex; align-items: center; gap: 6px; flex: 1; justify-content: center; }
.footer-right  { display: flex; align-items: center; gap: 4px; flex: 0 0 auto; margin-left: auto; }

/* ── paginazione (legacy classi) ── */
.footer-page-info { font-size: 12px; color: rgba(255,255,255,.55); white-space: nowrap; }
.footer-perpage {
    background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.14);
    color: #e8f0e9; border-radius: 8px; padding: 6px 10px; font-size: 12px; cursor: pointer;
    font-family: var(--font-s, inherit);
}
.footer-perpage:focus { outline: none; border-color: rgba(143, 201, 58, 0.45); box-shadow: 0 0 0 2px rgba(143, 201, 58, 0.15); }

/* ── bottoni footer (legacy) ── */
.btn-fnav {
    background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.15);
    color: rgba(255,255,255,.75); border-radius: 8px; padding: 6px 12px;
    font-size: 12px; font-weight: 500; cursor: pointer; transition: background .15s, color .15s, border-color .15s;
}
.btn-fnav:hover { background: rgba(255,255,255,.14); color: #fff; border-color: rgba(255,255,255,.22); }

.btn-fadd {
    background: linear-gradient(135deg, var(--moss, #2d6a35), var(--leaf, #4a9e55));
    border: 1px solid rgba(143, 201, 58, 0.35);
    color: #f0fff4; border-radius: 8px; padding: 6px 16px;
    font-size: 12px; font-weight: 600; cursor: pointer;
    transition: filter .15s, box-shadow .15s, transform .1s;
    box-shadow: 0 2px 8px rgba(45, 106, 53, 0.35);
}
.btn-fadd:hover {
    filter: brightness(1.08);
    box-shadow: 0 4px 14px rgba(45, 106, 53, 0.45);
}

.btn-fdel {
    background: rgba(120, 24, 24, 0.55); border: 1px solid rgba(220, 100, 100, 0.45);
    color: #ffd6d6; border-radius: 8px; padding: 6px 16px;
    font-size: 12px; font-weight: 600; cursor: pointer;
    transition: background .15s, box-shadow .15s;
}
.btn-fdel:hover { background: rgba(160, 36, 36, 0.65); box-shadow: 0 2px 12px rgba(180, 40, 40, 0.35); }

.footer-sel-label { font-size: 11px; color: rgba(255,255,255,.45); letter-spacing: 0.02em; }

/* === Toolbar tabelle: gruppi + bottoni ================================= */
.tbl-pager {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 14px;
}

.tbl-toolbar-group {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.tbl-count-label {
    font-size: 12px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.88);
    white-space: nowrap;
}

.tbl-toolbar-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgba(255, 255, 255, 0.42);
    white-space: nowrap;
}

.tbl-page-size {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 4px 4px 10px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.tbl-perpage-select,
.tbl-pager select.tbl-perpage-select {
    appearance: none;
    min-width: 52px;
    padding: 8px 28px 8px 12px;
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font-s, inherit);
    color: rgba(255, 255, 255, 0.92);
    background-color: rgba(255, 255, 255, 0.06);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23a8c4aa' d='M3 4.5L6 8l3-3.5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 8px;
    cursor: pointer;
    transition: border-color .15s, background .15s, box-shadow .15s;
}

.tbl-perpage-select:hover,
.tbl-pager select:hover {
    border-color: rgba(143, 201, 58, 0.35);
    background-color: rgba(255, 255, 255, 0.09);
}

.tbl-perpage-select:focus,
.tbl-pager select:focus {
    outline: none;
    border-color: rgba(143, 201, 58, 0.55);
    box-shadow: 0 0 0 2px rgba(143, 201, 58, 0.18);
}

.tbl-toolbar-nav {
    padding: 4px 6px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.08);
    gap: 6px;
}

.tbl-page-indicator {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.55);
    padding: 0 8px;
    white-space: nowrap;
}

.tbl-page-indicator strong {
    color: rgba(255, 255, 255, 0.95);
    font-weight: 700;
}

.tbl-page-of {
    font-weight: 400;
    opacity: 0.85;
}

/* Bottoni toolbar — sostituiscono .min-button nel footer */
.btn-ft {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin: 0;
    padding: 8px 16px;
    font-family: var(--font-s, inherit);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
    line-height: 1.2;
    border-radius: 9px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .1s;
}

.btn-ft:active {
    transform: translateY(1px);
}

.btn-ft-icon {
    min-width: 38px;
    padding: 8px 10px;
    font-size: 18px;
    font-weight: 700;
    line-height: 1;
    color: rgba(255, 255, 255, 0.88);
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(255, 255, 255, 0.14);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.btn-ft-icon:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.22);
    color: #fff;
}

.btn-ft-primary {
    color: #f4fff6;
    background: linear-gradient(145deg, var(--moss, #2d6a35), #25662d);
    border-color: rgba(143, 201, 58, 0.4);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.btn-ft-primary:hover {
    filter: brightness(1.07);
    box-shadow: 0 4px 16px rgba(45, 106, 53, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.btn-ft-danger {
    color: #ffe8e8;
    background: rgba(140, 32, 32, 0.55);
    border-color: rgba(255, 120, 120, 0.35);
}

.btn-ft-danger:hover {
    background: rgba(170, 42, 42, 0.7);
    border-color: rgba(255, 160, 160, 0.45);
}

.btn-ft-secondary {
    color: rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.16);
}

.btn-ft-secondary:hover {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.24);
}

.btn-ft-ghost {
    color: rgba(255, 255, 255, 0.82);
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.12);
    font-size: 11px;
    padding: 4px 10px;
}

.btn-ft-ghost:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(143, 201, 58, 0.35);
}

.page-footer .min-button {
    margin: 0;
}

.page-footer .tbl-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 12px;
    padding: 4px 0;
    width: max-content;
}

.tbl-actions-label {
    font-size: 12px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.48);
    letter-spacing: 0.02em;
}

/* === OVERLAY BACKDROP ======================================= */
.overlay {
    display: flex;
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 999;
    height: 100%;
    align-items: center;
    justify-content: center;
}

/* Reset posizionamento login-container dentro overlay
   (sovrascrive left:50%/top:50%/transform di .login-container) */
.overlay .login-container {
    position: relative;
    left: auto;
    top: auto;
    transform: none;
    overflow-y: auto;
}

/* === MODAL BOX (dimensioni) ================================= */
.modal-sm { width: 500px; max-width: 98vw; }
.modal-md {width: 100%;}

/* === CLOSE BUTTON NEL MODAL ================================= */
.modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
}

/* === COLOR PICKER INPUTS ==================================== */
.input-color {
    width: 24px;
    height: 24px;
    padding: 0px;
    border: none;
    cursor: pointer;
    border-radius: 4px;
}
.input-color-lg {
    width: 60px;
    height: 34px;
    padding: 1px !important;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
}

/* === PASTEL SWATCH PICKER =================================== */
.cp-wrap   { position: relative; display: inline-flex; align-items: center; }
.cp-swatch { width: 30px; height: 30px; border-radius: 6px; cursor: pointer; flex-shrink: 0;
             border: 2px solid rgba(255,255,255,.2); transition: border-color .15s, box-shadow .15s; }
.cp-swatch:hover { border-color: rgba(255,255,255,.55); box-shadow: 0 0 0 3px rgba(255,255,255,.1); }
.cp-palette {
              position: absolute;
              top: 36px;
              left: 0;
              z-index: 300;
              background: #16213e;
              border: 1px solid #1e4080;
              border-radius: 8px;
              padding: 8px;
              display: grid;
              grid-template-columns: repeat(5, 26px);
              gap: 5px;
              box-shadow: 0 8px 24px rgba(0,0,0,.55);
              }
.cp-option  { width: 26px; height: 26px; border-radius: 5px; cursor: pointer;
              border: 2px solid transparent; transition: border-color .1s, transform .1s; }
.cp-option:hover  { border-color: rgba(255,255,255,.75); transform: scale(1.15); }
.cp-option.cp-sel { border-color: #fff; box-shadow: 0 0 0 1px rgba(255,255,255,.35); }

/* === SORT HEADERS =========================================== */
th.th-sort {
    cursor: pointer;
    user-select: none;
    white-space: normal;
    transition: background 0.2s, box-shadow 0.2s, color 0.2s;
}
th.th-sort .sort-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.4em;
    margin-left: 8px;
    font-size: 15px;
    line-height: 1;
    font-weight: 800;
    vertical-align: middle;
    color: currentColor;
    opacity: 0.55;
    transition: opacity 0.15s, color 0.15s, transform 0.15s, filter 0.15s;
}
th.th-sort:hover .sort-icon {
    opacity: 0.95;
}
/* Colonna con ordinamento attivo: evidenza sull’intera cella */
th.th-sort.sort-active {
    font-weight: 700;
    letter-spacing: 0.02em;
    background: linear-gradient(
        90deg,
        rgba(143, 201, 58, 0.42) 0%,
        rgba(143, 201, 58, 0.18) 50%,
        rgba(143, 201, 58, 0.08) 100%
    );
    box-shadow:
        inset 5px 0 0 0 var(--leaf, #4a9e55),
        inset 0 -3px 0 0 rgba(45, 106, 53, 0.65);
}
th.th-sort.sort-active .sort-icon {
    opacity: 1;
    font-size: 17px;
    color: var(--moss, #2d6a35);
    transform: scale(1.12);
    filter: drop-shadow(0 0 8px rgba(143, 201, 58, 0.65));
}

/* === RICERCA TABELLE ======================================= */
.page-footer .tbl-search-wrap {
    position: relative;
    margin-left: auto;
    justify-self: end;
    width: 100%;
    max-width: 280px;
}

@media (max-width: 899px) {
    .page-footer .tbl-search-wrap {
        max-width: none;
    }
}

.tbl-search-wrap {
    display: flex;
    align-items: stretch;
    gap: 0;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.22);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
    overflow: hidden;
    transition: border-color .2s, box-shadow .2s;
}

.tbl-search-wrap:focus-within {
    border-color: rgba(143, 201, 58, 0.45);
    box-shadow: 0 0 0 2px rgba(143, 201, 58, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.tbl-search-wrap::before {
    content: "";
    flex-shrink: 0;
    width: 42px;
    background: rgba(255, 255, 255, 0.04) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23a8c4aa' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M21 21l-4.3-4.3'/%3E%3C/svg%3E") no-repeat center center;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.tbl-search-wrap input,
.tbl-search-wrap .tbl-search-input {
    flex: 1;
    min-width: 0;
    width: auto;
    margin: 0;
    padding: 10px 12px;
    font-size: 13px;
    font-family: var(--font-s, inherit);
    color: rgba(255, 255, 255, 0.95);
    background: transparent;
    border: none;
    border-radius: 0;
}

.tbl-search-wrap input::placeholder {
    color: rgba(255, 255, 255, 0.38);
}

.tbl-search-wrap input:focus {
    outline: none;
}

.tbl-search-clear {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    margin: 0;
    padding: 0;
    font-size: 15px;
    line-height: 1;
    color: rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.04);
    border: none;
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    cursor: pointer;
    transition: color .15s, background .15s;
}

.tbl-search-clear:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.tbl-pager input[type="number"] {
    width: 60px;
}

/* === CELLE TABELLA ========================================== */
.td-center { text-align: center; }
.td-right  { text-align: right; }
.td-bold   { font-weight: bold; }
.td-small  { font-size: 0.85em; }
.td-email  { word-break: break-all; font-size: 0.85em; }
.tr-warn       { background: #ffe0e0; }
.azi-row-warn  { background: rgba(255,80,80,0.12) !important; }

.tbl-aziende .td-center{
    overflow: visible !important;
}

/* === SELECT RUOLO INLINE =================================== */
.select-role {
    width: 100%;
    font-size: 0.82em;
}

/* === FORM GRIGLIA 2 COLONNE ================================= */
.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

/* === TEXTAREA FULL WIDTH =================================== */
.full-width { width: 100%; }

/* === PANEL PERMESSI ======================================== */
#ep-matrix {
    display: none;
    margin-top: 16px;
}
.tbl-permissions {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
}
.tbl-permissions th {
    padding: 8px;
    border-bottom: 2px solid #ccc;
}
.tbl-permissions .th-left   { text-align: left; }
.tbl-permissions .th-center { text-align: center; width: 80px; }
.tbl-permissions td {
    padding: 8px 6px;
    border-bottom: 1px solid #eee;
}
.tbl-permissions .td-center { text-align: center; }
.perm-actions {
    margin-top: 14px;
    display: flex;
    gap: 10px;
}
.perm-hint {
    font-size: 0.85em;
    color: #1a3464;
    margin-bottom: 14px;
}
.perm-default-label {
    font-size: 0.75em;
    color: #1a3464;
    opacity: 0.6;
    margin-left: 6px;
}
.ea-check, .eu-check, .ebm-check, .ecns-check, .eprl-check,
.ef-check, .est-check, .etr-check, .eim-check, .elot-check {
    width: 20px;
    height: 20px;
    border: 1px solid var(--border);
    color: var(--text2);
    background: none;
}
.ea-button, .eu-button, .ebm-button, .ecns-button, .eprl-button,
.ef-button, .est-button, .etr-button, .eim-button, .elot-button {
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    padding: 0px;
    font-size: 12px;
    color: var(--text2);
    width: 22px;
    height: 22px;
    align-items: center;
}
/* === LARGHEZZE COLONNE PER TABELLA ========================= */
table.tbl-aziende    col:nth-child(1) { width: 40px;  }
table.tbl-aziende    col:nth-child(2) { width: 40px; }
table.tbl-aziende    col:nth-child(3) { width: 40px; }
table.tbl-aziende    col:nth-child(4) { width: auto; }
table.tbl-aziende    col:nth-child(5) { width: 20%; }
table.tbl-aziende    col:nth-child(6) { width: 200px; }

table.tbl-elenco-user col:nth-child(1) { width: 40px; }
table.tbl-elenco-user col:nth-child(2) { width: 40px; }
table.tbl-elenco-user col:nth-child(3) { width: 50px; }
table.tbl-elenco-user col:nth-child(4) { width: auto; }
table.tbl-elenco-user col:nth-child(5) { width: 14%; }
table.tbl-elenco-user col:nth-child(6) { width: 20%; }
table.tbl-elenco-user col:nth-child(7) { width: 10%; }

table.tbl-fornitori  col:nth-child(1) { width: 40px;  }
table.tbl-fornitori  col:nth-child(2) { width: 40px; }
table.tbl-fornitori  col:nth-child(3) { width: auto; }
table.tbl-fornitori  col:nth-child(4) { width: 24%; }
table.tbl-fornitori  col:nth-child(5) { width: 10%; }
table.tbl-fornitori  col:nth-child(6) { width: 16%; }
table.tbl-fornitori  col:nth-child(7) { width: 110px; }

table.tbl-trasportatori col:nth-child(1) { width: 40px;  }
table.tbl-trasportatori col:nth-child(2) { width: 40px; }
table.tbl-trasportatori col:nth-child(3) { width: 28%; }
table.tbl-trasportatori col:nth-child(4) { width: 26%; }
table.tbl-trasportatori col:nth-child(5) { width: 18%; }
table.tbl-trasportatori col:nth-child(6) { width: 24%; }

table.tbl-impianti   col:nth-child(1) { width: 40px; }
table.tbl-impianti   col:nth-child(2) { width: 40px; }
table.tbl-impianti   col:nth-child(3) { width: auto; }
table.tbl-impianti   col:nth-child(4) { width: 35%; }

table.tbl-stabilimenti col:nth-child(1) { width: 40px; }
table.tbl-stabilimenti col:nth-child(2) { width: 40px; }
table.tbl-stabilimenti col:nth-child(3) { width: 26%; }
table.tbl-stabilimenti col:nth-child(4) { width: 24%; }
table.tbl-stabilimenti col:nth-child(5) { width: 20%; }
table.tbl-stabilimenti col:nth-child(6) { width: 26%; }

table.tbl-biomasse   col:nth-child(1) { width: 40px; }
table.tbl-biomasse   col:nth-child(2) { width: 40px; }
table.tbl-biomasse   col:nth-child(3) { width: auto; }
table.tbl-biomasse   col:nth-child(4) { width: 10%; }
table.tbl-biomasse   col:nth-child(5) { width: 8%;  }
table.tbl-biomasse   col:nth-child(6) { width: 10%; }
table.tbl-biomasse   col:nth-child(7) { width: 10%; }
table.tbl-biomasse   col:nth-child(8) { width: 16%; }
table.tbl-biomasse   col:nth-child(9) { width: 10%; }
table.tbl-biomasse   col:nth-child(10){ width: 10%; }

table.tbl-lotti      col:nth-child(1)  { width: 40px; }
table.tbl-lotti      col:nth-child(2)  { width: 40px; }
table.tbl-lotti      col:nth-child(3)  { width: 18%; }
table.tbl-lotti      col:nth-child(4)  { width: 18%; }
table.tbl-lotti      col:nth-child(5)  { width: 10%; }
table.tbl-lotti      col:nth-child(6)  { width: 8%;  }
table.tbl-lotti      col:nth-child(7)  { width: 10%; }
table.tbl-lotti      col:nth-child(8)  { width: 10%; }
table.tbl-lotti      col:nth-child(9)  { width: 10%; }
table.tbl-lotti      col:nth-child(10) { width: 12%; }

table.tbl-consegne   col:nth-child(1) { width: 40px; }
table.tbl-consegne   col:nth-child(2) { width: 40px; }
table.tbl-consegne   col:nth-child(3) { width: 12%; }
table.tbl-consegne   col:nth-child(4) { width: auto; }
table.tbl-consegne   col:nth-child(5) { width: 10%; }
table.tbl-consegne   col:nth-child(6) { width: 10%; }
table.tbl-consegne   col:nth-child(7) { width: 15%; }
table.tbl-consegne   col:nth-child(8) { width: 15%; }
table.tbl-consegne   col:nth-child(9) { width: 10%; }

table.tbl-prelievi   col:nth-child(1) { width: 40px; }
table.tbl-prelievi   col:nth-child(2) { width: 40px; }
table.tbl-prelievi   col:nth-child(3) { width: 12%; }
table.tbl-prelievi   col:nth-child(4) { width: auto; }
table.tbl-prelievi   col:nth-child(5) { width: 10%; }
table.tbl-prelievi   col:nth-child(6) { width: 10%; }
table.tbl-prelievi   col:nth-child(7) { width: 14%; }
table.tbl-prelievi   col:nth-child(8) { width: 10%; }
table.tbl-prelievi   col:nth-child(9) { width: 12%; }
table.tbl-prelievi   col:nth-child(10){ width: 10%; }

/* ================================================================
   AZIENDE — redesign SaaS Enterprise (scoped .azi-*)
   ================================================================ */

/* ── Panel overrides ─────────────────────────────────────────────── */
.azi-panel .page-header      { display: none; }
.azi-panel                   { padding-top: 6px; }
.azi-panel .page-body        { max-height: calc(100vh - 190px); }
/* Footer trasparente per tutti i panel che usano azi-toolbar */
.azi-panel .page-footer,
.eu-panel .page-footer,
.page-panel .page-footer {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 10px 0 4px;
}
.azi-pager-slot { width: 100%; }

/* ── White card ─────────────────────────────────────────────────── */
.azi-card {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,.07), 0 4px 18px rgba(0,0,0,.06);
    overflow: hidden;
    padding: 0 30px 20px;
}

/* ── Table base ─────────────────────────────────────────────────── */
.tbl-aziende-v2 {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    margin: 0;
}

/* ── Header row ─────────────────────────────────────────────────── */
.tbl-aziende-v2 thead tr {
    background: #ffffff;
    border-bottom: 2px solid #f0f0f0;
}
.tbl-aziende-v2 thead th {
    padding: 14px 14px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: #9ca3af;
    text-align: left;
    white-space: nowrap;
    height: auto;
}
/* Numeric columns right alignment */
.tbl-aziende-v2 thead th:nth-child(4) { text-align: right; } /* Q.tà (t) */
.tbl-aziende-v2 thead th:nth-child(5) { text-align: right; } /* Palate */
.tbl-aziende-v2 thead th:last-child   { padding: 14px 8px; }

/* Sort overrides inside azi card */
.tbl-aziende-v2 th.th-sort            { color: #9ca3af; }
.tbl-aziende-v2 th.th-sort:hover      { color: #6b7280; background: #f9fafb; }
.tbl-aziende-v2 th.th-sort.sort-active {
    color: #111827;
    background: #f9fafb;
    box-shadow: none;
    letter-spacing: 0.07em;
    font-weight: 700;
}
.tbl-aziende-v2 th.th-sort.sort-active .sort-icon {
    color: #16a34a;
    filter: none;
    font-size: 13px;
}

/* ── Data rows ──────────────────────────────────────────────────── */
.azi-row {
    height: 56px;
    background: #ffffff;
    border-bottom: 1px solid #f3f4f6;
    transition: background .12s;
}
.azi-row-alt           { background: #fafafa; }
.azi-row:hover         { background: #f0fdf4; }
.azi-row td            { vertical-align: middle; padding: 0 14px; height: 56px; }

/* ── Color bar ─────────────────────────────────────────────────── */
.azi-color-bar {
    padding: 0 !important;
    width: 5px !important;
    border: none !important;
}

/* ── Checkbox ──────────────────────────────────────────────────── */
.azi-cb            { text-align: center; }
.azi-cb input      { width: 16px; height: 16px; cursor: pointer; accent-color: #16a34a; }

/* ── Nome ──────────────────────────────────────────────────────── */
.azi-nome {
    font-weight: 600;
    font-size: 14px;
    color: #111827;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Partita IVA ───────────────────────────────────────────────── */
.azi-piva { font-size: 13px; color: #6b7280; }

/* ── Data ──────────────────────────────────────────────────────── */
.azi-data {
    font-size: 12px;
    color: #9ca3af;
    text-align: left;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* ── Edit button (hover only) ──────────────────────────────────── */
.azi-actions-cell  { text-align: center; padding: 0 8px !important; }
.azi-edit-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: none;
    border: 1px solid #d1d5db;
    border-radius: 7px;
    color: #6b7280;
    cursor: pointer;
    transition: border-color .15s, color .15s, background .15s;
}
.azi-row:hover .azi-edit-btn     { display: inline-flex; }
.azi-edit-btn:hover              { border-color: #16a34a; color: #16a34a; background: #f0fdf4; }

/* ── Glassmorphism toolbar ─────────────────────────────────────── */
.azi-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: rgba(18, 18, 18, 0.90);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: none;
    border-top: 1px solid #333333;
    border-radius: 20px;
    box-shadow: none;
    width: 100%;
    box-sizing: border-box;
}
.azi-tb-left  { display: flex; align-items: center; gap: 14px; flex-shrink: 0; }
.azi-tb-center{ display: flex; align-items: center; gap: 8px; flex: 1; justify-content: center; }
.azi-tb-right { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }

.azi-count {
    font-size: 12px;
    font-weight: 600;
    color: #ffffff;
    white-space: nowrap;
}
.azi-perpage-wrap  { display: inline-flex; align-items: center; gap: 7px; }
.azi-tb-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgba(255,255,255,.60);
    white-space: nowrap;
}
.azi-perpage-select {
    appearance: none;
    min-width: 52px;
    padding: 6px 24px 6px 10px;
    font-size: 12px;
    font-weight: 600;
    color: rgba(255,255,255,.88);
    background: rgba(255,255,255,.07) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23a8c4aa' d='M3 4.5L6 8l3-3.5z'/%3E%3C/svg%3E") no-repeat right 8px center;
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 8px;
    cursor: pointer;
}
.azi-nav-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    font-size: 22px;
    font-weight: 700;
    line-height: 1;
    color: rgba(255,255,255,.72);
    background: rgba(255,255,255,.07);
    border: 1px solid rgba(255,255,255,.14);
    border-radius: 8px;
    cursor: pointer;
    transition: background .15s, color .15s;
}
.azi-nav-btn:hover  { background: rgba(255,255,255,.13); color: #fff; }
.azi-page-info      { font-size: 13px; color: rgba(255,255,255,.80); white-space: nowrap; padding: 0 4px; }
.azi-page-info strong { color: #ffffff; font-weight: 700; }

.azi-btn-delete {
    padding: 8px 16px;
    font-size: 12px;
    font-weight: 600;
    color: #ff6b6b;
    background: transparent;
    border: 1.5px solid #ff6b6b;
    border-radius: 10px;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s, color .15s, border-color .15s;
    margin-right: 8px;
}
.azi-btn-delete:hover { 
    background: rgba(255,107,107,.15);
    border-color: #ff5252;
}

.azi-btn-secondary {
    padding: 7px 16px;
    font-size: 12px;
    font-weight: 500;
    color: #60a5fa;
    background: transparent;
    border: 1px solid #60a5fa;
    border-radius: 10px;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s, color .15s;
}
.azi-btn-secondary:hover { background: rgba(96,165,250,.12); }

.azi-btn-add {
    padding: 8px 18px;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, #14e26a, #22c55e);
    border: 1.5px solid #14e26a;
    border-radius: 10px;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s, color .15s, border-color .15s, box-shadow .15s;
    box-shadow: 0 2px 6px rgba(20, 226, 106, 0.2);
}
.azi-btn-add:hover { 
    background: linear-gradient(135deg, #10d660, #16a34a);
    border-color: #0ba550;
    box-shadow: 0 4px 10px rgba(20, 226, 106, 0.35);
}

/* ── Search dentro toolbar ─────────────────────────────────────── */
.azi-search-wrap {
    display: flex;
    align-items: stretch;
    border-radius: 10px;
    background: rgba(255,255,255,.07);
    border: 1px solid rgba(255,255,255,.12);
    overflow: hidden;
    transition: border-color .2s, box-shadow .2s;
    min-width: 160px;
}
.azi-search-wrap:focus-within {
    border-color: rgba(20,226,106,.45);
    box-shadow: 0 0 0 2px rgba(20,226,106,.12);
}
.azi-search-wrap::before {
    content: "";
    flex-shrink: 0;
    width: 36px;
    background: rgba(255,255,255,.04) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M21 21l-4.3-4.3'/%3E%3C/svg%3E") no-repeat center;
    border-right: 1px solid rgba(255,255,255,.08);
}
.azi-search-input {
    flex: 1;
    min-width: 0;
    padding: 7px 8px;
    font-size: 12px;
    color: rgba(255,255,255,.92);
    background: transparent;
    border: none;
    outline: none;
}
.azi-search-input::placeholder { color: rgba(255,255,255,.55); }
.azi-search-clear {
    flex-shrink: 0;
    width: 30px;
    background: rgba(255,255,255,.04);
    border: none;
    border-left: 1px solid rgba(255,255,255,.08);
    color: rgba(255,255,255,.35);
    cursor: pointer;
    font-size: 13px;
    transition: color .15s, background .15s;
}
.azi-search-clear:hover { color: #fff; background: rgba(255,255,255,.10); }

/* ── Right-side drawer ─────────────────────────────────────────── */
.azi-drawer-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.32);
    z-index: 999;
    display: flex;
    justify-content: flex-end;
}
.azi-drawer-backdrop.invisible { display: none !important; }

.azi-drawer {
    width: 520px;
    max-width: 96vw;
    height: 100%;
    background: #ffffff;
    box-shadow: -8px 0 32px rgba(0,0,0,.18);
    display: flex;
    flex-direction: column;
    padding: 28px 24px 20px;
    overflow-y: auto;
    border-radius: 12px 0 0 12px;
    animation: azi-slide-in .2s ease;
    box-sizing: border-box;
}
@keyframes azi-slide-in {
    from { transform: translateX(100%); opacity: 0; }
    to   { transform: translateX(0);   opacity: 1; }
}

.azi-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 22px;
}
.azi-drawer-title {
    font-size: 17px;
    font-weight: 700;
    color: #111827;
    margin: 0;
}
.azi-drawer-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f3f4f6;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
    color: #6b7280;
    transition: background .15s, color .15s;
}
.azi-drawer-close:hover { background: #e5e7eb; color: #111827; }

.azi-drawer .form-group label {
    font-size: 11px;
    font-weight: 700;
    color: #374151;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.azi-drawer .form-group input[type="text"],
.azi-drawer .form-group input[type="email"],
.azi-drawer .form-group input[type="url"],
.azi-drawer .form-group input[type="number"],
.azi-drawer .form-group input[type="date"],
.azi-drawer .form-group select,
.azi-drawer .form-group textarea {
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px;
    color: #111827;
    background: #fff;
    width: 100%;
    box-sizing: border-box;
    transition: border-color .15s, box-shadow .15s;
}
.azi-drawer .form-group select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M3 4.5L6 8l3-3.5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
}
.azi-drawer .form-group textarea { resize: vertical; min-height: 72px; }
.azi-drawer .form-group input[type="text"]:focus,
.azi-drawer .form-group input[type="email"]:focus,
.azi-drawer .form-group input[type="url"]:focus,
.azi-drawer .form-group input[type="number"]:focus,
.azi-drawer .form-group input[type="date"]:focus,
.azi-drawer .form-group select:focus,
.azi-drawer .form-group textarea:focus {
    border-color: #16a34a;
    box-shadow: 0 0 0 3px rgba(22,163,74,.12);
    outline: none;
}

.azi-drawer-colore-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 0 0;
    margin-top: 8px;
    border-top: 1px solid #f3f4f6;
}
.azi-drawer-colore-label {
    font-size: 11px;
    font-weight: 700;
    color: #374151;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    flex-shrink: 0;
}

.azi-drawer-actions {
    margin-top: auto;
    padding-top: 24px;
    display: flex;
    gap: 16px;
}

@media (max-width: 768px) {
    .azi-drawer-actions {
        flex-wrap: wrap;
    }
    .azi-drawer-save {
        flex: 1;
        min-width: 120px;
    }
    .azi-drawer-camera {
        order: 2;
        flex: 1;
        min-width: 120px;
    }
    .azi-drawer-cancel {
        order: 3;
        flex: 1;
        min-width: 100px;
    }
}
.azi-drawer-save {
    flex: 1;
    padding: 13px 18px;
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #16a34a, #22c55e);
    border: none;
    border-radius: 9px;
    cursor: pointer;
    transition: filter .15s, transform .15s;
    box-shadow: 0 2px 8px rgba(22, 163, 74, 0.25);
}
    filter: brightness(1.07);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(22, 163, 74, 0.35);

.azi-drawer-save:hover { filter: brightness(1.07); }
.azi-drawer-cancel {
    padding: 13px 18px;
    font-size: 14px;
    font-weight: 600;
    color: #6b7280;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 9px;
    cursor: pointer;
    transition: background .15s, color .15s;
    min-width: 100px;
    text-align: center;
}
.azi-drawer-cancel:hover { background: #e5e7eb; }

.azi-drawer-camera {
    padding: 13px 18px;
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    border: none;
    border-radius: 9px;
    cursor: pointer;
    transition: filter .15s, transform .15s;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.25);
}
.azi-drawer-camera:hover {
    filter: brightness(1.07);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.35);
}

.azi-drawer-msg            { min-height: 1.3em; font-size: 13px; margin: 0 0 6px; }
.azi-drawer-msg.error      { color: #dc2626; }
.azi-drawer-msg.success    { color: #16a34a; }
.azi-drawer-msg.warning    { color: #d97706; }
.drawer-section-title {
    font-size: 11px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .06em; color: #6b7280;
    margin: 14px 0 4px; padding-bottom: 4px;
    border-bottom: 1px solid #e5e7eb;
}
.azi-checkbox-label { display: flex; align-items: center; gap: 7px; font-size: 13px; cursor: pointer; }
.azi-checkbox-label input[type="checkbox"] { width: 15px; height: 15px; cursor: pointer; }
[data-theme="dark"] .drawer-section-title { color: rgba(255,255,255,.4); border-bottom-color: rgba(255,255,255,.1); }

/* ============================================================
   ELENCO UTENTI — panel + table
   ============================================================ */

/* ── Panel overrides ─────────────────────────────────────────────── */
.eu-panel .page-header      { display: none; }
.eu-panel                   { padding-top: 6px; }
.eu-panel .page-body        { max-height: calc(100vh - 190px); }

/* ── Table base ─────────────────────────────────────────────────── */
.tbl-eu-v2 {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    margin: 0;
}

/* ── Header row ─────────────────────────────────────────────────── */
.tbl-eu-v2 thead tr {
    background: #ffffff;
    border-bottom: 2px solid #f0f0f0;
}
.tbl-eu-v2 thead th {
    padding: 14px 14px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: #9ca3af;
    text-align: left;
    white-space: nowrap;
    height: auto;
}
.tbl-eu-v2 thead th:last-child   { padding: 14px 8px; }
.tbl-eu-v2 thead th:nth-child(4) { text-align: right; }
.tbl-eu-v2 thead th:nth-child(5) { text-align: right; padding-right: 30px; }

/* Sort overrides inside eu card */
.tbl-eu-v2 th.th-sort            { color: #9ca3af; }
.tbl-eu-v2 th.th-sort:hover      { color: #6b7280; background: #f9fafb; }
.tbl-eu-v2 th.th-sort.sort-active {
    color: #111827;
    background: #f9fafb;
    box-shadow: none;
    letter-spacing: 0.07em;
    font-weight: 700;
}
.tbl-eu-v2 th.th-sort.sort-active .sort-icon {
    color: #16a34a;
    filter: none;
    font-size: 13px;
}

/* ── Cell styles ────────────────────────────────────────────────── */
.eu-nome {
    font-weight: 600;
    font-size: 14px;
    color: #111827;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.eu-mail {
    font-size: 13px;
    color: #6b7280;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.eu-telefono {
    font-size: 13px;
    color: #9ca3af;
    white-space: nowrap;
    text-align: right;
}
.eu-ruolo {
    padding: 0 30px 0 10px !important;
    text-align: right;
}

/* ── Role badge ─────────────────────────────────────────────────── */
.eu-role-badge {
    display: inline-block;
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 700;
    border-radius: 20px;
    white-space: nowrap;
    letter-spacing: 0.03em;
    margin-left: auto;
    width: stretch;
    text-align: center;
}
.eu-badge-superadmin { background: #ede9fe; color: #6d28d9; border: 1px solid #c4b5fd; }
.eu-badge-admin      { background: #dbeafe; color: #1d4ed8; border: 1px solid #93c5fd; }
.eu-badge-segadmin   { background: #ccfbf1; color: #0f766e; border: 1px solid #5eead4; }
.eu-badge-segretaria { background: #dcfce7; color: #15803d; border: 1px solid #86efac; }
.eu-badge-user       { background: #f3f4f6; color: #374151; border: 1px solid #d1d5db; }
.eu-badge-ospite     { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }

/* ── Reset password button ──────────────────────────────────────── */
.eu-btn-reset {
    padding: 7px 16px;
    font-size: 12px;
    font-weight: 500;
    color: #60a5fa;
    background: transparent;
    border: 1px solid #60a5fa;
    border-radius: 10px;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s, color .15s;
}
.eu-btn-reset:hover { background: rgba(96,165,250,.12); }

/* ══════════════════════════════════════════════════════════════
   TEMA SCURO — tabelle, card, drawer, form
══════════════════════════════════════════════════════════════ */

/* Card contenitore tabella */
[data-theme="dark"] .azi-card {
    background: #1a2018;
    box-shadow: 0 1px 3px rgba(0,0,0,.35), 0 4px 18px rgba(0,0,0,.30);
}

/* Header tabella aziende */
[data-theme="dark"] .tbl-aziende-v2 thead tr {
    background: #1a2018;
    border-bottom-color: rgba(255,255,255,.06);
}
[data-theme="dark"] .tbl-aziende-v2 thead th { color: rgba(255,255,255,.35); }
[data-theme="dark"] .tbl-aziende-v2 th.th-sort:hover      { background: rgba(255,255,255,.04); color: rgba(255,255,255,.6); }
[data-theme="dark"] .tbl-aziende-v2 th.th-sort.sort-active { background: rgba(255,255,255,.06); color: #e0f7fa; }

/* Righe tabella aziende */
[data-theme="dark"] .azi-row         { background: #141a15; border-bottom-color: rgba(255,255,255,.04); }
[data-theme="dark"] .azi-row-alt     { background: #171d18; }
[data-theme="dark"] .azi-row:hover   { background: rgba(143,201,58,.07); }
[data-theme="dark"] .azi-nome        { color: #e0f7fa; }
[data-theme="dark"] .azi-piva        { color: rgba(255,255,255,.4); }
[data-theme="dark"] .azi-data        { color: rgba(255,255,255,.3); }

/* Header tabella utenti */
[data-theme="dark"] .tbl-eu-v2 thead tr {
    background: #1a2018;
    border-bottom-color: rgba(255,255,255,.06);
}
[data-theme="dark"] .tbl-eu-v2 thead th { color: rgba(255,255,255,.35); }
[data-theme="dark"] .tbl-eu-v2 th.th-sort:hover      { background: rgba(255,255,255,.04); color: rgba(255,255,255,.6); }
[data-theme="dark"] .tbl-eu-v2 th.th-sort.sort-active { background: rgba(255,255,255,.06); color: #e0f7fa; }
[data-theme="dark"] .eu-nome { color: #e0f7fa; }

/* Drawer modifica/inserimento */
[data-theme="dark"] .azi-drawer {
    background: #1e2520;
    box-shadow: -8px 0 32px rgba(0,0,0,.45);
}
[data-theme="dark"] .azi-drawer-title { color: #e0f7fa; }
[data-theme="dark"] .azi-drawer-close { background: rgba(255,255,255,.08); color: rgba(255,255,255,.5); }
[data-theme="dark"] .azi-drawer-close:hover { background: rgba(255,255,255,.14); color: #fff; }
[data-theme="dark"] .azi-drawer .form-group label { color: rgba(255,255,255,.55); }
[data-theme="dark"] .azi-drawer .form-group input[type="text"],
[data-theme="dark"] .azi-drawer .form-group input[type="email"],
[data-theme="dark"] .azi-drawer .form-group input[type="url"],
[data-theme="dark"] .azi-drawer .form-group input[type="number"],
[data-theme="dark"] .azi-drawer .form-group input[type="date"],
[data-theme="dark"] .azi-drawer .form-group textarea {
    background: rgba(255,255,255,.06);
    border-color: rgba(255,255,255,.12);
    color: #e0f7fa;
}
[data-theme="dark"] .azi-drawer .form-group select {
    background-color: rgba(255,255,255,.06);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238fc93a' d='M3 4.5L6 8l3-3.5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    border-color: rgba(255,255,255,.12);
    color: #e0f7fa;
}

/* Pulsanti annulla nel drawer */
[data-theme="dark"] .azi-drawer-cancel { 
    background: rgba(255,255,255,.07); 
    color: rgba(255,255,255,.6);
    border: 1px solid rgba(255,255,255,.12);
}
[data-theme="dark"] .azi-drawer-cancel:hover { 
    background: rgba(255,255,255,.12);
    color: rgba(255,255,255,.8);
}

/* Testo generico nelle celle tabella */
[data-theme="dark"] .tbl-aziende-v2 td { color: #c0d4c2; }
[data-theme="dark"] .tbl-aziende-v2 td .cell-clamp { color: inherit; }

/* Cella espandibile: sottile hint visivo (cursor + underline su hover) per
   indicare che il click apre il popup col testo intero. Buono sia desktop
   che mobile (al tap parte l'azione, senza :hover). */
.tbl-aziende-v2 td .cell-clamp.ecns-cell-expand { cursor: pointer; position: relative; }
.tbl-aziende-v2 td .cell-clamp.ecns-cell-expand:hover { text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 2px; }
[data-theme="dark"] .tbl-aziende-v2 td .cell-clamp.ecns-cell-expand:hover { color: #a7f3d0; }

/* Cella-link verso un'altra pagina (es. biomassa di consegne/prelievi che
   apre il lotto). Stile esplicito da "link": cursor pointer, colore tipo
   link, sempre sottolineato — molto più visibile dell'expand. */
.tbl-aziende-v2 td .cell-clamp.ecns-cell-link {
    cursor: pointer;
    color: #2563eb;
    text-decoration: underline;
    text-decoration-style: solid;
    text-underline-offset: 2px;
    font-weight: 500;
}
.tbl-aziende-v2 td .cell-clamp.ecns-cell-link:hover {
    color: #1d4ed8;
    text-decoration-style: solid;
}
[data-theme="dark"] .tbl-aziende-v2 td .cell-clamp.ecns-cell-link {
    color: #60a5fa;
}
[data-theme="dark"] .tbl-aziende-v2 td .cell-clamp.ecns-cell-link:hover {
    color: #93c5fd;
}

/* Testo nel drawer dettaglio (p, label generici) */
[data-theme="dark"] .azi-drawer .form-group p { color: #e0f7fa; }
[data-theme="dark"] .azi-drawer a            { color: #8fc93a; }

/* Riga colore e label */
[data-theme="dark"] .azi-drawer-colore-row   { border-top-color: rgba(255,255,255,.07); }
[data-theme="dark"] .azi-drawer-colore-label { color: rgba(255,255,255,.55); }

/* Messaggio drawer */
[data-theme="dark"] .azi-drawer-msg.error   { color: #f87171; }
[data-theme="dark"] .azi-drawer-msg.success { color: #4ade80; }

/* ══════════════════════════════════════════════════════════════
   TEMA CHIARO — toolbar e controlli tabella
══════════════════════════════════════════════════════════════ */
[data-theme="light"] .azi-toolbar {
    background: #ffffff;
    border-top: 1px solid #e5e7eb;
    box-shadow: 0 -1px 8px rgba(0,0,0,.06);
}
[data-theme="light"] .azi-tb-label  { color: #6b7280; }
[data-theme="light"] .azi-count     { color: #374151; }
[data-theme="light"] .azi-page-info { color: #374151; }
[data-theme="light"] .azi-page-info strong { color: #111827; }

[data-theme="light"] .azi-nav-btn {
    color: #374151;
    background: #f3f4f6;
    border-color: #d1d5db;
}
[data-theme="light"] .azi-nav-btn:hover { background: #e5e7eb; color: #111827; }

[data-theme="light"] .azi-perpage-select {
    color: #374151;
    background-color: #f9fafb;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M3 4.5L6 8l3-3.5z'/%3E%3C/svg%3E");
    border-color: #d1d5db;
}

[data-theme="light"] .azi-search-wrap {
    background: #f9fafb;
    border-color: #d1d5db;
}
[data-theme="light"] .azi-search-wrap:focus-within {
    border-color: #4a9e55;
    box-shadow: 0 0 0 2px rgba(74,158,85,.13);
}
[data-theme="light"] .azi-search-wrap::before {
    background-color: #f3f4f6;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M21 21l-4.3-4.3'/%3E%3C/svg%3E") no-repeat center;
    border-right-color: #e5e7eb;
}
[data-theme="light"] .azi-search-input {
    color: #111827;
}
[data-theme="light"] .azi-search-input::placeholder { color: #9ca3af; }
[data-theme="light"] .azi-search-clear {
    background: #f3f4f6;
    border-left-color: #e5e7eb;
    color: #9ca3af;
}
[data-theme="light"] .azi-search-clear:hover { background: #e5e7eb; color: #374151; }

/* ============================================================
   MOBILE — max-width: 768px
   ============================================================ */
@media (max-width: 768px) {

    /* ── Padding ridotti ─────────────────────────────────────── */
    .page-panel {
        padding: 6px 8px 4px;
        overflow: visible;          /* non clippa l'asse X */
    }
    .azi-panel  { padding-top: 4px; }
    .eu-panel   { padding-top: 4px; }

    /* ── page-body: scroll verticale, non clippa l'orizzontale ── */
    .page-body {
        overflow-y: auto;
        overflow-x: visible;
        max-height: calc(100dvh - 170px);
    }
    .azi-panel .page-body,
    .eu-panel  .page-body {
        max-height: calc(100dvh - 155px);
    }

    /* ── Card: diventa il contenitore dello scroll orizzontale ── */
    .azi-card {
        padding: 0 10px 14px;
        overflow-x: auto;           /* scroll orizzontale qui */
        overflow-y: visible;
        border-radius: 8px;
    }

    /* ── Tabelle: non si restringono, overflow gestito dalla card */
    .tbl-aziende-v2,
    .tbl-eu-v2 {
        width: auto;                /* non più 100% del contenitore */
        min-width: 700px;           /* larghezza minima fissa */
    }

    /* ── Toolbar: riga 1 = RIGHE + paginazione | riga 2 = bottoni/cerca */
    .azi-toolbar {
        flex-wrap: wrap;
        padding: 8px 10px;
        gap: 6px;
        border-radius: 12px;
    }
    /* Left (righe) e Center (paginazione) restano sulla riga 1 */
    .azi-tb-left   { flex-shrink: 0; }
    .azi-tb-center { flex: 1; justify-content: flex-end; }
    /* Right (bottoni + cerca) va sulla riga 2, larghezza piena con distribuzione spazio */
    .azi-tb-right  {
        order: 3;
        width: 100%;
        justify-content: space-between;
        align-items: center;
        gap: 8px;
        padding-top: 4px;
        border-top: 1px solid rgba(255,255,255,.07);
    }
    .azi-btn-delete {
        order: 1;
        flex-shrink: 0;
    }
    .azi-search-wrap {
        order: 2;
        flex: 1;
        min-width: 140px;
    }
    .azi-btn-add {
        order:3;
        display: inline-block;
    }
    
    /* Filtri uno sopra l'altro su mobile */
    .op-filters-row {
        display: flex;
        flex-direction: column;
        gap: 10px;
        margin-bottom: 12px;
    }
    .op-filters-row .op-filter-bar {
        width: 100%;
        margin-bottom: 0;
    }

    /* Search: si espande per riempire lo spazio disponibile */
    .azi-search-wrap { flex: 1; min-width: 0; }
    .azi-search-input { font-size: 12px; }

    /* ── Drawer: larghezza piena su mobile ───────────────────── */
    .azi-drawer { width: 100% !important; max-width: 100%; }
    .eu-drawer  { width: 100% !important; max-width: 100%; }
}

/* ══════════════════════════════════════════════════════════════
   OPERAZIONI: FILTRO IMPIANTO
══════════════════════════════════════════════════════════════ */
.op-filter-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    margin-bottom: 8px;
    background: #f8faf9;
    border: 1px solid #e8ece9;
    border-radius: 8px;
}
.op-filter-left {
    display: flex;
    align-items: center;
    gap: 10px;
}
.op-filter-label {
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    white-space: nowrap;
    font-family: var(--font-s);
}
.op-filter-select {
    padding: 6px 28px 6px 10px;
    background-color: #ffffff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M3 4.5L6 8l3-3.5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    appearance: none;
    -webkit-appearance: none;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 13px;
    color: #111827;
    cursor: pointer;
    font-family: var(--font-s);
    min-width: 180px;
}
.op-filter-select:focus {
    outline: none;
    border-color: #4a9e55;
    box-shadow: 0 0 0 2px rgba(74,158,85,.13);
}
.op-filter-chip {
    font-size: 0;
    padding: 0;
    transition: all .15s;
}
.op-filter-chip.op-filter-active {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px 4px 12px;
    background: #dcfce7;
    border: 1px solid #86efac;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    color: #15803d;
    font-family: var(--font-s);
}
.op-filter-chip button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    background: #bbf7d0;
    border: none;
    border-radius: 50%;
    font-size: 11px;
    line-height: 1;
    color: #15803d;
    cursor: pointer;
    transition: background .15s;
}
.op-filter-chip button:hover { background: #86efac; }

/* Riga con più filtri affiancati */
.op-filters-row {
    display: flex;
    gap: 12px;
    margin-bottom: 8px;
}
.op-filters-row .op-filter-bar {
    flex: 1;
    margin-bottom: 0;
}

/* Dark theme */
[data-theme="dark"] .op-filter-bar {
    background: rgba(255,255,255,.03);
    border-color: rgba(255,255,255,.07);
}
[data-theme="dark"] .op-filter-label { color: rgba(255,255,255,.55); }
[data-theme="dark"] .op-filter-select {
    background-color: rgba(255,255,255,.06);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238fc93a' d='M3 4.5L6 8l3-3.5z'/%3E%3C/svg%3E");
    border-color: rgba(255,255,255,.12);
    color: #e0f7fa;
}
[data-theme="dark"] .op-filter-chip.op-filter-active {
    background: rgba(143,201,58,.12);
    border-color: rgba(143,201,58,.3);
    color: #8fc93a;
}
[data-theme="dark"] .op-filter-chip button {
    background: rgba(143,201,58,.15);
    color: #8fc93a;
}
[data-theme="dark"] .op-filter-chip button:hover { background: rgba(143,201,58,.25); }
