/* =========================================================
   Archivio Lavoro — stile
   ========================================================= */
:root {
  --bg: #f6f5f1;
  --side: #efede7;
  --surface: #ffffff;
  --surface-2: #efede7;
  --hover: #e9e6de;
  --line: #e2dfd6;
  --line-strong: #d3cfc4;
  --text: #1d1f1e;
  --text-2: #3d413f;
  --muted: #6b6f6c;
  --accent: #1f4e46;
  --accent-hover: #173d37;
  --accent-soft: #e1ece8;
  --accent-text: #ffffff;
  --mint: #9fd8c9;
  --mark: #d6efe7;
  --danger: #b3261e;
  --ok: #2e7d4f;
  --warn: #b7791f;
  --shadow-sm: 0 1px 2px rgba(29, 31, 30, .06);
  --shadow: 0 1px 2px rgba(29, 31, 30, .05), 0 6px 20px rgba(29, 31, 30, .06);
  --shadow-lg: 0 12px 40px rgba(29, 31, 30, .16);

  --c-consulenza: #1f4e46;
  --c-lavoro: #2f5d8a;
  --c-studio: #a8671a;
  --c-ricerca: #74508a;
  --s-idea: #7c817e;
  --s-valutazione: #a8671a;
  --s-sviluppo: #2f5d8a;
  --s-lanciata: #2e7d4f;
  --s-archiviata: #a9a497;

  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --serif: "Literata", Georgia, "Times New Roman", serif;
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;

  --radius: 14px;
  --sidebar-w: 256px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141615; --side: #181b1a; --surface: #1c1f1e; --surface-2: #232726; --hover: #2a2f2d;
    --line: #2d3230; --line-strong: #3b413e; --text: #e9ebe9; --text-2: #c9cdca; --muted: #9ba19e;
    --accent: #6fbfae; --accent-hover: #86cdbd; --accent-soft: #21332e; --accent-text: #0d1a17; --mark: #28443c;
    --danger: #f2877f; --ok: #6cc58f; --warn: #e5b45a;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.3); --shadow: 0 1px 2px rgba(0,0,0,.25), 0 8px 24px rgba(0,0,0,.25); --shadow-lg: 0 16px 48px rgba(0,0,0,.5);
    --c-consulenza: #6fbfae; --c-lavoro: #86b4e3; --c-studio: #e0ae5c; --c-ricerca: #c29bd8;
    --s-idea: #a3a9a6; --s-valutazione: #e0ae5c; --s-sviluppo: #86b4e3; --s-lanciata: #6cc58f; --s-archiviata: #6d726f;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141615; --side: #181b1a; --surface: #1c1f1e; --surface-2: #232726; --hover: #2a2f2d;
  --line: #2d3230; --line-strong: #3b413e; --text: #e9ebe9; --text-2: #c9cdca; --muted: #9ba19e;
  --accent: #6fbfae; --accent-hover: #86cdbd; --accent-soft: #21332e; --accent-text: #0d1a17; --mark: #28443c;
  --danger: #f2877f; --ok: #6cc58f; --warn: #e5b45a;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.3); --shadow: 0 1px 2px rgba(0,0,0,.25), 0 8px 24px rgba(0,0,0,.25); --shadow-lg: 0 16px 48px rgba(0,0,0,.5);
  --c-consulenza: #6fbfae; --c-lavoro: #86b4e3; --c-studio: #e0ae5c; --c-ricerca: #c29bd8;
  --s-idea: #a3a9a6; --s-valutazione: #e0ae5c; --s-sviluppo: #86b4e3; --s-lanciata: #6cc58f; --s-archiviata: #6d726f;
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 var(--sans); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
body.writing { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
h1, h2, h3, h4 { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line-strong);
  background: var(--surface); font-weight: 550; font-size: 14.5px; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover { background: var(--hover); }
.btn:active { transform: scale(.98); }
.btn svg { width: 18px; height: 18px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--hover); }

.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; flex: none;
  border: 0; border-radius: 10px; background: transparent; color: var(--text-2);
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.text { font-family: var(--serif); font-size: 17px; font-weight: 600; }
.icon-btn.on { background: var(--accent-soft); color: var(--accent); }

.eyebrow { margin: 0 0 6px; font-size: 12px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: var(--accent); }

.select, .field input, .field select, .search input {
  height: 40px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface);
  padding: 0 12px; outline: none; transition: border-color .15s, box-shadow .15s; min-width: 0;
}
.select { padding-right: 30px; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b6f6c' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 8px center; background-size: 16px; }
.field input:focus, .field select:focus, .search input:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.segmented { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface-2); border-radius: 11px; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.segmented::-webkit-scrollbar { display: none; }
.segmented button {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 13px; flex: none;
  border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-weight: 550; font-size: 14px;
}
.segmented button:hover { color: var(--text); }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.segmented .n { font-size: 12px; color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.segmented i { width: 7px; height: 7px; border-radius: 50%; background: var(--dot, var(--muted)); }
.segmented.small button { height: 30px; padding: 0 11px; font-size: 13.5px; }

/* ---------- Sync ---------- */
.sync, .w-save { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); min-width: 0; }
.sync span, .w-save span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sync i, .w-save i { width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); flex: none; }
[data-state="ok"] > i { background: var(--ok); }
[data-state="pending"] > i { background: var(--warn); animation: pulse 1s ease-in-out infinite; }
[data-state="error"] > i, [data-state="offline"] > i { background: var(--danger); }
@keyframes pulse { 50% { opacity: .3; } }

/* =========================================================
   Layout app
   ========================================================= */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100%; }

.sidebar {
  position: sticky; top: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column; gap: 6px;
  padding: 18px 14px 14px; background: var(--side); border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 14px; font-family: var(--serif); font-size: 20px; font-weight: 600; letter-spacing: -.01em; }
.brand img { border-radius: 8px; }
.new-btn { width: 100%; height: 42px; margin-bottom: 12px; }

.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav a, .side-foot a {
  display: flex; align-items: center; gap: 11px; height: 38px; padding: 0 10px; border-radius: 9px;
  color: var(--text-2); font-weight: 500; font-size: 14.5px;
}
.side-nav a:hover, .side-foot a:hover { background: var(--hover); color: var(--text); }
.side-nav a svg, .side-foot a svg { color: var(--muted); }
.side-nav a em { margin-left: auto; font-style: normal; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.side-nav a.active, .side-foot a.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow-sm); }
.side-nav a.active svg, .side-foot a.active svg { color: var(--accent); }
.side-sub { display: flex; flex-direction: column; gap: 1px; margin: 2px 0 6px 20px; padding-left: 12px; border-left: 1px solid var(--line-strong); }
.side-sub a { height: 32px; font-size: 13.5px; gap: 9px; padding: 0 8px; }
.side-sub a i { width: 7px; height: 7px; border-radius: 50%; background: var(--cat); flex: none; }
.side-sub a.active { box-shadow: none; background: var(--hover); }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; padding-top: 10px; border-top: 1px solid var(--line); }
.side-foot .sync { padding: 6px 10px 2px; }

.main { min-width: 0; }
.view { max-width: 1240px; margin: 0 auto; padding: 44px 48px 80px; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.mobile-top { display: none; }
.tabbar { display: none; }

.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 26px; flex-wrap: wrap; }
.view-head h1 { font-family: var(--serif); font-size: 38px; font-weight: 600; letter-spacing: -.02em; line-height: 1.1; }
.head-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.search { position: relative; display: flex; align-items: center; }
.search svg { position: absolute; left: 11px; width: 17px; height: 17px; color: var(--muted); pointer-events: none; }
.search input { width: 240px; padding-left: 36px; }

/* ---------- Home ---------- */
.hero { margin-bottom: 28px; }
.hero h1 { font-family: var(--serif); font-size: 44px; font-weight: 600; letter-spacing: -.025em; line-height: 1.08; }
.lead { margin: 8px 0 0; font-size: 17px; color: var(--muted); }

.connect-banner {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px; margin-bottom: 22px;
  background: var(--accent-soft); border-radius: var(--radius); color: var(--text);
}
.connect-banner > svg { color: var(--accent); width: 26px; height: 26px; }
.connect-banner div { flex: 1; display: flex; flex-direction: column; font-size: 14px; }
.connect-banner span { color: var(--muted); }

.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.quick-card {
  display: flex; align-items: center; gap: 16px; padding: 20px; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  transition: border-color .15s, box-shadow .2s, transform .15s;
}
.quick-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow); transform: translateY(-1px); }
.quick-icon { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 13px; background: var(--accent-soft); color: var(--accent); flex: none; }
.quick-icon svg { width: 23px; height: 23px; }
.quick-icon.idea { background: color-mix(in srgb, var(--c-studio) 16%, transparent); color: var(--c-studio); }
.quick-text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.quick-text strong { font-size: 16px; font-weight: 600; }
.quick-text span { font-size: 13.5px; color: var(--muted); }
.quick-arrow { color: var(--muted); transition: transform .15s, color .15s; }
.quick-card:hover .quick-arrow { transform: translateX(3px); color: var(--accent); }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 26px; }
.stat { padding: 16px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
.stat b { display: block; font-family: var(--serif); font-size: 30px; font-weight: 600; line-height: 1.1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat span { font-size: 13px; color: var(--muted); }

.home-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 6px 8px 8px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 8px; }
.panel-head h2 { font-size: 15.5px; font-weight: 600; }
.panel-head a { font-size: 13.5px; color: var(--accent); font-weight: 550; }
.panel-head a:hover { text-decoration: underline; }

.row-link { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; }
.row-link:hover { background: var(--surface-2); }
.row-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; flex: none; color: var(--cat); background: color-mix(in srgb, var(--cat) 13%, transparent); }
.row-icon svg { width: 19px; height: 19px; }
.row-main { flex: 1; min-width: 0; }
.row-title { display: block; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-meta { display: block; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-link > .chev { color: var(--line-strong); width: 18px; height: 18px; }
.untitled { color: var(--muted); font-style: italic; font-weight: 450; }
.panel-empty { padding: 18px 12px 22px; color: var(--muted); font-size: 14px; }

/* ---------- Report ---------- */
.filters { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.filters-right { display: flex; gap: 10px; align-items: center; }

.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.doc-card {
  position: relative; display: flex; flex-direction: column; min-height: 230px; padding: 18px 20px 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  transition: border-color .15s, box-shadow .2s, transform .15s;
}
.doc-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow); transform: translateY(-2px); }
.doc-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cat-label { display: inline-flex; align-items: center; gap: 7px; font-size: 11.5px; font-weight: 650; letter-spacing: .07em; text-transform: uppercase; color: var(--cat); }
.cat-label i { width: 7px; height: 7px; border-radius: 50%; background: var(--cat); }
.doc-date { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.doc-card h3 {
  margin: 12px 0 8px; font-family: var(--serif); font-size: 19px; font-weight: 600; line-height: 1.3; letter-spacing: -.01em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.doc-excerpt { flex: 1; margin: 0; font-size: 14px; line-height: 1.55; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.doc-foot { display: flex; align-items: center; gap: 8px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted); }
.doc-foot .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); font-weight: 500; }
.tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.tag { font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); }

.empty-state { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; text-align: center; padding: 64px 20px; border: 1.5px dashed var(--line-strong); border-radius: 18px; color: var(--muted); }
.empty-state .quick-icon { width: 56px; height: 56px; border-radius: 16px; margin-bottom: 14px; }
.empty-state .quick-icon svg { width: 28px; height: 28px; }
.empty-state h3 { font-family: var(--serif); font-size: 21px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.empty-state p { margin: 0 0 18px; max-width: 360px; }

/* ---------- Idee: bacheca ---------- */
.board-tabs { display: none; }
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(200px, 1fr); gap: 14px; align-items: start; overflow-x: auto; padding-bottom: 10px; }
.column { background: var(--surface-2); border-radius: 16px; padding: 8px; min-height: 160px; transition: box-shadow .15s, background .15s; }
.column.drag-over { box-shadow: inset 0 0 0 2px var(--accent); background: var(--accent-soft); }
.column-head { display: flex; align-items: center; gap: 8px; padding: 6px 6px 10px 8px; font-weight: 600; font-size: 14px; }
.column-head i { width: 8px; height: 8px; border-radius: 50%; background: var(--dot); }
.column-head .n { font-size: 12px; color: var(--muted); font-weight: 500; }
.column-head .icon-btn { margin-left: auto; width: 30px; height: 30px; border-radius: 8px; }
.column-head .icon-btn svg { width: 17px; height: 17px; }
.column-body { display: flex; flex-direction: column; gap: 8px; min-height: 40px; }
.idea-card {
  display: block; padding: 14px 15px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow-sm); transition: border-color .15s, box-shadow .2s;
}
.idea-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }
.idea-card.dragging { opacity: .45; }
.idea-card h3 { font-family: var(--serif); font-size: 16.5px; font-weight: 600; line-height: 1.3; }
.idea-card p { margin: 6px 0 0; font-size: 13.5px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.idea-foot { display: flex; align-items: center; gap: 6px; margin-top: 10px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.idea-foot .sector { color: var(--text-2); font-weight: 550; }
.column-empty { padding: 14px 8px; text-align: center; font-size: 13px; color: var(--muted); border: 1.5px dashed var(--line-strong); border-radius: 12px; }

/* ---------- Impostazioni ---------- */
.settings { display: flex; flex-direction: column; gap: 14px; max-width: 820px; }
.set-card { display: grid; grid-template-columns: 46px 1fr; gap: 18px; padding: 22px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
.set-icon { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 13px; background: var(--accent-soft); color: var(--accent); }
.set-icon svg { width: 22px; height: 22px; }
.set-body { min-width: 0; }
.set-body h2 { font-size: 17px; font-weight: 600; margin-bottom: 4px; }
.hint { margin: 0 0 14px; color: var(--muted); font-size: 14.5px; }
.set-status { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 14px; padding: 6px 12px; border-radius: 999px; background: var(--surface-2); font-size: 13.5px; }
.set-status i { width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.field.full { grid-column: 1 / -1; }
.row { display: flex; flex-wrap: wrap; gap: 8px; }
.result { margin: 10px 0 0; font-size: 14px; }
.result:empty { display: none; }
.result.ok { color: var(--ok); }
.result.err { color: var(--danger); }
.howto { margin-top: 14px; font-size: 14.5px; }
.howto summary { cursor: pointer; color: var(--accent); font-weight: 550; }
.howto ol { padding-left: 20px; margin: 10px 0 0; color: var(--text-2); }
.howto li { margin-bottom: 4px; }
.howto a { color: var(--accent); text-decoration: underline; }
.qr { display: flex; flex-wrap: wrap; gap: 18px; align-items: center; margin-top: 16px; }
#qr-img { background: #fff; padding: 10px; border-radius: 12px; line-height: 0; border: 1px solid var(--line); }
#qr-img svg { width: 200px; height: 200px; stroke: none; }
.warn { color: var(--warn); font-size: 14px; margin: 0 0 8px; max-width: 280px; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* =========================================================
   Editor
   ========================================================= */
.writer {
  --w-font: var(--serif); --w-size: 18px; --w-width: 780px;
  position: fixed; inset: 0; z-index: 100; display: grid; grid-template-rows: auto auto 1fr auto;
  grid-template-columns: minmax(0, 1fr);
  background: var(--bg); animation: fade .2s ease;
}
.writer[data-font="sans"] { --w-font: var(--sans); }
.writer[data-font="mono"] { --w-font: var(--mono); }
.writer[data-size="s"] { --w-size: 16px; }
.writer[data-size="l"] { --w-size: 20.5px; }
.writer[data-width="wide"] { --w-width: 980px; }

.w-top { display: flex; align-items: center; gap: 8px; height: 56px; padding: 0 12px; background: var(--bg); border-bottom: 1px solid var(--line); }
.w-crumb { flex: 1 1 auto; display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 14px; color: var(--muted); }
.w-crumb .sep { color: var(--line-strong); }
#w-crumb-title { color: var(--text); font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-save { flex: none; padding: 0 8px; }
.w-actions { display: flex; gap: 2px; }

.w-toolbar {
  display: flex; align-items: center; justify-content: center; gap: 2px; padding: 6px 12px;
  background: var(--bg); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none;
}
.w-toolbar::-webkit-scrollbar { display: none; }
.tb {
  display: inline-grid; place-items: center; width: 36px; height: 36px; flex: none;
  border: 0; border-radius: 8px; background: transparent; color: var(--text-2); padding: 0;
}
.tb svg { width: 19px; height: 19px; }
.tb:hover { background: var(--hover); color: var(--text); }
.tb.ql-active { background: var(--accent-soft); color: var(--accent); }
.tb:disabled { opacity: .35; }
.tb-sep { width: 1px; height: 22px; background: var(--line-strong); margin: 0 6px; flex: none; }
.tb-select { height: 34px; border: 0; border-radius: 8px; background: transparent; padding: 0 26px 0 10px; font-size: 14px; font-weight: 550; color: var(--text-2); appearance: none; flex: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b6f6c' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 6px center; background-size: 15px; }
.tb-select:hover { background-color: var(--hover); }
.tb-select option { background: var(--surface); color: var(--text); }

.w-body { display: grid; grid-template-columns: minmax(0, 1fr) auto; min-height: 0; }
.w-scroll { overflow-y: auto; min-height: 0; padding: 36px 24px 30vh; scroll-padding-bottom: 120px; }
.page {
  max-width: var(--w-width); margin: 0 auto; min-height: calc(100% - 20px);
  background: var(--surface); border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--shadow);
  padding: 64px clamp(28px, 7vw, 92px) 96px; transition: max-width .25s ease;
}
.page-meta {
  display: inline-flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; margin: 0 0 10px -8px; padding: 4px 8px;
  border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 13px; text-align: left;
}
.page-meta:hover { background: var(--surface-2); color: var(--text-2); }
.page-meta .cat-label { font-size: 11.5px; }
.page-meta .dotsep { color: var(--line-strong); }
.page-title {
  display: block; width: 100%; border: 0; outline: none; resize: none; overflow: hidden; background: transparent; padding: 0;
  font-family: var(--w-font); font-size: calc(var(--w-size) * 2.1); font-weight: 650; line-height: 1.18; letter-spacing: -.02em; color: var(--text);
  margin-bottom: 26px;
}
.writer[data-font="mono"] .page-title { letter-spacing: -.03em; font-weight: 600; }
.page-title::placeholder { color: var(--line-strong); }

/* Contenuto Quill */
#w-editor { font-family: var(--w-font); font-size: var(--w-size); }
.writer .ql-editor {
  padding: 0; min-height: 50vh; overflow: visible; line-height: 1.75; color: var(--text); tab-size: 4;
  font-family: var(--w-font); font-size: var(--w-size); caret-color: var(--accent);
}
.writer .ql-editor.ql-blank::before { left: 0; right: 0; font-style: normal; color: var(--line-strong); }
.ql-editor p { margin: 0 0 .55em; }
.ql-editor h1, .ql-editor h2, .ql-editor h3 { font-weight: 650; letter-spacing: -.015em; line-height: 1.3; color: var(--text); }
.ql-editor h1 { font-size: 1.65em; margin: 1.3em 0 .45em; }
.ql-editor h2 { font-size: 1.3em; margin: 1.25em 0 .4em; }
.ql-editor h3 { font-size: 1.08em; margin: 1.1em 0 .3em; color: var(--text-2); }
.ql-editor > :first-child { margin-top: 0; }
.ql-editor strong { font-weight: 700; }
.ql-editor a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.ql-editor mark { background: var(--mark); color: inherit; padding: .05em .15em; border-radius: 3px; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.ql-editor blockquote { margin: .9em 0; padding: .1em 0 .1em 1.1em; border-left: 3px solid var(--accent); color: var(--text-2); font-style: italic; }
.ql-editor hr { border: 0; height: 0; margin: 1.8em auto; text-align: center; overflow: visible; }
.ql-editor hr::after { content: "\2022\2002\2022\2002\2022"; display: block; color: var(--muted); letter-spacing: .3em; font-size: .8em; line-height: 1; }
.ql-editor ol { padding-left: 0; margin: 0 0 .6em; }
.ql-editor li { padding-left: 1.6em; margin-bottom: .2em; }
.ql-editor li > .ql-ui::before { width: 1.3em; margin-left: -1.6em; margin-right: .3em; color: var(--accent); font-weight: 600; }
.ql-editor li[data-list="bullet"] > .ql-ui::before { content: "\2022"; font-size: 1.15em; line-height: 1.45; }
.ql-editor li[data-list="checked"], .ql-editor li[data-list="unchecked"] { list-style: none; }
.ql-editor li[data-list="checked"] > .ql-ui, .ql-editor li[data-list="unchecked"] > .ql-ui { cursor: pointer; }
.ql-editor li[data-list="unchecked"] > .ql-ui::before, .ql-editor li[data-list="checked"] > .ql-ui::before {
  content: ""; display: inline-block; width: .95em; height: .95em; margin-right: .65em; margin-left: -1.6em; vertical-align: -.12em;
  border: 1.5px solid var(--line-strong); border-radius: 4px; background: var(--surface);
}
.ql-editor li[data-list="checked"] > .ql-ui::before {
  background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12.5 4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / 80% no-repeat; border-color: var(--accent);
}
.ql-editor li[data-list="checked"] { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line-strong); }
.ql-editor .ql-align-center { text-align: center; }
.ql-editor ::selection, .page-title::selection { background: color-mix(in srgb, var(--mint) 55%, transparent); }

/* Pannello dettagli */
.w-panel { width: 0; overflow: hidden; background: var(--side); border-left: 1px solid transparent; transition: width .22s ease; }
.writer.panel-open .w-panel { width: 320px; border-left-color: var(--line); overflow-y: auto; }
.w-panel-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 12px 6px 20px; }
.w-panel-head h3 { font-size: 15px; font-weight: 600; }
.w-panel-body { width: 320px; padding: 8px 20px 30px; display: flex; flex-direction: column; gap: 14px; }
.p-block { padding-top: 14px; border-top: 1px solid var(--line); }
.p-block h4 { font-size: 12px; font-weight: 650; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.outline { display: flex; flex-direction: column; }
.outline button { border: 0; background: transparent; text-align: left; padding: 5px 8px; border-radius: 7px; font-size: 13.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.outline button:hover { background: var(--hover); color: var(--text); }
.outline .l2 { padding-left: 20px; }
.outline .l3 { padding-left: 32px; font-size: 13px; color: var(--muted); }
.outline-empty { font-size: 13px; color: var(--muted); margin: 0; }
.p-stats { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; margin: 0; font-size: 13.5px; }
.p-stats dt { color: var(--muted); }
.p-stats dd { margin: 0; font-variant-numeric: tabular-nums; text-align: right; }

.tag-input { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-height: 40px; padding: 5px 8px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); }
.tag-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.tag-input input { flex: 1; min-width: 90px; height: 28px; border: 0; outline: none; background: transparent; padding: 0 4px; }
.tag-chip { display: inline-flex; align-items: center; gap: 2px; height: 26px; padding: 0 4px 0 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 13px; font-weight: 550; }
.tag-chip button { display: grid; place-items: center; width: 20px; height: 20px; border: 0; border-radius: 50%; background: transparent; color: inherit; padding: 0; }
.tag-chip button:hover { background: color-mix(in srgb, var(--accent) 18%, transparent); }
.tag-chip svg { width: 13px; height: 13px; stroke-width: 2.2; }

.w-status { display: flex; align-items: center; justify-content: center; gap: 18px; height: 34px; padding: 0 16px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; background: var(--bg); }

/* Modalità concentrazione */
.writer.focus .w-toolbar, .writer.focus .w-status { display: none; }
.writer.focus .w-panel { width: 0; }
.writer.focus .w-top { border-color: transparent; opacity: 0; transition: opacity .3s; }
.writer.focus .w-top:hover, .writer.focus .w-top:focus-within { opacity: 1; }
.writer.focus .page { box-shadow: none; border-color: transparent; background: transparent; }
.writer.focus .w-scroll { padding-top: 12vh; }

/* ---------- Menu ---------- */
.scrim { position: fixed; inset: 0; z-index: 150; background: transparent; }
.menu {
  position: fixed; z-index: 160; min-width: 250px; max-width: calc(100vw - 24px); padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg);
  animation: pop .14s ease;
}
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
.menu-title { margin: 6px 10px 6px; font-size: 12px; font-weight: 650; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.menu-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 10px; border: 0; border-radius: 9px; background: transparent; text-align: left; font-size: 14.5px; }
.menu-item:hover { background: var(--surface-2); }
.menu-item svg { color: var(--muted); }
.menu-item.danger, .menu-item.danger svg { color: var(--danger); }
.menu-item.big { padding: 10px; }
.menu-item.big .quick-icon { width: 40px; height: 40px; border-radius: 11px; }
.menu-item.big span:last-child { display: flex; flex-direction: column; }
.menu-item.big small { color: var(--muted); font-size: 13px; }
.menu hr { border: 0; height: 1px; background: var(--line); margin: 6px 4px; }
#menu-typo { width: 320px; padding: 8px 14px 14px; }
#menu-typo .menu-title { margin: 6px 0 10px; }
.typo-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; font-size: 14px; color: var(--text-2); }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 300;
  background: var(--text); color: var(--bg); padding: 11px 18px; border-radius: 12px; font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-lg); max-width: calc(100% - 32px); animation: pop .2s ease;
}

/* =========================================================
   Tablet
   ========================================================= */
@media (max-width: 1180px) {
  .view { padding: 36px 32px 70px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .home-grid { grid-template-columns: minmax(0, 1fr); }
  .writer.panel-open .w-panel { position: absolute; right: 0; top: 0; bottom: 0; box-shadow: var(--shadow-lg); z-index: 5; }
  .w-body { position: relative; }
}

/* =========================================================
   Telefono
   ========================================================= */
@media (max-width: 820px) {
  body { font-size: 15.5px; }
  .app { display: block; }
  .sidebar { display: none; }
  .hide-phone { display: none !important; }

  .view { padding: 0 16px calc(96px + env(safe-area-inset-bottom)); }
  .mobile-top {
    position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px;
    margin: 0 -16px 14px; padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
    background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  }
  .brand-sm { display: flex; align-items: center; gap: 9px; font-family: var(--serif); font-weight: 600; font-size: 18px; }
  .brand-sm img { border-radius: 7px; }
  .mobile-top .sync { max-width: 55%; padding: 5px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); }

  .hero h1 { font-size: 34px; }
  .lead { font-size: 16px; }
  .view-head { margin-bottom: 16px; align-items: flex-start; flex-direction: column; }
  .view-head h1 { font-size: 32px; }
  .head-actions, .search, .search input { width: 100%; }
  .quick { grid-template-columns: 1fr; gap: 10px; }
  .quick-card { padding: 16px; }
  .stats { gap: 10px; margin-bottom: 18px; }
  .stat { padding: 13px 15px; }
  .stat b { font-size: 26px; }

  .filters { flex-direction: column; align-items: stretch; margin-bottom: 14px; }
  .filters-right { width: 100%; }
  .filters-right .search { flex: 1; }
  .select { flex: none; }
  #report-sort { width: 44px; padding: 0; color: transparent; background-position: center; }
  #report-sort option { color: var(--text); }
  .doc-grid { grid-template-columns: 1fr; gap: 10px; }
  .doc-card { min-height: 0; padding: 16px; }
  .doc-card h3 { font-size: 18px; margin-top: 8px; }
  .doc-excerpt { -webkit-line-clamp: 2; }

  .board-tabs { display: block; margin-bottom: 12px; }
  .board-tabs .segmented { width: 100%; }
  .board { display: block; overflow: visible; }
  .board .column { display: none; background: transparent; padding: 0; }
  .board .column.current { display: block; }
  .board .column-head { display: none; }
  .column-body { gap: 10px; }

  .set-card { grid-template-columns: 1fr; gap: 12px; padding: 18px; }
  .form { grid-template-columns: 1fr; }

  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; display: flex; align-items: stretch;
    height: calc(64px + env(safe-area-inset-bottom)); padding: 0 6px env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--line);
  }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11.5px; font-weight: 550; color: var(--muted); }
  .tabbar a svg { width: 24px; height: 24px; }
  .tabbar a.active { color: var(--accent); }
  .tabbar a.active svg { stroke-width: 2; }
  .fab {
    align-self: center; display: grid; place-items: center; width: 54px; height: 54px; margin: -22px 8px 0; flex: none;
    border: 0; border-radius: 18px; background: var(--accent); color: var(--accent-text); box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 45%, transparent);
  }
  .fab svg { width: 26px; height: 26px; stroke-width: 2.2; }

  /* Menu come fogli dal basso */
  .scrim { background: rgba(0, 0, 0, .35); animation: fade .2s ease; }
  .menu.sheet {
    left: 0 !important; right: 0 !important; top: auto !important; bottom: 0 !important; width: auto !important; max-width: none; min-width: 0;
    border-radius: 22px 22px 0 0; padding: 10px 12px calc(16px + env(safe-area-inset-bottom)); border-bottom: 0;
    animation: slideup .22s cubic-bezier(.2, .8, .2, 1);
  }
  .menu.sheet::before { content: ""; display: block; width: 40px; height: 4px; margin: 0 auto 8px; border-radius: 2px; background: var(--line-strong); }
  .menu-item { padding: 13px 10px; font-size: 16px; }
  @keyframes slideup { from { transform: translateY(100%); } }

  /* Editor su telefono */
  .writer { height: 100dvh; }
  .w-top { height: calc(52px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 6px 0; }
  .w-crumb #w-section, .w-crumb .sep { display: none; }
  .w-save span { display: none; }
  .w-toolbar { justify-content: flex-start; padding: 5px 8px; }
  .tb { width: 40px; height: 40px; }
  .w-scroll { padding: 0 0 40vh; background: var(--surface); }
  .page { border: 0; border-radius: 0; box-shadow: none; padding: 22px 20px 60px; min-height: 100%; background: var(--surface); }
  .writer[data-size="s"] { --w-size: 15.5px; }
  .writer { --w-size: 17px; }
  .writer[data-size="l"] { --w-size: 19.5px; }
  .page-title { font-size: calc(var(--w-size) * 1.75); margin-bottom: 18px; }
  .w-status { height: calc(30px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); gap: 14px; font-size: 12px; }
  .writer.panel-open .w-panel { position: fixed; inset: auto 0 0 0; top: 18vh; width: auto; z-index: 170; border-radius: 22px 22px 0 0; border: 0; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .35); animation: slideup .22s ease; }
  .w-panel-body { width: auto; padding-bottom: calc(30px + env(safe-area-inset-bottom)); }
  .field input, .field select, .search input, .select, .tag-input input { font-size: 16px; }
  #menu-typo { width: auto; }
  .toast { bottom: calc(84px + env(safe-area-inset-bottom)); }
}

/* =========================================================
   Radar Eventi
   ========================================================= */
.mobile-top-right { display: flex; align-items: center; gap: 4px; min-width: 0; }
.ev-summary { margin: 8px 0 0; color: var(--muted); font-size: 15px; }
.danger-text { color: var(--danger); font-weight: 600; }
#ev-refresh.loading svg, #ev-ics.loading svg { animation: spin .9s linear infinite; }
#view-eventi .view-head .head-actions { flex-wrap: nowrap; }
@media (max-width: 820px) {
  #view-eventi .view-head .head-actions { width: 100%; display: grid; grid-template-columns: 1fr 1fr; }
}
@keyframes spin { to { transform: rotate(360deg); } }

.ev-filters { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 26px; flex-wrap: wrap; }
.ev-filters .select { min-width: 170px; }

.ev-timeline { display: flex; flex-direction: column; gap: 30px; }
.ev-group { position: relative; display: flex; flex-direction: column; gap: 10px; }
.ev-group-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 2px; }
.ev-group-head h2 { font-family: var(--serif); font-size: 22px; font-weight: 600; letter-spacing: -.01em; }
.ev-group-head .n, .ev-archive summary .n { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.ev-group.soon { padding: 18px 18px 20px; border-radius: 20px; background: var(--accent-soft); }
.ev-group.soon .ev-group-head h2 { color: var(--accent); }
.ev-group.soon .ev-group-head::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); align-self: center; box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent); }
.ev-empty { margin: 0; padding: 8px 2px; color: var(--muted); font-size: 14px; list-style: none; }

.ev-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; transition: border-color .15s, box-shadow .2s; }
.ev-card:hover { border-color: var(--line-strong); }
.ev-card.open { box-shadow: var(--shadow); border-color: var(--line-strong); }
.ev-card.past { opacity: .92; }
.ev-head { display: flex; align-items: flex-start; gap: 16px; width: 100%; padding: 16px; border: 0; background: transparent; text-align: left; }
.ev-date {
  flex: none; display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 68px; padding: 8px 6px;
  border-radius: 12px; background: color-mix(in srgb, var(--cat) 11%, var(--surface)); color: var(--cat); line-height: 1.1; text-align: center;
}
.ev-date b { font-family: var(--serif); font-size: 24px; font-weight: 650; letter-spacing: -.02em; white-space: nowrap; }
.ev-date span { font-size: 12.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; margin-top: 2px; white-space: nowrap; }
.ev-date small { font-size: 11.5px; color: var(--muted); margin-top: 3px; white-space: nowrap; }
.ev-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.ev-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ev-prio { font-size: 12px; font-weight: 600; color: var(--muted); }
.ev-prio.alta { color: var(--accent); }
.ev-prio.alta::before { content: "\25B2\00a0"; font-size: 9px; vertical-align: 1px; }
.ev-name { font-family: var(--serif); font-size: 19px; font-weight: 600; line-height: 1.3; letter-spacing: -.01em; color: var(--text); }
.ev-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 2px 6px; font-size: 13.5px; color: var(--muted); }
.ev-meta svg { width: 15px; height: 15px; }
.ev-meta .dotsep { color: var(--line-strong); }
.ev-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.ev-badge { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: 999px; font-size: 12.5px; font-weight: 600; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.ev-badge svg { width: 14px; height: 14px; stroke-width: 2; }
.ev-badge.count.soon { background: var(--accent-soft); color: var(--accent); }
.ev-group.soon .ev-badge.count.soon { background: var(--surface-2); }
.ev-badge.count.now { background: var(--accent); color: var(--accent-text); }
.ev-badge.danger { background: var(--danger); color: #fff; }
.ev-badge.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.ev-badge.muted { color: var(--muted); font-weight: 500; }
.ev-badge.stato { background: transparent; box-shadow: inset 0 0 0 1px var(--line-strong); color: var(--muted); }
.ev-badge.s-iscritto { box-shadow: inset 0 0 0 1px var(--accent); color: var(--accent); }
.ev-badge.s-fatto { box-shadow: none; background: var(--surface-2); color: var(--ok); }
.ev-badge.s-saltato { text-decoration: line-through; }
.ev-chevron { flex: none; margin-top: 4px; color: var(--muted); transition: transform .2s; }
.ev-card.open .ev-chevron { transform: rotate(180deg); }

.ev-body { padding: 4px 20px 22px 100px; display: flex; flex-direction: column; gap: 20px; animation: fade .2s ease; }
.ev-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.ev-facts { display: grid; grid-template-columns: 140px 1fr; gap: 10px 18px; margin: 0; padding: 16px 18px; border-radius: 12px; background: var(--bg); font-size: 14.5px; }
.ev-facts dt { color: var(--muted); font-size: 13px; font-weight: 600; padding-top: 1px; }
.ev-facts dd { margin: 0; color: var(--text); }
.ev-body h4 { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-size: 12.5px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.ev-body h4 svg { width: 16px; height: 16px; color: var(--cat); }
.ev-body h4 .n { font-weight: 500; letter-spacing: 0; }
.ev-why p { margin: 0; padding-left: 14px; border-left: 3px solid var(--cat); font-family: var(--serif); font-size: 17px; line-height: 1.55; color: var(--text); }
.ev-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.ev-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; font-size: 14.5px; }
.ev-list li { position: relative; padding-left: 16px; }
.ev-list li::before { content: ""; position: absolute; left: 2px; top: .62em; width: 6px; height: 6px; border-radius: 50%; background: var(--cat); }
.muted { color: var(--muted); }

.ev-work { display: flex; flex-direction: column; gap: 18px; padding-top: 18px; border-top: 1px dashed var(--line-strong); }
.ev-work-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.ev-work-row h4 { margin: 0; }
.ev-contacts, .ev-followups { margin: 0 0 8px; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.ev-contacts li, .ev-followups li { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 10px 12px; border-radius: 10px; background: var(--bg); font-size: 14.5px; }
.ev-contacts li.ev-empty, .ev-followups li.ev-empty { background: transparent; padding: 2px; }
.ev-contacts .icon-btn, .ev-followups .icon-btn { width: 32px; height: 32px; color: var(--muted); }
.ev-contacts .icon-btn svg, .ev-followups .icon-btn svg { width: 17px; height: 17px; }
.ev-contact-link a { color: var(--accent); font-weight: 550; }
.ev-followups label { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; flex: 1; }
.ev-followups input[type="checkbox"] { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.ev-followups li.done > label > span { color: var(--muted); text-decoration: line-through; }
.ev-due { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.ev-due.late { color: var(--danger); font-weight: 600; }
.ev-add summary { display: inline-flex; align-items: center; gap: 6px; list-style: none; cursor: pointer; padding: 6px 10px; margin-left: -10px; border-radius: 8px; color: var(--accent); font-weight: 550; font-size: 14px; }
.ev-add summary::-webkit-details-marker { display: none; }
.ev-add summary:hover { background: var(--accent-soft); }
.ev-add summary svg { width: 16px; height: 16px; }
.ev-form { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.ev-form input { height: 40px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); padding: 0 12px; outline: none; min-width: 0; }
.ev-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.ev-form .wide { grid-column: 1 / -1; }
.ev-form .btn { grid-column: 1 / -1; justify-self: start; }

.ev-archive { border-top: 1px solid var(--line); padding-top: 18px; }
.ev-archive summary { display: flex; align-items: baseline; gap: 10px; list-style: none; cursor: pointer; margin-bottom: 12px; }
.ev-archive summary::-webkit-details-marker { display: none; }
.ev-archive summary h2 { font-family: var(--serif); font-size: 22px; font-weight: 600; }
.ev-archive summary .ev-chevron { margin-left: auto; align-self: center; }
.ev-archive[open] > summary .ev-chevron { transform: rotate(180deg); }
.ev-archive .ev-card { margin-bottom: 10px; }

.ev-loading { display: flex; flex-direction: column; gap: 12px; }
.ev-loading span { height: 110px; border-radius: 16px; background: linear-gradient(90deg, var(--surface-2), var(--surface), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

.home-side { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.row-icon.ev-mini { flex-direction: column; width: 44px; height: 44px; line-height: 1; gap: 1px; }
.row-icon.ev-mini b { font-family: var(--serif); font-size: 15px; font-weight: 650; white-space: nowrap; }
.row-icon.ev-mini span { font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; max-width: 42px; overflow: hidden; }

@media (max-width: 1180px) {
  .ev-body { padding-left: 20px; }
}
@media (max-width: 820px) {
  .mobile-top-right .icon-btn { width: 36px; height: 36px; }
  .mobile-top .sync { max-width: none; }
  .mobile-top-right { max-width: 62%; }
  .mobile-top-right .sync span { max-width: 150px; }
  .ev-filters { flex-direction: column; align-items: stretch; margin-bottom: 18px; }
  .ev-filters .filters-right { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .ev-filters .select { min-width: 0; width: 100%; }
  .ev-timeline { gap: 24px; }
  .ev-group.soon { margin: 0 -8px; padding: 14px 8px 10px; border-radius: 18px; }
  .ev-head { gap: 12px; padding: 14px 12px; }
  .ev-date { min-width: 56px; padding: 7px 4px; }
  .ev-date b { font-size: 20px; }
  .ev-name { font-size: 17.5px; }
  .ev-chevron { display: none; }
  .ev-body { padding: 0 14px 18px; gap: 18px; }
  .ev-actions .btn { flex: 1 1 auto; }
  .ev-facts { grid-template-columns: 1fr; gap: 2px; padding: 14px; }
  .ev-facts dd { margin-bottom: 10px; }
  .ev-facts dd:last-child { margin-bottom: 0; }
  .ev-cols { grid-template-columns: 1fr; }
  .ev-work-row .segmented { width: 100%; }
  .ev-form { grid-template-columns: 1fr; }
  .ev-form input { font-size: 16px; }
  .ev-form .btn { justify-self: stretch; }
}

/* =========================================================
   Progetto cyber (sobrio: si usa, non si mostra)
   ========================================================= */
.cy-counter {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 24px;
  padding: 20px 24px; margin-bottom: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
}
.cy-counter-main { display: flex; flex-direction: column; line-height: 1; }
.cy-counter-main b { font-family: var(--serif); font-size: 64px; font-weight: 600; letter-spacing: -.03em; color: var(--accent); font-variant-numeric: tabular-nums; }
.cy-counter-main span { margin-top: 6px; font-size: 14px; color: var(--muted); }
.cy-counter-side { display: flex; gap: 28px; margin: 0; flex-wrap: wrap; }
.cy-counter-side div { display: flex; flex-direction: column; gap: 2px; }
.cy-counter-side dt { font-size: 12.5px; color: var(--muted); }
.cy-counter-side dd { margin: 0; font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.cy-new { height: 46px; padding: 0 18px; font-size: 15px; }

.cy-warn { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: 10px; background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--text); font-size: 14px; }
.cy-warn svg { color: var(--warn); width: 18px; height: 18px; }
.cy-toolbar { margin: 4px 0 18px; }
.cy-toolbar .select { min-width: 240px; }

.cy-month { margin-bottom: 22px; }
.cy-month h2 { display: flex; align-items: baseline; gap: 8px; margin: 0 0 8px; font-size: 13px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.cy-month h2 span { font-weight: 500; letter-spacing: 0; }
.cy-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.cy-list li + li { border-top: 1px solid var(--line); }
.cy-row { display: flex; gap: 16px; padding: 14px 18px; }
.cy-row:hover { background: var(--surface-2); }
.cy-date { flex: none; width: 56px; font-size: 13.5px; font-weight: 600; color: var(--muted); padding-top: 1px; font-variant-numeric: tabular-nums; }
.cy-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.cy-who { font-size: 14px; color: var(--text-2); display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.cy-who b { color: var(--text); }
.cy-recall svg { width: 15px; height: 15px; color: var(--accent); vertical-align: -2px; }
.cy-quote { font-family: var(--serif); font-size: 16px; line-height: 1.45; color: var(--text); }
.cy-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.cy-tag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.cy-tag.conferma { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.cy-tag.smentisce { background: color-mix(in srgb, var(--danger) 13%, transparent); color: var(--danger); }

.cy-back { display: inline-flex; align-items: center; gap: 4px; margin: -8px 0 14px -6px; padding: 6px; border-radius: 8px; color: var(--muted); font-size: 14px; font-weight: 550; }
.cy-back:hover { color: var(--text); background: var(--hover); }
.cy-back svg { width: 18px; height: 18px; }
.cy-detail { max-width: 760px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 24px 28px; }
.cy-detail header { margin-bottom: 18px; }
.cy-detail-date { margin: 0 0 4px; font-size: 13px; color: var(--muted); }
.cy-detail-date::first-letter { text-transform: uppercase; }
.cy-detail h2 { font-family: var(--serif); font-size: 26px; font-weight: 600; }
.cy-detail-meta { margin: 6px 0 0; color: var(--muted); font-size: 14.5px; }
.cy-detail section { padding: 16px 0; border-top: 1px solid var(--line); }
.cy-detail h3 { margin: 0 0 8px; font-size: 12.5px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.cy-detail blockquote { margin: 0; padding-left: 14px; border-left: 3px solid var(--accent); font-family: var(--serif); font-size: 18px; line-height: 1.6; white-space: pre-wrap; }
.cy-pre { margin: 0; white-space: pre-wrap; line-height: 1.6; }
.cy-ass { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.cy-ass li { display: flex; gap: 10px; align-items: flex-start; font-size: 14.5px; }
.cy-actions { display: flex; gap: 8px; padding-top: 16px; border-top: 1px solid var(--line); }

/* Registrazione guidata */
.cy-wizard {
  position: fixed; inset: 0; z-index: 110; display: grid; grid-template-rows: auto 1fr auto;
  background: var(--bg); animation: fade .15s ease; height: 100vh; height: 100dvh;
}
.cy-w-top { display: flex; align-items: center; gap: 12px; padding: calc(8px + env(safe-area-inset-top)) 12px 8px; border-bottom: 1px solid var(--line); }
.cy-progress { flex: 1; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.cy-progress span { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width .2s ease; }
.cy-step { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 38px; text-align: right; }
.cy-w-body { width: 100%; max-width: 640px; margin: 0 auto; padding: 32px 20px 24px; overflow-y: auto; }
.cy-w-body h2 { font-family: var(--serif); font-size: 28px; font-weight: 600; line-height: 1.2; margin-bottom: 8px; }
.cy-help { margin: 0 0 16px; color: var(--muted); font-size: 15px; }
.cy-input { width: 100%; margin-top: 10px; padding: 12px 14px; border: 1.5px solid var(--line-strong); border-radius: 12px; background: var(--surface); font-size: 18px; outline: none; }
.cy-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.cy-initials { max-width: 180px; font-size: 26px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.cy-text { min-height: 38vh; resize: vertical; font-family: var(--serif); line-height: 1.55; }
.cy-choices { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.cy-choice { height: 54px; padding: 0 18px; border: 1.5px solid var(--line-strong); border-radius: 12px; background: var(--surface); font-size: 17px; font-weight: 550; text-align: left; }
.cy-choice:hover { border-color: var(--accent); }
.cy-choice.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.cy-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.cy-chip { height: 38px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface); font-size: 15px; }
.cy-chip.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.cy-ass-pick { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.cy-ass-pick li { padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.cy-ass-pick p { margin: 0 0 10px; font-size: 15px; line-height: 1.45; }
.cy-ass-pick .segmented { width: 100%; }
.cy-ass-pick .segmented button { flex: 1; justify-content: center; }
.cy-grav { display: inline-block; margin-right: 4px; padding: 1px 7px; border-radius: 6px; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; background: var(--surface-2); color: var(--muted); }
.cy-grav.fatale { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.cy-grav.seria { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.cy-summary pre { margin: 12px 0 0; padding: 16px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); white-space: pre-wrap; word-break: break-word; font-family: var(--mono); font-size: 13.5px; line-height: 1.55; }
.cy-msg { display: flex; gap: 10px; margin-top: 14px; padding: 12px 14px; border-radius: 12px; font-size: 14.5px; line-height: 1.5; }
.cy-msg svg { flex: none; width: 20px; height: 20px; margin-top: 1px; }
.cy-msg.err { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.cy-msg.warn { background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--text); }
.cy-msg.warn svg { color: var(--warn); }
.cy-w-foot { display: flex; justify-content: space-between; gap: 10px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--bg); }
.cy-w-foot .btn { height: 48px; font-size: 16px; }
.cy-w-foot .btn.primary { flex: 1; max-width: 320px; margin-left: auto; }

@media (max-width: 820px) {
  .cy-counter { grid-template-columns: 1fr; gap: 14px; padding: 18px; }
  .cy-counter-main b { font-size: 56px; }
  .cy-counter-side { gap: 18px; }
  .cy-counter-side dd { font-size: 18px; }
  .cy-new { width: 100%; }
  .cy-toolbar .select { width: 100%; min-width: 0; }
  .cy-row { gap: 12px; padding: 14px; }
  .cy-date { width: 46px; font-size: 13px; }
  .cy-quote { font-size: 15.5px; }
  .cy-detail { padding: 18px; }
  .cy-detail h2 { font-size: 22px; }
  .cy-w-body { padding: 22px 16px; }
  .cy-w-body h2 { font-size: 24px; }
  .cy-input { font-size: 17px; }
  .cy-text { min-height: 34vh; }
}

/* =========================================================
   Spazio di lavoro: giornata, liste to-do, startup e griglie
   ========================================================= */
.quick { grid-template-columns: repeat(3, 1fr); }
.quick-icon.day, .menu-item.big .quick-icon.day { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.quick-icon.cyber { background: color-mix(in srgb, var(--c-ricerca) 15%, transparent); color: var(--c-ricerca); }
.side-sub-todo { margin-top: -6px; }
.side-sub-todo a svg { width: 16px; height: 16px; }
.side-sub-todo a.active { box-shadow: none; background: var(--hover); }
.segmented a { display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 13px; flex: none; border-radius: 8px; color: var(--muted); font-weight: 550; font-size: 14px; }
.segmented a:hover { color: var(--text); }
.segmented a[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.segmented a svg { width: 17px; height: 17px; }
.sp-tabs { margin: -8px 0 22px; }
.btn.small { height: 32px; padding: 0 11px; font-size: 13.5px; border-radius: 9px; gap: 6px; }
.btn.small svg { width: 16px; height: 16px; }
.btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.eyebrow a:hover { text-decoration: underline; }
.sp-check-box { display: grid; place-items: center; width: 28px; height: 28px; flex: none; cursor: pointer; }
.sp-check-box input { width: 19px; height: 19px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.sp-menu .menu-item.on { font-weight: 600; }
.sp-menu .sp-check { margin-left: auto; color: var(--accent); }
.sp-menu-dot { width: 20px; flex: none; }
.sp-menu { max-height: 80vh; overflow-y: auto; }

/* Giornata */
#view-giornata .view-head, #view-todo .view-head { margin-bottom: 18px; }
.gi-nav { display: flex; align-items: center; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; max-width: 820px; }
.gi-nav .gi-next svg { transform: rotate(180deg); }
.gi-picker { position: relative; display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; color: var(--text-2); cursor: pointer; margin-left: auto; }
.gi-picker:hover { background: var(--hover); }
.gi-picker input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.gi-picker input::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: 100%; height: 100%; cursor: pointer; }
.gi-card { max-width: 820px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 20px 22px 14px; margin-bottom: 16px; }
.gi-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.gi-head h2 { font-family: var(--serif); font-size: 30px; font-weight: 600; letter-spacing: -.02em; line-height: 1.1; }
.gi-data { margin: 0 0 2px; font-size: 13.5px; color: var(--muted); }
.gi-count { font-size: 15px; color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.gi-count b { font-family: var(--serif); font-size: 26px; color: var(--accent); }
.gi-count span { display: block; font-size: 12px; }
.gi-head.small { align-items: center; margin-bottom: 8px; }
.gi-head h3 { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; }
.gi-head h3 svg { color: var(--warn); width: 18px; height: 18px; }
.gi-head h3 span { color: var(--muted); font-weight: 500; }
.gi-add { display: flex; align-items: center; gap: 8px; padding: 6px; border: 1.5px solid var(--line-strong); border-radius: 13px; background: var(--bg); margin-bottom: 8px; }
.gi-add:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--surface); }
.gi-add input[name="testo"] { flex: 1; min-width: 0; height: 40px; border: 0; outline: none; background: transparent; font-size: 16px; padding: 0 6px; }
.gi-add .gi-ora { border: 0; background: var(--surface-2); height: 36px; }
.gi-add.compact { margin: 4px 8px 6px; padding: 3px 3px 3px 6px; border-width: 1px; }
.gi-add.compact input[name="testo"] { height: 36px; font-size: 15px; }
.gi-ora { width: 92px; height: 32px; padding: 0 6px; border: 1px solid transparent; border-radius: 8px; background: transparent; font-size: 14px; font-variant-numeric: tabular-nums; color: var(--accent); font-weight: 600; outline: none; flex: none; }
.gi-ora:hover, .gi-ora:focus { border-color: var(--line-strong); background: var(--surface); }
.gi-ora::-webkit-calendar-picker-indicator { display: none; }
/* Orario vuoto: solo l'icona dell'orologio (si tocca per scegliere l'ora) */
.gi-ora.vuota:not(:focus) { width: 34px; color: transparent; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239ba19e' stroke-width='1.8' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='8.5'/%3E%3Cpath d='M12 7.5V12l3 2'/%3E%3C/svg%3E") center / 17px no-repeat; cursor: pointer; }
.gi-add .gi-ora.vuota:not(:focus) { width: 40px; background-color: var(--surface-2); }
.gi-ora.vuota::-webkit-datetime-edit { opacity: 0; }
.gi-ora.vuota:focus::-webkit-datetime-edit { opacity: 1; }
.gi-list { list-style: none; margin: 0; padding: 0; }
.gi-item { display: flex; align-items: center; gap: 4px; padding: 3px 2px; }
.gi-item + .gi-item { border-top: 1px solid var(--line); }
.gi-item .gi-testo { flex: 1; min-width: 0; height: 38px; border: 0; border-radius: 8px; background: transparent; padding: 0 8px; font-size: 15.5px; outline: none; }
.gi-item .gi-testo:focus { background: var(--bg); box-shadow: inset 0 0 0 1px var(--line-strong); }
.gi-item.done .gi-testo, .gi-item.done .gi-ora { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line-strong); }
.gi-item .icon-btn { width: 34px; height: 34px; color: var(--muted); opacity: .6; }
.gi-item:hover .icon-btn, .gi-item .icon-btn:focus { opacity: 1; }
.gi-quando { font-size: 12.5px; color: var(--danger); font-weight: 600; white-space: nowrap; }
.gi-empty { margin: 10px 4px 14px; color: var(--muted); }
.gi-fatti { margin-top: 8px; border-top: 1px dashed var(--line-strong); padding-top: 8px; }
.gi-fatti summary, .td-fatte summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--muted); padding: 6px 4px; list-style: none; }
.gi-fatti summary::-webkit-details-marker, .td-fatte summary::-webkit-details-marker { display: none; }
.gi-fatti summary::before, .td-fatte summary::before { content: "▸ "; }
.gi-fatti[open] summary::before, .td-fatte[open] summary::before { content: "▾ "; }
.gi-old { border-color: color-mix(in srgb, var(--warn) 40%, var(--line)); background: color-mix(in srgb, var(--warn) 5%, var(--surface)); }
.gi-bot { display: flex; align-items: center; gap: 10px; max-width: 820px; margin: 4px 0 0; color: var(--muted); font-size: 13.5px; }
.gi-bot svg { width: 18px; height: 18px; color: var(--accent); }
.gi-list.compact { padding: 0 8px 6px; }
.gi-list.compact .gi-item { padding: 5px 4px; }
.gi-ora-txt { font-size: 13px; font-weight: 600; color: var(--accent); font-variant-numeric: tabular-nums; }
.gi-testo-txt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-left: 4px; }
.gi-more { display: flex; justify-content: space-between; gap: 10px; margin: 0; padding: 4px 12px 10px; font-size: 13px; }
.gi-more a { color: var(--accent); font-weight: 550; }

/* Liste to-do */
.td-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.td-card { display: flex; flex-direction: column; min-height: 200px; padding: 18px 20px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); transition: border-color .15s, box-shadow .2s, transform .15s; }
.td-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow); transform: translateY(-2px); }
.td-card-top { display: flex; align-items: center; justify-content: space-between; }
.td-card h3 { margin: 10px 0 8px; font-family: var(--serif); font-size: 19px; font-weight: 600; line-height: 1.3; }
.td-preview { flex: 1; margin: 0; padding: 0; list-style: none; font-size: 14px; color: var(--text-2); }
.td-preview li { position: relative; padding: 2px 0 2px 22px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.td-preview li::before { content: ""; position: absolute; left: 2px; top: 6px; width: 11px; height: 11px; border: 1.5px solid var(--line-strong); border-radius: 3px; }
.td-preview li.muted::before { display: none; }
.td-preview li.muted { padding-left: 0; }
.td-card-foot { display: flex; align-items: center; gap: 10px; margin-top: 14px; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.td-bar { flex: 1; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.td-bar span { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width .25s ease; }

.sp-sheet { max-width: 780px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 22px 26px 20px; }
.sp-sheet-top { display: flex; align-items: center; justify-content: space-between; margin: -6px -10px 4px 0; }
.sp-title { display: block; width: 100%; border: 0; outline: none; resize: none; overflow: hidden; background: transparent; padding: 0; margin: 0 0 12px; font-family: var(--serif); font-size: 32px; font-weight: 600; line-height: 1.2; letter-spacing: -.02em; color: var(--text); }
.sp-title::placeholder { color: var(--line-strong); }
.td-progress { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--muted); margin-bottom: 14px; font-variant-numeric: tabular-nums; }
.td-progress .td-bar { max-width: 240px; }
.td-list { list-style: none; margin: 0; padding: 0; }
.td-item { display: flex; align-items: flex-start; gap: 6px; padding: 4px 0; border-bottom: 1px solid var(--line); }
.td-item .sp-check-box { margin-top: 5px; }
.td-testo { flex: 1; min-width: 0; min-height: 38px; border: 0; outline: none; resize: none; overflow: hidden; background: transparent; padding: 8px 6px; font-size: 16px; line-height: 1.4; border-radius: 8px; }
.td-testo:focus { background: var(--bg); }
.td-item.done .td-testo { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line-strong); }
.td-item .icon-btn { margin-top: 2px; width: 34px; height: 34px; color: var(--muted); opacity: 0; }
.td-item:hover .icon-btn, .td-item:focus-within .icon-btn { opacity: 1; }
.td-add { display: flex; align-items: center; gap: 6px; padding: 6px 0; }
.td-plus { display: grid; place-items: center; width: 28px; height: 28px; color: var(--accent); }
.td-plus svg { width: 18px; height: 18px; }
.td-add input { flex: 1; min-width: 0; height: 40px; border: 0; outline: none; background: transparent; font-size: 16px; padding: 0 6px; border-radius: 8px; }
.td-add input:focus { background: var(--bg); }
.td-fatte { margin-top: 10px; }

/* Griglie */
.gr-sheet { max-width: none; padding-bottom: 12px; }
.gr-tools { display: flex; flex-wrap: wrap; gap: 6px; }
.gr-help { margin-top: 12px; padding: 12px 16px; border-radius: 12px; background: var(--bg); font-size: 14px; color: var(--text-2); }
.gr-help p { margin: 0 0 6px; }
.gr-help ul { margin: 0 0 8px; padding-left: 18px; }
.gr-help code { font-family: var(--mono); font-size: 12.5px; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
.gr-scroll { margin: 16px -26px 0; overflow: auto; max-height: calc(100vh - 230px); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.gr-table { border-collapse: separate; border-spacing: 0; min-width: 100%; font-size: 14.5px; font-variant-numeric: tabular-nums; }
.gr-table th, .gr-table td { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 0; background: var(--surface); }
.gr-table thead th { position: sticky; top: 0; z-index: 2; background: var(--surface-2); text-align: left; min-width: 150px; vertical-align: top; }
.gr-table thead th.f-testo { min-width: 200px; }
.gr-table .gr-corner, .gr-table .gr-rownum { position: sticky; left: 0; z-index: 1; width: 46px; min-width: 46px; background: var(--surface-2); text-align: center; }
.gr-table thead .gr-corner { z-index: 3; min-width: 46px; }
.gr-colhead { display: flex; align-items: center; gap: 2px; padding: 5px 4px 0 8px; }
.gr-letter { font-size: 11px; font-weight: 700; color: var(--muted); width: 14px; flex: none; }
.gr-colname { flex: 1; min-width: 0; height: 30px; border: 0; outline: none; background: transparent; font-weight: 650; font-size: 14px; padding: 0 4px; border-radius: 6px; }
.gr-colname:focus { background: var(--surface); box-shadow: inset 0 0 0 1px var(--accent); }
.gr-menu-btn { display: grid; place-items: center; width: 26px; height: 26px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); padding: 0; flex: none; }
.gr-menu-btn:hover { background: var(--hover); color: var(--text); }
.gr-menu-btn svg { width: 15px; height: 15px; }
.gr-format { display: block; padding: 0 8px 5px 26px; font-size: 11px; font-weight: 500; color: var(--muted); }
.gr-rownum button { width: 100%; height: 36px; border: 0; background: transparent; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.gr-rownum button:hover { background: var(--hover); color: var(--text); }
.gr-cell { display: block; width: 100%; min-width: 0; height: 36px; border: 0; outline: none; background: transparent; padding: 0 10px; font-size: 14.5px; font-variant-numeric: tabular-nums; }
.gr-cell:focus { box-shadow: inset 0 0 0 2px var(--accent); background: var(--surface); position: relative; z-index: 1; font-family: var(--mono); font-size: 13.5px; }
.gr-table td.f-numero .gr-cell, .gr-table td.f-euro .gr-cell, .gr-table td.f-percentuale .gr-cell, .gr-table tfoot td { text-align: right; }
.gr-table td.f-numero .gr-cell:focus, .gr-table td.f-euro .gr-cell:focus, .gr-table td.f-percentuale .gr-cell:focus { text-align: left; }
.gr-table td.formula { background: color-mix(in srgb, var(--accent) 4%, var(--surface)); }
.gr-table td.formula .gr-cell:not(:focus) { color: var(--accent); font-weight: 550; }
.gr-table td.err .gr-cell:not(:focus) { color: var(--danger); font-weight: 600; }
.gr-table tr.attiva > th { background: var(--accent-soft); }
.gr-table tr.attiva > th button { color: var(--accent); font-weight: 700; }
.gr-table tfoot td, .gr-table tfoot th { position: sticky; bottom: 0; background: var(--surface-2); font-weight: 700; height: 38px; padding: 0 10px; border-top: 1px solid var(--line-strong); white-space: nowrap; }
.gr-table tfoot th { z-index: 2; font-size: 12px; color: var(--muted); padding: 0; }
.gr-foot { margin: 10px 0 0; font-size: 12.5px; color: var(--muted); }

/* Startup */
.sp-bar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.sp-bar-text { margin: 0; color: var(--muted); font-size: 14.5px; }
.st-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.st-card { display: flex; flex-direction: column; min-height: 190px; padding: 18px 20px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); transition: border-color .15s, box-shadow .2s, transform .15s; }
.st-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow); transform: translateY(-2px); }
.st-folder { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; color: var(--cat); background: color-mix(in srgb, var(--cat) 14%, transparent); flex: none; }
.st-folder svg { width: 24px; height: 24px; }
.st-folder.big { width: 56px; height: 56px; border-radius: 15px; }
.st-folder.big svg { width: 30px; height: 30px; }
.st-card h3 { margin: 12px 0 4px; font-family: var(--serif); font-size: 20px; font-weight: 600; line-height: 1.25; }
.st-card p { flex: 1; margin: 0; font-size: 14px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.st-foot { display: flex; justify-content: space-between; gap: 8px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted); }
.st-head { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.st-head-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.st-name { width: 100%; border: 0; outline: none; background: transparent; padding: 2px 6px; margin-left: -6px; border-radius: 8px; font-family: var(--serif); font-size: 30px; font-weight: 600; letter-spacing: -.02em; color: var(--text); }
.st-desc { width: 100%; border: 0; outline: none; background: transparent; padding: 2px 6px; margin-left: -6px; border-radius: 8px; font-size: 15px; color: var(--text-2); }
.st-name:hover, .st-desc:hover, .st-name:focus, .st-desc:focus { background: var(--surface); box-shadow: inset 0 0 0 1px var(--line-strong); }
.st-name::placeholder, .st-desc::placeholder { color: var(--line-strong); }
.st-new { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 26px; }
.st-new-btn { display: flex; align-items: center; gap: 12px; padding: 14px; border: 1px dashed var(--line-strong); border-radius: 14px; background: transparent; text-align: left; transition: border-color .15s, background .15s; }
.st-new-btn:hover { border-color: var(--cat); background: var(--surface); border-style: solid; }
.st-new-btn > span:last-child { display: flex; flex-direction: column; }
.st-new-btn strong { font-size: 14.5px; font-weight: 600; }
.st-new-btn small { font-size: 12.5px; color: var(--muted); }
.st-files h2 { display: flex; align-items: baseline; gap: 8px; margin: 0 0 10px; font-size: 13px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.st-files h2 span { font-weight: 500; letter-spacing: 0; }
.st-row { display: flex; align-items: center; padding-right: 8px; }
.st-row:hover { background: var(--surface-2); }
.st-row > a { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 12px 16px; }
.st-row .icon-btn { color: var(--muted); }

@media (max-width: 820px) {
  .quick { grid-template-columns: 1fr; }
  .tabbar a { font-size: 10.5px; }
  .fab { margin: -22px 4px 0; width: 50px; height: 50px; }
  .sp-tabs { width: 100%; margin: -4px 0 16px; }
  .sp-tabs a { flex: 1; justify-content: center; padding: 0 8px; font-size: 13.5px; }
  .sp-tabs a svg { display: none; }
  .gi-nav .segmented { flex: 1; }
  .gi-nav .segmented a { flex: 1; justify-content: center; }
  .gi-picker { margin-left: 0; }
  .gi-card { padding: 16px 12px 10px; border-radius: 16px; margin-left: -4px; margin-right: -4px; }
  .gi-head h2 { font-size: 26px; }
  .gi-add .gi-ora { width: 78px; }
  .gi-ora { width: 64px; font-size: 13px; padding: 0 2px; }
  .gi-head.small { flex-wrap: wrap; }
  .gi-old .gi-item { flex-wrap: wrap; }
  .gi-old .gi-item .gi-testo { flex: 1 1 calc(100% - 80px); }
  .gi-old .gi-item .gi-quando { margin-left: auto; }
  .gi-item .gi-testo { font-size: 16px; padding: 0 4px; }
  .gi-item .icon-btn, .td-item .icon-btn { opacity: 1; }
  .gi-item .btn.small { padding: 0 8px; }
  .sp-sheet { padding: 16px 14px; border-radius: 16px; margin-left: -4px; margin-right: -4px; }
  .sp-title { font-size: 26px; }
  .gr-scroll { margin: 14px -14px 0; max-height: calc(100dvh - 250px); }
  .gr-table thead th { min-width: 120px; }
  .gr-table thead th.f-testo { min-width: 150px; }
  .gr-table .gr-corner, .gr-table .gr-rownum, .gr-table thead .gr-corner { width: 36px; min-width: 36px; }
  .gr-cell { font-size: 16px; height: 40px; }
  .gr-cell:focus { font-size: 15px; }
  .gr-tools { flex-wrap: nowrap; overflow-x: auto; margin: 0 -14px; padding: 0 14px 2px; scrollbar-width: none; }
  .gr-tools::-webkit-scrollbar { display: none; }
  .sp-bar .btn { width: 100%; }
  .st-grid, .td-grid { grid-template-columns: 1fr; gap: 10px; }
  .st-card, .td-card { min-height: 0; }
  .st-head { gap: 12px; }
  .st-folder.big { width: 46px; height: 46px; }
  .st-name { font-size: 24px; }
  .st-new { grid-template-columns: 1fr; gap: 8px; }
  .st-new-btn { padding: 10px 12px; }
}

/* =========================================================
   Stampa / PDF
   ========================================================= */
@media print {
  @page { margin: 22mm 20mm; }
  :root { --bg: #fff; --surface: #fff; --text: #111; --text-2: #222; --muted: #555; --line: #ddd; --line-strong: #bbb; --accent: #1f4e46; --mark: #d6efe7; }
  body { background: #fff; }
  .app, .tabbar, .scrim, .menu, .toast, .cy-wizard, .w-top, .w-toolbar, .w-panel, .w-status { display: none !important; }
  .writer { position: static; display: block; background: #fff; animation: none; }
  .w-body, .w-scroll { display: block; overflow: visible; padding: 0; }
  .page { max-width: none; border: 0; box-shadow: none; padding: 0; margin: 0; min-height: 0; }
  .page-meta { margin-left: 0; padding-left: 0; }
  .ql-editor { min-height: 0; }
  .ql-editor h1, .ql-editor h2, .ql-editor h3 { break-after: avoid; }
}
