/* ==========================================================
   STC Travel Enterprise Portal — Master Stylesheet v2.0
   Brand: ST-Company — Bianco/Rosso #E8281E
   ========================================================== */

@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=Inter:wght@300;400;500;600;700&display=swap');

/* ── Variables ──────────────────────────────────────────── */
:root {
  /* Brand */
  --red:       #E8281E;
  --red2:      #c41f17;
  --red-pale:  rgba(232,40,30,.06);
  --red-mid:   rgba(232,40,30,.12);
  --red-bdr:   rgba(232,40,30,.25);

  /* Alias: legacy --org → --red (usato in index.php, risultati.php) */
  --org:       #E8281E;
  --org-d:     #c41f17;
  --org-l:     rgba(232,40,30,.10);
  --org-ll:    rgba(232,40,30,.05);

  /* Neutrals */
  --dark:      #1a1a1a;
  --dark-2:    #333333;
  --dark-3:    #444444;
  --mid:       #444444;
  --text:      #1a1a1a;
  --text-2:    #444444;
  --muted:     #767676;
  --hint:      #a8a8a8;

  /* Surfaces */
  --white:     #ffffff;
  --bg:        #f5f5f5;
  --bg-2:      #fafafa;
  --card:      #ffffff;
  --border:    #e8e8e8;
  --border-d:  #d4d4d4;
  --rule:      #e8e8e8;

  /* Status */
  --success:   #1a8a58;
  --danger:    #DC2626;
  --warning:   #D97706;

  /* Typography */
  --font:      'Inter', 'Segoe UI', Arial, sans-serif;
  --font-serif: 'DM Serif Display', 'Georgia', serif;
  --serif:     'DM Serif Display', 'Georgia', serif;

  /* Spacing & Shape */
  --radius:    4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --shadow:    0 1px 3px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.04);
  --shadow-lg: 0 4px 16px rgba(0,0,0,.08);
  --transition:0.15s ease;
}

/* ── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
::selection { background: var(--red); color: #fff; }
body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--red); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
button { font-family: var(--font); cursor: pointer; }
input, select, textarea { font-family: var(--font); }

/* ── Typography ─────────────────────────────────────────── */
h1 { font-size: 26px; font-weight: 700; color: var(--dark); }
h2 { font-size: 20px; font-weight: 600; color: var(--dark); }
h3 { font-size: 15px; font-weight: 600; color: var(--dark); }
h4 { font-size: 13px; font-weight: 600; color: var(--dark); }
.serif         { font-family: var(--serif); }
.text-muted    { color: var(--muted); }
.text-hint     { color: var(--hint); }
.text-red      { color: var(--red); }
.text-sm       { font-size: 12px; }
.text-xs       { font-size: 11px; }
.text-center   { text-align: center; }
.fw-500        { font-weight: 500; }
.fw-600        { font-weight: 600; }

/* ── Utilities ──────────────────────────────────────────── */
.flex          { display: flex; }
.flex-center   { display: flex; align-items: center; justify-content: center; }
.flex-between  { display: flex; align-items: center; justify-content: space-between; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-8   { margin-top: 8px; }
.mt-16  { margin-top: 16px; }
.mt-24  { margin-top: 24px; }
.mb-8   { margin-bottom: 8px; }
.mb-16  { margin-bottom: 16px; }
.mb-24  { margin-bottom: 24px; }

/* ═══════════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--white); color: var(--text);
  font-size: 13px; font-weight: 500; cursor: pointer;
  transition: all var(--transition); white-space: nowrap;
  text-decoration: none; line-height: 1;
}
.btn:hover { border-color: var(--border-d); background: var(--bg); text-decoration: none; }
.btn:active { transform: scale(.99); }

.btn-primary  { background: var(--red); color: #fff; border-color: var(--red); }
.btn-primary:hover:not(:disabled) { background: var(--red2); border-color: var(--red2); }
.btn-primary:disabled { background: #ccc; border-color: #ccc; color: #fff; cursor: not-allowed; }

.btn-dark     { background: var(--dark); color: #fff; border-color: var(--dark); }
.btn-dark:hover { background: #333; border-color: #333; }

.btn-danger   { background: #fff; color: var(--danger); border-color: rgba(220,38,38,.3); }
.btn-danger:hover { background: rgba(220,38,38,.06); }

.btn-sm  { padding: 6px 12px; font-size: 12px; }
.btn-lg  { padding: 12px 24px; font-size: 14px; font-weight: 600; }
.btn-full { width: 100%; }
.btn-icon { padding: 7px; width: 32px; height: 32px; }

/* ═══════════════════════════════════════════════════════════
   FORMS
   ═══════════════════════════════════════════════════════════ */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--mid); margin-bottom: 5px;
  text-transform: uppercase; letter-spacing: .4px;
}
.form-hint { font-size: 11px; color: var(--hint); margin-top: 4px; }

input[type=text], input[type=email], input[type=tel],
input[type=number], input[type=password], select, textarea {
  width: 100%; padding: 9px 13px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--white); color: var(--text);
  font-size: 13px; outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
input:focus, select:focus, textarea:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(232,40,30,.08);
}
input::placeholder, textarea::placeholder { color: var(--hint); }
textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23999'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

/* Divider */
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* ═══════════════════════════════════════════════════════════
   BADGES
   ═══════════════════════════════════════════════════════════ */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 2px;
  font-size: 10px; font-weight: 700; white-space: nowrap;
  text-transform: uppercase; letter-spacing: .4px;
}
.badge-org     { background: var(--red-pale); color: var(--red); }
.badge-success { background: rgba(26,138,88,.1); color: var(--success); }
.badge-danger  { background: rgba(220,38,38,.08); color: var(--danger); }
.badge-warning { background: rgba(217,119,6,.1);  color: var(--warning); }
.badge-muted   { background: var(--bg); color: var(--muted); border: 1px solid var(--border); }
.badge-dark    { background: var(--dark); color: #fff; }

/* ═══════════════════════════════════════════════════════════
   ALERTS
   ═══════════════════════════════════════════════════════════ */
.alert {
  border-radius: var(--radius); padding: 12px 14px;
  font-size: 13px; margin-bottom: 16px;
  display: flex; gap: 10px; align-items: flex-start;
  border-left: 3px solid transparent;
}
.alert-success { background: rgba(26,138,88,.07); border-color: var(--success); color: #0f5c38; }
.alert-danger  { background: rgba(220,38,38,.06); border-color: var(--danger); color: var(--danger); }
.alert-info    { background: rgba(232,40,30,.04); border-color: var(--red); color: var(--mid); }
.alert i       { flex-shrink: 0; margin-top: 1px; }

/* ═══════════════════════════════════════════════════════════
   CARDS
   ═══════════════════════════════════════════════════════════ */
.card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px 22px;
}
.card-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 16px; gap: 12px;
}
.card-title  { font-size: 13px; font-weight: 700; color: var(--dark); }
.card-sub    { font-size: 11px; color: var(--hint); margin-top: 2px; }

/* ═══════════════════════════════════════════════════════════
   EMPTY STATE
   ═══════════════════════════════════════════════════════════ */
.empty-state { text-align: center; padding: 40px 20px; }
.empty-icon  { font-size: 40px; color: var(--hint); margin-bottom: 10px; }
.empty-title { font-size: 14px; font-weight: 600; margin-bottom: 4px; color: var(--mid); }
.empty-sub   { font-size: 12px; color: var(--hint); line-height: 1.5; }

/* ═══════════════════════════════════════════════════════════
   TABLES
   ═══════════════════════════════════════════════════════════ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left; padding: 9px 14px;
  font-size: 10px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .7px;
  background: var(--bg); border-bottom: 1.5px solid var(--border);
  white-space: nowrap;
}
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--bg-2); }

/* ═══════════════════════════════════════════════════════════
   TOGGLE SWITCH
   ═══════════════════════════════════════════════════════════ */
.toggle { position: relative; display: inline-flex; align-items: center; cursor: pointer; gap: 8px; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-track { width: 36px; height: 20px; background: var(--border-d); border-radius: 10px; transition: background .2s; position: relative; }
.toggle input:checked + .toggle-track { background: var(--red); }
.toggle-thumb { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; background: #fff; border-radius: 50%; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.toggle input:checked + .toggle-track .toggle-thumb { transform: translateX(16px); }
.toggle-label { font-size: 13px; color: var(--text-2); }

/* ═══════════════════════════════════════════════════════════
   PAGINATION
   ═══════════════════════════════════════════════════════════ */
.pagination { display: flex; gap: 4px; align-items: center; margin-top: 16px; }
.page-item {
  width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius); font-size: 12px; font-weight: 500;
  cursor: pointer; border: 1px solid var(--border);
  background: var(--white); color: var(--mid);
  transition: all var(--transition); text-decoration: none;
}
.page-item:hover { border-color: var(--red); color: var(--red); text-decoration: none; }
.page-item.active { background: var(--red); color: #fff; border-color: var(--red); }
.page-item.disabled { opacity: .4; cursor: default; pointer-events: none; }

/* ═══════════════════════════════════════════════════════════
   TABS
   ═══════════════════════════════════════════════════════════ */
.tabs { display: flex; border-bottom: 1.5px solid var(--border); margin-bottom: 20px; gap: 0; }
.tab {
  padding: 9px 16px; font-size: 13px; font-weight: 500; color: var(--muted);
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1.5px;
  transition: all var(--transition); text-decoration: none;
}
.tab:hover { color: var(--dark); text-decoration: none; }
.tab.active { color: var(--red); border-bottom-color: var(--red); }

/* ═══════════════════════════════════════════════════════════
   ADMIN LAYOUT
   ═══════════════════════════════════════════════════════════ */
.admin-body { background: var(--bg); }

.admin-layout {
  display: flex; min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: 220px; flex-shrink: 0;
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0;
  z-index: 200;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo-row {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none;
}
.sidebar-logo-sq {
  width: 28px; height: 28px; border-radius: 4px;
  background: var(--red); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--serif); font-size: 12px; flex-shrink: 0;
}
.sidebar-logo-name {
  font-family: var(--serif); font-size: 15px; color: var(--dark); line-height: 1.1;
}
.sidebar-logo-name span { color: var(--red); }
.sidebar-logo-sub {
  font-size: 9px; color: var(--hint); text-transform: uppercase;
  letter-spacing: 1px; margin-top: 3px;
}

.sidebar-nav { flex: 1; padding: 12px 0; }

.nav-section { margin-bottom: 4px; }
.nav-section-title {
  font-size: 9px; font-weight: 700; color: var(--hint);
  text-transform: uppercase; letter-spacing: 1px;
  padding: 8px 18px 4px;
}
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 18px;
  font-size: 13px; font-weight: 500; color: var(--mid);
  text-decoration: none; transition: all var(--transition);
  border-left: 2px solid transparent;
  position: relative;
}
.nav-item:hover { color: var(--dark); background: var(--bg); text-decoration: none; }
.nav-item.active {
  color: var(--red); background: var(--red-pale);
  border-left-color: var(--red);
}
.nav-item i { font-size: 16px; flex-shrink: 0; }
.nav-badge {
  margin-left: auto;
  background: var(--red); color: #fff;
  font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: 10px;
  min-width: 18px; text-align: center;
}

.sidebar-footer {
  padding: 14px 18px; border-top: 1px solid var(--border);
  font-size: 11px; color: var(--hint);
}

/* ── Admin main area ── */
.admin-main { flex: 1; margin-left: 220px; min-width: 0; }

.admin-topbar {
  background: var(--white); border-bottom: 1px solid var(--border);
  padding: 0 28px; height: 50px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}
.admin-topbar-title { font-size: 13px; font-weight: 600; color: var(--dark); }
.admin-topbar-right { display: flex; align-items: center; gap: 10px; }

.admin-content { padding: 24px 28px; max-width: 1200px; }

/* ── Page header ── */
.page-header { margin-bottom: 22px; }
.page-header h1 { font-size: 22px; font-weight: 700; color: var(--dark); margin-bottom: 2px; }
.page-header p  { font-size: 12px; color: var(--muted); }
.page-header-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }

/* ── Stat cards ── */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 22px; }
.stat-card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px 18px;
  position: relative; overflow: hidden;
}
.stat-card::after {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: var(--red);
}
.stat-label { font-size: 10px; font-weight: 700; color: var(--hint); text-transform: uppercase; letter-spacing: .7px; margin-bottom: 8px; }
.stat-value { font-size: 26px; font-weight: 700; color: var(--dark); line-height: 1; margin-bottom: 3px; }
.stat-delta { font-size: 11px; color: var(--muted); }
.stat-icon  { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); font-size: 28px; color: var(--red); opacity: .08; }

/* ── Login page ── */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--bg); padding: 20px;
}
.login-box {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 36px 32px;
  width: 100%; max-width: 380px;
}
.login-logo {
  text-align: center; margin-bottom: 28px;
}
.login-logo-sq {
  width: 40px; height: 40px; border-radius: 6px;
  background: var(--red); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--serif); font-size: 16px;
  margin: 0 auto 10px;
}
.login-logo-name { font-family: var(--serif); font-size: 20px; color: var(--dark); }
.login-logo-name span { color: var(--red); }
.login-logo-sub  { font-size: 11px; color: var(--hint); margin-top: 3px; }
.login-title { font-size: 15px; font-weight: 700; color: var(--dark); text-align: center; margin-bottom: 22px; }
.login-error {
  background: rgba(220,38,38,.06); border: 1px solid rgba(220,38,38,.2);
  border-left: 3px solid var(--danger);
  color: var(--danger); font-size: 13px;
  padding: 10px 12px; border-radius: var(--radius);
  margin-bottom: 16px; display: flex; gap: 8px; align-items: center;
}
.login-field { margin-bottom: 14px; }
.login-field label { display: block; font-size: 11px; font-weight: 700; color: var(--mid); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 5px; }
.login-field input {
  width: 100%; padding: 9px 13px;
  border: 1.5px solid var(--border); border-radius: var(--radius);
  font-size: 14px; color: var(--text); background: var(--white); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.login-field input:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(232,40,30,.08); }

/* ── Dashboard chart bars ── */
.chart-bar-wrap { display: flex; flex-direction: column; gap: 10px; }
.chart-bar-row  { display: flex; align-items: center; gap: 10px; }
.chart-bar-lbl  { font-size: 12px; color: var(--text-2); width: 130px; flex-shrink: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chart-bar-track { flex: 1; height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; }
.chart-bar-fill  { height: 100%; border-radius: 3px; background: var(--red); transition: width .6s ease; }
.chart-bar-val   { font-size: 11px; font-weight: 600; color: var(--mid); width: 28px; text-align: right; flex-shrink: 0; }

/* ── Dashboard v2: KPI extended ── */
.stat-grid-6 { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-bottom: 22px; }
.stat-card-sm {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 14px 16px;
  position: relative; overflow: hidden;
}
.stat-card-sm::after { content:''; position:absolute; top:0; left:0; right:0; height:2px; background: var(--red); }
.stat-card-sm .sc-icon { font-size: 16px; color: var(--red); opacity: .85; margin-bottom: 8px; }
.stat-card-sm .sc-value { font-size: 21px; font-weight: 700; color: var(--dark); line-height: 1; margin-bottom: 4px; }
.stat-card-sm .sc-label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; line-height: 1.3; }
.stat-card-sm .sc-trend { font-size: 10px; margin-top: 5px; font-weight: 600; }
.sc-trend.up   { color: var(--success); }
.sc-trend.down { color: var(--danger); }
.sc-trend.flat { color: var(--hint); }

/* ── Unified activity timeline ── */
.activity-feed { display: flex; flex-direction: column; }
.activity-item {
  display: flex; gap: 12px; padding: 11px 0;
  border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }
.activity-ic {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; color: #fff;
}
.activity-ic.t-risposta { background: var(--red); }
.activity-ic.t-policy   { background: var(--dark); }
.activity-ic.t-analyzer { background: #1a8a58; }
.activity-body { flex: 1; min-width: 0; }
.activity-title { font-size: 13px; font-weight: 600; color: var(--dark); margin-bottom: 1px; }
.activity-sub   { font-size: 11px; color: var(--muted); }
.activity-time  { font-size: 10px; color: var(--hint); white-space: nowrap; flex-shrink: 0; padding-top: 2px; }

/* ── System status panel ── */
.status-row { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); }
.status-row:last-child { border-bottom: none; }
.status-label { font-size: 12px; color: var(--text-2); display:flex; align-items:center; gap:7px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink:0; }
.status-dot.ok   { background: var(--success); }
.status-dot.warn { background: var(--warning); }
.status-dot.err  { background: var(--danger); }
.status-val { font-size: 12px; font-weight: 600; color: var(--dark); }

/* ── Top aziende ranking ── */
.rank-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.rank-item:last-child { border-bottom: none; }
.rank-num {
  width: 20px; height: 20px; border-radius: 4px; background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; color: var(--muted); flex-shrink: 0;
}
.rank-item:nth-child(1) .rank-num { background: var(--red); color: #fff; }
.rank-item:nth-child(2) .rank-num { background: var(--dark); color: #fff; }
.rank-item:nth-child(3) .rank-num { background: var(--mid); color: #fff; }
.rank-name { flex: 1; font-size: 12.5px; font-weight: 500; color: var(--dark); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.rank-meta { font-size: 11px; color: var(--hint); flex-shrink: 0; }

/* ── Progress donut mini (completion rate) ── */
.donut-mini-wrap { display: flex; align-items: center; gap: 16px; }
.donut-mini-label { font-size: 11px; color: var(--muted); line-height: 1.5; }
.donut-mini-pct { font-size: 22px; font-weight: 700; color: var(--dark); }

/* ── Module summary cards ── */
.module-card {
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 16px; display: flex; flex-direction: column; gap: 10px;
}
.module-card-head { display: flex; align-items: center; gap: 10px; }
.module-ic { width: 34px; height: 34px; border-radius: 8px; display:flex; align-items:center; justify-content:center; font-size:17px; color:#fff; flex-shrink:0; }
.module-title { font-size: 13px; font-weight: 700; color: var(--dark); }
.module-sub   { font-size: 11px; color: var(--muted); }
.module-stats { display: flex; gap: 16px; }
.module-stat-val { font-size: 18px; font-weight: 700; color: var(--dark); line-height:1; }
.module-stat-lbl { font-size: 10px; color: var(--hint); margin-top:2px; text-transform:uppercase; letter-spacing:.4px; }

/* ── Mini bar dual-series chart ── */
.dual-bar-row { display: flex; align-items: center; gap: 8px; }
.dual-bar-lbl { font-size: 10px; color: var(--hint); width: 32px; flex-shrink:0; }
.dual-bar-track { flex:1; height: 16px; background: var(--bg); border-radius: 3px; overflow:hidden; display:flex; }
.dual-bar-seg1 { background: var(--red); height:100%; }
.dual-bar-seg2 { background: var(--dark); height:100%; opacity:.7; }
.filter-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.filter-bar input, .filter-bar select { width: auto; padding: 7px 11px; font-size: 12px; }

/* ── Answer items (dettaglio risposta) ── */
.risposta-grid { display: grid; grid-template-columns: 3fr 1.2fr; gap: 18px; }
.answer-item { padding: 11px 0; border-bottom: 1px solid var(--border); }
.answer-item:last-child { border-bottom: none; }
.answer-q { font-size: 11px; color: var(--hint); margin-bottom: 3px; text-transform: uppercase; letter-spacing: .3px; }
.answer-a { font-size: 13px; font-weight: 500; color: var(--dark); }

/* ── AI Insight card ── */
.insight-card {
  background: var(--dark); border-radius: var(--radius-lg); padding: 18px;
}
.insight-eyebrow {
  font-size: 9px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--red); margin-bottom: 14px;
  display: flex; align-items: center; gap: 6px;
}
.insight-eyebrow::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: var(--red); animation: blink 2s infinite; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.3} }
.insight-item { display: flex; gap: 10px; margin-bottom: 10px; }
.insight-item:last-child { margin-bottom: 0; }
.insight-num  { width: 18px; height: 18px; border-radius: 50%; background: var(--red); color: #fff; font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: 1px; }
.insight-txt  { font-size: 12px; color: rgba(255,255,255,.65); line-height: 1.6; }

/* ── File items (allegati) ── */
.file-item { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.file-item:last-child { border-bottom: none; }
.file-ic   { font-size: 16px; color: var(--red); flex-shrink: 0; }
.file-name { flex: 1; font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size { font-size: 11px; color: var(--hint); flex-shrink: 0; }

/* ── Domanda editor ── */
.domanda-row {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 12px 16px; margin-bottom: 8px;
  display: flex; align-items: center; gap: 12px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.domanda-row:hover { border-color: var(--border-d); box-shadow: var(--shadow); }
.drag-handle { color: var(--hint); cursor: grab; font-size: 18px; flex-shrink: 0; }
.drag-handle:active { cursor: grabbing; }
.domanda-info { flex: 1; min-width: 0; }
.domanda-text { font-size: 13px; font-weight: 500; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.domanda-meta { font-size: 11px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; }
.domanda-actions { display: flex; gap: 5px; flex-shrink: 0; }

/* ═══════════════════════════════════════════════════════════
   FRONTEND PUBBLICO — Questionario
   ═══════════════════════════════════════════════════════════ */
.admin-body-pub { background: var(--bg); }

/* ── App header ── */
#app-header {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 0 24px; height: 56px;
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0; position: sticky; top: 0; z-index: 100;
}
.logo { display: flex; align-items: center; gap: 10px; }
.logo-sq {
  width: 30px; height: 30px; border-radius: 4px;
  background: var(--red); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--serif); font-size: 12px;
}
.logo-name { font-family: var(--serif); font-size: 15px; color: var(--dark); line-height: 1.2; }
.logo-name span { color: var(--red); }
.logo-sub  { font-size: 9px; color: var(--hint); letter-spacing: 1px; text-transform: uppercase; }
.header-meta { font-size: 11px; color: var(--hint); }

/* ── Progress bar ── */
#progress-bar  { height: 2px; background: var(--border); flex-shrink: 0; }
#progress-fill { height: 100%; background: var(--red); transition: width .5s cubic-bezier(.4,0,.2,1); width: 0; }

/* ── Step pills ── */
.step-pills { display: flex; gap: 4px; padding: 14px 0 0; justify-content: center; flex-wrap: wrap; }
.step-pill  { width: 24px; height: 3px; border-radius: 2px; background: var(--border); transition: background .3s; }
.step-pill.done   { background: var(--red2); }
.step-pill.active { background: var(--red); }

/* ── Content ── */
#app { min-height: 100vh; display: flex; flex-direction: column; }
#content { flex: 1; display: flex; justify-content: center; padding: 0 16px 80px; background: var(--white); }
#step-box { width: 100%; max-width: 600px; }

/* ── Welcome screen ── */
.welcome-wrap { padding: 40px 0 28px; }
.welcome-badge {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--red-pale); border: 1px solid var(--red-bdr);
  border-radius: 2px; padding: 4px 12px;
  font-size: 10px; font-weight: 700; color: var(--red);
  letter-spacing: .8px; text-transform: uppercase; margin-bottom: 18px;
}
.welcome-title {
  font-family: var(--serif); font-size: 30px; font-weight: normal;
  line-height: 1.2; margin-bottom: 12px; color: var(--dark);
}
.welcome-sub { font-size: 14px; color: var(--muted); margin-bottom: 28px; max-width: 480px; line-height: 1.65; }
.welcome-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 24px; }
.welcome-card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 14px 15px;
  transition: border-color var(--transition);
}
.welcome-card:hover { border-color: rgba(232,40,30,.3); }
.welcome-card-icon  { font-size: 18px; margin-bottom: 7px; }
.welcome-card-title { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.welcome-card-sub   { font-size: 11px; color: var(--muted); line-height: 1.4; }
.gdpr-note { font-size: 11px; color: var(--hint); text-align: center; margin-top: 8px; }

/* ── Step header ── */
.step-header { padding-top: 30px; margin-bottom: 22px; }
.step-eyebrow { font-size: 9px; font-weight: 700; color: var(--red); text-transform: uppercase; letter-spacing: 1.4px; margin-bottom: 7px; }
.step-header h2 { font-family: var(--serif); font-size: 24px; font-weight: normal; line-height: 1.25; margin-bottom: 4px; }
.step-header p  { font-size: 13px; color: var(--muted); }

/* ── Question fields ── */
.field { margin-bottom: 18px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; color: var(--dark); }
.field .hint { font-size: 11px; color: var(--muted); margin-bottom: 7px; }
.field-req::after { content: ' *'; color: var(--red); }

/* ── Options (radio/checkbox) ── */
.opt-group { display: flex; flex-direction: column; gap: 6px; }
.opt {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 13px; border: 1.5px solid var(--border);
  border-radius: var(--radius); cursor: pointer; background: var(--white);
  transition: all var(--transition); user-select: none;
}
.opt:hover { background: var(--red-pale); border-color: var(--red-bdr); }
.opt.on    { background: rgba(232,40,30,.05); border-color: var(--red); }
.opt-mk {
  width: 17px; height: 17px; border: 1.5px solid var(--border-d);
  flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.opt.on .opt-mk { border-color: var(--red); background: var(--red); }
.opt-mk.r  { border-radius: 50%; }
.opt-mk.sq { border-radius: 3px; }
.opt.on .opt-mk.r::after  { content: ''; width: 7px; height: 7px; border-radius: 50%; background: #fff; }
.opt.on .opt-mk.sq::after { content: '✓'; color: #fff; font-size: 10px; font-weight: 700; line-height: 1; }
.opt-label { font-size: 14px; color: var(--text); flex: 1; }
.opt.on .opt-label { font-weight: 500; }

/* ── Grid 2 cols ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ── Questionario 3-col layout ── */
.q-layout {
  display: grid;
  grid-template-columns: 220px 1fr 280px;
  gap: 0;
  min-height: 100vh;
}
.q-sidebar {
  background: var(--white); border-right: 1px solid var(--border);
  padding: 24px 16px; position: sticky; top: 56px; height: calc(100vh - 56px); overflow-y: auto;
}
.q-main   { background: var(--white); padding: 28px 32px; }
.q-panel  { background: var(--bg); border-left: 1px solid var(--border); padding: 20px 16px; }

/* Journey sidebar */
.journey-title { font-size: 10px; font-weight: 700; color: var(--hint); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 16px; }
.journey-step  { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 14px; opacity: .4; transition: opacity .3s; }
.journey-step.done    { opacity: .7; }
.journey-step.current { opacity: 1; }
.j-dot { width: 20px; height: 20px; border-radius: 50%; background: var(--border); flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 9px; font-weight: 700; color: var(--muted); transition: all .3s; margin-top: 1px; }
.journey-step.done    .j-dot { background: var(--red); color: #fff; }
.journey-step.current .j-dot { background: var(--red); color: #fff; box-shadow: 0 0 0 3px rgba(232,40,30,.15); }
.j-name { font-size: 12px; font-weight: 500; color: var(--dark); }
.j-sub  { font-size: 11px; color: var(--hint); margin-top: 1px; }

/* Score ring */
.score-wrap { text-align: center; margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--border); }
.score-ring-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: var(--hint); margin-bottom: 10px; }

/* AI Panel right */
.ai-panel-title { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--red); margin-bottom: 14px; display: flex; align-items: center; gap: 6px; }
.ai-panel-title::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: var(--red); animation: blink 2s infinite; }

.ai-insight-item {
  background: var(--white); border: 1px solid var(--border);
  border-left: 2px solid var(--red);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 10px 12px; margin-bottom: 8px;
  font-size: 12px; color: var(--mid); line-height: 1.6;
}

.ai-chart-bar { margin-bottom: 10px; }
.ai-bar-label { font-size: 11px; color: var(--muted); display: flex; justify-content: space-between; margin-bottom: 4px; }
.ai-bar-track { height: 5px; background: var(--border); border-radius: 3px; overflow: hidden; }
.ai-bar-fill  { height: 100%; background: var(--red); border-radius: 3px; transition: width 1s ease; }

/* ── Nav bottom (prev/next) — nel flusso, mai sovrapposta al contenuto ── */
.step-nav {
  position: static;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-top: 36px; padding: 22px 0 8px;
  border-top: 1px solid var(--border);
  background: transparent;
}

/* ── Summary screen ── */
.summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.summary-card {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 14px;
}
.summary-q { font-size: 11px; color: var(--hint); margin-bottom: 3px; }
.summary-a { font-size: 13px; font-weight: 500; }

/* ═══════════════════════════════════════════════════════════
   RISULTATI PAGE
   ═══════════════════════════════════════════════════════════ */
.risultati-body { background: var(--bg); }

.ris-hero {
  background: var(--dark); padding: 48px 24px 40px;
  text-align: center;
}
.ris-hero-tag {
  font-size: 9px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--red); background: rgba(232,40,30,.12);
  display: inline-block; padding: 3px 12px; border-radius: 2px; margin-bottom: 14px;
}
.ris-hero h1 { font-family: var(--serif); font-size: clamp(24px,4vw,36px); font-weight: normal; color: #fff; margin-bottom: 6px; }
.ris-hero p  { font-size: 14px; color: rgba(255,255,255,.5); }

.ris-content { max-width: 900px; margin: 0 auto; padding: 28px 20px 60px; }

.ris-score-wrap {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 28px; text-align: center;
  margin-bottom: 20px;
}
.ris-score-top { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--hint); margin-bottom: 14px; }
.ris-score-val { font-family: var(--serif); font-size: 52px; color: var(--dark); line-height: 1; }
.ris-score-lbl { font-size: 12px; color: var(--muted); margin-top: 4px; }

.ris-metrics { display: grid; grid-template-columns: repeat(2,1fr); gap: 12px; margin-bottom: 20px; }
.ris-metric-card { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px; }
.ris-metric-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .7px; color: var(--hint); margin-bottom: 10px; }
.ris-metric-bar-track { height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; margin-bottom: 6px; }
.ris-metric-bar-fill  { height: 100%; background: var(--red); border-radius: 3px; }
.ris-metric-vals { display: flex; justify-content: space-between; font-size: 11px; }
.ris-metric-num  { font-size: 22px; font-weight: 700; color: var(--dark); }

.ris-insights { margin-bottom: 20px; }
.ris-section-title { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--hint); margin-bottom: 12px; }
.ris-insight-card {
  background: var(--white); border: 1px solid var(--border);
  border-left: 3px solid var(--red);
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
  padding: 14px 16px; margin-bottom: 8px;
  font-size: 13px; color: var(--mid); line-height: 1.65;
}
.ris-insight-num { font-size: 10px; font-weight: 700; color: var(--red); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 4px; }

.ris-cta {
  background: var(--red); border-radius: var(--radius-lg); padding: 28px 24px; text-align: center;
}
.ris-cta h2 { font-family: var(--serif); font-size: 22px; font-weight: normal; color: #fff; margin-bottom: 8px; }
.ris-cta p  { font-size: 13px; color: rgba(255,255,255,.7); margin-bottom: 20px; line-height: 1.6; }
.btn-white  {
  display: inline-flex; align-items: center; gap: 7px;
  background: #fff; color: var(--red);
  padding: 11px 24px; border-radius: var(--radius);
  font-size: 14px; font-weight: 700; text-decoration: none;
  transition: all .15s;
}
.btn-white:hover { background: #f5f5f5; transform: translateY(-1px); text-decoration: none; }

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  .q-layout { grid-template-columns: 1fr; }
  .q-sidebar, .q-panel { display: none; }
  .stat-grid { grid-template-columns: repeat(2,1fr); }
  .stat-grid-6 { grid-template-columns: repeat(3,1fr); }
  .ris-metrics { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .admin-main { margin-left: 0; }
  .sidebar    { display: none; }
  .admin-content { padding: 16px; }
  .grid-2 { grid-template-columns: 1fr; }
  .risposta-grid { grid-template-columns: 1fr; }
  .welcome-grid { grid-template-columns: 1fr; }
  .filter-bar input, .filter-bar select { width: 100%; }
  .page-header-row { flex-direction: column; }
  .stat-grid { grid-template-columns: 1fr; }
  .stat-grid-6 { grid-template-columns: repeat(2,1fr); }
}
