:root {
  --accent: #2f7d4f;
  --accent-soft: #e6f2ea;
  --bg: #f4f5f3;
  --panel: #ffffff;
  --side: #fafbf9;
  --line: #e3e6e1;
  --text: #1f2421;
  --muted: #69716b;
  --danger: #c62828;
  --warn: #b45309;
  --star: #c2185b;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 1px 1px rgba(0, 0, 0, .04);
  --radius: 8px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --accent: #5fbf86;
    --accent-soft: #1d3326;
    --bg: #161917;
    --panel: #212522;
    --side: #1b1e1c;
    --line: #313732;
    --text: #e8ebe8;
    --muted: #9aa39c;
    --danger: #ef6b6b;
    --warn: #f0a24a;
    --star: #f06292;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body, #app { height: 100%; margin: 0; }
body {
  font: 14px/1.4 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
input, select, textarea {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 9px;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
input:disabled, select:disabled, textarea:disabled { opacity: .7; cursor: not-allowed; }
.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.boot { display: grid; place-items: center; height: 100%; color: var(--muted); }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 6px;
  background: var(--accent); color: #fff; font-weight: 600;
}
.btn:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); font-weight: 500; }
.btn.ghost:hover { background: var(--bg); }
.btn.danger { background: var(--danger); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 6px; color: var(--muted); }
.icon-btn:hover { background: var(--bg); color: var(--text); }

/* ---------- Login / configuração ---------- */
.auth { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.auth-card {
  width: 100%; max-width: 380px; background: var(--panel);
  border-radius: 12px; padding: 28px; box-shadow: 0 10px 30px rgba(0, 0, 0, .08);
}
.auth-card h1 { display: flex; align-items: center; gap: 10px; font-size: 20px; margin: 0 0 6px; }
.auth-card h1 img { width: 32px; height: 32px; }
.auth-card p { color: var(--muted); margin: 0 0 18px; }
.form { display: grid; gap: 12px; }
.form label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.form label.check { display: flex; align-items: center; gap: 8px; color: var(--text); }
.form .btn { justify-content: center; margin-top: 4px; }
.form .error { color: var(--danger); font-size: 13px; min-height: 1em; }

/* ---------- Estrutura ---------- */
.shell { display: grid; grid-template-columns: 270px 1fr; height: 100%; }
.shell.has-detail { grid-template-columns: 270px 1fr 380px; }
.sidebar {
  background: var(--side); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0;
}
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.detail { display: none; background: var(--side); border-left: 1px solid var(--line); min-height: 0; flex-direction: column; }
.has-detail .detail { display: flex; }
.scrim { display: none; }

/* ---------- Barra lateral ---------- */
.me { display: flex; align-items: center; gap: 10px; padding: 14px 14px 10px; }
.me .who { min-width: 0; flex: 1; }
.me .who b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me .who small { color: var(--muted); }
.search { position: relative; margin: 0 12px 8px; }
.search .ic { position: absolute; left: 9px; top: 9px; width: 16px; height: 16px; color: var(--muted); }
.search input { width: 100%; padding-left: 32px; background: var(--panel); }
.nav { overflow-y: auto; flex: 1; padding: 4px 8px 12px; }
.nav h3 {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); margin: 16px 8px 4px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border-radius: 6px; text-align: left;
}
.nav-item:hover { background: var(--bg); }
.nav-item.active { background: var(--accent-soft); font-weight: 600; }
.nav-item .ic { color: var(--c, var(--accent)); }
.nav-item .label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-item .count { font-size: 12px; color: var(--muted); }
.nav-item .count.hot { background: var(--accent); color: #fff; border-radius: 10px; padding: 0 7px; font-weight: 600; }
.swatch { width: 10px; height: 10px; border-radius: 3px; background: var(--c); flex: none; margin: 0 4px; }
.side-foot { border-top: 1px solid var(--line); padding: 8px; display: flex; gap: 4px; flex-wrap: wrap; }
.side-foot button { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 6px; color: var(--muted); font-size: 13px; }
.side-foot button:hover { background: var(--bg); color: var(--text); }

/* ---------- Avatares ---------- */
.av {
  display: inline-grid; place-items: center; flex: none;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--c, #888); color: #fff; font-size: 11px; font-weight: 700; letter-spacing: .02em;
}
.av.lg { width: 36px; height: 36px; font-size: 13px; }
.av.sm { width: 22px; height: 22px; font-size: 9px; }
.av.none { background: transparent; border: 1.5px dashed var(--line); color: var(--muted); }
.av.none .ic { width: 14px; height: 14px; }

/* ---------- Área principal ---------- */
.main-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 20px 24px 10px;
}
.main-head .burger { display: none; }
.main-head h1 { font-size: 24px; margin: 0; color: var(--c, var(--accent)); display: flex; align-items: center; gap: 10px; min-width: 0; }
.main-head h1 .ic { width: 24px; height: 24px; }
.main-head .sub { color: var(--muted); font-size: 13px; width: 100%; margin-top: -4px; }
.main-head .spacer { flex: 1; }
.main-head select { padding: 5px 8px; font-size: 13px; }

.addbar { margin: 4px 24px 12px; background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); }
.addbar .row1 { display: flex; align-items: center; gap: 10px; padding: 4px 12px; }
.addbar .row1 .ic { color: var(--accent); }
.addbar .row1 input { flex: 1; border: 0; box-shadow: none; padding: 10px 0; background: transparent; font-size: 15px; }
.addbar .row2 {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 12px; border-top: 1px solid var(--line); background: var(--side);
  border-radius: 0 0 var(--radius) var(--radius);
}
.addbar .row2 select, .addbar .row2 input { padding: 4px 6px; font-size: 13px; }
.addbar .row2 .star { margin-left: auto; }
.chip-label { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 13px; }
.chip-label .ic { width: 15px; height: 15px; }

.tasks { overflow-y: auto; flex: 1; padding: 0 24px 40px; }
.tasks ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.group-title { font-size: 13px; font-weight: 600; color: var(--muted); margin: 14px 2px 6px; display: flex; align-items: center; gap: 6px; }
.group-title.late { color: var(--danger); }
.done-toggle { display: inline-flex; align-items: center; gap: 6px; margin: 16px 0 6px; padding: 4px 8px; border-radius: 6px; font-weight: 600; color: var(--muted); }
.done-toggle:hover { background: var(--panel); }
.done-toggle .ic { transition: transform .15s; }
.done-toggle.open .ic { transform: rotate(90deg); }
.empty { text-align: center; color: var(--muted); padding: 48px 12px; }
.empty .ic { width: 40px; height: 40px; color: var(--line); display: block; margin: 0 auto 8px; }

.task {
  display: flex; align-items: center; gap: 12px;
  background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 10px 12px; cursor: pointer;
}
.task:hover { background: color-mix(in srgb, var(--panel) 92%, var(--accent)); }
.task.sel { outline: 2px solid var(--accent); outline-offset: -2px; }
.task .body { flex: 1; min-width: 0; }
.task .title { word-break: break-word; }
.task.done .title { text-decoration: line-through; color: var(--muted); }
.task .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: 12px; color: var(--muted); margin-top: 2px; }
.task .meta:empty { display: none; }
.task .meta span { display: inline-flex; align-items: center; gap: 4px; }
.task .meta .ic { width: 13px; height: 13px; }
.task .meta .late { color: var(--danger); font-weight: 600; }
.task .meta .today { color: var(--accent); font-weight: 600; }
.badge-new { background: var(--accent); color: #fff; border-radius: 4px; padding: 0 6px; font-weight: 700; font-size: 11px; }

.chk {
  width: 20px; height: 20px; border-radius: 50%; flex: none;
  border: 2px solid var(--muted); display: grid; place-items: center; color: transparent;
}
.chk .ic { width: 12px; height: 12px; stroke-width: 3; }
.chk:hover { border-color: var(--accent); color: var(--accent); }
.done .chk, .chk.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chk.big { width: 24px; height: 24px; }

.star { color: var(--muted); display: grid; place-items: center; width: 28px; height: 28px; border-radius: 6px; flex: none; }
.star:hover { color: var(--star); }
.star.on { color: var(--star); }
.star.on .ic { fill: currentColor; }

/* ---------- Painel de detalhes ---------- */
.d-head { display: flex; align-items: flex-start; gap: 10px; padding: 16px 12px 8px 16px; }
.d-head .chk { margin-top: 6px; }
.d-title {
  flex: 1; resize: none; border: 1px solid transparent; background: transparent;
  font-size: 18px; font-weight: 600; padding: 3px 6px; overflow: hidden; min-height: 34px;
}
.d-title:hover:not(:disabled) { border-color: var(--line); }
.d-title.done { text-decoration: line-through; color: var(--muted); }
.d-scroll { flex: 1; overflow-y: auto; padding: 0 16px 16px; display: grid; gap: 10px; align-content: start; }
.card { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); }
.readonly-note { font-size: 12px; color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent); border-radius: 6px; padding: 8px 10px; }

.steps { list-style: none; margin: 0; padding: 4px 0; }
.step { display: flex; align-items: center; gap: 10px; padding: 6px 12px; }
.step .chk { width: 16px; height: 16px; border-width: 1.5px; }
.step .chk .ic { width: 10px; height: 10px; }
.step span.t { flex: 1; word-break: break-word; }
.step.done span.t { text-decoration: line-through; color: var(--muted); }
.step .del { opacity: 0; }
.step:hover .del { opacity: 1; }
.step.add .ic { color: var(--accent); }
.step.add input { flex: 1; border: 0; box-shadow: none; padding: 4px 0; background: transparent; }

.row-btn { display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px; border-radius: var(--radius); color: var(--muted); text-align: left; }
.row-btn:hover { background: var(--bg); }
.row-btn.on { color: var(--accent); font-weight: 600; }

.fields { padding: 4px 0; }
.field { display: grid; grid-template-columns: 110px 1fr auto; align-items: center; gap: 8px; padding: 8px 12px; }
.field + .field { border-top: 1px solid var(--line); }
.field > span { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.field select, .field input { width: 100%; padding: 5px 7px; }
.take-btn { grid-column: 2 / 4; justify-self: start; }

.notes { width: 100%; min-height: 90px; resize: vertical; border: 0; box-shadow: none; padding: 12px; background: transparent; }

.activity { padding: 12px; }
.activity h4 { margin: 0 0 8px; font-size: 13px; color: var(--muted); }
.activity ul { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 8px; }
.act { display: flex; gap: 8px; font-size: 13px; }
.act .txt { min-width: 0; flex: 1; }
.act .txt small { color: var(--muted); margin-left: 4px; }
.act.comment .bubble { background: var(--bg); border-radius: 8px; padding: 6px 10px; margin-top: 2px; white-space: pre-wrap; word-break: break-word; }
.act.event { color: var(--muted); align-items: center; }
.act.event .ic { width: 14px; height: 14px; margin: 0 4px; }
.comment-box { display: flex; gap: 8px; align-items: flex-end; }
.comment-box textarea { flex: 1; resize: vertical; min-height: 38px; }

.d-foot { display: flex; align-items: center; gap: 8px; padding: 10px 12px 10px 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.d-foot span { flex: 1; }
.d-foot .icon-btn:hover { color: var(--danger); }

/* ---------- Modal ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { background: var(--panel); border-radius: 12px; width: 100%; max-width: 440px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.modal.wide { max-width: 720px; }
.modal header { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 8px; }
.modal header h2 { margin: 0; font-size: 17px; }
.modal .content { padding: 8px 18px 18px; overflow-y: auto; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.team-add { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 8px; align-items: end; padding-bottom: 14px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.team-add .check { grid-column: 1 / -1; }
.team-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.team-row .who { flex: 1; min-width: 150px; }
.team-row .who small { color: var(--muted); display: block; }
.team-row.off { opacity: .55; }
.tag { font-size: 11px; border-radius: 4px; padding: 1px 6px; background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.colors { display: flex; gap: 8px; flex-wrap: wrap; }
.colors button { width: 24px; height: 24px; border-radius: 50%; background: var(--c); }
.colors button.on { outline: 2px solid var(--text); outline-offset: 2px; }

/* ---------- Avisos ---------- */
#toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 60; width: min(420px, calc(100vw - 32px)); }
.toast { background: #2b302c; color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0, 0, 0, .25); font-size: 13px; animation: pop .15s ease-out; }
.toast.err { background: var(--danger); }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }

/* ---------- Celular e tablet ---------- */
@media (max-width: 1100px) {
  .shell.has-detail { grid-template-columns: 270px 1fr; }
  .has-detail .detail { position: fixed; right: 0; top: 0; bottom: 0; width: min(400px, 100vw); z-index: 30; box-shadow: -10px 0 30px rgba(0, 0, 0, .15); }
}
@media (max-width: 760px) {
  .shell, .shell.has-detail { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: min(300px, 85vw); z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .nav-open .sidebar { transform: none; box-shadow: 10px 0 30px rgba(0, 0, 0, .2); }
  .nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .3); z-index: 35; }
  .main-head { padding: 14px 16px 8px; }
  .main-head .burger { display: inline-grid; }
  .main-head h1 { font-size: 20px; }
  .addbar { margin: 4px 16px 10px; }
  .tasks { padding: 0 16px 40px; }
  .has-detail .detail { width: 100vw; }
  .team-add { grid-template-columns: 1fr; }
  .field { grid-template-columns: 96px 1fr auto; }
}
