* { box-sizing: border-box; }
body {
  margin: 0; padding: 0 0 60px;
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: #f2f4f7; color: #1b2430;
}
header {
  background: #12325b; color: #fff; padding: 16px 20px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
header h1 { font-size: 20px; margin: 0; }
header a { color: #cfe0ff; text-decoration: none; font-size: 14px; }
.wrap { max-width: 1800px; margin: 20px auto; padding: 0 24px; }
.card {
  background: #fff; border-radius: 10px; padding: 18px;
  box-shadow: 0 1px 3px rgba(0,0,0,.12); margin-bottom: 18px;
}
h2 { font-size: 16px; margin: 0 0 14px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 8px; text-align: left; border-bottom: 1px solid #e6e9ef; font-size: 14px; }
th { background: #1a73c9; color: #fff; font-size: 13px; text-transform: uppercase; letter-spacing: .3px; }
tbody tr:hover { background: #f7faff; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.deve { color: #b3261e; font-weight: 600; }
.haver { color: #1a7f37; font-weight: 600; }
.zero { color: #6b7280; }
tfoot td { font-weight: 700; background: #eaf6ea; border-top: 2px solid #cfe3cf; }
a.nome { color: #12325b; font-weight: 600; text-decoration: none; }
a.nome:hover { text-decoration: underline; }
form.linha { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
label { display: block; font-size: 12px; color: #566; margin-bottom: 4px; }
input, select, textarea {
  padding: 9px 10px; border: 1px solid #ccd3dd; border-radius: 6px;
  font-size: 14px; font-family: inherit; background: #fff;
}
button {
  padding: 10px 18px; border: 0; border-radius: 6px; background: #1a73c9;
  color: #fff; font-size: 14px; font-weight: 600; cursor: pointer;
}
button:hover { background: #145ba0; }
button.mini { padding: 5px 10px; font-size: 12px; background: #b3261e; }
button.mini:hover { background: #8c1c16; }
.resumo { display: flex; gap: 14px; flex-wrap: wrap; }
.resumo div { flex: 1; min-width: 150px; background: #fff; border-radius: 10px; padding: 14px 16px; box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.resumo span { display: block; font-size: 12px; color: #667; margin-bottom: 4px; }
.resumo strong { font-size: 20px; }
.aviso { background: #fff6d6; border: 1px solid #f0d98a; padding: 10px 14px; border-radius: 6px; font-size: 13px; margin-bottom: 14px; }
.saldo-grande { font-size: 30px; }

/* ---- Quadro de clientes (cards) ---- */
.quadro-topo { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.filtros { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.chip {
  padding: 6px 12px; font-size: 12px; font-weight: 600; border-radius: 999px;
  background: #e8edf5; color: #445061; border: 0; cursor: pointer;
}
.chip:hover { background: #d8e1ee; }
.chip.ativo { background: #12325b; color: #fff; }

.quadro {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
}
.cli-card {
  position: relative; background: #fff; border: 1px solid #e2e7ef;
  border-left: 5px solid #9aa5b4; border-radius: 10px;
  transition: box-shadow .15s, transform .15s;
}
.cli-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.13); transform: translateY(-2px); }
.cli-card.deve  { border-left-color: #b3261e; }
.cli-card.haver { border-left-color: #1a7f37; }
.cli-card.zero  { border-left-color: #9aa5b4; }
.cli-link { display: block; padding: 14px 14px 12px; text-decoration: none; color: inherit; }
.cli-nome { font-weight: 700; font-size: 15px; color: #12325b; padding-right: 22px; }
.cli-tel { font-size: 12px; color: #78839a; min-height: 16px; margin-top: 2px; }
.cli-saldo { font-size: 20px; font-weight: 700; margin: 8px 0 10px; font-variant-numeric: tabular-nums; }
.cli-rodape { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.tag { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; }
.tag.deve  { background: #fdecea; color: #b3261e; }
.tag.haver { background: #e6f4ea; color: #1a7f37; }
.tag.zero  { background: #eef1f5; color: #6b7280; }
.cli-qtd { font-size: 11px; color: #8a94a3; }
.cli-editar {
  position: absolute; top: 8px; right: 8px; padding: 2px 7px; font-size: 13px;
  background: transparent; color: #9aa5b4; border-radius: 6px;
}
.cli-editar:hover { background: #eef1f5; color: #12325b; }
.cli-form { display: none; padding: 0 14px 14px; border-top: 1px solid #eef1f5; }
.cli-form label { margin-top: 8px; }

/* ---- Responsivo ---- */
@media (max-width: 900px) {
  .wrap { margin: 14px auto; padding: 0 12px; }
  .card { padding: 14px; margin-bottom: 14px; }
  .resumo { gap: 10px; }
  .resumo div { min-width: 140px; padding: 12px; }
  .resumo strong { font-size: 18px; }
  .quadro { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
}

@media (max-width: 640px) {
  header { padding: 12px 14px; gap: 10px; }
  header h1 { font-size: 17px; }

  /* formularios empilhados e de largura cheia */
  form.linha { flex-direction: column; align-items: stretch; gap: 12px; }
  form.linha > div { width: 100%; min-width: 0 !important; }
  form.linha input, form.linha select, form.linha textarea { width: 100% !important; min-width: 0 !important; }
  form.linha button { width: 100%; padding: 12px; font-size: 15px; }

  /* resumo em 2 colunas */
  .resumo { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .resumo div { min-width: 0; }

  /* busca e filtros */
  .quadro-topo { gap: 10px; }
  .quadro-topo #busca { width: 100%; min-width: 0; }
  .filtros { margin-left: 0; width: 100%; overflow-x: auto; padding-bottom: 2px; }
  .filtros .chip { flex: 0 0 auto; }

  /* cards em 2 colunas */
  .quadro { grid-template-columns: 1fr 1fr; gap: 10px; }
  .cli-nome { font-size: 14px; }
  .cli-saldo { font-size: 17px; }
  .cli-editar { padding: 6px 10px; font-size: 15px; }

  /* tabela do extrato vira lista de cartoes */
  table.resp thead { display: none; }
  table.resp, table.resp tbody, table.resp tr, table.resp td, table.resp tfoot { display: block; width: 100%; }
  table.resp tr {
    background: #fff; border: 1px solid #e6e9ef; border-radius: 8px;
    margin-bottom: 10px; padding: 6px 10px;
  }
  table.resp td { border: 0; padding: 6px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  table.resp td::before {
    content: attr(data-l); font-size: 12px; color: #78839a;
    text-transform: uppercase; letter-spacing: .3px; text-align: left; flex: 0 0 auto;
  }
  table.resp td:empty { display: none; }
  table.resp td.acoes { justify-content: flex-end; }
  table.resp td.acoes form { margin: 0; }
  table.resp td.rot-saldo { display: none; }
  table.resp tfoot tr { background: #eaf6ea; font-weight: 700; }
}

@media (max-width: 340px) {
  .quadro { grid-template-columns: 1fr; }
}
