:root {
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --bg: #f1f5f9;
  --card: #fff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --ok: #16a34a;
  --err: #dc2626;
  --warn: #d97706;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--text); background: var(--bg); }
h1 { font-size: 1.5rem; margin: .25rem 0; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
a { color: var(--brand); }
label { display: block; font-weight: 600; font-size: .9rem; margin: .75rem 0 .25rem; }
input, select { width: 100%; padding: .6rem .7rem; border: 1px solid var(--border); border-radius: 8px; font: inherit; background: #fff; }
input:focus, select:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: transparent; }
button, .button { display: inline-block; text-align: center; text-decoration: none; padding: .7rem 1.2rem; border: 0; border-radius: 8px;
  background: var(--brand); color: #fff; font: inherit; font-weight: 600; cursor: pointer; }
button:hover, .button:hover { background: var(--brand-dark); }
button:disabled { background: #94a3b8; cursor: not-allowed; }
button.link { background: none; color: var(--brand); padding: 0; font-weight: 500; }
button.link.danger { color: var(--err); }
.alert { padding: .7rem .9rem; border-radius: 8px; margin: .75rem 0; font-size: .92rem; }
.alert.error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert.info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.alert.ok { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; letter-spacing: .05em; }
.card { background: var(--card); border-radius: 14px; padding: 1.25rem; box-shadow: 0 1px 3px rgba(0,0,0,.06), 0 8px 24px rgba(15,23,42,.06); }

/* ---------- Portal ---------- */
body.portal { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 1rem;
  background: linear-gradient(160deg, #1e3a8a 0%, #2563eb 55%, #38bdf8 100%); }
body.portal .card { width: 100%; max-width: 400px; padding: 2rem 1.5rem; text-align: center; }
body.portal form { text-align: left; }
body.portal button, body.portal .button { width: 100%; margin-top: 1rem; font-size: 1.05rem; }
.logo { width: 64px; height: 64px; border-radius: 50%; margin: 0 auto .5rem; display: grid; place-items: center; background: #eff6ff; color: var(--brand); }
.logo.ok { background: #f0fdf4; color: var(--ok); }
.sub { color: var(--muted); margin: 0 0 1rem; }
.code-input { font-size: 1.4rem; text-align: center; letter-spacing: .2em; text-transform: uppercase; font-family: ui-monospace, Consolas, monospace; }
.code-input::placeholder { letter-spacing: .05em; font-size: 1rem; }
.terms { margin-top: 1rem; font-size: .85rem; color: var(--muted); }
.terms summary { cursor: pointer; font-weight: 600; }
.check { display: flex; gap: .5rem; align-items: center; font-weight: 500; }
.check input { width: auto; }
.foot { margin-top: 1rem; color: rgba(255,255,255,.85); font-size: .85rem; }

/* ---------- Admin ---------- */
.topbar { display: flex; justify-content: space-between; align-items: center; padding: .8rem 1.5rem; background: #0f172a; color: #fff; }
.topbar nav a { color: #cbd5e1; margin-left: 1.2rem; text-decoration: none; }
.topbar nav a:hover { color: #fff; }
.container { max-width: 1200px; margin: 0 auto; padding: 1.5rem; }
.container > .card { margin-top: 1.25rem; }
.card.narrow { max-width: 380px; margin: 4rem auto; }
.card.narrow button { width: 100%; margin-top: 1rem; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; }
.stat { background: var(--card); border-radius: 14px; padding: 1rem 1.25rem; text-decoration: none; color: var(--muted); box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.stat span { display: block; font-size: 1.8rem; font-weight: 700; color: var(--text); }
.grid { display: grid; grid-template-columns: 1fr 1.4fr; gap: 1.25rem; margin-top: 1.25rem; }
@media (max-width: 860px) { .grid { grid-template-columns: 1fr; } }
.gen button { margin-top: 1rem; width: 100%; }
.row { display: flex; gap: .5rem; }
.toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .75rem; margin-bottom: .5rem; }
.toolbar h2 { margin: 0; }
.search { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.search input { width: 200px; }
.search select { width: auto; }
.search .check { margin: 0; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: .55rem .6rem; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .78rem; font-weight: 600; }
.badge.nao_usado { background: #eff6ff; color: #1d4ed8; }
.badge.ativo { background: #f0fdf4; color: #15803d; }
.badge.expirado { background: #f1f5f9; color: #64748b; }
.badge.online { background: #fef3c7; color: #92400e; }

/* ---------- Impressão de vouchers ---------- */
.vouchers { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin-top: 1rem; }
.ticket { background: #fff; border: 1.5px dashed #94a3b8; border-radius: 10px; padding: 12px; text-align: center; break-inside: avoid; }
.t-title { font-weight: 700; }
.t-row { font-size: .82rem; }
.t-code { font: 700 1.6rem ui-monospace, Consolas, monospace; letter-spacing: .15em; margin: 6px 0; padding: 4px; background: #f1f5f9; border-radius: 6px; }
.t-help { font-size: .72rem; color: var(--muted); margin-top: 6px; }
@media print {
  .no-print { display: none !important; }
  body.admin { background: #fff; }
  .container { padding: 0; max-width: none; }
  .vouchers { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .t-code { background: none; border: 1px solid #000; }
}
