/* Paleta "Índigo + coral".
   - Marca: índigo (confiança, foco) com acento coral (calor, destaque) — o mesmo par do ícone.
   - Neutros levemente azulados, para combinar com a marca em vez de cinza "puro".
   - Cores de estado (vermelho/âmbar/verde) separadas da marca e com contraste WCAG AA (≥ 4,5:1)
     nos dois temas; texto sobre cor sólida usa --on-solid para continuar legível no escuro. */
:root {
  --bg: #f5f6fb;
  --surface: #ffffff;
  --surface-2: #eef0f8;
  --border: #dfe3ef;
  --text: #161a2e;
  --muted: #5b6382;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-text: #ffffff;
  --primary-soft: #ecebfe;
  --accent: #f9735b;
  --danger: #dc2626;
  --warn: #b45309;
  --ok: #15803d;
  --on-solid: #ffffff;
  --shadow: 0 1px 2px rgba(22, 26, 46, .05), 0 2px 6px rgba(22, 26, 46, .06);
  --radius: 12px;

  /* Categorias da agenda: tons fechados o suficiente para texto branco (≥ 4,8:1). */
  --c-blue: #0369a1;
  --c-green: #15803d;
  --c-red: #dc2626;
  --c-orange: #c2410c;
  --c-purple: #7c3aed;
  --c-gray: #4b5563;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0f1d;
    --surface: #141a2e;
    --surface-2: #1c2340;
    --border: #2a3255;
    --text: #e7e9f6;
    --muted: #9aa2c6;
    --primary: #8b8ff9;
    --primary-hover: #a5a8fb;
    --primary-text: #0c0f1d;
    --primary-soft: #252a5a;
    --accent: #fb8a74;
    --danger: #f87171;
    --warn: #fbbf24;
    --ok: #4ade80;
    --on-solid: #141a2e;
    --shadow: 0 1px 2px rgba(0, 0, 0, .45);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; line-height: 1.2; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 11px;
  min-width: 0;
  width: 100%;
}
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}
textarea { resize: vertical; }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--primary); flex: none; margin: 0; }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: 8px;
  padding: 9px 14px; cursor: pointer; white-space: nowrap;
  background: var(--surface-2);
  font-weight: 500;
}
.btn.primary { background: var(--primary); color: var(--primary-text); }
.btn.primary:hover { background: var(--primary-hover); }
.btn.ghost { background: transparent; border-color: var(--border); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--danger); }
.btn.small { padding: 6px 10px; font-size: .9rem; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .6; cursor: default; }

.segmented { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; }
.segmented button {
  border: 0; background: transparent; padding: 7px 14px; border-radius: 8px; cursor: pointer; color: var(--muted);
}
.segmented button[aria-selected="true"], .segmented button[aria-pressed="true"] {
  background: var(--surface); color: var(--text); box-shadow: var(--shadow);
}
.segmented.small button { padding: 5px 10px; font-size: .9rem; }

/* ---------- Login ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card {
  width: 100%; max-width: 380px; background: var(--surface); border-radius: 16px;
  padding: 28px 24px; box-shadow: var(--shadow); display: grid; gap: 14px; text-align: center;
}
.auth-logo { margin: 0 auto; }
.auth-card .segmented { justify-self: center; }
.auth-card form { display: grid; gap: 12px; text-align: left; }

.field { display: grid; gap: 5px; margin: 0; border: 0; padding: 0; min-width: 0; }
.field > span, .field > legend { font-size: .85rem; font-weight: 600; color: var(--muted); padding: 0; }
.form-error { color: var(--danger); margin: 0; min-height: 0; font-size: .9rem; }
.form-error:empty { display: none; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.self-end { align-self: end; padding-bottom: 10px; }
.hint { margin: 0; font-size: .85rem; color: var(--muted); background: var(--surface-2); padding: 8px 10px; border-radius: 8px; }

/* ---------- Estrutura ---------- */
.app { min-height: 100vh; padding-bottom: 76px; }
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px;
  padding: 10px max(16px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.05rem; }
.user-menu { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: .9rem; }

.tabs { display: flex; gap: 4px; }
.tab {
  display: flex; align-items: center; gap: 6px; border: 0; background: transparent; cursor: pointer;
  padding: 8px 14px; border-radius: 8px; color: var(--muted); font-weight: 500;
}
.tab svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tab:hover { background: var(--surface-2); }
.tab[aria-current="page"] { color: var(--primary); background: var(--primary-soft); }

.view { max-width: 1100px; margin: 0 auto; padding: 20px 16px; }
.view-head { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.view-head h2 { margin-right: auto; }
.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline-select select { width: auto; padding: 6px 10px; font-size: .9rem; }

.quick-add { display: flex; gap: 8px; margin-bottom: 14px; }
.quick-add input[name="title"], .quick-add input[name="text"], .quick-add input[name="name"] { flex: 1; }
.quick-add input[type="date"] { width: 150px; }
.quick-add select { width: 110px; }
.quick-add .qty { width: 90px; }

.card-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.card {
  display: flex; align-items: flex-start; gap: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px;
}
.card.clickable { cursor: pointer; }
.card.clickable:hover { border-color: color-mix(in srgb, var(--primary) 50%, var(--border)); }
.card .check-wrap { padding-top: 2px; }
.card-main { flex: 1; min-width: 0; border: 0; background: transparent; padding: 0; text-align: left; cursor: pointer; }
button.card { width: 100%; text-align: left; cursor: pointer; }
.card-title { display: block; font-weight: 500; overflow-wrap: anywhere; }
.list-card { flex-direction: column; align-items: stretch; gap: 0; }
.progress { display: block; }
.card.done .card-title { text-decoration: line-through; color: var(--muted); }
.card-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; font-size: .82rem; color: var(--muted); }
.card-notes { display: block; margin-top: 4px; font-size: .85rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn {
  border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 2px 6px; border-radius: 6px; font-size: 1.1rem; line-height: 1;
}
.icon-btn:hover { background: var(--surface-2); color: var(--danger); }

.chip { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); }
.chip.overdue { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); font-weight: 600; }
.chip.today { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); font-weight: 600; }
.chip.p3 { color: var(--danger); }
.chip.p1 { color: var(--ok); }

.empty { color: var(--muted); text-align: center; padding: 28px 12px; margin: 0; }

/* ---------- Início (dashboard) ---------- */
.home-head { align-items: flex-end; }
.home-title h2 { font-size: 1.5rem; }
.home-title p { margin: 4px 0 0; }
.home-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.home-stat {
  display: grid; gap: 2px; text-align: left; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px;
  border-left: 4px solid var(--border);
}
.home-stat:hover { border-color: color-mix(in srgb, var(--primary) 50%, var(--border)); }
.home-stat .stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.home-stat .stat-label { color: var(--muted); font-size: .85rem; }
.home-stat.is-danger { border-left-color: var(--danger); }
.home-stat.is-danger .stat-value { color: var(--danger); }
.home-stat.is-warn { border-left-color: var(--warn); }
.home-stat.is-warn .stat-value { color: var(--warn); }

.home-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.home-side { display: grid; gap: 16px; }
.home-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 16px; display: grid; gap: 12px; }
.home-card .card { background: var(--bg); }
.home-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.home-quick { margin-bottom: 0; }
.home-group { display: grid; gap: 8px; }
.home-group + .home-group { margin-top: 6px; }
.home-group-title {
  margin: 0; font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
  display: flex; align-items: center; gap: 6px;
}
.home-group-title .count { background: var(--surface-2); border-radius: 999px; padding: 0 7px; font-size: .75rem; }
.home-group-title.is-danger { color: var(--danger); }
.home-group-title.is-danger .count { background: color-mix(in srgb, var(--danger) 14%, transparent); }
.home-group-title.is-warn { color: var(--warn); }
.home-group-title.is-warn .count { background: color-mix(in srgb, var(--warn) 16%, transparent); }
.home-more { justify-self: start; }
.empty.compact { padding: 14px 8px; }

.link-btn {
  border: 0; background: transparent; color: var(--primary); cursor: pointer; font-weight: 600; font-size: .88rem; padding: 4px 2px;
}
.link-btn:hover { text-decoration: underline; }

.event-card.past { opacity: .6; }
.chip.now { color: var(--on-solid); background: var(--ok); font-weight: 600; }

/* ---------- Listas ---------- */
.lists-layout { display: grid; grid-template-columns: 320px 1fr; gap: 24px; align-items: start; }
.list-card.active { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.progress { height: 4px; background: var(--surface-2); border-radius: 4px; overflow: hidden; margin-top: 8px; }
.progress > span { display: block; height: 100%; background: var(--ok); transition: width .2s; }
.list-detail { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 18px; min-height: 240px; }
.list-detail .card { background: var(--bg); }
.list-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; gap: 8px; }
.back-btn { display: none; }
.qty-badge { font-size: .82rem; color: var(--muted); background: var(--surface-2); padding: 1px 8px; border-radius: 999px; margin-left: 6px; }

/* Larguras de barras de progresso sem estilos inline (CSP) */
.w-0{width:0}.w-5{width:5%}.w-10{width:10%}.w-15{width:15%}.w-20{width:20%}.w-25{width:25%}.w-30{width:30%}
.w-35{width:35%}.w-40{width:40%}.w-45{width:45%}.w-50{width:50%}.w-55{width:55%}.w-60{width:60%}.w-65{width:65%}
.w-70{width:70%}.w-75{width:75%}.w-80{width:80%}.w-85{width:85%}.w-90{width:90%}.w-95{width:95%}.w-100{width:100%}

/* ---------- Agenda ---------- */
.agenda-layout { display: grid; grid-template-columns: 1fr 320px; gap: 20px; align-items: start; }
.calendar { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; overflow: hidden; }
.cal-weekdays, .cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-weekdays span { padding: 8px; font-size: .78rem; font-weight: 600; color: var(--muted); text-transform: uppercase; text-align: center; border-bottom: 1px solid var(--border); }
.cal-day {
  min-height: 96px; border: 0; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
  background: transparent; padding: 6px; text-align: left; cursor: pointer; display: flex; flex-direction: column; gap: 3px; min-width: 0;
}
.cal-day:nth-child(7n) { border-right: 0; }
.cal-day:nth-last-child(-n+7) { border-bottom: 0; }
.cal-day:hover { background: var(--surface-2); }
.cal-day.other { color: var(--muted); background: color-mix(in srgb, var(--surface-2) 45%, transparent); }
.cal-day .num { font-size: .85rem; font-weight: 600; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; }
.cal-day.today .num { background: var(--primary); color: var(--primary-text); }
.cal-day.selected { box-shadow: inset 0 0 0 2px var(--primary); }
.cal-chip {
  font-size: .72rem; padding: 1px 6px; border-radius: 4px; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cal-more { font-size: .72rem; color: var(--muted); padding-left: 4px; }
.cal-dots { display: none; gap: 3px; flex-wrap: wrap; }
.cal-dot { width: 6px; height: 6px; border-radius: 50%; }

.day-panel { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 16px; display: grid; gap: 12px; }
.day-panel .card { background: var(--bg); border-left-width: 4px; }
.event-time { font-size: .82rem; font-weight: 600; color: var(--muted); min-width: 48px; padding-top: 1px; }

.bg-blue { background: var(--c-blue); } .bd-blue { border-left-color: var(--c-blue) !important; }
.bg-green { background: var(--c-green); } .bd-green { border-left-color: var(--c-green) !important; }
.bg-red { background: var(--c-red); } .bd-red { border-left-color: var(--c-red) !important; }
.bg-orange { background: var(--c-orange); } .bd-orange { border-left-color: var(--c-orange) !important; }
.bg-purple { background: var(--c-purple); } .bd-purple { border-left-color: var(--c-purple) !important; }
.bg-gray { background: var(--c-gray); } .bd-gray { border-left-color: var(--c-gray) !important; }

.color-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.color-option { position: relative; }
.color-option input { position: absolute; opacity: 0; inset: 0; cursor: pointer; width: 100%; height: 100%; }
.color-option span {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border: 1px solid var(--border); border-radius: 999px; font-size: .88rem;
}
.color-option span::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--dot); }
.color-option input:checked + span { border-color: var(--primary); background: var(--primary-soft); font-weight: 600; }
.color-option input:focus-visible + span { outline: 2px solid var(--primary); }
.dot-blue { --dot: var(--c-blue); } .dot-green { --dot: var(--c-green); } .dot-red { --dot: var(--c-red); }
.dot-orange { --dot: var(--c-orange); } .dot-purple { --dot: var(--c-purple); } .dot-gray { --dot: var(--c-gray); }

/* ---------- Administração ---------- */
.admin-tabs { flex-wrap: wrap; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px;
}
.stat .stat-value { display: block; font-size: 1.7rem; font-weight: 700; line-height: 1.1; }
.stat .stat-label { display: block; color: var(--muted); font-size: .85rem; margin-top: 4px; }
.stat .stat-sub { display: block; color: var(--muted); font-size: .78rem; margin-top: 2px; }

.user-card .card-title { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.badge { font-size: .72rem; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.badge.admin { background: var(--primary-soft); color: var(--primary); }
.badge.blocked { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.badge.you { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.user-meta { margin: -6px 0 0; font-size: .85rem; }
.user-tools { display: flex; flex-wrap: wrap; gap: 8px; }

.settings-groups { display: grid; gap: 16px; }
.settings-group { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 16px; margin: 0; }
.settings-group > legend, .settings-group > h3 { font-weight: 700; font-size: 1rem; padding: 0; }
.settings-group > legend { float: left; width: 100%; margin-bottom: 4px; }
.settings-group > legend + * { clear: both; }
.settings-group > h3 { padding: 0; margin-bottom: 6px; }
.setting-row {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(160px, 260px); gap: 6px 16px; align-items: center;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.setting-row:last-child { border-bottom: 0; padding-bottom: 0; }
.setting-row .setting-label { font-weight: 500; }
.setting-row .setting-desc { display: block; font-size: .82rem; color: var(--muted); font-weight: 400; margin-top: 2px; }
.setting-row .setting-default { display: block; font-size: .78rem; color: var(--muted); font-weight: 400; margin-top: 2px; }
.setting-row.dirty .setting-label::after { content: " •"; color: var(--warn); }
.setting-control { justify-self: end; width: 100%; display: flex; justify-content: flex-end; }
.switch { position: relative; width: 44px; height: 26px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; background: var(--border); border-radius: 999px; transition: background .15s; }
.switch span::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff;
  transition: transform .15s; box-shadow: 0 1px 2px rgba(0, 0, 0, .3);
}
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
.settings-actions {
  position: sticky; bottom: 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 12px 0; background: var(--bg); margin-top: 8px;
}
.env-box { margin-top: 16px; }
.env-list { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 10px 0 0; }
.env-list dt { font-family: ui-monospace, Consolas, monospace; font-weight: 600; }
.env-list dd { margin: 0; }
.env-list dd small { display: block; color: var(--muted); }
code { font-family: ui-monospace, Consolas, monospace; font-size: .9em; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }

.log-entry { flex-direction: column; gap: 2px; }
.log-entry .log-details { font-size: .82rem; color: var(--muted); overflow-wrap: anywhere; }

/* ---------- Diálogos ---------- */
.dialog {
  border: 0; border-radius: 16px; padding: 0; width: min(520px, calc(100vw - 24px));
  background: var(--surface); color: var(--text); box-shadow: 0 20px 50px rgba(0, 0, 0, .25);
}
.dialog::backdrop { background: rgba(10, 15, 25, .5); }
.dialog .dialog-body { padding: 20px; display: grid; gap: 12px; max-height: calc(100vh - 40px); overflow: auto; }
.ql-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.ql-origin { margin: -8px 0 0; font-size: .85rem; }
.ql-origin:empty { display: none; }
.ql-add { margin-bottom: 0; }
.ql-items .card { background: var(--bg); padding: 10px 12px; }
.ql-items { max-height: 50vh; overflow: auto; }

/* Minha conta */
.dialog.dialog-wide { width: min(640px, calc(100vw - 24px)); }
.account-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.account-email { margin: 2px 0 0; font-size: .88rem; }
.stack { display: grid; gap: 12px; }
.token-form { display: grid; grid-template-columns: minmax(0, 2fr) minmax(150px, 1.2fr) minmax(100px, 1fr) auto; gap: 10px; align-items: end; }
.token-form .token-error { grid-column: 1 / -1; }
.token-created {
  display: grid; gap: 8px; padding: 12px; border-radius: 10px;
  background: color-mix(in srgb, var(--ok) 12%, transparent); border: 1px solid color-mix(in srgb, var(--ok) 40%, transparent);
}
.token-value-row { display: flex; gap: 8px; align-items: center; }
.token-value-row code { flex: 1; min-width: 0; overflow-wrap: anywhere; padding: 8px; background: var(--surface); font-size: .85rem; user-select: all; }
.token-card { flex-direction: column; align-items: stretch; gap: 4px; }
.token-card .token-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.token-card .token-row .spacer { flex: 1; }
.badge.write { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.api-help summary { cursor: pointer; font-weight: 600; }
.api-help pre {
  background: var(--surface-2); padding: 10px 12px; border-radius: 8px; overflow-x: auto;
  font-family: ui-monospace, Consolas, monospace; font-size: .8rem; white-space: pre; margin: 8px 0;
}

/* Chip clicável da lista vinculada */
.list-link {
  display: inline-flex; align-items: center; gap: 6px; align-self: center; flex: none;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  border-radius: 999px; padding: 4px 10px; font-size: .82rem; cursor: pointer; white-space: nowrap; max-width: 100%;
}
.list-link:hover { border-color: var(--primary); color: var(--primary); }
.list-link svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.list-link .ll-name { overflow: hidden; text-overflow: ellipsis; }
.list-link .ll-count { color: var(--muted); }
.list-link.complete .ll-count { color: var(--ok); font-weight: 600; }
.event-card { flex-wrap: wrap; row-gap: 8px; }
.event-card .card-main { flex: 1 1 100%; }
.event-card .list-link { margin-left: 60px; }
.event-main { display: flex; gap: 12px; align-items: flex-start; }
.cal-chip .ll-icon { opacity: .85; }

.dialog > form { padding: 20px; display: grid; gap: 12px; max-height: calc(100vh - 40px); overflow: auto; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.dialog-actions { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.spacer { flex: 1; }

.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); z-index: 100;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow);
  max-width: calc(100vw - 32px); font-size: .92rem;
}
.toast.error { background: var(--danger); color: var(--on-solid); }

/* ---------- Responsivo ---------- */
@media (min-width: 761px) {
  .app { padding-bottom: 0; }
  .toast { bottom: 24px; }
}

@media (max-width: 960px) {
  .agenda-layout { grid-template-columns: 1fr; }
  .home-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .brand span { display: none; }
  /* backdrop-filter cria um containing block e prenderia a barra fixa de abas dentro do cabeçalho */
  .topbar { backdrop-filter: none; background: var(--surface); }
  .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    background: var(--surface); border-top: 1px solid var(--border);
    justify-content: space-around; padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  }
  .tab { flex-direction: column; gap: 2px; font-size: .75rem; padding: 6px 12px; flex: 1; }
  .tab[aria-current="page"] { background: transparent; }

  .quick-add { flex-wrap: wrap; }
  .quick-add input[name="title"], .quick-add input[name="text"] { flex-basis: 100%; }
  .quick-add input[type="date"], .quick-add select, .quick-add .qty { flex: 1; width: auto; }

  .lists-layout { grid-template-columns: 1fr; }
  .lists-layout.has-selection .lists-side { display: none; }
  .lists-layout:not(.has-selection) .list-detail { display: none; }
  .back-btn { display: inline-flex; }
  .list-detail { padding: 14px; }

  .tab { padding: 6px 4px; }
  .home-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .home-stat { padding: 10px 12px; }
  .home-stat .stat-value { font-size: 1.35rem; }
  .home-title h2 { font-size: 1.3rem; }
  .home-card { padding: 14px; }
  .home-quick { flex-wrap: nowrap; }
  .home-quick input[name="title"] { flex-basis: auto; }
  .token-form { grid-template-columns: 1fr 1fr; }
  .token-form label:first-child { grid-column: 1 / -1; }
  .account-btn span { max-width: 110px; overflow: hidden; text-overflow: ellipsis; }
  .task-card { flex-wrap: wrap; row-gap: 8px; }
  .task-card .card-main { flex: 1 1 calc(100% - 40px); }
  .task-card .list-link { margin-left: 30px; }
  .setting-row { grid-template-columns: 1fr; }
  .setting-control { justify-content: flex-start; }
  .settings-actions { bottom: 64px; }
  .env-list { grid-template-columns: 1fr; gap: 2px; }
  .env-list dd { margin-bottom: 8px; }

  .cal-day { min-height: 54px; padding: 4px; align-items: center; }
  .cal-chip, .cal-more { display: none; }
  .cal-dots { display: flex; justify-content: center; }
}
