:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --border: #e2e6ef;
  --text: #1c2333;
  --muted: #667085;
  --accent: #3357e5;
  --accent-dark: #223aa8;
  --ok: #1a9e5c;
  --ok-bg: #e7f8ef;
  --warn: #b45309;
  --warn-bg: #fef3e0;
  --danger: #c0392b;
  --danger-bg: #fdecea;
  --topbar: #10162b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  background: var(--topbar);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 2rem;
  padding: 0.85rem 1.5rem;
  flex-wrap: wrap;
}
.topbar .brand { color: #fff; font-weight: 700; font-size: 1.05rem; text-decoration: none; }
.topbar .brand span { color: #8fa1ff; font-weight: 400; font-size: 0.85rem; }
.topbar nav { display: flex; gap: 1.25rem; flex: 1; flex-wrap: wrap; }
.topbar nav a { color: #cfd6ee; font-size: 0.92rem; }
.topbar nav a:hover { color: #fff; text-decoration: none; }
.user-menu { display: flex; align-items: center; gap: 1rem; font-size: 0.9rem; color: #cfd6ee; }
.user-menu a { color: #ff9d9d; }

.container { max-width: 1100px; margin: 0 auto; padding: 1.75rem 1.5rem 4rem; }

h1 { font-size: 1.5rem; margin: 0 0 1.25rem; }
h2 { font-size: 1.15rem; margin: 0 0 1rem; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

.stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.1rem 1.25rem;
}
.stat .label { color: var(--muted); font-size: 0.82rem; margin-bottom: 0.3rem; }
.stat .value { font-size: 1.5rem; font-weight: 700; }

form label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 0.3rem; margin-top: 0.9rem; }
form label:first-child { margin-top: 0; }
input[type=text], input[type=date], input[type=number], input[type=password],
input[type=email], input[type=tel], select, textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}
textarea { resize: vertical; min-height: 4.5rem; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  margin-top: 1.25rem;
}
.btn:hover { background: var(--accent-dark); text-decoration: none; }
.btn-secondary { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #f0f2f8; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.85rem; margin-top: 0; }
.btn-row { display: flex; gap: 0.75rem; align-items: center; }

table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 0.6rem 0.7rem; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.02em; }
tr:hover td { background: #fafbfe; }

.badge { display: inline-block; padding: 0.15rem 0.55rem; border-radius: 999px; font-size: 0.78rem; font-weight: 600; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }

.flash { padding: 0.75rem 1rem; border-radius: 8px; margin-bottom: 1.25rem; font-size: 0.92rem; }
.flash-ok { background: var(--ok-bg); color: var(--ok); }
.flash-erro { background: var(--danger-bg); color: var(--danger); }

.filter-bar { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: flex-end; margin-bottom: 1.25rem; }
.filter-bar > div { min-width: 140px; }
.filter-bar label { margin-top: 0; }

.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.auth-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 2.25rem;
  width: 100%;
  max-width: 380px;
}
.auth-card h1 { font-size: 1.3rem; text-align: center; margin-bottom: 0.3rem; }
.auth-card .sub { text-align: center; color: var(--muted); font-size: 0.88rem; margin-bottom: 1.25rem; }
.auth-card .btn { width: 100%; text-align: center; }
.auth-links { text-align: center; margin-top: 1.25rem; font-size: 0.88rem; }

.receipt-preview {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  font-size: 0.98rem;
  line-height: 1.7;
}
.receipt-preview .rec-header { display: flex; justify-content: space-between; margin-bottom: 1.25rem; }
.receipt-preview .rec-number { color: var(--muted); font-size: 0.85rem; }
.receipt-preview .rec-amount { font-size: 1.4rem; font-weight: 700; color: var(--accent); margin: 1rem 0; }

.helptext { color: var(--muted); font-size: 0.8rem; margin-top: 0.3rem; }

@media (max-width: 720px) {
  .topbar { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
  .container { padding: 1.25rem 1rem 3rem; }
}

/* ---- Impressão A4 ---- */
@media print {
  body { background: #fff; }
  .topbar, .no-print { display: none !important; }
  .container { max-width: none; padding: 0; margin: 0; }
  .receipt-preview { border: none; padding: 0; }
}

.print-page {
  width: 210mm;
  min-height: 297mm;
  margin: 0 auto;
  background: #fff;
  padding: 20mm 18mm;
  box-sizing: border-box;
  font-family: Georgia, 'Times New Roman', serif;
  color: #111;
}
.print-page .recibo-box { border: 2px solid #1a1a1a; border-radius: 6px; overflow: hidden; }
.print-page .recibo-header { display: flex; align-items: stretch; border-bottom: 2px solid #1a1a1a; }
.print-page .recibo-header .recibo-title {
  flex: 1; display: flex; align-items: center; padding: 0.9rem 1.25rem;
  font-size: 1.6rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
}
.print-page .recibo-meta { display: flex; }
.print-page .recibo-meta > div {
  border-left: 1.5px solid #1a1a1a; padding: 0.55rem 1.1rem;
  display: flex; flex-direction: column; justify-content: center; min-width: 130px;
}
.print-page .recibo-meta .meta-label { font-size: 0.65rem; text-transform: uppercase; color: #555; letter-spacing: 0.05em; }
.print-page .recibo-meta .meta-value { font-size: 1.05rem; font-weight: 700; white-space: nowrap; }
.print-page .recibo-body { padding: 1.75rem 1.85rem 2.25rem; }
.print-page .doc-body { font-size: 1.02rem; line-height: 1.9; text-align: justify; }
.print-page .doc-signature { margin-top: 3.5rem; text-align: center; }
.print-page .doc-signature .line { border-top: 1px solid #111; width: 70%; margin: 0 auto 0.4rem; }
.print-page .doc-footer { margin-top: 2rem; font-size: 0.78rem; color: #777; text-align: center; }
.print-toolbar { max-width: 210mm; margin: 0 auto 1rem; padding: 0 18mm; }

@media screen {
  .print-page { margin: 1.5rem auto; box-shadow: 0 4px 24px rgba(0,0,0,0.12); }
}
@page { size: A4; margin: 0; }
