/* ══════════════════════════════════════════
   Gestionale dello studio — base chiara e morbida
   Tutti i colori derivano da un solo accento (--acc), scelto nelle Impostazioni.
   ══════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --acc: #6B8F7B;              /* accento: lo cambia la palette scelta */
  --on-acc: #FFFFFF;           /* testo sopra l'accento */

  /* Neutri chiari, leggermente tinti dall'accento */
  --bg: color-mix(in srgb, var(--acc) 4%, #FAF8F5);
  --bg-2: color-mix(in srgb, var(--acc) 6%, #F4F1EC);
  --surface: #FFFFFF;
  --surface-2: color-mix(in srgb, var(--acc) 5%, #F8F6F2);
  --surface-3: color-mix(in srgb, var(--acc) 9%, #F0EDE7);
  --line: color-mix(in srgb, var(--acc) 7%, #EAE6DF);
  --line-2: color-mix(in srgb, var(--acc) 10%, #DCD7CE);
  --text: #26231F;
  --text-2: #5F5A52;
  --muted: #8E887E;

  --acc-text: color-mix(in srgb, var(--acc) 80%, #000);
  --acc-soft: color-mix(in srgb, var(--acc) 12%, transparent);
  --acc-line: color-mix(in srgb, var(--acc) 38%, transparent);
  --acc-hover: color-mix(in srgb, var(--acc) 88%, #000);

  --ok: #3E8A5F;   --warn: #B7791F;   --bad: #C0564A;   --info: #4D72A6;
  --ok-soft: color-mix(in srgb, var(--ok) 12%, transparent);
  --warn-soft: color-mix(in srgb, var(--warn) 13%, transparent);
  --bad-soft: color-mix(in srgb, var(--bad) 11%, transparent);
  --info-soft: color-mix(in srgb, var(--info) 11%, transparent);

  --shadow: 0 1px 2px rgba(40, 34, 25, .04), 0 8px 24px -12px rgba(40, 34, 25, .12);
  --shadow-lg: 0 30px 60px -20px rgba(40, 34, 25, .28);
  --overlay: rgba(38, 35, 31, .32);
  --glass: color-mix(in srgb, var(--bg) 82%, transparent);

  --serif: 'Instrument Serif', 'Cormorant Garamond', Georgia, serif;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --r: 16px;
  --r-sm: 10px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  color-scheme: light;
}

/* Modalità scura (scelta nelle Impostazioni o automatica) */
:root[data-scheme="dark"] {
  --bg: color-mix(in srgb, var(--acc) 5%, #121314);
  --bg-2: color-mix(in srgb, var(--acc) 6%, #16171A);
  --surface: color-mix(in srgb, var(--acc) 4%, #1A1B1E);
  --surface-2: color-mix(in srgb, var(--acc) 6%, #212226);
  --surface-3: color-mix(in srgb, var(--acc) 8%, #292A2F);
  --line: color-mix(in srgb, var(--acc) 6%, #2A2B30);
  --line-2: color-mix(in srgb, var(--acc) 9%, #373840);
  --text: #ECE9E3;
  --text-2: #ABA79F;
  --muted: #77746D;
  --acc-text: color-mix(in srgb, var(--acc) 62%, #fff);
  --acc-soft: color-mix(in srgb, var(--acc) 18%, transparent);
  --acc-line: color-mix(in srgb, var(--acc) 45%, transparent);
  --acc-hover: color-mix(in srgb, var(--acc) 85%, #fff);
  --ok: #86B094;   --warn: #D9A95B;   --bad: #D98474;   --info: #93A7C6;
  --shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 20px 40px -24px rgba(0,0,0,.8);
  --shadow-lg: 0 40px 80px -20px rgba(0,0,0,.85);
  --overlay: rgba(0, 0, 0, .55);
  color-scheme: dark;
}

html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  font-family: var(--sans); font-size: 14px; line-height: 1.5;
  background: var(--bg); color: var(--text); min-height: 100vh;
  -webkit-font-smoothing: antialiased; font-feature-settings: 'cv11', 'ss01';
}
body::before {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(900px 520px at 88% -12%, color-mix(in srgb, var(--acc) 10%, transparent), transparent 62%),
    radial-gradient(700px 520px at -10% 112%, color-mix(in srgb, var(--acc) 6%, transparent), transparent 60%);
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--acc-soft); }
.hidden { display: none !important; }
.spacer { flex: 1; }
.neg { color: var(--bad); }
.pos { color: var(--ok); }
.muted-txt { color: var(--muted); font-size: 12.5px; }
code { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: .92em; background: var(--surface-3); padding: 1px 5px; border-radius: 5px; }

.ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

.eyebrow { font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--acc-text); font-weight: 500; margin-bottom: 6px; }
.display { font-family: var(--serif); font-weight: 400; letter-spacing: -.01em; line-height: 1.05; }
.display em { font-style: italic; color: var(--acc-text); }

.kbd, kbd {
  font-family: var(--sans); font-size: 11px; color: var(--text-2);
  border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 6px;
  padding: 1px 6px; background: var(--surface); white-space: nowrap;
}

/* ─────────── Monogramma / logo ─────────── */
.monogram {
  width: 64px; height: 64px; margin: 0 auto 24px; border-radius: 20px; overflow: hidden;
  display: grid; place-items: center; font-family: var(--serif); font-size: 28px; color: var(--on-acc);
  background: linear-gradient(145deg, var(--acc), var(--acc-hover));
  box-shadow: 0 0 0 6px var(--acc-soft), 0 16px 30px -12px color-mix(in srgb, var(--acc) 60%, transparent);
}
.monogram.sm { width: 38px; height: 38px; margin: 0; border-radius: 12px; font-size: 17px; box-shadow: none; flex-shrink: 0; }
.monogram.logo { background: var(--surface); border: 1px solid var(--line); }
.monogram img { width: 100%; height: 100%; object-fit: contain; padding: 12%; }
.monogram.icona img { object-fit: cover; padding: 0; }

/* ─────────── Accesso ─────────── */
.login { position: relative; z-index: 1; min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px; overflow: hidden; }
.login-glow { position: absolute; width: 620px; height: 620px; border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--acc) 18%, transparent), transparent 65%); filter: blur(20px); animation: breathe 9s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(1.12); opacity: .7; } }
.login-box { position: relative; width: 100%; max-width: 380px; text-align: center; }
.login-box .display { font-size: 50px; margin-bottom: 10px; }
.login-note { color: var(--text-2); margin-bottom: 28px; }
.login-fields { display: flex; flex-direction: column; gap: 10px; }
.login-fields > input, .login-field {
  border: 1px solid var(--line-2); border-radius: 14px; background: var(--glass);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); transition: border-color .2s, box-shadow .2s;
}
.login-fields > input { height: 54px; padding: 0 18px; outline: none; font-size: 16px; }
.login-fields > input:focus, .login-field:focus-within { border-color: var(--acc-line); box-shadow: 0 0 0 4px var(--acc-soft); }
.login-field { display: flex; align-items: center; gap: 6px; padding: 6px; }
.login-field input { flex: 1; min-width: 0; background: none; border: 0; outline: none; padding: 10px 12px; font-size: 16px; }
.login-go { width: 42px; height: 42px; border-radius: 10px; background: var(--acc); color: var(--on-acc); display: grid; place-items: center; transition: background .2s; flex-shrink: 0; }
.login-go:hover { background: var(--acc-hover); }
.login-go:disabled { opacity: .5; }
.login-go svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.login-error { color: var(--bad); font-size: 13px; min-height: 20px; margin-top: 14px; }
.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

/* ─────────── Struttura ─────────── */
.shell { position: relative; z-index: 1; display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column;
  padding: 22px 14px; border-right: 1px solid var(--line); background: var(--glass);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 26px; min-width: 0; }
.brand-txt { min-width: 0; }
.brand-name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-sub { font-size: 11px; color: var(--muted); letter-spacing: .1em; text-transform: uppercase; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  position: relative; display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 9px 12px; border-radius: 10px; color: var(--text-2); font-size: 14px; text-align: left;
  transition: background .2s, color .2s;
}
.nav-item:hover { background: var(--surface-3); color: var(--text); }
.nav-item.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.nav-item.active .ico { color: var(--acc-text); }
.nav-item .kbd { margin-left: auto; }
.nav-badge { margin-left: auto; font-size: 11px; font-weight: 600; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; display: none; place-items: center; background: var(--acc-soft); color: var(--acc-text); }
.nav-badge.on { display: grid; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; padding-top: 16px; border-top: 1px solid var(--line); }
.scrim { display: none; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; height: 64px; display: flex; align-items: center; gap: 14px;
  padding: 0 36px; border-bottom: 1px solid var(--line); background: var(--glass);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.crumb { display: flex; align-items: center; gap: 8px; font-size: 13px; min-width: 0; }
.crumb .ico { width: 14px; height: 14px; color: var(--muted); }
.crumb-root { color: var(--muted); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.sync { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.sync:not(:empty)::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.sync.saving { color: var(--acc-text); }
.sync.ok { color: var(--ok); }
.sync.err { color: var(--bad); }
.search-btn {
  display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 10px 0 12px; min-width: 230px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--muted); font-size: 13px;
  transition: border-color .2s;
}
.search-btn:hover { border-color: var(--line-2); color: var(--text-2); }
.search-btn .kbd { margin-left: auto; }

.view { width: 100%; max-width: 1280px; margin: 0 auto; padding: 36px 36px 80px; }
.view.enter { animation: enter .4s var(--ease); }
@keyframes enter { from { opacity: 0; transform: translateY(6px); } }

/* ─────────── Bottoni ─────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 16px;
  border-radius: 10px; font-size: 13.5px; font-weight: 500; white-space: nowrap;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--text);
  transition: background .2s, border-color .2s, color .2s, transform .1s;
}
.btn:hover { border-color: var(--acc-line); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; pointer-events: none; }
.btn .ico { width: 16px; height: 16px; }
.btn.primary { background: var(--acc); border-color: var(--acc); color: var(--on-acc); }
.btn.primary:hover { background: var(--acc-hover); border-color: var(--acc-hover); }
.btn.ghost { background: transparent; border-color: var(--line-2); color: var(--text-2); }
.btn.ghost:hover { color: var(--text); background: var(--surface); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { border-color: color-mix(in srgb, var(--bad) 40%, transparent); background: var(--bad-soft); }
.btn.danger-solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.sm { height: 30px; padding: 0 11px; font-size: 12.5px; border-radius: 8px; }
.btn.sm .ico { width: 14px; height: 14px; }
.icon-btn { width: 32px; height: 32px; display: inline-grid; place-items: center; border-radius: 8px; color: var(--muted); transition: background .2s, color .2s; }
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn .ico { width: 16px; height: 16px; }
.only-mobile { display: none; }

/* ─────────── Intestazioni ─────────── */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 28px; flex-wrap: wrap; }
.page-head .display { font-size: 48px; }
.sub { color: var(--text-2); margin-top: 8px; }
.sub b { color: var(--text); font-weight: 600; }
.head-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ─────────── Card, KPI, chip ─────────── */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 20px 22px; box-shadow: var(--shadow); min-width: 0;
}
.card.flush { padding: 0; overflow: hidden; }
.card + .card { margin-top: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-head h3 { font-size: 12.5px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--text-2); }
.card-note { color: var(--text-2); font-size: 13px; margin-bottom: 14px; }
.card-note a, .link { color: var(--acc-text); text-decoration: underline; text-decoration-color: var(--acc-line); text-underline-offset: 2px; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; min-width: 0; box-shadow: var(--shadow); }
.kpi-label { font-size: 12px; color: var(--muted); letter-spacing: .03em; }
.kpi-value { font-family: var(--serif); font-size: 32px; line-height: 1.15; margin-top: 4px; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kpi-sub { font-size: 12px; color: var(--text-2); margin-top: 2px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.grid-2 > .card + .card { margin-top: 0; }

.chip {
  display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 6px;
  font-size: 11.5px; font-weight: 500; white-space: nowrap; background: var(--surface-3); color: var(--text-2);
}
.chip .ico { width: 12px; height: 12px; }
.chip.acc { background: var(--acc-soft); color: var(--acc-text); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.info { background: var(--info-soft); color: var(--info); }

.empty { text-align: center; padding: 40px 20px; color: var(--text-2); }
.empty-ico { width: 52px; height: 52px; margin: 0 auto 14px; border-radius: 16px; display: grid; place-items: center; background: var(--acc-soft); color: var(--acc-text); }
.empty-ico .ico { width: 24px; height: 24px; }
.empty h4 { font-family: var(--serif); font-weight: 400; font-size: 26px; color: var(--text); margin-bottom: 6px; }
.empty p { font-size: 13.5px; max-width: 420px; margin: 0 auto; }
.empty .btn { margin-top: 18px; }

.banner {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; margin-bottom: 20px;
  border: 1px solid var(--acc-line); border-radius: var(--r); background: var(--acc-soft); color: var(--text);
}
.banner .ico { color: var(--acc-text); }
.banner span { flex: 1; }
.banner.warn { border-color: color-mix(in srgb, var(--warn) 40%, transparent); background: var(--warn-soft); }
.banner.warn .ico { color: var(--warn); }

/* ─────────── Controlli ─────────── */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.seg { display: inline-flex; padding: 3px; gap: 2px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.seg button { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 7px; font-size: 13px; color: var(--text-2); transition: background .2s, color .2s; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg button .ico { width: 16px; height: 16px; }
.tabs { display: flex; gap: 26px; border-bottom: 1px solid var(--line); margin-bottom: 22px; overflow-x: auto; scrollbar-width: none; }
.tab { position: relative; padding: 10px 0 12px; color: var(--muted); font-size: 14px; white-space: nowrap; transition: color .2s; }
.tab:hover { color: var(--text-2); }
.tab.on { color: var(--text); }
.tab.on::after { content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--acc); border-radius: 2px; }

/* ─────────── Righe ─────────── */
.rows { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.card.flush .row { padding: 12px 18px; }
.row:last-child { border-bottom: 0; }
.row-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-title b { font-weight: 500; }
.row-title small { display: block; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.row-ico { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; background: var(--surface-3); color: var(--text-2); }
.row-ico .ico { width: 16px; height: 16px; }
.row-ico.ok { background: var(--ok-soft); color: var(--ok); }
.row-ico.bad { background: var(--bad-soft); color: var(--bad); }
.row-ico.warn { background: var(--warn-soft); color: var(--warn); }
.row-ico.acc { background: var(--acc-soft); color: var(--acc-text); }

/* ─────────── Oggi ─────────── */
.hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 30px; margin-bottom: 28px; }
.hero > div:first-child { flex: 1; min-width: 0; }
.hero .display { font-size: 58px; }
.hero-sum { color: var(--text-2); font-size: 15px; margin-top: 12px; max-width: 620px; }
.hero-sum b { color: var(--text); font-weight: 600; }
.hero-clock { text-align: right; }
.clock { font-family: var(--serif); font-size: 58px; line-height: 1; font-variant-numeric: tabular-nums; }
.clock-date { color: var(--muted); font-size: 13px; margin-top: 6px; }

.steps { display: flex; flex-direction: column; }
.step { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.step:last-child { border-bottom: 0; }
.step-dot { width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center; font-size: 13px; font-weight: 600; border: 1.5px solid var(--line-2); color: var(--muted); }
.step-dot .ico { width: 15px; height: 15px; stroke-width: 2.4; }
.step.done .step-dot { background: var(--acc); border-color: var(--acc); color: var(--on-acc); }
.step-main { flex: 1; min-width: 0; }
.step-main b { display: block; font-weight: 500; }
.step.done .step-main b { color: var(--text-2); }
.step-main small { color: var(--muted); font-size: 12.5px; }
.step .chip { flex-shrink: 0; }

/* ─────────── Impostazioni ─────────── */
.settings { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.settings .card + .card { margin-top: 0; }
.settings .span-all { grid-column: 1 / -1; }
.sep { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; margin-bottom: 18px; }
.theme {
  position: relative; display: flex; flex-direction: column; gap: 8px; padding: 10px; border-radius: 12px; text-align: left;
  border: 1px solid var(--line); background: var(--surface); transition: border-color .2s, box-shadow .2s;
}
.theme:hover { border-color: var(--line-2); }
.theme.on { border-color: var(--acc); box-shadow: 0 0 0 3px var(--acc-soft); }
.theme-prev { height: 44px; border-radius: 8px; display: flex; align-items: flex-end; gap: 4px; padding: 7px; background: color-mix(in srgb, var(--t) 8%, #FAF8F5); border: 1px solid color-mix(in srgb, var(--t) 12%, #EAE6DF); }
.theme-prev i { display: block; border-radius: 4px; background: var(--t); }
.theme-prev i:nth-child(1) { width: 38%; height: 100%; }
.theme-prev i:nth-child(2) { width: 22%; height: 60%; opacity: .45; }
.theme-prev i:nth-child(3) { width: 22%; height: 35%; opacity: .25; }
.theme span { font-size: 12.5px; font-weight: 500; }
.theme .ico { position: absolute; top: 8px; right: 8px; width: 16px; height: 16px; padding: 2px; border-radius: 50%; background: var(--acc); color: var(--on-acc); stroke-width: 3; display: none; }
.theme.on .ico { display: block; }
:root[data-scheme="dark"] .theme-prev { background: color-mix(in srgb, var(--t) 10%, #1A1B1E); border-color: color-mix(in srgb, var(--t) 18%, #2A2B30); }
.theme.custom .theme-prev { background: conic-gradient(from 90deg, #C0564A, #B7791F, #3E8A5F, #4D72A6, #8475B8, #C0564A); border: 0; }
.color-line { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.color-line input[type=color] { width: 44px; height: 36px; padding: 2px; border: 1px solid var(--line-2); border-radius: 9px; background: var(--surface); cursor: pointer; }

.diag { list-style: none; display: flex; flex-direction: column; margin-top: 4px; }
.diag li { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.diag li:last-child { border-bottom: 0; }
.diag li span { flex: 1; min-width: 0; }
.diag li small { color: var(--muted); font-size: 12px; text-align: right; }
.diag .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: var(--muted); }
.diag .ok .dot { background: var(--ok); }
.diag .errore .dot { background: var(--bad); }
.diag .avviso .dot { background: var(--warn); }
.diag .errore span { color: var(--bad); }

.dev-list .row-title small { white-space: nowrap; }
.log-list .row { padding: 9px 0; font-size: 13px; }
.log-list time { color: var(--muted); font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.app-version { text-align: center; color: var(--muted); font-size: 12px; margin-top: 28px; }

.install-steps { counter-reset: s; list-style: none; display: flex; flex-direction: column; gap: 12px; margin: 6px 0 4px; }
.install-steps li { counter-increment: s; display: flex; gap: 12px; align-items: flex-start; font-size: 14px; color: var(--text-2); }
.install-steps li::before { content: counter(s); width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center; font-size: 12px; font-weight: 600; background: var(--acc-soft); color: var(--acc-text); }
.install-steps b { color: var(--text); font-weight: 600; }
.install-steps .ico { width: 16px; height: 16px; vertical-align: -3px; color: var(--info); }

/* ─────────── Form ─────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.form-grid.three { grid-template-columns: repeat(3, 1fr); }
.form-grid > .full { grid-column: 1 / -1; }
.form-sec { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--acc-text); font-weight: 600; margin: 8px 0 -2px; }
.form-sec:first-child { margin-top: 0; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12px; color: var(--text-2); font-weight: 500; }
.field label i { color: var(--acc-text); font-style: normal; }
.field small { font-size: 11.5px; color: var(--muted); }
.field input:not([type=checkbox]):not([type=radio]):not([type=color]), .field select, .field textarea {
  width: 100%; height: 42px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line-2);
  background: var(--surface); outline: none; transition: border-color .2s, box-shadow .2s;
}
.field textarea { height: auto; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.field select { appearance: none; padding-right: 32px; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238E887E' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center / 14px; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--acc-line); box-shadow: 0 0 0 3px var(--acc-soft); }
.field input::placeholder, .field textarea::placeholder { color: var(--muted); }
.field input[type=date], .field input[type=time] { -webkit-appearance: none; appearance: none; min-height: 42px; }
.check-line { display: flex; align-items: center; gap: 10px; min-height: 42px; cursor: pointer; font-size: 13.5px; color: var(--text-2); }
.check-line input { width: 18px; height: 18px; accent-color: var(--acc); flex-shrink: 0; }

/* ─────────── Modale ─────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px;
  background: var(--overlay); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); opacity: 0; transition: opacity .2s;
}
.modal-overlay.in { opacity: 1; }
.modal {
  width: 100%; max-width: 560px; max-height: calc(100vh - 40px); display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: 20px;
  box-shadow: var(--shadow-lg); transform: translateY(10px) scale(.99); transition: transform .3s var(--ease);
}
.modal.wide { max-width: 820px; }
.modal-overlay.in .modal { transform: none; }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 22px 24px 4px; }
.modal-head h2 { font-family: var(--serif); font-weight: 400; font-size: 28px; line-height: 1.1; }
.modal-head p { color: var(--text-2); font-size: 13px; margin-top: 4px; }
.modal-body { padding: 18px 24px; overflow-y: auto; }
.modal-foot { display: flex; align-items: center; gap: 10px; padding: 16px 24px; border-top: 1px solid var(--line); }
.confirm-text { color: var(--text-2); font-size: 14.5px; }

/* ─────────── Ricerca (⌘K) ─────────── */
.palette { position: fixed; inset: 0; z-index: 150; background: var(--overlay); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 16px; }
.palette-box { width: 100%; max-width: 600px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; box-shadow: var(--shadow-lg); animation: enter .25s var(--ease); }
#palette-input { width: 100%; height: 58px; padding: 0 20px; background: none; border: 0; border-bottom: 1px solid var(--line); outline: none; font-size: 16px; }
#palette-input::placeholder { color: var(--muted); }
.palette-list { max-height: 50vh; overflow-y: auto; padding: 8px; }
.pal-group { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); padding: 10px 12px 6px; }
.pal-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border-radius: 9px; text-align: left; color: var(--text-2); }
.pal-item span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pal-item em { font-style: normal; font-size: 12px; color: var(--muted); }
.pal-item .ico { width: 16px; height: 16px; }
.pal-item.on { background: var(--surface-3); color: var(--text); }
.pal-item.on .ico { color: var(--acc-text); }
.pal-empty { padding: 24px; text-align: center; color: var(--muted); }
.palette-foot { display: flex; gap: 16px; padding: 10px 16px; border-top: 1px solid var(--line); font-size: 11.5px; color: var(--muted); }
.palette-foot kbd { margin-right: 3px; }

/* ─────────── Avvisi ─────────── */
.toasts { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 14px; padding: 11px 16px; border-radius: 12px;
  background: #26231F; color: #F4F1EC; font-size: 13.5px; box-shadow: var(--shadow-lg); animation: toast-in .3s var(--ease);
}
:root[data-scheme="dark"] .toast { background: #2E2F34; border: 1px solid var(--line-2); }
.toast::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: #86B094; flex-shrink: 0; }
.toast.err::before { background: #E08A7B; }
.toast button { color: color-mix(in srgb, var(--acc) 55%, #fff); font-weight: 600; font-size: 13px; }
.toast.out { opacity: 0; transform: translateY(6px); transition: all .3s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }

/* ─────────── Pagina di installazione ─────────── */
.install { display: grid; place-items: start center; padding: 48px 16px; }
.install-box { position: relative; z-index: 1; width: 100%; max-width: 620px; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 32px; box-shadow: var(--shadow); }
.install-box .display { font-size: 40px; margin-bottom: 4px; }
.install-box .sub { margin-bottom: 18px; }
.install-req { list-style: none; display: flex; gap: 8px 18px; flex-wrap: wrap; font-size: 13px; margin-bottom: 18px; }
.install-err { border: 1px solid color-mix(in srgb, var(--bad) 40%, transparent); background: var(--bad-soft); color: var(--bad); border-radius: 12px; padding: 12px 14px; margin-bottom: 18px; font-size: 13.5px; }
.install-ok { font-family: var(--serif); font-size: 26px; color: var(--ok); margin: 10px 0; }
.install-config { width: 100%; font-family: ui-monospace, Menlo, monospace; font-size: 12px; padding: 12px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--bg-2); margin: 10px 0 16px; }

/* ═════════════ Telefono e tablet ═════════════ */
a, button, [data-act], label { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.tabbar { display: none; }

@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 280px; z-index: 60; transform: translateX(-100%); transition: transform .3s var(--ease);
    background: var(--bg); padding-top: calc(22px + env(safe-area-inset-top)); padding-bottom: calc(16px + env(safe-area-inset-bottom));
  }
  .nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 50; background: var(--overlay); }
  .topbar {
    height: calc(56px + env(safe-area-inset-top)); padding-top: env(safe-area-inset-top);
    padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right));
  }
  .only-mobile { display: inline-grid; }
  .menu-btn { width: 40px; height: 40px; margin-left: -8px; color: var(--text); }
  .menu-btn .ico { width: 22px; height: 22px; }
  .search-btn { min-width: 0; }
  .search-btn span, .search-btn .kbd, .crumb-root, .crumb .ico { display: none; }
  .crumb { font-size: 15px; font-weight: 600; }
  .view { padding: 24px max(16px, env(safe-area-inset-right)) calc(100px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
  .grid-2, .settings { grid-template-columns: 1fr; }
  .hero { flex-direction: column; align-items: stretch; gap: 16px; }
  .hero-clock { display: none; }
  .hero .display { font-size: 44px; }
  .palette { padding-top: calc(16px + env(safe-area-inset-top)); }
  .toasts { bottom: calc(86px + env(safe-area-inset-bottom)); width: calc(100% - 32px); }
  .toast { max-width: 100%; }

  /* Barra schede in basso */
  .tabbar {
    display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    padding: 6px max(6px, env(safe-area-inset-left)) calc(6px + env(safe-area-inset-bottom));
    background: var(--glass); backdrop-filter: blur(18px) saturate(1.4); -webkit-backdrop-filter: blur(18px) saturate(1.4);
    border-top: 1px solid var(--line);
  }
  .tab-item { position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0 4px; font-size: 10.5px; font-weight: 500; color: var(--muted); border-radius: 10px; }
  .tab-item .ico { width: 23px; height: 23px; }
  .tab-item.active { color: var(--acc-text); }
  .tab-item:active { background: var(--surface-3); }
  .tab-item .nav-badge { position: absolute; top: 1px; left: calc(50% + 5px); margin: 0; min-width: 17px; height: 17px; padding: 0 5px; font-size: 10px; }

  /* 16px nei campi: iOS non fa zoom quando li tocchi */
  .field input:not([type=checkbox]):not([type=radio]):not([type=color]), .field select, .field textarea,
  #palette-input, .login-field input, .login-fields > input { font-size: 16px; }
}

@media (max-width: 600px) {
  .page-head { margin-bottom: 20px; }
  .page-head .display { font-size: 38px; }
  .hero .display { font-size: 40px; }
  #btn-new span { display: none; }
  #btn-new { width: 38px; padding: 0; }
  .card { padding: 16px; }
  .kpis { gap: 10px; }
  .kpi { padding: 14px; }
  .kpi-value { font-size: 26px; }
  .form-grid, .form-grid.three { grid-template-columns: 1fr; }
  .themes { grid-template-columns: repeat(2, 1fr); }
  .modal-overlay { padding: 0; align-items: end; }
  .modal { max-height: 92vh; max-height: 92dvh; border-radius: 20px 20px 0 0; }
  .modal-foot { padding-bottom: calc(16px + env(safe-area-inset-bottom)); flex-wrap: wrap; }
  .modal-head { padding-top: 18px; }
  .install-box { padding: 22px 18px; }
  .diag li { flex-wrap: wrap; }
  .diag li small { width: 100%; text-align: left; padding-left: 20px; }
  .login-box .display { font-size: 44px; }
}

@media (hover: none) {
  .row-actions { opacity: 1; }
  .nav-item .kbd { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
