:root {
  --navy: #1F3A6B;
  --navy-2: #2b4d87;
  --navy-ink: #16294c;
  --azure: #008BCB;
  --azure-2: #0a9bde;
  --azure-soft: #e7f5fc;
  --bg: #eef2f7;
  --panel: #ffffff;
  --panel-2: #f7f9fc;
  --border: #e2e8f0;
  --text: #1b2839;
  --muted: #667588;
  --danger: #c0392b;
  --ok: #1e8e5a;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16,42,80,.06), 0 10px 30px rgba(16,42,80,.06);
  --shadow-sm: 0 1px 2px rgba(16,42,80,.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: var(--azure); }
.boot { padding: 40px 16px; text-align: center; color: var(--muted); }

/* ---------- login (overlay a schermo intero) ---------- */
.login {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1200px 600px at 50% -10%, #2a4d86 0%, var(--navy) 55%, var(--navy-ink) 100%);
}
.login-card {
  background: var(--panel); border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.35);
  width: 100%; max-width: 380px; padding: 0; overflow: hidden;
}
.login-head {
  background: var(--navy); padding: 26px 28px 22px; display: flex; justify-content: center;
}
.login-head img { height: 52px; width: auto; }
.login-body { padding: 24px 28px 28px; display: flex; flex-direction: column; gap: 14px; }
.login-body h1 { font-size: 18px; margin: 0; }
.login-sub { color: var(--muted); margin: 0; font-size: 14px; }

/* ---------- topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; background: var(--navy);
  display: flex; align-items: center; gap: 14px; padding: 0 18px; height: 60px;
  box-shadow: 0 2px 10px rgba(16,42,80,.12);
}
.topbar .logo { height: 30px; width: auto; display: block; }
.topbar .divider { width: 1px; height: 26px; background: rgba(255,255,255,.18); }
.topbar .crumb { color: #fff; font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.topbar .crumb .sep { color: rgba(255,255,255,.5); }
.topbar .chip { color: #cfe6f5; font-weight: 500; }
.topbar .spacer { flex: 1; }
.topbar .tbtn {
  background: rgba(255,255,255,.10); color: #fff; border: 1px solid rgba(255,255,255,.16);
  padding: 7px 13px; border-radius: 8px; cursor: pointer; font: inherit; font-weight: 600; font-size: 13px;
}
.topbar .tbtn:hover { background: rgba(255,255,255,.18); }

.container { max-width: 1080px; margin: 0 auto; padding: 22px 18px 70px; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 2px; margin-bottom: 20px; border-bottom: 1px solid var(--border); }
.tab {
  padding: 11px 16px; cursor: pointer; color: var(--muted); font-weight: 600; font-size: 14px;
  border: none; background: none; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--navy); }
.tab.active { color: var(--navy); border-bottom-color: var(--azure); }

/* ---------- card ---------- */
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px;
}
.card h2 { margin: 0 0 14px; font-size: 16px; color: var(--navy); font-weight: 700; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; color: var(--muted); font-weight: 600; }
.grow { flex: 1; min-width: 150px; }

/* ---------- controlli ---------- */
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea {
  background: #fff; border: 1px solid var(--border); border-radius: 9px;
  padding: 10px 12px; width: 100%; outline: none; transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus { border-color: var(--azure); box-shadow: 0 0 0 3px var(--azure-soft); }
textarea { resize: vertical; min-height: 64px; }
.btn {
  border: 1px solid var(--border); background: #fff; border-radius: 9px;
  padding: 10px 15px; cursor: pointer; font-weight: 600; white-space: nowrap; transition: .12s;
}
.btn:hover { border-color: var(--navy); color: var(--navy); }
.btn-primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn-primary:hover { background: var(--navy-2); color: #fff; }
.btn-accent { background: var(--azure); color: #fff; border-color: var(--azure); }
.btn-accent:hover { background: var(--azure-2); color: #fff; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); color: var(--danger); }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.btn-ghost { background: none; border-color: transparent; }
.err { color: var(--danger); font-size: 13px; }
.muted { color: var(--muted); }
.pill {
  font-size: 12px; padding: 3px 10px; border-radius: 999px;
  background: var(--azure-soft); color: var(--navy); border: 1px solid #cfeafa; font-weight: 600;
}

/* ---------- tabelle ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 12px; vertical-align: middle; border: none; }
tbody tr { border-bottom: 1px solid var(--border); }
tbody tr:last-child { border-bottom: none; }
th { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; font-weight: 700; border-bottom: 1px solid var(--border); }
tbody tr:hover { background: var(--panel-2); }
.tbl-actions { display: flex; gap: 6px; justify-content: flex-end; }
td.cell-title { vertical-align: top; }

.badge { font-size: 12px; padding: 3px 9px; border-radius: 6px; font-weight: 600; display: inline-block; }
.stato-Aperto { background: #e7f5fc; color: #0a6aa0; }
.stato-Incorso { background: #fff3df; color: #a9640a; }
.stato-Sospeso { background: #eef1f4; color: #566; }
.stato-Annullato { background: #fdeaea; color: #b02525; }
.stato-Chiuso { background: #e6f6ec; color: #1e8e5a; }

/* ---------- modale ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(22,41,76,.5); display: grid; place-items: center; padding: 16px; z-index: 40; }
.modal { background: var(--panel); border-radius: 16px; box-shadow: 0 24px 70px rgba(0,0,0,.35); width: 100%; max-width: 660px; max-height: 90vh; overflow: auto; padding: 24px; }
.modal h3 { margin: 0 0 16px; color: var(--navy); }
.modal .row + .row { margin-top: 10px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

.banner { background: #fff7e6; border: 1px solid #f0d9a8; color: #8a5a00; padding: 10px 14px; border-radius: 9px; font-size: 13px; margin-bottom: 16px; }
.fu-list { margin: 8px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.fu-list li { background: var(--panel-2); border: 1px solid var(--border); border-radius: 9px; padding: 9px 11px; font-size: 13px; }
.fu-date { font-weight: 700; color: var(--navy); }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 620px) { .split { grid-template-columns: 1fr; } .topbar { padding: 0 12px; } .container { padding: 16px 12px 60px; } }
.empty { color: var(--muted); text-align: center; padding: 28px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
