:root {
  --paper: #f3efe6;
  --paper-2: #fffdf8;
  --ink: #1c1915;
  --muted: #6f685e;
  --line: #e4d9c8;
  --pine: #143f38;
  --pine-2: #0f2f2a;
  --verde: #1b6b45;
  --verde-bg: #e3f5ea;
  --amarelo: #8a5a00;
  --amarelo-bg: #fbf1d2;
  --vermelho: #9d2c2c;
  --vermelho-bg: #f8e4e1;
  --cinza: #5c574f;
  --cinza-bg: #eceae4;
  --shadow: 0 10px 30px rgba(28, 25, 21, 0.05);
  font-family: "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--pine); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { font-family: Georgia, "Iowan Old Style", Palatino, serif; font-weight: 500; letter-spacing: -0.02em; }
h1 { font-size: clamp(2rem, 4vw, 3.2rem); margin: 0.15em 0; line-height: 1.05; }
h2 { font-size: 1.35rem; margin: 0 0 0.6rem; }
h3 { font-size: 1rem; margin: 1rem 0 0.4rem; }

.shell { min-height: 100vh; display: grid; grid-template-columns: 220px 1fr; }
.side {
  background: var(--pine);
  color: #f3efe6;
  padding: 1.2rem 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; gap: 0.7rem; align-items: center; color: inherit; text-decoration: none; }
.brand strong { display: block; font-family: Georgia, serif; font-size: 1.15rem; }
.brand small { color: #d5e4df; }
.mark {
  width: 2.1rem; height: 2.1rem; border-radius: 8px;
  display: grid; place-items: center;
  background: #f3efe6; color: var(--pine); font-family: Georgia, serif; font-size: 1.2rem;
}
.nav { display: flex; flex-direction: column; gap: 0.15rem; }
.nav a {
  color: #e7f2ee; text-decoration: none; padding: 0.45rem 0.65rem; border-radius: 8px;
}
.nav a.on, .nav a:hover { background: rgba(255, 255, 255, 0.1); }
.logout { margin-top: auto; display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; color: #d5e4df; font-size: 0.9rem; }
.logout button, .ghost {
  background: transparent; color: inherit; border: 1px solid rgba(243, 239, 230, 0.35);
  border-radius: 999px; padding: 0.25rem 0.7rem; cursor: pointer;
}
.ghost { color: var(--pine); border-color: var(--line); }
.main { padding: 1.5rem clamp(1rem, 3vw, 2.4rem) 3rem; }
.page-head, .meta-row, .links, .filters, .chips, .legend, .stats { display: flex; flex-wrap: wrap; gap: 0.75rem 1rem; align-items: center; }
.page-head { justify-content: space-between; align-items: flex-end; margin-bottom: 1rem; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.14em; font-size: 0.72rem; color: var(--muted); margin: 0; }
.lead { max-width: 46rem; color: var(--muted); line-height: 1.5; }
.muted, small { color: var(--muted); }
.card {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
}
.banner, .flash, .note {
  border-radius: 12px; padding: 0.75rem 1rem; margin: 0 0 1rem;
}
.banner, .flash.erro { background: var(--vermelho-bg); color: var(--vermelho); }
.flash.ok { background: var(--verde-bg); color: var(--verde); }
.note { background: #f7f1e4; border: 1px solid var(--line); display: flex; gap: 1rem; align-items: flex-start; justify-content: space-between; }
.note p { margin: 0; }
.token { font-family: ui-monospace, monospace; word-break: break-all; }

.button, button[type="submit"] {
  background: var(--pine); color: #f3efe6; border: 0; border-radius: 999px;
  padding: 0.65rem 1rem; text-decoration: none; cursor: pointer; display: inline-block;
}
.button:hover, button[type="submit"]:hover { background: var(--pine-2); }
.textlink { align-self: center; }
.form { display: grid; gap: 0.8rem; }
.grid-form { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); align-items: end; }
.span-2 { grid-column: span 2; }
label { display: grid; gap: 0.3rem; font-size: 0.92rem; }
input, select, textarea {
  width: 100%; background: white; border: 1px solid var(--line); border-radius: 10px; padding: 0.55rem 0.7rem;
}
textarea { resize: vertical; }
.check { display: flex; align-items: center; gap: 0.5rem; }
.check input { width: auto; }
.filters input[type="number"] { width: 6rem; }
.chips { margin: 0.8rem 0; }
.chip {
  text-decoration: none; border: 1px solid var(--line); background: white; color: var(--ink);
  border-radius: 999px; padding: 0.3rem 0.7rem; font-size: 0.9rem;
}
.chip.on { background: var(--pine); color: #f3efe6; border-color: var(--pine); }
.legend { color: var(--muted); font-size: 0.88rem; margin-bottom: 0.8rem; }
.swatch { width: 0.75rem; height: 0.75rem; border-radius: 99px; display: inline-block; margin-right: 0.25rem; }
.swatch.verde, .cell.verde { background: var(--verde-bg); }
.swatch.amarelo, .cell.amarelo { background: var(--amarelo-bg); }
.swatch.vermelho, .cell.vermelho { background: var(--vermelho-bg); }
.swatch.cinza, .cell.cinza { background: var(--cinza-bg); }

.grid-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 16px; background: var(--paper-2); }
.grade { border-collapse: separate; border-spacing: 0; min-width: 860px; width: 100%; }
.grade th, .grade td { padding: 0.35rem; text-align: center; border-bottom: 1px solid var(--line); }
.grade thead th { font-size: 0.75rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.grade tbody th {
  text-align: left; position: sticky; left: 0; background: var(--paper-2); z-index: 1;
  min-width: 10.5rem; padding-left: 0.8rem;
}
.grade tbody th a { text-decoration: none; color: var(--ink); font-weight: 650; }
.grade tbody th small, .grade tbody th a { display: block; }
.cell {
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  min-height: 3.4rem; border-radius: 10px; text-decoration: none; color: var(--ink); position: relative; padding: 0.25rem;
}
.cell strong { font-variant-numeric: tabular-nums; font-size: 1.05rem; }
.cell small, .cell em { font-style: normal; font-size: 0.68rem; letter-spacing: 0.03em; }
.cell.alerta { outline: 2px solid var(--vermelho); }
.cell.verde strong { color: var(--verde); }
.cell.amarelo strong { color: var(--amarelo); }
.cell.vermelho strong { color: var(--vermelho); }
.cell.mini { min-width: 4.5rem; min-height: 3.2rem; }
.empty { text-align: left; padding: 1.2rem; }
.month-strip { display: flex; gap: 0.5rem; overflow-x: auto; padding-bottom: 0.4rem; }
.month-strip .cell { min-width: 5.5rem; }

.stats { margin: 0.5rem 0 1rem; }
.stats article, .costs article {
  background: var(--paper-2); border: 1px solid var(--line); border-radius: 14px; padding: 0.8rem 1rem; min-width: 10rem;
}
.stats strong { display: block; font-family: Georgia, serif; font-size: 1.8rem; }
.split { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 1rem; margin-top: 1rem; }
.stack { display: grid; gap: 1rem; }
.cards { display: grid; gap: 0.7rem; }
.client-card, .account {
  display: flex; justify-content: space-between; gap: 1rem; align-items: center;
  text-decoration: none; color: inherit;
}
.client-card { background: var(--paper-2); border: 1px solid var(--line); border-radius: 14px; padding: 0.8rem 1rem; }
.client-card small, .client-card strong { display: block; }
.list { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.8rem; }
.list li { display: grid; gap: 0.15rem; }
.list p { margin: 0.2rem 0 0; white-space: pre-wrap; }
.pill {
  display: inline-flex; align-items: center; border-radius: 999px; padding: 0.1rem 0.55rem;
  background: var(--cinza-bg); font-size: 0.78rem; width: max-content;
}
.pill.ok, .pill.verde, .pill.em_dia { background: var(--verde-bg); color: var(--verde); }
.pill.amarelo, .pill.carencia, .pill.atrasado { background: var(--amarelo-bg); color: var(--amarelo); }
.pill.vermelho, .pill.bloqueado, .pill.falha, .pill.vencido { background: var(--vermelho-bg); color: var(--vermelho); }
.docs { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.9rem; }
.docs li { display: grid; gap: 0.35rem; padding-bottom: 0.8rem; border-bottom: 1px solid var(--line); }
.docs.compact li { grid-template-columns: 1fr auto; align-items: center; }
.docs small { grid-column: 1 / -1; }
.inline, .two { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: end; }
.inline label, .two label { flex: 1; min-width: 8rem; }
.indicator { border: 1px solid var(--line); border-radius: 12px; margin: 0.8rem 0 0; padding: 0.7rem; }
.indicator legend { padding: 0 0.3rem; font-weight: 650; }
.fonte { margin: 0.15rem 0 0.45rem; }
.fonte span { color: var(--muted); margin-right: 0.35rem; }
.seg { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0.4rem; margin: 0.5rem 0; }
.opt { border-radius: 10px; padding: 0.45rem; }
.opt input { width: auto; margin-right: 0.25rem; }
.opt.verde { background: var(--verde-bg); }
.opt.amarelo { background: var(--amarelo-bg); }
.opt.vermelho { background: var(--vermelho-bg); }
.opt.cinza { background: var(--cinza-bg); }
.costs { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0.7rem; margin-bottom: 1rem; }
.meter { height: 8px; background: var(--cinza-bg); border-radius: 99px; overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--pine); }
.warn { color: var(--vermelho); font-weight: 650; }
.login { max-width: 36rem; padding: 8vh 0; }
.narrow { max-width: 42rem; }
code { font-family: ui-monospace, monospace; font-size: 0.92em; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side {
    position: fixed; top: auto; bottom: 0; height: auto; width: 100%; z-index: 5;
    flex-direction: row; align-items: center; padding: 0.4rem;
    overflow-x: auto;
  }
  .brand, .logout span { display: none; }
  .nav { flex-direction: row; }
  .nav a { white-space: nowrap; font-size: 0.85rem; }
  .logout { margin-top: 0; }
  .main { padding-bottom: 5.5rem; }
  .split, .span-2 { grid-template-columns: 1fr; display: grid; }
  .span-2 { grid-column: auto; }
  .page-head { align-items: flex-start; }
}
