:root {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --panel-2: #f1f3f8;
  --line: #e3e6ef;
  --text: #1c2030;
  --muted: #6b7185;
  --accent: #4f46e5;
  --accent-2: #eef0ff;
  --danger: #d93a3a;
  --ok: #1f9d61;
  --warn: #c98a07;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 24, 40, .06), 0 4px 16px rgba(20, 24, 40, .06);
  --sidebar: 340px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12141c;
    --panel: #1a1d27;
    --panel-2: #222633;
    --line: #2d3242;
    --text: #e8eaf2;
    --muted: #949ab0;
    --accent: #7c75ff;
    --accent-2: #2a2950;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
code { background: var(--panel-2); padding: 1px 6px; border-radius: 6px; font-size: 12.5px; user-select: all; }

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 9px;
  padding: 7px 14px;
  cursor: pointer;
  font-weight: 550;
  white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--panel-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--panel-2); }
.btn.danger { color: var(--danger); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.connected { background: var(--accent-2); color: var(--accent); border-color: transparent; }
.icon-btn {
  width: 34px; height: 34px;
  border: 0; background: transparent; border-radius: 9px;
  cursor: pointer; font-size: 17px; color: var(--muted);
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); }
.icon-btn.spin { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 17px; display: flex; align-items: center; gap: 9px; letter-spacing: -.01em; }
.logo {
  width: 26px; height: 26px; border-radius: 8px;
  background: var(--accent); color: #fff;
  display: grid; place-items: center; font-size: 15px;
}
.sync { display: flex; align-items: center; gap: 2px; }
.sync-status { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.sync-status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.sync-status[data-state="ok"]::before { background: var(--ok); }
.sync-status[data-state="local"]::before { background: var(--warn); }
.sync-status[data-state="busy"]::before { background: var(--accent); animation: pulse 1s infinite; }
.sync-status[data-state="err"]::before { background: var(--danger); }
@keyframes pulse { 50% { opacity: .3; } }

.banner {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 8px 16px;
  background: #fff4d6; color: #6b4c00;
  border-bottom: 1px solid #f1dd9f;
}
@media (prefers-color-scheme: dark) { .banner { background: #3a3013; color: #f3dc9a; border-color: #5a4a1a; } }

/* ---------- Layout ---------- */
.layout { flex: 1; display: flex; min-height: 0; }
.sidebar {
  width: var(--sidebar); flex: none;
  display: flex; flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--line);
  min-height: 0;
  position: relative;
}
.calendar-wrap { flex: 1; min-width: 0; padding: 12px 16px 16px; display: flex; flex-direction: column; }
#calendar { flex: 1; min-height: 0; }

/* ---------- Quick add ---------- */
.quick-add { padding: 14px 14px 10px; display: flex; flex-direction: column; gap: 9px; border-bottom: 1px solid var(--line); }
.qa-title {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  outline: none;
  font-size: 15px;
}
.qa-title:focus { border-color: var(--accent); background: var(--panel); box-shadow: 0 0 0 3px var(--accent-2); }
.qa-row { display: flex; align-items: center; gap: 8px; }
.qa-row input[type="date"] {
  border: 1px solid var(--line); border-radius: 8px; background: var(--panel);
  padding: 3px 6px; font-size: 12.5px; color: var(--muted); min-width: 0; flex: 1;
}
.qa-row .lbl { width: 64px; flex: none; }
.lbl { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 650; }

.chips { display: flex; gap: 4px; flex-wrap: wrap; }
.chips button {
  border: 1px solid var(--line); background: var(--panel);
  border-radius: 999px; padding: 2px 10px; font-size: 12.5px; cursor: pointer; color: var(--muted);
}
.chips button:hover { border-color: var(--accent); color: var(--text); }
.chips button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chips.small button { padding: 1px 8px; font-size: 12px; }

.swatches { display: flex; gap: 4px; flex-wrap: wrap; }
.swatches button {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid transparent; cursor: pointer; padding: 0;
  background: var(--c); box-shadow: inset 0 0 0 1px rgba(0,0,0,.08);
}
.swatches button.on { border-color: var(--panel); box-shadow: 0 0 0 2px var(--c); }
.dlg .swatches button { width: 24px; height: 24px; }

.session-len { padding: 8px 14px; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.search-row { padding: 8px 14px 4px; }
.search-row input {
  width: 100%; border: 0; background: var(--panel-2); border-radius: 8px; padding: 6px 10px; outline: none;
}

/* ---------- Task list ---------- */
.task-list { flex: 1; overflow-y: auto; padding: 4px 10px 10px; }
.group-title {
  display: flex; align-items: center; gap: 6px;
  margin: 12px 4px 6px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); font-weight: 650; cursor: default; user-select: none;
}
.group-title .count { background: var(--panel-2); border-radius: 999px; padding: 0 7px; font-weight: 600; }
.group-title.toggle { cursor: pointer; }
.empty {
  margin: 30px 10px; text-align: center; color: var(--muted); font-size: 13.5px;
  border: 1.5px dashed var(--line); border-radius: var(--radius); padding: 22px 14px;
}
.task-card {
  position: relative;
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 10px 10px 12px;
  margin-bottom: 7px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 4px solid var(--c);
  border-radius: 10px;
  cursor: grab;
  user-select: none;
  transition: box-shadow .15s, transform .15s, border-color .15s;
}
.task-card:hover { box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--c) 40%, var(--line)); border-left-color: var(--c); }
.task-card:active { cursor: grabbing; }
.task-card.done { opacity: .6; cursor: default; }
.task-card.done .tc-title { text-decoration: line-through; }
.tc-check {
  flex: none; width: 18px; height: 18px; margin-top: 1px;
  border-radius: 50%; border: 2px solid var(--c); background: transparent;
  cursor: pointer; padding: 0; font-size: 10px; line-height: 1; color: #fff;
}
.tc-check:hover { background: color-mix(in srgb, var(--c) 25%, transparent); }
.task-card.done .tc-check { background: var(--c); }
.tc-body { flex: 1; min-width: 0; }
.tc-title { font-weight: 600; overflow-wrap: anywhere; }
.tc-meta { display: flex; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 2px; }
.tc-meta .overdue { color: var(--danger); font-weight: 600; }
.tc-meta .soon { color: var(--warn); font-weight: 600; }
.tc-bar { height: 5px; border-radius: 3px; background: var(--panel-2); margin: 7px 0 4px; display: flex; overflow: hidden; }
.tc-bar i { display: block; height: 100%; }
.tc-bar .w { background: var(--c); }
.tc-bar .p { background: color-mix(in srgb, var(--c) 40%, transparent); }
.tc-foot { font-size: 12px; color: var(--muted); }
.tc-foot b { color: var(--text); }
.tc-actions { display: flex; flex-direction: column; gap: 2px; opacity: 0; transition: opacity .15s; }
.task-card:hover .tc-actions { opacity: 1; }
.tc-actions button {
  border: 0; background: transparent; cursor: pointer; border-radius: 6px;
  width: 26px; height: 24px; color: var(--muted); font-size: 13px;
}
.tc-actions button:hover { background: var(--panel-2); color: var(--text); }

.sidebar-hint { margin: 0; padding: 10px 14px 12px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); }

.drop-zone {
  display: none;
  position: absolute; inset: 0;
  align-items: center; justify-content: center; text-align: center;
  padding: 30px; z-index: 5;
  background: color-mix(in srgb, var(--danger) 10%, var(--panel));
  border: 2px dashed var(--danger); border-radius: 6px;
  color: var(--danger); font-weight: 600; font-size: 15px;
}
body.dragging-session .drop-zone { display: flex; }
body.dragging-session .sidebar.over .drop-zone { background: color-mix(in srgb, var(--danger) 22%, var(--panel)); }

/* ---------- FullCalendar ---------- */
.fc { --fc-border-color: var(--line); --fc-page-bg-color: var(--panel); --fc-neutral-bg-color: var(--panel-2);
  --fc-today-bg-color: color-mix(in srgb, var(--accent) 6%, transparent);
  --fc-now-indicator-color: #e5484d;
  --fc-non-business-color: color-mix(in srgb, var(--panel-2) 65%, transparent);
  --fc-button-bg-color: var(--panel); --fc-button-border-color: var(--line); --fc-button-text-color: var(--text);
  --fc-button-hover-bg-color: var(--panel-2); --fc-button-hover-border-color: var(--line);
  --fc-button-active-bg-color: var(--accent-2); --fc-button-active-border-color: var(--accent);
  --fc-highlight-color: color-mix(in srgb, var(--accent) 15%, transparent);
  --fc-list-event-hover-bg-color: var(--panel-2);
}
.fc .fc-toolbar.fc-header-toolbar { margin-bottom: 10px; }
.fc .fc-toolbar-title { font-size: 19px; font-weight: 650; text-transform: capitalize; }
.fc .fc-button { font-size: 13px; padding: 5px 11px; border-radius: 8px; box-shadow: none !important; text-transform: capitalize; }
.fc .fc-button-primary:not(:disabled).fc-button-active { color: var(--accent); }
.fc .fc-view-harness { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); }
.fc .fc-scrollgrid { border-radius: var(--radius); overflow: hidden; }
.fc .fc-col-header-cell-cushion { text-transform: capitalize; font-weight: 600; padding: 6px 4px; }
.fc .fc-timegrid-slot { height: 2.1em; }
.fc .fc-timegrid-slot-label-cushion { font-size: 11.5px; color: var(--muted); }
.fc-event { border-radius: 6px !important; font-size: 12.5px; cursor: pointer; }
.fc-v-event .fc-event-main { padding: 2px 4px; }
.fc-event.is-session { box-shadow: inset 3px 0 0 rgba(0,0,0,.18); }
.fc-event.is-session .fc-event-title::before { content: "◎ "; }
.fc-event.readonly { cursor: default; }
.fc-event.declined { opacity: .5; text-decoration: line-through; }
.fc-event.pending { opacity: .55; }
.fc-event.flash { animation: flash 1.2s ease 2; }
@keyframes flash { 50% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 50%, transparent); } }
body.hl .fc-event.is-session { opacity: .3; }
.fc-event.hl-on { opacity: 1 !important; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 45%, transparent) !important; z-index: 3; }
.fc-event-dragging.fc-event-mirror { box-shadow: var(--shadow) !important; }

/* ---------- Dialogs ---------- */
.dlg {
  border: 0; border-radius: 16px; padding: 0; width: min(520px, 94vw);
  background: var(--panel); color: var(--text);
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.dlg.wide { width: min(680px, 95vw); }
.dlg::backdrop { background: rgba(15, 18, 30, .45); backdrop-filter: blur(2px); }
.dlg form { padding: 20px 22px 16px; display: flex; flex-direction: column; gap: 12px; max-height: 88vh; overflow-y: auto; }
.dlg h3 { margin: 0 0 2px; font-size: 18px; }
.dlg h4 { margin: 4px 0 8px; font-size: 14px; }
.dlg section { border-top: 1px solid var(--line); padding-top: 12px; }
.dlg label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); font-weight: 550; }
.dlg label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-size: 14px; }
.dlg input:not([type="checkbox"]):not([type="radio"]), .dlg select, .dlg textarea {
  border: 1px solid var(--line); border-radius: 9px; background: var(--panel);
  padding: 8px 10px; font-size: 14px; color: var(--text); outline: none; width: 100%;
}
.dlg input:focus, .dlg select:focus, .dlg textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-2); }
.dlg input:disabled, .dlg select:disabled, .dlg textarea:disabled { opacity: .7; }
.dlg textarea { resize: vertical; }
.dlg footer { display: flex; gap: 8px; align-items: center; padding-top: 6px; flex-wrap: wrap; }
.dlg label.btn { display: inline-flex; flex-direction: row; color: var(--text); font-size: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.hint { margin: 0; font-size: 12.5px; color: var(--muted); }
.g-status { margin: 0 0 10px; font-size: 13.5px; }
.ext-link { font-size: 13px; color: var(--accent); text-decoration: none; }

.sessions-box { background: var(--panel-2); border-radius: 10px; padding: 10px 12px; }
.sessions-box ul { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 3px; max-height: 180px; overflow-y: auto; }
.sessions-box li { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 3px 6px; border-radius: 6px; }
.sessions-box li:hover { background: var(--panel); }
.sessions-box li.past { color: var(--muted); }
.sessions-box li .when { flex: 1; cursor: pointer; }
.sessions-box li button { border: 0; background: transparent; cursor: pointer; color: var(--muted); border-radius: 5px; }
.sessions-box li button:hover { color: var(--danger); }

.cal-list { display: flex; flex-direction: column; gap: 2px; max-height: 240px; overflow-y: auto; }
.cal-row { display: grid; grid-template-columns: 14px 1fr auto auto; gap: 10px; align-items: center; padding: 5px 6px; border-radius: 7px; font-size: 13.5px; }
.cal-row:hover { background: var(--panel-2); }
.cal-row .dot { width: 12px; height: 12px; border-radius: 4px; }
.cal-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-row label { flex-direction: row !important; align-items: center; gap: 5px !important; font-size: 12px !important; }
.cal-head { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.days { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.days label { flex-direction: row !important; align-items: center; gap: 5px !important; color: var(--text) !important; font-size: 13.5px !important;
  border: 1px solid var(--line); border-radius: 8px; padding: 4px 9px; cursor: pointer; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 100; align-items: center; pointer-events: none; }
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 14px;
  background: #1f2333; color: #fff; padding: 10px 14px 10px 16px; border-radius: 11px;
  box-shadow: 0 8px 30px rgba(0,0,0,.25); font-size: 13.5px; max-width: min(560px, 92vw);
  animation: toastIn .2s ease;
}
.toast.error { background: #a32626; }
.toast.ok::before { content: "✓"; color: #6ee7a8; font-weight: 700; }
.toast.warn::before { content: "!"; color: #ffd166; font-weight: 800; }
.toast button { border: 0; background: rgba(255,255,255,.14); color: #fff; padding: 4px 10px; border-radius: 7px; cursor: pointer; font-weight: 600; white-space: nowrap; }
.toast button:hover { background: rgba(255,255,255,.25); }
.toast.out { opacity: 0; transform: translateY(8px); transition: .3s; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Quick add: assistente ---------- */
.qa-top { display: flex; gap: 6px; }
.qa-top .qa-title { flex: 1; min-width: 0; }
.qa-btn {
  flex: none; width: 40px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel); cursor: pointer; font-size: 16px;
}
.qa-btn:hover { border-color: var(--accent); background: var(--accent-2); }
.mic.on { background: #e5484d !important; border-color: #e5484d !important; color: #fff; animation: micPulse 1.2s infinite; }
@keyframes micPulse { 50% { box-shadow: 0 0 0 6px rgba(229, 72, 77, .25); } }
.qa-select {
  flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--panel);
  padding: 3px 6px; font-size: 13px;
}

/* ---------- Schede e gruppi ---------- */
.tabs { display: flex; gap: 4px; padding: 8px 14px 0; }
.tabs button {
  flex: 1; border: 1px solid var(--line); background: var(--panel); border-radius: 9px;
  padding: 6px 8px; cursor: pointer; font-weight: 600; color: var(--muted); font-size: 13px;
}
.tabs button.on { background: var(--accent-2); color: var(--accent); border-color: transparent; }
.tabs .count { background: var(--panel-2); border-radius: 999px; padding: 0 7px; font-size: 11.5px; margin-left: 4px; }
.group { margin-top: 8px; }
.group-head {
  display: flex; align-items: center; gap: 7px;
  padding: 6px 6px; margin: 0 0 4px; border-radius: 8px;
  font-size: 12.5px; font-weight: 650; cursor: pointer; user-select: none; color: var(--text);
}
.group-head:hover { background: var(--panel-2); }
.group-head .caret { width: 10px; color: var(--muted); font-size: 11px; }
.group-head .gdot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.group-head .gname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-head .count { background: var(--panel-2); border-radius: 999px; padding: 0 7px; font-weight: 600; font-size: 11.5px; color: var(--muted); }
.group-head .gsum { flex: 1; text-align: right; font-weight: 500; font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.group-head .gmenu { border: 0; background: transparent; cursor: pointer; color: var(--muted); border-radius: 6px; padding: 0 6px; opacity: 0; }
.group-head:hover .gmenu { opacity: 1; }
.group-head .gmenu:hover { background: var(--panel); color: var(--text); }
.add-project {
  display: block; width: 100%; margin: 12px 0 4px; padding: 8px;
  border: 1.5px dashed var(--line); border-radius: 10px; background: transparent;
  color: var(--muted); cursor: pointer; font-weight: 600;
}
.add-project:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Card: dettagli ---------- */
.tc-desc {
  font-size: 12.5px; color: var(--muted); margin-top: 4px; white-space: pre-line;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.sidebar.wide .tc-desc { -webkit-line-clamp: 4; }
.tc-sessions { display: none; list-style: none; margin: 6px 0 0; padding: 0; font-size: 12px; color: var(--muted); }
.sidebar.wide .tc-sessions { display: flex; flex-wrap: wrap; gap: 4px; }
.tc-sessions li { background: var(--panel-2); border-radius: 6px; padding: 1px 7px; }
.sidebar.wide .task-card { padding: 12px 12px 12px 14px; }
.sidebar.wide .tc-title { font-size: 14.5px; }
.cu-status {
  display: inline-flex; align-items: center; gap: 5px; text-transform: uppercase; font-size: 10.5px; font-weight: 700;
  letter-spacing: .03em; color: var(--sc); border: 1px solid color-mix(in srgb, var(--sc) 45%, transparent);
  border-radius: 5px; padding: 0 6px;
}
.cu-box { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; font-size: 13px; background: var(--panel-2); border-radius: 10px; padding: 8px 12px; }
.cu-box a { color: var(--accent); text-decoration: none; margin-left: auto; font-weight: 600; }

.cu-prio { color: var(--pc); font-weight: 600; }
.group-empty { font-size: 12.5px; color: var(--muted); padding: 4px 10px 10px 26px; }

/* ---------- Filtri ClickUp ---------- */
.dlg.xwide { width: min(900px, 96vw); }
.cu-filters { display: grid; grid-template-columns: 1.3fr 1fr; gap: 18px; }
.cu-tree { max-height: 55vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; padding: 6px; }
.dlg .cu-row { flex-direction: row !important; align-items: center; gap: 8px !important; color: var(--text) !important; font-size: 13.5px !important; font-weight: 500 !important; padding: 4px 6px; border-radius: 6px; cursor: pointer; }
.dlg .cu-row:hover { background: var(--panel-2); }
.cu-row .cnt { margin-left: auto; background: var(--panel-2); border-radius: 999px; padding: 0 8px; font-size: 11.5px; color: var(--muted); }
.cu-row .sq { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.cu-row .dotc { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.cu-children { padding-left: 22px; }
.cu-children.off { opacity: .4; pointer-events: none; }
.cu-space { margin-bottom: 4px; }
.cu-sep { height: 1px; background: var(--line); margin: 6px 4px; }

/* ---------- Pannello ridimensionabile ---------- */
.resizer { position: absolute; top: 0; right: -4px; width: 8px; height: 100%; cursor: col-resize; z-index: 6; }
.resizer:hover, body.resizing .resizer { background: color-mix(in srgb, var(--accent) 35%, transparent); }
body.resizing { cursor: col-resize; user-select: none; }

/* ---------- Menu contestuale ---------- */
.ctx-menu {
  position: fixed; z-index: 200; min-width: 230px; max-width: 320px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 11px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .22); padding: 5px;
  animation: toastIn .12s ease;
}
.ctx-head { font-size: 11.5px; color: var(--muted); font-weight: 650; padding: 6px 10px 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctx-item {
  display: flex; align-items: center; gap: 9px; width: 100%;
  border: 0; background: transparent; border-radius: 7px; padding: 7px 10px;
  cursor: pointer; text-align: left; font-size: 13.5px;
}
.ctx-item:hover:not(:disabled) { background: var(--accent-2); color: var(--accent); }
.ctx-item.danger { color: var(--danger); }
.ctx-item.danger:hover { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.ctx-item.active .ctx-label { font-weight: 700; }
.ctx-item.active::after { content: "✓"; margin-left: auto; color: var(--accent); }
.ctx-ic { width: 18px; text-align: center; flex: none; }
.ctx-ic .sw { display: inline-block; width: 12px; height: 12px; border-radius: 50%; vertical-align: middle; }
.ctx-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctx-arrow { color: var(--muted); font-size: 11px; }
.ctx-sep { height: 1px; background: var(--line); margin: 4px 6px; }

/* ---------- Assistente ---------- */
.agent-input { position: relative; }
.agent-input textarea { padding-right: 64px !important; font-size: 15px !important; }
.agent-mic {
  position: absolute; right: 10px; bottom: 10px; width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-size: 18px;
}
.agent-mic:hover { border-color: var(--accent); }
.agent-status { min-height: 20px; font-size: 13.5px; color: var(--muted); }
.agent-list { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.agent-list li { border-left: 4px solid var(--c); background: var(--panel-2); border-radius: 8px; padding: 8px 12px; display: flex; flex-direction: column; gap: 2px; }
.agent-desc { font-size: 12.5px; color: var(--muted); white-space: pre-line; }

/* ---------- Calendario: giorni passati più chiari ---------- */
.fc .fc-timegrid-col.fc-day-past, .fc .fc-daygrid-day.fc-day-past { background: color-mix(in srgb, var(--panel-2) 55%, transparent); }
.fc .fc-col-header-cell.fc-day-today { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.fc .fc-col-header-cell.fc-day-today .fc-col-header-cell-cushion { color: var(--accent); }

/* ---------- Schermi ultra-wide (es. 32:9) ---------- */
@media (min-width: 2300px) {
  body { font-size: 15px; }
  .fc-event { font-size: 13px; }
  .fc .fc-timegrid-slot { height: 2.3em; }
}

/* ---------- Schermata di accesso (versione online) ---------- */
.login-screen {
  position: fixed; inset: 0; z-index: 300; background: var(--bg);
  display: grid; place-items: center; padding: 20px;
}
.login-card {
  background: var(--panel); border-radius: 18px; box-shadow: var(--shadow);
  padding: 36px 32px; max-width: 380px; width: 100%; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.login-card h1 { margin: 6px 0 0; font-size: 24px; }
.login-card .btn { text-decoration: none; margin-top: 10px; padding: 10px 22px; }
.logo.big { width: 54px; height: 54px; font-size: 28px; border-radius: 14px; }
.login-error { color: var(--danger); font-size: 13.5px; margin: 0; }

/* ---------- Dispositivi touch: azioni sempre visibili ---------- */
@media (hover: none) {
  .tc-actions, .group-head .gmenu { opacity: 1; }
}

/* ---------- Telefono ---------- */
.mobile-nav { display: none; }
@media (max-width: 860px) {
  .resizer, .sidebar-hint, .session-len { display: none; }
  .topbar { padding: 8px 10px; gap: 6px; }
  .brand { font-size: 16px; }
  .sync-status { display: none; }
  #btnConnect { padding: 5px 10px; font-size: 12.5px; }
  .layout { flex-direction: column; padding-bottom: 62px; }
  .sidebar { width: auto !important; border-right: 0; flex: 1; }
  .calendar-wrap { padding: 6px; flex: 1; }
  body[data-pane="calendar"] .sidebar { display: none; }
  body[data-pane="tasks"] .calendar-wrap { display: none; }
  .fc .fc-toolbar { flex-wrap: wrap; gap: 6px; }
  .fc .fc-toolbar-title { font-size: 16px; }
  .fc .fc-button { padding: 5px 8px; font-size: 12px; }
  .fc .fc-toolbar.fc-header-toolbar { margin-bottom: 6px; }
  .quick-add { padding: 10px 12px 8px; }
  .qa-title { font-size: 16px; } /* evita lo zoom automatico su iPhone */
  .dlg { width: 100vw; max-width: 100vw; max-height: 100dvh; margin: auto 0 0; border-radius: 18px 18px 0 0; }
  .dlg form { max-height: 92dvh; padding: 18px 16px 14px; }
  .dlg input:not([type="checkbox"]):not([type="radio"]), .dlg select, .dlg textarea { font-size: 16px; }
  .row2, .row3, .cu-filters { grid-template-columns: 1fr; }
  .ctx-menu { min-width: 250px; }
  .ctx-item { padding: 10px 12px; font-size: 15px; }
  .toasts { bottom: 74px; }
  .mobile-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    background: var(--panel); border-top: 1px solid var(--line);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  }
  .mobile-nav button {
    flex: 1; border: 0; background: transparent; border-radius: 12px; padding: 6px 4px;
    display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 19px; color: var(--muted); cursor: pointer;
  }
  .mobile-nav button span { font-size: 11.5px; font-weight: 600; }
  .mobile-nav button.on { color: var(--accent); background: var(--accent-2); }
  .mobile-nav .mic.on { color: #fff; }
}
