/* Taccuino GFR — pensato per il telefono (una mano, pollice in basso), poi va bene anche sul computer */
:root {
  --bg: #f3f5f9; --card: #ffffff; --ink: #111827; --muted: #5b6474; --line: #e3e7ef;
  --brand: #16306b; --brand-2: #2453c9; --accent: #f08a24; --red: #c62828; --ok: #1e8e4e; --wait: #b7791f; --off: #6b7280;
  --ev: #2453c9; --rem: #e07b12; --g: #0f9d58;
  --r: 14px; --tap: 48px;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1020; --card: #151b2e; --ink: #e8ecf5; --muted: #9aa4b8; --line: #252d45;
    --brand: #0d1424; --brand-2: #6d93ff; --red: #ff6b6b; --ok: #4cc38a; --wait: #e0a84a; --off: #8b93a5; --ev: #6d93ff; --rem: #ffa94d;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.4 var(--font); -webkit-text-size-adjust: 100%; }
body { min-height: 100dvh; overscroll-behavior-y: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
.ic { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.muted { color: var(--muted); } .small { font-size: 13px; } .red { color: var(--red); }

/* avvio */
.boot { min-height: 100dvh; display: grid; place-items: center; background: var(--brand); }
.boot-logo, .gate-logo { width: 72px; height: 72px; border-radius: 20px; background: linear-gradient(140deg, var(--brand-2), var(--accent)); color: #fff; display: grid; place-items: center; font: 800 38px var(--font); box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.boot-logo { animation: pulse 1.2s ease-in-out infinite alternate; }
@keyframes pulse { to { transform: scale(1.08); } }

/* accesso */
.gate { min-height: 100dvh; padding: calc(40px + var(--sat)) 24px calc(24px + var(--sab)); display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; max-width: 440px; margin: 0 auto; }
.gate h1 { margin: 14px 0 0; font-size: 26px; }
.gate p { margin: 0; color: var(--muted); }
.gate form { width: 100%; display: grid; gap: 12px; margin-top: 14px; }
.inp.code { text-align: center; font-size: 26px; letter-spacing: 6px; font-variant-numeric: tabular-nums; }

/* struttura */
#hd { position: sticky; top: 0; z-index: 20; background: var(--brand); color: #fff; padding: calc(6px + var(--sat)) 6px 6px; display: flex; align-items: center; gap: 4px; min-height: calc(56px + var(--sat)); }
#hd h1 { flex: 1; margin: 0; font-size: 18px; font-weight: 700; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hb { width: var(--tap); height: var(--tap); display: grid; place-items: center; border-radius: 12px; position: relative; }
.hb:active { background: rgba(255,255,255,.15); }
.hb-sp { width: var(--tap); }
.st i { position: absolute; top: 10px; right: 10px; width: 9px; height: 9px; border-radius: 50%; background: #4cc38a; box-shadow: 0 0 0 2px var(--brand); }
.st-off i { background: #9aa4b8; } .st-wait i { background: #f6c343; } .st-bad i { background: #ff6b6b; } .st-run i { background: #6db3ff; animation: pulse .6s infinite alternate; }
.st:not(:has(svg)) i { position: static; display: block; margin: auto; }
#main { padding: 12px 14px calc(96px + var(--sab)); max-width: 680px; margin: 0 auto; }
#tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
  background: color-mix(in srgb, var(--card) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line); padding: 6px 4px calc(6px + var(--sab)); }
.tab { display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 52px; justify-content: center; color: var(--muted); font-size: 11px; font-weight: 600; }
.tab.on { color: var(--brand-2); }
.fab { justify-self: center; width: 58px; height: 58px; border-radius: 50%; background: linear-gradient(140deg, var(--brand-2), var(--brand)); color: #fff; display: grid; place-items: center; box-shadow: 0 6px 18px rgba(36,83,201,.45); transform: translateY(-14px); }
.fab .ic { width: 28px; height: 28px; stroke-width: 2.4; }
.fab:active { transform: translateY(-14px) scale(.94); }

/* oggi */
.hello { padding: 6px 4px 4px; }
.hello small { color: var(--muted); font-weight: 600; display: block; }
.hello small::first-letter { text-transform: uppercase; }
.hello h2 { margin: 2px 0 2px; font-size: 28px; }
.hello p { margin: 0; color: var(--muted); }
.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 14px 0 6px; }
.quick button, .pr-acts button { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); min-height: 72px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--brand-2); }
.quick button:active, .pr-acts button:active { transform: scale(.96); background: color-mix(in srgb, var(--brand-2) 8%, var(--card)); }
.hint { background: color-mix(in srgb, var(--accent) 14%, var(--card)); border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent); padding: 12px 14px; border-radius: var(--r); margin: 10px 0; font-size: 14px; }
.card { width: 100%; display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: var(--r); background: var(--card); border: 1px solid var(--line); text-align: left; margin: 10px 0; }
.card span { flex: 1; display: grid; } .card small { color: var(--muted); }
.card.warn { border-color: color-mix(in srgb, var(--accent) 50%, transparent); color: var(--ink); }
.card.warn > .ic:first-child { color: var(--accent); }
.sec { margin: 20px 4px 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.sec.red { color: var(--red); }
.grp { margin: 14px 4px 6px; font-size: 13px; color: var(--muted); font-weight: 700; text-transform: capitalize; }
.more { width: 100%; padding: 12px; color: var(--brand-2); font-weight: 600; }

/* elenchi */
.list { display: grid; gap: 8px; }
.row { width: 100%; display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 10px 12px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); text-align: left; transition: opacity .25s, transform .25s; }
.row:active { background: color-mix(in srgb, var(--brand-2) 6%, var(--card)); }
.row .main { flex: 1; min-width: 0; display: grid; gap: 2px; text-align: left; }
.row .main b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.row .main small { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row.gone { opacity: 0; transform: translateX(40px); }
.ref { font: 700 12.5px/1 ui-monospace, "SF Mono", Menlo, monospace; color: var(--brand-2); background: color-mix(in srgb, var(--brand-2) 10%, transparent); padding: 6px 7px; border-radius: 8px; flex: none; }
.ref.big { font-size: 14px; }
.pill { flex: none; font-size: 11.5px; font-weight: 700; padding: 4px 8px; border-radius: 999px; max-width: 46%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-run { background: color-mix(in srgb, var(--brand-2) 14%, transparent); color: var(--brand-2); }
.t-wait { background: color-mix(in srgb, var(--wait) 18%, transparent); color: var(--wait); }
.t-bad { background: color-mix(in srgb, var(--red) 14%, transparent); color: var(--red); }
.t-ok { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.t-off { background: color-mix(in srgb, var(--off) 16%, transparent); color: var(--off); }
.rem { border-left: 4px solid var(--rem); padding-left: 6px; }
.rem.late { border-left-color: var(--red); }
.rem.late .main small { color: var(--red); }
.rem .main { padding: 4px 0; }
.chk { width: 40px; height: 40px; flex: none; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; color: transparent; }
.chk:active, .chk.on { background: var(--ok); border-color: var(--ok); color: #fff; }
.rem.done { opacity: .6; border-left-color: var(--ok); } .rem.done b { text-decoration: line-through; }
.ev { border-left: 4px solid var(--ev); }
.ev.g { border-left-color: var(--g); }
.time { width: 52px; flex: none; font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; display: grid; line-height: 1.15; }
.time small { color: var(--muted); font-weight: 500; font-size: 12.5px; }
.empty { text-align: center; padding: 22px 10px; color: var(--muted); background: var(--card); border: 1px dashed var(--line); border-radius: var(--r); }
.empty p { margin: 0; font-weight: 600; } .empty small { display: block; margin-top: 4px; }
.foot { text-align: center; color: var(--muted); font-size: 13px; margin: 18px 8px; }

/* segmenti */
.seg { display: flex; background: color-mix(in srgb, var(--muted) 12%, transparent); border-radius: 12px; padding: 3px; margin: 4px 0 12px; }
.seg button { flex: 1; min-width: 0; min-height: 40px; border-radius: 10px; font-size: 14px; white-space: nowrap; font-weight: 600; color: var(--muted); display: flex; align-items: center; justify-content: center; gap: 6px; }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.seg em { font-style: normal; font-size: 12px; background: color-mix(in srgb, var(--muted) 18%, transparent); padding: 1px 7px; border-radius: 999px; }

/* calendario */
.cal { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 2px 6px 6px; }
.cal-h { display: flex; align-items: center; }
.cal-h h2 { flex: 1; text-align: center; margin: 0; font-size: 18px; text-transform: capitalize; }
.cal-h .hb { color: var(--brand-2); }
.cal-w, .cal-g { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; }
.cal-w span { font-size: 12px; color: var(--muted); font-weight: 700; padding: 0 0 2px; }
.cal-g .d { height: 40px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border-radius: 12px; }
.cal-g .d b { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; font-weight: 600; font-variant-numeric: tabular-nums; }
.cal-g .d.today b { color: var(--brand-2); box-shadow: inset 0 0 0 2px var(--brand-2); }
.cal-g .d.sel b { background: var(--brand-2); color: #fff; box-shadow: none; }
.cal-g .d i { display: flex; gap: 3px; height: 5px; }
.cal-g .d em { width: 5px; height: 5px; border-radius: 50%; } .cal-g em.e { background: var(--ev); } .cal-g em.r { background: var(--rem); }
.day-h { display: flex; align-items: center; gap: 4px; }
.day-h .sec { flex: 1; }
.day-h .sec { text-transform: capitalize; letter-spacing: 0; font-size: 15px; color: var(--ink); }

/* ricerca */
.search { position: sticky; top: calc(56px + var(--sat)); z-index: 5; display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 0 12px; margin-bottom: 10px; }
.sheet .search { position: static; }
.search .ic { color: var(--muted); }
.search input { flex: 1; border: 0; outline: 0; background: none; min-height: 50px; font-size: 17px; }

/* pratica */
.pr-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin-bottom: 12px; }
.pr-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pr-card h2 { margin: 10px 0 2px; font-size: 22px; }
.pr-card p { margin: 2px 0; font-size: 14px; }
.calls { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.pr-acts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 14px; }
.pr-acts button { min-height: 64px; background: color-mix(in srgb, var(--brand-2) 6%, var(--card)); }
.note { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; }
.note header { display: flex; gap: 8px; align-items: center; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.note header time { margin-left: auto; }
.nt { font-weight: 700; color: var(--brand-2); background: color-mix(in srgb, var(--brand-2) 10%, transparent); padding: 2px 8px; border-radius: 999px; }
.nt-chiamata_cliente .nt, .nt-chiamata_compagnia .nt, .nt-chiamata .nt { color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.nt-pec .nt, .nt-email .nt { color: var(--wait); background: color-mix(in srgb, var(--wait) 14%, transparent); }
.nt-visita .nt { color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.note h4 { margin: 8px 0 0; font-size: 15px; }
.note p { margin: 6px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.row-acts { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

/* impostazioni */
.group { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin-bottom: 12px; display: grid; gap: 10px; }
.group h3 { margin: 0; font-size: 16px; } .group p { margin: 0; }
.sw { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; }
.sw input { appearance: none; -webkit-appearance: none; width: 51px; height: 31px; border-radius: 999px; background: color-mix(in srgb, var(--muted) 35%, transparent); position: relative; transition: background .2s; flex: none; margin: 0; }
.sw input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,.25); transition: transform .2s; }
.sw input:checked { background: var(--ok); } .sw input:checked::after { transform: translateX(20px); }

/* campi e tasti */
.inp { width: 100%; min-height: 50px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); padding: 12px 14px; font-size: 17px; outline: 0; }
.inp:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-2) 18%, transparent); }
textarea.inp { resize: vertical; min-height: 60px; line-height: 1.45; }
select.inp { appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; }
.f { display: grid; gap: 4px; font-size: 13px; color: var(--muted); font-weight: 600; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn { min-height: var(--tap); padding: 0 18px; border-radius: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: color-mix(in srgb, var(--brand-2) 12%, var(--card)); color: var(--brand-2); text-decoration: none; }
.btn.pri { background: var(--brand-2); color: #fff; }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--ink); }
.btn.danger { color: var(--red); }
.btn.wide { width: 100%; }
.btn:active { transform: scale(.97); } .btn:disabled { opacity: .5; }
.lnk { color: var(--brand-2); font-weight: 600; padding: 10px 6px; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
.lnk.center { display: flex; justify-content: center; margin: 10px auto; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; min-height: 38px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); font-size: 14px; font-weight: 600; }
.chip.on { background: var(--brand-2); border-color: var(--brand-2); color: #fff; }
.pick { width: 100%; display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 0 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); text-align: left; }
.pick > span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pick .ic { color: var(--brand-2); }
.ta { position: relative; }
.ta textarea { padding-right: 56px; }
.mic { position: absolute; right: 6px; bottom: 6px; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; color: var(--brand-2); background: color-mix(in srgb, var(--brand-2) 10%, transparent); }
.mic.on { background: var(--red); color: #fff; animation: pulse .6s infinite alternate; }

/* fogli dal basso */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; }
.sheet-bg { position: absolute; inset: 0; background: rgba(5,10,25,.45); opacity: 0; transition: opacity .2s; }
.sheet { position: absolute; left: 0; right: 0; bottom: 0; max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain; background: var(--bg); border-radius: 22px 22px 0 0;
  padding: 0 16px calc(16px + var(--sab)); display: grid; gap: 12px; transform: translateY(100%); transition: transform .22s cubic-bezier(.2,.8,.2,1); max-width: 680px; margin: 0 auto; }
.sheet-wrap.open .sheet-bg { opacity: 1; } .sheet-wrap.open .sheet { transform: none; }
.grab { position: sticky; top: 0; height: 26px; margin: 0 -16px; background: var(--bg); z-index: 2; touch-action: none; }
.grab::after { content: ""; position: absolute; left: 50%; top: 9px; width: 40px; height: 5px; border-radius: 3px; background: color-mix(in srgb, var(--muted) 45%, transparent); transform: translateX(-50%); }
.sh-t { margin: 0; font-size: 20px; }
.sh-acts { display: flex; gap: 10px; justify-content: flex-end; position: sticky; bottom: calc(-16px - var(--sab)); background: var(--bg); padding: 8px 0 calc(8px + var(--sab)); margin-bottom: calc(-16px - var(--sab)); }
.sh-acts .btn { flex: 1; }
.sh-acts .btn.pri { flex: 1.4; }
.big-acts { display: grid; gap: 10px; }
.big-acts button { display: flex; align-items: center; gap: 14px; padding: 16px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); text-align: left; min-height: 72px; }
.big-acts button > .ic { width: 28px; height: 28px; color: var(--brand-2); }
.big-acts span { display: grid; } .big-acts small { color: var(--muted); }
.list.pk { max-height: 55dvh; overflow-y: auto; }
.phases .row { min-height: 52px; }
.phases .row.cur { opacity: .5; }

/* avvisi in basso */
#toast { position: fixed; left: 12px; right: 12px; bottom: calc(92px + var(--sab)); z-index: 60; margin: 0 auto; max-width: 520px; background: #1f2937; color: #fff; border-radius: 14px; padding: 12px 14px; display: flex; align-items: center; gap: 10px; justify-content: space-between;
  opacity: 0; transform: translateY(16px); pointer-events: none; transition: opacity .2s, transform .2s; font-size: 15px; box-shadow: 0 10px 30px rgba(0,0,0,.3); }
#toast.show { opacity: 1; transform: none; pointer-events: auto; }
#toast.bad { background: #8f1d1d; }
#toast .lnk { color: #9cc0ff; padding: 6px; }
.loading { display: grid; place-items: center; gap: 10px; padding: 60px 0; color: var(--muted); }
.spin { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--brand-2); animation: rot .8s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }

@media (min-width: 760px) {
  #tabs { left: 50%; right: auto; width: 520px; transform: translateX(-50%); bottom: 14px; border-radius: 20px; border: 1px solid var(--line); padding-bottom: 6px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
