/* ClosePilot · direzione D con i colori OneAgent, tema chiaro e scuro.
   Il fondo esterno (--stage) deve restare uguale al colore che il menu in vetro rifrange
   (GLASS_THEMES in app.js): se cambia uno, va cambiato anche l'altro. */
:root, :root[data-theme="light"] {
  color-scheme: light;
  --stage:#EDF2FA; --shell:#F4F7FC; --card:#FFFFFF; --soft:#EAF0F9; --field:#FFFFFF; --line:#DCE3EE;
  --ink:#0A1A38; --ink2:#3C4864; --muted:#55617C;
  --brand:#1547C8; --brand2:#2E66E6; --electric:#1879F3; --link:#1547C8; --tint:#E3ECFD; --tint-ink:#1547C8;
  --ok:#0B7A4B; --ok-bg:#E3F5EC; --warn:#9A5B00; --warn-bg:#FDF3E1; --warn-line:#F2DDB2;
  --danger:#B42318; --danger-bg:#FEF1F0; --danger-line:#F3C2BD;
  --navy:#051638; --navy-ink:#FFFFFF; --navy-muted:#BAC6DD;
  --shadow:0 4px 10px rgba(5,22,56,.05),0 16px 34px rgba(5,22,56,.07);
  --accent-shadow:0 8px 24px rgba(21,71,200,.28);
}
:root[data-theme="dark"] {
  /* Tre gradini ben distinti (fondo < guscio < schede) e testi chiari: niente tono su tono. */
  color-scheme: dark;
  --stage:#101B36; --shell:#17233F; --card:#1F2C4C; --soft:#2A3961; --field:#18243F; --line:#3A4C76;
  --ink:#F3F6FC; --ink2:#D3DBEA; --muted:#A9B5CC;
  --brand:#2E66E6; --brand2:#4A80F0; --electric:#6AA6FF; --link:#9CBEFF; --tint:#2B4A8C; --tint-ink:#E1EBFF;
  --ok:#5BE3A6; --ok-bg:#155A41; --warn:#FFC877; --warn-bg:#4A3613; --warn-line:#7A5A22;
  --danger:#FF9D95; --danger-bg:#542322; --danger-line:#8A3B37;
  --navy:#0A1430; --navy-ink:#F3F6FC; --navy-muted:#C7D1E3;
  --shadow:0 4px 10px rgba(0,0,0,.28),0 16px 34px rgba(0,0,0,.32);
  --accent-shadow:0 8px 24px rgba(0,0,0,.35);
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation:none !important; transition:none !important; } }

* { box-sizing:border-box; min-width:0; }
[hidden] { display:none !important; }
html { background:var(--stage); }
body { margin:0; font:15px/1.5 Figtree,system-ui,-apple-system,"Segoe UI",sans-serif; color:var(--ink); background:var(--stage); -webkit-font-smoothing:antialiased; }
a { color:var(--link); }
.sr { position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; }
:focus-visible { outline:2px solid var(--electric); outline-offset:2px; }

/* ---------- barra in alto, sul fondo ---------- */
.top { display:flex; align-items:center; gap:16px 20px; padding:18px clamp(14px,3vw,40px); }
.brand { display:inline-flex; align-items:center; gap:10px; height:46px; padding:0 18px 0 10px; border:1px solid var(--line); border-radius:999px; background:var(--card); font-weight:700; font-size:17px; letter-spacing:-.02em; flex:none; }
.brand .mark { width:30px; height:auto; display:block; }
.brand .word { font-size:18px; font-weight:700; letter-spacing:-.025em; color:var(--ink); }
.brand .word .close { color:#0A6CF0; }
:root[data-theme="dark"] .brand .word .close { color:#5C9DFF; }
:root[data-theme="dark"] .light-only, :root:not([data-theme="dark"]) .dark-only { display:none !important; }
.login-logo { margin:0 0 22px; }
.login-logo img { display:block; width:100%; max-width:340px; height:auto; }
.logo { display:inline-grid; place-items:center; width:28px; height:28px; border-radius:8px; background:linear-gradient(150deg,var(--brand2),var(--brand)); color:#fff; font-size:14px; }
#nav { flex:1; display:flex; justify-content:center; }
.nav-src { display:flex; gap:2px; flex-wrap:wrap; padding:5px; border:1px solid var(--line); border-radius:999px; background:var(--card); }
.nav-src button { border:0; background:none; padding:9px 16px; border-radius:999px; color:var(--ink2); font-weight:500; min-height:40px; }
.nav-src button.active { background:var(--ink); color:var(--card); }
#nav.glass-on .nav-src { display:none; }
#navGlass { width:100%; }
.who { display:flex; align-items:center; gap:10px; flex:none; }
.who .pill { background:var(--card); border:1px solid var(--line); }
.who .pill.on { background:var(--ok-bg); border-color:transparent; }
.who #me { max-width:260px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
button.icon { width:44px; height:44px; padding:0; border-radius:50%; display:grid; place-items:center; color:var(--ink2); background:var(--card); }
:root[data-theme="dark"] #theme .moon, :root:not([data-theme="dark"]) #theme .sun { display:none; }
@media (max-width:1080px) {
  .top { flex-wrap:wrap; }
  #nav { order:3; flex-basis:100%; overflow-x:auto; padding:24px 4px; margin:-22px 0 -18px; }
  .who { margin-left:auto; }
  .who #me { display:none; }
}
@media (max-width:560px) { .top { gap:12px; } }

.banner { margin:0 clamp(12px,2vw,26px) 14px; background:var(--warn-bg); color:var(--ink); border:1px solid var(--warn-line); border-radius:14px; padding:10px 16px; font-size:14px; }

/* ---------- guscio e schede ---------- */
main.shell { margin:0 clamp(10px,2vw,26px) 26px; padding:clamp(18px,3vw,32px); background:var(--shell); border-radius:28px; box-shadow:var(--shadow); display:grid; gap:18px; align-content:start; min-height:70vh; }
.view { display:grid; gap:18px; align-content:start; }
.card { background:var(--card); border:1px solid var(--line); border-radius:20px; padding:20px 22px; }
.narrow { max-width:480px; width:100%; margin:40px auto; }
h2 { margin:0 0 12px; font-size:18px; font-weight:600; letter-spacing:-.02em; }
h3 { margin:0 0 8px; font-size:14px; font-weight:600; color:var(--ink2); }
.steps { margin:0 0 12px; padding-left:20px; color:var(--ink2); }
.steps li { margin:2px 0; }
.row { display:flex; flex-wrap:wrap; gap:10px 12px; align-items:end; margin:10px 0; }
.row.between { justify-content:space-between; align-items:center; margin:0; }
.row.between h2 { margin:0; }
label { display:grid; gap:4px; font-size:13px; color:var(--muted); margin:8px 0; }
label.check { display:flex; align-items:center; gap:10px; color:var(--ink); font-size:14px; }
label.check input { width:18px; height:18px; accent-color:var(--brand); flex:none; }
label.file { display:inline-flex; align-items:center; gap:8px; color:var(--link); cursor:pointer; margin:0; }
label.file input { font-size:12px; color:var(--muted); }
.consent { background:var(--warn-bg); border:1px solid var(--warn-line); padding:10px 12px; border-radius:14px; }
select, input:not([type=checkbox]):not([type=file]), textarea { font:inherit; color:var(--ink); padding:10px 12px; min-height:44px; border:1px solid var(--line); border-radius:12px; background:var(--field); width:100%; }
select { width:auto; border-radius:999px; padding:0 14px; background:var(--soft); }
textarea { resize:vertical; }
input:disabled, textarea:disabled { background:var(--soft); color:var(--muted); }
button { font:inherit; font-weight:600; font-size:14px; min-height:44px; padding:0 18px; border-radius:999px; border:1px solid var(--line); background:var(--card); color:var(--ink); cursor:pointer; }
button:disabled { opacity:.45; cursor:default; }
/* Il blu dei pulsanti e della scheda in evidenza resta lo stesso nei due temi: il bianco sopra deve restare leggibile. */
button.primary { background:linear-gradient(180deg,#2E66E6,#1547C8); border-color:transparent; color:#fff; }
button.danger { color:var(--danger); border-color:var(--danger-line); }
button.link { border:0; background:none; color:var(--link); padding:0 6px; font-weight:600; }
button.link.danger-link { color:var(--danger); }
button.small { min-height:34px; padding:0 12px; font-size:13px; }
.pill, .chip { display:inline-flex; align-items:center; gap:6px; padding:4px 11px; border-radius:99px; font-size:12.5px; font-weight:600; background:var(--soft); color:var(--ink2); white-space:nowrap; }
.pill.on::before { content:""; width:7px; height:7px; border-radius:50%; background:currentColor; }
.pill.on, .pill.good { background:var(--ok-bg); color:var(--ok); }
.pill.mid { background:var(--warn-bg); color:var(--warn); }
.muted { color:var(--muted); font-size:13px; } .small { font-size:12.5px; }
.error { color:var(--danger); background:var(--danger-bg); border:1px solid var(--danger-line); padding:10px 12px; border-radius:12px; }
.grid2 { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:18px; }
@media (max-width:820px) { .grid2 { grid-template-columns:minmax(0,1fr); } }

/* ---------- In chiamata ---------- */
.lead { display:flex; flex-wrap:wrap; align-items:flex-end; gap:18px 48px; }
.bigfield { flex:1 1 420px; }
.bigfield textarea { border:0; border-bottom:1px solid var(--line); border-radius:0; background:transparent; padding:0 0 10px; font-size:clamp(24px,3vw,34px); font-weight:500; letter-spacing:-.03em; resize:none; min-height:0; line-height:1.25; }
.bigfield textarea::placeholder { color:var(--muted); }
.bigfield textarea:focus-visible { outline:none; border-bottom-color:var(--electric); }
.bigfield p { margin:8px 0 0; }
.kpirow { display:flex; flex-wrap:wrap; gap:16px 36px; }
.kpirow > div { display:grid; grid-template-columns:auto auto; align-items:center; gap:4px 9px; }
.klabel { grid-column:1 / -1; font-size:12px; font-weight:500; color:var(--muted); }
.kpirow b { font-size:32px; font-weight:600; letter-spacing:-.035em; font-variant-numeric:tabular-nums; line-height:1.1; }
.grid4 { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:18px; }
.grid4 .wide { grid-column:span 2; }
@media (max-width:1100px) { .grid4 { grid-template-columns:repeat(2,minmax(0,1fr)); } }
@media (max-width:700px) { .grid4 { grid-template-columns:minmax(0,1fr); } .grid4 .wide { grid-column:auto; } }
.card.accent { background:linear-gradient(150deg,#2E66E6,#1547C8); border-color:transparent; color:#fff; box-shadow:var(--accent-shadow); display:flex; flex-direction:column; gap:12px; }
.card.accent h2 { font-size:21px; }
.card.accent .chip { background:rgba(255,255,255,.2); color:#fff; }
.now { margin:0; font-size:19px; font-weight:600; line-height:1.3; letter-spacing:-.015em; }
.now.empty { font-size:15px; font-weight:500; opacity:.9; }
.nowfoot { margin:auto 0 0; align-items:center; }
button.ink { display:inline-flex; align-items:center; gap:8px; border:0; background:var(--navy); color:#fff; }
button.glass-btn { width:44px; padding:0; display:grid; place-items:center; border:0; background:rgba(255,255,255,.22); color:#fff; }
button.ink[aria-pressed="true"], button.glass-btn[aria-pressed="true"] { box-shadow:0 0 0 2px #fff inset; }
.nowms { margin-left:auto; font-size:12.5px; text-align:right; }
.meters { display:flex; flex-wrap:wrap; gap:10px; margin:6px 0 8px; }
.meter { flex:1 1 200px; display:grid; gap:6px; padding:10px 14px; border:1px solid var(--line); border-radius:14px; background:var(--soft); font-size:12.5px; font-weight:600; }
meter { width:100%; height:8px; border:0; border-radius:99px; background:var(--line); -webkit-appearance:none; appearance:none; }
meter::-webkit-meter-bar { background:var(--line); border:0; border-radius:99px; height:8px; }
meter::-webkit-meter-optimum-value { background:var(--ink); border-radius:99px; }
meter.them::-webkit-meter-optimum-value { background:var(--electric); }
meter::-moz-meter-bar { background:var(--ink); border-radius:99px; }
meter.them::-moz-meter-bar { background:var(--electric); }

/* ---------- liste ---------- */
.list { list-style:none; margin:0; padding:0; display:grid; gap:8px; max-height:340px; overflow:auto; }
.list.plain { max-height:none; }
.list li { background:var(--soft); border-radius:14px; padding:10px 14px; }
.list.plain li { display:grid; gap:4px; background:var(--card); border:1px solid var(--line); }
.list li .meta { font-size:11.5px; color:var(--muted); letter-spacing:.02em; display:flex; gap:8px; align-items:center; flex-wrap:wrap; }
.list li .actions { display:flex; gap:4px; justify-content:flex-end; flex-wrap:wrap; }
.tag { font-size:11.5px; padding:2px 9px; border-radius:99px; background:var(--soft); color:var(--ink2); }
.tag.team { background:var(--tint); color:var(--tint-ink); }
.transcript { max-height:340px; overflow:auto; font-size:14px; display:grid; gap:8px; align-content:start; }
.transcript p { margin:0; display:flex; gap:10px; align-items:baseline; }
.transcript b { flex:none; font-size:11px; font-weight:600; padding:2px 9px; border-radius:99px; }
.transcript .me b { background:var(--ink); color:var(--card); }
.transcript .them b { background:var(--tint); color:var(--tint-ink); }
.transcript .interim { color:var(--muted); font-style:italic; display:block; }
.table { width:100%; border-collapse:collapse; font-size:14px; }
.table th { text-align:left; font-weight:600; color:var(--muted); font-size:12px; padding:6px 8px; border-bottom:1px solid var(--line); }
.table td { padding:10px 8px; border-bottom:1px solid var(--line); }
.card:has(> .table) { overflow-x:auto; }
.kpis { display:grid; grid-template-columns:repeat(auto-fit,minmax(150px,1fr)); gap:10px; }
.kpi { border:1px solid var(--line); border-radius:16px; padding:12px 14px; background:var(--soft); }
.kpi b { display:block; font-size:28px; font-weight:600; letter-spacing:-.03em; font-variant-numeric:tabular-nums; }
.kpi span { font-size:12.5px; color:var(--muted); }
details summary { cursor:pointer; }
details ul { margin:8px 0 0; padding-left:18px; font-size:14px; }

.status { font-size:11.5px; padding:2px 9px; border-radius:99px; background:var(--soft); color:var(--ink2); }
.status.ready, .status.approved { background:var(--ok-bg); color:var(--ok); }
.status.error, .status.rejected { background:var(--danger-bg); color:var(--danger); }
.status.working, .status.proposed { background:var(--warn-bg); color:var(--warn); }
.ki-answer { font-size:14px; color:var(--ink); border-left:3px solid var(--line); padding-left:10px; }
.ki-edit textarea, .ki-edit input { margin-top:4px; }
