:root {
  --rail: #143028;
  --rail-ink: #f3f7f5;
  --rail-dim: #c5d5ce;
  --rail-line: rgba(255, 255, 255, 0.12);
  --canvas: #e7eeea;
  --paper: #ffffff;
  --ink: #17211c;
  --dim: #3e5148;
  --faint: #5d7268;
  --line: #d5e0da;
  --green: #0e6b45;
  --green-ink: #08472d;
  --green-wash: #e5f5ec;
  --red: #8d2f2a;
  --red-wash: #f8eceb;
  --blue: #0b4f86;
  --shadow: 0 10px 28px rgba(20, 48, 40, 0.12);
  --sans: "Segoe UI", "Helvetica Neue", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.4;
  letter-spacing: 0;
}
::selection { background: #cfe8db; color: var(--ink); }
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
input::placeholder, textarea::placeholder { color: var(--faint); }
a { color: var(--blue); }

.gate {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--rail);
}
.gate-card {
  width: min(400px, 100%);
  background: var(--paper);
  border-radius: 12px;
  padding: 28px 28px 22px;
  box-shadow: var(--shadow);
}
.gate-card h1 { margin: 8px 0 0; font-size: 28px; font-weight: 700; letter-spacing: -0.03em; }
.gate .brand span { color: var(--dim); }
.gate-card p { margin: 8px 0 0; color: var(--dim); }
.gate-card form { display: grid; gap: 8px; margin-top: 22px; }
label { font-size: 13px; font-weight: 600; color: var(--dim); }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 9px 10px;
}
textarea { min-height: 88px; resize: vertical; }
.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 14px;
  background: var(--green);
  color: white;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn:hover { background: var(--green-ink); }
.btn.quiet {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}
.btn.quiet:hover { background: #f4f8f6; }
.btn.danger { background: #fff; color: var(--red); border-color: #e4c6c4; }
.err { min-height: 1.2em; margin: 0; color: var(--red); font-size: 13px; }

.shell { height: 100vh; display: grid; grid-template-columns: 228px minmax(0, 1fr); }
.rail {
  background: var(--rail);
  color: var(--rail-ink);
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 18px 12px 12px;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 0 8px 16px; }
.brand b { display: block; font-size: 16px; font-weight: 700; }
.brand span { display: block; color: var(--rail-dim); font-size: 12px; }
.mark { width: 28px; height: 28px; display: block; flex: none; }
.rail h2 {
  margin: 8px 8px 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--rail-dim);
}
.people { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.person {
  width: 100%;
  display: flex;
  gap: 8px;
  align-items: center;
  text-align: left;
  border: 0;
  color: inherit;
  background: transparent;
  border-radius: 8px;
  padding: 7px 8px;
}
.person.on, .person:hover { background: rgba(255, 255, 255, 0.08); }
.person b { display: block; font-size: 13px; font-weight: 600; white-space: nowrap; }
.person small { color: var(--rail-dim); font-size: 12px; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; flex: none;
  background: #3e6b58; color: white; font-size: 11px; font-weight: 700;
}
.avatar.diego { background: #245c78; }
.avatar.alysson { background: #0e6b45; }
.avatar.lorenzo { background: #8a5a32; }
.avatar.none { background: #5d7268; }
.me {
  margin-top: auto;
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border-top: 1px solid var(--rail-line);
}
.me b { display: block; font-size: 13px; }
.me small { color: var(--rail-dim); }
.me button { margin-left: auto; background: none; border: 0; color: var(--rail-dim); font-weight: 600; }

.work { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.top {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 18px 10px;
}
.top h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.03em; }
.top .count { margin: 2px 0 0; color: var(--dim); font-size: 13px; }
.tools { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.search { width: 240px; background: #fff; }
.switch { display: flex; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 2px; }
.switch button {
  border: 0; background: transparent; border-radius: 6px; padding: 7px 12px; font-weight: 600; color: var(--dim);
}
.switch button.on { background: var(--rail); color: white; font-weight: 700; }
.chip {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 8px 12px;
  font-weight: 600;
}
.chip.on { background: var(--rail); color: white; border-color: var(--rail); }

.board {
  flex: 1;
  min-height: 0;
  display: flex;
  gap: 8px;
  padding: 4px 12px 12px;
  overflow: auto;
}
.col {
  flex: 1 0 180px;
  min-width: 0;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--line);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.col.over { outline: 2px solid var(--green); outline-offset: -2px; }
.col header { padding: 10px 10px 6px; display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.col h2 { margin: 0; font-size: 13px; font-weight: 700; }
.col header span { color: var(--faint); font-size: 12px; font-variant-numeric: tabular-nums; }
.col .list { overflow: auto; padding: 0 8px 8px; display: flex; flex-direction: column; gap: 6px; min-height: 64px; }
.col.archive { background: transparent; border-style: dashed; }
.gap { flex: 0 0 8px; }

.lead {
  text-align: left;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  display: grid;
  gap: 4px;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(20, 48, 40, 0.04);
}
.lead:hover { border-color: #b7c9c0; }
.lead.is-dragging { opacity: 0.45; }
.lead.ganho { background: var(--green-wash); }
.lead.perdido { background: var(--red-wash); }
.lead-top, .lead-foot { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.lead strong { font-size: 14px; font-weight: 700; }
.lead p { margin: 0; color: var(--dim); font-size: 13px; }
.phone { color: var(--faint); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.wa {
  border: 0; background: var(--green-wash); color: var(--green-ink);
  border-radius: 999px; padding: 3px 8px; font-size: 12px; font-weight: 700;
}
.empty { margin: 8px 4px; color: var(--faint); font-size: 13px; }

.table-wrap { flex: 1; min-height: 0; overflow: auto; padding: 0 18px 18px; }
table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: 10px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--dim); font-weight: 700; background: #f7faf8; position: sticky; top: 0; }
th button { border: 0; background: none; padding: 0; font-weight: 700; color: inherit; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #f4faf7; }
td .sub { display: block; color: var(--faint); font-size: 12px; }
.tag { font-weight: 700; font-size: 12px; }
.tag.ganho { color: var(--green-ink); }
.tag.perdido { color: var(--red); }

.deal { flex: 1; min-height: 0; display: grid; grid-template-rows: auto auto minmax(0, 1fr); }
.deal-head { padding: 14px 18px 8px; display: flex; gap: 16px; align-items: flex-start; }
.back { background: none; border: 0; color: var(--blue); font-weight: 600; padding: 4px 0; }
.deal-head h1 { margin: 0; font-size: 24px; letter-spacing: -0.03em; font-weight: 700; }
.deal-head .meta { margin: 4px 0 0; color: var(--dim); }
.deal-actions { margin-left: auto; display: flex; gap: 8px; }
.track {
  display: flex;
  gap: 4px;
  padding: 0 18px 12px;
  overflow: auto;
}
.track button {
  flex: 1 0 120px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 8px 10px;
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  color: var(--dim);
}
.track button.done { background: var(--green-wash); color: var(--green-ink); border-color: #b7dfc8; }
.track button.now { background: var(--green); color: white; border-color: var(--green); }
.track button.won { background: var(--green); color: white; }
.track button.lost { background: var(--red); color: white; border-color: var(--red); }
.deal-body { min-height: 0; display: grid; grid-template-columns: 320px minmax(0, 1fr); border-top: 1px solid var(--line); }
.facts, .history { min-height: 0; overflow: auto; }
.facts { background: #f7faf8; border-right: 1px solid var(--line); padding: 16px 16px 28px; }
.facts h2, .history h2 { margin: 18px 0 8px; font-size: 15px; font-weight: 700; }
.facts h2:first-child { margin-top: 0; }
.kv { display: grid; gap: 3px; margin: 0 0 10px; }
.kv span { color: var(--dim); font-size: 12px; font-weight: 600; }
.kv b, .kv a, .kv p { margin: 0; font-weight: 550; overflow-wrap: anywhere; }
.checks { display: grid; gap: 6px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 550; }
.check input { width: auto; }
.history { padding: 16px 20px 32px; background: #fff; }
.composer { display: grid; gap: 8px; }
.timeline { list-style: none; margin: 16px 0 0; padding: 0; }
.timeline li {
  display: grid;
  grid-template-columns: 10px 1fr;
  gap: 12px;
  padding: 8px 10px;
  margin-bottom: 8px;
  border-radius: 8px;
}
.timeline .kind { display: block; font-size: 12px; font-weight: 700; margin-bottom: 2px; }
.timeline p, .timeline b { margin: 0; font-weight: 550; }
.timeline li.move { background: transparent; }
.timeline li.move .dot { background: var(--green); }
.timeline li.move .kind { color: var(--green-ink); }
.timeline li.field { background: #eef3f8; }
.timeline li.field .dot { background: var(--blue); }
.timeline li.field .kind { color: var(--blue); }
.timeline li.extract { background: var(--canvas); }
.timeline li.extract .dot { background: var(--faint); }
.timeline li.extract .kind { color: var(--dim); }
.timeline li.nota {
  display: block;
  background: #f4efe6;
  padding: 12px 14px;
}
.timeline li.nota .dot { display: none; }
.timeline li.nota .kind { color: #6d5b45; }
.timeline li.nota p { font-size: 15px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--green); margin-top: 5px; }
.timeline small { color: var(--faint); }
.banner { margin: 0 0 12px; padding: 8px 10px; border-radius: 8px; font-weight: 700; }
.banner.ganho { background: var(--green-wash); color: var(--green-ink); }
.banner.perdido { background: var(--red-wash); color: var(--red); }

dialog {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  width: min(440px, calc(100vw - 32px));
  box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(20, 32, 28, 0.45); }
dialog h2 { margin: 0 0 6px; font-size: 20px; }
dialog p { margin: 0 0 12px; color: var(--dim); }
.row { display: flex; gap: 8px; margin-top: 12px; }
.choice { display: flex; gap: 8px; align-items: center; font-weight: 600; margin: 6px 0; }
.choice input { width: auto; }

@media (max-width: 900px) {
  html, body, .shell { height: auto; min-height: 100%; }
  .shell { display: block; }
  .rail { position: sticky; top: 0; z-index: 2; flex-direction: row; align-items: center; gap: 8px; overflow: auto; padding: 8px; }
  .rail h2, .person small, .me small, .brand span { display: none; }
  .people { display: flex; }
  .brand { padding: 0 8px 0 0; }
  .me { margin-top: 0; border-top: 0; padding: 0 0 0 8px; }
  .work { display: block; }
  .deal { display: block; }
  .deal-body { display: block; }
  .facts, .history { overflow: visible; }
  .facts { border-right: 0; border-bottom: 1px solid var(--line); }
  .board { display: block; height: auto; }
  .col { margin-bottom: 8px; }
  .top { flex-wrap: wrap; }
  .search { width: min(100%, 280px); }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
