:root {
  --bg: #0a101c;
  --bg2: #0f1726;
  --panel: #131d2e;
  --panel-h: #172338;
  --border: #22304a;
  --text: #eaf0f8;
  --muted: #8796ad;
  --primary: #0ea5e9;
  --primary-h: #38bdf8;
  --red: #f05252;
  --orange: #f59e0b;
  --yellow: #eab308;
  --slate: #64748b;
  --green: #22c55e;
  --radius: 14px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html { background: var(--bg); }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "SF Pro Text", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
svg { width: 18px; height: 18px; flex: none; }
button { font: inherit; color: inherit; cursor: pointer; }
.container { max-width: 980px; margin: 0 auto; padding: 0 18px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
[hidden] { display: none !important; }

/* ---------- Topo ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(10, 16, 28, 0.94);
  backdrop-filter: saturate(160%) blur(14px); -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid rgba(34, 48, 74, .7);
  padding-top: var(--safe-t);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 14px; padding-bottom: 14px; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-icon { width: 42px; height: 42px; border-radius: 12px; background: linear-gradient(145deg, rgba(14,165,233,.22), rgba(14,165,233,.08)); color: var(--primary); display: grid; place-items: center; flex: none; border: 1px solid rgba(14,165,233,.18); }
.brand-icon svg { width: 22px; height: 22px; }
.brand h1 { font-size: 19px; margin: 0; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; }
.brand p { margin: 2px 0 0; font-size: 13px; }
.brand p b { color: var(--primary); font-weight: 700; }
.top-actions { display: flex; align-items: center; gap: 8px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 11px; border: 1px solid transparent;
  font-size: 14px; font-weight: 600; transition: background .15s, border-color .15s, opacity .15s, transform .1s;
  white-space: nowrap;
}
.btn:active { transform: scale(.98); }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); color: #03121c; }
.btn-primary:hover { background: var(--primary-h); }
.btn-outline { background: var(--panel); border-color: var(--border); }
.btn-outline:hover { border-color: #33476a; }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-ghost:hover { background: var(--panel); }
.btn-danger { background: var(--red); color: #fff; }
.btn.wide { width: 100%; margin: 12px 0 24px; }
.btn:disabled { opacity: .55; cursor: default; }
.danger-text { color: #fca5a5; border-color: rgba(240,82,82,.35); }
.push-left { margin-right: auto; }

.sync-badge {
  display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 11px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--panel); font-size: 12px; color: var(--muted);
}
.sync-badge .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--slate); }
.sync-badge.ok .dot { background: var(--green); box-shadow: 0 0 0 3px rgba(34,197,94,.15); }
.sync-badge.busy .dot { background: var(--yellow); animation: blink 1s infinite; }
.sync-badge.err .dot { background: var(--red); }
@keyframes blink { 50% { opacity: .35; } }

/* ---------- Números ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 22px 0 18px; }
.stat {
  display: flex; align-items: center; gap: 12px; text-align: left;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px;
  transition: border-color .15s, background .15s;
}
.stat:hover { border-color: #31456a; background: var(--panel-h); }
.stat strong { display: block; font-size: 24px; line-height: 1.1; font-weight: 700; letter-spacing: -.02em; }
.stat small { color: var(--muted); font-size: 12px; }
.stat-icon { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; flex: none; }
.stat-icon.red { background: rgba(240,82,82,.12); color: var(--red); }
.stat-icon.blue { background: rgba(14,165,233,.12); color: var(--primary); }
.stat-icon.gray { background: rgba(148,163,184,.12); color: #a9b7ca; }
.stat-icon.green { background: rgba(34,197,94,.12); color: var(--green); }
.stat[data-jump="atraso"] strong { color: #ff8a8a; }

/* ---------- Abas ---------- */
.tabs { display: inline-flex; gap: 4px; padding: 4px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 20px; }
.tab { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 0; background: transparent; color: var(--muted); padding: 8px 14px; border-radius: 9px; font-size: 13px; font-weight: 600; }
.tab svg { width: 15px; height: 15px; }
.tab.active { background: var(--primary); color: #03121c; }

/* ---------- Seções ---------- */
.section { margin-bottom: 26px; scroll-margin-top: calc(var(--safe-t) + 90px); }
.section-head { display: flex; align-items: center; gap: 8px; margin: 0 0 10px 2px; font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.section-head .count { font-size: 12px; font-weight: 700; color: var(--muted); background: var(--panel); border: 1px solid var(--border); border-radius: 999px; padding: 1px 8px; }
.section-head svg { width: 17px; height: 17px; }
.section-head.red svg { color: var(--red); }
.section-head.red .count { color: #ff9b9b; background: rgba(240,82,82,.1); border-color: rgba(240,82,82,.25); }
.section-head.blue svg { color: var(--primary); }
.section-head.gray svg { color: #a9b7ca; }
.section-head.green svg { color: var(--green); }
.section-head.toggle { cursor: pointer; user-select: none; }
.section-head.toggle .chev { margin-left: auto; transition: transform .2s; color: var(--muted); }
.section-head.toggle.open .chev { transform: rotate(180deg); }
.empty-mini { color: var(--muted); font-size: 13px; padding: 13px 16px; border: 1px dashed var(--border); border-radius: var(--radius); }

/* ---------- Tarefa ---------- */
.cards { display: grid; gap: 8px; }
.card {
  position: relative; display: flex; gap: 12px; align-items: flex-start;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 13px 12px 13px 14px; cursor: pointer;
  transition: background .15s, border-color .15s;
  animation: fadein .18s ease;
}
.card:hover { background: var(--panel-h); border-color: #2d3f5f; }
.card:active { background: var(--panel-h); }
@keyframes fadein { from { opacity: 0; transform: translateY(2px); } to { opacity: 1; transform: none; } }
.card.overdue { border-color: rgba(240,82,82,.28); background: linear-gradient(90deg, rgba(240,82,82,.08), rgba(240,82,82,0) 60%), var(--panel); }

.chk {
  width: 24px; height: 24px; margin-top: 1px; border-radius: 50%; border: 2px solid var(--slate);
  background: transparent; display: grid; place-items: center; flex: none; color: transparent; padding: 0;
  transition: background .15s, border-color .15s, color .15s;
}
.chk svg { width: 13px; height: 13px; }
.chk:hover { color: rgba(255,255,255,.5); }
.u-maior .chk { border-color: var(--red); }
.u-alta .chk { border-color: var(--orange); }
.u-media .chk { border-color: var(--yellow); }
.u-baixa .chk { border-color: var(--slate); }
.card.done .chk { background: var(--green); border-color: var(--green); color: #052e14; }
.card.done .card-title { text-decoration: line-through; color: var(--muted); font-weight: 500; }
.card.done .meta, .card.done .card-desc { opacity: .7; }

.card-body { flex: 1; min-width: 0; }
.card-title { font-size: 15px; line-height: 1.35; font-weight: 600; margin: 0; word-break: break-word; }
.card-desc { font-size: 13px; line-height: 1.4; color: var(--muted); margin: 3px 0 0; white-space: pre-wrap; word-break: break-word; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-top: 6px; font-size: 12px; color: var(--muted); }
.meta svg { width: 13px; height: 13px; }
.due { display: inline-flex; align-items: center; gap: 4px; }
.due.late { color: #ff8a8a; font-weight: 600; }
.due.today { color: var(--primary-h); font-weight: 600; }
.urg { display: inline-flex; align-items: center; gap: 5px; }
.urg i { width: 7px; height: 7px; border-radius: 50%; background: var(--slate); }
.u-maior .urg i { background: var(--red); }
.u-alta .urg i { background: var(--orange); }
.u-media .urg i { background: var(--yellow); }
.created { color: #63738b; }

.card-actions { display: flex; gap: 2px; flex: none; opacity: 0; transition: opacity .15s; margin: -4px -2px -4px 0; }
.card:hover .card-actions, .card:focus-within .card-actions { opacity: 1; }
.icon-btn { width: 34px; height: 34px; display: grid; place-items: center; border: 0; background: transparent; color: var(--muted); border-radius: 9px; }
.icon-btn:hover { background: rgba(148,163,184,.12); color: var(--text); }
.icon-btn.del:hover { color: var(--red); }
.icon-btn svg { width: 17px; height: 17px; }

/* ---------- Lista completa ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; margin-bottom: 14px; }
.search { flex: 1 1 220px; display: flex; align-items: center; gap: 8px; background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; padding: 0 11px; height: 40px; }
.search svg { color: var(--muted); width: 16px; height: 16px; }
.search input { flex: 1; background: transparent; border: 0; outline: 0; color: var(--text); font-size: 15px; min-width: 0; }
select, input[type=text], input[type=date], input[type=password], textarea {
  background: var(--bg2); color: var(--text); border: 1px solid var(--border); border-radius: 10px;
  font: inherit; font-size: 15px; padding: 10px 11px; outline: none; width: 100%;
}
.filters select { width: auto; height: 40px; padding: 0 10px; font-size: 14px; }
select:focus, input:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(14,165,233,.18); }
input[type=date] { min-height: 42px; -webkit-appearance: none; appearance: none; }
input[type=date]::-webkit-calendar-picker-indicator { filter: invert(.8); }
.list-info { font-size: 12px; color: var(--muted); margin: -4px 0 10px 2px; }

/* ---------- Vazio ---------- */
.empty { text-align: center; padding: 36px 22px; background: var(--panel); border: 1px solid var(--border); border-radius: 18px; max-width: 440px; margin: 26px auto; }
.empty svg { width: 40px; height: 40px; color: var(--primary); }
.empty h3 { margin: 12px 0 6px; font-size: 18px; }
.empty p { color: var(--muted); margin: 0 0 16px; font-size: 14px; line-height: 1.45; }
.empty a { color: var(--primary); }
.pair-form { display: flex; gap: 8px; margin-top: 4px; }
.pair-form input { flex: 1; min-width: 0; font-size: 16px; }

/* ---------- Botão flutuante (celular) ---------- */
.fab { display: none; position: fixed; right: 18px; bottom: calc(20px + var(--safe-b)); width: 58px; height: 58px; border-radius: 18px; border: 0; background: var(--primary); color: #03121c; box-shadow: 0 12px 28px rgba(14,165,233,.35), 0 2px 6px rgba(0,0,0,.4); z-index: 30; place-items: center; }
.fab:active { transform: scale(.96); }
.fab svg { width: 26px; height: 26px; }

/* ---------- Janelas ---------- */
.dialog { border: 1px solid var(--border); border-radius: 18px; background: var(--panel); color: var(--text); padding: 20px; width: min(480px, calc(100vw - 24px)); max-height: calc(100vh - 32px); }
.dialog::backdrop { background: rgba(2, 6, 15, .72); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.dialog-head h2 { margin: 0; font-size: 18px; }
.dialog label { display: block; font-size: 13px; font-weight: 600; color: #c3cfdf; margin: 12px 0 0; }
.dialog label > input, .dialog label > textarea, .dialog label > select { margin-top: 6px; font-weight: 400; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quick-dates { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.quick-dates button { border: 1px solid var(--border); background: var(--bg2); color: var(--muted); border-radius: 999px; padding: 6px 12px; font-size: 12px; font-weight: 600; }
.quick-dates button:hover { color: var(--text); border-color: var(--primary); }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.dialog-foot.wrap { flex-wrap: wrap; }
.voice-box { text-align: center; padding: 12px 0 4px; }
.voice-pulse { width: 76px; height: 76px; margin: 6px auto 12px; border-radius: 50%; display: grid; place-items: center; background: rgba(240,82,82,.15); color: var(--red); }
.voice-pulse svg { width: 32px; height: 32px; }
.voice-pulse.live { animation: pulse 1.3s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(240,82,82,.45); } 70% { box-shadow: 0 0 0 18px rgba(240,82,82,0); } 100% { box-shadow: 0 0 0 0 rgba(240,82,82,0); } }
.voice-text { min-height: 44px; font-size: 16px; margin: 8px 0 0; }

/* ---------- Avisos ---------- */
.toasts { position: fixed; left: 50%; bottom: calc(20px + var(--safe-b)); transform: translateX(-50%); display: grid; gap: 8px; z-index: 50; width: min(420px, calc(100vw - 24px)); }
.toast { background: #1c2940; border: 1px solid #31456a; color: var(--text); padding: 12px 14px; border-radius: 12px; font-size: 14px; box-shadow: 0 12px 30px rgba(0,0,0,.4); display: flex; align-items: center; gap: 10px; animation: fadein .2s ease; }
.toast button { margin-left: auto; border: 0; background: transparent; color: var(--primary-h); font-weight: 700; }
.toast.err { border-color: rgba(240,82,82,.5); }

/* ---------- Celular ---------- */
@media (hover: none) {
  .card-actions { display: none; }
}
@media (max-width: 760px) {
  .container { padding: 0 16px; }
  .topbar-inner { padding-top: 12px; padding-bottom: 12px; }
  .brand-icon { width: 38px; height: 38px; border-radius: 11px; }
  .brand-icon svg { width: 20px; height: 20px; }
  .brand h1 { font-size: 22px; letter-spacing: -.02em; }
  .hide-sm { display: none; }
  .hide-xs { display: none; }
  .btn-outline { width: 40px; padding: 0; border-radius: 12px; }
  .sync-badge { width: 40px; height: 40px; padding: 0; justify-content: center; border-radius: 12px; }
  .sync-badge .sync-text { display: none; }

  .stats { grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 16px 0 14px; }
  .stat { flex-direction: column; align-items: flex-start; gap: 0; padding: 11px 10px 10px; border-radius: 13px; }
  .stat-icon { display: none; }
  .stat strong { font-size: 22px; }
  .stat small { font-size: 11px; margin-top: 2px; white-space: nowrap; }
  .stat[data-jump="atraso"] { border-color: rgba(240,82,82,.3); background: rgba(240,82,82,.07); }
  .stat[data-jump="hoje"] strong { color: var(--primary-h); }
  .stat[data-jump="concluidas"] strong { color: #6ee7a0; }

  .tabs { display: flex; margin-bottom: 18px; }
  .tab { flex: 1; padding: 9px 10px; }

  .card { padding: 13px 12px; gap: 12px; }
  .card-title { font-size: 16px; }
  .created { display: none; }
  .fab { display: grid; }
  main.container { padding-bottom: calc(100px + var(--safe-b)); }
  .filters select { flex: 1 1 45%; }
  .toasts { bottom: calc(92px + var(--safe-b)); }
  .dialog { padding: 18px; }
}
/* Instalado no iPhone/Android: espaço extra abaixo da barra de status */
@media (display-mode: standalone) and (max-width: 760px) {
  .topbar-inner { padding-top: 10px; }
  .topbar { padding-top: calc(var(--safe-t) + 6px); }
}

.voice-input { width: 100%; margin-top: 12px; height: 46px; border-radius: 12px; border: 1px solid var(--line, #2a3245); background: rgba(255,255,255,.04); color: inherit; padding: 0 14px; font-size: 16px; }
