:root {
  --bg: #f1f5f9;
  --panel: #ffffff;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --ok: #059669;
  --warn: #d97706;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 4px 12px rgba(15, 23, 42, 0.04);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

#app { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: 236px;
  flex: 0 0 236px;
  background: #0f172a;
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 16px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 18px;
}
.brand-title { color: #fff; font-weight: 700; letter-spacing: .2px; }
.brand-sub { font-size: 11px; color: #64748b; }

#nav { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  background: transparent; border: 0; color: #cbd5e1;
  padding: 10px 12px; border-radius: 8px; cursor: pointer;
  font-size: 14px; text-align: left; width: 100%;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: #1e293b; color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-ico { width: 16px; text-align: center; opacity: .9; }
.nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.nav-item { user-select: none; -webkit-user-select: none; cursor: pointer; }
.nav-item.grab { cursor: grab; }
.nav-item.dragging { opacity: .4; }
.nav-item .nav-move { display: none; gap: 2px; margin-left: 4px; }
.nav-item:hover .nav-move, .nav-item:focus-visible .nav-move { display: inline-flex; }
.nav-move-btn {
  font-size: 9px; line-height: 1; padding: 3px 4px; border-radius: 4px;
  color: #94a3b8; background: #1e293b;
}
.nav-move-btn:hover { background: #475569; color: #fff; }
.nav-item.active .nav-move-btn { background: rgba(255,255,255,.18); color: #fff; }
.nav-item.active .nav-move-btn:hover { background: rgba(255,255,255,.35); }

.sidebar-footer { padding: 12px; display: flex; flex-direction: column; gap: 8px; border-top: 1px solid #1e293b; }
.sidebar-footer .lang-field { margin: 0 0 4px; }
.sidebar-footer .lang-field label { color: #94a3b8; }

/* ---------- Main ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px; background: var(--panel); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20; gap: 12px; flex-wrap: wrap;
}
.topbar h1 { margin: 0; font-size: 19px; }
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.content { padding: 20px 24px 48px; }

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid var(--border-strong); background: var(--panel); color: var(--text);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; font-size: 13.5px; font-weight: 500;
  transition: background .12s, border-color .12s, opacity .12s;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.btn:hover { background: #f8fafc; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.93); }
.btn-ghost { background: transparent; color: #cbd5e1; border-color: #334155; }
.btn-ghost:hover { background: #1e293b; }
.btn-block { width: 100%; justify-content: center; }
.btn-sm { padding: 5px 9px; font-size: 12.5px; }
.icon-btn {
  border: 0; background: transparent; cursor: pointer; font-size: 15px; color: var(--muted);
  width: 30px; height: 30px; border-radius: 7px;
}
.icon-btn:hover { background: #f1f5f9; color: var(--text); }

/* ---------- Cards / panels ---------- */
.panel {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 18px; overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 13px 16px; border-bottom: 1px solid var(--border);
}
.panel-head h3 { margin: 0; font-size: 14.5px; }
.panel-body { padding: 16px; }
.panel-body.pad0 { padding: 0; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.kpi-link { cursor: pointer; transition: border-color .12s, box-shadow .12s, transform .12s; }
.kpi-link:hover { border-color: var(--primary); box-shadow: 0 4px 14px rgba(37,99,235,.14); }
.kpi-link:focus-visible { outline: 2px solid #bfdbfe; border-color: var(--primary); }
.kpi-label { color: var(--muted); font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; }

/* ---------- Dashboard: progetti in partenza ---------- */
.starting-panel.alert { border-color: #fecaca; box-shadow: 0 0 0 1px #fee2e2, var(--shadow); }
.starting-panel.alert .panel-head { background: #fef2f2; border-bottom-color: #fecaca; }
.starting-panel.alert .panel-head h3 { color: var(--danger); }
.starting-table .starting-row td { color: var(--danger); }
.starting-table .starting-row td strong { color: var(--danger); }
.starting-table .starting-row .task-link { color: var(--danger); font-weight: 600; }
.starting-table .starting-row .muted { color: var(--danger); opacity: .7; }
.starting-table .start-when { font-weight: 600; white-space: nowrap; }
.kpi-value { font-size: 28px; font-weight: 700; margin-top: 6px; }
.kpi-value.danger { color: var(--danger); }
.kpi-sub { color: var(--muted); font-size: 12.5px; margin-top: 4px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: #f8fafc; font-weight: 600; position: sticky; top: 0; }
.table tbody tr:hover { background: #f8fafc; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.badge-planned { background: #e2e8f0; color: #475569; }
.badge-active { background: #dbeafe; color: #1d4ed8; }
.badge-onhold { background: #fef3c7; color: #b45309; }
.badge-done { background: #d1fae5; color: #047857; }
.badge-released { background: #d1fae5; color: #047857; }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 6px; background: #f1f5f9; font-size: 12px; margin: 2px 3px 2px 0; }
.chip-sm { padding: 1px 6px; font-size: 11px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

/* ---------- Anteprima task nella tabella progetti ---------- */
.proj-name { display: flex; align-items: flex-start; gap: 8px; }
.proj-name-text { min-width: 0; }
.proj-caret { flex: none; width: 13px; margin-top: 1px; color: var(--muted); font-size: 13px; line-height: 1.4; text-align: center; cursor: pointer; border-radius: 4px; }
.proj-caret:hover { background: #eef2f7; color: var(--text); }
.proj-caret:focus-visible { outline: 2px solid #bfdbfe; outline-offset: 1px; }
.proj-caret-empty { cursor: default; }
.project-tasks-row > td { padding: 0 14px 12px 14px; background: #fbfcfe; border-bottom: 1px solid var(--border); }
.table tbody tr.project-tasks-row:hover { background: #fbfcfe; }
.task-preview { border-left: 3px solid #c7d2fe; padding: 8px 0 2px 12px; }
.task-preview-title { font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.mini-table { width: 100%; border-collapse: collapse; }
.mini-table th, .mini-table td { padding: 5px 10px; text-align: left; border-bottom: 1px solid #eef2f7; font-size: 12.5px; vertical-align: middle; }
.mini-table th { position: static; background: transparent; font-size: 11px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
.mini-table td.num, .mini-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.mini-table tbody tr:hover { background: #f7f9fc; }
.mini-table tbody tr:last-child td { border-bottom: 0; }
.task-link { color: var(--primary); cursor: pointer; font-weight: 500; }
.task-link:hover { text-decoration: underline; }
.link { color: var(--primary); cursor: pointer; font-size: 12.5px; font-weight: 500; }
.link:hover { text-decoration: underline; }
.head-actions { display: flex; align-items: center; gap: 12px; }

.muted { color: var(--muted); }
.mono { font-variant-numeric: tabular-nums; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.color-field { display: flex; gap: 8px; align-items: center; }
.color-field input { flex: 1; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.field-row-4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 12px; }
@media (max-width: 640px) { .field-row-3, .field-row-4 { grid-template-columns: 1fr 1fr; } }
label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 5px; color: #334155; }
input[type="text"], input[type="password"], input[type="search"], input[type="number"], input[type="date"], input[type="month"], input[type="email"], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: 8px;
  font-size: 13.5px; font-family: inherit; background: #fff; color: var(--text);
}
input[type="search"] { -webkit-appearance: none; appearance: none; }
input:focus, select:focus, textarea:focus { outline: 2px solid #bfdbfe; border-color: var(--primary); }
textarea { resize: vertical; min-height: 64px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

.assign-list { display: flex; flex-direction: column; gap: 8px; }
.assign-row { display: grid; grid-template-columns: 1fr 90px 1fr 1fr 34px; gap: 8px; align-items: center; }
.assign-head { font-size: 11.5px; color: var(--muted); font-weight: 600; }
/* ---------- Task del progetto (form) ---------- */
.task-list { display: flex; flex-direction: column; gap: 10px; }
.task-item { border: 1px solid var(--border); border-radius: 8px; padding: 10px 10px 10px 22px; background: #f8fafc; position: relative; }
.task-item.dragging { opacity: .45; }
.t-drag { position: absolute; left: 4px; top: 20px; cursor: grab; color: #cbd5e1; font-size: 15px; line-height: 1; user-select: none; }
.t-drag:hover { color: var(--muted); }
.t-drag:active { cursor: grabbing; }
.task-head { display: grid; grid-template-columns: minmax(80px, 1fr) 118px 186px 86px 76px 30px; gap: 6px; align-items: center; }
.task-head .t-effort, .task-head .t-elapsed, .task-head .t-numcell input { text-align: center; }
.task-head input[readonly] { background: #eef2f7; color: var(--muted); }
.t-numcell { display: flex; align-items: center; gap: 4px; min-width: 0; }
.t-numcell input { flex: 1; min-width: 0; }
.t-unit { flex: none; font-size: 11px; color: var(--muted); white-space: nowrap; }
.t-endcell { display: flex; align-items: center; gap: 6px; }
.t-endcell .t-end { flex: 1; min-width: 0; }
.t-endmode { display: inline-flex; align-items: center; gap: 4px; flex: none; font-size: 11px; font-weight: 400; color: var(--muted); margin: 0; cursor: pointer; white-space: nowrap; }
.t-endmode input { width: auto; margin: 0; flex: none; }
.t-endmode span { line-height: 1; }
.task-assigns { display: flex; flex-direction: column; gap: 6px; margin: 8px 0 0 14px; }
.task-assign-row { display: grid; grid-template-columns: 1fr 80px 30px; gap: 8px; align-items: center; }
.task-assign-head { font-size: 11px; color: var(--muted); font-weight: 600; }
.task-item .t-add-assign { margin: 8px 0 0 14px; }
.task-item-focus { border-color: var(--primary); box-shadow: 0 0 0 2px #bfdbfe; }
@media (max-width: 640px) {
  .task-head { grid-template-columns: 1fr 1fr 1fr; }
  .task-head .t-del { grid-column: 3; justify-self: end; }
}

.checkbox-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; }

/* ---------- Documentazione allegata (form progetto) ---------- */
.att-list { display: flex; flex-direction: column; gap: 6px; }
.att-empty { font-size: 12.5px; padding: 6px 0; }
.att-item {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; background: #f8fafc;
}
.att-ext {
  flex: none; width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 7px; background: #e2e8f0; color: #475569; font-size: 10px; font-weight: 700;
  letter-spacing: .02em; text-transform: uppercase;
}
.att-info { flex: 1; min-width: 0; }
.att-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-meta { font-size: 11.5px; color: var(--muted); }
.att-btns { display: flex; gap: 2px; flex: none; }
.att-btns .icon-btn { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.att-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.att-actions .hint { margin-top: 0; }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.checkbox-row input { width: auto; }
.checkbox-row label { margin: 0; font-weight: 400; }

/* ---------- Modal ---------- */
.modal {
  border: 0; border-radius: 12px; padding: 0; width: min(680px, 94vw); max-height: 90vh;
  box-shadow: 0 20px 60px rgba(15, 23, 42, .25);
}
.modal::backdrop { background: rgba(15, 23, 42, .45); }
.modal form { display: flex; flex-direction: column; max-height: 90vh; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; font-size: 16px; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--border); background: #f8fafc; }

/* ---------- Login ---------- */
.login-modal { width: min(400px, 94vw); }
.login-modal .modal-body { padding-bottom: 6px; }
.login-error {
  background: #fee2e2; color: #991b1b; border: 1px solid #fecaca;
  border-radius: 8px; padding: 9px 11px; font-size: 13px; margin-top: 4px;
}
.user-box {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 4px 2px 8px; border-bottom: 1px solid #1e293b; margin-bottom: 4px;
}
.user-name {
  font-size: 12.5px; font-weight: 600; color: #e2e8f0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-box .btn { padding: 5px 10px; font-size: 12px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: #0f172a; color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 999;
  box-shadow: var(--shadow); font-size: 13.5px; max-width: 90vw;
}
.toast.err { background: var(--danger); }
.toast.ok { background: var(--ok); }

/* ---------- Workload ---------- */
.workload-scroll { overflow-x: auto; }
.wl-table th, .wl-table td { padding: 7px 9px; font-size: 12.5px; white-space: nowrap; }
.wl-table th.sticky-col, .wl-table td.sticky-col { position: sticky; left: 0; background: var(--panel); z-index: 2; }
.wl-table th.sticky-col { background: #f8fafc; z-index: 3; }
.wl-table tbody tr:hover td.sticky-col { background: #f8fafc; }
.wl-cell { border-radius: 5px; text-align: center; font-variant-numeric: tabular-nums; }
.wl-0 { color: #94a3b8; }
.wl-low { background: #dcfce7; color: #166534; }
.wl-mid { background: #fef9c3; color: #854d0e; }
.wl-high { background: #fed7aa; color: #9a3412; }
.wl-over { background: #fecaca; color: #991b1b; font-weight: 700; }
.wl-week-label { font-size: 11px; color: var(--muted); }
.detail-row td { background: #f8fafc; }
.detail-list { margin: 0; padding-left: 18px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); align-items: center; }
.legend span.lg { display: inline-flex; align-items: center; gap: 5px; }
.legend .sw { width: 14px; height: 12px; border-radius: 3px; display: inline-block; }
.wl-toolbar { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.wl-toolbar .field { margin: 0; }

/* ---------- Capacity ---------- */
.table-scroll { overflow-x: auto; }
.cap-table th.sticky-col, .cap-table td.sticky-col { position: sticky; left: 0; background: var(--panel); z-index: 2; }
.cap-table th.sticky-col { background: #f8fafc; z-index: 3; }
.cap-table tbody tr:hover td.sticky-col { background: #f8fafc; }
.month-picker { display: inline-flex; align-items: center; gap: 6px; }
.month-picker input[type="month"] { width: auto; min-width: 155px; }
.month-picker .btn { font-size: 15px; line-height: 1; padding: 7px 11px; }
.cap-table th, .cap-table td { padding: 9px 12px; font-size: 13px; vertical-align: middle; }
.cap-table td.cap-res { white-space: nowrap; }
.cap-table td.cap-projects { min-width: 260px; white-space: normal; }
.cap-util { min-width: 124px; white-space: nowrap; }
.cap-pct { font-weight: 700; font-variant-numeric: tabular-nums; }
.cap-pct.none { color: #94a3b8; font-weight: 600; }
.cap-pct.low { color: #166534; }
.cap-pct.mid { color: #854d0e; }
.cap-pct.over { color: var(--danger); }
.cap-bar { display: block; height: 5px; margin-top: 5px; border-radius: 3px; background: #eef2f7; overflow: hidden; }
.cap-bar > span { display: block; height: 100%; min-width: 0; border-radius: 3px; background: #3b82f6; }
.cap-bar > span.none { background: #cbd5e1; }
.cap-bar > span.mid { background: #f59e0b; }
.cap-bar > span.over { background: var(--danger); }
.chip-link { cursor: pointer; border: 1px solid transparent; transition: border-color .12s, color .12s, background .12s; }
.chip-link:hover { border-color: var(--primary); color: var(--primary); background: #eff6ff; }

/* ---------- Barre dei filtri (Progetti / Risorse / Workload) ---------- */
.list-toolbar { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.list-toolbar .field { margin: 0; }
.list-toolbar .field input[type="search"] { min-width: 240px; }
.list-toolbar .btn { margin-bottom: 1px; }
.toolbar-count { align-self: flex-end; padding-bottom: 8px; font-size: 12.5px; white-space: nowrap; }
.check-inline { display: inline-flex; align-items: center; gap: 6px; align-self: flex-end; margin: 0; padding-bottom: 8px; font-size: 12.5px; font-weight: 500; color: var(--text); cursor: pointer; }
.check-inline input { width: auto; margin: 0; }
.seg { display: inline-flex; gap: 6px; }

/* Colonna weekend nel workload giornaliero */
.wl-table th.wl-weekend { background: #eef2f7; }
.wl-cell.wl-weekend-cell:not(.wl-low):not(.wl-mid):not(.wl-over) { background: #f8fafc; }

/* ---------- Gantt ---------- */
.gantt-controls { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 12px; }
.gantt-scroll {
  overflow: auto;
  max-height: calc(100vh - 200px);
  min-height: 260px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel);
  overscroll-behavior: contain;
}
.gantt-inner { display: inline-block; min-width: 100%; }
.gantt-row { display: flex; align-items: stretch; }
.gantt-label {
  position: sticky; left: 0; z-index: 3; width: 230px; flex: 0 0 230px;
  padding: 8px 12px; background: var(--panel); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; justify-content: center; gap: 2px;
}
.gantt-label .g-name { font-weight: 600; font-size: 13px; }
.gantt-label .g-sub { font-size: 11px; color: var(--muted); }
.gantt-track { position: relative; height: 40px; border-bottom: 1px solid var(--border); }
.gantt-header .gantt-track { height: 46px; border-bottom: 1px solid var(--border-strong); }
.gantt-header { position: sticky; top: 0; z-index: 4; background: #f8fafc; }
.gantt-header .gantt-label { background: #f8fafc; font-size: 12px; font-weight: 600; color: var(--muted); align-items: center; }
.gantt-months { position: absolute; top: 0; left: 0; height: 20px; }
.gantt-month { position: absolute; top: 0; height: 100%; border-left: 1px solid var(--border-strong); font-size: 11px; color: var(--muted); padding: 3px 0 0 6px; box-sizing: border-box; overflow: hidden; white-space: nowrap; }
.gantt-days { position: absolute; top: 20px; left: 0; right: 0; bottom: 0; }
.gantt-day {
  position: absolute; top: 0; height: 100%; box-sizing: border-box;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-left: 1px solid rgba(148,163,184,.25); overflow: hidden; line-height: 1.05;
}
.gantt-day .gd-num { font-size: 10px; font-weight: 600; color: #475569; font-variant-numeric: tabular-nums; }
.gantt-day .gd-wd { font-size: 8.5px; color: #94a3b8; text-transform: uppercase; letter-spacing: .02em; }
.gantt-day.we { background: rgba(148,163,184,.14); }
.gantt-day.we .gd-num { color: #94a3b8; font-weight: 500; }
.gantt-days.dense .gantt-day .gd-num { font-size: 9px; }
.gantt-bar {
  position: absolute; top: 8px; height: 24px; border-radius: 6px; cursor: pointer;
  display: flex; align-items: center; padding: 0 8px; overflow: hidden;
  font-size: 11.5px; color: #fff; white-space: nowrap; box-shadow: 0 1px 2px rgba(0,0,0,.15);
}
.gantt-bar:hover { filter: brightness(1.08); }
.bar-planned { background: #64748b; }
.bar-active { background: #2563eb; }
.bar-onhold { background: #d97706; }
.bar-done { background: #059669; }
/* Fasce "oggi" e "deadline": occupano l'intera colonna del giorno (non una linea) e sono
   trasparenti, così le barre dei progetti restano visibili sotto. `pointer-events: none`
   fa passare i click alle barre sottostanti. */
.gantt-band { position: absolute; top: 0; bottom: 0; pointer-events: none; }
.gantt-band-head { z-index: 0; } /* in testata: sopra lo sfondo, sotto le celle della data */
.gantt-band-body { z-index: 1; } /* nel corpo: sopra le barre, sotto la colonna nomi (z 3) */
.band-today { background: rgba(16, 163, 74, .18); }
.band-deadline { background: rgba(220, 38, 38, .15); }
.gantt-band-label {
  position: absolute; top: 3px; left: 3px;
  font-size: 10px; font-weight: 700; line-height: 1;
  padding: 3px 6px; border-radius: 4px; white-space: nowrap;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .18);
}
.band-label-today { color: #047857; border: 1px solid #16a34a; }
.band-label-deadline { color: #b91c1c; border: 1px solid #dc2626; }
.gantt-release-marker { position: absolute; top: 4px; width: 0; height: 0; border-left: 6px solid transparent; border-right: 6px solid transparent; border-top: 10px solid #7c3aed; z-index: 2; cursor: help; }
.gantt-bar-task { top: 5px; height: 16px; background: #e0e7ff; border: 1px solid #6366f1; color: #3730a3; font-size: 10.5px; border-radius: 4px; box-shadow: none; }
.gantt-task-row .gantt-track { height: 26px; }
.gantt-task-label { padding-left: 28px; cursor: pointer; }
.gantt-task-label .g-sub { font-style: italic; }
.gantt-task-label:hover .g-sub { text-decoration: underline; }

/* ---------- Editor deadline (Gantt) ---------- */
/* Le deadline stanno in orizzontale: la barra dei controlli resta bassa anche
   con più deadline, così il Gantt non viene spinto fuori schermo. */
.dl-field { flex: 1 1 100%; min-width: 0; }
.dl-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 12.5px; font-weight: 600; color: #334155; margin-bottom: 5px; }
.dl-list { display: flex; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 6px; }
.dl-row { display: flex; align-items: center; gap: 6px; }
.dl-row .dl-date { width: 140px; flex: 0 0 auto; }
.dl-row .dl-label { width: 170px; flex: 0 0 auto; min-width: 0; }
.dl-empty { font-size: 12px; padding: 2px 0; }
.dl-field .btn-sm { margin-top: 0; flex: 0 0 auto; }

/* ---------- Release: elenco collassabile ---------- */
.rel-head { align-items: flex-start; }
.rel-title { flex: 1; min-width: 0; display: flex; align-items: flex-start; gap: 9px; cursor: pointer; border-radius: 6px; padding: 2px 4px; margin: -2px -4px; }
.rel-title:hover { background: #f8fafc; }
.rel-title:focus-visible { outline: 2px solid #bfdbfe; outline-offset: 1px; }
.rel-caret { color: var(--muted); font-size: 13px; line-height: 1.5; flex: none; }
.badge-count { background: #e2e8f0; color: #334155; margin-left: 6px; font-weight: 600; }
/* ---------- Dettaglio task ---------- */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 18px; }
.detail-grid > div > .muted { display: block; font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; margin-bottom: 2px; }
.detail-actions { margin-top: 16px; display: flex; justify-content: flex-end; }
.gantt-group-row { display: flex; background: #f1f5f9; border-bottom: 1px solid var(--border); }
.gantt-group-row .gantt-label { background: #f1f5f9; font-weight: 700; font-size: 12px; color: #334155; }
.gantt-grid { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--border); }
.gantt-track-bg {
  background-image:
    linear-gradient(to right, rgba(148,163,184,.35) 1px, transparent 1px),
    linear-gradient(to right, rgba(148,163,184,.15) 1px, transparent 1px);
}

/* ---------- Capacity: Gantt per risorsa ---------- */
.rt-scroll {
  overflow: auto;
  max-height: calc(100vh - 280px);
  min-height: 220px;
  overscroll-behavior: contain;
}
.rt-inner { display: inline-block; min-width: 100%; }
.rt-row { display: flex; align-items: stretch; }
.rt-label {
  position: sticky; left: 0; z-index: 3; width: 230px; flex: 0 0 230px;
  padding: 8px 12px; background: var(--panel); border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  display: flex; flex-direction: column; justify-content: center; gap: 2px;
}
.rt-label .g-name { font-weight: 600; font-size: 13px; }
.rt-label .g-sub { font-size: 11px; color: var(--muted); }
.rt-head { position: sticky; top: 0; z-index: 4; background: #f8fafc; }
.rt-head .rt-label { background: #f8fafc; border-bottom: 1px solid var(--border-strong); }
.rt-track { position: relative; border-bottom: 1px solid var(--border); }
.rt-track-head { height: 44px; background: #f8fafc; border-bottom: 1px solid var(--border-strong); }
.rt-day {
  position: absolute; top: 0; height: 100%; box-sizing: border-box;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-left: 1px solid rgba(148,163,184,.25); overflow: hidden; line-height: 1.05;
}
.rt-day .gd-num { font-size: 10px; font-weight: 600; color: #475569; font-variant-numeric: tabular-nums; }
.rt-day .gd-wd { font-size: 8.5px; color: #94a3b8; text-transform: uppercase; letter-spacing: .02em; }
.rt-day.we { background: rgba(148,163,184,.14); }
.rt-today { position: absolute; top: 0; bottom: 0; z-index: 1; background: rgba(16,163,74,.14); pointer-events: none; }
.rt-bar {
  position: absolute; height: 18px; box-sizing: border-box; z-index: 2;
  border-radius: 4px; color: #fff; font-size: 10.5px; font-weight: 600;
  line-height: 18px; padding: 0 5px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  cursor: pointer; box-shadow: 0 1px 2px rgba(0,0,0,.16);
}
.rt-bar:hover { filter: brightness(1.08); }
.rt-empty { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); font-size: 11px; color: var(--muted); }

/* Ferie delle risorse (nuova funzionalità): banda tratteggiata sulla riga + chip. */
.rt-holiday {
  position: absolute; top: 0; bottom: 0; z-index: 3; pointer-events: none;
  background: repeating-linear-gradient(45deg,
    rgba(217, 119, 6, .28) 0, rgba(217, 119, 6, .28) 5px,
    rgba(217, 119, 6, .10) 5px, rgba(217, 119, 6, .10) 10px);
  border-left: 1px solid rgba(217, 119, 6, .55);
  border-right: 1px solid rgba(217, 119, 6, .55);
}
.rt-hol-chip {
  display: inline-block; margin-left: 6px; padding: 0 5px; border-radius: 999px;
  background: rgba(217, 119, 6, .14); color: #b45309; border: 1px solid rgba(217, 119, 6, .35);
  font-size: 10.5px; font-weight: 600; white-space: nowrap;
}
.rt-hol-legend { margin-left: 12px; display: inline-flex; align-items: center; gap: 5px; color: #b45309; }
.rt-hol-legend .sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block;
  background: repeating-linear-gradient(45deg, rgba(217,119,6,.5) 0, rgba(217,119,6,.5) 3px, rgba(217,119,6,.15) 3px, rgba(217,119,6,.15) 6px); }

/* Celle del Workload con ferie: capacità ridotta nel periodo. */
.wl-cell.wl-holiday { box-shadow: inset 0 0 0 1px rgba(217, 119, 6, .5); }
.wl-holiday-sw { background: repeating-linear-gradient(45deg, rgba(217,119,6,.5) 0, rgba(217,119,6,.5) 3px, rgba(217,119,6,.15) 3px, rgba(217,119,6,.15) 6px); }

/* Editor ferie nel form risorsa. */
.holiday-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.holiday-row { display: grid; grid-template-columns: 1fr 14px 1fr 1fr 30px; gap: 6px; align-items: center; }
.holiday-row .h-sep { text-align: center; color: var(--muted); font-size: 12px; }
.holiday-row .h-note, .holiday-row input[type="date"] { width: 100%; }

/* ---------- Archivio (dati storici in sola lettura) ---------- */
.arch-note { margin: 10px 0 0; font-size: 12.5px; }
.arch-src { font-size: 12.5px; }
.arch-list { padding: 0; overflow: hidden; }
.arch-item { border-bottom: 1px solid var(--border); }
.arch-item:last-child { border-bottom: 0; }
.arch-head { display: flex; align-items: center; gap: 8px; padding: 10px 16px; cursor: pointer; user-select: none; }
.arch-head:hover { background: #f8fafc; }
.arch-head:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.arch-caret { width: 12px; flex: 0 0 auto; color: var(--muted); }
.arch-wbs { flex: 0 0 auto; min-width: 46px; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12px; }
.arch-ver { font-weight: 700; flex: 0 0 auto; }
.arch-name { flex: 1; min-width: 0; font-weight: 600; }
.arch-meta { font-size: 12.5px; white-space: nowrap; }
.arch-dates { font-size: 12.5px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.arch-body { background: #fbfcfe; border-top: 1px solid var(--border); }
.arch-body .table th { position: static; }
.arch-sub { padding: 10px 16px 0; font-size: 12.5px; color: var(--muted); }
.arch-core { display: flex; flex-wrap: wrap; gap: 8px; }
.arch-core-item { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; font-size: 12.5px; }
.cap-bar { display: inline-block; vertical-align: middle; width: 120px; height: 8px; border-radius: 4px; background: #e2e8f0; overflow: hidden; }
.cap-bar > span { display: block; height: 100%; }
.cap-bar.req > span { background: #f59e0b; }
.cap-bar.avail > span { background: #3b82f6; }

/* ---------- Progetti: vista FTE allocati nel tempo ---------- */
.segmented { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; align-self: flex-end; }
.fte-view-mode { display: inline-flex; align-items: center; gap: 8px; margin-left: 12px; }
.fte-section-title { padding: 10px 16px; font-weight: 600; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); background: #f8fafc; }
.fte-project-block { border-bottom: 1px solid var(--border); }
.fte-project-block:last-child { border-bottom: 0; }
.fte-project-block-head { padding: 8px 16px; font-weight: 600; background: #fbfcfe; }
.fte-mini th, .fte-mini td { padding: 6px 16px; }
.fte-project-detail { max-height: 560px; overflow: auto; }
.seg-btn { border: 0; background: #fff; padding: 8px 14px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg-btn + .seg-btn { border-left: 1px solid var(--border-strong); }
.seg-btn:hover { background: #f8fafc; color: var(--text); }
.seg-btn.active { background: #eff6ff; color: #1d4ed8; }
.fte-toolbar { margin-bottom: 8px; }
.fte-projects { border-top: 1px solid var(--border); padding-top: 12px; }
.fte-projects-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.fte-projects-head label { margin: 0; }
.fte-proj-list {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 4px 14px;
  max-height: 132px; overflow: auto; border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; background: #f8fafc;
}
.fte-proj { display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500; margin: 0; color: var(--text); }
.fte-proj input { width: auto; }
.fte-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; padding: 12px 16px; border-bottom: 1px solid var(--border); background: #f8fafc; }
.fte-sum-chip { font-size: 13px; }
.fte-sum-chip strong { font-size: 15px; }
.fte-hint { padding: 8px 16px; margin: 0; border-bottom: 1px solid var(--border); }
.fte-scroll { max-height: 560px; overflow: auto; }
.fte-scroll .table th { background: var(--panel); z-index: 1; box-shadow: inset 0 -1px 0 var(--border); }
.fte-table .is-weekend { background: #fafbfc; color: var(--muted); }
.fte-table .is-weekend .chip { opacity: .7; }
.fte-bar-cell { width: 26%; min-width: 120px; }
.fte-bar { height: 10px; border-radius: 5px; background: linear-gradient(90deg, #60a5fa, #2563eb); min-width: 2px; }
.fte-parts { display: flex; flex-wrap: wrap; gap: 4px; }

/* ---------- Changelog ---------- */
.chg-day { margin-bottom: 12px; }
.chg-day-head { display: flex; align-items: baseline; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--border); background: #f8fafc; }
.chg-day-head strong { font-size: 13.5px; }
.chg-entry { padding: 10px 16px; border-bottom: 1px solid var(--border); }
.chg-entry:last-child { border-bottom: 0; }
.chg-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chg-time { font-size: 12px; color: var(--muted); }
.chg-badge { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; padding: 2px 7px; border-radius: 999px; }
.chg-create { background: #dcfce7; color: #166534; }
.chg-update { background: #dbeafe; color: #1e40af; }
.chg-delete { background: #fee2e2; color: #991b1b; }
.chg-proj { font-weight: 600; font-size: 13px; }
.chg-changes { margin: 6px 0 0; padding-left: 18px; font-size: 12.5px; line-height: 1.55; }
.chg-changes li { margin: 1px 0; }
.chg-sub { margin: 2px 0 4px; padding-left: 16px; }
.chg-reason { color: #92400e; }

@media (max-width: 720px) {
  .sidebar { width: 64px; flex-basis: 64px; }
  .brand div, .nav-item span:not(.nav-ico), .sidebar-footer { display: none; }
  .nav-item { justify-content: center; }
  .assign-row { grid-template-columns: 1fr 70px 34px; }
  .assign-row .a-start, .assign-row .a-end { display: none; }
  .arch-meta { display: none; }
}
