/* Mio Calendario. Usa solo i token di tokens.css. */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: var(--fs-sm)/var(--lh-sm) var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2 { margin: 0; }
.icon { flex: none; display: block; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: var(--s2); top: var(--s2); z-index: 100; background: var(--bg); padding: var(--s2); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --- guscio ------------------------------------------------------------- */
.app {
  height: 100dvh;
  display: grid;
  grid-template: "top" calc(var(--header-h) + env(safe-area-inset-top)) "main" minmax(0, 1fr) "tabs" calc(var(--tabbar-h) + env(safe-area-inset-bottom)) / minmax(0, 1fr);
}
.topbar {
  grid-area: top;
  display: flex; align-items: center; gap: var(--s2);
  padding: env(safe-area-inset-top) max(var(--s3), env(safe-area-inset-right)) 0 max(var(--s3), env(safe-area-inset-left));
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.brand { display: flex; align-items: center; gap: var(--s2); font-size: var(--fs-lg); font-weight: 600; color: var(--text); margin-right: var(--s4); white-space: nowrap; }
.brand .icon { color: var(--accent); }
.period { font-size: var(--fs-lg); line-height: var(--lh-lg); font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-arrows { display: flex; }
.view-select select {
  height: 36px; padding: 0 var(--s6) 0 var(--s3);
  border: 1px solid var(--border-input); border-radius: var(--r-md);
  background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237b838e' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center;
  appearance: none; font-size: var(--fs-sm); font-weight: 600;
}
.sidebar { display: none; }
.main { grid-area: main; overflow: auto; min-height: 0; position: relative; outline: none; }
.tabbar {
  grid-area: tabs;
  display: grid; grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--border); background: var(--bg);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--text-muted); text-decoration: none; font-size: 11px; font-weight: 600;
}
.tabbar a[aria-current] { color: var(--accent); }
.desktop-only { display: none !important; }
@media (max-width: 899px) {
  .topbar { gap: var(--s1); }
  .period { font-size: var(--fs-base); }
  .view-select select { padding: 0 var(--s5) 0 var(--s2); background-position: right 4px center; }
}

.fab {
  position: fixed; z-index: 20;
  right: max(var(--s4), env(safe-area-inset-right));
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--s4));
  width: 56px; height: 56px; border-radius: var(--r-lg); border: 0;
  display: grid; place-items: center;
  background: var(--accent); color: var(--on-accent); box-shadow: var(--shadow-pop);
  transition: transform var(--t-fast) var(--ease);
}
.fab:active { transform: scale(.94); }
body:not([data-section="cal"]) .fab { display: none; }

@media (min-width: 900px) {
  .app {
    grid-template: "top top" var(--header-h) "side main" minmax(0, 1fr) / var(--sidebar-w) minmax(0, 1fr);
  }
  body.sidebar-hidden .app { grid-template-columns: 0 minmax(0, 1fr); }
  body.sidebar-hidden .sidebar, body.sidebar-hidden .tabbar { visibility: hidden; }
  .desktop-only { display: flex !important; }
  .mobile-only { display: none !important; }
  .tabbar {
    grid-area: side; align-self: end;
    display: flex; flex-direction: column; border-top: 1px solid var(--border); padding: var(--s2);
    position: relative; z-index: 1;
  }
  .tabbar a { flex-direction: row; justify-content: flex-start; gap: var(--s3); padding: var(--s2) var(--s3); border-radius: var(--r-pill); font-size: var(--fs-sm); }
  .tabbar a[aria-current] { background: var(--accent-soft); color: var(--on-accent-soft); }
  .tabbar a:hover:not([aria-current]) { background: var(--surface); }
  .sidebar { grid-area: side; display: flex; flex-direction: column; gap: var(--s4); padding: var(--s3) var(--s3) 200px; overflow: auto; }
  .create { align-self: flex-start; height: 48px; padding: 0 var(--s5) 0 var(--s4); box-shadow: var(--shadow-card); }
}

/* --- pulsanti e campi ---------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  height: 40px; padding: 0 var(--s4); border-radius: var(--r-md); border: 1px solid transparent;
  font-weight: 600; white-space: nowrap; background: none;
  transition: background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn.sm { height: 32px; padding: 0 var(--s3); }
.btn.primary { background: var(--accent); color: var(--on-accent); border-radius: var(--r-pill); }
.btn.secondary { border-color: var(--border-input); background: var(--bg); }
.btn.secondary:hover, .btn.ghost:hover { background: var(--surface); }
.btn.ghost { color: var(--accent); }
.btn.danger-ghost { color: var(--danger); }
.btn.danger-ghost:hover { background: var(--surface); }
.btn.wide { width: 100%; }
.icon-btn {
  width: 40px; height: 40px; border-radius: var(--r-pill); border: 0; background: none;
  display: inline-grid; place-items: center; color: var(--text-muted);
}
.icon-btn:hover { background: var(--surface); color: var(--text); }
.icon-btn.sm { width: 28px; height: 28px; }

.input {
  width: 100%; min-height: 44px; padding: var(--s2) var(--s3);
  border: 1px solid var(--border-input); border-radius: var(--r-md);
  background: var(--bg); font-size: var(--fs-base); /* 16px: iOS non zooma */
}
.input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.input[aria-invalid="true"] { border-color: var(--danger); }
textarea.input { resize: vertical; min-height: 80px; }
.field { display: flex; flex-direction: column; gap: var(--s1); }
.label { font-size: var(--fs-xs); font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.field-error { color: var(--danger); font-size: var(--fs-xs); }
.pair { display: flex; gap: var(--s2); }
.pair .timeonly { width: 120px; flex: none; }

/* --- vista mese ----------------------------------------------------------- */
.month { display: flex; flex-direction: column; height: 100%; min-height: 420px; }
.month-head { display: grid; grid-template-columns: repeat(7, 1fr); border-bottom: 1px solid var(--border); }
.month-head div { text-align: center; font-size: 11px; font-weight: 600; color: var(--text-muted); padding: var(--s1) 0; }
.month-body { flex: 1; display: grid; grid-template-columns: repeat(7, 1fr); grid-template-rows: repeat(var(--weeks), 1fr); }
.cell {
  min-width: 0; min-height: 0; overflow: hidden;
  border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
  padding: 2px 2px 0; display: flex; flex-direction: column; align-items: stretch; gap: 2px; cursor: pointer;
}
.cell:nth-child(7n) { border-right: 0; }
.cell:hover { background: var(--surface); }
.daynum {
  align-self: center; width: 26px; height: 26px; border-radius: var(--r-pill); border: 0; background: none;
  font-size: var(--fs-xs); font-weight: 600; display: grid; place-items: center; flex: none;
}
.cell.is-outside .daynum { color: var(--text-muted); font-weight: 400; }
.cell.is-today .daynum { background: var(--accent); color: var(--on-accent); }
.chips { display: flex; flex-direction: column; gap: 2px; min-height: 0; }
.chip {
  display: flex; align-items: center; gap: 3px; width: 100%; min-width: 0;
  border: 0; border-radius: 4px; padding: 0 4px; height: 16px;
  font-size: 10px; line-height: 16px; font-weight: 600; text-align: left;
  background: var(--ev); color: var(--ev-on);
}
.chip .chip-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip .chip-time { display: none; }
.chip.is-past { opacity: .6; }
.more { border: 0; background: none; font-size: 10px; font-weight: 600; color: var(--text-muted); text-align: left; padding: 0 4px; }
@media (min-width: 900px) {
  .cell { padding: 4px 4px 0; }
  .chip { height: 20px; font-size: var(--fs-xs); padding: 0 6px; }
  .chip:not(.is-allday) { background: none; color: var(--text); }
  .chip:not(.is-allday)::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ev); flex: none; }
  .chip:not(.is-allday):hover { background: var(--surface-2); }
  .chip .chip-time { display: inline; font-weight: 400; color: var(--text-muted); }
  .more { font-size: var(--fs-xs); }
}

.ev-blue { --ev: var(--ev-blue); } .ev-green { --ev: var(--ev-green); } .ev-red { --ev: var(--ev-red); }
.ev-orange { --ev: var(--ev-orange); } .ev-yellow { --ev: var(--ev-yellow); } .ev-purple { --ev: var(--ev-purple); }
.ev-teal { --ev: var(--ev-teal); } .ev-gray { --ev: var(--ev-gray); }

/* --- griglia oraria ------------------------------------------------------- */
.tg { display: flex; flex-direction: column; height: 100%; }
.tg-head, .tg-allday { display: grid; grid-template-columns: 52px repeat(var(--days), 1fr); border-bottom: 1px solid var(--border); flex: none; }
.tg-dayhead { border: 0; background: none; display: flex; flex-direction: column; align-items: center; padding: var(--s1) 0; gap: 2px; }
.tg-wd { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; }
.tg-num { width: 32px; height: 32px; border-radius: var(--r-pill); display: grid; place-items: center; font-size: var(--fs-lg); font-weight: 600; }
.tg-dayhead.is-today .tg-wd { color: var(--accent); }
.tg-dayhead.is-today .tg-num { background: var(--accent); color: var(--on-accent); }
.tg-allday-label { font-size: 10px; line-height: 12px; color: var(--text-muted); padding: 4px; text-align: right; }
.tg-allday-col { border-left: 1px solid var(--border); padding: 2px; display: flex; flex-direction: column; gap: 2px; min-width: 0; cursor: pointer; }
.tg-allday .chip { background: var(--ev); color: var(--ev-on); }
.tg-allday .chip::before { display: none; }
.tg-scroll { flex: 1; overflow-y: auto; min-height: 0; }
.tg-body { display: grid; grid-template-columns: 52px repeat(var(--days), 1fr); position: relative; }
.tg-hour { height: var(--hour-h); position: relative; }
.tg-hour span { position: absolute; top: -8px; right: 8px; font-size: 10px; color: var(--text-muted); }
.tg-col {
  position: relative; border-left: 1px solid var(--border); cursor: pointer;
  background: repeating-linear-gradient(to bottom, transparent 0 calc(var(--hour-h) - 1px), var(--border) calc(var(--hour-h) - 1px) var(--hour-h));
  height: calc(24 * var(--hour-h));
}
.block {
  position: absolute; z-index: 1; overflow: hidden;
  border: 1px solid var(--bg); border-radius: var(--r-sm); padding: 2px 6px;
  background: var(--ev); color: var(--ev-on); text-align: left;
  display: flex; flex-direction: column; font-size: var(--fs-xs); line-height: 15px;
}
.block-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.block-time { opacity: .9; white-space: nowrap; }
.block.is-short { flex-direction: row; gap: 6px; align-items: center; }
.block.is-short .block-title { white-space: nowrap; }
.block.is-past { opacity: .6; }
.now-line { position: absolute; left: 0; right: 0; height: 2px; background: var(--now-line); z-index: 2; pointer-events: none; }
.now-line::before { content: ""; position: absolute; left: -6px; top: -5px; width: 12px; height: 12px; border-radius: 50%; background: var(--now-line); }

/* --- agenda ------------------------------------------------------------- */
.agenda { padding: var(--s2) max(var(--s3), env(safe-area-inset-right)) calc(var(--s7) * 2) max(var(--s3), env(safe-area-inset-left)); max-width: 760px; }
.ag-day { display: grid; grid-template-columns: 64px 1fr; padding: var(--s2) 0; border-bottom: 1px solid var(--border); }
.ag-date button { border: 0; background: none; display: flex; flex-direction: column; align-items: center; width: 56px; padding: 0; }
.ag-num { width: 36px; height: 36px; display: grid; place-items: center; font-size: var(--fs-lg); font-weight: 600; border-radius: var(--r-pill); }
.ag-wd { font-size: 11px; color: var(--text-muted); font-weight: 600; }
.ag-day.is-today .ag-num { background: var(--accent); color: var(--on-accent); }
.ag-day ul { list-style: none; margin: 0; padding: 0; }
.ag-item {
  width: 100%; border: 0; background: none; text-align: left; border-radius: var(--r-md);
  display: grid; grid-template-columns: 12px 1fr; column-gap: var(--s3); padding: var(--s2);
}
.ag-item:hover { background: var(--surface); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ev); margin-top: 5px; grid-row: span 3; }
.ag-time { font-size: var(--fs-xs); color: var(--text-muted); }
.ag-title { font-weight: 600; font-size: var(--fs-base); }
.ag-loc { display: flex; align-items: center; gap: 4px; font-size: var(--fs-xs); color: var(--text-muted); }

.empty { display: grid; place-items: center; text-align: center; gap: var(--s3); padding: var(--s7) var(--s4); color: var(--text-muted); }
.empty .icon { color: var(--border-input); }

/* --- mini calendario ------------------------------------------------------- */
.mini-head { display: flex; justify-content: space-between; align-items: center; font-weight: 600; padding: 0 var(--s1) var(--s1) var(--s2); }
.mini-head > span:last-child { display: flex; }
.mini-grid { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; }
.mini-grid span { font-size: 10px; font-weight: 600; color: var(--text-muted); padding: 2px 0; }
.mini-grid button { border: 0; background: none; height: 28px; width: 28px; margin: 1px auto; border-radius: var(--r-pill); font-size: 11px; }
.mini-grid button:hover { background: var(--surface-2); }
.mini-grid .is-outside { color: var(--text-muted); }
.mini-grid .is-selected { background: var(--accent-soft); color: var(--on-accent-soft); font-weight: 600; }
.mini-grid .is-today { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.store-note { font-size: var(--fs-xs); color: var(--warning); margin: 0; padding: 0 var(--s2); }

/* --- foglio / finestra -------------------------------------------------------- */
dialog.sheet {
  border: 0; padding: 0; background: var(--bg); color: var(--text);
  width: 100%; max-width: 100%; height: 100%; max-height: 100%; margin: 0;
}
dialog.sheet::backdrop { background: rgba(0,0,0,.4); }
dialog.sheet[open] { animation: sheet-in var(--t-base) var(--ease); }
@keyframes sheet-in { from { transform: translateY(24px); opacity: 0; } }
.sheet-form { display: flex; flex-direction: column; height: 100%; }
.sheet-bar {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s2);
  padding: calc(env(safe-area-inset-top) + var(--s2)) var(--s3) var(--s2); border-bottom: 1px solid var(--border);
}
.sheet-bar h2 { font-size: var(--fs-base); }
.sheet-body { flex: 1; overflow: auto; padding: var(--s4) var(--s4) calc(env(safe-area-inset-bottom) + var(--s5)); display: flex; flex-direction: column; gap: var(--s4); }
.title-input { font-size: var(--fs-lg); border: 0; border-bottom: 2px solid var(--border); border-radius: 0; padding-left: 0; }
.title-input:focus { outline: none; border-bottom-color: var(--accent); }
.row { display: flex; align-items: center; gap: var(--s3); color: var(--text-muted); }
.row-field { flex-direction: row; align-items: center; gap: var(--s3); color: var(--text-muted); }
.row-field.top { align-items: flex-start; }
.row-field.top .icon { margin-top: 12px; }
.row-field .input { color: var(--text); }
.toggle { display: flex; align-items: center; gap: var(--s2); color: var(--text); font-size: var(--fs-base); }
.toggle input { width: 20px; height: 20px; accent-color: var(--accent); }
.when { display: grid; gap: var(--s3); }
.is-allday .timeonly { display: none; }
.colors { border: 0; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--s2); }
.colors legend { margin-bottom: var(--s2); }
.swatch { width: 32px; height: 32px; border-radius: 50%; background: var(--ev); cursor: pointer; display: grid; place-items: center; }
.swatch input { appearance: none; margin: 0; width: 100%; height: 100%; border-radius: 50%; cursor: pointer; }
.swatch input:checked { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--ev); }
.swatch input:focus-visible { outline: 2px solid var(--accent); outline-offset: 5px; }
@media (min-width: 900px) {
  dialog.sheet { width: 480px; height: auto; max-height: 85vh; margin: auto; border-radius: var(--r-lg); box-shadow: var(--shadow-pop); }
  .sheet-bar { padding-top: var(--s2); }
  .sheet-body { padding-bottom: var(--s5); }
}

/* --- toast -------------------------------------------------------------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 50;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 88px);
  display: flex; align-items: center; gap: var(--s3);
  background: var(--text); color: var(--bg); padding: var(--s2) var(--s2) var(--s2) var(--s4); border-radius: var(--r-md);
  box-shadow: var(--shadow-pop); max-width: calc(100% - 32px);
}
.toast[hidden] { display: none; }
.toast .btn.ghost { color: var(--accent-soft); }
@media (min-width: 900px) { .toast { bottom: var(--s5); } }

/* --- accesso ---------------------------------------------------------------- */
.login {
  min-height: 100dvh; display: grid; place-items: center;
  padding: calc(env(safe-area-inset-top) + var(--s4)) var(--s4) calc(env(safe-area-inset-bottom) + var(--s4));
  background: var(--surface);
}
.login-card {
  width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: var(--s4);
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s5);
  box-shadow: var(--shadow-card);
}
.login-brand { display: flex; flex-direction: column; align-items: center; gap: var(--s2); margin-bottom: var(--s2); }
.login-brand .icon { color: var(--accent); }
.login-brand h1 { font-size: var(--fs-lg); line-height: var(--lh-lg); }
.login-card .btn.primary { height: 44px; }

/* --- pagine semplici (Altro) ------------------------------------------------- */
.page { max-width: 640px; padding: var(--s4) max(var(--s4), env(safe-area-inset-right)) var(--s7) max(var(--s4), env(safe-area-inset-left)); display: flex; flex-direction: column; gap: var(--s4); }
.card { border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s4); display: flex; flex-direction: column; align-items: flex-start; gap: var(--s3); }
.card h2 { font-size: var(--fs-base); line-height: var(--lh-base); }
.card p { margin: 0; }
.muted { color: var(--text-muted); }

/* --- ripetizione nell'editor ------------------------------------------------- */
.repeat { display: flex; flex-direction: column; gap: var(--s3); }
.repeat select.input { color: var(--text); }
.repeat-custom { display: flex; flex-direction: column; gap: var(--s3); padding-left: 36px; }
.repeat-custom[hidden], .repeat-end[hidden], .weekdays[hidden], .count-wrap[hidden], .repeat-end [hidden] { display: none; }
.inline { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.repeat-end { padding-left: 36px; }
.inline .input { width: auto; }
.input.num { width: 72px; }
.count-wrap { display: inline-flex; align-items: center; gap: var(--s2); }
.weekdays { border: 0; margin: 0; padding: 0; display: flex; gap: var(--s1); }
.weekdays label { position: relative; }
.weekdays input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.weekdays span[aria-hidden] {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  border: 1px solid var(--border-input); font-weight: 600; font-size: var(--fs-xs);
}
.weekdays input:checked + span { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.weekdays input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --- domanda "solo questo / successivi / tutti" ----------------------------------- */
dialog.ask {
  border: 0; border-radius: var(--r-lg); padding: var(--s5); width: min(360px, calc(100% - 32px));
  background: var(--bg); color: var(--text); box-shadow: var(--shadow-pop);
}
dialog.ask::backdrop { background: rgba(0,0,0,.4); }
dialog.ask h2 { font-size: var(--fs-lg); line-height: var(--lh-lg); margin-bottom: var(--s3); }
dialog.ask fieldset { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; }
.radio { display: flex; align-items: center; gap: var(--s3); min-height: 44px; font-size: var(--fs-base); cursor: pointer; }
.radio input { width: 20px; height: 20px; accent-color: var(--accent); margin: 0; }
.ask-actions { display: flex; justify-content: flex-end; gap: var(--s2); margin-top: var(--s4); }

/* --- appunti -------------------------------------------------------------- */
body:not([data-section="cal"]) .nav-arrows,
body:not([data-section="cal"]) [data-act="today"],
body:not([data-section="cal"]) .view-select { display: none; }
body[data-section="notes"] .fab { display: grid; }

.notes-page { gap: var(--s3); }
.search .input { border-radius: var(--r-pill); padding-left: var(--s4); background: var(--surface); border-color: transparent; }
.desktop-inline { display: none; align-self: flex-start; }
@media (min-width: 900px) { .desktop-inline { display: inline-flex; } }
.note-group h2 { font-size: var(--fs-xs); line-height: var(--lh-xs); font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; margin: var(--s3) 0 var(--s2); }
.note-list { display: grid; gap: var(--s2); grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.note-card {
  display: flex; flex-direction: column; gap: var(--s1); text-align: left; width: 100%; min-width: 0;
  border: 1px solid var(--border); border-radius: var(--r-md); background: var(--bg); padding: var(--s3);
  transition: background var(--t-fast) var(--ease);
}
.note-card:hover { background: var(--surface); }
.note-card.is-pinned { border-color: var(--accent); }
.note-head { display: flex; gap: var(--s2); align-items: baseline; }
.note-title { font-weight: 600; font-size: var(--fs-base); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-pin { color: var(--accent); }
.note-body { color: var(--text-muted); white-space: pre-wrap; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.note-meta { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s3); font-size: var(--fs-xs); color: var(--text-muted); }
.note-meta:empty { display: none; }
.note-event { display: inline-flex; align-items: center; gap: var(--s1); font-size: var(--fs-xs); color: var(--text-muted); }
.note-event .dot { margin: 0; width: 8px; height: 8px; grid-row: auto; background: var(--ev, var(--accent)); }

.cell { position: relative; }
.note-ind { position: absolute; top: 6px; right: 4px; color: var(--accent); }
.tg-dayhead { position: relative; }
.tg-dayhead .note-ind { top: 4px; right: 6px; }
.day-notes { display: flex; gap: var(--s2); overflow-x: auto; padding: var(--s2) var(--s3); border-bottom: 1px solid var(--border); align-items: center; flex: none; }
.day-notes .note-card { width: 200px; flex: none; padding: var(--s2) var(--s3); }
.day-notes .note-body { -webkit-line-clamp: 1; }

.note-sheet .sheet-body { gap: var(--s3); }
.note-text { min-height: 40vh; font-size: var(--fs-base); line-height: var(--lh-base); }
.field.grow { flex: 1; min-height: 0; }
.field.grow .note-text { flex: 1; resize: none; }
.linked { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); background: var(--surface); border-radius: var(--r-md); padding: var(--s1) var(--s1) var(--s1) var(--s3); }
.ed-notes { display: flex; flex-direction: column; align-items: flex-start; gap: var(--s2); border-top: 1px solid var(--border); padding-top: var(--s3); }
.ed-notes-list { display: flex; flex-direction: column; gap: var(--s2); width: 100%; }
.ed-notes-list:empty { display: none; }

/* --- menu Crea ------------------------------------------------------------------ */
dialog.menu {
  position: fixed; margin: 0; padding: var(--s1); border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--bg); color: var(--text); box-shadow: var(--shadow-pop); width: 200px;
}
dialog.menu::backdrop { background: transparent; }
dialog.menu button {
  display: flex; align-items: center; gap: var(--s3); width: 100%; height: 44px; padding: 0 var(--s3);
  border: 0; background: none; border-radius: var(--r-sm); font-size: var(--fs-base); text-align: left;
}
dialog.menu button:hover, dialog.menu button:focus-visible { background: var(--surface); }
dialog.menu .icon { color: var(--text-muted); }

/* --- spese ------------------------------------------------------------------ */
body[data-section="expenses"] .fab { display: grid; }
.month-nav { display: flex; align-items: center; gap: var(--s1); }
.month-nav h2 { font-size: var(--fs-lg); line-height: var(--lh-lg); min-width: 0; flex: 0 1 auto; text-align: center; }
.month-nav .btn { margin-left: auto; }
.card { width: 100%; }
.card-head { display: flex; align-items: center; justify-content: space-between; width: 100%; }
.hero { gap: var(--s1); }
.hero-number { font-size: var(--fs-xl); line-height: var(--lh-xl); font-weight: 700; font-variant-numeric: tabular-nums; }

/* andamento 6 mesi: una serie, barre sottili arrotondate in alto, base comune */
.trend { display: grid; grid-template-columns: repeat(6, 1fr); gap: var(--s2); width: 100%; margin-top: var(--s3); }
.tb { display: flex; flex-direction: column; align-items: center; gap: 4px; border: 0; background: none; padding: 0; border-radius: var(--r-sm); }
.tb:hover .tb-bar { filter: brightness(1.1); }
.tb-value { font-size: 11px; line-height: 14px; height: 14px; color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tb-track { height: 72px; width: 100%; max-width: 28px; display: flex; align-items: flex-end; border-bottom: 1px solid var(--border); }
.tb-bar { display: block; width: 100%; background: var(--border-input); border-radius: 4px 4px 0 0; }
.tb.is-current .tb-bar { background: var(--accent); }
.tb.is-current .tb-value { color: var(--text); font-weight: 600; }
.tb-label { font-size: 11px; color: var(--text-muted); text-transform: capitalize; }
.tb.is-current .tb-label { color: var(--text); font-weight: 600; }

/* per categoria */
.cats { list-style: none; margin: 0; padding: 0; width: 100%; display: flex; flex-direction: column; gap: var(--s3); }
.cat-row { display: grid; grid-template-columns: 32px 1fr; gap: var(--s3); align-items: start; }
.cat-icon {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-size: 16px; flex: none;
  background: color-mix(in srgb, var(--ev) 18%, var(--bg));
}
.cat-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.cat-line { display: flex; justify-content: space-between; gap: var(--s2); }
.cat-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-amount { font-variant-numeric: tabular-nums; font-weight: 600; }
.meter { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--ev); border-radius: 3px; }
.cat-row.is-over .meter span { background: var(--danger); }
.cat-note { font-size: var(--fs-xs); }
.cat-over { color: var(--danger); font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }

/* movimenti */
.x-list { display: flex; flex-direction: column; gap: var(--s3); }
.x-day h3 { display: flex; justify-content: space-between; font-size: var(--fs-xs); font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; margin: 0 0 var(--s1); padding: 0 var(--s2); }
.x-day ul { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; }
.x-day li + li { border-top: 1px solid var(--border); }
.x-item { display: flex; align-items: center; gap: var(--s3); width: 100%; border: 0; background: var(--bg); padding: var(--s2) var(--s3); text-align: left; min-height: 52px; }
.x-item:hover { background: var(--surface); }
.x-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.x-desc { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.x-cat { font-size: var(--fs-xs); color: var(--text-muted); }
.x-cat:empty { display: none; }
.x-amount { font-variant-numeric: tabular-nums; font-weight: 600; }

/* editor spesa */
.amount-wrap { display: flex; align-items: center; gap: var(--s2); font-size: var(--fs-xl); font-weight: 700; }
.amount-input { font-size: var(--fs-xl); font-weight: 700; height: 56px; font-variant-numeric: tabular-nums; }
.cat-pick { border: 0; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.cat-pick legend { margin-bottom: var(--s2); }
.cat-chip { position: relative; }
.cat-chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.cat-chip span {
  display: inline-flex; align-items: center; gap: 4px; height: 36px; padding: 0 var(--s3);
  border: 1px solid var(--border-input); border-radius: var(--r-pill); font-weight: 600; white-space: nowrap;
}
.cat-chip input:checked + span { background: color-mix(in srgb, var(--ev) 18%, var(--bg)); border-color: var(--ev); box-shadow: inset 0 0 0 1px var(--ev); }
.cat-chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* gestione categorie */
.cat-manage { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s1); }
.cat-line-btn { display: flex; align-items: center; gap: var(--s3); width: 100%; border: 0; background: none; padding: var(--s2); border-radius: var(--r-md); text-align: left; }
.cat-line-btn:hover { background: var(--surface); }
.cat-line-btn .cat-name { flex: 1; }
.is-archived .cat-line-btn { opacity: .6; }
.cat-form { display: flex; flex-direction: column; gap: var(--s3); padding: var(--s3); border: 1px solid var(--border); border-radius: var(--r-md); }
.cat-form .inline .input:not(.icon-input) { flex: 1; }
.icon-input { width: 56px; text-align: center; font-size: 20px; }
/* oltre il budget: rosso di stato + righe diagonali, così non si confonde con una categoria rossa */
.cat-row.is-over .meter span { background: repeating-linear-gradient(135deg, var(--danger) 0 6px, color-mix(in srgb, var(--danger) 70%, var(--bg)) 6px 9px); }
/* spazio in fondo perché il pulsante + non copra l'ultima riga */
@media (max-width: 899px) { .expenses-page, .notes-page { padding-bottom: 104px; } }

/* --- Altro: installazione e backup -------------------------------------------- */
.steps { margin: 0; padding-left: 1.2em; display: flex; flex-direction: column; gap: var(--s1); }
.restore { width: 100%; }
.restore summary { cursor: pointer; color: var(--accent); font-weight: 600; padding: var(--s1) 0; }
.restore[open] { display: flex; flex-direction: column; gap: var(--s2); align-items: flex-start; }
.restore label.btn { cursor: pointer; }

/* --- promemoria nell'editor ----------------------------------------------------- */
.reminders { align-items: flex-start; }
.reminders > .icon { margin-top: 12px; }
.rem-box { flex: 1; display: flex; flex-direction: column; gap: var(--s2); min-width: 0; }
.rem-list { display: flex; flex-wrap: wrap; gap: var(--s2); }
.rem-list:empty { display: none; }
.rem-chip { display: inline-flex; align-items: center; gap: 2px; height: 32px; padding: 0 2px 0 var(--s3); border-radius: var(--r-pill); background: var(--surface-2); color: var(--text); font-size: var(--fs-sm); }
.rem-chip button { width: 28px; height: 28px; border: 0; background: none; border-radius: 50%; display: grid; place-items: center; color: var(--text-muted); }
.rem-chip button:hover { background: var(--border); color: var(--text); }
.rem-add { color: var(--text); }
.rem-add[hidden] { display: none; }
