:root {
  --bg: #0d1013;
  --panel: #14181d;
  --panel-2: #1a1f26;
  --line: #262c35;
  --text: #e8eaed;
  --muted: #8b949e;
  --dim: #636c76;
  --accent: #d9a441;
  --green: #4a9d6a;
  --amber: #d9a441;
  --red: #c9585d;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, "Segoe UI", Inter, Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.55;
}

body { display: flex; min-height: 100vh; }

a { color: inherit; text-decoration: none; }

/* ── login ───────────────────────────────────────────────────── */

body.centrado {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.login {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 34px 30px;
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login .marca {
  font-weight: 700;
  font-size: 21px;
  letter-spacing: 0.16em;
  color: var(--accent);
  text-align: center;
  margin-bottom: 6px;
}

.login input {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  padding: 11px 13px;
  font: inherit;
  font-size: 15px;
  width: 100%;
}
.login input:focus { outline: none; border-color: var(--accent); }
.login button { margin-left: 0; width: 100%; padding: 11px; }
.login button:disabled { opacity: 0.45; cursor: not-allowed; }

.aviso {
  color: var(--red);
  font-size: 13.5px;
  margin: 0;
  text-align: center;
  line-height: 1.5;
}

/* ── navegação lateral ───────────────────────────────────────── */

.rail {
  width: 216px;
  flex: 0 0 216px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
  gap: 26px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  font-weight: 700;
  font-size: 19px;
  letter-spacing: 0.14em;
  color: var(--accent);
  padding-left: 10px;
}

.rail nav { display: flex; flex-direction: column; gap: 2px; }

.rail nav a {
  padding: 9px 10px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.rail nav a:hover { background: var(--panel-2); color: var(--text); }
.rail nav a.on { background: var(--panel-2); color: var(--text); box-shadow: inset 2px 0 0 var(--accent); }

.rail-foot {
  margin-top: auto;
  font-size: 11px;
  color: var(--dim);
  padding-left: 10px;
  letter-spacing: 0.05em;
  display: flex;
  gap: 10px;
  align-items: center;
}

.rail-foot .sair { margin-left: auto; }
.rail-foot .sair:hover { color: var(--text); }

.pill {
  background: var(--accent);
  color: #1a1204;
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 700;
}
.pill.red { background: var(--red); color: #fff; }

/* ── tarefas ─────────────────────────────────────────────────── */

.check {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  border-radius: 5px;
  border: 1.5px solid var(--dim);
  background: transparent;
  padding: 0;
  margin: 0;
  cursor: pointer;
  position: relative;
}
.check:hover { border-color: var(--accent); }
.check.done { background: var(--green); border-color: var(--green); }
.check.done::after {
  content: "";
  position: absolute;
  left: 5px; top: 1px;
  width: 4px; height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(42deg);
}

.strike { text-decoration: line-through; color: var(--dim); }
.row.is-overdue { box-shadow: inset 2px 0 0 var(--red); }
.when.late { color: var(--red); font-weight: 600; }
.when.soon { color: var(--amber); }

.muted-link { color: var(--dim); font-size: 12.5px; }
a.muted-link:hover { color: var(--accent); }

/* ── conversa ────────────────────────────────────────────────── */

.thread { display: flex; flex-direction: column; gap: 16px; margin-top: 24px; }

.msg { display: flex; flex-direction: column; gap: 5px; max-width: 82%; }
.msg .who { font-size: 11px; color: var(--dim); text-transform: uppercase;
            letter-spacing: 0.08em; }
.msg .body {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px 16px;
  font-size: 14.5px;
  line-height: 1.6;
  white-space: pre-wrap;
}
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.user .body { background: var(--panel-2); border-color: #303845; }
.msg.assistant .body { border-left: 3px solid var(--accent); }

/* ── números ─────────────────────────────────────────────────── */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }

.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px 17px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat .n { font-size: 25px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.1; }
.stat .l { font-size: 12.5px; color: var(--muted); }
.stat.warn { border-color: #4a3a1a; }
.stat.warn .n { color: var(--amber); }
.stat.bad { border-color: #4a2225; }
.stat.bad .n { color: var(--red); }
.stat.dim .n { color: var(--dim); font-size: 20px; }

.bar {
  flex: 0 0 130px;
  height: 6px;
  background: var(--panel-2);
  border-radius: 3px;
  overflow: hidden;
}
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }

/* leitura executiva — o julgamento do SEBAS, não a lista */
.reading {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 17px 20px;
  font-size: 15px;
  line-height: 1.6;
  margin-bottom: 8px;
  white-space: pre-wrap;
}

/* ── layout principal ────────────────────────────────────────── */

main {
  flex: 1;
  padding: 34px 40px 60px;
  max-width: 1100px;
  min-width: 0;
}

h1 { font-size: 26px; margin: 0 0 4px; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 15px; margin: 34px 0 12px; font-weight: 600; color: var(--muted);
     text-transform: uppercase; letter-spacing: 0.09em; }
.sub { color: var(--muted); margin: 0 0 26px; font-size: 14px; }

/* ── cards de cliente ────────────────────────────────────────── */

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

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: block;
  transition: border-color .14s, transform .14s;
}

.card:hover { border-color: #38414d; transform: translateY(-1px); }

.card-top { display: flex; align-items: center; gap: 9px; margin-bottom: 3px; }
.card h3 { margin: 0; font-size: 15.5px; font-weight: 600; }
.card .stage { font-size: 12px; color: var(--dim); margin-bottom: 11px; }

.dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 8px; }
.dot.verde { background: var(--green); }
.dot.atencao { background: var(--amber); }
.dot.risco { background: var(--red); }
.dot.indefinido { background: var(--dim); }

.next {
  font-size: 13.5px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  padding-top: 11px;
  margin-top: 11px;
}
.next b { color: var(--text); font-weight: 500; }

.tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 11px; }
.tag {
  font-size: 11.5px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 2px 8px;
  border-radius: 5px;
}
.tag.warn { color: var(--amber); border-color: #4a3a1a; }
.tag.bad { color: var(--red); border-color: #4a2225; }

/* ── captura ─────────────────────────────────────────────────── */

.capture {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.capture textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  padding: 11px 13px;
  font: inherit;
  font-size: 14px;
  resize: vertical;
  min-height: 84px;
}

.capture textarea:focus { outline: none; border-color: var(--accent); }

.capture-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 11px;
  flex-wrap: wrap;
}

input[type=file] { font-size: 13px; color: var(--muted); max-width: 100%; }
input[type=file]::file-selector-button {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 6px;
  padding: 6px 12px;
  margin-right: 10px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
}

button {
  background: var(--accent);
  color: #1a1204;
  border: none;
  border-radius: 7px;
  padding: 9px 20px;
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  margin-left: auto;
}
button:hover { filter: brightness(1.08); }

button.ghost {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--muted);
  font-weight: 500;
  padding: 7px 14px;
  font-size: 13px;
}
button.ghost:hover { color: var(--text); border-color: #38414d; filter: none; }
button.ghost.on { background: var(--accent); color: #1a1204; border-color: var(--accent); }

select {
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 7px;
  padding: 8px 11px;
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
}
select:focus { outline: none; border-color: var(--accent); }

/* ── listas ──────────────────────────────────────────────────── */

.list { display: flex; flex-direction: column; gap: 1px; background: var(--line);
        border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }

.row {
  background: var(--panel);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 13px;
  font-size: 14px;
}
.row:hover { background: var(--panel-2); }
.row .grow { flex: 1; min-width: 0; }
.row .truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .when { color: var(--dim); font-size: 12px; white-space: nowrap; }

.state {
  font-size: 11.5px;
  padding: 2px 9px;
  border-radius: 5px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}
.state.recebido { color: var(--accent); border-color: #4a3a1a; }
.state.processado { color: var(--green); border-color: #1f3d2b; }
.state.erro { color: var(--red); border-color: #4a2225; }

.kind { color: var(--dim); font-size: 12px; width: 54px; flex: 0 0 54px; }

/* ── abas e conteúdo do cliente ──────────────────────────────── */

.tabs { display: flex; gap: 3px; flex-wrap: wrap; border-bottom: 1px solid var(--line);
        margin: 22px 0 0; padding-bottom: 0; }

.tabs a {
  padding: 8px 13px;
  font-size: 13.5px;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tabs a:hover { color: var(--text); }
.tabs a.on { color: var(--accent); border-bottom-color: var(--accent); }

.doc { padding-top: 8px; font-size: 14.5px; }
.doc h1 { font-size: 21px; margin: 26px 0 10px; }
.doc h2 { font-size: 14px; margin: 26px 0 10px; color: var(--muted);
          text-transform: uppercase; letter-spacing: 0.08em; }
.doc h3 { font-size: 15px; margin: 20px 0 8px; color: var(--text); text-transform: none;
          letter-spacing: 0; }
.doc p { margin: 10px 0; }
.doc ul, .doc ol { margin: 10px 0; padding-left: 22px; }
.doc li { margin: 4px 0; }
.doc code { background: var(--panel-2); padding: 1px 5px; border-radius: 4px; font-size: 13px; }
.doc hr { border: none; border-top: 1px solid var(--line); margin: 26px 0; }
.doc em { color: var(--muted); font-style: normal; font-size: 13px; }
.doc a { color: var(--accent); }

.doc blockquote {
  border-left: 2px solid var(--line);
  margin: 14px 0;
  padding: 2px 0 2px 15px;
  color: var(--muted);
  font-size: 13.5px;
}

.doc table { border-collapse: collapse; width: 100%; margin: 14px 0; font-size: 13.5px;
             display: block; overflow-x: auto; }
.doc th, .doc td { border: 1px solid var(--line); padding: 8px 11px; text-align: left;
                   vertical-align: top; }
.doc th { background: var(--panel); color: var(--muted); font-weight: 600; white-space: nowrap; }

.empty { color: var(--dim); font-size: 14px; padding: 22px 0; }

.back { color: var(--muted); font-size: 13px; }
.back:hover { color: var(--text); }

@media (max-width: 760px) {
  body { flex-direction: column; }
  .rail { width: 100%; flex: none; height: auto; position: static;
          flex-direction: row; align-items: center; gap: 14px; padding: 12px 14px; }
  .rail nav { flex-direction: row; flex: 1; }
  .rail-foot { display: none; }
  main { padding: 22px 18px 50px; }
}
