:root {
  --bg: #f2f2f7;
  --bg-2: #ffffff;
  --bg-3: #f7f7fa;
  --fill: rgba(118,118,128,.12);
  --fill-2: rgba(118,118,128,.2);
  --text: #1c1c1e;
  --text-2: #6c6c70;
  --text-3: #aeaeb2;
  --sep: rgba(60,60,67,.14);
  --accent: #0a84ff;
  --accent-soft: rgba(10,132,255,.12);
  --red: #ff3b30;
  --red-soft: rgba(255,59,48,.12);
  --orange: #ff9500;
  --orange-soft: rgba(255,149,0,.14);
  --green: #34c759;
  --green-soft: rgba(52,199,89,.14);
  --purple: #af52de;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 18px rgba(0,0,0,.05);
  --shadow-lg: 0 20px 60px rgba(0,0,0,.18);
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --tabbar-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --bg-2: #1c1c1e;
    --bg-3: #2c2c2e;
    --fill: rgba(118,118,128,.24);
    --fill-2: rgba(118,118,128,.36);
    --text: #f2f2f7;
    --text-2: #a1a1a6;
    --text-3: #636366;
    --sep: rgba(84,84,88,.5);
    --accent-soft: rgba(10,132,255,.22);
    --red: #ff453a; --red-soft: rgba(255,69,58,.2);
    --orange: #ff9f0a; --orange-soft: rgba(255,159,10,.2);
    --green: #30d158; --green-soft: rgba(48,209,88,.2);
    --shadow: none;
    --shadow-lg: 0 20px 60px rgba(0,0,0,.6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font); font-size: 16px; line-height: 1.4;
  background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
.i { width: 20px; height: 20px; flex: none; }
.muted { color: var(--text-2); }
.small { font-size: 13px; }
.center { text-align: center; }
.error { color: var(--red); font-size: 14px; margin: 4px 0; }

.boot { position: fixed; inset: 0; display: grid; place-items: center; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--fill-2); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Bottoni ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 10px; padding: 9px 14px; background: var(--fill); color: var(--text);
  font-weight: 600; font-size: 15px; transition: transform .08s, background .15s, opacity .15s; white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.danger { background: var(--red-soft); color: var(--red); }
.btn.ghost { background: transparent; color: var(--accent); padding: 8px 10px; }
.btn.big { width: 100%; padding: 13px; font-size: 17px; border-radius: 12px; }
.btn.sm { padding: 6px 10px; font-size: 14px; border-radius: 8px; }
.btn:disabled { opacity: .5; pointer-events: none; }
.icon-btn { position: relative; border: 0; background: var(--fill); border-radius: 50%; width: 38px; height: 38px; display: grid; place-items: center; color: var(--text); }
.icon-btn.plain { background: transparent; }
.badge { position: absolute; top: -2px; right: -2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--red); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }

.seg { display: inline-flex; background: var(--fill); border-radius: 9px; padding: 2px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 7px; font-size: 14px; font-weight: 500; color: var(--text); }
.seg button.on { background: var(--bg-2); box-shadow: 0 1px 3px rgba(0,0,0,.12); font-weight: 600; }
@media (prefers-color-scheme: dark) { .seg button.on { background: #636366; } }
.seg.full { display: flex; width: 100%; }
.seg.full button { flex: 1; }

/* ---------- Accesso ---------- */
.auth { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 380px; background: var(--bg-2); border-radius: 22px; padding: 32px 24px; box-shadow: var(--shadow); }
.auth-logo { display: grid; place-items: center; margin-bottom: 8px; }
.auth h1 { text-align: center; margin: 4px 0; font-size: 26px; }
.auth-card > p { text-align: center; margin: 0 0 20px; }
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 13px; color: var(--text-2); margin: 0 0 5px 2px; font-weight: 500; }
input:not([type=checkbox]):not([type=radio]):not([type=color]), select, textarea {
  width: 100%; border: 1px solid var(--sep); background: var(--bg-3); border-radius: 10px; padding: 10px 12px; outline: none; font-size: 16px;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; min-height: 70px; }

/* ---------- Struttura ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 250px; flex: none; position: sticky; top: 0; height: 100vh; overflow: auto;
  padding: 18px 12px; border-right: 1px solid var(--sep); background: var(--bg-2); display: flex; flex-direction: column; gap: 14px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 19px; padding: 0 8px; }
.new-btn { width: 100%; padding: 11px; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav button { display: flex; align-items: center; gap: 10px; border: 0; background: transparent; padding: 9px 10px; border-radius: 9px; text-align: left; font-size: 15px; color: var(--text); }
.side-nav button:hover { background: var(--fill); }
.side-nav button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.side-nav .count { margin-left: auto; font-size: 13px; color: var(--text-2); font-weight: 500; }
.side-nav .count.red { color: var(--red); font-weight: 700; }
.side-nav .sep { height: 1px; background: var(--sep); margin: 8px 6px; }
.side-foot { margin-top: auto; font-size: 13px; color: var(--text-2); padding: 0 8px; }
.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 24px; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--sep);
}
.topbar h1 { margin: 0; font-size: 24px; letter-spacing: -.02em; }
.topbar p { margin: 0; }
.topbar-left { min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.search { display: flex; align-items: center; gap: 6px; background: var(--fill); border-radius: 10px; padding: 0 10px; width: 240px; color: var(--text-2); }
.search input { border: 0 !important; background: transparent !important; box-shadow: none !important; padding: 8px 0 !important; color: var(--text); }
.avatar-btn { border: 0; padding: 0; background: none; }
.av { width: 30px; height: 30px; border-radius: 50%; display: inline-grid; place-items: center; color: #fff; font-size: 12px; font-weight: 700; flex: none; letter-spacing: .02em; }
.av.lg { width: 38px; height: 38px; font-size: 14px; }
.av.xs { width: 20px; height: 20px; font-size: 9px; }
#main { padding: 20px 24px 40px; outline: none; max-width: 1400px; width: 100%; }
.sync-banner { background: var(--orange-soft); color: var(--orange); text-align: center; font-size: 13px; padding: 6px; font-weight: 600; }
.tabbar { display: none; }

/* ---------- Card e liste ---------- */
.card { background: var(--bg-2); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 16px 6px; }
.card-h h2, .sec-title { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.card-h .btn.ghost { padding: 4px 6px; font-size: 14px; }
.empty { padding: 14px 16px 18px; color: var(--text-3); font-size: 15px; }
.empty.big { padding: 50px 16px; text-align: center; }
.empty.big .i { width: 44px; height: 44px; display: block; margin: 0 auto 10px; color: var(--text-3); }

.rlist { list-style: none; margin: 0; padding: 0; }
.ritem { display: flex; gap: 12px; padding: 11px 16px; align-items: flex-start; cursor: pointer; position: relative; }
.ritem + .ritem::before { content: ""; position: absolute; top: 0; left: 50px; right: 0; height: 1px; background: var(--sep); }
.ritem:hover { background: var(--bg-3); }
.check { flex: none; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--text-3); background: transparent; display: grid; place-items: center; padding: 0; margin-top: 1px; color: #fff; transition: all .15s; }
.check .i { width: 14px; height: 14px; opacity: 0; }
.check:hover { border-color: var(--accent); }
.check.p-alta { border-color: var(--orange); }
.check.p-urgente { border-color: var(--red); }
.check.half { border-color: var(--accent); background: linear-gradient(90deg, var(--accent-soft) 50%, transparent 50%); }
.check.done { background: var(--accent); border-color: var(--accent); }
.check.done .i { opacity: 1; }
.rbody { flex: 1; min-width: 0; }
.rtitle { font-size: 16px; font-weight: 500; overflow-wrap: anywhere; }
.ritem.is-done .rtitle { color: var(--text-2); text-decoration: line-through; text-decoration-color: var(--text-3); }
.rdesc { font-size: 14px; color: var(--text-2); margin-top: 1px; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.rmeta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 4px; font-size: 13px; color: var(--text-2); }
.rmeta .i { width: 14px; height: 14px; }
.rmeta > span { display: inline-flex; align-items: center; gap: 4px; }
.rmeta .late { color: var(--red); font-weight: 600; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.pri { font-weight: 700; font-size: 12px; padding: 2px 7px; border-radius: 6px; }
.pri.alta { background: var(--orange-soft); color: var(--orange); }
.pri.urgente { background: var(--red-soft); color: var(--red); }
.pri.bassa { background: var(--fill); color: var(--text-2); }
.st { font-size: 12px; font-weight: 600; padding: 2px 7px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); }
.ritem .rside { flex: none; display: flex; align-items: center; gap: 6px; }
.group-h { padding: 14px 16px 4px; font-size: 13px; font-weight: 700; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; display: flex; justify-content: space-between; }
.group-h.red { color: var(--red); }

/* ---------- Dashboard ---------- */
.greet { margin: 0 0 16px; }
.greet h2 { margin: 0; font-size: 28px; letter-spacing: -.02em; }
.quick { display: flex; gap: 8px; margin-bottom: 18px; }
.quick-input { flex: 1; display: flex; align-items: center; gap: 8px; background: var(--bg-2); border-radius: 14px; padding: 6px 6px 6px 14px; box-shadow: var(--shadow); }
.quick-input input { border: 0 !important; background: transparent !important; box-shadow: none !important; padding: 9px 0 !important; }
.quick-input .i { color: var(--accent); }
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; margin-bottom: 20px; }
.tile { background: var(--bg-2); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; border: 0; text-align: left; display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; gap: 6px 10px; align-items: center; transition: transform .1s; }
.tile:active { transform: scale(.98); }
.tile .ti { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: #fff; }
.tile .ti .i { width: 18px; height: 18px; }
.tile .tn { font-size: 26px; font-weight: 700; text-align: right; line-height: 1; }
.tile .tl { grid-column: 1 / -1; font-size: 15px; font-weight: 600; color: var(--text-2); }
.dash { display: grid; grid-template-columns: minmax(0,1.3fr) minmax(0,1fr); gap: 16px; align-items: start; }
.dash .col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.feed { list-style: none; margin: 0; padding: 4px 0 8px; }
.feed li { display: flex; gap: 10px; padding: 8px 16px; font-size: 14px; align-items: flex-start; }
.feed li .when { margin-left: auto; color: var(--text-3); font-size: 12px; white-space: nowrap; padding-left: 8px; }
.feed b { font-weight: 600; }
.feed .what { color: var(--text-2); }
.feed .link { cursor: pointer; }
.feed .link:hover b.t { text-decoration: underline; }

.person-block { padding: 6px 0; }
.person-h { display: flex; align-items: center; gap: 8px; padding: 6px 16px; font-weight: 600; font-size: 14px; }

/* ---------- Calendario ---------- */
.cal-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.cal-bar h2 { margin: 0; font-size: 21px; letter-spacing: -.01em; min-width: 0; text-transform: capitalize; }
.cal-bar .nav { display: flex; gap: 4px; }
.cal-bar .spacer { flex: 1; }
.cal-layout { display: grid; grid-template-columns: minmax(0,1fr) 320px; gap: 16px; align-items: start; }
.cal-side { display: flex; flex-direction: column; gap: 16px; }

.month { background: var(--bg-2); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.month-head { display: grid; grid-template-columns: repeat(7, 1fr); font-size: 12px; font-weight: 600; color: var(--text-2); text-transform: uppercase; text-align: center; padding: 8px 0; border-bottom: 1px solid var(--sep); }
.month-grid { display: grid; grid-template-columns: repeat(7, minmax(0,1fr)); }
.mcell { min-height: 104px; border-right: 1px solid var(--sep); border-bottom: 1px solid var(--sep); padding: 4px; cursor: pointer; position: relative; min-width: 0; background: none; border-top: 0; border-left: 0; text-align: left; display: flex; flex-direction: column; gap: 2px; }
.mcell:nth-child(7n) { border-right: 0; }
.mcell:hover { background: var(--bg-3); }
.mcell.out .mnum { color: var(--text-3); }
.mcell.sel { background: var(--accent-soft); }
.mnum { font-size: 13px; font-weight: 600; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; margin-bottom: 1px; }
.mcell.today .mnum { background: var(--red); color: #fff; }
.mev { font-size: 12px; line-height: 1.25; padding: 2px 5px; border-radius: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.mev.done { opacity: .5; text-decoration: line-through; }
.mmore { font-size: 11px; color: var(--text-2); padding-left: 5px; font-weight: 600; }
.mdots { display: none; gap: 3px; justify-content: center; flex-wrap: wrap; }

.week { display: grid; grid-template-columns: repeat(7, minmax(0,1fr)); gap: 8px; }
.wday { background: var(--bg-2); border-radius: 12px; box-shadow: var(--shadow); min-height: 300px; display: flex; flex-direction: column; min-width: 0; }
.wday-h { padding: 10px 10px 8px; border-bottom: 1px solid var(--sep); cursor: pointer; display: flex; align-items: baseline; gap: 6px; }
.wday-h .wd { font-size: 12px; color: var(--text-2); font-weight: 600; text-transform: uppercase; }
.wday-h .wn { font-size: 20px; font-weight: 700; }
.wday.today .wn { color: var(--red); }
.wday-b { padding: 6px; display: flex; flex-direction: column; gap: 5px; flex: 1; }
.wev { border-radius: 8px; padding: 6px 8px; font-size: 13px; cursor: pointer; border-left: 3px solid; min-width: 0; }
.wev .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.wev .h { font-size: 12px; opacity: .8; }
.wev.done { opacity: .5; }
.wev.done .t { text-decoration: line-through; }
.wadd { margin-top: auto; border: 0; background: none; color: var(--text-3); font-size: 22px; line-height: 1; padding: 6px; border-radius: 8px; }
.wadd:hover { background: var(--fill); color: var(--accent); }

.day { background: var(--bg-2); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.allday { padding: 8px 12px; border-bottom: 1px solid var(--sep); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.allday-l { font-size: 12px; color: var(--text-2); font-weight: 600; width: 52px; }
.hours { max-height: calc(100vh - 260px); overflow: auto; }
.hrow { display: flex; min-height: 54px; border-bottom: 1px solid var(--sep); cursor: pointer; }
.hrow:hover { background: var(--bg-3); }
.hrow.now { box-shadow: inset 0 2px 0 var(--red); }
.hlabel { width: 64px; flex: none; font-size: 12px; color: var(--text-2); padding: 6px 10px; text-align: right; font-variant-numeric: tabular-nums; }
.hbody { flex: 1; padding: 4px 8px 4px 0; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.hev { border-radius: 8px; padding: 6px 10px; font-size: 14px; border-left: 3px solid; display: flex; gap: 8px; align-items: center; cursor: pointer; }
.hev .t { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hev .h { font-size: 12px; opacity: .8; font-variant-numeric: tabular-nums; }
.hev.done { opacity: .5; }
.hev.done .t { text-decoration: line-through; }

/* ---------- Lista attività ---------- */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { border: 0; background: var(--bg-2); box-shadow: var(--shadow); border-radius: 20px; padding: 7px 14px; font-size: 14px; font-weight: 600; white-space: nowrap; color: var(--text); display: inline-flex; gap: 6px; align-items: center; }
.tabs button.on { background: var(--accent); color: #fff; }
.tabs button .n { font-size: 12px; opacity: .7; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; align-items: center; }
.filters select, .filters input[type=date] { width: auto; padding: 7px 10px; font-size: 14px; border-radius: 9px; background: var(--bg-2); }
.filters .lbl { font-size: 13px; color: var(--text-2); }
.list-search { display: none; margin-bottom: 12px; }

/* ---------- Impostazioni ---------- */
.settings { max-width: 760px; display: flex; flex-direction: column; gap: 18px; }
.srow { display: flex; align-items: center; gap: 12px; padding: 12px 16px; min-height: 52px; }
.srow + .srow { border-top: 1px solid var(--sep); }
.srow .grow { flex: 1; min-width: 0; }
.srow .lab { font-weight: 500; }
.srow .desc { font-size: 13px; color: var(--text-2); }
.switch { position: relative; width: 51px; height: 31px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: var(--fill-2); border-radius: 31px; transition: .2s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; width: 27px; height: 27px; left: 2px; top: 2px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.2); transition: .2s; }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:disabled + span { opacity: .4; cursor: default; }
.cat-row input[type=color] { width: 34px; height: 34px; border: 0; padding: 0; background: none; border-radius: 50%; cursor: pointer; flex: none; }
.cat-row input[type=text] { flex: 1; padding: 7px 10px; }
.note { padding: 12px 16px; font-size: 14px; color: var(--text-2); background: var(--bg-3); border-radius: 12px; margin: 0 16px 14px; }
.note.warn { background: var(--orange-soft); color: var(--text); }
.note b { color: var(--text); }
.creds { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; white-space: pre-wrap; background: var(--bg-3); border-radius: 10px; padding: 12px; margin: 10px 0; user-select: all; }

/* ---------- Finestre ---------- */
.overlay { position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.35); display: flex; align-items: center; justify-content: center; padding: 20px; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(24px); opacity: .6; } }
.sheet { background: var(--bg); width: 100%; max-width: 620px; max-height: calc(100vh - 40px); border-radius: 18px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; overflow: hidden; animation: up .2s ease-out; }
.sheet.sm { max-width: 420px; }
.sheet-h { display: flex; align-items: center; gap: 8px; padding: 12px 12px 10px 18px; border-bottom: 1px solid var(--sep); background: var(--bg-2); }
.sheet-h h3 { margin: 0; font-size: 17px; flex: 1; text-align: center; }
.sheet-b { padding: 16px; overflow: auto; flex: 1; display: flex; flex-direction: column; gap: 14px; overscroll-behavior: contain; }
.sheet-f { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--sep); display: flex; gap: 8px; background: var(--bg-2); flex-wrap: wrap; }
.sheet-f .grow { flex: 1; }
.group { background: var(--bg-2); border-radius: 12px; padding: 4px 14px; }
.group .row { display: flex; align-items: center; gap: 10px; padding: 9px 0; min-height: 46px; }
.group .row + .row { border-top: 1px solid var(--sep); }
.group .row > label:first-child, .group .row > .rl { width: 110px; flex: none; font-size: 15px; color: var(--text); }
.group .row input, .group .row select, .group .row textarea { background: transparent; border-color: transparent; padding: 6px 4px; }
.group .row input:focus, .group .row select:focus, .group .row textarea:focus { background: var(--bg-3); }
.group .row.col { flex-direction: column; align-items: stretch; gap: 4px; }
.group .row.col > label:first-child { width: auto; font-size: 13px; color: var(--text-2); }
.title-input { font-size: 20px !important; font-weight: 600; border: 0 !important; background: var(--bg-2) !important; border-radius: 12px !important; padding: 14px !important; }
.nl { background: var(--bg-2); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.nl-top { display: flex; gap: 6px; align-items: center; }
.nl-top .i { color: var(--purple); }
.nl-top input { flex: 1; border: 0 !important; background: var(--bg-3) !important; padding: 9px 10px !important; }
.nl-hint { font-size: 13px; color: var(--text-2); }
.nl-result { font-size: 14px; background: var(--green-soft); border-radius: 9px; padding: 8px 10px; }
.mic { width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--fill); display: grid; place-items: center; flex: none; color: var(--text); }
.mic.rec { background: var(--red); color: #fff; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px var(--red-soft); } }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { border: 1px solid var(--sep); background: var(--bg-2); border-radius: 18px; padding: 5px 11px; font-size: 14px; display: inline-flex; gap: 6px; align-items: center; color: var(--text); }
.chips button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chips button.on .dot { box-shadow: 0 0 0 2px #fff; }
.pchips button.on[data-v=bassa] { background: var(--text-2); border-color: var(--text-2); }
.pchips button.on[data-v=alta] { background: var(--orange); border-color: var(--orange); }
.pchips button.on[data-v=urgente] { background: var(--red); border-color: var(--red); }
.more-toggle { border: 0; background: none; color: var(--accent); font-weight: 600; padding: 4px 2px; text-align: left; font-size: 15px; }
.meta-info { font-size: 13px; color: var(--text-2); text-align: center; }
.history { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.history li { padding: 7px 0; display: flex; gap: 8px; align-items: center; }
.history li + li { border-top: 1px solid var(--sep); }
.history .when { margin-left: auto; color: var(--text-3); font-size: 12px; white-space: nowrap; }

.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 100%; max-width: 400px; background: var(--bg); z-index: 101; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: slide .2s ease-out; }
@keyframes slide { from { transform: translateX(40px); opacity: .5; } }
.nitem { display: flex; gap: 10px; padding: 12px 16px; cursor: pointer; border-bottom: 1px solid var(--sep); background: var(--bg-2); }
.nitem.unread { background: color-mix(in srgb, var(--accent) 7%, var(--bg-2)); }
.nitem .ni { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex: none; color: #fff; }
.nitem .ni .i { width: 17px; height: 17px; }
.nitem .nt { font-weight: 600; font-size: 15px; }
.nitem .nb { font-size: 14px; color: var(--text-2); }
.nitem .nw { font-size: 12px; color: var(--text-3); margin-top: 2px; }

.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast { background: rgba(30,30,32,.94); color: #fff; padding: 11px 16px; border-radius: 14px; font-size: 15px; box-shadow: var(--shadow-lg); display: flex; gap: 12px; align-items: center; pointer-events: auto; animation: up .2s; max-width: 100%; }
.toast button { background: none; border: 0; color: #64d2ff; font-weight: 700; padding: 0; }
.toast.err { background: var(--red); }

/* ---------- Tablet ---------- */
@media (max-width: 1100px) {
  .search { width: 180px; }
  .cal-layout { grid-template-columns: 1fr; }
  .cal-side { display: grid; grid-template-columns: 1fr 1fr; }
}
@media (max-width: 1000px) {
  .sidebar { width: 210px; }
  .dash { grid-template-columns: 1fr; }
  .week { grid-template-columns: repeat(4, minmax(0,1fr)); }
}

/* ---------- Telefono ---------- */
@media (max-width: 760px) {
  body { font-size: 16px; }
  .sidebar { display: none; }
  .topbar { padding: calc(10px + env(safe-area-inset-top)) 16px 10px; flex-wrap: wrap; gap: 8px; }
  .topbar h1 { font-size: 26px; }
  .topbar .search { display: none; }
  .topbar-right { gap: 8px; }
  .space-switch { order: 5; width: 100%; display: flex; }
  .space-switch button { flex: 1; }
  .topbar-right { flex-wrap: wrap; justify-content: flex-end; }
  .topbar { display: grid; grid-template-columns: 1fr auto; }
  .topbar-right { display: contents; }
  .topbar #bell { grid-column: 2; grid-row: 1; justify-self: end; margin-right: 46px; }
  .topbar #me-avatar { grid-column: 2; grid-row: 1; justify-self: end; }
  .topbar .space-switch { grid-column: 1 / -1; grid-row: 2; }
  #main { padding: 14px 16px calc(var(--tabbar-h) + 30px + env(safe-area-inset-bottom)); }
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    padding: 4px 6px env(safe-area-inset-bottom); background: color-mix(in srgb, var(--bg-2) 88%, transparent); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); border-top: 1px solid var(--sep);
  }
  .tabbar button { flex: 1; border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; font-weight: 500; color: var(--text-2); }
  .tabbar button .i { width: 24px; height: 24px; }
  .tabbar button.on { color: var(--accent); }
  .tabbar .tab-new { flex: none; width: 56px; height: 56px; border-radius: 50%; background: var(--accent); color: #fff; margin: -18px 6px 0; box-shadow: 0 6px 18px rgba(10,132,255,.45); align-self: flex-start; }
  .tabbar .tab-new .i { width: 28px; height: 28px; }
  .tiles { grid-template-columns: 1fr 1fr; gap: 10px; }
  .greet h2 { font-size: 22px; }
  .cal-side { grid-template-columns: 1fr; }
  .mcell { min-height: 54px; padding: 3px 2px; align-items: center; }
  .mcell .mev, .mcell .mmore { display: none; }
  .mcell .mdots { display: flex; }
  .mnum { font-size: 15px; width: 28px; height: 28px; }
  .week { grid-template-columns: 1fr; }
  .wday { min-height: 0; }
  .wday-b { padding: 6px 8px 8px; }
  .wadd { display: none; }
  .cal-bar h2 { font-size: 19px; width: 100%; order: -1; }
  .cal-bar .seg { margin-left: auto; }
  .hours { max-height: none; }
  .list-search { display: block; }
  .overlay { padding: 0; align-items: flex-end; }
  .sheet { max-width: none; max-height: calc(100vh - 30px - env(safe-area-inset-top)); border-radius: 18px 18px 0 0; }
  .drawer { max-width: none; }
  .group .row > label:first-child, .group .row > .rl { width: 92px; }
  .toasts { bottom: calc(var(--tabbar-h) + 20px + env(safe-area-inset-bottom)); }
  .filters select, .filters input[type=date] { flex: 1 1 40%; }
}
@media (max-width: 380px) {
  .tiles .tile .tn { font-size: 22px; }
  .seg button { padding: 6px 8px; }
}
