:root {
  --brand: #0f766e;
  --brand-d: #0b5750;
  --bg: #f4f6f7;
  --card: #ffffff;
  --ink: #14201f;
  --muted: #6b7b79;
  --line: #e2e8e7;
  --ok: #158a4a;
  --ok-bg: #e3f5ea;
  --warn: #b45309;
  --warn-bg: #fdf1e0;
  --danger: #b42318;
  --free: #eef2f2;
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  padding-bottom: 64px;
}
.hidden { display: none !important; }

/* Topbar */
#topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  background: var(--brand); color: #fff;
  padding: 12px 14px; padding-top: max(12px, env(safe-area-inset-top));
}
#topbar .title { font-weight: 700; font-size: 17px; flex: 1; }
#topbar .user { font-size: 12px; opacity: .9; }
#topbar button.ghost { background: transparent; border: none; color: #fff; font-size: 26px; line-height: 1; padding: 0 4px; }

main { padding: 16px; max-width: 640px; margin: 0 auto; }
.loading { text-align: center; color: var(--muted); padding: 48px 0; font-size: 15px; }

/* Cartões */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 14px;
}
.card h2 { margin: 0 0 4px; font-size: 16px; }
.card .sub { color: var(--muted); font-size: 13px; margin-bottom: 12px; }

/* Botões */
button {
  font: inherit; cursor: pointer; border-radius: 10px; border: none;
  padding: 13px 16px; font-weight: 600;
}
.btn { background: var(--brand); color: #fff; width: 100%; }
.btn:active { background: var(--brand-d); }
.btn.sec { background: #eaf2f1; color: var(--brand-d); }
.btn.danger { background: #fdeceb; color: var(--danger); }
button.ghost { background: transparent; color: var(--brand-d); }
button.small { padding: 6px 10px; font-size: 13px; }
.row-btns { display: flex; gap: 8px; }
.row-btns .btn { flex: 1; }

/* Formulários */
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
input, select, textarea {
  width: 100%; font: inherit; padding: 12px; border: 1px solid var(--line);
  border-radius: 10px; background: #fff; color: var(--ink);
}
textarea { min-height: 60px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* Listas */
.list-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 14px; margin-bottom: 10px;
}
.list-item .grow { flex: 1; min-width: 0; }
.list-item .big { font-weight: 700; }
.list-item .meta { color: var(--muted); font-size: 13px; }
.chev { color: var(--muted); font-size: 22px; }

/* PIN login */
.login-wrap { max-width: 340px; margin: 8vh auto 0; text-align: center; }
.login-wrap .logo { font-size: 30px; font-weight: 800; color: var(--brand); }
.login-wrap .tg { color: var(--muted); margin: 4px 0 24px; }
.pin-hint { font-size: 12px; color: var(--muted); margin-top: 18px; line-height: 1.7; }

/* Mapa de assentos */
.seatmap-legend { display: flex; gap: 16px; font-size: 13px; color: var(--muted); margin: 6px 0 14px; }
.seatmap-legend .dot { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: -2px; margin-right: 5px; }
.dot.free { background: var(--free); border: 1px solid var(--line); }
.dot.mine { background: var(--brand); }
.dot.other { background: #2563eb; }
.dot.pend { background: var(--warn-bg); border: 1px solid var(--warn); }

.bus { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.bus-front { text-align: center; color: var(--muted); font-size: 12px; border-bottom: 1px dashed var(--line); padding-bottom: 8px; margin-bottom: 12px; }
.seat-row { display: grid; grid-template-columns: 1fr 1fr 20px 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.aisle { }
.seat {
  aspect-ratio: 1 / 1; border-radius: 10px; border: 1px solid var(--line);
  background: var(--free); display: flex; flex-direction: column;
  align-items: center; justify-content: center; font-weight: 700; font-size: 14px;
  padding: 2px; line-height: 1.05;
}
.seat .who { font-size: 9px; font-weight: 500; opacity: .85; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat.occ-mine { background: var(--brand); color: #fff; border-color: var(--brand); }
.seat.occ-other { background: #2563eb; color: #fff; border-color: #2563eb; }
.seat.pend { box-shadow: inset 0 0 0 2px var(--warn); }
.seat.empty-slot { visibility: hidden; }

/* Badges de pagamento */
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.badge.pago { background: var(--ok-bg); color: var(--ok); }
.badge.resta { background: var(--warn-bg); color: var(--warn); }

/* Resumo */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 8px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.stat .n { font-size: 22px; font-weight: 800; }
.stat .l { font-size: 12px; color: var(--muted); }
table.mini { width: 100%; border-collapse: collapse; font-size: 14px; }
table.mini th, table.mini td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
table.mini td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Rodapé demo */
.demo-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 15;
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; background: #fff8e6; border-top: 1px solid #f0e2b8;
  color: #7a5b12; font-size: 12px; padding: 8px 14px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
}

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 78px; transform: translateX(-50%);
  background: #14201f; color: #fff; padding: 11px 16px; border-radius: 10px;
  font-size: 14px; z-index: 40; max-width: 90%; text-align: center;
}
.toast.err { background: var(--danger); }

/* Modal */
.modal-back {
  position: fixed; inset: 0; background: rgba(10,20,19,.45); z-index: 30;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: #fff; width: 100%; max-width: 640px;
  border-radius: 18px 18px 0 0; padding: 18px;
  max-height: 92vh; overflow-y: auto;
}
.modal h3 { margin: 0 0 2px; }
.modal .seat-tag { color: var(--brand-d); font-weight: 700; }
.sect-title { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 22px 0 8px; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
