/* Plano do dia — preto no branco, mobile-first, sem dependências */
:root {
  --paper: #ffffff;
  --ink: #000000;
  --graphite: #5e5e5e;
  --rule: #e4e4e4;
  --wash: #f4f4f4;
  --alert: #c8102e;
  --radius: 6px;
  --tap: 44px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 16px/1.45 var(--font); font-variant-numeric: tabular-nums;
}
a { color: inherit; }
h1, h2 { margin: 0; line-height: 1.15; }
h1 { font-size: 1.5rem; font-weight: 750; letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; font-weight: 700; }
p { margin: 0; }
.muted { color: var(--graphite); }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }

/* ---------- barra superior e navegação */
.topbar {
  position: sticky; top: 0; z-index: 10; background: var(--paper);
  display: flex; align-items: center; gap: 1rem;
  padding: .6rem 1rem; padding-top: max(.6rem, env(safe-area-inset-top));
  border-bottom: 1px solid var(--ink);
}
.brand { font-weight: 800; text-decoration: none; letter-spacing: -0.01em; }
.topbar-tools { margin-left: auto; display: flex; gap: .75rem; }
.topbar-tools form { margin: 0; }
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--paper); border-top: 1px solid var(--ink);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav a {
  min-height: 56px; display: flex; align-items: center; justify-content: center;
  text-decoration: none; font-size: .85rem; color: var(--graphite);
}
.nav a[aria-current="page"] { color: var(--ink); font-weight: 750; box-shadow: inset 0 3px 0 var(--ink); }
.main { max-width: 760px; margin: 0 auto; padding: 1rem 1rem calc(88px + env(safe-area-inset-bottom)); }
.is-bare .main { padding-bottom: 2rem; }

@media (min-width: 800px) {
  .nav { position: static; display: flex; gap: .25rem; border: 0; padding: 0; }
  .nav a { min-height: 40px; padding: 0 .8rem; font-size: .95rem; }
  .nav a[aria-current="page"] { box-shadow: inset 0 -3px 0 var(--ink); }
  .main { padding-bottom: 3rem; }
}

/* ---------- botões e campos */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: var(--tap); padding: 0 1rem; border: 1.5px solid var(--ink); border-radius: var(--radius);
  background: var(--paper); color: var(--ink); font: inherit; font-weight: 600;
  text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--wash); }
.btn:disabled { opacity: .3; cursor: default; }
.btn-primary { background: var(--ink); color: var(--paper); }
.btn-primary:hover { background: #262626; }
.btn-icon { width: var(--tap); padding: 0; font-size: 1.3rem; }
.btn-danger { border-color: var(--alert); color: var(--alert); }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; min-height: 32px; }
.topbar-tools .link { font-size: .85rem; color: var(--graphite); }

input[type=text], input[type=password], input[type=date], input[type=time], input[type=file], select, textarea {
  width: 100%; min-height: var(--tap); padding: .55rem .7rem; font: inherit; font-weight: 400; color: var(--ink);
  background: var(--paper); border: 1.5px solid #bdbdbd; border-radius: var(--radius);
}
input:focus, select:focus, textarea:focus { border-color: var(--ink); outline: none; box-shadow: 0 0 0 2px var(--ink); }
label { display: block; font-weight: 600; font-size: .92rem; }
label > input, label > select, label > textarea { margin-top: .3rem; font-weight: 400; }
.check-row { display: flex; align-items: center; gap: .5rem; font-weight: 400; min-height: 36px; }
.check-row input[type=checkbox], .check-row input[type=radio] { width: 20px; height: 20px; accent-color: var(--ink); margin: 0; }
.check-row input[type=date] { width: auto; margin: 0 0 0 .25rem; }
fieldset { border: 1px solid var(--rule); border-radius: var(--radius); padding: .75rem 1rem 1rem; margin: 0; }
legend { font-weight: 700; padding: 0 .3rem; }
.stack { display: grid; gap: 1rem; }
.row2 { display: grid; gap: 1rem; }
@media (min-width: 560px) { .row2 { grid-template-columns: 1fr 1fr; } }
.actions { display: flex; flex-wrap: wrap; gap: .6rem; }

/* ---------- mensagens */
.flash { padding: .65rem .8rem; border-radius: var(--radius); margin-bottom: .75rem; border-left: 4px solid var(--ink); background: var(--wash); }
.flash-error { border-left-color: var(--alert); color: #7a0a1c; background: #fdf1f3; }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 20;
  background: var(--ink); color: var(--paper); padding: .55rem 1rem; border-radius: 999px; font-size: .9rem;
}
@media (min-width: 800px) { .toast { bottom: 1.5rem; } }

/* ---------- cabeçalho do dia: a folha de calendário */
.dayhead {
  display: grid; grid-template-columns: auto 1fr; align-items: end; column-gap: .9rem; row-gap: .9rem;
  padding: .5rem 0 1rem; border-bottom: 1px solid var(--ink);
}
.daynum {
  font-size: clamp(4.5rem, 22vw, 7.5rem); font-weight: 850; line-height: .8; letter-spacing: -0.06em;
  margin-left: -0.05em;
}
.daytext h1 { font-size: clamp(1.25rem, 4.5vw, 1.8rem); white-space: nowrap; }
.daytext p { color: var(--graphite); text-transform: lowercase; }
.daynav { grid-column: 1 / -1; display: flex; gap: .5rem; align-items: center; }
.daynav .btn-icon { flex: none; }
.datepick { flex: 1 1 auto; min-width: 0; margin: 0; }
.datepick input { min-width: 0; }
@media (min-width: 640px) {
  .dayhead { grid-template-columns: auto 1fr auto; }
  .daynav { grid-column: auto; }
  .datepick { flex: 0 1 170px; }
}

/* ---------- progresso */
.progress { padding: 1rem 0 .5rem; }
.progress-text { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: .4rem; }
.progress-text strong { font-size: 1.35rem; font-weight: 800; }
.bar { height: 10px; background: var(--wash); border: 1px solid var(--ink); border-radius: 2px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--ink); transition: width .25s ease; }
.all-done { margin-top: .5rem; font-weight: 700; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin: .5rem 0 1rem; font-size: .9rem; }
.chip {
  border: 1px solid #bdbdbd; border-radius: 999px; padding: .3rem .8rem; background: var(--paper);
  text-decoration: none; font: inherit; cursor: pointer; min-height: 34px;
}
.chip[aria-current="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* ---------- lista de tarefas */
.group { margin-bottom: 1.25rem; }
.group-title { display: flex; align-items: baseline; gap: .5rem; padding: .25rem 0; }
.group-title .count { font-weight: 500; color: var(--graphite); font-size: .9rem; }
.tasklist, .manage { list-style: none; margin: 0; padding: 0; }
.task {
  display: grid; grid-template-columns: var(--tap) 1fr auto; gap: .75rem; align-items: start;
  padding: .7rem 0 .7rem .75rem; border-bottom: 1px solid var(--rule);
  border-left: 2px solid var(--ink);
}
/* a espessura da régua esquerda codifica a prioridade */
.prio-1 { border-left: 5px solid var(--ink); }
.prio-2 { border-left: 2px solid var(--ink); }
.prio-3 { border-left: 1px dashed #9a9a9a; }
.toggle, .task form { margin: 0; }
.check {
  width: var(--tap); height: var(--tap); display: grid; place-items: center; padding: 0;
  border: 2px solid var(--ink); border-radius: var(--radius); background: var(--paper); cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.check svg { width: 26px; height: 26px; fill: none; stroke: var(--paper); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.check:hover { background: var(--wash); }
.check[aria-pressed="true"] { background: var(--ink); }
.check.just-done svg { animation: tick .18s ease-out; }
@keyframes tick { from { transform: scale(.6); opacity: 0; } }
.check-sm { width: 36px; height: 36px; }
.check-sm svg { width: 20px; height: 20px; }
.task-body { min-width: 0; padding-top: .1rem; }
.task-title { display: block; font-weight: 600; overflow-wrap: anywhere; text-decoration: none; }
.task.is-done .task-title { text-decoration: line-through; text-decoration-thickness: 1.5px; color: var(--graphite); }
.task-meta { display: flex; flex-wrap: wrap; gap: .35rem .7rem; font-size: .83rem; color: var(--graphite); margin-top: .15rem; }
.task-meta .time { color: var(--ink); font-weight: 650; }
.tag { border: 1px solid var(--rule); border-radius: 4px; padding: 0 .35rem; }
.tag-muted { background: var(--wash); }
.done-at:empty { display: none; }
.task-notes { font-size: .88rem; color: var(--graphite); margin-top: .3rem; cursor: pointer;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.task-notes.is-open { display: block; }
.task-edit { font-size: .83rem; color: var(--graphite); padding: .6rem 0 .6rem .4rem; }

.empty { border: 1.5px dashed #bdbdbd; border-radius: var(--radius); padding: 1.25rem; margin: 1rem 0; display: grid; gap: .6rem; justify-items: start; }

.quickadd { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--ink); display: grid; gap: .5rem; }
.quickadd-row { display: flex; gap: .5rem; }
.quickadd-opts { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.quickadd-opts select, .quickadd-opts input[type=text] { width: auto; flex: 1 1 130px; }

/* ---------- gerenciar tarefas */
.pagehead { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; padding: .5rem 0 1rem; }
.pagehead .daynav { grid-column: auto; }
.manage { margin-top: .75rem; }
.manage-item {
  display: grid; grid-template-columns: 36px 1fr auto; gap: .5rem; align-items: center;
  padding: .55rem .25rem .55rem .5rem; border-bottom: 1px solid var(--rule); background: var(--paper);
}
.manage-item.is-paused .task-title { color: var(--graphite); }
.manage-item.dragging { box-shadow: 0 6px 18px rgba(0,0,0,.18); position: relative; z-index: 2; }
.handle { width: 36px; height: var(--tap); display: grid; place-items: center; cursor: grab; touch-action: none; }
.handle svg { width: 22px; height: 22px; stroke: var(--ink); stroke-width: 3.2; stroke-linecap: round; }
.manage-actions { display: flex; gap: .3rem; }
.manage-actions form { margin: 0; }
.manage-actions .btn-icon { width: 38px; min-height: 38px; font-size: 1rem; }

.daypicker { display: flex; flex-wrap: wrap; gap: .35rem; margin: .4rem 0 .75rem 1.8rem; align-items: center; }
.daybox { position: relative; font-weight: 600; }
.daybox input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.daybox span {
  display: grid; place-items: center; min-width: 46px; height: 40px; padding: 0 .4rem;
  border: 1.5px solid var(--ink); border-radius: var(--radius); cursor: pointer; font-size: .9rem;
}
.daybox input:checked + span { background: var(--ink); color: var(--paper); }
.daybox input:focus-visible + span { outline: 3px solid var(--ink); outline-offset: 2px; }
.daypicker-quick { display: flex; gap: .8rem; margin-left: .3rem; font-size: .88rem; }
.range { margin: 0 0 .9rem 1.8rem; }
.range label { font-weight: 400; }
.danger-zone { margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--rule); }

/* ---------- semana */
.week-total { font-weight: 650; margin-bottom: .75rem; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--ink); border-radius: var(--radius); }
table.week { border-collapse: collapse; width: 100%; min-width: 620px; font-size: .9rem; }
.week th, .week td { border-bottom: 1px solid var(--rule); padding: .35rem; text-align: center; }
.week thead th { background: var(--paper); border-bottom: 1px solid var(--ink); font-weight: 700; }
.week thead a { text-decoration: none; }
.week thead small { font-weight: 400; color: var(--graphite); }
.week .col-task {
  text-align: left; position: sticky; left: 0; background: var(--paper); z-index: 1;
  min-width: 170px; max-width: 240px; font-weight: 600; border-right: 1px solid var(--rule);
}
.week tbody .col-task small { display: block; font-weight: 400; }
.week tr.prio-1, .week tr.prio-2, .week tr.prio-3 { border-left: 0; }
.week tr.prio-1 .col-task { box-shadow: inset 5px 0 0 var(--ink); padding-left: .7rem; }
.week tr.prio-2 .col-task { box-shadow: inset 2px 0 0 var(--ink); padding-left: .7rem; }
.week td.na { background: repeating-linear-gradient(135deg, transparent 0 6px, var(--wash) 6px 8px); }
.week .is-today { background: var(--wash); }
.week td form { margin: 0; display: grid; place-items: center; }
.week tfoot td, .week tfoot th { font-weight: 750; border-top: 1px solid var(--ink); border-bottom: 0; }

/* ---------- painéis e login */
.panel { border: 1px solid var(--rule); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; display: grid; gap: .75rem; justify-items: start; }
.panel > form, .panel .stack { width: 100%; }
.auth { max-width: 380px; margin: 12vh auto 0; display: grid; gap: 1rem; }
.auth h1 { font-size: 2rem; font-weight: 850; letter-spacing: -0.03em; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- impressão */
@media print {
  .topbar, .nav, .no-print, .quickadd, .daynav, .toast, .flash, .task-edit { display: none !important; }
  .main { max-width: none; padding: 0; }
  body { font-size: 11pt; }
  .daynum { font-size: 48pt; }
  .task-notes { display: block; }
  .task { break-inside: avoid; padding-top: .35rem; padding-bottom: .35rem; }
  .check { width: 18px; height: 18px; border-width: 1.5px; }
  .check svg { width: 14px; height: 14px; }
  .check[aria-pressed="true"] { background: #000 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .table-wrap { overflow: visible; border: 0; }
  table.week { min-width: 0; font-size: 9pt; }
  .week .col-task { position: static; }
  .check-sm { width: 16px; height: 16px; }
}
