/* Tema claro/escuro seguindo a preferencia do sistema, com override manual
   guardado em localStorage (atributo data-theme no <html>). */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #dfe3e8;
  --text: #16191d;
  --text-dim: #666e78;
  --accent: #0f766e;
  --accent-soft: #d5f0ec;
  --p0: #dc2626;
  --p1: #ea580c;
  --p2: #0284c7;
  --p3: #64748b;
  --done: #16a34a;
  --shadow: 0 1px 3px rgba(0,0,0,.07), 0 6px 18px rgba(0,0,0,.05);
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1116;
    --surface: #171b22;
    --surface-2: #1f242d;
    --border: #2b323c;
    --text: #e6e9ee;
    --text-dim: #949daa;
    --accent: #2dd4bf;
    --accent-soft: #123833;
    --shadow: 0 1px 3px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.3);
  }
}

:root[data-theme="dark"] {
  --bg: #0e1116;
  --surface: #171b22;
  --surface-2: #1f242d;
  --border: #2b323c;
  --text: #e6e9ee;
  --text-dim: #949daa;
  --accent: #2dd4bf;
  --accent-soft: #123833;
  --shadow: 0 1px 3px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.3);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

button { font: inherit; cursor: pointer; border: 0; border-radius: 9px; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 9px; padding: 9px 11px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea { resize: vertical; }

.primary { background: var(--accent); color: #fff; padding: 9px 16px; font-weight: 600; }
.primary:hover { filter: brightness(1.08); }
.ghost { background: var(--surface); color: var(--text); border: 1px solid var(--border); padding: 9px 14px; }
.ghost:hover { background: var(--surface-2); }
.icon-btn { background: transparent; color: var(--text-dim); font-size: 18px; padding: 6px 10px; }
.icon-btn:hover { color: var(--text); background: var(--surface-2); }
.err { color: var(--p0); font-size: 13px; min-height: 18px; display: block; }

/* ───────────────────────────── Login ───────────────────────────── */

.login { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); padding: 20px; }
.login-box {
  background: var(--surface); padding: 32px; border-radius: 16px; box-shadow: var(--shadow);
  width: min(380px, 100%); display: flex; flex-direction: column; gap: 14px;
}
.login-box h1 { margin: 0; font-size: 22px; }
.login-box p { margin: 0; color: var(--text-dim); font-size: 14px; }

/* ──────────────────────────── Topo ─────────────────────────────── */

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  padding: 12px 22px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 11px; cursor: pointer; }
.brand:hover strong { color: var(--accent); }
.logo {
  width: 36px; height: 36px; border-radius: 10px; background: var(--accent); color: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: 15px; letter-spacing: -.5px;
}
.brand strong { display: block; font-size: 15px; }
.brand small { color: var(--text-dim); font-size: 12.5px; }

.tabs { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.tab { background: transparent; color: var(--text-dim); padding: 8px 14px; font-weight: 500; }
.tab:hover { background: var(--surface-2); color: var(--text); }
.tab.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.actions { display: flex; gap: 8px; align-items: center; }

.view { padding: 26px 22px 60px; max-width: 1500px; margin: 0 auto; }

.section-head { margin-bottom: 20px; }
.section-head h2 { margin: 0 0 4px; font-size: 20px; }
.section-head p { margin: 0; color: var(--text-dim); font-size: 14px; max-width: 70ch; }

/* ──────────────────────────── KPIs ─────────────────────────────── */

/* Cada cartao e um botao que abre a lista daquele recorte. O "ver lista →"
   aparece no hover para deixar isso obvio sem poluir o numero. */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 30px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 15px 17px; text-align: left; color: var(--text);
  position: relative; transition: transform .12s, border-color .12s, box-shadow .12s;
}
.kpi:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: var(--shadow); }
.kpi b { display: block; font-size: 29px; line-height: 1.15; }
.kpi span { color: var(--text-dim); font-size: 13px; display: block; }
.kpi i { font-style: normal; font-size: 11.5px; color: var(--accent); opacity: 0; transition: opacity .12s; }
.kpi:hover i { opacity: 1; }
.kpi.danger b { color: var(--p0); }
.kpi.good b { color: var(--done); }
.kpi.warn b { color: var(--p1); }

.block-title { font-size: 15px; margin: 0 0 13px; display: flex; align-items: baseline; gap: 9px; }
.block-title small { font-weight: 400; color: var(--text-dim); font-size: 12.5px; }

.back {
  background: transparent; color: var(--text-dim); padding: 4px 0;
  font-size: 13.5px; margin-bottom: 6px; display: block;
}
.back:hover { color: var(--accent); }

.hint { color: var(--text-dim); font-size: 13px; margin: -6px 0 16px; }
.hint code { background: var(--surface-2); padding: 1px 6px; border-radius: 5px; font-size: 12px; }
.mine { color: var(--p1); font-weight: 600; }
.muted { color: var(--text-dim); font-size: 13.5px; }

.badge {
  background: var(--p1); color: #fff; font-size: 11px; font-weight: 700;
  border-radius: 20px; padding: 1px 7px; margin-left: 5px;
}

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 11px 20px; border-radius: 10px;
  font-size: 13.5px; z-index: 200; box-shadow: 0 6px 24px rgba(0,0,0,.25);
}

/* ──────────────────── Cartoes de projeto ───────────────────────── */

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 15px; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 17px 18px; box-shadow: var(--shadow); cursor: pointer;
  border-top: 3px solid var(--c, var(--accent)); transition: transform .12s, box-shadow .12s;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.1), 0 14px 32px rgba(0,0,0,.08); }
.card h3 { margin: 0 0 3px; font-size: 16.5px; }
.card .tagline { color: var(--text-dim); font-size: 13px; margin: 0 0 12px; }

.bar { background: var(--surface-2); border-radius: 6px; height: 7px; overflow: hidden; margin: 12px 0 9px; }
.bar > span { display: block; height: 100%; background: var(--c, var(--accent)); transition: width .3s; }

.card-meta { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--text-dim); }
.card-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 11px; }

.chip {
  font-size: 11.5px; padding: 3px 9px; border-radius: 20px;
  background: var(--surface-2); color: var(--text-dim); white-space: nowrap;
}
.chip.stage-producao { background: #dcfce7; color: #15803d; }
.chip.stage-beta { background: #fef3c7; color: #b45309; }
.chip.stage-desenvolvimento { background: #dbeafe; color: #1d4ed8; }
.chip.stage-pausado, .chip.stage-ideia { background: var(--surface-2); color: var(--text-dim); }
.chip.blockers { background: #fee2e2; color: #b91c1c; font-weight: 600; }
.chip.earning { background: #dcfce7; color: #15803d; font-weight: 600; }
.chip.mine { background: #ffedd5; color: #c2410c; font-weight: 600; }
.chip.tiny { font-size: 10.5px; padding: 2px 7px; }
:root[data-theme="dark"] .chip.mine { background: #3d2510; color: #fb923c; }

.card-foot {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 13px; padding-top: 11px; border-top: 1px solid var(--border);
}
.open-hint { font-size: 12px; color: var(--text-dim); }
.card:hover .open-hint { color: var(--accent); }
.mini {
  background: var(--surface-2); color: var(--text-dim); border: 1px solid var(--border);
  font-size: 11.5px; padding: 4px 10px;
}
.mini:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

.board-actions { display: flex; gap: 8px; margin-left: auto; }
:root[data-theme="dark"] .chip.stage-producao, :root[data-theme="dark"] .chip.earning { background: #14351f; color: #4ade80; }
:root[data-theme="dark"] .chip.stage-beta { background: #3a2c0c; color: #fbbf24; }
:root[data-theme="dark"] .chip.stage-desenvolvimento { background: #16243f; color: #60a5fa; }
:root[data-theme="dark"] .chip.blockers { background: #3d1418; color: #f87171; }

/* ──────────────────────────── Quadro ───────────────────────────── */

.board-head { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.board-head > select { width: auto; min-width: 210px; font-weight: 600; }
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filters select { width: auto; font-size: 13.5px; padding: 7px 9px; }
.chk { display: inline-flex; align-items: center; gap: 7px; font-size: 13.5px; color: var(--text-dim); white-space: nowrap; }
.chk input { width: auto; }
.chk.big { font-size: 14.5px; color: var(--text); padding: 4px 0; }

.board { display: grid; grid-template-columns: repeat(5, minmax(230px, 1fr)); gap: 13px; align-items: start; }
@media (max-width: 1100px) { .board { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .board { grid-template-columns: 1fr; } }

.col { background: var(--surface-2); border-radius: var(--radius); padding: 11px; min-height: 90px; }
.col > h4 {
  margin: 2px 4px 11px; font-size: 12.5px; text-transform: uppercase;
  letter-spacing: .6px; color: var(--text-dim); display: flex; justify-content: space-between;
}
.col-empty { color: var(--text-dim); font-size: 13px; text-align: center; padding: 14px 0; }

.task {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 11px 12px; margin-bottom: 9px; cursor: pointer;
  border-left: 3px solid var(--pc, var(--p2));
}
.task:hover { border-color: var(--accent); }
.task.blocks { box-shadow: inset 3px 0 0 var(--p0); border-left-color: var(--p0); }
.task h5 { margin: 0 0 6px; font-size: 14px; font-weight: 600; line-height: 1.35; }
.task-meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 11.5px; color: var(--text-dim); }
.task .flag { background: var(--p0); color: #fff; padding: 1px 6px; border-radius: 4px; font-size: 10.5px; font-weight: 700; }
.task .att { color: var(--text-dim); }

/* ───────────────────── Lista (producao/atividade) ──────────────── */

.stack { display: flex; flex-direction: column; gap: 10px; }
.row-item {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 13px 16px; display: flex; gap: 13px; align-items: flex-start; cursor: pointer;
  border-left: 4px solid var(--pc, var(--p2));
}
.row-item:hover { border-color: var(--accent); }
.row-item.quiet { cursor: default; }
.row-item.quiet:hover { border-color: var(--border); }
.row-item .who { font-size: 12px; color: var(--text-dim); white-space: nowrap; }
.row-item .who.mine { color: var(--p1); font-weight: 700; }
.task.is-mine { background: linear-gradient(90deg, rgba(234,88,12,.07), transparent 60%); }
.row-item .grow { flex: 1; min-width: 0; }
.row-item h5 { margin: 0 0 4px; font-size: 14.5px; }
.empty-state { text-align: center; color: var(--text-dim); padding: 50px 20px; }
.empty-state b { display: block; font-size: 17px; color: var(--done); margin-bottom: 6px; }

/* ───────────────────────── Painel lateral ──────────────────────── */

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100%);
  background: var(--surface); border-left: 1px solid var(--border);
  z-index: 60; display: flex; flex-direction: column; box-shadow: -8px 0 30px rgba(0,0,0,.13);
}
.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 18px; border-bottom: 1px solid var(--border);
}
.pill { background: var(--accent-soft); color: var(--accent); padding: 4px 11px; border-radius: 20px; font-size: 12.5px; font-weight: 600; }
.drawer-body { overflow-y: auto; padding: 20px 22px 50px; flex: 1; }
.drawer-body h3 { margin: 0 0 10px; font-size: 18px; line-height: 1.35; }
.drawer-body .detail { background: var(--surface-2); padding: 12px 14px; border-radius: 10px; white-space: pre-wrap; font-size: 14px; }
.drawer-body h4 { margin: 24px 0 9px; font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--text-dim); }

.quick { display: flex; gap: 7px; flex-wrap: wrap; margin: 14px 0; }
.quick button { padding: 7px 13px; font-size: 13.5px; background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.quick button:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.quick button.on { background: var(--accent); color: #fff; border-color: var(--accent); }

.note { background: var(--surface-2); border-radius: 10px; padding: 10px 13px; margin-bottom: 8px; font-size: 13.5px; }
.note b { font-size: 12.5px; }
.note i { color: var(--text-dim); font-size: 11.5px; font-style: normal; margin-left: 6px; }
.note p { margin: 5px 0 0; white-space: pre-wrap; }

.shots { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 9px; }
.shots figure { margin: 0; }
.shots img { width: 100%; border-radius: 8px; border: 1px solid var(--border); cursor: zoom-in; display: block; }
.shots figcaption { font-size: 11.5px; color: var(--text-dim); margin-top: 3px; }

.dropzone {
  border: 2px dashed var(--border); border-radius: 10px; padding: 18px;
  text-align: center; color: var(--text-dim); font-size: 13.5px; cursor: pointer; margin-top: 10px;
}
.dropzone:hover, .dropzone.over { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 50; }

/* ─────────────────────────── Modal ─────────────────────────────── */

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 80; display: grid; place-items: center; padding: 20px; }
.modal-box {
  background: var(--surface); border-radius: 16px; padding: 24px;
  width: min(600px, 100%); max-height: 90vh; max-height: 90dvh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 13px; box-shadow: var(--shadow);
}
.modal-box.wide { width: min(880px, 100%); }
.modal-box h2 { margin: 0; font-size: 19px; }
.modal-box textarea[readonly] {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 12px; line-height: 1.5; background: var(--surface-2);
}
.modal-box label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--text-dim); font-weight: 500; }
.modal-box .row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-actions { display: flex; gap: 9px; justify-content: flex-end; margin-top: 6px; }

/* Visualizador de imagem em tela cheia */
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.9); z-index: 100; display: grid; place-items: center; cursor: zoom-out; padding: 20px; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }

@media (max-width: 720px) {
  .topbar { padding: 10px 14px; gap: 12px; }
  .tabs { order: 3; width: 100%; margin-left: 0; overflow-x: auto; }
  .view { padding: 18px 14px 50px; }
  .modal-box .row { grid-template-columns: 1fr; }
}
