* { box-sizing: border-box; margin: 0; padding: 0; }

:root{
  --bg:#0b1220; --panel:#111a2e; --card:#16213a; --line:#24324f;
  --text:#e5eaf5; --muted:#8b98b8; --green:#22c55e; --red:#ef4444;
}

body{ font-family:'Segoe UI',system-ui,sans-serif; background:var(--bg); color:var(--text); }

header{
  display:flex; justify-content:space-between; align-items:center; flex-wrap:wrap; gap:12px;
  padding:14px 24px; background:var(--panel); border-bottom:1px solid var(--line);
  position:sticky; top:0; z-index:20;
}
h1{ font-size:1.25rem; letter-spacing:.5px; }
.budget{ font-size:.85rem; color:var(--muted); display:flex; align-items:center; gap:8px; }
.budget input{
  width:90px; background:#0d1526; border:1px solid var(--line); color:var(--text);
  border-radius:8px; padding:6px 8px; font-size:.9rem;
}

#status-bar{
  max-width:1200px; margin:12px auto 0; padding:0 20px;
  font-size:.85rem; color:var(--muted); display:flex; gap:12px; align-items:center; flex-wrap:wrap;
}
#status-bar.error{ color:var(--red); }
#upload-btn{
  background:var(--green); color:#06281a; border:none; border-radius:8px;
  padding:6px 12px; font-weight:600; cursor:pointer;
}

.layout{
  display:grid; grid-template-columns:1fr 300px; gap:20px;
  padding:20px; max-width:1200px; margin:0 auto; align-items:start;
}

.role-section{
  background:var(--card); border:1px solid var(--line);
  border-radius:12px; padding:14px 16px; margin-bottom:16px;
}
.role-head{ display:flex; justify-content:space-between; align-items:baseline; margin-bottom:10px; }
.role-head h3{ font-size:.95rem; text-transform:uppercase; letter-spacing:1px; }
.role-meta{ color:var(--muted); font-size:.78rem; }

.slot{
  display:grid; grid-template-columns:24px 1fr 120px 90px;
  gap:8px; align-items:center; margin-bottom:8px;
}
.slot-n{ color:var(--muted); font-size:.78rem; text-align:center; }

.ac-wrap{ position:relative; }
.ac-input,.credits{
  width:100%; background:#0d1526; border:1px solid var(--line); color:var(--text);
  border-radius:8px; padding:8px 10px; font-size:.9rem;
}
.ac-input:focus,.credits:focus{ outline:none; border-color:var(--green); }
.team-badge{
  font-size:.75rem; color:var(--muted); text-align:right;
  overflow:hidden; white-space:nowrap; text-overflow:ellipsis;
}

.ac-list{
  position:absolute; top:calc(100% + 4px); left:0; right:0; z-index:30;
  background:#0d1526; border:1px solid var(--line); border-radius:8px;
  max-height:230px; overflow:auto; display:none; box-shadow:0 8px 24px rgba(0,0,0,.45);
}
.ac-list.open{ display:block; }
.ac-item{
  padding:8px 10px; cursor:pointer; display:flex; justify-content:space-between;
  gap:8px; font-size:.88rem;
}
.ac-item:hover,.ac-item.active{ background:#1b2a4a; }
.ac-team{ color:var(--muted); font-size:.78rem; }

.summary{
  position:sticky; top:80px;
  background:var(--card); border:1px solid var(--line); border-radius:12px; padding:18px;
}
.summary h2{ font-size:1rem; margin-bottom:10px; }
.row{
  display:flex; justify-content:space-between; padding:8px 0;
  border-bottom:1px dashed var(--line); font-size:.92rem;
}
.row b{ font-variant-numeric:tabular-nums; }
.row.total{ border-bottom:none; margin-top:6px; font-size:1.05rem; }
.row.remaining b{ color:var(--green); font-size:1.15rem; }
.row.remaining b.negative{ color:var(--red); }

#reset{
  width:100%; margin-top:14px; background:transparent; border:1px solid var(--red);
  color:var(--red); padding:9px; border-radius:8px; cursor:pointer; font-size:.9rem;
}
#reset:hover{ background:var(--red); color:#fff; }

@media(max-width:900px){
  .layout{ grid-template-columns:1fr; }
  .summary{ position:static; order:-1; }  /* su mobile il riepilogo sta in cima */
  .team-badge{ display:none; }
  .slot{ grid-template-columns:24px 1fr 90px; }
}