/* ══ RESET & TOKENS ══════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:      #f5f7fa;
  --surface: #ffffff;
  --border:  #e8ecf0;
  --text:    #1a1f2e;
  --muted:   #64748b;
  --faint:   #f0f3f7;

  --primary:    #3b82f6;
  --primary-dk: #2563eb;
  --accent:     #1d4ed8;   /* alias usato da profilo, toggle, badge */

  --red:    #ef4444;   --red-bg:    #fef2f2;   --red-border:    #fca5a5;
  --orange: #f97316;   --orange-bg: #fff7ed;   --orange-border: #fdba74;
  --green:  #22c55e;   --green-bg:  #f0fdf4;   --green-border:  #86efac;

  --radius:  14px;
  --r-sm:    9px;
  --shadow:  0 1px 4px rgba(0,0,0,.07);
  --shadow-md: 0 4px 16px rgba(0,0,0,.1);
  --panel-w: 500px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ══ HEADER ══════════════════════════════════════════════════════════════════ */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 24px 14px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 20px; flex-wrap: wrap;
  position: sticky; top: 0; z-index: 10;
  box-shadow: var(--shadow);
}

/* hdr-compact-info — non usato in questa versione, nascosto */
.hdr-compact-info { display: none !important; }

.header-brand h1 {
  font-size: 1.6rem; font-weight: 800; letter-spacing: -.6px; line-height: 1;
  color: var(--text);
}
.brand-dot { color: var(--primary); }
.header-sub {
  font-size: .75rem; color: var(--muted); margin-top: 3px;
  font-style: italic;
}

.header-stats { display: flex; gap: 6px; flex-wrap: wrap; align-items: stretch; }

/* Base hstat */
.hstat {
  display: flex; flex-direction: column; align-items: flex-end;
  background: var(--faint); border: 1px solid var(--border);
  border-radius: 10px; padding: 7px 14px; min-width: 88px;
  transition: background .15s, box-shadow .15s;
  cursor: pointer; user-select: none;
}
.hstat:hover { background: var(--surface); box-shadow: var(--shadow-md); }

.hstat-n {
  font-size: 1.2rem; font-weight: 800; color: var(--text); line-height: 1;
}
.hstat-l {
  font-size: .6rem; color: var(--muted); text-align: right;
  text-transform: uppercase; letter-spacing: .4px; margin-top: 3px; line-height: 1.3;
}

/* 1. Scadenze — massima priorità */
.hstat-scad {
  background: var(--surface); border-color: var(--border);
  min-width: 130px;
}
.hstat-scad .hstat-n { font-size: 1rem; font-weight: 700; }
.hstat-scad .hstat-l { font-size: .68rem; letter-spacing: 0; text-transform: none; }
/* Con scadenze urgenti */
.hstat-scad.urgente {
  background: var(--red-bg); border-color: var(--red-border);
}
.hstat-scad.urgente .hstat-n { color: var(--red); font-size: 1.3rem; }
.hstat-scad.urgente .hstat-l { color: var(--red); opacity: .8; }

/* 2. Prossima — testo compatto con nome inline */
.hstat-pross {
  min-width: 200px; max-width: 320px; align-items: flex-start;
}
.hstat-pross .hstat-n {
  font-size: .76rem; font-weight: 700; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 100%;
}
.hstat-pross .hstat-l {
  text-align: left; font-size: .59rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 100%;
}

/* 3+4. Dimmed — priorità bassa */
.hstat-dim {
  opacity: .65;
}
.hstat-dim:hover { opacity: 1; }

/* filtro rinnovi attivo */
.hstat-active {
  opacity: 1 !important;
  background: #eff6ff !important;
  border-color: #bfdbfe !important;
}
.hstat-active .hstat-n { color: var(--primary) !important; }

/* ══ SCADENZA STRIP ══════════════════════════════════════════════════════════ */
.scad-strip {
  background: var(--red-bg); border-bottom: 1px solid var(--red-border);
  padding: 4px 24px; display: flex; align-items: center; gap: 10px;
  overflow-x: auto; scrollbar-width: none;
}
.scad-strip::-webkit-scrollbar { display: none; }

.scad-strip-label {
  font-size: .73rem; font-weight: 700; color: var(--red);
  white-space: nowrap; flex-shrink: 0;
}
.scad-strip-items { display: flex; gap: 6px; flex-wrap: nowrap; align-items: center; }

.scad-chip {
  display: flex; align-items: center; gap: 7px;
  background: var(--surface); border: 1.5px solid var(--red-border);
  border-radius: 7px; padding: 3px 9px; cursor: pointer;
  transition: box-shadow .12s; flex-shrink: 0;
}
.scad-chip:hover { box-shadow: var(--shadow-md); }
.scad-chip.orange { border-color: var(--orange-border); background: var(--orange-bg); }
.scad-chip.green  { border-color: var(--green-border);  background: var(--green-bg); }
.scad-chip-name { font-size: .78rem; font-weight: 600; color: var(--text); white-space: nowrap; }
.scad-chip-days { font-size: .7rem; font-weight: 600; white-space: nowrap; }
.scad-chip.red    .scad-chip-days { color: var(--red); }
.scad-chip.orange .scad-chip-days { color: var(--orange); }
.scad-chip.green  .scad-chip-days { color: #16a34a; }
.scad-chip-more {
  font-size: .72rem; font-weight: 600; color: var(--muted);
  white-space: nowrap; padding: 4px 8px;
  background: var(--faint); border-radius: 8px; border: 1px solid var(--border);
}

/* ══ OGGI RICORDA ════════════════════════════════════════════════════════════ */
.oggi-ricorda {
  margin: 8px 24px 2px;
  padding: 9px 14px 7px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
}
.oggi-ricorda.hidden { display: none; }
.oggi-hdr {
  font-size: .68rem; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .07em;
  margin-bottom: 6px;
}
.oggi-item {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 0; cursor: pointer;
  background: none; border: none; border-top: 1px solid var(--border);
  font-family: inherit; width: 100%; text-align: left;
  -webkit-tap-highlight-color: transparent;
}
.oggi-item:first-child { border-top: none; padding-top: 0; }
.oggi-item:active { opacity: .6; }
.oggi-nome { font-size: .86rem; font-weight: 600; color: var(--text); flex: 1; }
.oggi-meta { font-size: .74rem; color: var(--muted); white-space: nowrap; }
.oggi-more {
  font-size: .74rem; color: var(--muted);
  padding-top: 5px; margin-top: 2px;
  border-top: 1px solid var(--border); text-align: center;
}

/* ══ STICKY BAR — search + tabs, fissa sotto l'header ═══════════════════ */
.sticky-bar {
  position: sticky;
  top: var(--header-h, 60px);
  z-index: 9;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 6px rgba(0,0,0,.04);
}

/* ══ TOOLBAR ════════════════════════════════════════════════════════════════ */
.toolbar {
  display: flex; align-items: center;
  padding: 10px 24px 6px; gap: 10px;
}
.toolbar .search-wrap { flex: 1; }

/* ── View Tabs (Priorità / Più avanti) — switch minimalisti ────────────── */
.view-tab-bar {
  display: flex; gap: 4px;
  padding: 0 24px 10px;
}
.view-tab {
  padding: 5px 16px; border-radius: 20px;
  background: transparent; color: var(--muted);
  font-size: .79rem; font-weight: 500; cursor: pointer;
  font-family: var(--font); transition: all .13s;
  border: 1.5px solid transparent;  /* ghost di default */
}
.view-tab:hover { color: var(--primary); border-color: #bfdbfe; }
.view-tab.active {
  background: var(--primary); border-color: var(--primary);
  color: #fff; font-weight: 700;
  box-shadow: 0 2px 8px rgba(59,130,246,.25);
}

/* ── Micro-label di gruppo — guida senza dominare ──────────────────────── */
.view-group-label {
  grid-column: 1/-1;
  font-size: .68rem; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: #78879a;
  padding: 20px 0 7px; opacity: 1;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2px;
}
.view-group-label:first-child { padding-top: 4px; }

/* ── Feedback positivo coda (pochi elementi) — rassicurante, non protagonista */
.priority-ok-note {
  grid-column: 1/-1; text-align: center;
  padding: 14px 0 4px; font-size: .71rem; color: #6b9070;
  font-weight: 500; opacity: .72;
}

/* Empty state "ok" */
.empty-state.ok strong { color: #16a34a; }


.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.search-icon {
  position: absolute;
  left: 10px;
  font-size: .78rem;
  pointer-events: none;
  line-height: 1;
  opacity: .55;
}
#searchInput {
  padding: 6px 12px 6px 28px; border: 1.5px solid var(--border); border-radius: 20px;
  font-size: .8rem; outline: none;
  width: clamp(200px, 22vw, 300px);
  transition: border-color .15s; background: var(--surface);
  color: var(--text);
}
#searchInput:focus { border-color: var(--primary); }

/* ══ GRID ════════════════════════════════════════════════════════════════════ */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 14px; padding: 0 24px 100px;
  transition: margin-right .3s ease;
}
.grid.panel-open { margin-right: calc(var(--panel-w) + 16px); }

.empty-state {
  grid-column: 1/-1; text-align: center;
  padding: 70px 0; color: var(--muted);
}
.empty-state strong {
  display: block; font-size: 1.05rem; color: var(--text); margin-bottom: 6px;
}
.empty-cta {
  display: inline-block; margin-top: 14px;
  background: var(--primary); color: #fff;
  border: none; padding: 10px 22px; border-radius: 20px;
  font-size: .88rem; font-weight: 600; cursor: pointer;
}

/* ══ CARD ════════════════════════════════════════════════════════════════════ */
.card {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 13px 14px 10px;
  box-shadow: var(--shadow); cursor: pointer;
  transition: box-shadow .15s, transform .12s;
  display: flex; flex-direction: column; gap: 6px;
  position: relative;
}
.card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.card.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}

/* Urgency left border */
.card.urg-red    { border-left: 4px solid #dc2626; background: #fffafa; }  /* più saturo + micro tint */
.card.urg-orange { border-left: 3px solid var(--orange); }
.card.urg-green  { border-left: 3px solid #86efac; }
.card.urg-none   { border-left: 3px solid transparent; }

/* Nome — titolo principale, gerarchia alta */
.card-nome {
  font-size: 1.04rem; font-weight: 800; line-height: 1.25;
  color: var(--text);
}

/* Urgency inline text — gerarchia secondaria */
.card-scad {
  font-size: .69rem; font-weight: 500; line-height: 1.2;
}
.card-scad.red    { color: var(--red); }
.card-scad.orange { color: var(--orange); }
.card-scad.green  { color: var(--muted); font-weight: 500; }

/* Scaduto — evidenziato con sfondo e bordo */
.card-scad.red.scaduto {
  background: #fee2e2; border-radius: 5px; padding: 2px 7px;
  border: 1px solid var(--red-border);
  font-weight: 700;
}

/* Urgency badge (usato nel pannello dettagli) */
.urg-badge {
  font-size: .72rem; font-weight: 700; padding: 2px 9px;
  border-radius: 20px; white-space: nowrap;
}
.urg-badge.red    { background: var(--red-bg);    color: var(--red);    border: 1px solid var(--red-border); }
.urg-badge.orange { background: var(--orange-bg); color: var(--orange); border: 1px solid var(--orange-border); }
.urg-badge.green  { background: var(--green-bg);  color: var(--green);  border: 1px solid var(--green-border); }
.urg-badge.grey   {
  background: transparent; color: var(--muted); border: none;
  font-size: .65rem; font-weight: 400; padding: 0; opacity: .6;
}
/* Stato scaduto nel badge dettaglio panel */
.urg-badge.red.scaduto {
  background: var(--red); color: #fff; border-color: var(--red);
  font-weight: 800; letter-spacing: .2px;
}

/* Costo — prominente, ben separato dallo stato */
.card-costo {
  font-size: 1.0rem; color: var(--muted); font-weight: 600;
  margin-top: 7px;
}
.card-costo.card-costo-expense { color: #dc2626; font-size: 1.05rem; font-weight: 700; }
.card-costo.card-costo-income  { color: #15803d; font-size: 1.05rem; font-weight: 700; }

/* Rinnovo */
.card-rinnovo {
  font-size: .76rem; color: var(--muted);
}
.card-rinnovo.auto { color: var(--green); }
.card-rinnovo.man  { color: var(--muted); }

/* Social bar (like + share) */
.card-social {
  display: flex; gap: 6px; justify-content: flex-end;
  position: absolute; top: 10px; right: 10px;
}
.card-heart, .card-share-btn {
  background: none; border: none; cursor: pointer;
  font-size: 1.1rem; line-height: 1; padding: 3px 5px;
  border-radius: 6px; transition: transform .15s, background .12s;
  font-family: inherit;
}
.card-heart:hover { background: var(--faint); transform: scale(1.15); }

/* "Piace a te" — stile Instagram */
.card-piace {
  font-size: .76rem; font-weight: 500; color: var(--text);
  margin-top: 1px; line-height: 1.4;
}
.card-piace strong { font-weight: 700; }
.card-piace-altri { font-weight: 500; color: var(--muted); }

/* Bottone Condividi — ora integrato nel card-quick come .share-q */
.card-heart.liked { animation: none; }

/* Animazione pop al click */
@keyframes heart-pop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.45); }
  70%  { transform: scale(0.9); }
  100% { transform: scale(1); }
}
.heart-pop { animation: heart-pop .38s ease; }

/* ── Highlight card da "Prossima" — pulse + glow + fade ─────────────────── */
@keyframes card-highlight-pulse {
  0%   { transform: scale(1);     background: var(--surface);
         box-shadow: 0 0 0 0   rgba(59,130,246,.0); }
  8%   { transform: scale(1.018); background: #eff6ff;
         box-shadow: 0 0 0 3px rgba(59,130,246,.6), 0 6px 20px rgba(59,130,246,.18); }
  22%  { transform: scale(1);     background: #eff6ff;
         box-shadow: 0 0 0 2px rgba(59,130,246,.45), 0 4px 14px rgba(59,130,246,.12); }
  80%  { background: #f0f7ff;
         box-shadow: 0 0 0 1.5px rgba(59,130,246,.25); }
  100% { transform: scale(1);     background: var(--surface);
         box-shadow: 0 0 0 0   rgba(59,130,246,.0); }
}
.card-highlight {
  animation: card-highlight-pulse 2.5s cubic-bezier(.4,0,.2,1) forwards;
  position: relative; z-index: 2;  /* sale leggermente sopra le card vicine */
}

/* Animazione "Segna come fatto" — bounce verde + fade */
@keyframes fatto-flash {
  0%   { background: var(--surface); transform: scale(1); }
  18%  { background: #dcfce7; transform: scale(1.015); }
  45%  { background: #bbf7d0; transform: scale(1.008); opacity: 1; }
  100% { background: #dcfce7; opacity: 0; transform: scale(.96); }
}
.fatto-flash {
  animation: fatto-flash .48s cubic-bezier(.4,0,.2,1) forwards;
  pointer-events: none;
}

/* Quick actions — distanziate, tap friendly */
.card-quick {
  display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
  margin-top: 4px; padding-top: 7px;
  border-top: 1px solid var(--faint);
}
.card-quick-link {
  font-size: .7rem; background: none; border: none;
  cursor: pointer; padding: 3px 9px; font-family: inherit;
  font-weight: 500; color: var(--muted);
  transition: color .12s; border-radius: 4px;
}
.card-quick-link:hover { color: var(--text); background: var(--faint); }
.card-quick-link.add-scad {
  color: var(--primary); font-weight: 600;
  padding: 2px 7px; border-radius: 6px;
  background: #eff6ff; border: 1px solid #bfdbfe;
}
.card-quick-link.add-scad:hover { background: #dbeafe; }
/* Fatto — pill verde, visivamente dominante tra le azioni */
.card-quick-link.fatto {
  color: #15803d; font-weight: 700;
  background: #f0fdf4; border: 1px solid #bbf7d0;
  padding: 3px 11px; border-radius: 6px;
}
.card-quick-link.fatto:hover { background: #dcfce7; color: #166534; }
.card-quick-link.share-q { color: #94a3b8; font-size: .67rem; }
.card-quick-link.share-q:hover { color: var(--muted); }
.card-quick-sep { color: var(--border); font-size: .6rem; padding: 0 1px; }

/* Grid group separator */
.grid-separator {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 10px;
  padding: 4px 0; margin-top: 6px;
}
.grid-separator-line {
  flex: 1; height: 1px; background: var(--border);
}
.grid-separator-label {
  font-size: .7rem; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .5px; white-space: nowrap;
}

/* ══ AVANTI GROUPS — collapsible sections ═══════════════════════════════════ */
.avanti-group {
  grid-column: 1/-1;
  margin-top: 32px;       /* respiro generoso tra sezioni */
  margin-bottom: 0;
}
.avanti-group:first-child { margin-top: 8px; }

/* Header del gruppo — sticky + separatore visivo chiaro */
.avanti-hdr {
  display: flex; align-items: center; gap: 8px;
  width: 100%; background: var(--bg); border: none; cursor: pointer;
  padding: 9px 2px 9px; font-family: var(--font); text-align: left;
  border-bottom: 2px solid var(--border);
  border-radius: 0;
  position: sticky; top: var(--sticky-top, 120px); z-index: 4;
  transition: background .12s, box-shadow .15s;
}
.avanti-hdr:hover { background: #edf1f6; }
.avanti-hdr.is-stuck { box-shadow: 0 3px 10px rgba(0,0,0,.06); }

@keyframes avanti-lbl-in {
  from { opacity: 0; transform: translateX(-5px); }
  to   { opacity: 1; transform: translateX(0); }
}
.avanti-lbl {
  font-size: .79rem; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: #475569; flex: 1;
  animation: avanti-lbl-in .22s ease both;
}
.avanti-cnt {
  font-size: .67rem; font-weight: 600;
  background: var(--faint); color: var(--muted);
  padding: 2px 8px; border-radius: 10px;
  border: 1px solid var(--border);
}
.avanti-arr {
  font-size: 1rem; color: var(--muted); opacity: .55;
  font-weight: 300; min-width: 14px; text-align: center;
  transition: color .12s;
}
.avanti-hdr:hover .avanti-arr { opacity: .9; color: var(--primary); }

/* Body del gruppo — collapsible */
.avanti-bdy {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 7px;
  padding: 18px 0 6px;   /* respiro tra header e prima card */
}
.avanti-bdy.collapsed { display: none; }

/* Suggerimento smart in fondo */
.avanti-suggestion {
  grid-column: 1/-1; text-align: center;
  margin-top: 20px; padding: 12px 20px;
  font-size: .77rem; color: var(--muted); line-height: 1.5;
  background: var(--faint); border-radius: 10px;
  border: 1px solid var(--border);
}
.avanti-suggestion strong { color: var(--text); }

/* ══ FAB ════════════════════════════════════════════════════════════════════ */
.fab-wrap {
  position: fixed; bottom: 80px; right: 28px; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  transition: transform .28s cubic-bezier(.4,0,.2,1), opacity .22s;
}
.fab-wrap.fab-hidden {
  transform: translateY(90px);
  opacity: 0;
  pointer-events: none;
}
.fab-tooltip {
  background: var(--text); color: #fff;
  font-size: .72rem; font-weight: 600; padding: 5px 10px;
  border-radius: 8px; white-space: nowrap;
  opacity: 0; pointer-events: none;
  transition: opacity .18s; transform: translateX(0);
}
.fab-wrap:hover .fab-tooltip { opacity: 1; }

.fab {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--primary); color: #fff; font-size: 1.8rem; line-height: 1;
  border: none; cursor: pointer; flex-shrink: 0;
  box-shadow: 0 4px 24px rgba(59,130,246,.20), 0 1px 6px rgba(0,0,0,.07);
  transition: background .15s, transform .12s;
}
.fab:hover { background: var(--primary-dk); transform: scale(1.07); }

/* ══ DETAIL PANEL ═══════════════════════════════════════════════════════════ */
.detail-overlay {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.22); z-index: 40; backdrop-filter: blur(1px);
}
.detail-panel {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: var(--panel-w); max-width: 100vw;
  background: var(--surface); border-left: 1px solid var(--border);
  box-shadow: -6px 0 30px rgba(0,0,0,.1);
  z-index: 50; display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform .3s cubic-bezier(.4,0,.2,1);
}
.detail-panel.open { transform: translateX(0); }

.dp-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 10px; padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.dp-title-area { flex: 1; min-width: 0; }
.dp-title-area h2 { font-size: 1.15rem; font-weight: 700; word-break: break-word; }
.dp-urgency { font-size: .78rem; color: var(--muted); margin-top: 3px; display: block; }
.dp-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.btn-text-edit {
  font-size: .82rem; font-weight: 600; color: var(--primary);
  background: none; border: 1.5px solid #bfdbfe;
  border-radius: 8px; padding: 5px 12px; cursor: pointer;
}
.btn-text-edit:hover { background: #eff6ff; }
.dp-close {
  background: none; border: none; font-size: 1.4rem; color: var(--muted);
  cursor: pointer; padding: 2px 6px; border-radius: 4px; line-height: 1;
}
.dp-close:hover { background: var(--faint); color: var(--text); }

.dp-tabs {
  display: flex; border-bottom: 1px solid var(--border);
  flex-shrink: 0; padding: 0 20px;
}
.dp-tab {
  padding: 9px 14px; border: none; background: none;
  font-size: .83rem; font-weight: 500; color: var(--muted);
  cursor: pointer; border-bottom: 2px solid transparent;
  margin-bottom: -1px; transition: all .13s;
  white-space: nowrap; display: flex; align-items: center; gap: 5px;
}
.dp-tab:hover { color: var(--text); }
.dp-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.dp-tab-secondary {
  font-size: .75rem; opacity: .55;
}
.dp-tab-secondary:hover { opacity: 1; }
.dp-tab-secondary.active { opacity: 1; }

.doc-count {
  background: var(--primary); color: #fff; font-size: .63rem;
  font-weight: 700; border-radius: 10px; padding: 1px 6px;
}

.dp-body {
  flex: 1; overflow-y: auto; padding: 14px 18px;
  display: flex; flex-direction: column; gap: 10px;
}

/* ── Panel sintesi: blocchi ───────────────────────────────────────────────── */

/* Scadenza */
.dp-scad {
  font-size: 1rem; font-weight: 700; padding: 10px 12px;
  border-radius: 10px; line-height: 1.3;
}
.dp-scad-red    { background: var(--red-bg);    color: var(--red);    border: 1px solid var(--red-border); }
.dp-scad-orange { background: var(--orange-bg); color: var(--orange); border: 1px solid var(--orange-border); }
.dp-scad-green  { background: var(--green-bg);  color: #16a34a;       border: 1px solid var(--green-border); }

/* box "nessuna scadenza" — intera riga cliccabile */
.dp-scad-missing {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--faint); border: 1.5px dashed var(--border);
  border-radius: 8px; padding: 7px 12px;
  font-size: .83rem; color: var(--muted);
  cursor: pointer; width: 100%; text-align: left; font-family: inherit;
  transition: border-color .15s, background .15s;
}
.dp-scad-missing:hover {
  border-color: var(--primary); background: #eff6ff;
}
.dp-scad-missing-label { color: var(--muted); }
.dp-scad-missing-cta {
  font-size: .78rem; font-weight: 700; color: var(--primary);
  white-space: nowrap;
}

/* Importo */
.dp-amount {
  font-size: 1.35rem; font-weight: 800; color: var(--text);
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
}
.dp-sub {
  font-size: .8rem; font-weight: 500; color: var(--muted);
}

/* Importo + Rinnovo raggruppati */
.dp-main-info {
  display: flex; flex-direction: column; gap: 4px;
}

/* Rinnovo */
.dp-rinnovo {
  font-size: .83rem; font-weight: 500;
}
.dp-rinnovo.auto { color: var(--green); }
.dp-rinnovo.man  {
  color: #92400e;
  background: #fffbeb; border: 1px solid #fde68a;
  border-radius: 6px; padding: 3px 8px;
  display: inline-block;
}

/* Nota — info, non commento */
.dp-note {
  font-size: .8rem; color: var(--muted); font-style: normal;
  padding: 6px 9px; background: #fafafa;
  border-radius: 7px; border-left: 2px solid var(--border);
}

/* ── CTA primaria — "✓ Segna come fatto" full-width ────────────────────── */
.dp-fatto-primary {
  display: block; width: 100%;
  padding: 13px 0; border-radius: 10px;
  background: #16a34a; color: #fff;
  font-size: .95rem; font-weight: 700; font-family: inherit;
  border: none; cursor: pointer; text-align: center;
  transition: background .13s, transform .1s;
  margin-top: 4px;
}
.dp-fatto-primary:hover  { background: #15803d; }
.dp-fatto-primary:active { transform: scale(.98); }

/* ── Azioni secondarie — Modifica · Condividi ───────────────────────────── */
.dp-secondary-row {
  display: flex; align-items: center; justify-content: center;
  gap: 4px; padding-top: 6px;
}
.dp-sec-sep { color: var(--border); font-size: .65rem; }

/* Testo azione secondaria */
.dp-cta-txt {
  background: none; border: none; cursor: pointer; font-family: inherit;
  font-size: .78rem; color: var(--muted); padding: 4px 8px;
  border-radius: 5px; transition: color .12s;
}
.dp-cta-txt:hover { color: var(--text); background: var(--faint); }

/* Dettagli avanzati collapsible */
.dp-advanced {
  border: 1px solid var(--border); border-radius: 9px; overflow: hidden;
}
.dp-advanced-toggle {
  list-style: none; display: flex; align-items: center; gap: 6px;
  padding: 9px 12px; cursor: pointer; font-size: .78rem;
  font-weight: 600; color: var(--muted); background: var(--faint);
  user-select: none;
}
.dp-advanced-toggle::-webkit-details-marker { display: none; }
.dp-advanced-toggle::before { content: "›"; font-size: 1rem; transition: transform .2s; }
.dp-advanced[open] .dp-advanced-toggle::before { transform: rotate(90deg); }
.dp-advanced .dp-rows { padding: 4px 0 4px; }

/* Rows dentro i dettagli avanzati */
.dp-rows { display: flex; flex-direction: column; }
.dp-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 7px 12px; border-bottom: 1px solid var(--faint); font-size: .84rem;
}
.dp-row:last-child { border-bottom: none; }
.dp-label { color: var(--muted); flex-shrink: 0; }
.dp-value { font-weight: 500; text-align: right; max-width: 65%; }

/* Elimina — sinistra, rosso leggero */
.dp-delete-row {
  margin-top: 18px; display: flex; justify-content: flex-start;
  padding-top: 12px; border-top: 1px solid var(--faint);
}
.dp-delete-row .btn-danger {
  background: none; border: none;
  color: #dc2626; font-size: .74rem; font-weight: 500;
  cursor: pointer; padding: 4px 6px; border-radius: 5px; font-family: inherit;
  opacity: .7; transition: opacity .12s, background .12s;
}
.dp-delete-row .btn-danger:hover { opacity: 1; background: var(--red-bg); }
.btn-sm { padding: 5px 14px; font-size: .78rem; }

/* ── Tab nav nascosta (servizi — singola tab) ────────────────────────────── */
.dp-tabs-hidden { display: none !important; }

/* ── Info strip compatta (scadenza + importo sotto l'header) ─────────────── */
.dp-info-strip {
  display: flex; gap: 10px; flex-wrap: wrap;
  padding: 8px 0 4px;
  border-bottom: 1px solid var(--faint);
  margin-bottom: 4px;
}
.dp-info-item {
  display: flex; flex-direction: column; gap: 1px;
  min-width: 80px;
}
.dp-info-lbl {
  font-size: .62rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .4px; color: var(--muted); opacity: .7;
}
.dp-info-val {
  font-size: .88rem; font-weight: 600; color: var(--text);
}
.dp-val-green { color: #166534; }
.dp-val-red   { color: #b91c1c; }

/* ── Dettagli avanzati: hover feedback più evidente ─────────────────────── */
.dp-advanced-toggle:hover {
  background: var(--border); color: var(--text);
}

/* ── Toast notifica ──────────────────────────────────────────────────────── */
.app-toast {
  position: fixed; bottom: 80px; left: 50%;
  transform: translateX(-50%) translateY(6px);
  background: #1e293b; color: #fff;
  font-size: .84rem; font-weight: 600;
  padding: 9px 20px; border-radius: 22px;
  box-shadow: 0 4px 16px rgba(0,0,0,.18);
  pointer-events: none; z-index: 9999;
  opacity: 0; transition: opacity .2s, transform .2s;
  white-space: nowrap;
}
.app-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Bottone Condividi nel pannello ──────────────────────────────────────── */
.btn-text-share {
  font-size: .82rem; font-weight: 600; color: var(--green);
  background: var(--green-bg); border: 1.5px solid var(--green-border);
  border-radius: 8px; padding: 5px 12px; cursor: pointer;
  transition: background .12s;
}
.btn-text-share:hover { background: #dcfce7; }

/* ── Share modal ─────────────────────────────────────────────────────────── */
.share-sub {
  font-size: .85rem; color: var(--muted); margin: -4px 0 14px;
}
.share-options {
  display: flex; flex-direction: column; gap: 10px;
}
.share-opt {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px; border-radius: 10px;
  border: 1.5px solid var(--border); background: var(--surface);
  cursor: pointer; font-size: .9rem; font-weight: 500;
  transition: border-color .12s, background .12s; text-align: left;
  font-family: inherit;
}
.share-opt:hover { border-color: var(--primary); background: #eff6ff; }
.share-opt-icon { font-size: 1.3rem; }

.share-success {
  text-align: center; padding: 10px 0;
}
.share-success-icon { font-size: 2.2rem; margin-bottom: 8px; }
.share-success p { font-size: .95rem; font-weight: 600; margin-bottom: 14px; }
.share-via {
  display: flex; gap: 10px; justify-content: center; flex-wrap: wrap;
}
.btn-whatsapp {
  background: #25d366; color: #fff; border: none;
  padding: 8px 18px; border-radius: 8px; font-size: .85rem;
  font-weight: 600; cursor: pointer; font-family: inherit;
}
.btn-whatsapp:hover { background: #1da851; }
.btn-sms {
  background: var(--faint); color: var(--text); border: 1.5px solid var(--border);
  padding: 8px 18px; border-radius: 8px; font-size: .85rem;
  font-weight: 600; cursor: pointer; font-family: inherit;
}
.btn-sms:hover { background: var(--border); }

/* ── Sezione "Condiviso con" nel pannello ───────────────────────────────── */
.dp-share-section {
  border: 1px solid var(--border); border-radius: 9px;
  overflow: hidden; margin-bottom: 4px;
}
.dp-share-header {
  font-size: .72rem; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .5px;
  padding: 7px 12px; background: var(--faint);
  border-bottom: 1px solid var(--border);
}
.share-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; border-bottom: 1px solid var(--faint); font-size: .84rem;
}
.share-row:last-child { border-bottom: none; }
.share-row-info { flex: 1; }
.share-remove {
  background: none; border: none; cursor: pointer; color: var(--muted);
  font-size: .8rem; padding: 2px 5px; border-radius: 4px;
  transition: color .12s; font-family: inherit;
}
.share-remove:hover { color: var(--red); background: var(--red-bg); }

/* ── KPI ──────────────────────────────────────────────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kpi-card {
  background: var(--faint); border: 1px solid var(--border);
  border-radius: 10px; padding: 11px 13px;
}
.kpi-val { font-size: 1.2rem; font-weight: 800; color: var(--text); }
.kpi-lbl { font-size: .68rem; color: var(--muted); margin-top: 3px;
           text-transform: uppercase; letter-spacing: .4px; }
.kpi-card.accent .kpi-val { color: var(--primary-dk); }
.kpi-card.green  .kpi-val { color: var(--green); }
.kpi-card.orange .kpi-val { color: var(--orange); }
.kpi-card.red    .kpi-val { color: var(--red); }

/* ── Progress bar ─────────────────────────────────────────────────────────── */
.progress-wrap { display: flex; flex-direction: column; gap: 6px; }
.progress-labels { display: flex; justify-content: space-between; font-size: .73rem; color: var(--muted); }
.progress-bar { height: 8px; background: var(--border); border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 99px; transition: width .6s; }
.progress-fill.ok   { background: var(--green); }
.progress-fill.warn { background: var(--orange); }
.progress-fill.crit { background: var(--red); }
.progress-pct { font-size: .76rem; font-weight: 700; text-align: right; }

/* ── Charts ───────────────────────────────────────────────────────────────── */
.chart-block { display: flex; flex-direction: column; gap: 6px; }
.chart-block h4 { font-size: .68rem; font-weight: 700; text-transform: uppercase;
                  letter-spacing: .5px; color: var(--muted); }
.chart-wrap { position: relative; height: 165px; }
.no-data {
  background: var(--faint); border: 1.5px dashed var(--border);
  border-radius: 10px; padding: 18px; text-align: center;
  color: var(--muted); font-size: .83rem; line-height: 1.5;
}
.no-data strong { display: block; font-size: .95rem; margin-bottom: 3px; color: var(--text); }

/* ── Spese ────────────────────────────────────────────────────────────────── */
.spesa-form { background: var(--faint); border: 1px solid var(--border); border-radius: 10px; padding: 14px; }
.spesa-form-title { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin-bottom: 10px; }
.spesa-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 9px 12px;
}
.spesa-item:hover { border-color: var(--orange); }
.spesa-amt { font-size: .95rem; font-weight: 700; color: var(--orange); min-width: 64px; flex-shrink: 0; }
.spesa-info { flex: 1; min-width: 0; }
.spesa-desc { font-size: .83rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spesa-meta { font-size: .7rem; color: var(--muted); margin-top: 2px; }
.spesa-cat {
  font-size: .66rem; font-weight: 600; padding: 2px 7px; border-radius: 10px;
  background: var(--orange-bg); color: #92400e; border: 1px solid var(--orange-border);
  flex-shrink: 0; text-transform: capitalize;
}
.spese-total {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--faint); border: 1px solid var(--border);
  border-radius: 8px; padding: 9px 12px; font-size: .84rem;
}
.spese-total strong { font-size: .95rem; color: var(--orange); }
.spese-empty { text-align: center; color: var(--muted); font-size: .83rem; padding: 14px 0; }

/* ── Documenti ────────────────────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border); border-radius: 10px;
  padding: 22px; text-align: center; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.upload-zone:hover, .upload-zone.dragover { border-color: var(--primary); background: #eff6ff; }
.upload-icon { font-size: 1.8rem; margin-bottom: 6px; }
.upload-zone p { font-size: .83rem; color: var(--muted); }
.upload-link { color: var(--primary); cursor: pointer; font-weight: 600; }
.upload-hint { font-size: .72rem; margin-top: 3px; }
.upload-preview {
  background: var(--faint); border: 1px solid var(--border);
  border-radius: 8px; padding: 9px 12px;
  display: flex; align-items: center; gap: 10px; font-size: .83rem;
}
.upload-preview .file-name { font-weight: 500; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-preview .file-size { color: var(--muted); flex-shrink: 0; }
.doc-list { display: flex; flex-direction: column; gap: 7px; margin-top: 4px; }
.doc-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--faint); border: 1px solid var(--border);
  border-radius: 8px; padding: 9px 12px; transition: border-color .12s;
}
.doc-item:hover { border-color: var(--primary); }
.doc-icon { font-size: 1.3rem; flex-shrink: 0; }
.doc-info { flex: 1; min-width: 0; }
.doc-name { font-size: .83rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-meta { font-size: .7rem; color: var(--muted); margin-top: 2px; }
.doc-tipo {
  font-size: .65rem; font-weight: 600; padding: 2px 7px; border-radius: 10px;
  background: var(--border); color: var(--muted); text-transform: capitalize; flex-shrink: 0;
}
.doc-actions { display: flex; gap: 5px; }
.doc-btn {
  padding: 3px 9px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); font-size: .72rem; font-weight: 500;
  cursor: pointer; color: var(--muted); text-decoration: none;
  display: inline-flex; align-items: center; transition: all .12s;
}
.doc-btn:hover { background: var(--faint); color: var(--text); }
.doc-btn.del:hover { border-color: var(--red); color: var(--red); }
.doc-empty { text-align: center; color: var(--muted); font-size: .82rem; padding: 16px 0; }

/* ══ AUTH OVERLAY ════════════════════════════════════════════════════════════ */
#authOverlay { z-index: 9999; background: rgba(15,23,42,.6); }

.auth-brand { text-align: center; margin-bottom: 22px; }
.auth-brand h2 { font-size: 1.6rem; font-weight: 800; letter-spacing: -.5px; }
.auth-brand p  { font-size: .82rem; color: var(--muted); margin-top: 2px; }
.auth-access-note {
  text-align: center; margin-top: 18px;
  font-size: .76rem; color: var(--muted); line-height: 1.5;
}

.auth-tabs {
  display: flex; gap: 0; margin-bottom: 20px;
  border: 1.5px solid var(--border); border-radius: var(--r-sm);
  overflow: hidden;
}
.auth-tab {
  flex: 1; padding: 8px; border: none; background: none;
  cursor: pointer; font-size: .85rem; font-weight: 600;
  font-family: inherit; color: var(--muted);
  transition: background .12s, color .12s;
}
.auth-tab:first-child { border-right: 1.5px solid var(--border); }
.auth-tab.active { background: var(--primary); color: #fff; }
.auth-tab:not(.active):hover { background: var(--faint); color: var(--text); }

.auth-error {
  font-size: .8rem; color: var(--red); margin-bottom: 10px;
  padding: 6px 10px; background: var(--red-bg); border-radius: var(--r-sm);
}
.ricordami-row {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 14px; cursor: pointer;
  font-size: .83rem; color: var(--muted);
}
.ricordami-row input[type="checkbox"] {
  width: 16px; height: 16px; accent-color: var(--primary);
  cursor: pointer; flex-shrink: 0;
}

/* Header user / logout */
.header-user {
  display: flex; align-items: center; gap: 10px; margin-left: auto;
}
.header-user-name { font-size: .85rem; font-weight: 600; color: var(--muted); }
.btn-logout {
  font-size: .78rem; padding: 5px 12px; border-radius: 20px;
  border: 1.5px solid var(--border); background: none;
  cursor: pointer; font-family: inherit; color: var(--muted);
  transition: background .12s, color .12s;
}
.btn-logout:hover { background: var(--faint); color: var(--text); }

/* Share search results */
.share-search-results {
  max-height: 200px; overflow-y: auto;
  border: 1.5px solid var(--border); border-radius: var(--r-sm);
  margin-top: 4px; empty-cells: show;
}
.share-search-results:empty { display: none; }
.share-user-result {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; cursor: pointer;
  transition: background .1s;
  border-bottom: 1px solid var(--faint);
}
.share-user-result:last-child { border-bottom: none; }
.share-user-result:hover, .share-user-result.selected { background: #eff6ff; }
.share-user-result.selected { background: #dbeafe; }
.share-user-nome  { font-size: .88rem; font-weight: 600; color: var(--text); }
.share-user-email { font-size: .76rem; color: var(--muted); }
.share-no-results { text-align: center; color: var(--muted); font-size: .82rem; padding: 14px; }

/* ══ MODAL ═══════════════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 16px;
}
.modal {
  background: var(--surface); border-radius: var(--radius);
  width: 100%; max-width: 520px; max-height: 92vh; overflow-y: auto;
  box-shadow: 0 24px 60px rgba(0,0,0,.18); padding: 24px;
}
.modal-sm { max-width: 360px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px;
}
.modal-header h2 { font-size: 1.15rem; font-weight: 800; }
.modal-close {
  background: none; border: none; font-size: 1.4rem; color: var(--muted);
  cursor: pointer; line-height: 1; padding: 2px 6px; border-radius: 4px;
}
.modal-close:hover { background: var(--faint); color: var(--text); }

/* ── Form fields ──────────────────────────────────────────────────────────── */
.field-main { margin-bottom: 14px; }
.input-nome {
  width: 100%; padding: 18px 16px;
  border: 2px solid var(--border); border-radius: var(--r-sm);
  font-size: 1.12rem; font-weight: 600; outline: none;
  transition: border-color .15s, box-shadow .15s; color: var(--text);
}
.input-nome:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,.1);
}
.input-nome::placeholder { font-weight: 400; color: #9aa3b2; font-size: 1rem; }

.field-row { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.field-group { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 120px; }
.field-group.flex2 { flex: 2; }
.field-group label { font-size: .76rem; font-weight: 600; color: var(--muted); letter-spacing: .01em; }
/* Campi secondari — peso ridotto */
.field-group.field-secondary label { font-size: .72rem; opacity: .75; }
.field-group input,
.field-group select,
.field-group textarea {
  padding: 9px 10px; border: 1.5px solid var(--border); border-radius: var(--r-sm);
  font-size: .88rem; outline: none; background: var(--surface); color: var(--text);
  transition: border-color .15s; font-family: var(--font);
  height: 38px; box-sizing: border-box;
}
.field-group textarea { height: auto; }
.field-group input:focus,
.field-group select:focus,
.field-group textarea:focus { border-color: var(--primary); }

/* ── Importo collassabile ─────────────────────────────────────────────────── */
.importo-outer { margin-bottom: 2px; }

/* Pill "+ Importo" — visibile di default, scompare quando attivo */
.importo-trigger {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 14px 6px 10px;
  background: var(--faint); border: 1.5px solid var(--border);
  border-radius: 20px; cursor: pointer;
  font-family: var(--font); font-size: .82rem; font-weight: 600;
  color: var(--muted);
  transition: border-color .12s, color .12s, background .12s;
  margin: 6px 0 2px;
}
.importo-trigger:hover { border-color: var(--primary); color: var(--primary); background: #eff6ff; }
.importo-trigger-plus {
  font-size: 1rem; font-weight: 700; line-height: 1;
  color: var(--primary);
}
/* Nasconde il pill quando il blocco è aperto */
.importo-outer.active .importo-trigger { display: none; }

/* Blocco espanso — layout verticale */
.importo-block {
  display: flex; flex-direction: column; gap: 8px;
  padding: 4px 0 6px;
}
.importo-block.hidden { display: none; }

@keyframes importoIn {
  from { opacity: 0; transform: translateY(-5px); }
  to   { opacity: 1; transform: translateY(0); }
}
.importo-block:not(.hidden) { animation: importoIn .14s ease; }

/* Header: etichetta + "rimuovi" */
.importo-block-head {
  display: flex; align-items: center; justify-content: space-between;
}
.importo-block-label {
  font-size: .76rem; font-weight: 700;
  color: var(--muted); letter-spacing: .01em;
}
.importo-dismiss {
  background: none; border: none; cursor: pointer;
  font-size: .74rem; font-weight: 600; font-family: var(--font);
  color: var(--muted); padding: 2px 0;
  text-decoration: underline; text-underline-offset: 2px;
  transition: color .12s;
}
.importo-dismiss:hover { color: var(--red); }

/* Toggle Pago/Ricevo — full width nel blocco importo */
.importo-block .dir-toggle { width: 100%; }
.importo-block .dir-btn    { flex: 1; padding: 8px 0; font-size: .85rem; }

.importo-input {
  width: 100%;
  padding: 10px 12px; border: 1.5px solid var(--border); border-radius: var(--r-sm);
  font-size: 1.1rem; font-weight: 700; outline: none;
  background: var(--surface); color: var(--text);
  font-family: var(--font);
  height: 44px; box-sizing: border-box;
  transition: border-color .15s;
}
.importo-input:focus { border-color: var(--primary); }
.importo-input.dir-expense { color: #92400e; }
.importo-input.dir-expense:focus { border-color: #f59e0b; }
.importo-input.dir-income  { color: #15803d; }
.importo-input.dir-income:focus  { border-color: var(--green); }

/* ── Toggle Pago / Ricevo ─────────────────────────────────────────────────── */
.dir-toggle {
  display: flex; gap: 0;
  border: 1.5px solid var(--border); border-radius: var(--r-sm);
  overflow: hidden; width: fit-content;
  flex-shrink: 0;
}
.dir-btn {
  background: none; border: none; cursor: pointer;
  padding: 6px 16px; font-size: .82rem; font-weight: 700;
  font-family: inherit; color: #94a3b8;
  transition: background .12s, color .12s;
  line-height: 1.4;
}
.dir-btn:first-child { border-right: 1.5px solid var(--border); }
/* Pago — arancione caldo */
.dir-btn.expense.active { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
/* Ricevo — verde soft */
.dir-btn.income.active  { background: #dcfce7; color: #14532d; }
.dir-btn:not(.active):hover { background: var(--faint); color: var(--text); }

/* Input importo colorato (legacy per compat) */
#fCosto.dir-expense { color: #92400e; font-weight: 700; }
#fCosto.dir-income  { color: #15803d; font-weight: 700; }

/* ── Toggle tipo data (Data precisa / Mese anno) ──────────────────────────── */
.date-type-toggle {
  display: flex; gap: 0; margin-bottom: 6px;
  border: 1.5px solid var(--border); border-radius: var(--r-sm);
  overflow: hidden; width: fit-content;
}
.date-type-btn {
  background: none; border: none; cursor: pointer;
  padding: 8px 14px; font-size: .75rem; font-weight: 600;
  font-family: inherit; color: var(--muted);
  transition: background .12s, color .12s;
  line-height: 1.4;
}
.date-type-btn:first-child { border-right: 1.5px solid var(--border); }
.date-type-btn.active {
  background: var(--primary); color: #fff;
}
.date-type-btn:not(.active):hover { background: var(--faint); color: var(--text); }

/* ── Date input wrapper — custom placeholder ──────────────────────────────── */
.date-input-wrap { position: relative; width: 100%; display: block; }
.date-input-wrap > input[type="date"] { height: 38px; width: 100%; box-sizing: border-box; cursor: pointer; }
.date-input-wrap::before {
  content: attr(data-placeholder);
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  font-size: .85rem; color: var(--muted); opacity: .6;
  pointer-events: none; z-index: 1; font-family: inherit;
  transition: opacity .1s;
}
.date-input-wrap.has-value::before,
.date-input-wrap:focus-within::before { opacity: 0; }
.date-input-wrap:not(.has-value):not(:focus-within) > input[type="date"] { color: transparent; }

/* Notifica disabled (no date selected) */
#fNotifica:disabled {
  opacity: .45; background: var(--faint); cursor: not-allowed;
}
.field-notifica-disabled label { opacity: .45; }

/* ── Ripeti (notifica periodica, collassabile) ────────────────────────────── */
.ripeti-outer { margin-top: 10px; margin-bottom: 4px; }

/* Trigger button — tutta la riga tappabile */
.ripeti-toggle {
  display: flex; align-items: center; gap: 6px; width: 100%;
  background: none; border: none; cursor: pointer; padding: 10px 0;
  font-family: inherit; font-size: .82rem; font-weight: 600;
  color: var(--muted); -webkit-tap-highlight-color: transparent;
  transition: color .12s, opacity .12s;
  min-height: 44px; /* tap target minimo iOS */
}
.ripeti-toggle:not(:disabled):hover { color: var(--text); }
.ripeti-toggle:disabled { opacity: .38; cursor: not-allowed; }
.ripeti-toggle.is-active { color: var(--text); }
.ripeti-toggle-icon { font-size: 1.15rem; color: var(--primary); line-height: 1; font-weight: 700; }
.ripeti-check { color: var(--green); font-weight: 700; }

/* "Seleziona prima una data" hint */
.ripeti-no-date {
  font-size: .72rem; color: var(--muted); margin: 2px 0 0 0;
  display: none; opacity: .7;
}
.ripeti-outer.no-date .ripeti-no-date { display: block; }
.ripeti-outer.no-date .ripeti-toggle { pointer-events: none; }

/* Expanded block */
.ripeti-block {
  margin-top: 8px; padding: 10px 12px 12px;
  border-radius: var(--r-sm); border: 1px solid var(--border);
  background: var(--faint);
  display: flex; flex-direction: column; gap: 8px;
  animation: ripetiIn .16s ease;
}
@keyframes ripetiIn {
  from { opacity: 0; transform: translateY(-5px); }
  to   { opacity: 1; transform: translateY(0); }
}
.ripeti-every-label {
  font-size: .74rem; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em;
}
.ripeti-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ripeti-chip {
  border: 1.5px solid var(--border); background: var(--surface);
  color: var(--muted); border-radius: 14px; padding: 5px 13px;
  font-size: .78rem; font-weight: 600; font-family: inherit; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background .12s, border-color .12s, color .12s;
}
.ripeti-chip.active {
  background: rgba(34,197,94,.1); border-color: var(--green);
  border-width: 2px; color: #16a34a; font-weight: 700;
}
.ripeti-chip:not(.active):hover { background: var(--border); color: var(--text); }
.ripeti-chip:active { opacity: .7; }
.ripeti-custom-wrap {
  display: flex; align-items: center; gap: 8px;
}
.ripeti-custom-pre, .ripeti-custom-suf {
  font-size: .83rem; color: var(--muted); font-weight: 500; white-space: nowrap;
}
#fRipetiGiorni {
  width: 56px; padding: 4px 8px;
  border: 1.5px solid var(--border); border-radius: 6px;
  font-size: .9rem; font-family: inherit;
  text-align: center; outline: none; background: var(--surface); color: var(--text);
}
#fRipetiGiorni:focus { border-color: var(--primary); }
.ripeti-confirm {
  font-size: .78rem; color: #16a34a; font-weight: 600; margin: 0;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.form-actions { display: flex; justify-content: flex-end; gap: 28px; margin-top: 24px; align-items: center; border-top: 1px solid var(--border); padding-top: 16px; }
.btn-save {
  padding: 12px 28px; border-radius: 10px; font-size: .9rem;
  font-weight: 700; cursor: pointer; border: none;
  background: var(--primary); color: #fff;
  transition: background .12s, opacity .12s, box-shadow .12s, transform .1s;
  box-shadow: 0 4px 14px rgba(59,130,246,.35);
}
.btn-save:not(:disabled):hover { background: var(--primary-dk); box-shadow: 0 6px 20px rgba(59,130,246,.5); transform: scale(1.03); }
.btn-save:not(:disabled):active { transform: scale(.96); box-shadow: 0 2px 8px rgba(59,130,246,.25); }
.btn-save:disabled { opacity: .55; cursor: not-allowed; box-shadow: none; }
.btn-ghost {
  padding: 8px 14px; border-radius: 10px; font-size: .83rem;
  font-weight: 400; cursor: pointer;
  background: transparent; color: var(--muted);
  border: 1px solid transparent; transition: all .12s;
  opacity: .65;
}
.btn-ghost:hover { color: var(--text); border-color: var(--border); opacity: 1; }
.btn-danger {
  padding: 9px 18px; border-radius: 10px; font-size: .88rem;
  font-weight: 600; cursor: pointer; border: none;
  background: var(--red); color: #fff;
}
.btn-danger:hover { background: #dc2626; }

/* ── Grid fade-in al cambio di vista ────────────────────────────────────── */
@keyframes grid-fadein {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: translateY(0); }
}
.grid-anim { animation: grid-fadein .2s ease both; }

/* ══ SWIPE GESTURES ══════════════════════════════════════════════════════════ */

/* Wrapper — clip dell'action zone; shadow qui, non sulla card */
.swipe-wrap {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

/* Card sopra entrambi i background, copre tutta la larghezza */
.swipe-wrap > .card {
  position: relative; z-index: 2;
  width: 100%;
  transform: translateX(0);
  will-change: transform;
  box-shadow: none; border-radius: 0;
  background: var(--surface);
}

/* ── Sfondo verde (swipe destra = fatto) — sempre opaco, rivelato dallo scorrimento ── */
.swipe-bg-l {
  position: absolute; inset: 0; z-index: 0;
  background: #16a34a;
  display: flex; align-items: center;
  padding: 0 22px; gap: 10px;
  color: #fff; font-size: .9rem; font-weight: 700;
}
.swipe-icon-l {
  font-size: 1.5rem; line-height: 1;
  transform: scale(calc(0.4 + var(--sw-prog, 0) * 0.6));
  opacity: calc(var(--sw-prog, 0) * 1.5 - 0.1);
}
.swipe-lbl-l { letter-spacing: .01em; }



/* ── Toast undo ──────────────────────────────────────────────────────────── */
.app-toast { display: flex; align-items: center; gap: 12px; }
.toast-msg  { flex: 1; }
.toast-undo-btn {
  background: none; border: none; cursor: pointer;
  font-size: .83rem; font-weight: 700; color: #93c5fd;
  padding: 0; font-family: inherit; white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.toast-undo-btn:active { color: #bfdbfe; }

/* ══ CATEGORY CHIPS ══════════════════════════════════════════════════════════ */

/* Strip sotto la search bar */
.cat-strip-wrap {
  overflow-x: auto; overflow-y: hidden;
  padding: 7px 14px 8px;
  border-top: 1px solid var(--border);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.cat-strip-wrap::-webkit-scrollbar { display: none; }
.cat-strip-wrap.hidden { display: none; }
.cat-strip { display: flex; gap: 6px; width: max-content; }

/* Chip base */
.cat-chip {
  display: inline-flex; align-items: center; gap: 4px;
  border: 1.5px solid var(--border);
  background: var(--surface); color: var(--text);
  border-radius: 20px; padding: 5px 13px;
  font-size: .78rem; font-weight: 600;
  cursor: pointer; white-space: nowrap;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
  transition: background .12s, border-color .12s, color .12s;
}
.cat-chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.cat-chip:active { opacity: .75; }

/* Form chips */
.field-cat-wrap { margin-bottom: 10px; margin-top: 14px; }
.field-cat-wrap > label { font-size: .76rem; font-weight: 600; color: var(--muted); display: block; margin-bottom: 8px; }
.lbl-opt { font-weight: 400; opacity: .7; }
.cat-chips-form { display: flex; flex-wrap: wrap; gap: 5px; }
.cat-chip-form {
  border: 1.5px solid var(--border);
  background: transparent; color: var(--muted);
  border-radius: 14px; padding: 3px 10px;
  font-size: .74rem; font-weight: 600;
  cursor: pointer; white-space: nowrap;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
  transition: background .12s, border-color .12s, color .12s;
}
.cat-chip-form.active {
  background: rgba(29,78,216,.12);
  border-color: var(--accent); border-width: 2px;
  color: var(--accent); font-weight: 700;
}
.cat-chip-form:active { opacity: .7; }

/* Filter badge */
.filter-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .78rem; font-weight: 600; color: var(--accent);
  background: rgba(29,78,216,.08); border-radius: 20px;
  padding: 5px 8px 5px 12px; margin-bottom: 10px;
}
.filter-badge-x {
  background: none; border: none; cursor: pointer;
  font-size: .85rem; color: var(--accent); padding: 0 2px;
  line-height: 1; font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}

/* Card category icon */
.card-cat-icon { font-size: .82rem; line-height: 1; flex-shrink: 0; margin-right: 3px; }

/* ══ SEARCH UI ═══════════════════════════════════════════════════════════════ */
.srch-home { display: flex; flex-direction: column; gap: 22px; padding: 8px 0 32px; }
.srch-section-lbl {
  font-size: .7rem; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .07em; margin-bottom: 8px;
}
.srch-recent-list { display: flex; flex-direction: column; gap: 5px; }
.srch-recent-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 11px;
  background: var(--surface); border: 1px solid var(--border);
  cursor: pointer; text-align: left; font-family: inherit; width: 100%;
  -webkit-tap-highlight-color: transparent; box-shadow: var(--shadow);
}
.srch-recent-btn:active { background: var(--faint); }
.srch-recent-icon { font-size: .95rem; opacity: .45; flex-shrink: 0; }
.srch-recent-nome { font-size: .88rem; font-weight: 500; color: var(--text); flex: 1; }
.srch-sugg-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.srch-sugg {
  display: inline-flex; align-items: center; gap: 5px;
  border: 1.5px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 20px; padding: 6px 13px; font-size: .8rem; font-weight: 600;
  cursor: pointer; font-family: inherit; -webkit-tap-highlight-color: transparent;
}
.srch-sugg:active { background: var(--faint); }
.srch-results { display: flex; flex-direction: column; gap: 6px; padding: 4px 0 24px; }
.srch-card {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border);
  cursor: pointer; text-align: left; width: 100%; font-family: inherit;
  -webkit-tap-highlight-color: transparent; box-shadow: var(--shadow);
}
.srch-card:active { background: var(--faint); }
.srch-card-body { flex: 1; min-width: 0; }
.srch-nome {
  font-size: .9rem; font-weight: 600; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.srch-meta { font-size: .78rem; color: var(--muted); margin-top: 2px; }
.srch-arrow { color: #cbd5e1; font-size: 1.1rem; flex-shrink: 0; }
.srch-empty {
  text-align: center; padding: 44px 20px; grid-column: 1/-1;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.srch-empty strong { font-size: .93rem; color: var(--text); font-weight: 700; }
.srch-empty span { font-size: .82rem; color: var(--muted); }

/* ══ UTILS ═══════════════════════════════════════════════════════════════════ */
.hidden { display: none !important; }

/* ══ MOBILE-ONLY HEADER INFO (hidden on desktop) ════════════════════════════ */
.header-row1     { display: contents; }   /* trasparente nel flex del header */
.mobile-header-info { display: none; }

@media (max-width: 600px) {
  .oggi-ricorda { margin: 8px 12px 4px; }

  /* ══ TOKENS ══════════════════════════════════════════════════════════════ */
  :root { --panel-w: 100vw; }

  /* ══ HEADER — colonna compatta ══════════════════════════════════════════ */
  .app-header {
    flex-direction: column;
    align-items: stretch;
    padding: 8px 14px 7px;
    gap: 6px;
  }

  /* Riga 1: logo sinistra + utente destra */
  .header-row1 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 6px;
  }
  .header-brand     { flex-shrink: 0; }
  .header-brand h1  { font-size: 1.12rem; letter-spacing: -.3px; }
  .header-sub       { display: none; }
  .header-user      { margin-left: 0; flex-shrink: 0; }
  .header-user-name { display: block; font-size: .78rem; font-weight: 600; }

  /* Desktop KPI e strip nascosti su mobile */
  .header-stats { display: none !important; }
  .scad-strip   { display: none !important; }

  /* ══ MOBILE STATUS COMPATTO ══════════════════════════════════════════════ */
  .mobile-header-info {
    display: flex;
    flex-direction: column;
    gap: 5px;
  }
  .mhi-status {
    display: flex;
    align-items: center;   /* icona allineata verticalmente al centro */
    gap: 8px;
  }
  .mhi-icon {
    font-size: .9rem;
    line-height: 1;
    flex-shrink: 0;
    align-self: center;    /* forza centramento verticale preciso */
    margin-top: -1px;      /* micro-aggiustamento visivo */
  }
  .mhi-text { display: flex; flex-direction: column; min-width: 0; }
  .mhi-main {
    font-size: .85rem;
    font-weight: 800;      /* più pesante — gerarchia chiara */
    color: var(--text);
    line-height: 1.3;
  }
  .mhi-sub  {
    font-size: .64rem;     /* più piccolo rispetto a main — gerarchia */
    color: var(--muted);
    line-height: 1.3;
  }

  /* Colori stato */
  .mhi-status.ok     .mhi-main { color: #166534; }  /* verde meno saturo */
  .mhi-status.warn   .mhi-main { color: var(--orange); }
  .mhi-status.urgent .mhi-main { color: var(--red); }

  /* Riga prossima scadenza — tap area aumentata, feedback visivo chiaro */
  .mhi-prossima {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 7px 10px;     /* più alta per tap comodo */
    background: var(--faint);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: background .12s, transform .08s;
    -webkit-tap-highlight-color: transparent;
  }
  .mhi-prossima:active {
    background: #dbeafe;   /* flash blu al tap — chiaramente interattivo */
    transform: scale(.99);
  }
  .mhi-pross-icon  { font-size: .88rem; flex-shrink: 0; opacity: 1; }
  /* Wrapper a 2 righe */
  .mhi-pross-body {
    display: flex; flex-direction: column;
    flex: 1; min-width: 0; gap: 1px;
  }
  .mhi-pross-main {
    font-size: .76rem; font-weight: 700; color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .mhi-pross-text {
    font-size: .67rem; font-weight: 500; color: var(--muted);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .mhi-pross-arrow {
    font-size: 1rem; color: var(--primary);  /* freccia blu → indica interattività */
    flex-shrink: 0; font-weight: 700;
  }

  /* ══ STICKY BAR (mobile) ════════════════════════════════════════════════ */
  .sticky-bar { box-shadow: 0 2px 8px rgba(0,0,0,.06); }

  /* ══ TOOLBAR ═════════════════════════════════════════════════════════════ */
  .toolbar {
    padding: 8px 12px 4px;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }
  .toolbar { flex-wrap: wrap; gap: 6px; }
  .search-wrap { width: 100%; }
  .search-icon { font-size: .8rem; left: 12px; opacity: .5; }

  /* ── View tabs ── */
  .view-tab-bar { padding: 0 10px 8px; gap: 5px; }
  .view-tab { padding: 7px 0; font-size: .78rem; flex: 1; text-align: center; }
  #searchInput {
    width: 100%;
    padding: 12px 16px 12px 34px;   /* più alta */
    font-size: .88rem;
    border-radius: 22px;
    border-width: 1.5px;
  }

  /* ══ GRID ════════════════════════════════════════════════════════════════ */
  .grid {
    grid-template-columns: 1fr;
    padding: 0 10px 100px;
    gap: 8px;
  }
  .grid.panel-open { margin-right: 0; }

  /* ══ AVANTI GROUPS (mobile) ══════════════════════════════════════════════ */
  .avanti-bdy { grid-template-columns: 1fr; gap: 6px; padding-top: 16px; }
  .avanti-hdr { padding: 10px 2px 9px; }

  /* ══ CARD ════════════════════════════════════════════════════════════════ */
  .card      { padding: 8px 11px 6px; gap: 3px; }
  .card-nome { font-size: 1rem; font-weight: 700; }  /* +0.03rem */

  /* Stato urgenza */
  .card-scad            { font-size: .79rem; font-weight: 700; }
  .card-scad.red        { font-weight: 700; }
  .card-scad.red.scaduto {
    font-weight: 800;
    background: #fee2e2;
    border: 1px solid #fca5a5;
    border-radius: 4px;
    padding: 2px 7px;
  }

  /* Importi — decisi, alto contrasto */
  .card-costo                    { font-size: 1.1rem; font-weight: 600; margin-top: 5px; }
  .card-costo.card-costo-expense { font-size: 1.15rem; color: #dc2626; font-weight: 800; }
  .card-costo.card-costo-income  { font-size: 1.15rem; color: #166534; font-weight: 800; }

  /* Azioni rapide — gap aumentato, tap comodo */
  .card-quick { padding-top: 9px; margin-top: 5px; gap: 5px; }
  .card-quick-link {
    font-size: .73rem;
    padding: 6px 10px;
    border-radius: 5px;
  }
  /* Fatto — pill prominente, verde deciso */
  .card-quick-link.fatto {
    font-weight: 700;
    color: #15803d;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    padding: 6px 13px;
    border-radius: 6px;
  }
  .card-quick-link.fatto:hover { background: #dcfce7; }
  /* Condividi — quasi invisibile */
  .card-quick-link.share-q {
    color: #d1d5db;
    font-size: .63rem;
  }
  .card-quick-sep { color: #e2e8f0; padding: 0; }


  /* ══ FAB — alzato, shadow morbida ═══════════════════════════════════════ */
  .fab-wrap { bottom: 68px; right: 16px; }
  .fab {
    width: 48px; height: 48px; font-size: 1.55rem;
    box-shadow: 0 4px 18px rgba(59,130,246,.25), 0 1px 5px rgba(0,0,0,.08);
  }
  .fab-tooltip { display: none; }

  /* ══ MODALE "SEGNA QUALCOSA" ═════════════════════════════════════════════ */
  .modal {
    padding: 22px 20px 20px;
    max-height: 96vh;
    border-radius: 18px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .modal-sm     { max-width: 96vw; }
  .modal-header { margin-bottom: 22px; }

  /* Respiro titolo → nome */
  .field-main { margin-bottom: 20px; }

  /* Toggle Data / Importo — full width, altezza aumentata */
  .date-type-toggle,
  .dir-toggle {
    width: 100%;
    margin-bottom: 10px;
  }
  .date-type-btn,
  .dir-btn {
    flex: 1;
    padding: 10px 6px;
    font-size: .82rem;
    font-weight: 600;
    text-align: center;
    line-height: 1.3;
  }

  /* ══ FORM ACTIONS — Salva dominante, Annulla ultra-ghost ═════════════════ */
  .form-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    margin-top: 18px;
  }
  .form-actions .btn-save {
    width: 100%;
    text-align: center;
    padding: 14px;
    font-size: .97rem;
    border-radius: 12px;
  }
  .form-actions .btn-ghost {
    width: 100%;
    text-align: center;
    background: transparent;
    border: none;
    color: var(--muted);
    font-weight: 400;
    font-size: .82rem;
    padding: 8px;
    opacity: .75;
  }
}

/* ══ HEADER PROF BTN ════════════════════════════════════════════════════════ */
.header-prof-btn {
  display: flex; align-items: center; gap: 8px;
  background: none; border: none; cursor: pointer; padding: 4px 6px;
  border-radius: 8px; font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}
.header-prof-btn:active { background: rgba(0,0,0,.06); }
.header-prof-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: #1d4ed8; color: #fff;
  font-size: .9rem; font-weight: 900;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(29,78,216,.45);
  letter-spacing: -.01em;
}
.header-user-name {
  font-size: .85rem; font-weight: 600; color: var(--text);
}

/* ══ PROFILO PANEL ══════════════════════════════════════════════════════════ */
.prof-panel {
  position: fixed; inset: 0; z-index: 200;
  background: var(--bg);
  transform: translateX(100%);
  transition: transform .28s cubic-bezier(.4,0,.2,1);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.prof-panel.open { transform: translateX(0); }

.prof-panel-hdr {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}
.prof-back-btn {
  font-size: 1.7rem; line-height: 1; background: none; border: none;
  cursor: pointer; color: var(--accent); padding: 0 8px 0 0;
  font-family: inherit; -webkit-tap-highlight-color: transparent;
}
.prof-panel-title {
  font-size: 1rem; font-weight: 700; color: var(--text);
}

.prof-panel-body {
  flex: 1; overflow-y: auto;
  padding: 20px 16px 56px;
  display: flex; flex-direction: column; gap: 32px;
}

/* ── Hero ─────────────────────────────────────────────────────────────────── */
.prof-hero {
  display: flex; align-items: center; gap: 16px;
  padding: 4px 0 4px;
}
.prof-avatar-lg {
  width: 64px; height: 64px; border-radius: 50%;
  background: #1d4ed8; color: #fff;
  font-size: 1.7rem; font-weight: 900;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(29,78,216,.45);
  letter-spacing: -.01em;
}
.prof-hero-nome {
  font-size: 1.1rem; font-weight: 700; color: var(--text);
}
.prof-hero-sub {
  font-size: .82rem; color: var(--muted); margin-top: 3px;
}

/* ── Sections ─────────────────────────────────────────────────────────────── */
.prof-section { display: flex; flex-direction: column; gap: 8px; }
.prof-section-lbl {
  font-size: .71rem; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .07em;
  padding-left: 4px;
}
.prof-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}

/* ── Rows ─────────────────────────────────────────────────────────────────── */
.prof-row {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 16px; min-height: 46px;
}
.prof-row-sep { border-top: 1px solid var(--border); }
.prof-row-label {
  flex: 1; font-size: .9rem; color: var(--text); font-weight: 500;
}
.prof-row-val {
  font-size: .84rem; color: var(--muted);
  max-width: 145px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
/* Gerarchia account: nome evidenziato, telefono neutro, email attenuata */
.prof-row-val.val-primary   { color: var(--text); font-weight: 700; }
.prof-row-val.val-secondary { color: #b0bec5; font-size: .79rem; }
/* Telefono "Non impostato" — più grigio del valore reale */
.prof-row-val.val-placeholder { color: #c4cdd6; font-size: .82rem; }
/* Disabilitazione riga orario quando notifiche OFF */
.prof-row-disabled {
  opacity: .28;
  pointer-events: none;
  transition: opacity .2s;
}

/* ── Nav rows ─────────────────────────────────────────────────────────────── */
.prof-nav-row {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 16px; min-height: 46px; width: 100%;
  background: none; border: none; cursor: pointer;
  font-family: inherit; text-align: left;
  -webkit-tap-highlight-color: transparent;
}
.prof-nav-row:active { background: rgba(0,0,0,.04); }
.prof-nav-arr { font-size: 1.15rem; color: var(--muted); flex-shrink: 0; }
/* Badge contatore condivisioni */
.prof-count-badge {
  font-size: .78rem; font-weight: 700;
  color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent);
  padding: 2px 8px; border-radius: 20px;
  flex-shrink: 0; margin-left: auto; margin-right: 4px;
}

/* ── Toggle switch ────────────────────────────────────────────────────────── */
.tog { position: relative; display: inline-block; flex-shrink: 0; }
.tog input { opacity: 0; width: 0; height: 0; position: absolute; }
.tog-track {
  display: block; width: 51px; height: 30px; border-radius: 15px;
  background: #d1d5db; cursor: pointer;
  transition: background .22s, box-shadow .22s; position: relative;
}
.tog input:checked + .tog-track {
  background: #16a34a;                          /* verde ON — inequivocabile */
  box-shadow: 0 0 0 3px rgba(22,163,74,.18);    /* alone verde leggero */
}
.tog-thumb {
  position: absolute; top: 3px; left: 3px;
  width: 24px; height: 24px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.3);
  transition: transform .22s cubic-bezier(.4,0,.2,1);
}
.tog input:checked + .tog-track .tog-thumb { transform: translateX(21px); }

/* ── Time input ───────────────────────────────────────────────────────────── */
.prof-time-input {
  font-size: .88rem; color: var(--text); font-family: inherit;
  background: none; border: none; outline: none;
  cursor: pointer; text-align: right; flex-shrink: 0;
}

/* ── Support text ─────────────────────────────────────────────────────────── */
.prof-support-txt {
  font-size: .78rem; color: var(--muted);
  padding: 0 16px 12px; margin: 0; line-height: 1.45;
}

/* ── Segmented control ────────────────────────────────────────────────────── */
.prof-seg {
  display: flex; border-radius: 9px; overflow: hidden;
  border: 1.5px solid var(--border); flex-shrink: 0;
  background: var(--bg);
}
.prof-seg-opt {
  padding: 6px 16px; font-size: .82rem; font-weight: 600;
  background: none; border: none; cursor: pointer;
  font-family: inherit; color: #c4cdd6;   /* inattivo: molto attenuato */
  transition: background .15s, color .15s;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}
.prof-seg-opt + .prof-seg-opt { border-left: 1.5px solid var(--border); }
.prof-seg-opt.active {
  background: #1d4ed8; color: #fff;       /* attivo: blu scuro, massimo contrasto */
  font-weight: 700;
}

/* ── Logout button ────────────────────────────────────────────────────────── */
.prof-logout-btn {
  width: 100%; padding: 15px 16px;
  background: none; border: none; cursor: pointer;
  font-size: .95rem; font-weight: 700; color: #dc2626;
  font-family: inherit; text-align: center;
  letter-spacing: .01em;
  -webkit-tap-highlight-color: transparent;
}
.prof-logout-btn:active { background: rgba(220,38,38,.07); }
/* Sezione logout — separazione visiva netta */
.prof-section-logout {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ══ SHARE SUB-PANELS ═══════════════════════════════════════════════════════ */
.share-sub-panel { z-index: 210; }

.share-list {
  display: flex; flex-direction: column;
}
.share-list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; min-height: 56px;
  background: none; border: none; cursor: pointer;
  width: 100%; text-align: left; font-family: inherit;
  border-bottom: 1px solid var(--border);
  -webkit-tap-highlight-color: transparent;
  transition: background .12s;
}
.share-list-item:last-child { border-bottom: none; }
.share-list-item:active { background: rgba(0,0,0,.04); }
.share-item-icon {
  font-size: 1.35rem; flex-shrink: 0; width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface); border-radius: 10px;
}
.share-item-info { flex: 1; min-width: 0; }
.share-item-name {
  font-size: .92rem; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.share-item-sub {
  font-size: .78rem; color: var(--muted); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.share-item-arr { font-size: 1.1rem; color: var(--muted); flex-shrink: 0; }
.share-panel-empty {
  text-align: center; padding: 56px 24px;
  color: var(--muted); font-size: .9rem; line-height: 1.6;
}
.share-panel-empty .spe-icon { font-size: 2.2rem; margin-bottom: 10px; }

/* ══ EDIT FIELD MODAL ═══════════════════════════════════════════════════════ */
.efm-overlay {
  position: fixed; inset: 0; z-index: 300;
  display: flex; align-items: flex-end;
}
.efm-overlay.hidden { display: none; }
.efm-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.38);
}
.efm-sheet {
  position: relative; z-index: 1;
  width: 100%; background: var(--bg);
  border-radius: 20px 20px 0 0;
  padding: 24px 20px 36px;
  display: flex; flex-direction: column; gap: 14px;
}
.efm-title {
  font-size: 1rem; font-weight: 700; color: var(--text);
}
.efm-input {
  width: 100%; padding: 12px 14px;
  border: 1.5px solid var(--border); border-radius: 10px;
  font-size: .95rem; font-family: inherit;
  background: var(--surface); color: var(--text);
  outline: none; box-sizing: border-box;
}
.efm-input:focus { border-color: var(--accent); }
.efm-err { font-size: .82rem; color: #dc2626; }
.efm-err.hidden { display: none; }
.efm-actions { display: flex; gap: 10px; justify-content: flex-end; }
.efm-cancel {
  padding: 10px 18px; border-radius: 10px;
  background: none; border: 1.5px solid var(--border);
  font-size: .9rem; font-weight: 600; font-family: inherit;
  cursor: pointer; color: var(--muted);
}
.efm-save {
  padding: 10px 22px; border-radius: 10px;
  background: var(--accent); border: none;
  font-size: .9rem; font-weight: 700; font-family: inherit;
  cursor: pointer; color: #fff;
}
.efm-save:disabled { opacity: .5; cursor: not-allowed; }


/* ══ INVITI RICEVUTI ════════════════════════════════════════════════════════ */
.invites-block {
  margin: 0 16px 12px;
  background: var(--surface);
  border: 1.5px solid #bfdbfe;
  border-radius: var(--radius);
  overflow: hidden;
}
.invites-block.hidden { display: none; }
.invites-header {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px 10px;
  border-bottom: 1px solid #e0ecff;
}
.invites-icon { font-size: 1.1rem; }
.invites-title {
  font-size: .88rem; font-weight: 700;
  color: #1d4ed8; letter-spacing: .01em;
}
.invites-list { display: flex; flex-direction: column; }
.invite-card {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.invite-card:last-child { border-bottom: none; }
.invite-nome {
  font-size: .93rem; font-weight: 700; color: var(--text);
  margin-bottom: 2px;
}
.invite-meta {
  font-size: .78rem; color: var(--muted);
  margin-bottom: 10px;
}
.invite-meta strong { color: var(--text); }
.invite-scad {
  font-size: .75rem; color: var(--muted);
  margin-top: 1px;
}
.invite-cta {
  display: flex; gap: 8px;
}
.btn-invite-accept {
  flex: 1; padding: 8px 0;
  background: var(--primary); color: #fff;
  border: none; border-radius: 8px;
  font-size: .85rem; font-weight: 700; font-family: inherit;
  cursor: pointer;
  transition: background .12s;
}
.btn-invite-accept:hover { background: var(--primary-dk); }
.btn-invite-decline {
  flex: 1; padding: 8px 0;
  background: none; color: var(--muted);
  border: 1.5px solid var(--border); border-radius: 8px;
  font-size: .85rem; font-weight: 600; font-family: inherit;
  cursor: pointer;
  transition: border-color .12s, color .12s;
}
.btn-invite-decline:hover { border-color: #94a3b8; color: var(--text); }

/* ══ CARD — METADATI CONDIVISIONE ═══════════════════════════════════════════ */
.card-share-meta {
  font-size: .74rem; color: var(--muted);
  margin-top: 3px;
  display: flex; align-items: center; gap: 4px;
}
.card-share-meta .share-icon { font-size: .8rem; }
.card-share-meta .share-pending {
  color: #f59e0b;
}
.card-shared-by {
  font-size: .74rem; color: var(--muted);
  margin-top: 3px;
  font-style: italic;
}

/* ══ SEZIONE CONDIVISIONE NEL PANNELLO DETTAGLIO ════════════════════════════ */
.dp-share-section {
  margin-top: 20px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}
.dp-share-header {
  font-size: .82rem; font-weight: 700;
  color: var(--muted); letter-spacing: .04em;
  text-transform: uppercase;
  margin-bottom: 10px;
}
.share-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.share-row:last-of-type { border-bottom: none; }
.share-row-info { display: flex; flex-direction: column; gap: 2px; }
.share-row-nome { font-size: .88rem; font-weight: 600; color: var(--text); }
.share-row-email { font-size: .74rem; color: var(--muted); }
.share-stato {
  font-size: .72rem; font-weight: 700;
  padding: 2px 8px; border-radius: 20px;
  white-space: nowrap;
}
.share-stato.pending  { background: #fef3c7; color: #92400e; }
.share-stato.accepted { background: #dcfce7; color: #14532d; }
.share-stato.declined { background: #fee2e2; color: #7f1d1d; }
.share-remove {
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: .85rem; padding: 4px 8px;
  border-radius: 6px; transition: background .1s, color .1s;
  margin-left: 8px;
}
.share-remove:hover { background: var(--red-bg); color: var(--red); }
.dp-share-invite-btn {
  margin-top: 12px; width: 100%;
  padding: 9px 0;
  background: none; border: 1.5px dashed var(--border);
  border-radius: 10px; color: var(--muted);
  font-size: .85rem; font-weight: 600; font-family: inherit;
  cursor: pointer; transition: border-color .12s, color .12s;
}
.dp-share-invite-btn:hover { border-color: var(--primary); color: var(--primary); }
