/* ============================================================
   Escon Boletos — sistema visual
   Tinta verde-escura + papel frio + laranja Inter como acento.
   Marca e títulos em serifa; dados sempre em números tabulares.
   ============================================================ */
:root {
  --ink: #101915;
  --ink-2: #1a2620;
  --ink-3: #24332c;
  --paper: #eef1ee;
  --card: #ffffff;
  --text: #17211c;
  --muted: #5d6a63;
  --line: #dde3de;
  --laranja: #e05e00;
  --laranja-2: #c25200;
  --laranja-soft: #fdeadd;
  --verde: #127346;
  --verde-soft: #e2f2e9;
  --vermelho: #b3341f;
  --vermelho-soft: #fbe7e2;
  --ambar: #96690a;
  --ambar-soft: #faf0d8;
  --azul: #2b5d8a;
  --azul-soft: #e4eef6;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 25, 21, 0.06), 0 8px 24px rgba(16, 25, 21, 0.05);
  --serif: Georgia, 'Times New Roman', serif;
  --sans: 'Segoe UI', system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  background: var(--paper);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--vermelho); font-size: 0.9em; }
.num { font-variant-numeric: tabular-nums; }
a { color: var(--laranja-2); }

:focus-visible { outline: 2px solid var(--laranja); outline-offset: 2px; }

/* ============ Login ============ */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(224, 94, 0, 0.14), transparent 60%),
    var(--ink);
  padding: 24px;
}
.login-card {
  display: flex;
  width: 780px;
  max-width: 100%;
  min-height: 460px;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}
.login-brand {
  flex: 1 1 46%;
  background: linear-gradient(160deg, var(--ink-2), var(--ink));
  color: #e8ede9;
  padding: 44px 40px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.login-brand .logo {
  font-family: var(--serif);
  font-size: 2.1em;
  color: #fff;
  letter-spacing: 0.01em;
}
.login-brand .logo em { color: var(--laranja); font-style: italic; }
.login-brand .tagline { color: #9fb0a6; max-width: 26ch; }
.login-brand ul {
  list-style: none;
  padding: 0;
  margin: 28px 0 0;
  display: grid;
  gap: 10px;
  color: #c3cec7;
  font-size: 0.92em;
}
.login-brand li::before { content: '—'; color: var(--laranja); margin-right: 10px; }
.login-form {
  flex: 1 1 54%;
  background: var(--card);
  padding: 44px 40px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.login-form h1 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.5em;
  margin: 0 0 4px;
}
.login-form > p { margin: 0 0 22px; }

/* ============ Estrutura ============ */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px;
  flex: 0 0 232px;
  background: var(--ink);
  color: #d7dfda;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  padding: 26px 22px 20px;
  font-family: var(--serif);
  font-size: 1.5em;
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.brand em { color: var(--laranja); font-style: italic; }
.brand small {
  display: block;
  font-family: var(--sans);
  font-size: 0.5em;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: #7f9188;
  margin-top: 4px;
}
.sidebar nav { flex: 1; display: flex; flex-direction: column; padding: 12px 10px; gap: 2px; }
.sidebar nav a {
  color: #b9c6bf;
  text-decoration: none;
  padding: 10px 13px;
  border-radius: 8px;
  font-size: 0.94em;
  display: flex;
  align-items: center;
  gap: 10px;
  border-left: 2px solid transparent;
}
.sidebar nav a:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.sidebar nav a.active {
  background: rgba(224, 94, 0, 0.16);
  color: #fff;
  border-left-color: var(--laranja);
}
.sidebar-footer {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.sidebar-footer .muted { color: #8b9c93; font-size: 0.85em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-footer .btn { background: transparent; color: #c3cec7; border-color: #3a4a41; }
.sidebar-footer .btn:hover { background: rgba(255, 255, 255, 0.08); }

.content { flex: 1; padding: 30px 36px 60px; max-width: 1280px; min-width: 0; }

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 24px;
}
.page-header h2 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.65em;
}
.page-header .sub { margin: 4px 0 0; color: var(--muted); font-size: 0.92em; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.eyebrow {
  font-size: 0.72em;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

/* ============ Cartões / KPIs ============ */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(185px, 1fr)); gap: 14px; margin-bottom: 18px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px 14px;
  box-shadow: var(--shadow);
  border-top: 3px solid var(--line);
}
.card .value {
  font-size: 1.55em;
  font-weight: 700;
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.card .hint { color: var(--muted); font-size: 0.83em; margin-top: 2px; }
.card.ok { border-top-color: var(--verde); }
.card.ok .value { color: var(--verde); }
.card.warn { border-top-color: var(--ambar); }
.card.warn .value { color: var(--ambar); }
.card.danger { border-top-color: var(--vermelho); }
.card.danger .value { color: var(--vermelho); }
.card.info { border-top-color: var(--azul); }
.card.accent { border-top-color: var(--laranja); }
.card.accent .value { color: var(--laranja-2); }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.panel h3 { margin: 0 0 4px; font-family: var(--serif); font-weight: 400; font-size: 1.15em; }
.panel .panel-sub { margin: 0 0 14px; color: var(--muted); font-size: 0.88em; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }

/* ============ Fluxo mensal (assinatura) ============ */
.fluxo { display: flex; gap: 6px; align-items: flex-end; height: 170px; padding-top: 8px; }
.fluxo .mes { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.fluxo .barras { display: flex; gap: 4px; align-items: flex-end; height: 120px; width: 100%; justify-content: center; }
.fluxo .barra { width: 34%; max-width: 26px; border-radius: 4px 4px 0 0; min-height: 2px; }
.fluxo .barra.previsto { background: #c8d2cb; }
.fluxo .barra.recebido { background: var(--verde); }
.fluxo .rotulo { font-size: 0.74em; color: var(--muted); text-transform: capitalize; white-space: nowrap; }
.fluxo .valor-mes { font-size: 0.72em; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.fluxo .mes.atual .rotulo { color: var(--laranja-2); font-weight: 700; }
.fluxo .mes.atual .barra.previsto { background: var(--laranja-soft); border: 1px solid var(--laranja); }
.fluxo-legenda { display: flex; gap: 18px; margin-top: 10px; font-size: 0.82em; color: var(--muted); }
.fluxo-legenda .dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* ============ Listas do dashboard ============ */
.linha-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 2px;
  border-bottom: 1px solid var(--line);
  font-size: 0.93em;
}
.linha-item:last-child { border-bottom: 0; }
.linha-item .quem { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.linha-item .quando { color: var(--muted); font-size: 0.86em; white-space: nowrap; }
.linha-item .quanto { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.linha-item .quanto.pos { color: var(--verde); }
.linha-item .quanto.neg { color: var(--vermelho); }
.vazio {
  color: var(--muted);
  padding: 26px 10px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 10px;
}

/* ============ Tabelas ============ */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: 0.92em; }
td { font-variant-numeric: tabular-nums; }
th {
  background: #f6f8f6;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
  font-size: 0.78em;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fafbfa; }

/* ============ Botões / formulários ============ */
.btn {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 0.92em;
  font-family: inherit;
}
.btn:hover { background: #f2f4f2; border-color: #c9d1ca; }
.btn.primary { background: var(--laranja); border-color: var(--laranja); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--laranja-2); border-color: var(--laranja-2); }
.btn.danger { color: var(--vermelho); border-color: #ecc9c1; }
.btn.danger:hover { background: var(--vermelho-soft); }
.btn.small { padding: 5px 10px; font-size: 0.85em; }
.btn.full { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: wait; }

label { display: block; margin-bottom: 13px; font-size: 0.88em; color: var(--muted); font-weight: 600; }
input, select, textarea {
  width: 100%;
  padding: 9px 12px;
  margin-top: 5px;
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 1rem;
  font-family: var(--sans);
  font-weight: 400;
  background: #fff;
  color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(224, 94, 0, 0.3);
  border-color: var(--laranja);
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }

/* ============ Badges ============ */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.76em;
  font-weight: 700;
  white-space: nowrap;
  letter-spacing: 0.02em;
}
.badge.PAGO, .badge.EMITIDA { background: var(--verde-soft); color: var(--verde); }
.badge.EMITIDO, .badge.PENDENTE, .badge.A_RECEBER { background: var(--azul-soft); color: var(--azul); }
.badge.ATRASADO, .badge.ERRO { background: var(--vermelho-soft); color: var(--vermelho); }
.badge.CANCELADO, .badge.CANCELADA, .badge.EXPIRADO { background: #eceeec; color: var(--muted); }
.badge.PENDENTE_EMISSAO { background: var(--ambar-soft); color: var(--ambar); }

/* ============ Modal / toast ============ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16, 25, 21, 0.55);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 6vh 16px;
  z-index: 50;
  overflow-y: auto;
}
.modal {
  background: var(--card);
  border-radius: 14px;
  padding: 28px;
  width: 640px;
  max-width: 100%;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}
.modal h3 { margin: 0 0 14px; font-family: var(--serif); font-weight: 400; font-size: 1.3em; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

#toast-root { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast {
  background: var(--ink);
  color: #eef2ef;
  padding: 12px 18px;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  max-width: 380px;
  font-size: 0.92em;
}
.toast.ok { border-left: 3px solid var(--verde); }
.toast.err { border-left: 3px solid var(--vermelho); }

@media (prefers-reduced-motion: no-preference) {
  .toast { animation: toast-in 0.22s ease-out; }
  @keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
  .fluxo .barra { transition: height 0.4s ease; }
}

/* ============ Responsivo ============ */
@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar nav a { border-left: 0; }
  .content { padding: 18px 16px 48px; }
  .form-grid, .grid-2 { grid-template-columns: 1fr; }
  .login-card { flex-direction: column; min-height: 0; }
  .login-brand { padding: 30px 28px; }
  .login-brand ul { display: none; }
  .fluxo .valor-mes { display: none; }
}
