* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f4f2ef;
  --col-bg: #eceae6;
  --card-bg: #ffffff;
  --ink: #1c1a17;
  --ink-soft: #6f6a63;
  --line: #dedad4;
  --accent: #1c1a17;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(28, 26, 23, .08);
  --shadow-lift: 0 8px 24px rgba(28, 26, 23, .16);
  font-size: 15px;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- header ---------- */
.site-header {
  display: flex; align-items: center; justify-content: space-between;
  background: #fff;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.brand { display: flex; align-items: center; }
.brand-name {
  font-size: 1.2rem; font-weight: 800;
  letter-spacing: .01em;
  color: #1b2430;
}
.brand-sep {
  width: 1px; height: 24px;
  background: #c6cad0;
  margin: 0 14px;
}
.brand-app { font-size: 1.2rem; font-weight: 600; color: #1b2430; }
.site-nav { display: flex; align-items: center; gap: 26px; }
.site-nav button {
  background: none; border: none; cursor: pointer;
  font: inherit; font-size: .95rem;
  color: #5a6472;
  padding: 2px 0;
}
.site-nav button:hover { color: #1b2430; }

/* ---------- toolbar (filtros + ações) ---------- */
.toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 12px 20px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.toolbar input[type=search] { flex: 1 1 160px; max-width: 260px; }
.toolbar input, .toolbar select {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font: inherit;
  font-size: .85rem;
  color: var(--ink);
}
.stats { margin-left: auto; font-size: .8rem; color: var(--ink-soft); white-space: nowrap; }

/* ---------- botões ---------- */
.btn {
  font: inherit; font-size: .85rem;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: filter .15s, background .15s;
  white-space: nowrap;
}
.btn:hover { filter: brightness(.92); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--ink); color: var(--ink); }
.btn-ghost:hover { background: rgba(0,0,0,.05); filter: none; }
.btn-danger { background: transparent; border-color: #c0392b; color: #c0392b; }
.btn-danger:hover { background: #c0392b; color: #fff; filter: none; }
.btn-dark { background: var(--accent); color: #fff; }
.btn-small { font-size: .75rem; padding: 4px 10px; border-radius: 6px; }
.btn-icon {
  background: none; border: none; font-size: 1rem; cursor: pointer;
  color: var(--ink-soft); padding: 4px 8px; border-radius: 6px;
}
.btn-icon:hover { background: rgba(0,0,0,.06); color: var(--ink); }

/* ---------- board ---------- */
.board {
  flex: 1;
  display: flex;
  gap: 14px;
  padding: 16px 20px 20px;
  overflow-x: auto;
  align-items: stretch;
}
.column {
  flex: 1 0 215px;
  min-width: 210px;
  max-width: 360px;
  background: var(--col-bg);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  max-height: 100%;
}
.column.drag-over { outline: 2px dashed var(--ink-soft); outline-offset: -4px; }
.col-head {
  padding: 12px 14px 8px;
  display: flex; align-items: baseline; gap: 8px;
  flex-shrink: 0;
}
.col-head h2 { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.col-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; align-self: center; }
.col-count { font-size: .75rem; color: var(--ink-soft); }
.col-cards {
  padding: 4px 10px 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-height: 60px;
}

/* ---------- cards ---------- */
.card {
  background: var(--card-bg);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 6px 10px 7px;
  cursor: grab;
  border-left: 3px solid var(--area-color, #999);
  transition: box-shadow .15s, transform .15s;
}
.card:hover { box-shadow: var(--shadow-lift); transform: translateY(-1px); }
.card.dragging { opacity: .45; }
.card-top { display: flex; align-items: center; gap: 6px; margin-bottom: 3px; }
.badge-area {
  font-size: .65rem; font-weight: 600;
  color: var(--area-color, #666);
  text-transform: uppercase; letter-spacing: .04em;
}
.card-top .right { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.badge-effort {
  font-size: .68rem; font-weight: 700;
  padding: 2px 7px; border-radius: 999px;
  color: #fff;
}
.badge-effort.e-S { background: #2e9e5b; }
.badge-effort.e-M { background: #d99a06; }
.badge-effort.e-L { background: #e06816; }
.badge-effort.e-XL { background: #c0392b; }
.badge-effort.e-unk { background: #8a857e; }
.badge-shots { font-size: .68rem; cursor: help; }
.badge-owner {
  font-size: .62rem; font-weight: 700; letter-spacing: .03em;
  color: #fff; background: #1b2430;
  padding: 2px 6px; border-radius: 999px;
}
.badge-branch {
  font-size: .72rem; font-weight: 700;
  color: #7c3aed;
  cursor: help;
}
.badge-agent { font-size: .7rem; cursor: help; }
.badge-agent.a-queued { opacity: .55; }
.badge-agent.a-working { animation: agent-pulse 1.4s ease-in-out infinite; }
.badge-agent.a-error { filter: hue-rotate(140deg) saturate(3); }
@keyframes agent-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .35; }
}
.agent-note {
  font-size: .78rem; color: var(--ink-soft);
  background: rgba(13, 148, 136, .08);
  border: 1px solid rgba(13, 148, 136, .25);
  border-radius: 8px; padding: 8px 10px;
}
.agent-note.agent-error {
  background: rgba(192, 57, 43, .07);
  border-color: rgba(192, 57, 43, .3);
  color: #96281b;
}
.card-title { font-size: .82rem; font-weight: 500; line-height: 1.3; }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(28,26,23,.45);
  display: flex; align-items: center; justify-content: center;
  padding: 18px; z-index: 100;
}
.modal {
  background: #fff; border-radius: 14px;
  width: 100%; max-width: 720px;
  max-height: 92vh;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lift);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px 10px;
}
.modal-head h2 { font-size: 1.05rem; font-weight: 600; }
.modal-body {
  padding: 6px 20px 10px;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 12px;
}
.modal-body label { display: flex; flex-direction: column; gap: 5px; font-size: .78rem; font-weight: 600; color: var(--ink-soft); }
.modal-body input, .modal-body select, .modal-body textarea {
  font: inherit; font-size: .88rem; font-weight: 400; color: var(--ink);
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; width: 100%;
}
.modal-body textarea { resize: vertical; line-height: 1.45; }
#m-prompt { background: #faf9f7; font-family: Consolas, 'Courier New', monospace; font-size: .8rem; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.branch-row { display: flex; gap: 6px; }
.branch-row input { flex: 1; font-family: Consolas, 'Courier New', monospace; font-size: .82rem; }
.branch-row .btn-small { flex-shrink: 0; border: 1px solid var(--line); background: none; color: var(--ink-soft); }
.branch-row .btn-small:hover { background: var(--accent); color: #fff; border-color: var(--accent); filter: none; }

/* gestão de utilizadores (settings) */
.users-section { display: flex; flex-direction: column; gap: 6px; }
.users-head { font-size: .78rem; font-weight: 600; color: var(--ink-soft); }
.user-row {
  display: grid;
  grid-template-columns: 1.5fr 1.5fr 70px 30px;
  gap: 6px; align-items: center;
}
.user-row-head span {
  font-size: .68rem; font-weight: 600; color: var(--ink-soft);
  text-transform: uppercase; letter-spacing: .04em;
}
.user-row .u-code { text-transform: uppercase; text-align: center; }
#s-add-user { align-self: flex-start; margin-top: 2px; border: 1px solid var(--line); background: none; color: var(--ink-soft); }
#s-add-user:hover { background: var(--accent); color: #fff; border-color: var(--accent); filter: none; }
/* gestão de áreas (settings) */
.area-row {
  display: grid;
  grid-template-columns: 1fr 56px 30px;
  gap: 6px; align-items: center;
}
.area-row-head span {
  font-size: .68rem; font-weight: 600; color: var(--ink-soft);
  text-transform: uppercase; letter-spacing: .04em;
}
.area-row input[type=color] {
  padding: 2px; height: 34px; width: 100%;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer;
}
#s-add-area { align-self: flex-start; margin-top: 2px; border: 1px solid var(--line); background: none; color: var(--ink-soft); }
#s-add-area:hover { background: var(--accent); color: #fff; border-color: var(--accent); filter: none; }

/* screenshots */
.shots-section { display: flex; flex-direction: column; gap: 6px; }
.shots-hint { font-size: .72rem; color: var(--ink-soft); align-self: center; }
.shots-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.shot { position: relative; }
.shot img {
  width: 96px; height: 72px; object-fit: cover;
  border: 1px solid var(--line); border-radius: 8px; display: block;
  background: #faf9f7;
}
.shot img:hover { box-shadow: var(--shadow-lift); }
.shot-del {
  position: absolute; top: -6px; right: -6px;
  width: 20px; height: 20px; line-height: 1;
  background: var(--ink); color: #fff; border: none; border-radius: 50%;
  font-size: .65rem; cursor: pointer;
}
#m-add-shot { border: 1px solid var(--line); background: none; color: var(--ink-soft); }
#m-add-shot:hover:not(:disabled) { background: var(--accent); color: #fff; border-color: var(--accent); filter: none; }
#m-add-shot:disabled { opacity: .4; cursor: default; }

.export-section { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.export-section .btn { border: 1px solid var(--line); background: none; color: var(--ink-soft); text-decoration: none; }
.export-section .btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); filter: none; }
.prompt-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.prompt-btns { display: flex; gap: 6px; }
.modal-foot {
  display: flex; gap: 8px; align-items: center;
  padding: 12px 20px 16px;
  border-top: 1px solid var(--line);
}
.spacer { flex: 1; }

/* ---------- princípios ---------- */
.modal-sm { max-width: 560px; }
.principles-list {
  list-style: none;
  display: flex; flex-direction: column; gap: 12px;
  padding: 4px 2px 10px;
  counter-reset: pr;
}
.principles-list li {
  display: flex; gap: 14px;
  font-size: .9rem; line-height: 1.5;
  color: var(--ink);
}
.principles-list li::before {
  counter-increment: pr;
  content: counter(pr, decimal-leading-zero);
  font-size: .8rem; font-weight: 700;
  color: #b08d57;
  flex-shrink: 0;
  padding-top: 2px;
}

/* ---------- botão ordenar (coluna backlog) ---------- */
.btn-order {
  margin-left: auto;
  background: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  font-size: .68rem;
  color: var(--ink-soft);
  cursor: pointer;
  padding: 3px 8px;
  white-space: nowrap;
}
.btn-order:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---------- vista de ordenação do backlog ---------- */
.overlay {
  position: fixed; inset: 0;
  background: var(--bg);
  z-index: 90;
  display: flex;
}
.overlay-panel {
  width: 100%; max-width: 880px;
  margin: 0 auto;
  padding: 18px 20px 0;
  display: flex; flex-direction: column;
  height: 100%;
}
.overlay-head {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 14px; flex-shrink: 0;
}
.overlay-head h2 { font-size: 1.1rem; font-weight: 600; white-space: nowrap; }
.overlay-hint { font-size: .75rem; color: var(--ink-soft); }
.overlay-head .btn-icon { margin-left: auto; }
.bl-list {
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 4px;
  padding-bottom: 40px;
}
.bl-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 12px;
  cursor: grab;
  font-size: .85rem;
}
.bl-row.dragging { opacity: .4; }
.bl-row:hover { box-shadow: var(--shadow); }
.bl-num { width: 22px; text-align: right; color: var(--ink-soft); font-size: .72rem; flex-shrink: 0; }
.bl-handle { color: var(--ink-soft); flex-shrink: 0; }
.bl-area {
  font-size: .68rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em;
  white-space: nowrap; flex-shrink: 0;
  width: 130px;
}
.bl-title { flex: 1; line-height: 1.3; }
.bl-arrows { display: flex; gap: 2px; flex-shrink: 0; }
.bl-arrows button {
  background: none; border: 1px solid var(--line); border-radius: 5px;
  font-size: .75rem; color: var(--ink-soft); cursor: pointer;
  padding: 1px 7px;
}
.bl-arrows button:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

@media (max-width: 720px) {
  .bl-area { width: auto; }
  .overlay-hint { display: none; }
}

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff;
  padding: 10px 18px; border-radius: 999px;
  font-size: .85rem; z-index: 200;
  box-shadow: var(--shadow-lift);
  transition: opacity .25s;
}

.hidden { display: none !important; }

/* ---------- mobile ---------- */
@media (max-width: 720px) {
  body { overflow: auto; height: auto; }
  .board { flex-direction: row; overflow-x: auto; scroll-snap-type: x mandatory; }
  .column { flex: 0 0 85vw; scroll-snap-align: start; max-height: 75vh; }
  .row-3 { grid-template-columns: 1fr; }
  .row-2 { grid-template-columns: 1fr; }
  .stats { display: none; }
}
