:root {
  --indigo: #4F46E5;
  --violet: #9333EA;
  --bg: #0B1020;
  --panel: #151B34;
  --panel2: #1C2342;
  --text: #E7E9F5;
  --muted: #9AA0C3;
  --line: #2A3160;
  --alta: #EF4444;
  --media: #F59E0B;
  --baixa: #22C55E;
  --ok: #22C55E;
  --radius: 14px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
}
#app { display: flex; flex-direction: column; height: 100dvh; max-width: 760px; margin: 0 auto; }
#topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  background: linear-gradient(135deg, var(--indigo), var(--violet));
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.logo {
  background: rgba(255,255,255,.18); border-radius: 9px; padding: 3px 7px;
  font-size: 13px; letter-spacing: .5px;
}
.greeting { font-size: 13px; opacity: .92; }
#view { flex: 1; overflow-y: auto; padding: 14px; }
#tabbar {
  display: flex; border-top: 1px solid var(--line); background: var(--panel);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; background: none; border: 0; color: var(--muted); padding: 8px 2px 7px;
  font-size: 11px; display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.tab .ic { font-size: 19px; }
.tab.active { color: #fff; }
.tab.active .ic { filter: drop-shadow(0 0 6px rgba(147,51,234,.9)); }
h2 { margin: 4px 0 10px; font-size: 19px; }
h3 { margin: 14px 0 8px; font-size: 15px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin-bottom: 12px;
}
.panel.gradient { background: linear-gradient(135deg, var(--indigo), var(--violet)); border: 0; }
.pending-title { font-weight: 700; font-size: 16px; margin-bottom: 8px; }
.task-row {
  display: flex; align-items: center; gap: 8px; background: rgba(255,255,255,.08);
  border-radius: 10px; padding: 9px 10px; margin-bottom: 7px;
}
.task-row .t { flex: 1; }
.task-row .d { font-size: 12px; opacity: .85; }
.badge { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; color: #fff; white-space: nowrap; }
.badge.alta { background: var(--alta); } .badge.media { background: var(--media); } .badge.baixa { background: var(--baixa); }
.empty { color: var(--muted); font-size: 14px; padding: 8px 2px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 10px; text-align: center; }
.stat .v { font-size: 20px; font-weight: 800; }
.stat .l { font-size: 11px; color: var(--muted); margin-top: 2px; }
.quick { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.btn {
  background: var(--panel2); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; font-size: 14px; font-weight: 600; width: 100%;
}
.btn.primary { background: linear-gradient(135deg, var(--indigo), var(--violet)); border: 0; color: #fff; }
.btn.small { width: auto; padding: 6px 10px; font-size: 12px; }
.btn.danger { border-color: #7F1D1D; color: #FCA5A5; }
.btn:active { transform: scale(.97); }
.cols { display: flex; flex-direction: column; gap: 10px; }
.col { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; }
.col h3 { margin: 0 0 8px; display: flex; justify-content: space-between; align-items: center; }
.col h3 .n { background: var(--panel2); border-radius: 999px; padding: 1px 9px; font-size: 12px; }
.card {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 10px; margin-bottom: 8px;
}
.card .t { font-weight: 600; font-size: 14px; }
.card .d { font-size: 12px; color: var(--muted); margin: 3px 0; white-space: pre-wrap; }
.card .meta { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.card .meta .when { font-size: 11px; color: var(--muted); flex: 1; }
.card .meta button { background: none; border: 1px solid var(--line); color: var(--muted); border-radius: 7px; font-size: 12px; padding: 3px 7px; }
.room { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; }
.room .head { display: flex; justify-content: space-between; align-items: center; }
.room .name { font-weight: 700; }
.room .kind { font-size: 11px; color: var(--muted); }
.bar { height: 8px; background: var(--panel2); border-radius: 999px; margin: 8px 0; overflow: hidden; }
.bar > div { height: 100%; background: linear-gradient(90deg, var(--indigo), var(--violet)); }
.bar.full > div { background: var(--alta); }
.room .foot { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--muted); }
.mine { color: var(--ok); font-weight: 700; }
#calc-display {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; text-align: right; font-size: 30px; min-height: 58px; word-break: break-all;
}
#calc-display .prev { font-size: 13px; color: var(--muted); min-height: 16px; }
.pad { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 10px; }
.pad button {
  background: var(--panel); color: var(--text); border: 1px solid var(--line);
  border-radius: 12px; padding: 14px 0; font-size: 19px; font-weight: 600;
}
.pad button.op { color: #C4B5FD; }
.pad button.eq { background: linear-gradient(135deg, var(--indigo), var(--violet)); border: 0; color: #fff; }
.pad button:active { transform: scale(.95); }
.spoken { display: flex; gap: 8px; margin-top: 10px; }
.spoken input {
  flex: 1; background: var(--panel); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 10px; font-size: 14px;
}
.hist { margin-top: 12px; }
.hist .h { display: flex; justify-content: space-between; background: var(--panel2); border-radius: 9px; padding: 7px 10px; margin-bottom: 6px; font-size: 13px; }
.hist .h span:last-child { color: #C4B5FD; font-weight: 700; }
#chat { display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 82%; padding: 9px 12px; border-radius: 14px; font-size: 14px; white-space: pre-wrap; }
.msg.bot { background: var(--panel2); border: 1px solid var(--line); align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.user { background: linear-gradient(135deg, var(--indigo), var(--violet)); align-self: flex-end; border-bottom-right-radius: 4px; }
#chat-input { display: flex; gap: 8px; margin-top: 10px; position: sticky; bottom: 0; }
#chat-input input { flex: 1; background: var(--panel); border: 1px solid var(--line); color: var(--text); border-radius: 999px; padding: 11px 14px; font-size: 14px; }
#modal {
  position: fixed; inset: 0; background: rgba(4,6,16,.7); display: flex;
  align-items: flex-end; justify-content: center; z-index: 50;
}
#modal.hidden { display: none; }
#modal-card { background: var(--panel); border: 1px solid var(--line); border-radius: 18px 18px 0 0; padding: 16px; width: 100%; max-width: 760px; max-height: 80dvh; overflow-y: auto; }
.field { margin-bottom: 10px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.field input, .field textarea, .field select {
  width: 100%; background: var(--panel2); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 10px; font-size: 14px; font-family: inherit;
}
.row { display: flex; gap: 8px; }
.row .btn { margin-top: 4px; }
.note { font-size: 12px; color: var(--muted); margin-top: 10px; }
.kv { display: flex; gap: 8px; margin-bottom: 8px; }
.kv input { flex: 1; background: var(--panel2); border: 1px solid var(--line); color: var(--text); border-radius: 10px; padding: 9px 10px; font-size: 13px; }
a { color: #C4B5FD; }
