/* FSM - stile base condiviso (login, area ufficio, area tecnico) */
:root {
  --bg: #0b1220;
  --bg-2: #0f172a;
  --surface: #162033;
  --surface-2: #1e2a42;
  --line: #2a3a57;
  --text: #e6edf7;
  --muted: #8fa3c0;
  --primary: #3b82f6;
  --primary-d: #2563eb;
  --ok: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius: 14px;
  --tap: 48px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* ---------- pulsanti ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: var(--tap); padding: 0 20px; border: 0; border-radius: 12px;
  font: inherit; font-weight: 600; color: #fff; background: var(--surface-2);
  cursor: pointer; text-decoration: none; transition: background .15s, transform .05s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary { background: var(--primary-d); }
.btn-primary:hover:not(:disabled) { background: var(--primary); }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.btn-danger { background: #b91c1c; }
.btn-ok { background: #15803d; }
.btn-block { display: flex; width: 100%; }
.btn-sm { min-height: 38px; padding: 0 14px; font-size: .9rem; border-radius: 10px; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(59, 130, 246, .55); outline-offset: 2px;
}

/* ---------- form ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; margin-bottom: 6px; font-size: .9rem; color: var(--muted); font-weight: 600; }
.field input, .field select, .field textarea {
  width: 100%; min-height: var(--tap); padding: 12px 14px;
  background: var(--bg-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px;
  font: inherit; font-size: 16px; /* 16px evita lo zoom automatico su iOS */
}
.field textarea { min-height: 110px; resize: vertical; }
.field input::placeholder, .field textarea::placeholder { color: #5d7090; }

.alert { padding: 12px 14px; border-radius: 12px; margin-bottom: 16px; font-size: .95rem; }
.alert-danger { background: rgba(239, 68, 68, .14); border: 1px solid rgba(239, 68, 68, .5); color: #fecaca; }
.alert-warn { background: rgba(245, 158, 11, .14); border: 1px solid rgba(245, 158, 11, .5); color: #fde68a; }
.alert-ok { background: rgba(34, 197, 94, .14); border: 1px solid rgba(34, 197, 94, .5); color: #bbf7d0; }

.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, .35); border-top-color: #fff;
  animation: giro .7s linear infinite;
}
@keyframes giro { to { transform: rotate(360deg); } }

/* ---------- login ---------- */
.auth-body {
  background:
    radial-gradient(1000px 500px at 80% -10%, rgba(59, 130, 246, .25), transparent 60%),
    radial-gradient(800px 400px at -10% 110%, rgba(34, 197, 94, .12), transparent 60%),
    var(--bg);
}
.auth { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.auth-card {
  width: 100%; max-width: 420px; padding: 28px 22px 24px;
  background: rgba(22, 32, 51, .85); backdrop-filter: blur(10px);
  border: 1px solid var(--line); border-radius: 22px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .45);
}
.logo-mark {
  width: 64px; height: 64px; margin: 0 auto 16px; display: grid; place-items: center;
  border-radius: 18px; background: linear-gradient(135deg, var(--primary), var(--primary-d));
  font-weight: 800; letter-spacing: .5px;
}
.auth-card h1 { text-align: center; font-size: 1.6rem; }
.auth-sub { text-align: center; color: var(--muted); margin: 0 0 22px; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 96px; }
.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  min-height: 38px; padding: 0 12px; border: 0; border-radius: 8px;
  background: transparent; color: var(--primary); font: inherit; font-weight: 600; cursor: pointer;
}
@media (min-width: 600px) { .auth-card { padding: 36px 32px 30px; } }

/* ---------- barra superiore e pagine ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 18px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 1.1rem; margin: 0; }
.page { padding: 18px; max-width: 960px; margin: 0 auto; }
