/* ============================================================
   Cash Flow Predictor AI 36™ — style.css
   Design system completo: "Bloomberg Terminal × Private Bank Vault"
   Fonts: DM Serif Display | Syne | DM Sans | JetBrains Mono
   Versione: 1.0 — aprile 2026
   ============================================================ */

/* ============================================================
   1. CSS VARIABLES
   ============================================================ */
:root {
  /* Sfondi */
  --bg-deep:    #060a10;
  --bg-card:    #0c1220;
  --bg-card2:   #111827;
  --bg-input:   #0a1020;

  /* Colori brand */
  --cyan:        #00e5cc;
  --cyan-dim:    rgba(0, 229, 204, 0.12);
  --cyan-glow:   rgba(0, 229, 204, 0.25);
  --gold:        #f0c040;
  --gold-dim:    rgba(240, 192, 64, 0.12);
  --orange:      #ff8c42;
  --orange-dim:  rgba(255, 140, 66, 0.12);

  /* Semaforo */
  --red:         #ef4444;
  --red-dim:     rgba(239, 68, 68, 0.12);
  --green:       #22c55e;
  --green-dim:   rgba(34, 197, 94, 0.12);
  --yellow:      #eab308;
  --yellow-dim:  rgba(234, 179, 8, 0.12);

  /* Testo */
  --text-main:   #eef2f6;
  --text-sub:    #7a8ba5;
  --text-muted:  #4a5568;

  /* Bordi */
  --border:        rgba(0, 229, 204, 0.12);
  --border-subtle: rgba(255, 255, 255, 0.06);

  /* Geometria */
  --radius:    12px;
  --radius-sm: 8px;

  /* Ombre */
  --shadow-card:       0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-glow-cyan:  0 0 20px rgba(0, 229, 204, 0.3), 0 0 60px rgba(0, 229, 204, 0.1);
  --shadow-glow-gold:  0 0 20px rgba(240, 192, 64, 0.3);

  /* Font stack */
  --font-display: 'DM Serif Display', Georgia, serif;
  --font-heading: 'Syne', sans-serif;
  --font-body:    'DM Sans', sans-serif;
  --font-mono:    'JetBrains Mono', 'Courier New', monospace;
}

/* ============================================================
   2. RESET E BASE
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  color: var(--text-main);
  min-height: 100vh;
  background-color: var(--bg-deep);
  /* Griglia SVG inline come background */
  background-image:
    linear-gradient(rgba(0, 229, 204, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 229, 204, 0.03) 1px, transparent 1px);
  background-size: 60px 60px;
  animation: gridPulse 4s ease-in-out infinite;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

@keyframes gridPulse {
  0%, 100% { background-color: #060a10; }
  50%       { background-color: #070c13; }
}

/* Scrollbar personalizzata */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: #0c1220;
}
::-webkit-scrollbar-thumb {
  background: #1e3050;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--cyan);
}

a {
  color: var(--cyan);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* ============================================================
   3. TIPOGRAFIA
   ============================================================ */

/* Classe brand: DM Serif Display */
.brand-display {
  font-family: var(--font-display);
}

/* Heading con Syne */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.3;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; }
h4 { font-size: 1rem; }

/* Monospace per numeri e dati */
.mono {
  font-family: var(--font-mono);
}

/* Classi testo utility */
.text-sub    { color: var(--text-sub); font-size: 0.875rem; }
.text-muted  { color: var(--text-muted); }
.text-cyan   { color: var(--cyan); }
.text-gold   { color: var(--gold); }
.text-orange { color: var(--orange); }
.text-green  { color: var(--green); }
.text-red    { color: var(--red); }

/* Valori negativi nelle tabelle */
.text-negative { color: var(--red); }
.text-positive { color: var(--green); }

/* ============================================================
   4. NAVIGAZIONE — TOP BAR
   ============================================================ */
.navbar {
  background: rgba(6, 10, 16, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 0 2rem;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.navbar-brand {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  gap: 0.1rem;
}

.navbar-brand .brand-tag {
  font-size: 0.65rem;
  color: var(--text-sub);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  font-family: var(--font-heading);
}

.navbar-brand .brand-name {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--text-main);
}

.navbar-brand .brand-tm {
  font-size: 0.6rem;
  vertical-align: super;
  color: var(--cyan);
}

.navbar-actions {
  display: flex;
  gap: 1rem;
  align-items: center;
}

/* Chip nome utente */
.user-chip {
  background: var(--bg-card2);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  padding: 0.3rem 0.75rem;
  font-size: 0.8rem;
  color: var(--text-sub);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* Link logout */
.btn-logout {
  color: var(--text-muted);
  font-size: 0.8rem;
  text-decoration: none;
  transition: color 0.2s;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
}
.btn-logout:hover {
  color: var(--orange);
  text-decoration: none;
}

/* ============================================================
   5. CARDS
   ============================================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  position: relative;
  box-shadow: var(--shadow-card);
}

/* Accent line ciano in alto a sinistra */
.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 40px;
  height: 2px;
  background: var(--cyan);
  border-radius: 0 0 2px 0;
}

.card-header {
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-subtle);
}

.card-title {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-main);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-subtitle {
  font-size: 0.8rem;
  color: var(--text-sub);
  margin-top: 0.25rem;
}

/* ============================================================
   6. BUTTONS
   ============================================================ */
.btn {
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  font-size: 0.875rem;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--cyan);
  color: #060a10;
}
.btn-primary:hover {
  background: #00ccb4;
  box-shadow: var(--shadow-glow-cyan);
  text-decoration: none;
  color: #060a10;
}

.btn-secondary {
  background: var(--bg-card2);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
}
.btn-secondary:hover {
  border-color: var(--cyan);
  color: var(--cyan);
  text-decoration: none;
}

.btn-danger {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, 0.2);
}
.btn-danger:hover {
  background: var(--red);
  color: #fff;
}

.btn-ghost {
  background: transparent;
  color: var(--text-sub);
  border: 1px solid var(--border-subtle);
}
.btn-ghost:hover {
  color: var(--text-main);
  border-color: var(--border);
}

/* Dimensioni */
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }
.btn-lg { padding: 0.8rem 2rem; font-size: 1rem; }
.btn-full { width: 100%; justify-content: center; }

.btn:disabled,
.btn[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* ============================================================
   7. LAUNCH BUTTON — Speciale
   ============================================================ */
.btn-launch {
  background: linear-gradient(135deg, #00e5cc, #00b8a3);
  color: #060a10;
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 700;
  padding: 1rem 2.5rem;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  transition: all 0.3s;
  position: relative;
  overflow: hidden;
  letter-spacing: 0.05em;
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
}

/* Effetto luce al centro al hover */
.btn-launch::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.15) 0%, transparent 60%);
  transform: scale(0);
  transition: transform 0.5s;
  pointer-events: none;
}
.btn-launch:hover::after {
  transform: scale(1);
}

/* Stato attivo: pulsazione */
.btn-launch.active {
  box-shadow: 0 0 30px rgba(0, 229, 204, 0.5), 0 0 80px rgba(0, 229, 204, 0.2);
  animation: launchPulse 2s ease-in-out infinite;
}

@keyframes launchPulse {
  0%, 100% { box-shadow: 0 0 30px rgba(0, 229, 204, 0.5), 0 0 80px rgba(0, 229, 204, 0.2); }
  50%       { box-shadow: 0 0 50px rgba(0, 229, 204, 0.7), 0 0 120px rgba(0, 229, 204, 0.3); }
}

.btn-launch:disabled,
.btn-launch[disabled] {
  background: #1e2a3a;
  color: var(--text-muted);
  box-shadow: none;
  animation: none;
  cursor: not-allowed;
  pointer-events: none;
}
.btn-launch:disabled::after {
  display: none;
}

/* ============================================================
   8. UPLOAD ZONES
   ============================================================ */
.upload-zone {
  border: 2px dashed rgba(0, 229, 204, 0.2);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
  position: relative;
  background: var(--bg-card2);
  overflow: hidden;
  user-select: none;
}

.upload-zone:hover {
  border-color: rgba(0, 229, 204, 0.5);
  background: rgba(0, 229, 204, 0.04);
}

/* Stato drag-over */
.upload-zone.drag-over {
  border-color: var(--cyan);
  background: rgba(0, 229, 204, 0.08);
  box-shadow: 0 0 0 1px var(--cyan), inset 0 0 40px rgba(0, 229, 204, 0.05);
}

/* Scanner beam che scorre dall'alto in basso */
.upload-zone.drag-over::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--cyan), transparent);
  animation: scanBeam 1s linear infinite;
  pointer-events: none;
}

@keyframes scanBeam {
  0%   { top: 0; }
  100% { top: 100%; }
}

.upload-zone .upload-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  opacity: 0.6;
  display: block;
  line-height: 1;
}

.upload-zone .upload-title {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  color: var(--text-main);
  margin-bottom: 0.25rem;
  display: block;
}

.upload-zone .upload-hint {
  font-size: 0.75rem;
  color: var(--text-sub);
  display: block;
}

/* Stato: file già presente */
.upload-zone.has-file {
  border-color: rgba(34, 197, 94, 0.3);
  background: rgba(34, 197, 94, 0.04);
}
.upload-zone.has-file .upload-icon {
  opacity: 1;
}

/* Input file nascosto */
.upload-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

/* ============================================================
   9. BADGES
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
  font-family: var(--font-heading);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* Badge stato setup */
.badge-setup-complete   { background: var(--green-dim); color: var(--green); border: 1px solid rgba(34, 197, 94, 0.2); }
.badge-setup-incomplete { background: var(--orange-dim); color: var(--orange); border: 1px solid rgba(255, 140, 66, 0.2); }

/* Badge campo obbligatorio/opzionale */
.badge-required { background: var(--orange-dim); color: var(--orange); }
.badge-optional  { background: rgba(122, 139, 165, 0.1); color: var(--text-sub); }

/* Badge stato predizione */
.badge-queued     { background: rgba(122, 139, 165, 0.1); color: var(--text-sub); }
.badge-processing { background: var(--cyan-dim); color: var(--cyan); }
.badge-completed  { background: var(--green-dim); color: var(--green); }
.badge-failed     { background: var(--red-dim); color: var(--red); }

/* Badge admin */
.badge-admin { background: var(--gold-dim); color: var(--gold); }

/* ============================================================
   10. TAB SWITCHER
   ============================================================ */
.tab-nav {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 2rem;
  overflow-x: auto;
}

.tab-btn {
  padding: 0.875rem 1.5rem;
  font-family: var(--font-heading);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-sub);
  background: none;
  border: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.tab-btn:hover {
  color: var(--text-main);
}

.tab-btn.active {
  color: var(--cyan);
  border-bottom-color: var(--cyan);
}

/* Badge contatore nel tab */
.tab-badge {
  font-size: 0.65rem;
  padding: 0.15rem 0.4rem;
  border-radius: 10px;
  background: var(--cyan-dim);
  color: var(--cyan);
  font-family: var(--font-mono);
}

/* Pannelli tab */
.tab-pane {
  display: none;
}
.tab-pane.active {
  display: block;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}

/* ============================================================
   11. SEMAFORI — Early Warning KPIs
   ============================================================ */
.semaforo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
}

.semaforo-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
  transition: transform 0.2s;
}
.semaforo-card:hover {
  transform: translateY(-2px);
}

/* Pallino semaforo */
.semaforo-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  margin: 0 auto 0.75rem;
  flex-shrink: 0;
}

.semaforo-card.verde .semaforo-dot {
  background: var(--green);
  box-shadow: 0 0 12px var(--green), 0 0 30px rgba(34, 197, 94, 0.3);
}
.semaforo-card.giallo .semaforo-dot {
  background: var(--yellow);
  box-shadow: 0 0 12px var(--yellow), 0 0 30px rgba(234, 179, 8, 0.3);
}
.semaforo-card.rosso .semaforo-dot {
  background: var(--red);
  box-shadow: 0 0 12px var(--red), 0 0 30px rgba(239, 68, 68, 0.3);
}

.semaforo-label {
  font-size: 0.7rem;
  color: var(--text-sub);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-family: var(--font-heading);
  margin-bottom: 0.5rem;
}

.semaforo-value {
  font-family: var(--font-mono);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-main);
}

.semaforo-trend {
  font-size: 0.8rem;
  margin-top: 0.25rem;
}
.semaforo-trend.up   { color: var(--green); }
.semaforo-trend.down { color: var(--red); }
.semaforo-trend.flat { color: var(--text-muted); }

/* ============================================================
   12. TABELLA DATI — 36 mesi
   ============================================================ */
.data-table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-sm);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 0.82rem;
}

.data-table th {
  font-family: var(--font-heading);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-sub);
  padding: 0.75rem 1rem;
  text-align: right;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}
.data-table th:first-child {
  text-align: left;
}

.data-table td {
  padding: 0.6rem 1rem;
  text-align: right;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  white-space: nowrap;
}
.data-table td:first-child {
  text-align: left;
  color: var(--text-sub);
}

.data-table tr:nth-child(odd) {
  background: rgba(255, 255, 255, 0.01);
}
.data-table tr:hover {
  background: rgba(0, 229, 204, 0.04);
}

/* Classi valori scenari */
.val-scenario-a  { color: var(--text-sub); }
.val-scenario-b  { color: var(--cyan); }
.val-positive    { color: var(--green); }
.val-negative    { color: var(--red); }
.val-confidence  { color: var(--gold); }

/* ============================================================
   13. CONFIDENCE GAUGE — conic-gradient
   ============================================================ */
.confidence-gauge {
  --pct: 0; /* Impostato via JS: style="--pct: 75" */
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: conic-gradient(var(--cyan) calc(var(--pct) * 1%), var(--bg-card2) 0);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
}

/* Cerchio interno che crea il donut */
.confidence-gauge::after {
  content: '';
  position: absolute;
  width: 64px;
  height: 64px;
  background: var(--bg-card);
  border-radius: 50%;
}

.confidence-gauge .gauge-value {
  position: relative;
  z-index: 1;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--cyan);
}

/* Versione mini (per company card) */
.confidence-gauge-mini {
  --pct: 0;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: conic-gradient(var(--cyan) calc(var(--pct) * 1%), var(--bg-card2) 0);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
}
.confidence-gauge-mini::after {
  content: '';
  position: absolute;
  width: 36px;
  height: 36px;
  background: var(--bg-card);
  border-radius: 50%;
}
.confidence-gauge-mini .gauge-value {
  position: relative;
  z-index: 1;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--cyan);
}

/* ============================================================
   14. FILE LIST ITEMS
   ============================================================ */
.file-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: var(--bg-card2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  margin-bottom: 0.5rem;
  transition: border-color 0.2s;
}
.file-item:hover {
  border-color: var(--border);
}

.file-item-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
  line-height: 1;
}

.file-item-info {
  flex: 1;
  min-width: 0;
}

.file-item-name {
  font-size: 0.85rem;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.file-item-meta {
  font-size: 0.72rem;
  color: var(--text-sub);
  font-family: var(--font-mono);
  display: block;
  margin-top: 0.15rem;
}

.file-item-delete {
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 4px;
  transition: color 0.2s;
  font-size: 1rem;
  flex-shrink: 0;
  line-height: 1;
}
.file-item-delete:hover {
  color: var(--red);
}

/* ============================================================
   15. FORM ELEMENTS
   ============================================================ */
.form-group {
  margin-bottom: 1.25rem;
}

label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-sub);
  margin-bottom: 0.4rem;
  font-family: var(--font-heading);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
select,
textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 0.9rem;
  padding: 0.7rem 1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
  -webkit-appearance: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px var(--cyan-dim);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
}

select option {
  background: var(--bg-card);
  color: var(--text-main);
}

textarea {
  resize: vertical;
  min-height: 100px;
}

/* Griglia 2 colonne */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* Messaggi di errore campo */
.form-error {
  color: var(--red);
  font-size: 0.78rem;
  margin-top: 0.3rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* Input con prefisso (es. €) */
.input-group {
  display: flex;
  align-items: stretch;
}
.input-group-prefix {
  background: var(--bg-card2);
  border: 1px solid var(--border-subtle);
  border-right: none;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  padding: 0.7rem 0.75rem;
  color: var(--text-sub);
  font-size: 0.85rem;
  font-family: var(--font-mono);
  white-space: nowrap;
  display: flex;
  align-items: center;
}
.input-group input {
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* ============================================================
   16. LOGIN PAGE
   ============================================================ */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem;
  position: relative;
}

/* Accent line in cima alla login card */
.login-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--cyan), transparent);
  border-radius: var(--radius) var(--radius) 0 0;
}

.login-brand {
  text-align: center;
  margin-bottom: 2rem;
}

.login-brand .brand-tag {
  font-size: 0.65rem;
  color: var(--text-sub);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-family: var(--font-heading);
  margin-bottom: 0.5rem;
  display: block;
}

.login-brand .brand-name {
  font-family: var(--font-display);
  font-size: 1.75rem;
  color: var(--text-main);
  display: block;
}

.login-brand .brand-tm {
  font-size: 0.7rem;
  vertical-align: super;
  color: var(--cyan);
}

/* Messaggio errore login */
.login-error {
  background: var(--red-dim);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  color: var(--red);
  font-size: 0.85rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ============================================================
   17. DASHBOARD AZIENDE
   ============================================================ */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-subtle);
  flex-wrap: wrap;
  gap: 1rem;
}

.page-title {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-main);
}

.page-subtitle {
  font-size: 0.85rem;
  color: var(--text-sub);
  margin-top: 0.25rem;
}

/* Griglia card aziende */
.companies-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
}

.company-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: transform 0.2s, border-color 0.2s;
  cursor: pointer;
  position: relative;
  box-shadow: var(--shadow-card);
}

/* Accent line identica alle .card */
.company-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 40px;
  height: 2px;
  background: var(--cyan);
  border-radius: 0 0 2px 0;
}

.company-card:hover {
  transform: translateY(-2px);
  border-color: rgba(0, 229, 204, 0.25);
  text-decoration: none;
}

.company-name {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.25rem;
}

.company-piva {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-sub);
}

.company-meta {
  display: flex;
  gap: 1rem;
  margin: 1rem 0;
  font-size: 0.78rem;
  color: var(--text-sub);
  flex-wrap: wrap;
}

.company-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-subtle);
}

/* Mini confidence gauge inline */
.confidence-mini {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ============================================================
   18. LAUNCH BOX — Footer predictor
   ============================================================ */
.launch-box {
  background: linear-gradient(135deg, rgba(0, 229, 204, 0.05), rgba(0, 229, 204, 0.02));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  margin-top: 2rem;
}

.launch-warning {
  background: var(--orange-dim);
  border: 1px solid rgba(255, 140, 66, 0.2);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  color: var(--orange);
  font-size: 0.85rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.launch-info {
  color: var(--text-sub);
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
  line-height: 1.7;
}

/* ============================================================
   19. ALERT / TOAST MESSAGES
   ============================================================ */
.alert {
  padding: 0.875rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.alert-success { background: var(--green-dim);  color: var(--green);  border: 1px solid rgba(34, 197, 94, 0.2); }
.alert-error   { background: var(--red-dim);    color: var(--red);    border: 1px solid rgba(239, 68, 68, 0.2); }
.alert-info    { background: var(--cyan-dim);   color: var(--cyan);   border: 1px solid rgba(0, 229, 204, 0.2); }
.alert-warning { background: var(--orange-dim); color: var(--orange); border: 1px solid rgba(255, 140, 66, 0.2); }

/* Transizione per auto-dismiss */
.alert.fade-out {
  opacity: 0;
  transition: opacity 0.5s ease;
}

/* ============================================================
   20. MODALE CONFERMA
   ============================================================ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(6, 10, 16, 0.85);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-overlay.open {
  display: flex;
}

.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  max-width: 420px;
  width: 90%;
  position: relative;
  animation: modalIn 0.2s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(-10px); }
  to   { opacity: 1; transform: none; }
}

.modal-title {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
  color: var(--text-main);
}

.modal-body {
  color: var(--text-sub);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

/* ============================================================
   21. CHART CONTAINER
   ============================================================ */
.chart-container {
  position: relative;
  width: 100%;
  height: 350px;
}

.chart-legend {
  display: flex;
  gap: 1.5rem;
  margin-top: 1rem;
  justify-content: center;
  font-size: 0.8rem;
  flex-wrap: wrap;
}

.chart-legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-sub);
}

.chart-legend-dot {
  width: 12px;
  height: 3px;
  border-radius: 2px;
  flex-shrink: 0;
}

/* ============================================================
   22. KPI SUMMARY BOXES
   ============================================================ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.kpi-box {
  background: var(--bg-card2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 1.25rem;
  text-align: center;
}

.kpi-period {
  font-size: 0.7rem;
  color: var(--text-sub);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-family: var(--font-heading);
  margin-bottom: 0.5rem;
}

.kpi-value-a {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  color: var(--text-sub);
}

.kpi-value-b {
  font-family: var(--font-mono);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--cyan);
}

.kpi-delta {
  font-size: 0.78rem;
  color: var(--green);
  margin-top: 0.25rem;
}
.kpi-delta.negative {
  color: var(--red);
}

/* ============================================================
   23. MINI-CARDS MAPPA STRATEGICA — sfondo gold
   ============================================================ */
.mappa-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-top: 1rem;
}

.mappa-card {
  background: rgba(240, 192, 64, 0.06);
  border: 1px solid rgba(240, 192, 64, 0.15);
  border-radius: var(--radius-sm);
  padding: 1rem;
  transition: border-color 0.2s;
}
.mappa-card:hover {
  border-color: rgba(240, 192, 64, 0.3);
}

.mappa-card-icon {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
  display: block;
  line-height: 1;
}

.mappa-card-title {
  font-family: var(--font-heading);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 0.25rem;
}

.mappa-card-desc {
  font-size: 0.72rem;
  color: var(--text-sub);
  line-height: 1.5;
}

/* ============================================================
   24. PROGRESS BAR
   ============================================================ */
.progress-bar-wrapper {
  background: var(--bg-card2);
  border-radius: 20px;
  height: 6px;
  overflow: hidden;
  margin: 0.5rem 0;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--gold));
  border-radius: 20px;
  transition: width 0.5s ease;
}

/* ============================================================
   25. STATUS DOT + DOCUMENT COUNTER BADGE
   ============================================================ */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.status-dot.ok      { background: var(--green); box-shadow: 0 0 6px rgba(34, 197, 94, 0.5); }
.status-dot.missing { background: var(--text-muted); }
.status-dot.error   { background: var(--red); box-shadow: 0 0 6px rgba(239, 68, 68, 0.5); }

/* Contatore documenti */
.doc-counter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  background: var(--cyan-dim);
  color: var(--cyan);
  border-radius: 50%;
  font-size: 0.7rem;
  font-weight: 700;
  font-family: var(--font-mono);
  flex-shrink: 0;
}

/* ============================================================
   26. LAYOUT GENERALE
   ============================================================ */
.page-wrapper {
  max-width: 1280px;
  margin: 0 auto;
  padding: 2rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1.5rem;
}

/* Sidebar + main content */
.layout-sidebar {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 1.5rem;
  align-items: start;
}

.layout-sidebar-wide {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 1.5rem;
  align-items: start;
}

/* ============================================================
   27. UTILITA'
   ============================================================ */
.divider {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: 1.5rem 0;
}

/* Stato vuoto */
.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--text-sub);
}
.empty-state .empty-icon {
  font-size: 3rem;
  opacity: 0.3;
  margin-bottom: 1rem;
  display: block;
  line-height: 1;
}
.empty-state .empty-title {
  font-family: var(--font-heading);
  font-size: 1rem;
  color: var(--text-sub);
  margin-bottom: 0.5rem;
}

/* Spinner di caricamento */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--cyan);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
.spinner-lg {
  width: 40px;
  height: 40px;
  border-width: 3px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Spinner inline centrato */
.spinner-center {
  display: flex;
  justify-content: center;
  padding: 2rem;
}

/* Separatore sezione con label */
.section-label {
  font-family: var(--font-heading);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.section-label::after {
  content: '';
  flex: 1;
  border-top: 1px solid var(--border-subtle);
}

/* Testo con glow ciano (titoli importanti) */
.glow-text {
  text-shadow: 0 0 20px rgba(0, 229, 204, 0.4);
}

/* Highlight inline */
.highlight {
  background: var(--cyan-dim);
  color: var(--cyan);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.9em;
}

/* Tooltip semplice */
[data-tooltip] {
  position: relative;
  cursor: help;
}
[data-tooltip]::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card2);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  font-size: 0.75rem;
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  margin-bottom: 4px;
  z-index: 50;
  font-family: var(--font-body);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}
[data-tooltip]:hover::before {
  opacity: 1;
}

/* Flex utility */
.flex        { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between{ display: flex; align-items: center; justify-content: space-between; }
.flex-end    { display: flex; align-items: center; justify-content: flex-end; }
.gap-sm      { gap: 0.5rem; }
.gap-md      { gap: 1rem; }
.gap-lg      { gap: 1.5rem; }

/* Spaziatura verticale */
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

/* Visibilità */
.hidden { display: none !important; }

/* ============================================================
   28. RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
  .layout-sidebar,
  .layout-sidebar-wide {
    grid-template-columns: 1fr;
  }
  .grid-3 {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 768px) {
  .page-wrapper {
    padding: 1rem;
  }
  .navbar {
    padding: 0 1rem;
  }
  .companies-grid {
    grid-template-columns: 1fr;
  }
  .kpi-grid {
    grid-template-columns: 1fr;
  }
  .mappa-grid {
    grid-template-columns: 1fr;
  }
  .form-row {
    grid-template-columns: 1fr;
  }
  .semaforo-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }
  .data-table-wrapper {
    overflow-x: auto;
  }
  .launch-box {
    padding: 1.25rem;
  }
  .chart-container {
    height: 250px;
  }
  .tab-nav {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .tab-btn {
    padding: 0.75rem 1rem;
    font-size: 0.8rem;
  }
  .modal-box {
    padding: 1.5rem;
  }
  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 480px) {
  .semaforo-grid {
    grid-template-columns: 1fr;
  }
  .company-actions {
    flex-wrap: wrap;
  }
  .modal-actions {
    flex-direction: column-reverse;
  }
  .navbar-brand .brand-name {
    font-size: 0.95rem;
  }
}
