:root {
  --bg: #0a1220;
  --panel: #121c2e;
  --panel2: #18253a;
  --border: #24344d;
  --text: #e8eef7;
  --muted: #8b9bb3;
  --accent: #c9a227;
  --ok: #2dd4a0;
  --warn: #fbbf24;
  --danger: #f87171;
  --blue: #38bdf8;
  --radius: 12px;
  --font: "DM Sans", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: radial-gradient(ellipse 80% 50% at 20% 0%, #152038, var(--bg));
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}
a { color: var(--blue); }
.wrap { width: min(1180px, calc(100% - 2rem)); margin: 0 auto; padding: 1.25rem 0 3rem; }
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.85rem 0 1.25rem; border-bottom: 1px solid var(--border); margin-bottom: 1.25rem;
}
.top-sticky {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(10, 18, 32, 0.94);
  backdrop-filter: blur(10px);
}
.top-left { display: flex; align-items: center; gap: 0.65rem; min-width: 0; }
.top-right { display: flex; align-items: center; gap: 0.45rem; flex-wrap: wrap; justify-content: flex-end; }
.logo { font-weight: 700; letter-spacing: 0.04em; }
.logo b { color: var(--accent); font-weight: 600; }
.muted { color: var(--muted); font-size: 0.9rem; }
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.2rem;
  margin-bottom: 1rem;
}
.card h2 { font-size: 1.05rem; margin-bottom: 0.75rem; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(4, minmax(0,1fr)); }
@media (max-width: 900px) { .grid { grid-template-columns: repeat(2, 1fr); } }
.stat {
  background: var(--panel2); border: 1px solid var(--border);
  border-radius: 10px; padding: 0.9rem 1rem;
}
.stat .n { font-size: 1.6rem; font-weight: 700; color: var(--accent); }
.stat .l { font-size: 0.8rem; color: var(--muted); }
label { display: block; font-size: 0.8rem; color: var(--muted); margin: 0.55rem 0 0.3rem; }
input, select, textarea {
  width: 100%; background: #0c1524; border: 1px solid var(--border);
  color: var(--text); border-radius: 8px; padding: 0.6rem 0.75rem; font: inherit;
}
textarea { min-height: 80px; resize: vertical; }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  border: none; border-radius: 9px; padding: 0.55rem 0.9rem;
  font: inherit; font-weight: 600; cursor: pointer; margin: 0.25rem 0.25rem 0.25rem 0;
}
.btn-primary { background: linear-gradient(135deg, #1e5a8a, #0c1f3d); color: #fff; }
.btn-ok { background: #14532d; color: #bbf7d0; }
.btn-danger { background: #7f1d1d; color: #fecaca; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn:disabled { opacity: 0.5; cursor: wait; }
#btn-refresh:disabled { opacity: 1; cursor: pointer; }
.actions-cell { white-space: normal; min-width: 11rem; }
.actions-cell .btn { margin: 0.15rem 0.2rem 0.15rem 0; font-size: 0.8rem; padding: 0.4rem 0.65rem; }
.msg { margin-top: 0.65rem; font-size: 0.88rem; display: none; }
.msg.show { display: block; }
.msg.ok { color: var(--ok); }
.msg.err { color: var(--danger); }
table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
th, td { text-align: left; padding: 0.55rem 0.4rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; }
.badge {
  display: inline-block; padding: 0.15rem 0.45rem; border-radius: 999px;
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
}
.badge.pending { background: #422006; color: var(--warn); }
.badge.active, .badge.approved { background: #052e1c; color: var(--ok); }
.badge.denied, .badge.rejected { background: #450a0a; color: var(--danger); }
.badge.revoked { background: #1f2937; color: #9ca3af; }
.chk {
  display: flex; align-items: center; gap: 0.5rem;
  margin: 0.45rem 0; color: var(--text); font-size: 0.92rem; cursor: pointer;
}
.chk input { width: auto; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
@media (max-width: 700px) { .row2 { grid-template-columns: 1fr; } }
.tabs { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; }
.tab {
  background: var(--panel2); border: 1px solid var(--border); color: var(--muted);
  border-radius: 999px; padding: 0.4rem 0.85rem; cursor: pointer; font: inherit; font-weight: 600; font-size: 0.88rem;
}
.tab.on { color: var(--bg); background: var(--accent); border-color: var(--accent); }
.panel-sec { display: none; }
.panel-sec.on { display: block; }
.hidden { display: none !important; }
.scroll { overflow-x: auto; }
.mono, code { font-family: var(--mono); font-size: 0.82rem; }
.login-box { max-width: 420px; margin: 3rem auto; }

/* Idle countdown */
.idle-timer {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  padding: 0.35rem 0.65rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel2);
  min-width: 4.5rem;
}
.idle-label { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.idle-count { font-size: 1.05rem; font-weight: 700; color: var(--ok); line-height: 1.2; }
.idle-timer.warn .idle-count { color: var(--warn); }
.idle-timer.danger .idle-count { color: var(--danger); animation: idlePulse 1s ease infinite; }
@keyframes idlePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* Hub */
.hub-intro { margin: 0.5rem 0 1.25rem; }
.hub-intro h1 { font-size: 1.55rem; margin-bottom: 0.35rem; letter-spacing: -0.02em; }
.hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}
@media (max-width: 980px) { .hub-grid { grid-template-columns: 1fr; } }
.hub-card {
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.35rem 1.25rem;
  cursor: pointer;
  color: inherit;
  font: inherit;
  display: grid;
  gap: 0.45rem;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.hub-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}
.hub-utility:hover { border-color: var(--blue); }
.hub-imprint:hover { border-color: #a78bfa; }
.hub-formichina:hover { border-color: #c45c26; }
.hub-formichina .hub-cta { color: #e8a06a; }
.hub-visite:hover { border-color: #34d399; }
.hub-visite .hub-cta { color: #6ee7b7; }
.hub-ceh:hover { border-color: #818cf8; }
.hub-ceh .hub-cta { color: #a5b4fc; }
.area-banner-ceh { border-color: rgba(129, 140, 248, 0.45); }
.hub-spesa:hover { border-color: #34d399; }
.hub-spesa .hub-cta { color: #6ee7b7; }
.area-banner-spesa { border-color: rgba(5, 150, 105, 0.5); }
.hub-riparto:hover { border-color: #c4a36a; }
.hub-riparto .hub-cta { color: #e8c99a; }
.area-banner-riparto { border-color: rgba(154, 107, 47, 0.5); }
.hub-palio:hover { border-color: #e8a06a; }
.hub-palio .hub-cta { color: #e8a06a; }
.area-banner-palio { border-color: rgba(196, 92, 38, 0.5); }
.hub-icon { font-size: 1.8rem; line-height: 1; }
.hub-title { font-size: 1.2rem; font-weight: 700; }
.hub-desc { color: var(--muted); font-size: 0.92rem; line-height: 1.45; }
.hub-stats { font-size: 0.82rem; margin-top: 0.25rem; }
.hub-cta { font-weight: 700; color: var(--accent); margin-top: 0.35rem; }
.hub-imprint .hub-cta { color: #a78bfa; }
.hub-extra { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }

.area-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 1rem;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel2);
  margin-bottom: 1rem;
}
.area-banner-utility { border-color: rgba(56, 189, 248, 0.35); }
.area-banner-imprint { border-color: rgba(167, 139, 250, 0.4); }
.area-banner-formichina { border-color: rgba(196, 92, 38, 0.45); }
.area-banner-visite { border-color: rgba(52, 211, 153, 0.4); }
.vis-toolbar-row {
  display: grid;
  grid-template-columns: 11rem 1fr auto;
  gap: 0.75rem;
  align-items: end;
}
@media (max-width: 800px) { .vis-toolbar-row { grid-template-columns: 1fr; } }
.vis-toolbar-actions { display: flex; flex-wrap: wrap; gap: 0.35rem; padding-bottom: 0.15rem; }
.vis-sid { font-size: 0.72rem; word-break: break-all; }
.badge.vis-page { background: #0b3a4a; color: #7dd3fc; }
.badge.vis-click { background: #3b2a08; color: #fbbf24; }
.badge.vis-beat { background: #1f2937; color: #9ca3af; }
.badge.vis-hide, .badge.vis-leave { background: #3f1020; color: #fda4af; }
.badge.vis-show { background: #052e1c; color: #86efac; }
.badge.vis-focus { background: #1e1b4b; color: #c4b5fd; }
.vis-int { text-transform: none; letter-spacing: 0; font-size: 0.78rem; }
.vis-int-bounce { background: #3f1020; color: #fda4af; }
.vis-int-bot { background: #1f2937; color: #9ca3af; }
.vis-int-convert { background: #052e1c; color: #86efac; }
.vis-int-deep { background: #0b3a4a; color: #7dd3fc; }
.vis-int-explore { background: #3b2a08; color: #fbbf24; }
.vis-int-care { background: #1e1b4b; color: #c4b5fd; }
.vis-int-return { background: #172554; color: #93c5fd; }
.vis-int-scan { background: #1f2937; color: #d1d5db; }
.vis-trail { font-weight: 600; }
.vis-row-mine { opacity: 0.72; }
.vis-dossier-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem;
  margin-bottom: 1rem;
}
.vis-h3 { font-size: 1rem; margin: 1.25rem 0 0.65rem; }
.vis-read {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
  line-height: 1.55;
}
.vis-read-top { display: flex; gap: 0.75rem; align-items: center; margin-bottom: 0.5rem; }
.vis-headline { font-weight: 700; font-size: 1.05rem; margin-bottom: 0.65rem; }
.vis-read p { margin-bottom: 0.65rem; }
.vis-why { margin-top: 0.75rem; padding-top: 0.75rem; border-top: 1px solid var(--border); }
.vis-why ul { margin: 0.4rem 0 0.6rem 1.1rem; }
.vis-why li { margin: 0.25rem 0; }
.vis-caveat { font-size: 0.82rem; }
.vis-idgrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.65rem;
  margin-bottom: 0.5rem;
}
.vis-fact {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
}
.vis-fact .k { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.vis-fact .v { font-size: 0.88rem; margin-top: 0.2rem; word-break: break-word; }
.vis-journey { list-style: none; display: grid; gap: 0.65rem; margin: 0 0 1rem; }
.vis-step {
  display: grid;
  grid-template-columns: 2.2rem 1fr;
  gap: 0.75rem;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.8rem 0.9rem;
}
.vis-step-n {
  width: 2.2rem; height: 2.2rem; border-radius: 999px;
  background: #052e1c; color: #86efac;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
}
.vis-step-h { display: flex; flex-wrap: wrap; gap: 0.35rem 0.85rem; align-items: baseline; margin-bottom: 0.2rem; }
.vis-step-acts { margin: 0.45rem 0 0 1rem; }
.vis-step-acts li { margin: 0.2rem 0; font-size: 0.88rem; }
.area-view { animation: areaFade 0.25s ease; }
@keyframes areaFade {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
