/* ── Design tokens (stessa palette delle altre app IMM) ───────────────── */
:root {
  --bg:           #f5f7fb;
  --surface:      #ffffff;
  --surface-2:    #fafbfd;
  --border:       #e5e8ef;
  --border-2:     #d8dce4;
  --text:         #1a2233;
  --text-muted:   #6b7384;
  --text-soft:    #95a0b2;

  --brand:        #2451c7;
  --brand-strong: #1b3fa3;
  --brand-soft:   #e8eefc;
  --danger:       #d8324a;
  --danger-soft:  #fde8ec;
  --in:           #15803d;
  --in-soft:      #e3f4e9;
  --out:          #c2410c;
  --out-soft:     #fdeadf;

  --shadow-sm:    0 1px 2px rgba(15, 22, 41, .04), 0 1px 3px rgba(15, 22, 41, .05);
  --shadow-md:    0 2px 6px rgba(15, 22, 41, .06), 0 8px 24px rgba(15, 22, 41, .08);
  --shadow-lg:    0 4px 12px rgba(15, 22, 41, .08), 0 24px 48px rgba(15, 22, 41, .16);

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 16px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1 { font-size: 22px; font-weight: 700; letter-spacing: -.01em; margin: 0 0 14px; }
h2 { font-size: 16px; font-weight: 600; margin: 0 0 10px; }
a  { color: var(--brand); }
.muted { color: var(--text-muted); }
.error { color: var(--danger); }

/* ── Form ──────────────────────────────────────────────────────────────── */
label { display: block; font-size: 13px; font-weight: 600; color: var(--text-muted); margin: 0 0 6px; }
.req  { color: var(--danger); }

input, select, textarea {
  width: 100%; height: 50px;
  padding: 0 14px;
  font: inherit; font-size: 17px; color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--border-2); border-radius: var(--r-md);
  outline: none; appearance: none; -webkit-appearance: none;
}
select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%236b7384'><path d='M7 10l5 5 5-5z'/></svg>");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 24px;
  padding-right: 40px;
}
input:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }

.field { position: relative; margin-bottom: 14px; }

/* ── Bottoni ───────────────────────────────────────────────────────────── */
button { font: inherit; cursor: pointer; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px;
  font-size: 16px; font-weight: 600;
  color: var(--text); background: var(--surface);
  border: 1.5px solid var(--border-2); border-radius: var(--r-md);
}
.btn:active { transform: scale(.98); }
.btn.primary { color: #fff; background: var(--brand); border-color: var(--brand); }
.btn.danger  { color: #fff; background: var(--danger); border-color: var(--danger); }
.btn.small   { min-height: 38px; padding: 0 14px; font-size: 14px; }
.btn.block   { display: flex; width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

/* ── Card / Toast ──────────────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-sm);
  padding: 16px;
}

#toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 60;
  max-width: calc(100vw - 32px);
  padding: 12px 18px; border-radius: var(--r-md);
  color: #fff; background: #1f2a4e; box-shadow: var(--shadow-lg);
  font-size: 15px; font-weight: 500; text-align: center;
}
#toast.error { background: var(--danger); }
#toast.ok    { background: var(--in); }
#toast.out   { background: var(--out); }

/* ── Sheet di conferma ─────────────────────────────────────────────────── */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(15, 22, 41, .5);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.sheet {
  width: 100%; max-width: 420px;
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 24px 20px 20px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.sheet h2 { font-size: 20px; margin-bottom: 12px; }
.sheet .body { margin-bottom: 22px; line-height: 1.6; font-size: 18px; }
.sheet .actions { display: flex; gap: 10px; }
.sheet .actions .btn { flex: 1; padding: 0 8px; }
