/* Enigma ERP - design token e stili di base, allineati al sito enigma-tech.it (inchiostro #181E25, lime #D6FD70, fondo #F8F7F5) */
:root {
    --primary: #181E25;
    --onprimary: #FFFFFF;
    --accent: #D6FD70;
    --accent-strong: #B9E44A;
    --accent-soft: #EEFCCB;
    --onaccent: #181E25;
    --logo-fg: #D6FD70;
    --surface: #FFFFFF;
    --bg: #F8F7F5;
    --border: #D9D7D0;
    --tx: #181E25;
    --tx2: #4A5058;
    --success: #1F8A5B;
    --warning: #B7791F;
    --danger: #C8372D;
    --info: #2878C8;
    --neutral: #6B7078;
    --hover: #EFEDE6;
    --bar2: #D9D7D0;
    --radius: 8px;
    --radius-card: 12px;
    --row-height: 36px;
    --font: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-display: "Inter Tight", Inter, system-ui, sans-serif;
    --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
    color-scheme: light;
}

[data-theme="dark"] {
    --primary: #D6FD70;
    --onprimary: #0E1216;
    --accent: #D6FD70;
    --accent-strong: #E4FF9A;
    --accent-soft: rgba(214, 253, 112, .14);
    --onaccent: #0E1216;
    --logo-fg: #0E1216;
    --surface: #171D23;
    --bg: #0E1216;
    --border: #2B323A;
    --tx: #F8F7F5;
    --tx2: #A4A9AF;
    --success: #3DBE85;
    --warning: #E3A94B;
    --danger: #EF6B61;
    --info: #5AA2EA;
    --neutral: #8D939A;
    --hover: #1F262D;
    --bar2: #39414A;
    color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
    [data-theme="system"] {
        --primary: #D6FD70;
        --onprimary: #0E1216;
        --accent: #D6FD70;
        --accent-strong: #E4FF9A;
        --accent-soft: rgba(214, 253, 112, .14);
        --onaccent: #0E1216;
        --logo-fg: #0E1216;
        --surface: #171D23;
        --bg: #0E1216;
        --border: #2B323A;
        --tx: #F8F7F5;
        --tx2: #A4A9AF;
        --success: #3DBE85;
        --warning: #E3A94B;
        --danger: #EF6B61;
        --info: #5AA2EA;
        --neutral: #8D939A;
        --hover: #1F262D;
        --bar2: #39414A;
        color-scheme: dark;
    }
}

[data-density="compact"] { --row-height: 32px; }
[data-density="comfortable"] { --row-height: 40px; }

html, body { margin: 0; padding: 0; }

body {
    font-family: var(--font);
    font-size: 14px;
    color: var(--tx);
    background: var(--surface);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; cursor: pointer; }
a:hover { text-decoration: underline; }
button { font-family: inherit; }

.material-symbols-outlined { font-size: 18px; line-height: 1; user-select: none; }
.mono { font-family: var(--mono); }
.muted { color: var(--tx2); }

.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0);
    white-space: nowrap; border: 0;
}

:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
/* Il titolo riceve il focus a ogni navigazione (FocusOnNavigate, per i lettori di schermo): niente riquadro */
[tabindex="-1"]:focus { outline: none; }

/* Pulsanti */
.btn {
    height: 40px;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 0 16px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--tx);
    font-size: 14px; font-weight: 500;
    cursor: pointer;
    text-decoration: none;
}
.btn:hover { background: var(--hover); text-decoration: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: default; }
/* Come i pulsanti di enigma-tech.it: lime con testo scuro */
.btn-primary { border-color: var(--accent); background: var(--accent); color: var(--onaccent); font-weight: 600; }
.btn-primary:hover { border-color: var(--accent-strong); background: var(--accent-strong); }
.btn-primary .material-symbols-outlined { color: var(--onaccent); }
.btn-block { width: 100%; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; gap: 6px; }
.btn-sm .material-symbols-outlined { font-size: 16px; color: var(--tx2); }

/* Campi */
.field label, .field-label { display: block; font-size: 12.5px; font-weight: 500; margin-bottom: 6px; }
.input {
    width: 100%; height: 40px; box-sizing: border-box;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--tx);
    font: inherit; font-size: 14px;
    outline: none;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.invalid { border-color: var(--danger); }
.input.valid { border-color: var(--success); }
.field-error { font-size: 12px; color: var(--danger); margin-top: 5px; }
.field-help { font-size: 12px; color: var(--tx2); margin-top: 5px; }

.input-group { position: relative; }
.input-group .input { padding-right: 44px; }
.input-group .input-action {
    position: absolute; right: 4px; top: 4px;
    width: 32px; height: 32px;
    display: grid; place-items: center;
    border: 0; border-radius: var(--radius);
    background: transparent; color: var(--tx2);
    cursor: pointer;
}
.input-group .input-action:hover { background: var(--hover); }
.input-group .input-action .material-symbols-outlined { font-size: 19px; }

/* Checkbox quadrata del design */
.check { display: flex; align-items: center; gap: 10px; font-size: 13.5px; cursor: pointer; user-select: none; }
.check input {
    appearance: none; -webkit-appearance: none;
    width: 18px; height: 18px; margin: 0; flex: none;
    border: 1.5px solid var(--bar2); border-radius: 4px;
    background: transparent; display: grid; place-items: center; cursor: pointer;
}
.check input::after {
    content: "check"; font-family: "Material Symbols Outlined"; font-size: 14px; line-height: 1;
    color: var(--onprimary); opacity: 0;
}
.check input:checked { border-color: var(--primary); background: var(--primary); }
.check input:checked::after { opacity: 1; }
.check.check-sm { font-size: 13px; }
.check.check-sm input { width: 16px; height: 16px; }
.check.check-sm input::after { font-size: 13px; }

/* Avvisi */
.alert {
    display: flex; gap: 10px; align-items: flex-start;
    padding: 10px 12px; border-radius: var(--radius);
    font-size: 13px; line-height: 1.45;
}
.alert .material-symbols-outlined { font-size: 18px; }
.alert-danger {
    background: color-mix(in oklch, var(--danger) 9%, var(--surface));
    border: 1px solid color-mix(in oklch, var(--danger) 30%, var(--border));
}
.alert-danger .material-symbols-outlined { color: var(--danger); }
.alert-info {
    background: color-mix(in oklch, var(--info) 9%, var(--surface));
    border: 1px solid color-mix(in oklch, var(--info) 30%, var(--border));
}
.alert-info .material-symbols-outlined { color: var(--info); }
.alert-warning {
    background: color-mix(in oklch, var(--warning) 10%, var(--surface));
    border: 1px solid color-mix(in oklch, var(--warning) 30%, var(--border));
}
.alert-warning .material-symbols-outlined { color: var(--warning); }

/* Toast */
.toast {
    position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 60;
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; border-radius: 8px;
    background: var(--tx); color: var(--surface);
    box-shadow: 0 8px 24px rgba(15, 17, 21, .24);
    font-size: 13px;
    transition: opacity .3s ease;
}
.toast .material-symbols-outlined { color: var(--success); }
.toast.hide { opacity: 0; pointer-events: none; }

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}

/* Shell applicativa: barra superiore + menu laterale */
.shell { height: 100vh; display: grid; grid-template-rows: 56px minmax(0, 1fr); grid-template-columns: 248px minmax(0, 1fr); background: var(--bg); color: var(--tx); overflow: hidden; }
.shell-collapsed { grid-template-columns: 60px minmax(0, 1fr); }
.shell-top { grid-column: 1 / -1; display: flex; align-items: center; gap: 4px; padding: 0 16px 0 0; background: var(--surface); border-bottom: 1px solid var(--border); }
.shell-top .spacer { flex: 1; }
.shell-brand { width: 248px; flex: none; display: flex; align-items: center; gap: 10px; padding: 0 16px; box-sizing: border-box; }
.shell-collapsed .shell-brand { width: 60px; padding: 0 16px; }
.shell-collapsed .shell-brand .auth-name { display: none; }
.icon-btn { width: 34px; height: 34px; display: grid; place-items: center; border: 0; border-radius: var(--radius); background: transparent; color: var(--tx2); cursor: pointer; }
.icon-btn:hover { background: var(--hover); }
.icon-btn .material-symbols-outlined { font-size: 20px; }
.shell-logout { margin: 0; display: flex; }
.shell-avatar { width: 30px; height: 30px; margin-left: 8px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 600; background: var(--accent); color: var(--onaccent); text-decoration: none; }
.shell-nav { display: flex; flex-direction: column; gap: 2px; padding: 12px 8px; background: var(--surface); border-right: 1px solid var(--border); overflow: auto; box-sizing: border-box; }
.nav-link { width: 100%; height: 34px; display: flex; align-items: center; gap: 10px; padding: 0 10px; border: 0; border-radius: var(--radius); background: transparent; color: var(--tx); font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; text-decoration: none; box-sizing: border-box; text-align: left; }
.nav-link:hover { background: var(--hover); text-decoration: none; }
.nav-link.active { background: var(--accent-soft); color: var(--tx); font-weight: 600; }
.nav-link .material-symbols-outlined { font-size: 18px; color: var(--tx2); }
.nav-link.active .material-symbols-outlined { color: var(--tx); }
.nav-label { flex: 1; }
.nav-chevron { transition: transform .15s; }
.nav-parent.open .nav-chevron { transform: rotate(180deg); }
.nav-children { display: flex; flex-direction: column; gap: 2px; padding: 2px 0 4px 38px; }
.nav-child { height: 30px; display: flex; align-items: center; padding: 0 10px; border-radius: var(--radius); color: var(--tx2); font-size: 13px; text-decoration: none; }
.nav-child:hover { background: var(--hover); text-decoration: none; }
.nav-child.active { background: var(--accent-soft); color: var(--tx); font-weight: 600; }
.shell-collapsed .nav-label, .shell-collapsed .nav-chevron, .shell-collapsed .nav-children { display: none; }
.shell-collapsed .nav-link { justify-content: center; padding: 0; }
.shell-main { overflow: auto; padding: 24px 32px; box-sizing: border-box; min-width: 0; }
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 20px; }
.page-head h1 { margin: 0; font-family: var(--font-display); font-size: 24px; font-weight: 600; letter-spacing: -.02em; }
.page-head .sub { color: var(--tx2); margin-top: 4px; font-size: 13px; }
.page-head .spacer { flex: 1; }
.breadcrumb { display: flex; gap: 6px; color: var(--tx2); font-size: 12px; margin-bottom: 8px; }

/* Elenchi, schede laterali e dialoghi */
.grow { flex: 1; }
.small { font-size: 12px; }
.tone-success { color: var(--success); } .tone-warning { color: var(--warning); } .tone-danger { color: var(--danger); }
.tone-info { color: var(--info); } .tone-neutral { color: var(--neutral); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.tab { height: 36px; padding: 0 12px; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; background: transparent; color: var(--tx2); font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; }
.tab:hover { color: var(--tx); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tab-count { font-size: 11px; padding: 1px 6px; border-radius: 10px; background: var(--hover); color: var(--tx2); }
.toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.search { position: relative; width: 320px; }
.search .material-symbols-outlined { position: absolute; left: 10px; top: 8px; font-size: 18px; color: var(--tx2); pointer-events: none; }
.search-input { width: 100%; height: 34px; padding: 0 10px 0 34px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--tx); font: inherit; font-size: 13px; box-sizing: border-box; }
.search-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--accent-soft); }
.table-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); overflow: auto; }
.grid { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 900px; }
.grid th { text-align: left; font-size: 12px; font-weight: 600; color: var(--tx2); padding: 0 12px; height: 34px; border-bottom: 1px solid var(--border); background: var(--bg); white-space: nowrap; }
.grid td { padding: 0 12px; height: var(--row-height); border-bottom: 1px solid var(--border); white-space: nowrap; }
.grid tbody tr { cursor: pointer; }
.grid tbody tr:hover { background: var(--hover); }
.grid tbody tr.selected { background: var(--accent-soft); }
.grid tbody tr:last-child td { border-bottom: 0; }
.grid td.empty { text-align: center; color: var(--tx2); height: 72px; cursor: default; }
.table-note { margin-top: 10px; font-size: 12px; color: var(--tx2); }
.muted { color: var(--tx2); }
.avatar-sm, .avatar-lg { display: inline-grid; place-items: center; border-radius: 50%; font-weight: 600; background: var(--accent); color: var(--onaccent); flex: none; }
.avatar-sm { width: 24px; height: 24px; font-size: 10px; margin-right: 10px; vertical-align: middle; }
.avatar-lg { width: 40px; height: 40px; font-size: 14px; }
.ico-text { display: inline-flex; align-items: center; gap: 6px; }
.ico-text .material-symbols-outlined { font-size: 17px; }
.badge { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: 11px; font-size: 12px; font-weight: 500; background: color-mix(in oklch, currentColor 12%, transparent); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.scrim { position: fixed; inset: 0; background: rgba(15, 17, 21, .35); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 440px; max-width: 100vw; z-index: 41; display: flex; flex-direction: column; background: var(--surface); border-left: 1px solid var(--border); box-shadow: -8px 0 24px rgba(0, 0, 0, .12); }
.drawer-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.drawer-title { font-size: 15px; font-weight: 600; }
.drawer-body { flex: 1; overflow: auto; padding: 20px; display: flex; flex-direction: column; gap: 20px; }
.drawer-foot { display: flex; align-items: center; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--border); }
.drawer-section { display: flex; flex-direction: column; gap: 10px; }
.section-label { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--tx2); }
.two-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { height: 30px; padding: 0 12px 0 8px; display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); border-radius: 15px; background: var(--surface); color: var(--tx2); font: inherit; font-size: 13px; cursor: pointer; }
.chip .material-symbols-outlined { font-size: 16px; }
.chip.on { border-color: var(--primary); color: var(--tx); background: var(--accent-soft); }
.chip:disabled { cursor: default; opacity: .7; }
.sec-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px; }
.btn-danger-text { color: var(--danger); }
.modal-backdrop { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: rgba(15, 17, 21, .45); }
.modal { width: 420px; max-width: calc(100vw - 32px); padding: 20px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.modal-title { font-size: 15px; font-weight: 600; }
.modal-text { font-size: 13px; color: var(--tx2); line-height: 1.5; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

/* Form a sezioni (Azienda) e varie */
.form-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 20px; margin-bottom: 16px; }
.form-section h2 { margin: 0 0 4px; font-size: 14px; font-weight: 600; }
.form-section .section-desc { color: var(--tx2); font-size: 12.5px; margin-bottom: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .span-1 { grid-column: span 1; } .form-grid .span-2 { grid-column: span 2; } .form-grid .span-3 { grid-column: span 3; }
.form-grid .span-4 { grid-column: span 4; } .form-grid .span-6 { grid-column: span 6; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.right, .grid th.right, .grid td.right { text-align: right; }
.input:disabled, select.input:disabled { background: var(--hover); color: var(--tx2); cursor: default; }
.switch-row { display: flex; align-items: center; gap: 10px; min-height: 34px; font-size: 13px; }
.lock-note { display: flex; align-items: center; gap: 8px; color: var(--tx2); font-size: 12.5px; margin-bottom: 12px; }
.lock-note .material-symbols-outlined { font-size: 16px; }
.save-bar { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.drawer.wide { width: 560px; }
@media (max-width: 900px) { .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .form-grid [class*="span-"] { grid-column: span 2; } }
.check-inline { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--tx2); cursor: pointer; }
.inner-grid { min-width: 0; border: 1px solid var(--border); }
.inner-grid td, .inner-grid th { padding: 4px 8px; }
.input-sm { height: 30px; font-size: 13px; }
.split { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 16px; align-items: start; }
.role-list { display: flex; flex-direction: column; padding: 8px; gap: 2px; }
.role-item { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border: 0; border-radius: var(--radius); background: transparent; color: var(--tx); font: inherit; text-align: left; cursor: pointer; }
.role-item:hover { background: var(--hover); }
.role-item.active { background: var(--accent-soft); }
.role-item .material-symbols-outlined { font-size: 18px; }
.role-name { display: block; font-size: 13px; font-weight: 600; }
.role-detail .drawer-foot { border-top: 1px solid var(--border); }
.empty-state { padding: 48px; text-align: center; color: var(--tx2); }
.perm-group { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.perm-group-title { padding: 8px 12px; background: var(--bg); font-size: 12px; font-weight: 600; color: var(--tx2); }
.perm-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-top: 1px solid var(--border); font-size: 13px; cursor: pointer; }
.perm-row:hover { background: var(--hover); }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } }
.filter { width: auto; height: 34px; font-size: 13px; padding: 0 28px 0 10px; }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 10px; }
.summary { max-width: 520px; overflow: hidden; text-overflow: ellipsis; }
