/* =====================================================================
   1Homepage · Tema delle pagine utente  (app_theme.css)
   Pagine di lavoro dell'utente (profilo, aggiungi/modifica bottoni,
   sezioni, righe, note, condivisioni...). La dashboard ha il suo CSS.
   Stessa famiglia visiva del pannello admin (admin_theme.css): carta
   calda, tipografia Bricolage Grotesque + IBM Plex, arancio del marchio.
   Colori personali dell'utente (impostati da app_ui_head() in app_ui.php):
   --nav-bg / --nav-fg  = users.nav_color     (barra superiore)
   --accent / --accent-ink = users.button_color (pulsanti principali)
   Stessi token e misure di dashboard_theme.css (--hp-*) e admin_theme.css.
   ===================================================================== */

/* ---------- Token ---------- */
:root {
  --font-display: "Bricolage Grotesque", "IBM Plex Sans", system-ui, sans-serif;
  --font-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --bg: #f4f1eb;
  --surface: #ffffff;
  --surface-2: #faf8f4;
  --surface-3: #f1ede6;
  --ink: #1c1917;
  --ink-2: #3f3a36;
  --muted: #7a716a;
  --muted-2: #a89f95;
  --line: #e8e2d9;
  --line-2: #d8d0c5;

  --brand: #f45422;
  --brand-deep: #c93c10;
  --brand-soft: #ffefe8;

  /* colori personali dell'utente (sovrascritti da app_ui_head()) */
  --nav-bg: #333333;
  --nav-fg: #ffffff;
  --accent: #f45422;
  --accent-ink: #ffffff;
  --accent-soft: color-mix(in srgb, var(--accent) 10%, #ffffff);
  --accent-line: color-mix(in srgb, var(--accent) 38%, #ffffff);

  --ok: #0f766e;   --ok-soft: #e3f3f0;   --ok-ink: #0b5c56;
  --bad: #b42318;  --bad-soft: #fdeceb;  --bad-ink: #8f1d13;
  --info: #1d4ed8; --info-soft: #e9effd; --info-ink: #1a3faf;
  --warn: #b45309; --warn-soft: #fdf1e0; --warn-ink: #8a4007;

  --radius-s: 8px;
  --radius: 12px;
  --radius-l: 18px;
  --shadow-s: 0 1px 2px rgba(28, 25, 23, .06), 0 1px 1px rgba(28, 25, 23, .03);
  --shadow: 0 1px 2px rgba(28, 25, 23, .05), 0 16px 36px -20px rgba(28, 25, 23, .24);
  --shadow-l: 0 30px 70px -28px rgba(28, 25, 23, .45), 0 2px 6px rgba(28, 25, 23, .08);
  --ring: 0 0 0 3px color-mix(in srgb, var(--accent) 28%, transparent);
  --bar-h: 64px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

/* ---------- Base (solo pagine con <body class="app">) ---------- */
:where(.app, .app *, .app *::before, .app *::after) { box-sizing: border-box; }
html:has(body.app) { -webkit-text-size-adjust: 100%; }
body.app {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background-color: var(--bg);
  background-image:
  radial-gradient(1000px 460px at 8% -14%, color-mix(in srgb, var(--nav-bg) 17%, transparent), transparent 64%),
  radial-gradient(760px 380px at 100% -8%, rgba(244, 84, 34, .06), transparent 60%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
/* grana leggera, come nel pannello admin */
body.app::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: .045;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.7 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  background-size: 240px 240px;
}
:where(.app h1, .app h2, .app h3, .app h4) {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -.012em;
  line-height: 1.15;
  color: var(--ink);
  margin: 0 0 .4em;
}
:where(.app h1) { font-size: clamp(26px, 3.2vw, 36px); letter-spacing: -.022em; }
:where(.app h2) { font-size: 20px; }
:where(.app h3) { font-size: 16.5px; }
:where(.app h4) { font-size: 15px; }
:where(.app p) { margin: 0 0 12px; }
:where(.app a) { color: var(--brand-deep); text-decoration: none; }
:where(.app a:hover) { text-decoration: underline; text-underline-offset: 3px; }
:where(.app img) { max-width: 100%; }
:where(.app hr) { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }
:where(.app code), .mono { font-family: var(--font-mono); font-size: .88em; }
:where(.app) ::selection { background: color-mix(in srgb, var(--accent) 22%, #fff); }
:where(.app) :focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--radius-s); }
.muted, .text-muted { color: var(--muted) !important; }
.small { font-size: 13px; }
.t-center { text-align: center; }
.nowrap { white-space: nowrap; }
/* l'attributo hidden vince sempre sui display dei componenti */
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- Barra superiore (app_ui_bar() in app_ui.php) ---------- */
.app-bar {
  position: sticky;
  top: 0;
  z-index: 1000;
  color: var(--nav-fg);
  background:
  linear-gradient(180deg, rgba(255, 255, 255, .10), rgba(255, 255, 255, 0) 60%),
  var(--nav-bg);
  box-shadow: 0 1px 0 rgba(0, 0, 0, .08), 0 10px 30px -18px rgba(28, 25, 23, .55);
}
.app-bar__inner {
  max-width: 1240px;
  height: var(--bar-h);
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.app-bar a { color: inherit; text-decoration: none; }
.app-bar a:hover { text-decoration: none; }
.app-bar__back {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  height: 36px;
  padding: 0 14px 0 12px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  background: color-mix(in srgb, var(--nav-fg) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--nav-fg) 18%, transparent);
  transition: background .18s var(--ease), transform .18s var(--ease);
}
.app-bar__back:hover { background: color-mix(in srgb, var(--nav-fg) 20%, transparent); }
.app-bar__back:active { transform: translateY(1px); }
.app-bar__back i { font-size: 13px; transition: transform .2s var(--ease); }
.app-bar__back:hover i { transform: translateX(-2px); }
.app-bar__title {
  min-width: 0;
  flex: 1;
  font-family: var(--font-display);
  font-weight: 650;
  font-size: 16px;
  letter-spacing: -.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: .96;
}
.app-bar__title small {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  opacity: .72;
  margin-right: 8px;
}
.app-bar__user { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.app-bar__chip {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  height: 36px;
  max-width: 320px;
  padding: 0 14px 0 4px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 500;
  background: color-mix(in srgb, var(--nav-fg) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--nav-fg) 16%, transparent);
  transition: background .18s var(--ease);
}
.app-bar__chip:hover { background: color-mix(in srgb, var(--nav-fg) 18%, transparent); }
.app-bar__chip.is-active { background: color-mix(in srgb, var(--nav-fg) 22%, transparent); }
.app-bar__chip span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-bar__avatar {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  color: var(--nav-bg);
  background: var(--nav-fg);
  overflow: hidden;
}
.app-bar__avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.app-bar__icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .12);
  display: inline-grid;
  place-items: center;
  font-size: 15px;
  border: 1px solid color-mix(in srgb, var(--nav-fg) 16%, transparent);
  transition: background .18s var(--ease);
}
.app-bar__icon:hover { background: color-mix(in srgb, var(--nav-fg) 16%, transparent); }
@media (max-width: 640px) {
  :root { --bar-h: 56px; }
}
@media (max-width: 720px) {
  .app-bar__inner { padding: 0 12px; gap: 8px; }
  .app-bar__title { display: none; }
  .app-bar__chip { padding-right: 4px; }
  .app-bar__chip span:last-child { display: none; }
  .app-bar__back span { display: none; }
  .app-bar__back { padding: 0 13px; }
}

/* ---------- Layout di pagina ---------- */
.app-main {
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: 36px 20px 72px;
}
.app-main--narrow { max-width: 680px; }
.app-main--wide { max-width: 1240px; }
@media (max-width: 720px) { .app-main { padding: 22px 14px 56px; } }

.page-head { margin: 0 0 26px; }
.page-head--center { text-align: center; }
.page-head--center .page-subtitle { margin-left: auto; margin-right: auto; }
.page-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}
.page-eyebrow::before {
  content: "";
  width: 22px;
  height: 2px;
  border-radius: 2px;
  background: var(--brand);
}
.page-head h1 { margin: 0; }
.page-subtitle {
  max-width: 62ch;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 15px;
}
.page-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.page-head--center .page-actions { justify-content: center; }

/* entrata morbida degli elementi principali */
@media (prefers-reduced-motion: no-preference) {
  .app-main > * { animation: app-rise .5s var(--ease) both; }
  .app-main > *:nth-child(2) { animation-delay: .05s; }
  .app-main > *:nth-child(3) { animation-delay: .10s; }
  .app-main > *:nth-child(4) { animation-delay: .15s; }
  .app-main > *:nth-child(n+5) { animation-delay: .2s; }
}
@keyframes app-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
@media (max-width: 860px) { .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.stack > * + * { margin-top: 16px; }
.row-flex { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.spacer { flex: 1; }

/* ---------- Pannelli / card ---------- */
.panel, .card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow);
}
.panel + .panel { margin-top: 18px; }
.panel__head, .card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  background: transparent;
}
.panel__head h2, .panel__head h3, .card-header h2, .card-header h3 { margin: 0; font-size: 16.5px; }
.panel__head .fa-solid, .panel__head .fas, .card-header .fas, .card-header .fa-solid { color: var(--muted); }
.panel__body, .card-body { padding: 22px; }
.panel__foot, .card-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 22px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 0 0 var(--radius-l) var(--radius-l);
}
.panel--flat { box-shadow: var(--shadow-s); }
.panel--muted { background: var(--surface-2); box-shadow: none; }
@media (max-width: 640px) {
  .panel__head, .card-header { padding: 16px; }
  .panel__body, .card-body { padding: 16px; }
  .panel__foot, .card-footer { padding: 14px 16px; }
}

/* card cliccabile con icona (pagina "aggiungi") */
.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-s);
  transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s var(--ease);
}
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--line-2); }
.tile__icon {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 19px;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
}
.tile h2, .tile h3 { margin: 4px 0 0; font-size: 18px; }
.tile p { color: var(--muted); margin: 0; }
.tile__foot { margin-top: auto; padding-top: 6px; display: flex; flex-direction: column; gap: 10px; }

/* ---------- Form ---------- */
.field, .form-group { margin-bottom: 18px; }
:where(.app label), .field__label {
  display: block;
  margin-bottom: 7px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-2);
}
:where(.app label) .req { color: var(--brand-deep); }
:where(.app input[type="text"], .app input[type="email"], .app input[type="url"], .app input[type="password"],
.app input[type="number"], .app input[type="search"], .app input[type="tel"], .app input[type="date"],
.app select, .app textarea), .form-control {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 10px 13px;
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  box-shadow: inset 0 1px 1px rgba(28, 25, 23, .03);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease), background .15s var(--ease);
  -webkit-appearance: none;
  appearance: none;
}
:where(.app textarea) { min-height: 110px; resize: vertical; line-height: 1.5; }
:where(.app select), select.form-control {
  padding-right: 38px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='none' stroke='%23736a63' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M1 1.5l5 5 5-5'/></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
}
:where(.app input:hover, .app select:hover, .app textarea:hover), .form-control:hover { border-color: var(--muted-2); }
:where(.app input:focus, .app select:focus, .app textarea:focus), .form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}
:where(.app input[readonly], .app input:disabled, .app select:disabled, .app textarea[readonly]), .form-control[readonly] {
  color: var(--muted);
  background: var(--surface-3);
  border-color: var(--line);
  cursor: not-allowed;
  box-shadow: none;
}
:where(.app) ::placeholder { color: var(--muted-2); opacity: 1; }
:where(.app input[type="checkbox"], .app input[type="radio"]) {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
  vertical-align: middle;
  cursor: pointer;
}
:where(.app input[type="color"]) {
  width: 46px;
  height: 40px;
  padding: 3px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-s);
  background: var(--surface);
  cursor: pointer;
}
:where(.app input[type="file"]) {
  display: block;
  width: 100%;
  padding: 9px;
  font: inherit;
  font-size: 14px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px dashed var(--line-2);
  border-radius: var(--radius);
}
:where(.app input[type="file"])::file-selector-button {
  margin-right: 12px;
  padding: 8px 14px;
  font: inherit;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: 999px;
  cursor: pointer;
}
.hint, .form-text, .help-text {
  display: block;
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--muted);
}
.check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
  font-size: 14.5px;
  color: var(--ink-2);
  cursor: pointer;
  margin: 0;
}
.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}
.form-actions--split { justify-content: space-between; }

/* scelta a pillole (radio) */
.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.segmented label, .segmented .segmented__opt {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label:has(input:checked), .segmented .is-active {
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow-s);
}

/* ---------- Pulsanti ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 40px;
  padding: 0 18px;
  font: inherit;
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.1;
  white-space: nowrap;
  color: var(--ink);
  background: var(--surface-3);
  border: 1px solid var(--line-2);
  border-radius: 999px;
  box-shadow: var(--shadow-s);
  cursor: pointer;
  text-decoration: none;
  transition: background .16s var(--ease), border-color .16s var(--ease), box-shadow .16s var(--ease), transform .16s var(--ease), color .16s var(--ease);
}
.btn:hover { text-decoration: none; border-color: var(--muted-2); background: var(--surface-2); color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn.is-disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn i { font-size: .95em; }
.btn--primary, .btn-primary, .btn-accent {
  color: var(--accent-ink);
  background: var(--accent);
  border-color: transparent;
  box-shadow: 0 1px 2px rgba(28, 25, 23, .12), 0 8px 18px -10px color-mix(in srgb, var(--accent) 70%, transparent);
}
.btn--primary:hover, .btn-primary:hover, .btn-accent:hover {
  color: var(--accent-ink);
  background: color-mix(in srgb, var(--accent) 88%, #000);
  border-color: transparent;
}
.btn--brand, .btn-brand { color: #fff; background: var(--brand); border-color: transparent; }
.btn--brand:hover, .btn-brand:hover { color: #fff; background: var(--brand-deep); border-color: transparent; }
.btn--danger, .btn-danger { color: #fff; background: var(--bad); border-color: transparent; }
.btn--danger:hover, .btn-danger:hover { color: #fff; background: var(--bad-ink); border-color: transparent; }
.btn--danger-ghost { color: var(--bad); background: var(--surface); border-color: color-mix(in srgb, var(--bad) 30%, #fff); }
.btn--danger-ghost:hover { color: var(--bad-ink); background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 45%, #fff); }
.btn--ok, .btn-success { color: #fff; background: var(--ok); border-color: transparent; }
.btn--ok:hover, .btn-success:hover { color: #fff; background: var(--ok-ink); border-color: transparent; }
.btn--ghost, .btn-secondary, .btn-outline { color: var(--ink-2); background: transparent; box-shadow: none; }
.btn--ghost:hover, .btn-secondary:hover, .btn-outline:hover { background: var(--surface); }
.btn--quiet { color: var(--muted); background: transparent; border-color: transparent; box-shadow: none; }
.btn--quiet:hover { color: var(--ink); background: var(--surface-3); border-color: transparent; }
.btn--sm, .btn-sm { min-height: 34px; padding: 0 13px; font-size: 13px; gap: 7px; }
.btn--lg, .btn-lg { min-height: 50px; padding: 0 24px; font-size: 15.5px; }
.btn--block, .btn-block { display: flex; width: 100%; }
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 14px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 50%;
  cursor: pointer;
  transition: color .15s var(--ease), background .15s var(--ease), border-color .15s var(--ease);
}
.icon-btn:hover { color: var(--ink); border-color: var(--line-2); background: var(--surface-2); text-decoration: none; }
.icon-btn--danger:hover { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, #fff); background: var(--bad-soft); }

/* pulsante flottante (es. nuova nota) */
.fab {
  position: fixed;
  right: 26px;
  bottom: 26px;
  z-index: 900;
  width: 58px;
  height: 58px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 22px;
  color: var(--accent-ink);
  background: var(--accent);
  box-shadow: 0 16px 34px -14px color-mix(in srgb, var(--accent) 80%, #000), 0 2px 6px rgba(28, 25, 23, .18);
  cursor: pointer;
  transition: transform .2s var(--ease);
}
.fab:hover { transform: translateY(-2px) rotate(90deg); }

/* ---------- Messaggi ---------- */
.alert, .message {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 13px 16px;
  margin: 0 0 18px;
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--ink-2);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: var(--radius);
}
.alert > i:first-child, .message > i:first-child { margin-top: 3px; }
.alert--ok, .alert-success, .message-success { color: var(--ok-ink); background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 28%, #fff); border-left-color: var(--ok); }
.alert--bad, .alert-danger, .alert-error, .message-error { color: var(--bad-ink); background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 26%, #fff); border-left-color: var(--bad); }
.alert--info, .alert-info, .message-info { color: var(--info-ink); background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 24%, #fff); border-left-color: var(--info); }
.alert--warn, .alert-warning, .message-warning { color: var(--warn-ink); background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 26%, #fff); border-left-color: var(--warn); }
.alert p:last-child { margin-bottom: 0; }

/* notifica temporanea in basso */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 3000;
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  font-size: 14.5px;
  font-weight: 500;
  color: #fff;
  background: var(--ink);
  border-radius: 999px;
  box-shadow: var(--shadow-l);
  transition: opacity .25s var(--ease), transform .25s var(--ease);
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast--ok i { color: #5eead4; }
.toast--bad { background: var(--bad-ink); }

/* ---------- Schede (tab) ---------- */
.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin: 0 0 20px;
  overflow-x: auto;
  scrollbar-width: none;
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.tabs::-webkit-scrollbar { display: none; }
.tab, .tab-link, .tab-button {
  flex: 1 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 16px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
  transition: color .15s var(--ease), background .15s var(--ease), box-shadow .15s var(--ease);
}
.tab:hover, .tab-link:hover, .tab-button:hover { color: var(--ink); text-decoration: none; }
.tab.is-active, .tab.active, .tab-link.active, .tab-button.active {
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow-s);
}
@media (max-width: 560px) {
  /* schede su schermi stretti: tutte visibili, testo su due righe se serve */
  .tabs { border-radius: 16px; }
  .tab, .tab-link, .tab-button {
    flex: 1 1 0;
    min-width: 0;
    padding: 6px 8px;
    border-radius: 12px;
    white-space: normal;
    text-align: center;
    line-height: 1.2;
    font-size: 13px;
  }
  .tab i, .tab-link i, .tab-button i { display: none; }
}
.tab-content, .tab-panel { display: none; }
.tab-content.active, .tab-panel.active { display: block; animation: app-rise .35s var(--ease) both; }

/* ---------- Tabelle ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
table.table th {
  padding: 11px 14px;
  text-align: left;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.table tr:last-child td { border-bottom: 0; }
table.table tbody tr:hover td { background: var(--surface-2); }

/* ---------- Badge ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.5;
  color: var(--ink-2);
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: 999px;
  white-space: nowrap;
}
.badge--accent { color: var(--accent); background: var(--accent-soft); border-color: var(--accent-line); }
.badge--ok { color: var(--ok-ink); background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 25%, #fff); }
.badge--bad { color: var(--bad-ink); background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 25%, #fff); }
.badge--warn { color: var(--warn-ink); background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 25%, #fff); }
.badge--info { color: var(--info-ink); background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 25%, #fff); }

/* ---------- Statistiche ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.stat {
  padding: 14px 14px 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.stat__value { font-family: var(--font-display); font-size: 26px; font-weight: 700; line-height: 1.1; color: var(--ink); font-variant-numeric: tabular-nums; }
.stat__label { margin-top: 4px; font-size: 12.5px; color: var(--muted); line-height: 1.35; }
.stat__label i { margin-right: 4px; opacity: .8; }

/* ---------- Selettori: colori, emoji, icone ---------- */
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch {
  position: relative;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 10px;
  border: 1px solid rgba(28, 25, 23, .12);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .22);
  cursor: pointer;
  transition: transform .15s var(--ease), box-shadow .15s var(--ease);
}
.swatch:hover { transform: translateY(-2px); }
.swatch.selected, .swatch.is-selected, .swatch[aria-checked="true"] {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink);
}
.swatch.selected::after, .swatch.is-selected::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 8px;
  height: 14px;
  border: solid #fff;
  border-width: 0 2.5px 2.5px 0;
  transform: translateY(-2px) rotate(45deg);
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .45));
}
.picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: 6px;
  max-height: 260px;
  padding: 10px;
  overflow-y: auto;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.picker-item {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  font-size: 22px;
  line-height: 1;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  transition: transform .12s var(--ease), border-color .12s var(--ease), box-shadow .12s var(--ease);
}
.picker-item img { width: 24px; height: 24px; object-fit: contain; }
.picker-item:hover { transform: translateY(-1px); border-color: var(--line-2); box-shadow: var(--shadow-s); }
.picker-item.selected, .picker-item.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 2px var(--accent-line);
}
.picker-label {
  grid-column: 1 / -1;
  margin: 6px 2px 0;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}

/* anteprima di un bottone / sezione */
.preview-box {
  display: grid;
  place-items: center;
  gap: 10px;
  padding: 26px 18px;
  background:
  linear-gradient(45deg, rgba(28, 25, 23, .025) 25%, transparent 25%, transparent 75%, rgba(28, 25, 23, .025) 75%),
  linear-gradient(45deg, rgba(28, 25, 23, .025) 25%, transparent 25%, transparent 75%, rgba(28, 25, 23, .025) 75%),
  var(--surface-2);
  background-size: 18px 18px;
  background-position: 0 0, 9px 9px;
  border: 1px dashed var(--line-2);
  border-radius: var(--radius);
}
.preview-box__label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- Finestra modale ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(28, 25, 23, .45);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.modal.is-open, .modal.show { display: flex; }
.modal__dialog, .modal-content {
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 40px);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow-l);
  animation: app-rise .25s var(--ease) both;
}
.modal__head { display: flex; align-items: center; gap: 10px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal__head h2, .modal__head h3 { margin: 0; font-size: 21px; flex: 1; }
.modal__body { padding: 22px; }
.modal__foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 22px 22px; }

/* ---------- Stato vuoto ---------- */
.empty {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 44px 20px;
  text-align: center;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px dashed var(--line-2);
  border-radius: var(--radius-l);
}
.empty i { font-size: 26px; color: var(--muted-2); margin-bottom: 4px; }
.empty h3 { margin: 0; color: var(--ink); }

/* ---------- Liste (elementi con azioni) ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.list-item + .list-item { margin-top: 8px; }
.list-item__main { flex: 1; min-width: 0; }
.list-item__title { font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item__meta { font-size: 12.5px; color: var(--muted); }
.list-item__actions { display: flex; gap: 6px; flex: none; }

/* ---------- Pagine pubbliche (accesso, invito, recupero password) ---------- */
body.app.app--auth {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  background-image:
  radial-gradient(900px 520px at 50% -20%, rgba(244, 84, 34, .16), transparent 62%),
  radial-gradient(700px 420px at 100% 110%, rgba(29, 78, 216, .07), transparent 60%);
}
.auth-shell {
  width: 100%;
  max-width: 1000px;
  min-height: 600px;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 26px;
  box-shadow: var(--shadow-l);
  overflow: hidden;
  animation: app-rise .5s var(--ease) both;
}
.auth-aside {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 40px 42px;
  color: #f4efe8;
  background:
  radial-gradient(520px 360px at 0% 0%, rgba(244, 84, 34, .38), transparent 70%),
  radial-gradient(420px 320px at 110% 105%, rgba(244, 84, 34, .20), transparent 70%),
  #1c1917;
  overflow: hidden;
}
.auth-aside::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .08;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 0.6 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}
.auth-aside__logo img { height: 27px; width: auto; display: block; }
.auth-aside__copy { margin-top: auto; position: relative; z-index: 1; }
.auth-aside h2 {
  margin: 0 0 12px;
  font-family: var(--font-display);
  font-size: clamp(28px, 3vw, 36px);
  font-weight: 700;
  line-height: 1.06;
  letter-spacing: -.025em;
  color: #fff;
}
.auth-aside h2 em { font-style: normal; color: var(--brand); }
.auth-aside p { margin: 0; max-width: 34ch; color: rgba(244, 239, 232, .72); font-size: 15px; }
/* mini anteprima stilizzata della homepage */
.auth-mock {
  position: relative;
  z-index: 1;
  margin-top: 30px;
  padding: 16px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .10);
  border-radius: 16px;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.auth-mock__label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 2px 0 10px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: rgba(244, 239, 232, .55);
}
.auth-mock__label::after { content: ""; flex: 1; height: 1px; background: rgba(255, 255, 255, .10); }
.auth-mock__row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.auth-mock__row + .auth-mock__label { margin-top: 14px; }
.auth-mock__btn {
  position: relative;
  height: 30px;
  border-radius: 8px;
  background: var(--c, #f45422);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .18);
  opacity: 0;
  animation: auth-pop .45s var(--ease) forwards;
  animation-delay: calc(var(--i, 0) * 55ms + 250ms);
}
.auth-mock__btn::before {
  content: "";
  position: absolute;
  left: 9px;
  top: 50%;
  width: 12px;
  height: 12px;
  margin-top: -6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, .85);
}
.auth-mock__btn::after {
  content: "";
  position: absolute;
  left: 27px;
  right: 12px;
  top: 50%;
  height: 5px;
  margin-top: -2.5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, .55);
}
@keyframes auth-pop { from { opacity: 0; transform: translateY(6px) scale(.96); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .auth-mock__btn { animation: none; opacity: 1; } }

.auth-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 46px 46px 38px;
}
.auth-panel__logo { display: none; margin-bottom: 26px; }
.auth-panel__logo img { height: 25px; width: auto; }
.auth-panel h1 { margin: 0 0 6px; font-size: 28px; }
.auth-lead { margin: 0 0 24px; color: var(--muted); font-size: 14.5px; }
.auth-divider { display: flex; align-items: center; gap: 12px; margin: 18px 0; font-size: 12.5px; color: var(--muted); }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.auth-foot { margin-top: 20px; font-size: 14px; color: var(--muted); }
.auth-note {
  margin-top: 26px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--muted);
}
.auth-note i { margin-right: 6px; color: var(--muted-2); }
.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  min-height: 48px;
  padding: 0 18px;
  font: inherit;
  font-weight: 600;
  font-size: 15px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: 999px;
  box-shadow: var(--shadow-s);
  transition: border-color .15s var(--ease), background .15s var(--ease), box-shadow .15s var(--ease);
}
.btn-google:hover { text-decoration: none; border-color: var(--muted-2); background: var(--surface-2); box-shadow: var(--shadow); }
.btn-google svg { width: 19px; height: 19px; flex: none; }
@media (max-width: 880px) {
  .auth-shell { grid-template-columns: 1fr; max-width: 460px; min-height: 0; }
  .auth-aside { display: none; }
  .auth-panel { padding: 34px 28px 28px; }
  .auth-panel__logo { display: block; }
}
@media (max-width: 420px) {
  body.app.app--auth { padding: 16px 10px; justify-content: flex-start; }
  .auth-panel { padding: 28px 20px 22px; }
}
/* scheda semplice centrata (pagine brevi: verifica email, avvisi) */
.auth-card {
  width: 100%;
  max-width: 460px;
  padding: 36px 32px 30px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow-l);
  animation: app-rise .5s var(--ease) both;
}
.auth-card .auth-logo { display: flex; justify-content: center; margin-bottom: 22px; }
.auth-card .auth-logo img { height: 25px; width: auto; }
.password-field { position: relative; }
.password-field input { padding-right: 92px !important; }
.password-toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  height: 32px;
  padding: 0 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface-3);
  border: 0;
  border-radius: 999px;
  cursor: pointer;
}
.password-toggle:hover { color: var(--ink); }
.auth-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 20px; font-size: 14px; }

/* ---------- Piè di pagina ---------- */
.app-foot {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 20px 40px;
  text-align: center;
  font-size: 12.5px;
  color: var(--muted);
}
.app-foot a { color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
