/* Consolle — i colori di Meraki: il blu notte del logo e il suo arancio.
   L'arancio (#FF6600) su bianco sta a 2,9:1: si usa per riempire e
   sottolineare, mai per scrivere. */
:root {
  --accent: #1e2a8a;        /* riempimenti: bottoni, selezioni (testo bianco 11:1) */
  --accent-dark: #141c63;   /* testo e link su bianco: 14:1 */
  --accent-soft: #e8ebfa;
  --arancio: #ff6600;       /* il pallino del logo */
  --bg: #f4f6f8;
  --surface: #ffffff;
  --barra: #090f49;         /* lo sfondo del logo, preso dal file */
  --barra-testo: #e8ebfa;
  --text: #1e293b;
  --muted: #64748b;         /* 4,8:1 su bianco */
  --border: #e2e8f0;
  --danger: #dc2626;
  --danger-dark: #b91c1c;
  --warn: #b45309;
  --ok: #15803d;
  --radius: 10px;
  --ombra: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .08);
  --testo-font: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --titoli-font: 'Archivo', var(--testo-font);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 600 16px/1.5 var(--testo-font);
  overflow-x: hidden;
}
h1, h2, h3 { font-family: var(--titoli-font); font-stretch: 92%; line-height: 1.2; margin: 0; }
a { color: var(--accent-dark); }
[hidden] { display: none !important; }

/* ---------- barra in alto ---------- */
.barra {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: var(--barra); color: var(--barra-testo);
}
.marchio {
  display: flex; align-items: center; gap: 12px;
  color: #fff; text-decoration: none;
  font: 700 17px/1 var(--titoli-font); font-stretch: 88%; letter-spacing: .02em;
}
.marchio img { display: block; height: 26px; width: auto; }
/* Il nome dell'app separato dal logo da un filo: Meraki è chi la fa, Consolle è cosa è. */
.marchio-nome { padding-left: 12px; border-left: 1px solid rgba(232, 235, 250, .3); }
.barra .spazio { flex: 1; }
.barra .btn-fantasma { color: var(--barra-testo); border-color: rgba(232, 235, 250, .35); }
.barra .btn-primario { background: var(--arancio); color: #1a0a00; }   /* testo scuro: 6,4:1 */
.barra .btn-primario:hover:not(:disabled) { background: #ff8533; }
.barra .btn-fantasma:hover { background: rgba(255, 255, 255, .08); }

.contenuto { max-width: 1100px; margin: 0 auto; padding: 20px 16px 48px; }

/* ---------- bottoni ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 8px 16px;
  border: 1px solid transparent; border-radius: 8px;
  font: 700 15px/1.2 var(--testo-font);
  cursor: pointer; text-decoration: none; white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.btn:disabled { opacity: .6; cursor: default; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .scheda:focus-visible, .filtro:focus-visible {
  outline: 3px solid #7c8cf0; outline-offset: 2px;
}
.btn-primario { background: var(--accent); color: #fff; }
.btn-primario:hover:not(:disabled) { background: var(--accent-dark); }
.btn-secondario { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondario:hover:not(:disabled) { background: #f8fafc; }
.btn-fantasma { background: transparent; color: var(--accent-dark); border-color: var(--border); }
.btn-pericolo { background: var(--surface); color: var(--danger-dark); border-color: #fecaca; }
.btn-pericolo:hover:not(:disabled) { background: #fef2f2; }
.btn-piccolo { min-height: 32px; padding: 4px 10px; font-size: 14px; }

/* ---------- accesso ---------- */
.accesso {
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px;
  background: var(--barra);
}
.accesso-box {
  width: 100%; max-width: 380px;
  background: var(--surface); border-radius: 14px; padding: 28px 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .3);
}
.accesso-logo { display: block; width: 180px; height: auto; margin: 0 auto 22px; }
.accesso-box h1 { font-size: 22px; margin-bottom: 4px; }
.accesso-box p { color: var(--muted); margin: 0 0 20px; }
.accesso-box .btn { width: 100%; margin-top: 8px; }

/* ---------- moduli ---------- */
.campo { display: block; margin-bottom: 14px; }
.campo > span { display: block; font-size: 14px; font-weight: 700; margin-bottom: 4px; }
.campo small { display: block; color: var(--muted); font-size: 13px; margin-top: 3px; }
input, select, textarea {
  width: 100%; padding: 10px 12px;
  border: 1px solid #cbd5e1; border-radius: 8px;
  background: #fff; color: var(--text);
  font: 600 16px/1.4 var(--testo-font);  /* 16px: sotto, iOS ingrandisce la pagina */
}
textarea { resize: vertical; min-height: 84px; }
.campo-errore input, .campo-errore select, .campo-errore textarea { border-color: var(--danger); }
.griglia-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.errore-modulo {
  background: #fef2f2; color: var(--danger-dark); border: 1px solid #fecaca;
  border-radius: 8px; padding: 10px 12px; margin-bottom: 14px;
}

/* ---------- intestazione di pagina ---------- */
.testata { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 16px; }
.testata h1 { font-size: 26px; flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.testata .azioni { display: flex; gap: 8px; flex-wrap: wrap; }
.indietro { display: inline-block; margin-bottom: 10px; font-weight: 700; text-decoration: none; }
.indietro:hover { text-decoration: underline; }

/* ---------- filtri ---------- */
.filtri { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.filtro {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 999px; padding: 6px 12px; min-height: 34px;
  font: 700 14px/1 var(--testo-font); cursor: pointer;
}
.filtro[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.filtro .conta { opacity: .75; margin-left: 4px; }
.cerca { flex: 1 1 220px; max-width: 320px; margin-left: auto; }

/* ---------- schede delle app ---------- */
.griglia { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.scheda {
  display: flex; flex-direction: column; gap: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--ombra);
  color: inherit; text-decoration: none; min-width: 0;
  transition: border-color .15s ease, transform .15s ease;
}
.scheda:hover { border-color: #a5b0ec; }
.scheda:active { transform: scale(.99); }
.scheda-testa { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.scheda h2 { font-size: 18px; overflow-wrap: anywhere; }
.scheda .descr {
  color: var(--muted); margin: 0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.passo {
  background: var(--accent-soft); color: var(--accent-dark); border-radius: 8px;
  border-left: 3px solid var(--arancio);
  padding: 8px 10px; font-size: 14px; margin: 0;
  overflow-wrap: anywhere;
}
.passo b { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--accent-dark); }
.scheda .piede { margin-top: auto; display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--muted); font-size: 13px; }

/* ---------- stati ---------- */
.stato {
  flex: none; display: inline-block; border-radius: 999px; padding: 3px 10px;
  font-size: 12px; font-weight: 800; letter-spacing: .02em; white-space: nowrap;
}
.stato-idea        { background: #f1f5f9; color: #334155; }
.stato-sviluppo    { background: #dbeafe; color: #1e40af; }
.stato-pausa       { background: #fef3c7; color: #92400e; }
.stato-produzione  { background: #dcfce7; color: #166534; }
.stato-archiviata  { background: #e2e8f0; color: #475569; }

/* ---------- dettaglio ---------- */
.dettaglio { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.riquadro {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--ombra); min-width: 0;
}
.riquadro + .riquadro { margin-top: 16px; }
.riquadro h2 { font-size: 17px; margin-bottom: 12px; }
.dati { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 14px; margin: 0; }
.dati dt { color: var(--muted); font-size: 14px; }
.dati dd { margin: 0; overflow-wrap: anywhere; }
.testo-libero { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; }
.vuoto-campo { color: var(--muted); font-style: italic; }

/* Niente style="" nell'HTML: la CSP (style-src 'self') li scarta. */
.voci { margin-top: 20px; }
.azioni-modulo { display: flex; flex-wrap: wrap; gap: 8px; }
.voce { border-top: 1px solid var(--border); padding: 12px 0; }
.voce:first-of-type { border-top: 0; padding-top: 0; }
.voce-testa { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; margin-bottom: 4px; }
.voce-testa .spazio { flex: 1; }

/* ---------- stati della schermata ---------- */
.carica, .messaggio-schermata, .vuoto {
  text-align: center; padding: 48px 16px; color: var(--muted);
}
.rotella {
  width: 28px; height: 28px; margin: 0 auto 12px; border-radius: 50%;
  border: 3px solid #d5dbf7; border-top-color: var(--arancio);
  animation: gira .8s linear infinite;
}
@keyframes gira { to { transform: rotate(360deg); } }
.messaggio-schermata p { color: var(--danger-dark); margin: 0 0 14px; }
.vuoto h2 { color: var(--text); font-size: 20px; margin-bottom: 6px; }
.vuoto p { margin: 0 0 16px; }

/* ---------- avvisi ---------- */
.avvisi {
  position: fixed; z-index: 50; right: 16px; bottom: 16px; left: 16px;
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px; pointer-events: none;
}
.avviso {
  max-width: 420px; padding: 10px 14px; border-radius: 8px; color: #fff;
  background: var(--text); box-shadow: 0 6px 20px rgba(0, 0, 0, .2);
  animation: entra .18s ease-out;
}
.avviso-ok { background: var(--ok); }
.avviso-errore { background: var(--danger-dark); }
@keyframes entra { from { opacity: 0; transform: translateY(6px); } }

.piede-pagina { text-align: center; color: var(--muted); font-size: 13px; padding: 0 16px 24px; }

@media (max-width: 760px) {
  .dettaglio { grid-template-columns: minmax(0, 1fr); }
  .griglia-2 { grid-template-columns: 1fr; }
  .testata h1 { font-size: 22px; }
  .cerca { max-width: none; margin-left: 0; flex-basis: 100%; }
  .barra .testo-lungo, .marchio-nome { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition: none !important; }
}
