/* ============================================================
   SINERGIASCUOLA AI — DESIGN SYSTEM DARK FUTURISTICO
   Dark Navy · Neon Blue · Glassmorphism · Enterprise AI
============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

:root {
  /* Palette dark futuristica */
  --bg:           #050d1a;
  --bg-2:         #030810;
  --surface:      #0a1628;
  --surface-2:    #0c1a2e;
  --surface-3:    #0d1f35;
  --border:       rgba(59,130,246,0.20);
  --border-light: rgba(59,130,246,0.10);

  /* Navy scuro */
  --navy:         #03080f;
  --navy-2:       #050d1a;
  --navy-3:       #0a1628;
  --navy-light:   rgba(59,130,246,0.06);

  /* Accenti neon */
  --accent:       #3b82f6;
  --accent-2:     #2563eb;
  --accent-light: rgba(59,130,246,0.12);
  --accent-border:rgba(59,130,246,0.35);
  --teal:         #0891b2;
  --teal-light:   rgba(8,145,178,0.12);

  /* Testo */
  --text:         #e2e8f0;
  --text-2:       rgba(255,255,255,0.75);
  --text-3:       rgba(255,255,255,0.55);
  --text-4:       rgba(255,255,255,0.35);
  --text-inv:     #ffffff;

  /* Semantici */
  --success:      #10b981;
  --success-bg:   rgba(16,185,129,0.12);
  --success-b:    rgba(16,185,129,0.30);
  --warning:      #f59e0b;
  --warning-bg:   rgba(245,158,11,0.12);
  --warning-b:    rgba(245,158,11,0.30);
  --danger:       #ef4444;
  --danger-bg:    rgba(239,68,68,0.12);
  --danger-b:     rgba(239,68,68,0.30);
  --info:         #38bdf8;
  --info-bg:      rgba(56,189,248,0.12);
  --info-b:       rgba(56,189,248,0.30);

  /* Gradienti */
  --grad-navy:    linear-gradient(135deg, #03080f 0%, #0a1628 60%, #1d4ed8 100%);
  --grad-accent:  linear-gradient(135deg, #1d4ed8 0%, #2563eb 50%, #0891b2 100%);
  --grad-soft:    linear-gradient(135deg, rgba(29,78,216,0.12) 0%, rgba(8,145,178,0.08) 100%);
  --grad-card:    linear-gradient(145deg, #0a1628 0%, #0c1a2e 100%);
  --grad-header:  linear-gradient(90deg, #03080f 0%, #0a1628 100%);

  /* Shadows + Glow */
  --sh-xs:     0 2px 8px rgba(0,0,0,0.30);
  --sh-sm:     0 2px 12px rgba(0,0,0,0.40);
  --sh:        0 4px 20px rgba(0,0,0,0.50);
  --sh-lg:     0 8px 32px rgba(0,0,0,0.60);
  --sh-navy:   0 2px 20px rgba(0,0,0,0.50);
  --sh-accent: 0 0 20px rgba(59,130,246,0.30);
  --glow-sm:   0 0 0 3px rgba(59,130,246,0.15);
  --glow:      0 0 0 3px rgba(59,130,246,0.20), 0 0 20px rgba(59,130,246,0.15);

  --r-sm: 6px;
  --r:    10px;
  --r-lg: 14px;
  --r-xl: 20px;
  --header-h: 72px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-font-smoothing: antialiased; scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  min-height: 100vh;
  /* Ingrandimento globale ~1 punto: scala uniformemente tutto il testo e la
     grafica (incluse le misure inline in px). Su Chromium/PWA. */
  zoom: 1.07;
}

/* ── UTILITY ─────────────────────────────────────────────────── */
.hidden  { display: none !important; }
.flex    { display: flex; }
.gap-1   { gap: 6px; }
.gap-2   { gap: 12px; }
.gap-3   { gap: 20px; }
.mt-1    { margin-top: 8px; }
.mt-2    { margin-top: 16px; }
.mt-3    { margin-top: 24px; }

/* ── LOGO ─────────────────────────────────────────────────────── */
.logo-mark {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--grad-accent);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 3px 12px rgba(29,78,216,0.35);
}
.logo-name {
  font-size: 17px; font-weight: 800; color: white;
  letter-spacing: -.5px; line-height: 1;
}
.logo-name span {
  font-weight: 300; opacity: .65;
  font-size: 11px; display: block;
  letter-spacing: .8px; text-transform: uppercase;
}

/* ── HEADER (navy — autorevole) ─────────────────────────────── */
.app-header {
  height: var(--header-h);
  background: var(--grad-header);
  color: white;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 300;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  box-shadow: var(--sh-navy);
}
.hd-sep   { width: 1px; height: 22px; background: rgba(255,255,255,0.12); flex-shrink: 0; }
.hd-school { font-size: 13px; font-weight: 600; color: rgba(255,255,255,0.80); max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hd-anno  { font-size: 11px; color: rgba(255,255,255,0.52); white-space: nowrap; }
.hd-right { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.hd-user  { color: rgba(255,255,255,0.80); }
.btn-hd-logout {
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.16);
  color: rgba(255,255,255,0.85);
  padding: 5px 14px; border-radius: var(--r-sm);
  font-size: 12px; font-weight: 600;
  cursor: pointer; transition: .2s; font-family: inherit;
}
.btn-hd-logout:hover { background: rgba(255,255,255,0.18); color: white; }

/* ── MAIN NAV ─────────────────────────────────────────────────── */
.main-nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex; align-items: center; gap: 2px;
  height: 48px; overflow-x: auto;
  box-shadow: var(--sh-xs);
}
.mnav-btn {
  padding: 0 16px; height: 46px; border-radius: 0;
  border: none; border-bottom: 2px solid transparent;
  background: transparent; font-size: 13px; font-weight: 600;
  color: var(--text-3); cursor: pointer;
  display: flex; align-items: center; gap: 7px;
  transition: .2s; font-family: inherit;
  white-space: nowrap; margin-bottom: -1px;
}
.mnav-btn:hover  { color: var(--text-2); background: var(--navy-light); }
.mnav-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.mnav-sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; flex-shrink: 0; }
.mnav-btn-ai {
  margin-left: auto;
  background: var(--grad-accent) !important;
  color: white !important; border-radius: var(--r-sm) !important;
  border-bottom: none !important; height: 32px !important;
  padding: 0 14px !important; margin-bottom: 0 !important;
  box-shadow: var(--sh-accent);
}
.mnav-btn-ai:hover { box-shadow: var(--glow) !important; opacity: .92; }

/* ── BODY ────────────────────────────────────────────────────── */
.app-main { max-width: 1400px; margin: 0 auto; padding: 24px 28px 60px; }

/* ── CARD ────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  box-shadow: var(--sh-sm);
  transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
}
.card:hover {
  transform: translateY(-2px);
  border-color: var(--accent-border);
  box-shadow: var(--sh), 0 0 0 1px rgba(29,78,216,0.06);
}
.card-hd {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
}
.card-title {
  font-size: 13px; font-weight: 700; color: var(--text);
  display: flex; align-items: center; gap: 7px; letter-spacing: -.1px;
}
.card-body   { padding: 18px; }
.card-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
  display: flex; justify-content: flex-end; gap: 8px;
}

/* ── DIRIGENTE COMMAND CENTER ────────────────────────────────── */
@keyframes dirblink {
  0%,100% { opacity:1; box-shadow: 0 0 8px #34d399; }
  50%     { opacity:.4; box-shadow: 0 0 4px #34d399; }
}
@media (max-width: 960px) {
  #dir-cmd-grid { grid-template-columns: 1fr !important; }
}

/* ── KPI CARD ────────────────────────────────────────────────── */
.kpi-card {
  background: var(--surface);
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  padding: 20px;
  display: flex; flex-direction: column; gap: 8px;
  box-shadow: var(--sh-sm);
  position: relative; overflow: hidden;
  transition: transform .25s ease, box-shadow .25s ease;
}
.kpi-card::before {
  content: ''; position: absolute; top: 0; left: 0; width: 3px; height: 100%;
  background: var(--kpi-color, var(--grad-accent));
}
.kpi-card:hover { transform: translateY(-3px); box-shadow: var(--sh-lg); }
.kpi-label { font-size: 11px; font-weight: 700; color: var(--text-3); letter-spacing: .5px; text-transform: uppercase; }
.kpi-value { font-size: 32px; font-weight: 800; color: var(--text); letter-spacing: -1px; line-height: 1; }
.kpi-sub   { font-size: 12px; color: var(--text-3); }

/* ── TABS ────────────────────────────────────────────────────── */
.cfg-tabs {
  display: flex; gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r); padding: 3px;
  margin-bottom: 20px; overflow-x: auto;
}
.cfg-tab {
  flex-shrink: 0; padding: 7px 15px;
  border-radius: var(--r-sm); border: none;
  background: transparent; font-size: 12px; font-weight: 600;
  color: var(--text-3); cursor: pointer;
  display: flex; align-items: center; gap: 6px;
  transition: .2s; font-family: inherit; white-space: nowrap;
}
.cfg-tab:hover  { background: var(--navy-light); color: var(--text-2); }
.cfg-tab.active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--sh-sm);
  border: 1px solid var(--accent-border);
}
.cfg-tab-ai {
  margin-left: auto;
  background: var(--grad-accent) !important;
  color: white !important;
  box-shadow: var(--sh-accent);
}

/* ── BUTTONS ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--r);
  border: none; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: .2s; line-height: 1;
  font-family: inherit; white-space: nowrap; text-decoration: none;
}
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 2px 8px rgba(29,78,216,0.25);
}
.btn-primary:hover:not(:disabled) {
  background: #1e40af;
  box-shadow: 0 4px 16px rgba(29,78,216,0.35);
  transform: translateY(-1px);
}
.btn-success { background: var(--success); color: white; box-shadow: 0 2px 8px rgba(5,150,105,0.25); }
.btn-success:hover:not(:disabled) { background: #047857; transform: translateY(-1px); }
.btn-danger  { background: var(--danger);  color: white; box-shadow: 0 2px 8px rgba(220,38,38,0.25); }
.btn-danger:hover:not(:disabled)  { background: #b91c1c; transform: translateY(-1px); }
.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-2);
}
.btn-outline:hover:not(:disabled) { background: var(--surface-2); border-color: var(--accent-border); color: var(--accent); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--navy-light); }
.btn-ai {
  background: var(--grad-accent);
  color: white;
  box-shadow: var(--sh-accent);
}
.btn-ai:hover:not(:disabled) { box-shadow: var(--glow); transform: translateY(-1px); }
.btn-sm  { padding: 5px 10px; font-size: 12px; border-radius: var(--r-sm); }
.btn-lg  { padding: 11px 22px; font-size: 14px; }
.btn-full { width: 100%; justify-content: center; }

/* ── FORM ────────────────────────────────────────────────────── */
.ss-label {
  display: block; font-size: 11px; font-weight: 700;
  color: var(--text-3); letter-spacing: .4px;
  text-transform: uppercase; margin-bottom: 5px;
}
.form-control, .form-select {
  border-radius: var(--r) !important;
  border-color: var(--border) !important;
  background: var(--surface) !important;
  font-size: 13px !important; font-family: 'Inter', sans-serif !important;
  color: var(--text) !important;
}
.form-control::placeholder { color: var(--text-4) !important; }
.form-control:focus, .form-select:focus {
  border-color: var(--accent) !important;
  background: var(--surface) !important;
  box-shadow: var(--glow-sm) !important;
  color: var(--text) !important;
}
.form-select option { background: var(--surface); color: var(--text); }

/* ── TABLE ───────────────────────────────────────────────────── */
.ss-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ss-table th {
  padding: 10px 14px;
  font-size: 11px; font-weight: 700; color: var(--text-3);
  letter-spacing: .5px; text-transform: uppercase;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border); text-align: left;
}
.ss-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text); vertical-align: middle;
}
.ss-table tr:last-child td { border-bottom: none; }
.ss-table tbody tr:hover td { background: var(--accent-light); }

/* ── BADGE ───────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 4px;
  font-size: 11px; font-weight: 700; letter-spacing: .3px;
  text-transform: uppercase;
}
.badge-success { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-b); }
.badge-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid var(--warning-b); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger);  border: 1px solid var(--danger-b);  }
.badge-info    { background: var(--info-bg);    color: var(--info);    border: 1px solid var(--info-b);    }
.badge-neutral { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }

/* ── PROGRESS ────────────────────────────────────────────────── */
.progress-track { height: 6px; background: var(--border); border-radius: 99px; overflow: hidden; }
.progress-fill  { height: 100%; border-radius: 99px; transition: width .7s cubic-bezier(.22,1,.36,1); }
.pf-success { background: linear-gradient(90deg, var(--success), #34d399); }
.pf-info    { background: linear-gradient(90deg, var(--accent), var(--teal)); }
.pf-warning { background: linear-gradient(90deg, var(--warning), #fbbf24); }
.pf-danger  { background: linear-gradient(90deg, var(--danger), #fb7185); }
.pf-blu     { background: var(--grad-accent); }

/* ── ALERT ───────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px; border-radius: var(--r);
  font-size: 13px; display: flex; align-items: flex-start; gap: 10px;
}
.alert-info    { background: var(--info-bg);    border: 1px solid var(--info-b);    color: var(--info); }
.alert-success { background: var(--success-bg); border: 1px solid var(--success-b); color: var(--success); }
.alert-warning { background: var(--warning-bg); border: 1px solid var(--warning-b); color: var(--warning); }
.alert-danger  { background: var(--danger-bg);  border: 1px solid var(--danger-b);  color: var(--danger); }

/* ── LOGIN — split layout professionale ─────────────────────── */
.auth-page {
  min-height: 100vh;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.auth-card {
  position: relative; z-index: 10;
  width: 440px; max-width: calc(100vw - 48px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px; padding: 44px 40px;
  box-shadow: var(--sh-lg);
  animation: authFadeIn .6s cubic-bezier(.22,1,.36,1);
  text-align: center;
}
.auth-card h1 { font-size: 22px; font-weight: 700; color: var(--text); margin: 18px 0 6px; }
.auth-card .auth-sub { font-size: 13px; color: var(--text-3); margin-bottom: 26px; }

/* ── TAG INPUT ───────────────────────────────────────────────── */
.tag-box {
  min-height: 72px; padding: 7px 10px;
  border: 1px solid var(--border); border-radius: var(--r);
  background: var(--surface-2); display: flex; flex-wrap: wrap; gap: 5px;
  align-items: flex-start; cursor: text; transition: .2s;
}
.tag-box:focus-within { border-color: var(--accent); box-shadow: var(--glow-sm); background: var(--surface); }
.tag-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--accent-light); border: 1px solid var(--accent-border);
  color: var(--navy-2); padding: 3px 9px; border-radius: 4px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.tag-chip-x { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 14px; line-height: 1; padding: 0; opacity: .7; transition: .1s; }
.tag-chip-x:hover { color: var(--danger); opacity: 1; }
.tag-input { border: none; outline: none; font-size: 13px; font-family: inherit; flex: 1; min-width: 100px; background: transparent; padding: 2px 4px; color: var(--text); }
.tag-input::placeholder { color: var(--text-4); }

/* ── DAY PILLS ───────────────────────────────────────────────── */
.day-pill {
  padding: 7px 16px; border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface); color: var(--text-2);
  font-size: 12px; font-weight: 700;
  cursor: pointer; transition: .2s; font-family: inherit;
  letter-spacing: .3px; text-transform: uppercase;
}
.day-pill:hover  { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }
.day-pill.active { background: var(--accent-light); border-color: var(--accent); color: var(--navy-2); box-shadow: var(--glow-sm); }

/* ── AI CHAT ─────────────────────────────────────────────────── */
.chat-msg { display: flex; margin-bottom: 6px; }
.chat-msg.chat-user { justify-content: flex-end; }
.chat-msg.chat-ai   { justify-content: flex-start; }
.chat-bubble-user {
  background: var(--grad-accent); color: white;
  padding: 10px 14px; border-radius: 14px 14px 3px 14px;
  font-size: 13px; max-width: 75%; line-height: 1.5;
  box-shadow: 0 2px 8px rgba(29,78,216,0.20);
}
.chat-bubble-ai {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  padding: 10px 14px; border-radius: 3px 14px 14px 14px;
  font-size: 13px; max-width: 85%; line-height: 1.6; white-space: pre-wrap;
}
.chat-thinking {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-3);
  padding: 10px 14px; border-radius: 3px 14px 14px 14px;
  font-size: 13px; font-style: italic;
}
.chat-quick-btn {
  text-align: left; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 8px 10px; font-size: 12px; color: var(--text-2);
  cursor: pointer; transition: .2s; font-family: inherit; width: 100%;
}
.chat-quick-btn:hover { background: var(--accent-light); border-color: var(--accent-border); color: var(--accent); }

/* ── ONBOARDING STEPS ────────────────────────────────────────── */
.step-bar { display: flex; gap: 0; margin-bottom: 24px; }
.step-item {
  flex: 1; padding: 10px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border); border-right: none;
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 600; color: var(--text-3);
}
.step-item:first-child { border-radius: var(--r) 0 0 var(--r); }
.step-item:last-child  { border-right: 1px solid var(--border); border-radius: 0 var(--r) var(--r) 0; }
.step-item.done   { background: var(--success-bg); color: var(--success); border-color: var(--success-b); }
.step-item.active { background: var(--accent-light); color: var(--accent); border-color: var(--accent-border); }
.step-num {
  width: 22px; height: 22px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800; flex-shrink: 0;
  background: var(--border); color: var(--text-3);
}
.step-item.done   .step-num { background: var(--success); color: white; }
.step-item.active .step-num { background: var(--accent); color: white; }

/* ── AI ASSISTANT WIDGET ─────────────────────────────────────── */
#ai-assistant {
  position: fixed; bottom: 24px; right: 24px; z-index: 800;
  display: flex; flex-direction: column; align-items: flex-end; gap: 10px;
  pointer-events: none; /* il contenitore non blocca scroll/click sulla pagina */
}
#ai-assistant > * { pointer-events: auto; }
#ai-assistant-btn {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--grad-navy);
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 20px rgba(15,32,66,0.35), 0 0 0 0 rgba(29,78,216,0);
  transition: transform .2s, box-shadow .3s;
  animation: aiPulse 3s ease-in-out infinite;
}
#ai-assistant-btn:hover { transform: scale(1.08); box-shadow: 0 6px 28px rgba(15,32,66,0.45), var(--glow); }
@keyframes aiPulse {
  0%, 100% { box-shadow: 0 4px 20px rgba(15,32,66,.35), 0 0 0 0 rgba(29,78,216,.4); }
  50%       { box-shadow: 0 4px 20px rgba(15,32,66,.35), 0 0 0 8px rgba(29,78,216,0); }
}
#ai-panel {
  width: 680px; max-width: calc(100vw - 48px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-lg), 0 0 0 1px rgba(29,78,216,0.06);
  overflow: hidden;
  display: flex; flex-direction: column;
  max-height: calc(100vh - 186px); /* bottom:24 + btn:52 + gap:10 + nav:88 + margin:12 = 186 */
  animation: slideUp .3s cubic-bezier(.22,1,.36,1);
}
.ai-panel-hd {
  background: var(--grad-navy);
  padding: 16px 18px;
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.ai-panel-hd-left { display: flex; align-items: center; gap: 10px; }
.ai-panel-avatar {
  width: 34px; height: 34px; border-radius: 10px;
  background: rgba(255,255,255,0.15);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}
.ai-panel-title { font-size: 13px; font-weight: 700; color: white; }
.ai-panel-sub   { font-size: 11px; color: rgba(255,255,255,0.55); margin-top: 1px; }
.ai-panel-close {
  background: rgba(255,255,255,0.10); border: none;
  width: 28px; height: 28px; border-radius: 50%;
  color: rgba(255,255,255,0.70); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; transition: .15s;
}
.ai-panel-close:hover { background: rgba(255,255,255,0.20); color: white; }
.ai-panel-body { padding: 18px; overflow-y: auto; flex: 1; min-height: 0; }
#ai-preview-area { }
#ai-text-scroll  { padding-top: 12px; }
.ai-typing-wrap {
  display: flex; gap: 10px; align-items: flex-start;
}
.ai-typing-dot {
  width: 32px; height: 32px; border-radius: 10px;
  background: var(--accent-light); border: 1px solid var(--accent-border);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; flex-shrink: 0;
}
.ai-typing-text {
  font-size: 13px; color: var(--text); line-height: 1.6;
  flex: 1; min-height: 48px;
}
.ai-typing-cursor {
  display: inline-block; width: 2px; height: 14px;
  background: var(--accent); margin-left: 2px;
  animation: blink .7s step-end infinite; vertical-align: middle;
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }
@keyframes ai-dot  { 0%, 80%, 100% { transform: scale(.6); opacity: .4; } 40% { transform: scale(1); opacity: 1; } }
@keyframes ai-badge-pulse { 0%,100% { box-shadow:0 0 0 0 rgba(244,63,94,.6); } 60% { box-shadow:0 0 0 5px rgba(244,63,94,0); } }
.ai-actions {
  display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px;
  padding-top: 14px; border-top: 1px solid var(--border);
}
.ai-action-chip {
  padding: 5px 11px; border-radius: 20px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 11px; font-weight: 600; color: var(--text-2);
  cursor: pointer; transition: .15s; font-family: inherit;
}
.ai-action-chip:hover { background: var(--accent-light); border-color: var(--accent-border); color: var(--accent); }

/* ── COMMAND PALETTE ─────────────────────────────────────────── */
#cmd-overlay {
  position: fixed; inset: 0; z-index: 9000;
  background: rgba(15,23,42,0.50);
  backdrop-filter: blur(4px);
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 15vh;
  animation: fadeIn .15s ease;
}
#cmd-box {
  width: 560px; max-width: calc(100vw - 32px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-lg), 0 32px 64px rgba(15,23,42,0.20);
  overflow: hidden;
}
#cmd-input-wrap {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
#cmd-input-wrap i { font-size: 18px; color: var(--text-3); flex-shrink: 0; }
#cmd-input {
  flex: 1; border: none; outline: none; font-size: 15px;
  font-family: 'Inter', sans-serif; color: var(--text);
  background: transparent; font-weight: 500;
}
#cmd-input::placeholder { color: var(--text-4); }
#cmd-kbd {
  font-size: 10px; background: var(--surface-2); border: 1px solid var(--border);
  padding: 2px 7px; border-radius: 4px; color: var(--text-3); font-weight: 700;
  flex-shrink: 0;
}
#cmd-results { padding: 8px; max-height: 360px; overflow-y: auto; }
.cmd-group-label {
  font-size: 10px; font-weight: 700; color: var(--text-4);
  letter-spacing: .6px; text-transform: uppercase;
  padding: 6px 10px 4px; margin-top: 4px;
}
.cmd-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--r);
  cursor: pointer; transition: .12s;
}
.cmd-item:hover, .cmd-item.selected {
  background: var(--accent-light);
}
.cmd-item-icon {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--surface-2); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; flex-shrink: 0; color: var(--text-2);
}
.cmd-item:hover .cmd-item-icon, .cmd-item.selected .cmd-item-icon {
  background: var(--accent); border-color: var(--accent); color: white;
}
.cmd-item-label { font-size: 13px; font-weight: 600; color: var(--text); }
.cmd-item-sub   { font-size: 11px; color: var(--text-3); margin-top: 1px; }
.cmd-footer {
  padding: 8px 16px; border-top: 1px solid var(--border);
  display: flex; gap: 16px;
  font-size: 11px; color: var(--text-4); background: var(--surface-2);
}
.cmd-footer kbd { background: var(--surface); border: 1px solid var(--border); border-radius: 3px; padding: 1px 5px; color: var(--text-3); font-family: inherit; }

/* ── ANIMATIONS ──────────────────────────────────────────────── */
@keyframes authFadeIn { from { opacity: 0; transform: translateY(20px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes fadeIn     { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes slideUp    { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
.animate-in { animation: fadeIn .35s ease-out; }

/* ── SCROLLBAR ───────────────────────────────────────────────── */
::-webkit-scrollbar       { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-border); }

/* ── PRINT ───────────────────────────────────────────────────── */
@media print {
  .app-header, .main-nav, .no-print, #ai-assistant { display: none !important; }
  body { background: white !important; }
  .app-main { padding: 0; max-width: 100%; }
  .card { box-shadow: none !important; border: 1px solid #e2e8f0 !important; }
}

/* ── RESPONSIVE ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  .app-header { padding: 0 14px; }
  .main-nav   { padding: 0 10px; }
  .app-main   { padding: 14px 14px 80px; }
  #ai-assistant { bottom: 16px; right: 16px; }
  #ai-panel { width: calc(100vw - 32px); }

  /* Card stacking */
  .row.g-4 > [class*="col-lg"] { margin-bottom: 16px; }
  .kpi-card { padding: 14px; }

  /* Tabella orizzontale scrollabile */
  .ss-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .ss-table { min-width: 480px; }

  /* Tabs scrollabili */
  .cfg-tabs { flex-wrap: nowrap; overflow-x: auto; padding: 3px 3px 6px; }

  /* Nav sub nascosto su mobile */
  .nav-sub { display: none !important; }

  /* Command palette fullscreen su mobile */
  #cmd-overlay { padding-top: 0; align-items: flex-end; }
  #cmd-box { border-radius: var(--r-xl) var(--r-xl) 0 0; width: 100%; max-width: 100%; }
  #cmd-results { max-height: 50vh; }
}

@media (max-width: 480px) {
  .app-header { padding: 0 10px; }
  .kpi-value  { font-size: 26px; }
  .card-body, .ss-card-body { padding: 14px; }
  .btn-ss-lg  { padding: 9px 16px; font-size: 13px; }

  /* Login form fullscreen */
  .login-wrap { grid-template-columns: 1fr !important; }
  .panel-visual { display: none !important; }
  .panel-form { padding: 24px 18px !important; }
}
