html, body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

h1:focus {
    outline: none;
}

a, .btn-link {
    color: #0071c1;
}

.btn-primary {
    color: #fff;
    background-color: #1b6ec2;
    border-color: #1861ac;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

.content {
    padding-top: 1.1rem;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid red;
}

.validation-message {
    color: red;
}

#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: 0.5rem;
    }

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.loading-progress {
    position: relative;
    display: block;
    width: 8rem;
    height: 8rem;
    margin: 20vh auto 1rem auto;
}

    .loading-progress circle {
        fill: none;
        stroke: #e0e0e0;
        stroke-width: 0.6rem;
        transform-origin: 50% 50%;
        transform: rotate(-90deg);
    }

        .loading-progress circle:last-child {
            stroke: #1b6ec2;
            stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
            transition: stroke-dasharray 0.05s ease-in-out;
        }

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

    .loading-progress-text:after {
        content: var(--blazor-load-percentage-text, "Loading");
    }

code {
    color: #c02d76;
}

/* Login */
.login-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
    padding: 1.5rem;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}

.login-card h1 {
    font-size: 1.35rem;
    margin-bottom: 0.25rem;
}

.login-subtitle {
    color: #64748b;
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
    color: #334155;
}

/* Planner — layout definito sotto in "PORT WPF" */

.planner-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: flex-end;
    padding: 0.75rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
}

.toolbar-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 140px;
}

.toolbar-group.flex-grow {
    flex: 1;
    min-width: 180px;
}

.planner-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
    color: #475569;
}

.live-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.25);
}

/* gantt-scroll — regole complete sotto in "Gantt2" */

.gantt {
    min-width: 900px;
}

.gantt-header,
.gantt-row {
    display: grid;
    grid-template-columns: 180px 1fr;
    border-bottom: 1px solid #e2e8f0;
}

.gantt-label-col {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    font-weight: 600;
    background: #f8fafc;
    border-right: 1px solid #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    position: sticky;
    left: 0;
    z-index: 2;
}

.gantt-days,
.gantt-track {
    display: grid;
    grid-template-columns: repeat(var(--day-count), minmax(28px, 1fr));
    position: relative;
}

.gantt-day {
    text-align: center;
    font-size: 0.7rem;
    padding: 0.25rem 0;
    border-right: 1px solid #f1f5f9;
    color: #64748b;
}

.gantt-day.weekend,
.gantt-cell.weekend {
    background: #f8fafc;
}

.gantt-day-num {
    display: block;
    font-weight: 700;
    color: #334155;
}

.gantt-row {
    min-height: 42px;
}

.gantt-cell {
    border-right: 1px solid #f1f5f9;
}

.gantt-bar {
    position: absolute;
    top: 6px;
    height: 28px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    color: #fff;
    padding: 0 6px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    line-height: 28px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
    z-index: 1;
}

.gantt-bar.tipo-op { background: #2563eb; }
.gantt-bar.tipo-flex { background: #7c3aed; }
.gantt-bar.tipo-ferie { background: #059669; }
.gantt-bar.conflict { outline: 2px solid #ef4444; outline-offset: -1px; }

/* ============================================================
   PORT WPF — planner full, ferie, admin, export, modali
   ============================================================ */

:root {
    --g-line: #e4e4e7;
    --g-line-soft: #f1f5f9;
    --g-muted: #71717a;
    --g-ink: #09090b;
    --g-weekend: #f4f4f5;
    --g-holiday: #fef2f2;
    --g-today: #fef9c3;
}

/* ---- Toolbar ---- */
.planner-page { display: flex; flex-direction: column; gap: .6rem; height: calc(100vh - 4.5rem); min-height: 0; overflow: hidden; }
.planner-toolbar {
    display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .5rem;
    padding: .5rem .75rem; background: #fff; border: 1px solid var(--g-line); border-radius: 8px;
}
.tb-left, .tb-right { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.tb-divider { width: 1px; height: 22px; background: var(--g-line); margin: 0 .25rem; }
.tb-period { font-size: 12px; font-weight: 600; color: var(--g-ink); margin: 0 .35rem; white-space: nowrap; }
.tb-window { width: 130px; }
.tb-search { width: 230px; }
.btn-help { width: 34px; padding: 0; font-weight: 600; }
.btn-conflict { color: #DC2626; border-color: #FECACA; background: #FEF2F2; font-weight: 600; }
.tb-notify-info {
    display: inline-flex; align-items: center; white-space: nowrap;
    font-size: 12px; color: #92400e; background: #fef3c7; border: 1px solid #fde68a;
    border-radius: 6px; padding: 4px 10px;
}
.btn-xs { padding: .1rem .4rem; font-size: 11px; line-height: 1.4; }

.legend { display: flex; gap: .25rem; }
.legend-chip {
    display: inline-flex; align-items: center; gap: .35rem; padding: .25rem .5rem; font-size: 11px;
    border: 1px solid transparent; border-radius: 6px; cursor: pointer; color: var(--g-muted); user-select: none;
}
.legend-chip:hover { background: #f4f4f5; border-color: var(--g-line); }
.legend-chip.active { background: #eff6ff; border-color: #bfdbfe; color: #1d4ed8; }
.legend-chip .dot { width: 14px; height: 14px; border-radius: 4px; }

.help-popup {
    position: absolute; z-index: 50; margin-top: .25rem; max-width: 380px; padding: .8rem;
    background: #fff; border: 1px solid var(--g-line); border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.15);
    font-size: 11px; color: #334155;
}
.help-popup .help-section { font-weight: 600; color: var(--g-muted); margin-top: .5rem; }

/* ---- Filtri ---- */
.planner-filters {
    display: flex; align-items: center; flex-wrap: wrap; gap: .75rem;
    padding: .4rem .75rem; background: #fff; border: 1px solid var(--g-line); border-radius: 8px;
}
.toggle { display: inline-flex; align-items: center; gap: .35rem; font-size: 12px; color: #334155; margin: 0; cursor: pointer; }
.filter-lbl { font-size: 11px; color: var(--g-muted); }
.filter-tipo { width: 120px; }
.res-filter { position: relative; }
.res-filter-pop {
    position: absolute; z-index: 50; margin-top: .25rem; width: 320px; max-height: 360px; overflow: auto;
    background: #fff; border: 1px solid var(--g-line); border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.15); padding: .6rem;
}
.res-filter-actions { display: flex; gap: .4rem; margin-bottom: .5rem; }
.res-filter-list { display: grid; grid-template-columns: 1fr 1fr; gap: .2rem .6rem; }
.res-filter-item { display: flex; align-items: center; gap: .4rem; font-size: 12px; cursor: pointer; }

/* ---- Conflitti ---- */
.conflict-panel { display: flex; align-items: center; gap: .6rem; padding: .4rem .75rem; background: #FEF2F2; border: 1px solid #FECACA; border-radius: 8px; }
.conflict-title { font-size: 11px; font-weight: 600; color: #B91C1C; white-space: nowrap; }
.conflict-list { display: flex; gap: .4rem; overflow-x: auto; }
.conflict-chip { font-size: 11px; padding: .25rem .5rem; background: #fff; border: 1px solid #FECACA; border-radius: 4px; cursor: pointer; white-space: nowrap; }

/* ---- Layout: permette al gantt-scroll di scorrere internamente invece di allargare la pagina ---- */
main { min-width: 0; }
.content { min-width: 0; }
.planner-page, .ferie-page { min-width: 0; min-height: 0; }
.ferie-page { overflow: hidden; }

/* ---- Gantt2 ---- */
.gantt-scroll {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
    border: 1px solid var(--g-line);
    border-radius: 8px;
    background: #fff;
    position: relative;
    -webkit-overflow-scrolling: touch;
}
.gantt2 { position: relative; display: inline-block; width: max-content; min-width: 100%; vertical-align: top; }
.g2-thead, .g2-track { flex-shrink: 0; }

.g2-head { display: flex; position: sticky; top: 0; z-index: 5; }
.g2-corner {
    width: 200px; min-width: 200px; position: sticky; left: 0; z-index: 6; background: #fafafa;
    border-right: 1px solid var(--g-line); border-bottom: 1px solid var(--g-line);
    display: flex; align-items: flex-end; padding: .35rem .75rem; font-size: 11px; font-weight: 600; color: var(--g-muted);
}
.g2-thead { display: flex; flex-direction: column; }
.g2-months { display: flex; }
.g2-month { font-size: 11px; font-weight: 600; color: var(--g-muted); padding: .2rem .4rem; box-sizing: border-box;
    background: #fafafa; border-right: 1px solid var(--g-line); border-bottom: 1px solid var(--g-line); overflow: hidden; white-space: nowrap; }
.g2-days { display: flex; }
.g2-day { display: flex; flex-direction: column; align-items: center; box-sizing: border-box; padding: .1rem 0;
    background: #fafafa; border-right: 1px solid var(--g-line-soft); border-bottom: 1px solid var(--g-line); }
.g2-day.today { background: var(--g-today); }
.g2-day.weekend { background: var(--g-weekend); }
.g2-day.holiday { background: var(--g-holiday); }
.g2-dow { font-size: 9px; color: var(--g-muted); }
.g2-dnum { font-size: 11px; font-weight: 600; color: var(--g-ink); }
.g2-dnum.red { color: #DC2626; }

.g2-row { display: flex; border-bottom: 1px solid var(--g-line); }
.g2-name {
    width: 200px; min-width: 200px; position: sticky; left: 0; z-index: 3; background: #fff;
    border-right: 1px solid var(--g-line); display: flex; align-items: center; gap: .4rem; padding: 0 .5rem 0 .75rem; box-sizing: border-box;
}
.g2-name.self { background: #EFF6FF; }
.g2-name.self .g2-name-text { font-weight: 700; }
.presence { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }
.presence.on { background: #86EFAC; }
.presence.off { background: #F87171; }
.g2-name-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--g-ink); }

.g2-track { position: relative; box-sizing: border-box; }
.g2-cells { position: absolute; inset: 0; display: flex; pointer-events: none; }
.g2-cell { box-sizing: border-box; height: 100%; border-right: 1px solid var(--g-line-soft); }
.g2-cell.today { background: var(--g-today); }
.g2-cell.weekend { background: var(--g-weekend); }
.g2-cell.holiday { background: var(--g-holiday); }

.g2-bar {
    position: absolute; border-radius: 4px; color: #fff; font-size: 11px; font-weight: 500;
    overflow: hidden; white-space: nowrap; display: flex; align-items: center; cursor: grab;
    box-shadow: 0 1px 2px rgba(0,0,0,.12); user-select: none;
}
.g2-bar.tipo-op { background: #3B82F6; }
.g2-bar.tipo-flex { background: #9CA3AF; color: #1F2937; }
.g2-bar.tipo-ferie { background: #EF4444; }
.g2-bar.conflict { outline: 2px solid #B91C1C; outline-offset: -2px; }
.g2-bar.selected { outline: 2px solid #2563EB; outline-offset: -2px; }
.g2-bar.preview { opacity: .55; pointer-events: none; }
.g2-bar.clickable { cursor: pointer; }
.g2-bar-label { overflow: hidden; text-overflow: ellipsis; flex: 1; padding: 0 .35rem; }
.grip { width: 6px; align-self: stretch; cursor: ew-resize; flex: 0 0 auto; }

.g2-empty { padding: 1.5rem; text-align: center; color: var(--g-muted); font-size: 13px; }

/* ---- Status bar ---- */
.planner-status { display: flex; justify-content: space-between; align-items: center; padding: .4rem .9rem;
    background: #fff; border: 1px solid var(--g-line); border-radius: 8px; font-size: 11px; color: var(--g-muted); }
.status-right { display: inline-flex; align-items: center; gap: .4rem; }
.conn-dot { width: 8px; height: 8px; border-radius: 50%; background: #9CA3AF; }
.conn-dot.on { background: #22c55e; }
.conn-dot.off { background: #9CA3AF; }

/* ---- Context menu ---- */
.ctx-overlay { position: fixed; inset: 0; z-index: 100; }
.ctx-menu { position: fixed; min-width: 160px; background: #18181b; color: #fafafa; border-radius: 6px; padding: .25rem; box-shadow: 0 10px 30px rgba(0,0,0,.3); }
.ctx-item { padding: .4rem .6rem; font-size: 12px; border-radius: 4px; cursor: pointer; }
.ctx-item:hover { background: #27272a; }
.ctx-item.danger { color: #fca5a5; }

/* ---- Modale ---- */
.modal-overlay { position: fixed; inset: 0; z-index: 200; background: rgba(15,23,42,.45); display: flex; align-items: center; justify-content: center; padding: 1rem; }
.modal-card { background: #fff; border-radius: 12px; box-shadow: 0 25px 60px rgba(0,0,0,.3); display: flex; flex-direction: column; max-height: 92vh; width: 100%; }
.modal-sm { max-width: 420px; }
.modal-md { max-width: 600px; }
.modal-lg { max-width: 860px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: .9rem 1.25rem; border-bottom: 1px solid var(--g-line); }
.modal-title { font-size: 15px; font-weight: 600; color: var(--g-ink); }
.modal-close { border: none; background: transparent; font-size: 15px; cursor: pointer; color: var(--g-muted); }
.modal-body { padding: 1rem 1.25rem; overflow: auto; }
.modal-footer { display: flex; justify-content: flex-end; align-items: center; gap: .5rem; padding: .8rem 1.25rem; border-top: 1px solid var(--g-line); }
.ftr-left { margin-right: auto; }

/* ---- Form ---- */
.form-lbl { display: block; font-size: 11px; font-weight: 600; color: var(--g-muted); margin: .5rem 0 .3rem; letter-spacing: .02em; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .75rem; margin: .5rem 0; }
.form-section { font-size: 11px; font-weight: 700; color: var(--g-muted); margin: 1rem 0 .25rem; letter-spacing: .04em; }
.hint { font-size: 11px; color: var(--g-muted); margin-top: .5rem; }
.dialog-sub { font-size: 12px; color: var(--g-muted); margin-bottom: .5rem; }
.single-resource { padding: .6rem .75rem; background: #f4f4f5; border: 1px solid var(--g-line); border-radius: 6px; font-weight: 600; }
.resource-picker { border: 1px solid var(--g-line); border-radius: 6px; padding: .5rem; }
.resource-list { max-height: 280px; overflow: auto; margin-top: .4rem; }
.resource-row { display: flex; align-items: center; gap: .5rem; padding: .25rem .25rem; font-size: 13px; cursor: pointer; }
.resource-row.resource-head { font-weight: 600; border-bottom: 1px solid var(--g-line); margin-bottom: .25rem; }

/* ---- Ferie ---- */
.ferie-page { display: flex; flex-direction: column; gap: .6rem; height: calc(100vh - 4.5rem); }
.ferie-kpis { display: flex; gap: .75rem; flex-wrap: wrap; }
.kpi-card { flex: 1; min-width: 180px; background: #fff; border: 1px solid var(--g-line); border-radius: 8px; padding: .75rem 1rem; }
.kpi-label { font-size: 11px; color: var(--g-muted); text-transform: uppercase; letter-spacing: .03em; }
.kpi-value { font-size: 1.6rem; font-weight: 700; color: var(--g-ink); }
.kpi-sub { font-size: .8rem; font-weight: 400; color: var(--g-muted); }
.ferie-sel { flex: 0 0 auto; }
.ferie-days { font-size: 10px; color: var(--g-muted); white-space: nowrap; }
.ferie-add { border: 1px solid var(--g-line); background: #fff; border-radius: 4px; width: 22px; height: 22px; line-height: 1; cursor: pointer; color: #2563eb; font-weight: 700; }
.ferie-add:hover { background: #eff6ff; }

/* ---- Admin ---- */
.admin-page { padding-bottom: 2rem; }
.admin-page h1 { font-size: 1.3rem; margin-bottom: .75rem; }
.admin-tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--g-line); margin-bottom: 1rem; }
.admin-tab { border: none; background: transparent; padding: .5rem .9rem; font-size: 13px; cursor: pointer; color: var(--g-muted); border-bottom: 2px solid transparent; }
.admin-tab.active { color: var(--g-ink); border-bottom-color: #2563eb; font-weight: 600; }
.admin-toolbar { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .75rem; }
.admin-toolbar > input[type=search] { width: 240px; }
.file-btn { position: relative; overflow: hidden; cursor: pointer; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.admin-table-wrap { overflow: auto; border: 1px solid var(--g-line); border-radius: 8px; background: #fff; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th { text-align: left; padding: .5rem .6rem; background: #fafafa; border-bottom: 1px solid var(--g-line); font-size: 11px; color: var(--g-muted); text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
.admin-table td { padding: .4rem .6rem; border-bottom: 1px solid var(--g-line-soft); vertical-align: middle; }
.admin-table td.center { text-align: center; }
.admin-table tr.terminated { opacity: .55; }
.admin-table .actions { display: flex; gap: .25rem; flex-wrap: wrap; }
.admin-table select.form-select-sm { min-width: 130px; }
.admin-empty { padding: 1rem; color: var(--g-muted); }
.perms-panel { max-width: 560px; background: #fff; border: 1px solid var(--g-line); border-radius: 8px; padding: 1rem; }
.perms-select { max-width: 420px; }
.perms-help { margin-top: .75rem; font-size: 13px; color: #334155; }
.perms-legend { margin-top: 1rem; font-size: 12px; color: var(--g-muted); display: grid; gap: .2rem; }

/* ---- Export attività ---- */
.export-page { padding-bottom: 2rem; }
.export-controls h1 { font-size: 1.3rem; margin-bottom: .75rem; }
.export-row { display: flex; align-items: flex-end; gap: .75rem; flex-wrap: wrap; margin-bottom: .75rem; }
.export-resources { background: #fff; border: 1px solid var(--g-line); border-radius: 8px; padding: .75rem; margin-bottom: 1rem; }
.export-res-actions { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.export-res-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .25rem .75rem; max-height: 220px; overflow: auto; }
.export-res-item { display: flex; align-items: center; gap: .4rem; font-size: 13px; }
.export-doc { background: #fff; border: 1px solid var(--g-line); border-radius: 8px; padding: 1.5rem; }
.export-doc-head { border-bottom: 2px solid var(--g-ink); padding-bottom: .5rem; margin-bottom: 1rem; }
.export-doc-head h2 { margin: 0; font-size: 1.2rem; }
.export-doc-meta { font-size: 12px; color: var(--g-muted); }
.export-group { margin-bottom: 1rem; }
.export-group h3 { font-size: 1rem; margin: 0 0 .25rem; }
.export-group ul { margin: 0; padding-left: 1.25rem; }
.export-group li { font-size: 13px; margin: .15rem 0; }

/* ---- Top bar / user menu ---- */
.top-row { display: flex; align-items: center; }
.top-spacer { flex: 1; }
.user-menu { position: relative; }
.user-chip { display: flex; align-items: center; gap: .5rem; border: 1px solid transparent; background: transparent; border-radius: 8px; padding: .25rem .5rem; cursor: pointer; }
.user-chip:hover { background: #f4f4f5; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: #1e3a5f; color: #fff; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; }
.user-meta { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.1; }
.user-name { font-size: 12px; font-weight: 600; color: var(--g-ink); }
.user-role { font-size: 10px; color: var(--g-muted); }
.caret { font-size: 10px; color: var(--g-muted); }
.user-dropdown { position: absolute; right: 0; top: calc(100% + 4px); z-index: 100; min-width: 180px; background: #fff; border: 1px solid var(--g-line); border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.15); padding: .25rem; }
.dropdown-item { display: block; width: 100%; text-align: left; border: none; background: transparent; padding: .5rem .6rem; font-size: 13px; border-radius: 6px; cursor: pointer; color: var(--g-ink); }
.dropdown-item:hover { background: #f4f4f5; }
.dropdown-sep { height: 1px; background: var(--g-line); margin: .25rem 0; }

/* ---- Badge utente in fondo alla sidebar (come ATEC PM) ---- */
.sidebar-user { margin-top: auto; padding: .75rem; position: relative; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-user .user-chip { width: 100%; }
.sidebar-user .user-chip:hover { background: rgba(255,255,255,.08); }
.sidebar-user .avatar { background: #3b82f6; }
.sidebar-user .user-name { color: #f8fafc; }
.sidebar-user .user-role { color: #94a3b8; }
.sidebar-user .caret { color: #94a3b8; margin-left: auto; }
.sidebar-user .user-dropdown { left: .75rem; right: .75rem; top: auto; bottom: calc(100% + 4px); }

/* ---- Sidebar a scomparsa (pulsante ☰, come ATEC PM) ---- */
.sidebar-toggle { position: absolute; top: .55rem; right: .45rem; z-index: 5; background: transparent; border: none; color: #cbd5e1; font-size: 17px; line-height: 1; padding: .3rem .5rem; border-radius: 6px; cursor: pointer; }
.sidebar-toggle:hover { background: rgba(255,255,255,.1); }

@media (min-width: 641px) {
    .page.nav-hidden .sidebar { width: 46px; }
    .page.nav-hidden .sidebar .nav-brand,
    .page.nav-hidden .sidebar .nav-scrollable,
    .page.nav-hidden .sidebar .sidebar-user { display: none; }
}

/* Su schermi piccoli c'è già il menu hamburger nativo: il toggle non serve */
@media (max-width: 640.98px) {
    .sidebar-toggle { display: none; }
}

/* ---- Stampa ---- */
@media print {
    .no-print, .sidebar, .top-row, .planner-status { display: none !important; }
    .page { display: block; }
    main { margin: 0; }
    .content { padding: 0 !important; }
    .export-doc { border: none; box-shadow: none; padding: 0; }
    .export-page { padding: 0; }
}

/* ---- Checkbox come interruttore a slitta (toggle switch, stile WPF) ---- */
:where(.planner-page, .ferie-page, .admin-page, .export-page, .modal-card) input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    box-sizing: border-box;
    width: 34px;
    height: 18px;
    flex: 0 0 auto;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 999px;
    background: #cbd5e1;
    position: relative;
    cursor: pointer;
    vertical-align: middle;
    transition: background .15s ease;
}
:where(.planner-page, .ferie-page, .admin-page, .export-page, .modal-card) input[type="checkbox"]::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .3);
    transition: transform .15s ease;
}
:where(.planner-page, .ferie-page, .admin-page, .export-page, .modal-card) input[type="checkbox"]:checked {
    background: #2563eb;
}
:where(.planner-page, .ferie-page, .admin-page, .export-page, .modal-card) input[type="checkbox"]:checked::after {
    transform: translateX(16px);
}
:where(.planner-page, .ferie-page, .admin-page, .export-page, .modal-card) input[type="checkbox"]:disabled {
    opacity: .5;
    cursor: not-allowed;
}
:where(.planner-page, .ferie-page, .admin-page, .export-page, .modal-card) input[type="checkbox"]:focus-visible {
    outline: 2px solid #93c5fd;
    outline-offset: 2px;
}

/* ---- Dark Theme ---- */
body.dark-theme {
    --g-line: #3f3f46;
    --g-line-soft: #27272a;
    --g-muted: #a1a1aa;
    --g-ink: #f4f4f5;
    --g-weekend: #18181b;
    --g-holiday: #2d1d1d;
    --g-today: #2d2b1d;
    background-color: #09090b !important;
    color: #f4f4f5 !important;
}

body.dark-theme main {
    background-color: #09090b;
}

body.dark-theme .planner-toolbar,
body.dark-theme .planner-filters,
body.dark-theme .planner-status,
body.dark-theme .gantt-scroll,
body.dark-theme .g2-corner,
body.dark-theme .g2-month,
body.dark-theme .g2-day,
body.dark-theme .g2-name,
body.dark-theme .kpi-card,
body.dark-theme .modal-card,
body.dark-theme .modal-header,
body.dark-theme .modal-footer,
body.dark-theme .admin-table-wrap,
body.dark-theme .admin-table th,
body.dark-theme .perms-panel,
body.dark-theme .export-doc,
body.dark-theme .export-resources,
body.dark-theme .user-dropdown {
    background-color: #18181b !important;
    color: #f4f4f5 !important;
    border-color: #3f3f46 !important;
}

body.dark-theme .form-control,
body.dark-theme .form-select {
    background-color: #27272a !important;
    color: #f4f4f5 !important;
    border-color: #3f3f46 !important;
}

body.dark-theme .btn-outline-secondary {
    color: #e4e4e7 !important;
    border-color: #3f3f46 !important;
}

body.dark-theme .btn-outline-secondary:hover {
    background-color: #27272a !important;
}

body.dark-theme .user-chip:hover {
    background-color: #27272a !important;
}

body.dark-theme .dropdown-item:hover {
    background-color: #27272a !important;
}

body.dark-theme .dropdown-sep {
    background: #3f3f46 !important;
}

body.dark-theme .single-resource {
    background: #27272a !important;
    border-color: #3f3f46 !important;
}

body.dark-theme .resource-picker {
    border-color: #3f3f46 !important;
}

body.dark-theme .resource-row.resource-head {
    border-bottom-color: #3f3f46 !important;
}

body.dark-theme .conflict-panel {
    background: #2d1d1d !important;
    border-color: #8c2a2a !important;
}

body.dark-theme .conflict-chip {
    background: #18181b !important;
    border-color: #8c2a2a !important;
}

body.dark-theme .help-popup {
    background: #18181b !important;
    border-color: #3f3f46 !important;
    color: #f4f4f5 !important;
}

body.dark-theme .sidebar {
    background-color: #18181b !important;
    border-right: 1px solid #3f3f46;
}

body.dark-theme .top-row {
    background-color: #18181b !important;
    border-bottom: 1px solid #3f3f46;
}

body.dark-theme .user-dropdown {
    background-color: #18181b !important;
    border: 1px solid #3f3f46 !important;
}

body.dark-theme .dropdown-item {
    color: #f4f4f5 !important;
}

body.dark-theme .dropdown-item:hover {
    background-color: #27272a !important;
}

body.dark-theme .gantt2 {
    background-color: #09090b !important;
}

body.dark-theme .nav-item a {
    color: #a1a1aa !important;
}

body.dark-theme .nav-item a.active {
    background-color: #27272a !important;
    color: #fff !important;
}

body.dark-theme .nav-item a:hover {
    background-color: #27272a !important;
}
