:root {
  --bg: #fbfaf7; --surface: #ffffff; --fg: #1d2b33; --muted: #5d6b73; --line: #d9d6cd;
  --navy: #225165; --wine: #cf307c; --orange: #f39664; --turq: #33b7b8; --teal: #1b7f80; --green: #66783f;
  --danger: #b3261e; --ok: #2e7d4f; --hub-bg: #225165; --hub-fg: #fff; --font: "Fira Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) { :root {
  --bg: #11191d; --surface: #182329; --fg: #e8edef; --muted: #9fb0b8; --line: #2b3b43;
  --navy: #8fc3d9; --wine: #f06aa3; --orange: #f39664; --teal: #4fc9c9; --green: #a7c06c; --danger: #ff8a80; --ok: #7fd0a0; --hub-bg: #1d4455; --hub-fg: #fff;
  color-scheme: dark; } }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 400 16px/1.5 var(--font); }
h1, h2, h3, h4 { margin: 0; font-weight: 700; line-height: 1.15; text-wrap: balance; }
p { margin: 0; } ul, ol { margin: 0; padding: 0; list-style: none; }
a { color: var(--teal); } img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
.boot { padding: 40px; text-align: center; color: var(--muted); }
.wrap { max-width: 1180px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }

/* fascia del marchio */
.brandband { background: #fff; border-bottom: 0; }
.brand { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 14px; padding-bottom: 12px; flex-wrap: wrap; }
.brand-l { display: flex; align-items: center; gap: 18px; min-width: 0; flex-wrap: wrap; }
.brand img.cs { height: 52px; width: auto; } .brand img.dama { height: 58px; width: auto; } .brand img.cat { height: 86px; width: auto; }
.stripe { height: 5px; background: linear-gradient(90deg, #225165 0 20%, #cf307c 20% 40%, #f39664 40% 60%, #33b7b8 60% 80%, #93a56a 80%); }
@media (max-width: 640px) { .brand img.cs { height: 40px; } .brand img.dama { height: 44px; } .brand img.cat { height: 62px; } .brand-l { gap: 10px; } }

/* barra di navigazione */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar .wrap { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.nav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.nav a { display: inline-flex; align-items: center; gap: 6px; padding: 12px 12px; color: var(--fg); text-decoration: none; font-weight: 600; font-size: 14.5px; border-bottom: 3px solid transparent; white-space: nowrap; }
.nav a:hover { color: var(--wine); } .nav a.on { border-bottom-color: var(--wine); color: var(--navy); }
.badge { background: var(--wine); color: #fff; border-radius: 9px; padding: 0 6px; font-size: 11px; line-height: 17px; font-weight: 700; }
.who { display: flex; align-items: center; gap: 10px; font-size: 13.5px; color: var(--muted); white-space: nowrap; }
@media (max-width: 760px) { .who .nm { display: none; } }

main.wrap { padding-top: 26px; padding-bottom: 80px; }
.head { display: grid; gap: 10px; margin-bottom: 26px; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--wine); }
.head h1 { font-size: clamp(28px, 4.6vw, 42px); color: var(--navy); }
.lede { max-width: 70ch; color: var(--fg); }
.muted { color: var(--muted); } .small { font-size: 13px; }

/* pulsanti e moduli */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--navy); background: var(--navy); color: #fff; padding: 8px 16px; min-height: 38px; border-radius: 2px; font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none; }
.btn:hover { filter: brightness(1.1); } .btn:disabled { opacity: .5; cursor: default; }
.btn.alt { background: transparent; color: var(--navy); } .btn.wine { background: var(--wine); border-color: var(--wine); }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--danger); } .btn.sm { min-height: 30px; padding: 3px 10px; font-size: 13px; }
.lnk { background: none; border: 0; color: var(--teal); padding: 4px 2px; cursor: pointer; font-weight: 600; font-size: 13.5px; text-decoration: underline; text-underline-offset: 2px; }
.lnk:hover { color: var(--wine); } .lnk.danger { color: var(--danger); }
:focus-visible { outline: 2px solid var(--wine); outline-offset: 2px; }
label.f { display: grid; gap: 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=date], select, textarea { width: 100%; border: 1px solid var(--line); background: var(--surface); padding: 8px 10px; border-radius: 2px; min-height: 38px; font-weight: 400; color: var(--fg); }
textarea { min-height: 90px; resize: vertical; line-height: 1.45; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; } .grid2 { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.stack { display: grid; gap: 14px; }
.err { color: var(--danger); font-weight: 600; font-size: 14px; }

/* chip di stato */
.chip { display: inline-block; margin-left: 6px; padding: 0 5px; border: 1px solid currentColor; font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; line-height: 1.5; white-space: nowrap; vertical-align: .1em; }
.chip.nuovo { color: var(--wine); } .chip.aggiornato { color: var(--teal); } .chip.validare { color: var(--muted); }
.chip.st-fatta, .chip.st-chiusa { color: var(--ok); } .chip.st-corso { color: var(--teal); } .chip.st-fare, .chip.st-prep { color: var(--muted); }
.hub .chip { color: rgba(255,255,255,.92); } .hub .chip.nuovo { color: #ffd0e3; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 22px; font-size: 13px; color: var(--muted); align-items: center; }
.legend .chip { margin-left: 0; }

/* sezioni del modello */
.index { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 4px 0 8px; font-size: 14px; }
.sec { margin-top: 56px; display: grid; gap: 20px; min-width: 0; } .sec > * { min-width: 0; }
.sec-h { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.sec h2 { font-size: clamp(24px, 3.2vw, 32px); color: var(--navy); }
.sec .intro { max-width: 72ch; }
.cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); }
.card { position: relative; min-width: 0; background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--c, var(--navy)); border-radius: 2px; padding: 16px 18px 12px; display: grid; gap: 8px; align-content: start; }
.card.teal { --c: var(--teal); } .card.wine { --c: var(--wine); } .card.green { --c: var(--green); } .card.navy { --c: var(--navy); }
.card.hub { grid-column: 1 / -1; background: var(--hub-bg); color: var(--hub-fg); border-color: transparent; --c: var(--hub-fg); }
.card.wide { grid-column: 1 / -1; }
.tag { font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--c); }
.hub .tag { color: rgba(255,255,255,.8); }
.card h3 { font-size: 21px; } .card.hub h3 { font-size: 30px; }
.card .descr { font-size: 14px; color: var(--muted); } .hub .descr { color: rgba(255,255,255,.88); font-size: 16px; }
.items { display: grid; gap: 6px; }
.items li { position: relative; padding-left: 14px; font-size: 14.5px; line-height: 1.4; }
.items li::before { content: ""; position: absolute; left: 0; top: .55em; width: 5px; height: 5px; background: var(--c); }
.items li.grp { padding-left: 0; margin-top: 6px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); } .items li.grp::before { display: none; }
.hub .items { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); } .hub .items li::before { background: rgba(255,255,255,.75); } .hub .items li.grp { color: rgba(255,255,255,.8); }
.items.num { counter-reset: n; } .items.num li { counter-increment: n; padding-left: 24px; } .items.num li::before { content: counter(n); background: none; width: auto; height: auto; top: 0; font-weight: 700; color: var(--c); }
.nota { font-size: 13px; color: var(--muted); }
.tablewrap { overflow-x: auto; } table { border-collapse: collapse; width: 100%; min-width: 520px; font-size: 14.5px; }
th, td { text-align: left; vertical-align: top; padding: 8px 12px 8px 0; border-bottom: 1px solid var(--line); }
th { font-size: 12px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); } td:first-child { font-weight: 600; }
.cfoot { display: flex; flex-wrap: wrap; gap: 4px 14px; border-top: 1px solid var(--line); margin-top: 6px; padding-top: 6px; }
.hub .cfoot { border-color: rgba(255,255,255,.3); } .hub .lnk { color: #fff; }
.thread { border-top: 1px dashed var(--line); padding-top: 10px; display: grid; gap: 10px; }
.cm { display: grid; gap: 2px; font-size: 14px; padding: 8px 10px; background: color-mix(in srgb, var(--fg) 5%, transparent); border-left: 3px solid var(--wine); color: var(--fg); }
.hub .cm { color: var(--fg); background: var(--surface); }
.cm.ris { opacity: .6; border-left-color: var(--ok); } .cm .meta { font-size: 12px; color: var(--muted); }
.filelist li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; padding: 4px 0; font-size: 14px; border-bottom: 1px solid var(--line); }
.hub .filelist li a { color: #fff; }

/* commesse */
.cgrid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; } .bar i { display: block; height: 100%; background: var(--teal); }
.gantt { display: grid; gap: 0; border-top: 2px solid var(--navy); overflow-x: auto; }
.g-inner { min-width: 640px; } .g-row { display: grid; grid-template-columns: 210px 1fr; align-items: center; border-bottom: 1px solid var(--line); min-height: 34px; }
.g-lbl { font-size: 13.5px; padding: 4px 10px 4px 0; line-height: 1.25; } .g-track { position: relative; height: 34px; }
.g-bar { position: absolute; top: 9px; height: 16px; border-radius: 2px; background: var(--teal); min-width: 5px; } .g-bar.fatta { background: var(--ok); } .g-bar.fare { background: var(--navy); opacity: .55; }
.g-band { position: absolute; top: 0; bottom: 0; background: color-mix(in srgb, var(--wine) 12%, transparent); } .g-today { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--wine); z-index: 2; }
.g-ticks { position: relative; height: 24px; border-bottom: 1px solid var(--line); font-size: 11px; color: var(--muted); } .g-ticks span { position: absolute; top: 4px; padding-left: 4px; border-left: 1px solid var(--line); white-space: nowrap; }
.kv { display: grid; gap: 4px 16px; grid-template-columns: max-content 1fr; font-size: 14.5px; } .kv dt { color: var(--muted); font-weight: 600; } .kv dd { margin: 0; }

/* messaggi, elenchi */
.list > li { border-bottom: 1px solid var(--line); padding: 12px 0; display: grid; gap: 4px; }
.list > li.unread { border-left: 3px solid var(--wine); padding-left: 12px; background: color-mix(in srgb, var(--wine) 5%, transparent); }
.list .t { font-weight: 700; } .msgbody { white-space: pre-wrap; max-width: 76ch; }
.panel { background: var(--surface); border: 1px solid var(--line); padding: 16px 18px; display: grid; gap: 12px; min-width: 0; }
.diff { font: 13px/1.4 ui-monospace, Menlo, monospace; white-space: pre-wrap; border: 1px solid var(--line); background: var(--surface); padding: 8px 10px; max-height: 320px; overflow: auto; }
.diff .add { background: color-mix(in srgb, var(--ok) 18%, transparent); } .diff .del { background: color-mix(in srgb, var(--danger) 16%, transparent); text-decoration: line-through; }
.perm { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }

/* finestre */
dialog { border: 1px solid var(--line); background: var(--bg); color: var(--fg); padding: 0; width: min(760px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); border-radius: 3px; }
dialog::backdrop { background: rgba(10, 20, 26, .55); }
.dlg { display: grid; gap: 14px; padding: 18px 20px; } .dlg h3 { font-size: 22px; color: var(--navy); }
.dlg .actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; position: sticky; bottom: 0; background: var(--bg); padding-top: 8px; }
.login { max-width: 400px; margin: 40px auto; }
#toast { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--navy); color: #fff; padding: 10px 16px; border-radius: 3px; font-size: 14px; max-width: 90vw; z-index: 99; display: none; }
#toast.on { display: block; } #toast.bad { background: var(--danger); color: #fff; }
.src { margin-top: 56px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); display: grid; gap: 6px; }
@media (max-width: 640px) { .g-row { grid-template-columns: 1fr; } .g-lbl { padding-bottom: 0; } .g-track { margin-top: -6px; } }
