/* Il sistema visivo. Un solo file, nessun marchio scritto dentro.
 *
 * Il colore d'accento arriva dal branding della struttura via variabile CSS:
 * un cliente che vuole il proprio verde non ha bisogno di un foglio di stile
 * suo, e noi non abbiamo bisogno di mantenere venti fogli di stile.
 *
 * Mobile-first davvero, non per modo di dire: chi usa questo prodotto lo usa
 * in piedi in un corridoio, con una mano sola. Le misure di partenza sono
 * quelle di un telefono; il desktop e' l'adattamento. */

:root {
  --accent: #2f5fd8;
  --accent-soft: #eaf0ff;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --line: #e3e6eb;
  --text: #14171c;
  --muted: #6b7280;
  --faint: #9aa1ab;
  --open: #2f5fd8;
  --progress: #b46b00;
  --done: #1a7f4b;
  --urgent: #c0392b;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 14px rgba(16, 24, 40, .06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c; --surface: #1c2027; --line: #2b313a;
    --text: #eef1f5; --muted: #98a1ad; --faint: #6e7783;
    --accent-soft: #1e2942;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ------------------------------------------------------------ struttura */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.top .brand { font-weight: 650; letter-spacing: -.01em; }
.top .grow { flex: 1; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 16px 16px 96px; }

/* La barra in basso: il pollice arriva li', non in cima allo schermo. */
.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.tabs button {
  flex: 1; border: 0; background: none; color: var(--muted);
  padding: 10px 4px 12px; font-size: 11px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.tabs button .ico { font-size: 19px; line-height: 1; }
.tabs button.on { color: var(--accent); font-weight: 600; }

@media (min-width: 860px) {
  .tabs { position: static; border: 0; background: none; padding: 0 0 8px;
          max-width: 1080px; margin: 12px auto 0; gap: 4px; }
  .tabs button { flex: 0 0 auto; flex-direction: row; font-size: 14px;
                 padding: 8px 14px; border-radius: 999px; }
  .tabs button.on { background: var(--accent-soft); }
  .wrap { padding-bottom: 48px; }
}

/* --------------------------------------------------------------- pezzi */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 14px;
}
.card h2 { margin: 0 0 4px; font-size: 16px; letter-spacing: -.01em; }
.card .sub { color: var(--muted); font-size: 13px; margin-bottom: 12px; }

.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
@media (min-width: 700px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; text-align: left;
  cursor: pointer; font: inherit; color: inherit; width: 100%;
}
.kpi:hover { border-color: var(--accent); }
.kpi .lab { color: var(--muted); font-size: 12px; display: block; margin-bottom: 6px; }
.kpi .num { font-size: 26px; font-weight: 650; letter-spacing: -.02em; }
.kpi .num.urgent { color: var(--urgent); }

.item {
  display: block; width: 100%; text-align: left; font: inherit; color: inherit;
  background: var(--surface); border: 1px solid var(--line);
  border-left: 3px solid var(--open);
  border-radius: 10px; padding: 12px 14px; margin-bottom: 8px; cursor: pointer;
}
.item:hover { border-color: var(--accent); }
.item.s2 { border-left-color: var(--progress); }
.item.s3 { border-left-color: var(--done); }
.item.s4 { border-left-color: var(--faint); }
.item .t { font-weight: 560; margin-bottom: 4px; }
.item .m { color: var(--muted); font-size: 12.5px;
           display: flex; flex-wrap: wrap; gap: 10px; }

.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; background: var(--accent-soft);
  color: var(--accent);
}
.badge.urgent { background: #fdecea; color: var(--urgent); }
.badge.done { background: #e8f6ee; color: var(--done); }
.badge.prov { background: #fdf3e0; color: var(--progress); }

button.btn {
  font: inherit; font-weight: 560; cursor: pointer;
  border-radius: 10px; padding: 10px 16px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); min-height: 44px;
}
button.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.btn.ghost { border: 0; background: none; color: var(--accent); }
button.btn:disabled { opacity: .5; cursor: not-allowed; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }

label.f { display: block; margin-bottom: 12px; }
label.f span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px;
  min-height: 44px;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent);
}
textarea { min-height: 84px; resize: vertical; }

.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty .big { font-size: 34px; margin-bottom: 8px; }

.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px;
         margin-bottom: 12px; -webkit-overflow-scrolling: touch; }
.chip { white-space: nowrap; border: 1px solid var(--line); background: var(--surface);
        color: var(--muted); border-radius: 999px; padding: 7px 14px;
        font-size: 13px; cursor: pointer; min-height: 38px; }
.chip.on { background: var(--accent-soft); color: var(--accent);
           border-color: var(--accent); font-weight: 600; }

.steps { display: flex; gap: 4px; margin-bottom: 16px; }
.steps i { flex: 1; height: 4px; border-radius: 2px; background: var(--line); }
.steps i.on { background: var(--accent); }

.bar { height: 8px; border-radius: 4px; background: var(--accent-soft); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); }

table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { text-align: left; color: var(--muted); font-weight: 560;
                font-size: 12px; padding: 6px 8px; }
table.data td { padding: 9px 8px; border-top: 1px solid var(--line); }
.scroll-x { overflow-x: auto; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 84px;
  background: var(--text); color: var(--bg); padding: 11px 18px;
  border-radius: 10px; z-index: 60; font-size: 14px; max-width: 90vw;
}
.toast.bad { background: var(--urgent); color: #fff; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 8px 0 8px 16px; border-left: 2px solid var(--line);
               margin-left: 4px; font-size: 13.5px; }
.timeline li b { font-weight: 600; }
.timeline li span { color: var(--muted); }

/* Il selettore della struttura si adatta al nome, non allo schermo: largo
   quanto la pagina sembrerebbe un campo da compilare invece di
   un'indicazione di dove ci si trova. */
.sel { display: inline-flex; align-items: center; gap: 6px; width: auto;
       min-height: 36px; border: 1px solid var(--line);
       background: var(--surface); border-radius: 999px; padding: 6px 12px;
       font-size: 13px; cursor: pointer; max-width: 55vw; }
select.sel { -webkit-appearance: none; appearance: none;
             padding-right: 28px;
             background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                               linear-gradient(135deg, var(--muted) 50%, transparent 50%);
             background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%;
             background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
.sel b { font-weight: 600; overflow: hidden; text-overflow: ellipsis;
         white-space: nowrap; }

.sheet {
  position: fixed; inset: 0; background: rgba(10, 14, 20, .45); z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet > div {
  background: var(--surface); width: 100%; max-width: 560px;
  border-radius: 16px 16px 0 0; padding: 20px; max-height: 88vh; overflow-y: auto;
}
@media (min-width: 700px) {
  .sheet { align-items: center; }
  .sheet > div { border-radius: 16px; }
}
