:root {
  --bg-1: #eff5ec; --bg-2: #e2ede0;
  --card: #ffffff;
  --surface: #f3f8f1;
  --surface-2: #e9f2e6;
  --line: #d8e3d4;
  --line-strong: #c7d6c2;
  --txt: #1b2420;
  --muted: #6f8076;
  --accent: #df8129;
  --accent-d: #c46c1a;
  --ok: #3f9d5f;
  --ok-bg: #d8ebd9;
  --ok-txt: #2f7d49;
  --err: #cf5640;
  --err-bg: #f7e1dc;
  --shadow-sm: 0 1px 2px rgba(30,55,32,.05), 0 4px 12px rgba(40,75,45,.05);
  --shadow: 0 2px 6px rgba(30,55,32,.05), 0 14px 34px rgba(40,75,45,.08);
  --maxw: 1160px;        /* largura máxima do conteúdo */
  --maxw-narrow: 720px;  /* p/ blocos que ficam melhores estreitos (histórico) */
}
* { box-sizing: border-box; }
/* O atributo `hidden` deve sempre vencer classes que definem display (.modal, .login-screen, etc.) */
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(180deg, var(--bg-1) 0%, var(--bg-2) 100%);
  background-attachment: fixed;
  color: var(--txt); line-height: 1.5;
}

/* ---------- inputs / botões ---------- */
input[type="text"], input[type="password"], input[type="date"], input[type="time"], textarea {
  width: 100%; font-family: inherit; font-size: 15px; color: var(--txt);
  background: var(--surface); border: 1px solid var(--line); border-radius: 11px;
  padding: 12px 14px; transition: .15s; resize: vertical;
}
input:focus, textarea:focus { outline: none; border-color: var(--accent); background: #fffdfb; }
button {
  font-family: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  border-radius: 11px; border: 1px solid var(--line); background: var(--surface);
  color: var(--txt); padding: 11px 16px; transition: .15s; white-space: nowrap;
}
button:hover { background: var(--surface-2); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: var(--accent-d); border-color: var(--accent-d); }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); padding: 6px 8px; }
button.ghost:hover { background: var(--surface-2); color: var(--txt); }

/* ---------- login ---------- */
.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 20px;
  box-shadow: var(--shadow); padding: 34px 30px; width: 100%; max-width: 360px; text-align: center;
}
.login-logo { font-size: 44px; }
.login-card h2 { margin: 8px 0 2px; font-size: 24px; font-weight: 800; }
.login-card p { margin: 0 0 20px; color: var(--muted); font-size: 14px; }
.login-card input { margin-bottom: 12px; text-align: center; }
.login-card button { width: 100%; padding: 13px; font-size: 15px; }
.login-err { color: var(--err); font-size: 13px; font-weight: 600; margin-top: 10px; min-height: 18px; }

/* ---------- header / abas ---------- */
header.top { position: sticky; top: 0; z-index: 20; background: rgba(239,245,236,.92);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.top-inner { max-width: var(--maxw); margin: 0 auto; padding: 12px 20px 0; }
.brandline { display: flex; align-items: center; justify-content: space-between; }
.badge {
  display: inline-flex; align-items: center; gap: 8px; font-size: 11px; font-weight: 700;
  letter-spacing: 1.4px; text-transform: uppercase; color: var(--ok-txt);
  background: var(--ok-bg); border: 1px solid #bfe0c2; padding: 6px 14px; border-radius: 99px;
}
.conn { font-size: 12px; font-weight: 600; color: var(--muted); }
.conn.on { color: var(--ok-txt); }
.conn.off { color: var(--err); }
.conn-dot { display: inline-block; }
/* bolinha "ao vivo" pulsando como uma live */
.conn.on .conn-dot { animation: livePulse 1.2s ease-in-out infinite; }
@keyframes livePulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .25; transform: scale(.8); } }
.tabs { display: flex; gap: 6px; margin-top: 12px; }
.tab {
  flex: 1; border: none; background: transparent; border-radius: 0; padding: 12px 8px;
  font-size: 15px; font-weight: 700; color: var(--muted); border-bottom: 3px solid transparent;
}
.tab:hover { background: transparent; color: var(--txt); }
.tab.active { color: var(--accent-d); border-bottom-color: var(--accent); }

main { max-width: var(--maxw); margin: 0 auto; padding: 20px 20px 80px; }
.tabpane { animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: var(--shadow); padding: 20px; margin-bottom: 18px;
}
.today-line { color: var(--muted); font-size: 15px; margin: 4px 2px 16px; font-weight: 600; }
.section-title { font-size: 13px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; color: var(--muted); margin: 0 0 12px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.hint { font-size: 12.5px; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 26px 10px; font-size: 15px; }
footer { text-align: center; color: var(--muted); font-size: 12px; padding: 0 20px 30px; max-width: var(--maxw); margin: 0 auto; }

/* ---------- navegação por dia (aba Tarefas) ---------- */
.day-nav { display: flex; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: var(--shadow-sm); padding: 8px 12px; margin-bottom: 18px; }
.day-nav-label { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: center; gap: 10px; font-weight: 700; }
.day-nav-label #todayLine { font-size: 16px; color: var(--txt); }
.view-today-pill { flex: none; font-size: 11px; font-weight: 700; color: var(--accent-d); background: #fbe9d6; border-radius: 99px; padding: 2px 9px; }
.cal { position: relative; display: inline-flex; flex: none; }
.calendar-btn { font-size: 15px; padding: 4px 6px; }
#datePick { position: absolute; left: 0; top: 100%; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
@media (max-width: 560px) { .day-nav-label #todayLine { font-size: 13px; } .nav-btn { padding: 4px 8px; } }

/* ---------- colunas (tarefas fixas | tarefas do dia) ---------- */
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; margin-bottom: 18px; }
.cols .card { margin-bottom: 0; }
.col-hint { font-weight: 600; color: var(--line-strong); text-transform: none; letter-spacing: 0; }
.col .progress-wrap { margin: 0 0 14px; }
hr.soft { border: none; border-top: 1px solid var(--line); margin: 18px 0 14px; }
@media (max-width: 680px) { .cols { grid-template-columns: 1fr; } }

/* ---------- progresso ---------- */
.progress-wrap { display: flex; align-items: center; gap: 14px; }
.progress-bar { flex: 1; height: 14px; background: var(--surface-2); border-radius: 99px; overflow: hidden; border: 1px solid var(--line); }
.progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--ok), #58b97a); transition: width .35s ease; }
.progress-txt { font-weight: 700; font-size: 15px; white-space: nowrap; }
.progress-txt small { color: var(--muted); font-weight: 500; }

/* ---------- tarefas ---------- */
.add-row { display: flex; gap: 10px; }
.tasks { list-style: none; margin: 0; padding: 0; }
.task { display: flex; align-items: flex-start; gap: 12px; padding: 13px 6px; border-bottom: 1px solid var(--line); }
.task:last-child { border-bottom: none; }
.check { flex: none; width: 26px; height: 26px; margin-top: 1px; border-radius: 8px;
  border: 2px solid var(--line-strong); background: #fff; cursor: pointer; display: grid; place-items: center; transition: .15s; padding: 0; }
.check:hover { border-color: var(--ok); }
.check svg { width: 16px; height: 16px; stroke: #fff; stroke-width: 3.5; fill: none; stroke-linecap: round; stroke-linejoin: round; opacity: 0; transition: .15s; }
.task.done .check { background: var(--ok); border-color: var(--ok); }
.task.done .check svg { opacity: 1; }
.task-body { flex: 1; min-width: 0; }
.task-text { font-size: 16px; font-weight: 600; word-break: break-word; }
.task.done .task-text { text-decoration: line-through; color: var(--muted); }
.task-meta { font-size: 12.5px; color: var(--ok-txt); font-weight: 600; margin-top: 1px; }
.pending-since { font-size: 12px; color: var(--accent-d); font-weight: 600; margin-top: 1px; }
.task-note { width: 100%; margin-top: 7px; font-size: 13.5px; color: var(--txt); background: var(--surface);
  border: 1px dashed var(--line-strong); border-radius: 9px; padding: 7px 10px; min-height: 36px; display: none; }
.task-note.show { display: block; }
.task-actions { flex: none; display: flex; gap: 2px; align-items: center; }
.task-actions .ico { font-size: 16px; line-height: 1; }

/* ---------- histórico ---------- */
.hist-day { border: 1px solid var(--line); border-radius: 13px; margin-bottom: 12px; overflow: hidden; }
.hist-head { display: flex; align-items: center; gap: 12px; padding: 13px 15px; cursor: pointer; background: var(--surface); }
.hist-head:hover { background: var(--surface-2); }
.hist-date { font-weight: 700; font-size: 15px; }
.hist-count { margin-left: auto; font-size: 13px; font-weight: 700; padding: 3px 11px; border-radius: 99px; }
.hist-count.full { background: var(--ok-bg); color: var(--ok-txt); }
.hist-count.partial { background: #fbe9d6; color: var(--accent-d); }
.hist-count.none { background: var(--err-bg); color: var(--err); }
.hist-arrow { color: var(--muted); transition: transform .2s; }
.hist-day.open .hist-arrow { transform: rotate(90deg); }
.hist-body { display: none; padding: 6px 16px 14px; }
.hist-day.open .hist-body { display: block; }
.hist-task { display: flex; gap: 9px; padding: 6px 0; font-size: 14.5px; align-items: baseline; border-bottom: 1px dashed var(--line); }
.hist-task:last-child { border-bottom: none; }
.hist-task .mk { flex: none; font-weight: 700; }
.hist-task .mk.y { color: var(--ok-txt); }
.hist-task .mk.n { color: var(--err); }
.hist-task .tt.no { text-decoration: line-through; color: var(--muted); }
.hist-task .when { color: var(--ok-txt); font-size: 12px; margin-left: 4px; }
.hist-task .daytag { font-size: 10.5px; font-weight: 700; color: var(--accent-d); background: #fbe9d6; border-radius: 6px; padding: 1px 6px; margin-left: 6px; text-transform: uppercase; letter-spacing: .3px; }
.hist-task .tnote { display: block; color: var(--muted); font-size: 12.5px; font-style: italic; }
.hist-note { margin-top: 10px; font-size: 13.5px; background: var(--surface); border-radius: 9px; padding: 9px 12px; white-space: pre-wrap; }
.hist-note b { color: var(--muted); }
.load-more { display: block; margin: 6px auto 0; }

/* ---------- agenda ---------- */
.month-nav { display: flex; align-items: center; gap: 10px; padding: 12px 16px; }
.nav-btn { font-size: 22px; line-height: 1; padding: 4px 12px; border-radius: 10px; }
.month-label { flex: 1; text-align: center; font-size: 18px; font-weight: 800; }
.today-jump { font-size: 13px; padding: 7px 12px; }

.day-row { background: var(--card); border: 1px solid var(--line); border-radius: 15px; margin-bottom: 12px; box-shadow: var(--shadow-sm); overflow: hidden; }
.day-row.today { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(223,129,41,.18), var(--shadow-sm); }
.day-row.past { opacity: .82; }
.day-head { display: flex; align-items: center; gap: 14px; padding: 12px 16px; }
.day-num { flex: none; width: 46px; height: 46px; border-radius: 12px; background: var(--surface-2); display: grid; place-items: center; line-height: 1; }
.day-row.today .day-num { background: var(--accent); color: #fff; }
.day-num b { font-size: 20px; font-weight: 800; }
.day-num span { font-size: 10px; text-transform: uppercase; letter-spacing: .5px; font-weight: 700; }
.day-info { flex: 1; min-width: 0; }
.day-weekday { font-size: 15px; font-weight: 700; }
.day-sub { font-size: 12.5px; color: var(--muted); }
.day-sub .today-pill { color: var(--accent-d); font-weight: 700; }
.day-add { flex: none; font-size: 13px; padding: 8px 12px; }

.appts { list-style: none; margin: 0; padding: 0 16px 6px; }
.appt { display: flex; gap: 11px; align-items: flex-start; padding: 9px 0; border-top: 1px dashed var(--line); }
.appt-time { flex: none; font-weight: 800; font-size: 13px; color: var(--accent-d); background: #fbe9d6; border-radius: 7px; padding: 3px 8px; min-width: 52px; text-align: center; }
.appt-time.allday { background: var(--surface-2); color: var(--muted); }
.appt-body { flex: 1; min-width: 0; }
.appt-title { font-weight: 600; font-size: 15px; word-break: break-word; }
.appt-note { font-size: 13px; color: var(--muted); white-space: pre-wrap; margin-top: 1px; }
.appt-actions { flex: none; display: flex; gap: 2px; }
.appt-actions .ico { font-size: 15px; }

.day-tasks { padding: 4px 16px 14px; }
.day-tasks-toggle { font-size: 12.5px; color: var(--muted); cursor: pointer; user-select: none; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.day-tasks-toggle:hover { color: var(--txt); }
.day-tasks-list { margin-top: 8px; display: none; }
.day-tasks-list.show { display: block; }
.dt { display: flex; gap: 8px; font-size: 13.5px; padding: 4px 0; align-items: baseline; }
.dt .mk { flex: none; font-weight: 700; }
.dt .mk.y { color: var(--ok-txt); } .dt .mk.n { color: var(--line-strong); }
.dt .tt.no { color: var(--muted); }
.dt .when { color: var(--ok-txt); font-size: 11.5px; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(20,35,25,.45); display: grid; place-items: center; z-index: 50; padding: 18px; }
.modal-card { background: var(--card); border-radius: 18px; box-shadow: var(--shadow); padding: 22px; width: 100%; max-width: 420px; }
.modal-card h3 { margin: 0 0 16px; font-size: 19px; font-weight: 800; }
.modal-card label { display: block; font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: 12px; }
.modal-card label input, .modal-card label textarea { margin-top: 5px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

/* ---------- toast ---------- */
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--txt); color: #fff;
  padding: 11px 18px; border-radius: 11px; font-size: 14px; font-weight: 600; box-shadow: var(--shadow); z-index: 60; }

@media (max-width: 560px) {
  .add-row { flex-direction: column; }
  .day-add span.lbl { display: none; }
}
