:root {
  --bg: #f4f6f8;
  --card: #fff;
  --ink: #1c2430;
  --muted: #5b6775;
  --line: #d7dee7;
  --accent: #0f6a5a;
  --accent2: #0b4f43;
  --danger: #a11d2e;
  --warn: #8a6d1d;
  --ok: #1d6b3a;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, #d9efe9 0%, transparent 55%),
    radial-gradient(900px 400px at 100% 0%, #e7eef8 0%, transparent 50%),
    var(--bg);
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 20px; }
.nav {
  display: flex; gap: 14px; align-items: center; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 16px; margin-bottom: 18px;
}
.nav .brand { font-weight: 700; color: var(--accent2); margin-right: auto; }
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 18px; margin-bottom: 16px;
}
h1,h2,h3 { margin-top: 0; }
.muted { color: var(--muted); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 800px) { .grid2 { grid-template-columns: 1fr; } }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=password], input[type=date], input[type=file], select, textarea {
  width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px;
  font: inherit; background: #fff;
}
textarea { min-height: 70px; }
.btn {
  display: inline-block; border: 0; border-radius: 8px; padding: 9px 14px;
  background: var(--accent); color: #fff; font-weight: 600; cursor: pointer;
}
.btn:hover { background: var(--accent2); }
.btn.secondary { background: #405466; }
.btn.danger { background: var(--danger); }
.btn.light { background: #e8eef3; color: var(--ink); }
table { width: 100%; border-collapse: collapse; }
th, td { border-bottom: 1px solid var(--line); padding: 8px 6px; text-align: left; font-size: 14px; vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.flash { padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; }
.flash.ok { background: #e6f6eb; color: var(--ok); }
.flash.error { background: #fdebec; color: var(--danger); }
.flash.warn { background: #fff6db; color: var(--warn); }
.login-box { max-width: 420px; margin: 8vh auto; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; background: #e7f4f1; color: var(--accent2); font-size: 12px; font-weight: 600; }
.badge.off { background: #f3e6e8; color: var(--danger); }
.badge.ok { background: #e6f6eb; color: var(--ok); }
.badge.warn { background: #fff6db; color: var(--warn); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline-form { display: inline; margin: 0; }
pre.preview {
  white-space: pre-wrap; background: #f7fafc; border: 1px solid var(--line);
  border-radius: 8px; padding: 10px; max-height: 240px; overflow: auto; font-size: 12px;
}
.pw-wrap {
  position: relative;
  display: block;
  width: 100%;
}
.actions .pw-wrap {
  width: auto;
  flex: 1 1 160px;
  min-width: 140px;
}
.pw-wrap input[type=password],
.pw-wrap input[type=text] {
  width: 100%;
  padding-right: 42px;
}
.pw-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 6px;
  line-height: 0;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.pw-toggle:hover { color: var(--ink); background: #eef3f7; }
.pw-toggle[aria-pressed="true"] { color: var(--accent2); }
.check-box {
  margin: 12px 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  background: #f9fbfd;
}
.check-box > summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--accent2);
  margin-bottom: 8px;
}
.check-bulk { margin: 8px 0 10px; }
.check-table { margin-top: 4px; }
.check-table td:last-child { width: 110px; }
.check-table select.check-esito { min-width: 90px; }
body.modal-open { overflow: hidden; }
.modal[hidden] { display: none !important; }
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 12px;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 28, 40, 0.45);
}
.modal-panel {
  position: relative;
  z-index: 1;
  width: min(960px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.18);
  padding: 16px 18px 18px;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.modal-head h3 { margin: 0; font-size: 18px; }
