/* Vista mobile in sola lettura - stile. File NUOVO, solo caratteri ASCII. */
:root {
  --bg: #eef1f6;
  --surface: #ffffff;
  --surface-2: #f5f7fb;
  --ink: #17202f;
  --muted: #5d6b82;
  --line: #e0e5ee;
  --brand: #1d4999;
  --brand-ink: #ffffff;
  --brand-soft: #e6edf9;
  --ok: #12805c;
  --ok-soft: #dff3ea;
  --warn: #a35a00;
  --warn-soft: #fdf0d9;
  --danger: #b3261e;
  --danger-soft: #fbe3e1;
  --grey-soft: #e9ecf2;
  --shadow: 0 1px 2px rgba(20, 30, 50, .08), 0 4px 14px rgba(20, 30, 50, .06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1118;
    --surface: #171d28;
    --surface-2: #1d2432;
    --ink: #e8edf6;
    --muted: #9aa8bf;
    --line: #2a3344;
    --brand: #7ea6ee;
    --brand-ink: #0d1118;
    --brand-soft: #1f2c47;
    --ok: #55d1a0;
    --ok-soft: #123a2c;
    --warn: #f0b458;
    --warn-soft: #3b2c10;
    --danger: #ff8f86;
    --danger-soft: #45201d;
    --grey-soft: #262e3d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.4;
  -webkit-text-size-adjust: 100%;
}
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--brand); }
#root { height: 100%; display: flex; justify-content: center; background: var(--bg); }

/* ---------- struttura ---------- */
.app {
  width: 100%;
  max-width: 560px;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}
@media (min-width: 600px) {
  .app { box-shadow: 0 0 0 1px var(--line), var(--shadow); }
}
.topbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 12px 10px;
  background: var(--bg);
}
.topbar h1 { font-size: 20px; margin: 0; flex: 1; line-height: 1.2; }
.iconbtn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 0;
  background: transparent;
  display: grid;
  place-items: center;
  color: var(--ink);
}
.iconbtn:active { background: var(--grey-soft); }
.iconbtn svg { width: 22px; height: 22px; }
.content { flex: 1; overflow-y: auto; padding: 0 14px 18px; -webkit-overflow-scrolling: touch; }
.tabbar {
  flex: none;
  display: flex;
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tabbar button {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 8px 0 6px;
  color: var(--muted);
  display: grid;
  justify-items: center;
  gap: 2px;
  font-size: 11.5px;
}
.tabbar button svg { width: 22px; height: 22px; }
.tabbar button.on { color: var(--brand); font-weight: 700; }

/* ---------- componenti ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 13px 14px;
  margin-bottom: 10px;
}
.card.tap { cursor: pointer; }
.card.tap:active { background: var(--surface-2); }
.row { display: flex; align-items: center; gap: 8px; }
.grow { flex: 1; min-width: 0; }
.title { font-weight: 700; font-size: 16px; }
.sub { color: var(--muted); font-size: 13px; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; align-items: center; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--grey-soft);
  color: var(--ink);
  white-space: nowrap;
}
.chip svg { width: 13px; height: 13px; }
.chip.brand { background: var(--brand-soft); color: var(--brand); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.danger { background: var(--danger-soft); color: var(--danger); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); display: inline-block; flex: none; }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.danger { background: var(--danger); }
.dot.unread { background: var(--brand); }

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 12px;
  margin-bottom: 10px;
}
.search svg { width: 18px; height: 18px; color: var(--muted); flex: none; }
.search input {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  padding: 12px 0;
  min-width: 0;
  outline: none;
}
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 10px; }
.chips button {
  flex: none;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 13px;
}
.chips button.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.count { color: var(--muted); font-size: 12.5px; margin: 2px 2px 8px; }
.morebtn {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 12px;
  padding: 12px;
  color: var(--brand);
  font-weight: 600;
  margin-bottom: 10px;
}
.absent {
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 12px;
  color: var(--muted);
  font-size: 13px;
  margin-top: 10px;
}
.banner {
  background: var(--warn-soft);
  color: var(--warn);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13px;
  margin: 0 0 10px;
}
.banner.err { background: var(--danger-soft); color: var(--danger); }
.loading { color: var(--muted); padding: 18px 4px; }

/* area: fascia colorata e pallino */
.areaCard { padding: 12px 14px; border-left-width: 6px; border-left-style: solid; }
.areaCard .title { font-size: 16px; }
.code { font-weight: 700; color: var(--muted); font-size: 13px; white-space: nowrap; }
.adot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.a0 { border-left-color: #2563eb; } .adot.a0 { background: #2563eb; }
.a1 { border-left-color: #9333ea; } .adot.a1 { background: #9333ea; }
.a2 { border-left-color: #d97706; } .adot.a2 { background: #d97706; }
.a3 { border-left-color: #059669; } .adot.a3 { background: #059669; }
.a4 { border-left-color: #dc2626; } .adot.a4 { background: #dc2626; }
.a5 { border-left-color: #0891b2; } .adot.a5 { background: #0891b2; }
.a6 { border-left-color: #64748b; } .adot.a6 { background: #64748b; }
.a7 { border-left-color: #be185d; } .adot.a7 { background: #be185d; }
.ax { border-left-color: #94a3b8; } .adot.ax { background: #94a3b8; }

/* accesso e codice */
.login { padding: 28px 22px; display: flex; flex-direction: column; justify-content: center; flex: 1; overflow-y: auto; }
.logo {
  width: 58px;
  height: 58px;
  border-radius: 16px;
  background: var(--brand);
  color: var(--brand-ink);
  display: grid;
  place-items: center;
  margin-bottom: 14px;
}
.logo svg { width: 30px; height: 30px; }
.login h1 { margin: 0 0 4px; font-size: 24px; }
.login p { margin: 0 0 20px; color: var(--muted); }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
.field input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 12px;
  padding: 13px 14px;
  font: inherit;
  outline: none;
}
.field input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.btn {
  width: 100%;
  border: 0;
  background: var(--brand);
  color: var(--brand-ink);
  border-radius: 12px;
  padding: 14px;
  font-weight: 700;
  margin-top: 4px;
}
.btn[disabled] { opacity: .45; cursor: default; }
.btn.ghost { background: transparent; color: var(--brand); font-weight: 600; }
.btn.outline {
  background: var(--surface);
  color: var(--brand);
  border: 1px solid var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px;
  margin: 0 0 10px;
  text-decoration: none;
}
.btn.outline svg { width: 18px; height: 18px; }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.note {
  margin-top: 16px;
  font-size: 12.5px;
  color: var(--muted);
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.note svg { width: 16px; height: 16px; flex: none; margin-top: 1px; }
.otp { display: flex; gap: 8px; justify-content: space-between; margin: 4px 0 8px; }
.otp input {
  width: 100%;
  min-width: 0;
  aspect-ratio: 1 / 1.25;
  text-align: center;
  font-size: 26px;
  font-weight: 800;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
  padding: 0;
}
.otp input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.otp.err input { border-color: var(--danger); background: var(--danger-soft); }
.errmsg, .login p.errmsg { color: var(--danger); font-size: 13px; font-weight: 600; margin: 0 0 8px; }

/* scheda */
.hero { padding: 2px 2px 12px; }
.hero .who { font-size: 21px; font-weight: 800; line-height: 1.2; overflow-wrap: anywhere; }
.hero .what { color: var(--muted); margin-top: 3px; }
.seg-tabs { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 10px; }
.seg-tabs button {
  flex: none;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13.5px;
}
.seg-tabs button.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 700; }
.kv { display: grid; }
.kv > div {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.kv > div:last-child { border-bottom: 0; }
.kv .k { color: var(--muted); font-size: 13px; }
.kv .v { font-weight: 600; overflow-wrap: anywhere; }
.kv .v small { font-weight: 400; color: var(--muted); display: block; }
.link { color: var(--brand); text-decoration: none; font-weight: 700; }
.section-h { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 16px 2px 8px; font-weight: 700; }

/* timeline verticale */
.progress { height: 8px; background: var(--grey-soft); border-radius: 999px; overflow: hidden; margin: 8px 0 4px; }
.progress > i { display: block; height: 100%; background: var(--brand); border-radius: 999px; }
.tl { list-style: none; margin: 0; padding: 0; position: relative; }
.tl li { position: relative; padding: 0 0 16px 32px; min-height: 34px; }
.tl li::before {
  content: "";
  position: absolute;
  left: 10px;
  top: 22px;
  bottom: -2px;
  width: 2px;
  background: var(--line);
}
.tl li:last-child::before { display: none; }
.tl li.done::before { background: var(--brand); }
.tl .pin {
  position: absolute;
  left: 2px;
  top: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: var(--surface);
  display: grid;
  place-items: center;
}
.tl li.done .pin { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.tl li.now .pin { border-color: var(--brand); box-shadow: 0 0 0 5px var(--brand-soft); background: var(--surface); }
.tl li.now .pin::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); }
.tl .pin svg { width: 11px; height: 11px; }
.tl .t { font-weight: 600; }
.tl li.todo .t { color: var(--muted); font-weight: 500; }
.tl li.now .t { font-weight: 800; }
.tl .d { font-size: 12.5px; color: var(--muted); }
.tl li.gap { min-height: 0; padding-bottom: 12px; }
.tl li.gap .pin { width: 8px; height: 8px; left: 7px; top: 8px; background: var(--line); border: 0; }
.tl li.gap .t { font-size: 13px; }
.tl .pin.warn { border-color: var(--warn); }
.tl .pin.danger { border-color: var(--danger); }
.miniLink { border: 0; background: none; color: var(--brand); font-weight: 600; padding: 0; }
.today {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: .08em;
  color: var(--brand);
  margin: 2px 0 10px;
}
.today::before, .today::after { content: ""; height: 1px; background: var(--brand); flex: 1; opacity: .5; }

/* documenti */
.doc { display: flex; align-items: center; gap: 12px; }
.doc .ico { width: 38px; height: 38px; border-radius: 10px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; flex: none; }
.doc .ico svg { width: 20px; height: 20px; }
.doc .n { font-weight: 700; overflow-wrap: anywhere; }
.chev { color: var(--muted); width: 18px; height: 18px; flex: none; }

/* email */
.mail .sender { font-size: 14px; display: flex; align-items: center; gap: 7px; }
.mail .subject { font-size: 15px; margin: 2px 0 3px; overflow-wrap: anywhere; }
.mail.unread .sender, .mail.unread .subject { font-weight: 800; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mailbody {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.5;
}
.mailframe { width: 100%; border: 1px solid var(--line); border-radius: 14px; background: #ffffff; min-height: 120px; display: block; }
.att { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.att:last-child { border-bottom: 0; }
.att svg { width: 20px; height: 20px; color: var(--muted); flex: none; }
.att .n { font-weight: 600; overflow-wrap: anywhere; }
.att .sz { color: var(--muted); font-size: 12.5px; }
.readonly-note { display: flex; gap: 8px; align-items: flex-start; font-size: 12.5px; color: var(--muted); margin: 12px 2px 0; }
.readonly-note svg { width: 16px; height: 16px; flex: none; margin-top: 1px; }

/* visualizzatore documento */
.overlay { position: absolute; top: 0; right: 0; bottom: 0; left: 0; z-index: 8; display: flex; flex-direction: column; background: var(--bg); }
.viewerbody { flex: 1; overflow-y: auto; padding: 0 14px 18px; }
.viewerbody img { max-width: 100%; height: auto; display: block; margin: 0 auto; border-radius: 6px; }
.pdfframe { width: 100%; height: 70vh; border: 1px solid var(--line); border-radius: 8px; background: #ffffff; }
.avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 18px;
  flex: none;
}
.toast {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 74px);
  background: var(--ink);
  color: var(--bg);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13px;
  z-index: 9;
  overflow-wrap: anywhere;
}

/* fase 2: assistiti */
.stato { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; color: var(--muted); flex: none; }
.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0 0 12px; }
.actions a {
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 10px 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  text-decoration: none;
  color: var(--brand);
  font-size: 12.5px;
  font-weight: 700;
}
.actions a:not([href]) { opacity: .4; }
.actions svg { width: 22px; height: 22px; }
