:root {
  --bg: #F2F5FA; --panel: #FFFFFF; --navy: #14243A; --sidebar: #13263E; --teal: #087F84; --teal-dark: #066A6E;
  --blue: #255FA2; --muted: #65768B; --line: #DDE5EF; --orange: #D99435; --red: #C15A63; --soft: #EDF6F5;
  --radius: 10px; --shadow: 0 1px 2px rgba(20,36,58,.06), 0 4px 14px rgba(20,36,58,.05);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; color: var(--navy);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); font-size: 15px; line-height: 1.45; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.55rem; margin: 0 0 .25rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
h3 { font-size: .95rem; margin: 0 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* Layout */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { background: var(--sidebar); color: #fff; padding: 22px 14px; display: flex; flex-direction: column; gap: 4px; }
.brand { font-weight: 700; font-size: 1.2rem; padding: 0 10px 18px; letter-spacing: .3px; }
.brand span { color: #6FD0D4; }
.nav a { display: block; color: #C9D6E6; padding: 10px 12px; border-radius: 8px; font-weight: 600; }
.nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.nav a.active { background: var(--teal); color: #fff; }
.nav .soon { color: #6E8299; cursor: default; }
.nav .soon:hover { background: none; color: #6E8299; }
.nav small { font-weight: 400; font-size: .72rem; margin-left: 4px; }
.sidebar .who { margin-top: auto; border-top: 1px solid rgba(255,255,255,.1); padding: 14px 10px 0; font-size: .85rem; color: #C9D6E6; }
.sidebar .who b { color: #fff; display: block; }
.sidebar form { display: inline; }
.linkbtn { background: none; border: 0; color: #9FD8DB; cursor: pointer; padding: 0; font: inherit; font-size: .85rem; }
main { padding: 26px 32px 48px; min-width: 0; }
.demo-banner { background: #FFF6E6; border: 1px solid #F1D9A8; color: #7A5414; padding: 8px 14px; border-radius: 8px; font-size: .85rem; margin-bottom: 18px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }

/* Components */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px; margin-bottom: 18px; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.grid { display: grid; gap: 14px 18px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; margin-bottom: 18px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.tile .k { font-size: .78rem; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 700; }
.tile .v { font-size: 1.6rem; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 0; border-radius: 8px; padding: 10px 16px; font: inherit; font-weight: 700; font-size: .9rem; cursor: pointer; background: var(--teal); color: #fff; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--teal-dark); text-decoration: none; }
.btn.blue { background: var(--blue); }
.btn.ghost { background: #EAF0F7; color: var(--navy); }
.btn.ghost:hover { background: #DCE6F1; }
.btn.danger { background: var(--red); }
.btn.sm { padding: 6px 11px; font-size: .82rem; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

label.f { display: flex; flex-direction: column; gap: 4px; font-size: .8rem; font-weight: 700; color: var(--navy); }
input[type=text], input[type=date], input[type=number], input[type=password], input[type=search], select, textarea {
  font: inherit; font-size: .92rem; padding: 9px 11px; border: 1px solid #C9D5E3; border-radius: 7px; background: #fff; color: var(--navy); width: 100%; font-weight: 400; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(8,127,132,.25); border-color: var(--teal); }
textarea { min-height: 80px; resize: vertical; }
.checks { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px 18px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 600; font-size: .9rem; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.check:has(input:checked) { border-color: var(--teal); background: var(--soft); }

table.t { width: 100%; border-collapse: collapse; font-size: .9rem; }
.t th { text-align: left; background: #E9EFF6; padding: 10px 12px; font-size: .78rem; text-transform: uppercase; letter-spacing: .4px; }
.t td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.t tr:hover td { background: #F8FAFD; }
.t .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-wrap { overflow-x: auto; }

.badge { display: inline-block; padding: 3px 9px; border-radius: 99px; font-size: .74rem; font-weight: 700; white-space: nowrap; background: #E9EFF6; color: var(--navy); }
.badge.IN.ATTESA, .badge.s-attesa { background: #FFF1DA; color: #8A5A10; }
.badge.s-emesso { background: #E1ECFA; color: #1D4F8A; }
.badge.s-accettato { background: #DDF3EE; color: #0B6B55; }
.badge.s-rifiutato { background: #F8E1E3; color: #96323C; }
.badge.s-annullato { background: #EEF0F3; color: #6B7684; }

.flash { padding: 11px 14px; border-radius: 8px; margin-bottom: 14px; font-weight: 600; font-size: .9rem; }
.flash.ok { background: #DDF3EE; color: #0B6B55; }
.flash.error { background: #F8E1E3; color: #96323C; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; font-size: .9rem; }
.kv dt { color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; }
.big { font-size: 1.5rem; font-weight: 700; color: var(--teal); font-variant-numeric: tabular-nums; }
.preview-box { position: sticky; top: 16px; }
.split { display: grid; grid-template-columns: minmax(0,1fr) 340px; gap: 18px; align-items: start; }
.steps { counter-reset: s; list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.steps li { counter-increment: s; display: flex; gap: 10px; align-items: baseline; }
.steps li::before { content: counter(s); background: var(--soft); color: var(--teal); font-weight: 700; border-radius: 99px; width: 24px; height: 24px; display: inline-grid; place-items: center; flex: none; font-size: .8rem; }
.step-done::before { background: var(--teal) !important; color: #fff !important; }

/* Landing */
.landing { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: linear-gradient(160deg, #13263E 0%, #0E4B5C 100%); }
.landing .card { background: #fff; border-radius: 14px; max-width: 760px; width: 100%; padding: 36px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.landing h1 { font-size: 1.9rem; }
.feature-list { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px 22px; margin: 22px 0; padding: 0; list-style: none; font-size: .92rem; }
.feature-list li::before { content: "✓ "; color: var(--teal); font-weight: 700; }
.role-choice { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.role-choice button { text-align: left; border: 1px solid var(--line); border-radius: 10px; background: #F8FAFD; padding: 14px 16px; cursor: pointer; font: inherit; color: var(--navy); }
.role-choice button:hover { border-color: var(--teal); background: var(--soft); }
.role-choice b { display: block; margin-bottom: 2px; }

@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 12px; }
  .brand { padding: 0 10px 0 4px; }
  .nav { display: flex; flex-wrap: wrap; gap: 2px; }
  .nav a { padding: 7px 10px; }
  .sidebar .who { margin: 0; border: 0; padding: 4px 8px; }
  main { padding: 18px 16px 40px; }
  .split { grid-template-columns: 1fr; }
  .tiles, .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .g3 { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 600px) {
  .g2, .g3, .g4, .checks, .feature-list, .role-choice { grid-template-columns: 1fr; }
  .landing .card { padding: 24px 18px; }
}

/* Tabs e workspace SGI */
.tabs { display: flex; flex-wrap: wrap; gap: 0 4px; border-bottom: 2px solid var(--line); margin-bottom: 18px; }
.tabs a { padding: 10px 14px; font-weight: 700; font-size: .9rem; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -2px; white-space: nowrap; }
.tabs a:hover { color: var(--navy); text-decoration: none; }
.tabs a.active { color: var(--teal); border-bottom-color: var(--teal); }
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pills a { padding: 6px 12px; border-radius: 99px; border: 1px solid var(--line); background: #fff; font-weight: 600; font-size: .85rem; color: var(--navy); }
.pills a.active { background: var(--navy); border-color: var(--navy); color: #fff; }
.pills a:hover { text-decoration: none; border-color: var(--teal); }
.badge.d-bozza { background: #FFF1DA; color: #8A5A10; }
.badge.d-in-revisione { background: #EDE5FA; color: #5B3A99; }
.badge.d-approvato { background: #DDF3EE; color: #0B6B55; }
.badge.d-emesso { background: #E1ECFA; color: #1D4F8A; }
.badge.d-obsoleto { background: #EEF0F3; color: #6B7684; }
.notice { padding: 14px 16px; border-radius: 10px; background: #FFF6E6; border: 1px solid #F1D9A8; margin-bottom: 18px; }
.notice.ok { background: #EAF7F3; border-color: #BFE5DA; }
details.box { border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; margin-bottom: 12px; background: #FBFCFE; }
details.box summary { cursor: pointer; font-weight: 700; }
details.box[open] summary { margin-bottom: 12px; }
.section-note { border-top: 1px solid var(--line); padding-top: 16px; margin-top: 16px; }
.section-note:first-of-type { border-top: 0; margin-top: 0; padding-top: 0; }
.logo-preview { max-width: 220px; max-height: 90px; border: 1px solid var(--line); border-radius: 8px; padding: 6px; background: #fff; }
.radio-row { display: flex; gap: 16px; flex-wrap: wrap; font-size: .9rem; }
.radio-row label { display: flex; gap: 6px; align-items: center; }

/* Calendario */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0,1fr)); gap: 4px; }
.cal-h { font-size: .74rem; font-weight: 700; text-transform: uppercase; color: var(--muted); text-align: center; padding: 4px 0; }
.cal-d { min-height: 92px; border: 1px solid var(--line); border-radius: 8px; padding: 5px; background: #fff; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal-d.out { background: #F7F9FC; color: #A7B3C2; }
.cal-d.today { border-color: var(--teal); box-shadow: inset 0 0 0 1px var(--teal); }
.cal-d .n { font-size: .8rem; font-weight: 700; }
.cal-d .ev { display: block; font-size: .72rem; padding: 2px 5px; border-radius: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-d .ev.q { background: #E1ECFA; color: #1D4F8A; }
.cal-d .ev.s { background: #DDF3EE; color: #0B6B55; }
@media (max-width: 600px) { .cal-d { min-height: 60px; } .cal-d .ev { font-size: .62rem; } }

/* Barre della dashboard: una serie, un colore, valore scritto accanto */
.bar-row { display: grid; grid-template-columns: 110px minmax(0,1fr) auto; align-items: center; gap: 10px; padding: 5px 0; }
.bar-label { font-size: .82rem; color: var(--navy); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { height: 14px; background: #EEF2F7; border-radius: 4px; overflow: hidden; }
.bar { display: block; height: 100%; background: var(--teal); border-radius: 0 4px 4px 0; min-width: 2px; }
.bar-row:hover .bar { background: var(--teal-dark); }
.bar-value { font-size: .82rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--navy); }
