/* ==========================================================================
   PureLabs MdL - Design System & UI Engineering Master Style
   Ispirato al Master Design PureLabs TV (tv_chiavari.html):
   - Tipografia Primaria: 'Outfit' (Headings, Numeri, Monogramma, Statistiche)
   - Tipografia Corpo: 'Plus Jakarta Sans' (Lettura, Dati, Metadati)
   - Palette Ufficiale PureLabs:
       --red: #FF1A46 (Crimson PureLabs vivo)
       --red-d: #D90F38
       --red-dd: #A50A2A
       --red-soft: #FFF0F3
       --navy: #14215A (Navy Profondo Istituzionale)
       --ink: #0F172A (Slate 900)
       --body: #334155 (Slate 700)
       --muted: #64748B (Slate 500)
       --line: #E2E8F0
       --bg: #F8FAFC
       --white: #FFFFFF
   - Zero testo troncato o spaginato, padding e gap armonici, micro-interazioni
   ========================================================================== */

:root {
  --red: #FF1A46;
  --red-d: #D90F38;
  --red-dd: #A50A2A;
  --red-soft: #FFF0F3;
  --navy: #14215A;
  --ink: #0F172A;
  --body: #334155;
  --muted: #64748B;
  --line: #E2E8F0;
  --bg: #F8FAFC;
  --white: #FFFFFF;

  --sidebar-w: 260px;
  --header-h: 70px;

  --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;

  --shadow-subtle: 0 1px 3px 0 rgba(15, 23, 42, 0.04);
  --shadow-card: 0 4px 16px -2px rgba(15, 23, 42, 0.06), 0 2px 4px -1px rgba(15, 23, 42, 0.03);
  --shadow-hover: 0 12px 28px -4px rgba(255, 26, 70, 0.12), 0 4px 12px -2px rgba(15, 23, 42, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg);
  color: var(--body);
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, .font-heading {
  font-family: var(--font-heading);
  letter-spacing: -0.02em;
}

/* ==========================================================================
   HEADER ISTITUZIONALE PURELABS
   ========================================================================== */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-h);
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 2px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 100;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.03);
}

/* Sidebar Verticale a Sinistra */
.app-sidebar {
  position: fixed;
  top: var(--header-h);
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--white);
  border-right: 2px solid var(--line);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px 14px;
  z-index: 90;
  transition: transform 0.25s ease;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-category-label {
  font-family: var(--font-heading);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: 10px 12px 4px 12px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 12px;
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--body);
  text-decoration: none;
  transition: all 0.16s ease;
  border: 1.5px solid transparent;
}

.nav-item:hover {
  background: var(--bg);
  color: var(--ink);
  border-color: var(--line);
}

.nav-item.active {
  background: var(--red-soft);
  color: var(--red);
  border-color: #FECDD3;
  font-weight: 800;
}

.nav-item.active i {
  color: var(--red);
}

/* Main Wrapper */
.main-wrapper {
  margin-top: var(--header-h);
  margin-left: var(--sidebar-w);
  padding: 28px 36px 60px 36px;
  min-height: calc(100vh - var(--header-h));
  transition: margin-left 0.25s ease;
}

@media (max-width: 1024px) {
  .app-sidebar {
    transform: translateX(-100%);
  }
  .app-sidebar.open {
    transform: translateX(0);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  }
  .main-wrapper {
    margin-left: 0;
    padding: 20px 16px 40px 16px;
  }
}

/* ==========================================================================
   CARD CLINICHE & FASCICOLI SANITARI (STILE PURELABS LUXURY ENTERPRISE)
   ========================================================================== */
.luxury-card, .clinical-card {
  background: var(--white);
  border-radius: 20px;
  border: 1.5px solid var(--line);
  box-shadow: var(--shadow-card);
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.luxury-card:hover, .clinical-card:hover {
  border-color: #CBD5E1;
  box-shadow: 0 8px 24px -4px rgba(15, 23, 42, 0.08);
}

.card-fascicolo {
  background: var(--white);
  border-radius: 20px;
  border: 1.5px solid var(--line);
  box-shadow: var(--shadow-card);
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}

.card-fascicolo::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 0;
  background: var(--red);
  transition: height 0.22s ease;
}

.card-fascicolo:hover {
  border-color: #FDA4AF;
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.card-fascicolo:hover::before {
  height: 100%;
}

/* Righe e Valori Metadati */
.meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  font-size: 12.5px;
}

.meta-label {
  color: var(--muted);
  font-weight: 600;
  flex-shrink: 0;
}

.meta-value {
  color: var(--ink);
  font-weight: 700;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Badge di Stato */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 9999px;
  font-family: var(--font-heading);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.status-pill-green {
  background: #DCFCE7;
  color: #15803D;
  border: 1px solid #86EFAC;
}

.status-pill-red {
  background: var(--red-soft);
  color: var(--red-d);
  border: 1px solid #FECDD3;
}

.status-pill-blue {
  background: #E0F2FE;
  color: #0369A1;
  border: 1px solid #BAE6FD;
}

/* ==========================================================================
   MODALE DI LOGIN BLINDATO ENTERPRISE (Stile PureLabs VoiceCore/HelpCore)
   ========================================================================== */
#login-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.78);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 20px;
  animation: fadeInModal 0.35s ease-out;
}

@keyframes fadeInModal {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}

#login-card {
  width: 100%;
  max-width: 980px;
  background: var(--white);
  border-radius: 26px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  min-height: 520px;
}

@media (max-width: 860px) {
  #login-card {
    grid-template-columns: 1fr;
    max-width: 480px;
  }
  #lp-left {
    display: none;
  }
}

#lp-left {
  background: linear-gradient(145deg, #8B0014 0%, #A60D26 30%, #C8102E 70%, #FF1A46 100%);
  padding: 38px 34px;
  color: #FFFFFF;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

.lp-brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(8px);
  padding: 6px 14px;
  border-radius: 9999px;
  font-family: var(--font-heading);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  border: 1px solid rgba(255, 255, 255, 0.28);
  width: fit-content;
  margin-bottom: 12px;
}

.lp-canvas-container {
  width: 100%;
  height: 180px;
  position: relative;
  border-radius: 18px;
  background: radial-gradient(circle at 50% 40%, rgba(255, 42, 85, 0.22) 0%, rgba(30, 2, 7, 0.35) 100%);
  border: 1px solid rgba(255, 255, 255, 0.24);
  box-shadow: 0 14px 34px -8px rgba(0, 0, 0, 0.35), inset 0 1px 2px rgba(255, 255, 255, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin: 10px 0 16px 0;
}

.lp-canvas-container canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.lp-hl {
  font-family: var(--font-heading);
  font-size: 21px;
  font-weight: 900;
  line-height: 1.25;
  color: #FFFFFF;
  margin-bottom: 8px;
}

.lp-features {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-top: 14px;
}

.lp-pill {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  padding: 9px 12px;
  border-radius: 12px;
  backdrop-filter: blur(6px);
}

.lp-pill-ic {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
}

.lp-pill-t {
  font-size: 11.5px;
  font-weight: 700;
  color: #FFFFFF;
  line-height: 1.15;
}

.lp-pill-s {
  font-size: 9.5px;
  color: rgba(255, 255, 255, 0.75);
  margin-top: 1px;
}

#lp-right {
  padding: 42px 38px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--white);
}

.btn-m365-entra {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 13px 18px;
  background: var(--white);
  border: 2px solid var(--line);
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 4px rgba(15, 23, 42, 0.04);
}

.btn-m365-entra:hover {
  border-color: #0284C7;
  background: #F0F9FF;
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(2, 132, 199, 0.15);
}

.m365-squares-icon {
  display: grid;
  grid-template-columns: 10px 10px;
  gap: 2.5px;
}

.m365-sq {
  width: 10px;
  height: 10px;
  border-radius: 1.5px;
}
.m365-sq-red { background-color: #F25022; }
.m365-sq-green { background-color: #7FBA00; }
.m365-sq-blue { background-color: #00A4EF; }
.m365-sq-yellow { background-color: #FFB900; }

.m365-badge {
  font-family: var(--font-heading);
  font-size: 11px;
  font-weight: 800;
  color: #0369A1;
  background: #E0F2FE;
  padding: 3px 8px;
  border-radius: 6px;
}

/* ==========================================================================
   VISUALIZZATORE CLINICO AVANZATO PDF & SMART SECTIONS NAVIGATOR
   ========================================================================== */
#modal-viewer {
  z-index: 99999 !important;
}

.doc-section-card {
  display: flex;
  flex-direction: column;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: var(--white);
  cursor: pointer;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  text-align: left;
  user-select: none;
}

.doc-section-card:hover {
  border-color: var(--muted);
  background: var(--bg);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.05);
}

.doc-section-card.active {
  border-color: var(--red);
  background: var(--red-soft);
  box-shadow: 0 0 0 2px rgba(255, 26, 70, 0.18);
}

.doc-section-badge {
  font-family: var(--font-heading);
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2.5px 7px;
  border-radius: 5px;
  display: inline-block;
  width: fit-content;
}

.page-thumbnail {
  cursor: pointer;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--white);
  padding: 8px;
  transition: all 0.18s ease;
}

.page-thumbnail:hover {
  border-color: var(--muted);
  transform: scale(1.02);
}

.page-thumbnail.active {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(255, 26, 70, 0.2);
}

#modal-email {
  z-index: 100000 !important;
}

.tab-pane {
  display: none;
}
.tab-pane.active {
  display: block;
}

/* ==========================================================================
   MASTER PURELABS TV DESIGN SYSTEM EXTENSIONS (tv_chiavari.html)
   ========================================================================== */

/* Main layout wrapper con margine corretto dalla sidebar */
.main-wrapper {
  margin-top: var(--header-h);
  margin-left: var(--sidebar-w);
  padding: 32px 40px 60px 40px;
  min-height: calc(100vh - var(--header-h));
  transition: margin-left 0.25s ease;
  max-width: 1720px;
}

@media (max-width: 1024px) {
  .main-wrapper {
    margin-left: 0;
    padding: 20px 16px 40px 16px;
  }
}

/* Hero Banner Cruscotto KPI */
.kpi-hero-banner {
  background: linear-gradient(135deg, var(--navy) 0%, #1E293B 100%);
  border-radius: 28px;
  padding: 36px 44px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 20px 50px -15px rgba(20, 33, 90, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.kpi-hero-overlay {
  position: absolute;
  top: -80px;
  right: -80px;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 26, 70, 0.28), transparent 70%);
  pointer-events: none;
}

.kpi-hero-content {
  position: relative;
  z-index: 2;
}

.tv-kicker {
  font-family: var(--font-heading);
  font-weight: 900;
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #FF8FA3;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.tv-kicker::before {
  content: '';
  width: 24px;
  height: 4px;
  border-radius: 4px;
  background: currentColor;
}

.tv-badge-pill {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--white);
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.24);
  padding: 4px 12px;
  border-radius: 999px;
  backdrop-filter: blur(8px);
}

.tv-badge-live {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: #10B981;
  background: rgba(16, 185, 129, 0.16);
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 4px 12px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10B981;
  animation: blinkLive 1.6s infinite;
}

@keyframes blinkLive {
  50% { opacity: 0.3; }
}

.kpi-hero-title {
  font-family: var(--font-heading);
  font-weight: 900;
  font-size: 38px;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--white);
  margin-top: 14px;
}

.kpi-hero-sub {
  font-size: 15px;
  color: rgba(255, 255, 255, 0.85);
  font-weight: 500;
  margin-top: 8px;
  max-width: 820px;
  line-height: 1.5;
}

/* ==========================================================================
   TV STAT CARDS (Contatori Enormi Outfit 900 e Glow)
   ========================================================================== */
.tv-stat-card {
  background: var(--white);
  border-radius: 24px;
  padding: 28px 32px;
  border: 2px solid var(--line);
  box-shadow: 0 10px 30px -10px rgba(15, 23, 42, 0.08);
  position: relative;
  overflow: hidden;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.tv-stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 6px;
  background: var(--line);
  transition: background 0.25s ease;
}

.tv-stat-crimson::before { background: var(--red); }
.tv-stat-navy::before { background: var(--navy); }
.tv-stat-emerald::before { background: #10B981; }

.tv-stat-card:hover {
  transform: translateY(-4px);
  border-color: #CBD5E1;
  box-shadow: 0 20px 40px -12px rgba(15, 23, 42, 0.12);
}

.tv-stat-crimson:hover {
  box-shadow: 0 20px 40px -12px rgba(255, 26, 70, 0.2);
  border-color: #FECDD3;
}

.tv-stat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tv-stat-label {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.tv-stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease;
}

.tv-stat-card:hover .tv-stat-icon {
  transform: scale(1.08);
}

.tv-stat-crimson .tv-stat-icon {
  background: var(--red-soft);
  color: var(--red);
}

.tv-stat-navy .tv-stat-icon {
  background: #EEF2FF;
  color: var(--navy);
}

.tv-stat-emerald .tv-stat-icon {
  background: #ECFDF5;
  color: #059669;
}

.tv-stat-num {
  font-family: var(--font-heading);
  font-weight: 900;
  font-size: 64px;
  line-height: 1;
  letter-spacing: -0.04em;
  color: var(--ink);
  margin: 18px 0 12px 0;
}

.tv-stat-crimson .tv-stat-num {
  color: var(--red);
}

.tv-stat-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.tv-stat-tag {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--body);
  display: flex;
  align-items: center;
  gap: 6px;
}

.tv-stat-hint {
  font-family: var(--font-heading);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ==========================================================================
   TV CHART CARDS
   ========================================================================== */
.tv-chart-card {
  background: var(--white);
  border-radius: 24px;
  padding: 28px 32px;
  border: 2px solid var(--line);
  box-shadow: 0 10px 30px -10px rgba(15, 23, 42, 0.08);
  transition: border-color 0.2s ease;
}

.tv-chart-card:hover {
  border-color: #CBD5E1;
}

.tv-chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.tv-chart-icon-box {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--red-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.tv-chart-title {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 17px;
  letter-spacing: -0.01em;
  color: var(--ink);
  line-height: 1.2;
}

.tv-chart-sub {
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 500;
  margin-top: 2px;
}

.tv-chart-badge {
  font-family: var(--font-heading);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--red);
  background: var(--red-soft);
  padding: 4px 10px;
  border-radius: 8px;
}

.tv-chart-body {
  height: 320px;
  position: relative;
}

/* ==========================================================================
   TV BATCH LOTTI GSV CARD
   ========================================================================== */
.tv-batch-card {
  background: var(--white);
  border-radius: 24px;
  padding: 32px;
  border: 2px solid var(--line);
  box-shadow: 0 10px 30px -10px rgba(15, 23, 42, 0.08);
}

.tv-batch-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 20px;
  border-bottom: 1.5px solid var(--line);
}

.tv-batch-title {
  font-family: var(--font-heading);
  font-weight: 900;
  font-size: 22px;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin-top: 4px;
}

.tv-batch-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  background: #ECFDF5;
  border: 1.5px solid #A7F3D0;
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 12px;
  color: #065F46;
  letter-spacing: 0.02em;
}

.tv-batch-item {
  background: var(--bg);
  border: 1.5px solid var(--line);
  border-radius: 18px;
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.2s ease;
}

.tv-batch-item:hover {
  background: var(--white);
  border-color: #FECDD3;
  transform: translateY(-2px);
  box-shadow: 0 10px 24px -6px rgba(255, 26, 70, 0.12);
}

.tv-batch-name {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 16px;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.tv-batch-desc {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  margin-top: 3px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.tv-batch-pill {
  font-family: var(--font-heading);
  font-weight: 900;
  font-size: 18px;
  color: var(--red);
  background: var(--red-soft);
  border: 1.5px solid #FECDD3;
  padding: 6px 16px;
  border-radius: 12px;
  white-space: nowrap;
}
