:root {
  --ink: #0B1324;
  --ink-2: #131E36;
  --ink-3: #1C2A47;
  --ground: #F3F5F8;
  --card: #FFFFFF;
  --line: #E2E7EF;
  --line-2: #C5CEDC;
  --text: #0B1324;
  --text-2: #3A465C;
  --muted: #5B677D;
  --side-text: #C9D2E3;
  --side-muted: #93A1BA;
  --accent: #1F5EFF;
  --accent-dark: #1747C4;
  --accent-soft: #E8EEFF;
  --ok: #0F8A5F;
  --ok-soft: #E3F5EC;
  --warn: #A4470C;
  --warn-soft: #FDF0E6;
  --bad: #A61B1B;
  --bad-soft: #FDECEC;
  --radius: 16px;
  --font: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --display: "Space Grotesk", "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--ground); color: var(--text); font-family: var(--font); font-size: 15px; line-height: 1.45; }
a { color: var(--accent); }
a:hover { color: var(--accent-dark); }
h1, h2, h3 { font-family: var(--display); margin: 0; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Layout */
.shell { display: flex; flex-wrap: wrap; min-height: 100vh; }
.side { flex: 1 1 248px; background: var(--ink); color: var(--side-text); padding: 24px 16px; display: flex; flex-direction: column; gap: 24px; }
.main { flex: 999 1 560px; min-width: 0; padding: 24px 32px 48px; display: flex; flex-direction: column; gap: 24px; }
@media (max-width: 640px) { .main { padding: 16px; } }

.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px; text-decoration: none; color: #fff; }
.brand svg { flex: none; }
.brand-name { font-family: var(--display); font-weight: 700; font-size: 20px; letter-spacing: .1em; color: #fff; }
.brand-sub { display: block; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--side-muted); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { padding: 12px 12px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--side-muted); }
.nav a, .nav .soon { display: flex; align-items: center; gap: 12px; min-height: 42px; padding: 0 12px; border-radius: 10px; text-decoration: none; font-size: 15px; font-weight: 500; color: var(--side-text); }
.nav a:hover { background: var(--ink-2); color: #fff; }
.nav a.active { background: var(--ink-3); color: #fff; }
.nav .soon { color: #6E7C95; cursor: default; }
.nav .soon small { margin-left: auto; font-size: 11px; padding: 1px 8px; border-radius: 999px; background: var(--ink-2); color: var(--side-muted); }
.nav svg { flex: none; }

/* Top bar */
.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.topbar .spacer { flex: 1; }
.switcher { display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid #D7DEE9; border-radius: 10px; padding: 4px 4px 4px 12px; }
.switcher label { font-size: 12px; color: var(--muted); }
.switcher select { border: 0; background: transparent; font: inherit; font-weight: 600; color: var(--text); min-height: 36px; max-width: 280px; }
.userchip { display: flex; align-items: center; gap: 10px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--ink); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 14px; }
.userchip .who { display: flex; flex-direction: column; font-size: 13px; }
.userchip .who span { color: var(--muted); font-size: 12px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 10px; border: 1px solid var(--ink); background: transparent; color: var(--ink); font: inherit; font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--ink); color: #fff; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }
.btn-danger { border-color: var(--bad); color: var(--bad); }
.btn-danger:hover { background: var(--bad); color: #fff; }
.btn-small { min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn-block { width: 100%; }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; font-weight: 600; }

/* Page heading */
.pagehead { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.pagehead h1 { font-weight: 600; font-size: 32px; letter-spacing: -.01em; }
.pagehead p { margin: 6px 0 0; color: var(--muted); }
.crumb { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* Cards and grids */
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-wide { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.card.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.card h2 { font-size: 18px; font-weight: 600; }
.card .label { font-family: var(--font); font-size: 14px; font-weight: 500; color: var(--muted); }
.card.dark .label { color: var(--side-text); }
.span-2 { grid-column: span 2; }
@media (max-width: 760px) { .span-2 { grid-column: auto; } }
.kpi { font-family: var(--mono); font-size: 34px; font-weight: 600; line-height: 1.1; }
.kpi small { font-size: 15px; color: var(--side-muted); }
.note { font-size: 13px; color: var(--text-2); }
.card.dark .note { color: var(--side-text); }
.grade { width: 72px; height: 72px; border-radius: 18px; background: var(--ink-3); color: var(--side-muted); display: flex; align-items: center; justify-content: center; font-family: var(--display); font-weight: 700; font-size: 32px; }
.row { display: flex; align-items: center; gap: 16px; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--ground); color: var(--text-2); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.info { background: var(--accent-soft); color: var(--accent-dark); }

/* Severity and index */
.fill-critical { fill: #C62828; background: #C62828; }
.fill-high { fill: #E0661B; background: #E0661B; }
.fill-medium { fill: #E8B423; background: #E8B423; }
.fill-low { fill: #2F7FE0; background: #2F7FE0; }
.sevbar { width: 100%; height: 10px; border-radius: 999px; background: #E6EBF3; overflow: hidden; }
.sevlist { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--text-2); }
.sevlist span { display: inline-flex; align-items: center; gap: 6px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.pill.sev-critical { background: #FDECEC; color: #A61B1B; }
.pill.sev-high { background: #FDF0E6; color: #A4470C; }
.pill.sev-medium { background: #FBF4DC; color: #7A5C00; }
.pill.sev-low { background: #E8F1FC; color: #1D5DAD; }
.pill.sev-info { background: var(--ground); color: var(--muted); }
.grade { color: #fff; }
.grade-a, .grade-a-1, .grade-a-, .grade-a-plus { background: #0F8A5F; }
.grade-b { background: var(--accent); }
.grade-c { background: #B88A00; }
.grade-d, .grade-e { background: #C2540A; }
.grade-f { background: #A61B1B; }
.scale { display: flex; gap: 4px; }
.scale span { flex: 1; text-align: center; font-family: var(--mono); font-size: 11px; padding: 4px 0; border-radius: 4px; background: var(--ink-3); color: var(--side-muted); }
.scale span.on { background: var(--accent); color: #fff; }
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.filters .field { min-width: 180px; }
.pagehead h2 { font-size: 18px; }

/* NIS2 */
progress.meter { width: 100%; height: 10px; border: 0; border-radius: 999px; background: #E6EBF3; overflow: hidden; appearance: none; }
progress.meter::-webkit-progress-bar { background: #E6EBF3; border-radius: 999px; }
progress.meter::-webkit-progress-value { background: var(--accent); border-radius: 999px; }
progress.meter::-moz-progress-bar { background: var(--accent); border-radius: 999px; }
.card.dark progress.meter { background: var(--ink-3); }
.card.dark progress.meter::-webkit-progress-bar { background: var(--ink-3); }
.meter-cell { display: flex; align-items: center; gap: 10px; min-width: 200px; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.tabs a { min-width: 44px; min-height: 40px; display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; border: 1px solid var(--line-2); background: #fff; font-family: var(--mono); font-weight: 600; text-decoration: none; color: var(--text); }
.tabs a.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.control-head { align-items: flex-start; flex-wrap: wrap; }
.control-text { flex: 1 1 320px; }
.form-wide { max-width: none; }
.field textarea { min-height: 64px; resize: vertical; }

.kpi-small { font-size: 22px; }
.prose { font-size: 14px; line-height: 1.6; color: var(--text-2); overflow-wrap: anywhere; }
.small { font-size: 12px; }
.plainlist { margin: 0; padding-left: 18px; font-size: 13px; display: flex; flex-direction: column; gap: 4px; overflow-wrap: anywhere; }

/* Tables */
.tablewrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: .06em; white-space: nowrap; }
table.data td { padding: 12px 8px; border-bottom: 1px solid #EEF1F6; vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
.empty { padding: 32px; text-align: center; color: var(--muted); }
.logo-thumb { width: 40px; height: 40px; border-radius: 8px; object-fit: contain; background: var(--ground); border: 1px solid var(--line); }
.initials { width: 40px; height: 40px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 13px; }

/* Forms */
.form { display: flex; flex-direction: column; gap: 18px; max-width: 760px; }
.form-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 13px; font-weight: 600; }
.field input[type=text], .field input[type=email], .field input[type=password], .field input[type=number], .field select, .field textarea, .field input[type=file] {
  min-height: 44px; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line-2); background: #fff; font: inherit; color: var(--text); width: 100%;
}
.field input:focus, .field select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.field .help { font-size: 12px; color: var(--muted); }
.field .errors { margin: 0; padding: 0; list-style: none; font-size: 13px; color: var(--bad); }
.field.check { flex-direction: row; align-items: center; gap: 10px; }
.field.check input { width: 18px; height: 18px; }
.radios { display: flex; flex-wrap: wrap; gap: 10px; }
.radios label { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line-2); background: #fff; font-weight: 600; font-size: 14px; cursor: pointer; }
.radios label:has(input:checked) { border: 2px solid var(--accent); background: var(--accent-soft); color: var(--accent-dark); }
.radios ul { display: contents; list-style: none; margin: 0; padding: 0; }
.radios li { display: contents; }
.formerrors { padding: 12px 16px; border-radius: 12px; background: var(--bad-soft); color: var(--bad); font-size: 14px; }
.callout { display: flex; gap: 12px; padding: 14px 16px; border-radius: 12px; background: var(--warn-soft); color: #6B2E07; font-size: 14px; line-height: 1.5; }
.callout.info { background: var(--accent-soft); color: #13307F; }
.callout svg { flex: none; margin-top: 2px; }
.is-hidden { display: none; }

/* Messages */
.messages { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
.messages li { padding: 12px 16px; border-radius: 12px; font-size: 14px; background: var(--accent-soft); color: #13307F; }
.messages li.success { background: var(--ok-soft); color: #0B5E41; }
.messages li.error { background: var(--bad-soft); color: var(--bad); }

/* Events */
.events { display: flex; flex-direction: column; }
.events div { display: flex; justify-content: space-between; gap: 12px; min-height: 40px; align-items: center; border-bottom: 1px solid #EEF1F6; font-size: 14px; }
.events div:last-child { border-bottom: 0; }
.events time { font-family: var(--mono); font-size: 12px; color: var(--muted); white-space: nowrap; }

/* Auth pages */
.auth { display: flex; flex-wrap: wrap; min-height: 100vh; }
.auth-hero { flex: 1 1 420px; background: var(--ink); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; gap: 40px; }
.auth-hero h1 { font-weight: 600; font-size: 40px; line-height: 1.15; max-width: 480px; }
.auth-hero p { margin: 16px 0 0; font-size: 17px; line-height: 1.55; color: var(--side-text); max-width: 460px; }
.auth-hero .fine { font-size: 13px; color: var(--side-muted); }
.auth-main { flex: 999 1 480px; min-width: 0; display: flex; align-items: center; justify-content: center; padding: 48px 24px; }
.auth-card { width: 100%; max-width: 440px; background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 36px; display: flex; flex-direction: column; gap: 20px; }
.auth-card h2 { font-size: 26px; font-weight: 600; }
.auth-card .sub { margin: 6px 0 0; font-size: 14px; color: var(--muted); }
.auth-foot { display: flex; gap: 10px; align-items: center; padding-top: 18px; border-top: 1px solid #EEF1F6; font-size: 13px; color: var(--text-2); }
.otp { font-family: var(--mono) !important; font-size: 24px !important; letter-spacing: .4em; text-align: center; }
.qr { align-self: center; width: 200px; height: 200px; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.qr svg { width: 100%; height: 100%; }
.secret { font-family: var(--mono); font-size: 13px; word-break: break-all; padding: 8px 12px; border-radius: 8px; background: var(--ground); }
@media (max-width: 640px) { .auth-hero { padding: 32px 24px; } .auth-hero h1 { font-size: 30px; } .auth-card { padding: 24px; } }

/* Scansioni web */
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.card-head h2 { font-size: 17px; }
.stack { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.breakword { overflow-wrap: anywhere; }
.empty .btn { margin-top: 12px; }
.run-note { max-width: 460px; overflow-wrap: anywhere; color: var(--text-2); font-size: 13px; }
.authgrid { display: grid; gap: 8px 20px; grid-template-columns: max-content 1fr; font-size: 14px; align-items: baseline; }
.authgrid dt { color: var(--muted); font-size: 13px; }
.authgrid dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.scan-cta { align-items: center; gap: 14px; }
.scan-cta .tools { font-size: 13px; color: var(--muted); }
.trend { width: 100%; height: auto; display: block; }
.trend-line { fill: none; stroke: var(--accent); stroke-width: 2; }
.trend-area { fill: var(--accent-soft); stroke: none; }
.trend-dot { fill: var(--accent); }

/* ===== Partner dashboard (Fase A) ===== */
.kpis{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:14px;margin:18px 0}
.kpi-card{background:#fff;border:1px solid #E6EBF3;border-radius:14px;padding:16px 18px;box-shadow:0 1px 2px rgba(16,24,40,.04)}
.kpi-card .kpi-label{font-size:.78rem;color:#667085;text-transform:uppercase;letter-spacing:.04em;font-weight:600}
.kpi-card .kpi-num{font-size:2rem;font-weight:800;color:#0f2742;line-height:1.1;margin-top:4px}
.kpi-card .kpi-num small{font-size:1rem;color:#98a2b3;font-weight:600}
.kpi-card.accent{background:linear-gradient(135deg,#0ea5a4,#0f766e);border:0;color:#fff}
.kpi-card.accent .kpi-label,.kpi-card.accent .kpi-num,.kpi-card.accent small{color:#fff}
.kpi-card.promo{background:#0f2742;color:#fff;border:0;display:flex;flex-direction:column;gap:6px;justify-content:center}
.kpi-card.promo .promo-title{font-weight:800}
.kpi-card.promo .promo-sub{font-size:.82rem;color:#cbd5e1}
.planbadge{display:inline-block;font-size:.7rem;font-weight:800;letter-spacing:.06em;padding:3px 9px;border-radius:999px;vertical-align:middle;text-transform:uppercase}
.plan-silver{background:#e2e8f0;color:#475569}
.plan-gold{background:#fde68a;color:#92400e}
.plan-platinum{background:#312e81;color:#e0e7ff}
.tabs{display:flex;gap:4px;border-bottom:2px solid #E6EBF3;margin:12px 0 18px;flex-wrap:wrap}
.tabs .tab{background:none;border:0;padding:10px 16px;font-weight:600;color:#667085;cursor:pointer;border-bottom:2px solid transparent;margin-bottom:-2px}
.tabs .tab.active{color:#0f766e;border-bottom-color:#0f766e}
.clientgrid{display:grid;grid-template-columns:repeat(auto-fill,minmax(260px,1fr));gap:16px}
.clientcard{background:#fff;border:1px solid #E6EBF3;border-radius:16px;padding:16px;box-shadow:0 1px 3px rgba(16,24,40,.05);transition:box-shadow .15s,transform .15s}
.clientcard:hover{box-shadow:0 8px 24px rgba(16,24,40,.10);transform:translateY(-2px)}
.cc-head{display:flex;align-items:center;gap:8px}
.cc-head h3{margin:0;font-size:1rem;flex:1;color:#0f2742;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.statusdot{width:10px;height:10px;border-radius:50%;flex:none;background:#98a2b3}
.status-contratto{background:#22c55e}.status-trial{background:#3b82f6}.status-da_attivare{background:#f59e0b}.status-inattivo{background:#98a2b3}
.statusdot.blocked{background:#ef4444}
.cc-body{display:flex;justify-content:space-around;align-items:flex-start;gap:8px;margin:16px 0 10px;text-align:center}
.cc-metric{display:flex;flex-direction:column;align-items:center;gap:6px}
.cc-cap{font-size:.68rem;color:#667085;text-transform:uppercase;letter-spacing:.03em;font-weight:600}
.hexgrade{width:58px;height:64px;display:flex;align-items:center;justify-content:center;color:#fff;font-weight:800;font-size:1.3rem;clip-path:polygon(50% 0,100% 25%,100% 75%,50% 100%,0 75%,0 25%);background:#98a2b3}
.hexgrade.grade-a{background:#16a34a}.hexgrade.grade-b{background:#65a30d}.hexgrade.grade-c{background:#eab308}.hexgrade.grade-d{background:#f97316}.hexgrade.grade-e{background:#ea580c}.hexgrade.grade-f{background:#dc2626}.hexgrade.grade-none{background:#cbd5e1;color:#64748b}
.checkbubble{width:44px;height:44px;border-radius:50%;display:flex;align-items:center;justify-content:center;font-weight:800;font-size:1.1rem}
.checkbubble.ok{background:#dcfce7;color:#16a34a}.checkbubble.warn{background:#fef9c3;color:#a16207}.checkbubble.bad{background:#fee2e2;color:#dc2626}
.sevbar{display:flex;gap:4px;margin-top:4px}
.sevbar .sv{flex:1;text-align:center;font-size:.72rem;font-weight:700;color:#fff;border-radius:6px;padding:3px 0}
.sevbar .sv.crit{background:#dc2626}.sevbar .sv.high{background:#f59e0b}.sevbar .sv.med{background:#3b82f6}
.iconbtn{list-style:none;cursor:pointer;border:1px solid #E6EBF3;border-radius:8px;width:30px;height:30px;display:inline-flex;align-items:center;justify-content:center;color:#667085}
.iconbtn::-webkit-details-marker{display:none}
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]) .kpi-card,:root:not([data-theme="light"]) .clientcard{background:#0b1b2b;border-color:#1e3a52}
  :root:not([data-theme="light"]) .kpi-card .kpi-num,:root:not([data-theme="light"]) .cc-head h3{color:#e5edf5}
}
.partnerbrand{margin:2px 10px 12px;padding:8px 10px;border-radius:10px;background:rgba(255,255,255,.06);display:flex;flex-direction:column;gap:5px;align-items:flex-start}
.partnerbrand .pb-name{font-size:.82rem;font-weight:700;color:inherit;opacity:.95}
.clientcard.clickable{cursor:pointer}
.hexgrade.grade-locked{background:#94a3b8}
.cc-hint{font-size:.74rem;color:#667085;text-align:center;margin:6px 0 0}