:root {
  color-scheme: light;
  --bg: #f6f4f9;
  --surface: #ffffff;
  --surface-2: #f9f7fc;
  --border: #e6e1ee;
  --text: #1b1426;
  --text-2: #5b5269;
  --text-3: #8a8297;
  --brand: #6d28d9;
  --brand-ink: #ffffff;
  --brand-soft: #f1eafd;
  --accent: #6d28d9;
  --accent-soft: #f1eafd;
  --ok: #157a4c;
  --ok-soft: #e2f4ea;
  --warn: #a15c00;
  --warn-soft: #fff3dc;
  --danger: #c0352b;
  --danger-soft: #fde8e6;
  --series-1: #6d28d9;
  --series-2: #f08a24;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.06);
  --radius: 12px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #120d19;
    --surface: #1a1424;
    --surface-2: #211a2d;
    --border: #30273f;
    --text: #f2eef8;
    --text-2: #b9b0c8;
    --text-3: #888096;
    --brand: #a98bfa;
    --brand-soft: #2a1e45;
    --brand-ink: #1a0b33;
    --ok: #3fc98a;
    --ok-soft: #12321f;
    --accent: #a98bfa;
    --accent-soft: #2a1e45;
    --warn: #e0a33a;
    --warn-soft: #3a2d14;
    --danger: #ef6a5f;
    --danger-soft: #3d1c19;
    --series-1: #a98bfa;
    --series-2: #f59a46;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.3);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #120d19; --surface: #1a1424; --surface-2: #211a2d; --border: #30273f;
  --text: #f2eef8; --text-2: #b9b0c8; --text-3: #888096; --brand: #a98bfa; --brand-ink: #1a0b33; --brand-soft: #2a1e45;
  --accent: #a98bfa; --accent-soft: #2a1e45; --ok: #3fc98a; --ok-soft: #12321f; --warn: #e0a33a; --warn-soft: #3a2d14;
  --danger: #ef6a5f; --danger-soft: #3d1c19; --series-1: #a98bfa; --series-2: #f59a46;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.3);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
.num { font-variant-numeric: tabular-nums; }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
a { color: var(--accent); }

button, input, select { font: inherit; color: inherit; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 9px 14px; border-radius: 10px; cursor: pointer; font-weight: 600; white-space: nowrap;
  transition: background .12s, border-color .12s, transform .05s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: var(--brand); filter: brightness(1.08); }
.btn-danger { color: var(--danger); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-lg { padding: 14px 18px; font-size: 16px; border-radius: 12px; }
kbd { font-family: ui-monospace, monospace; font-size: 11px; padding: 1px 5px; border-radius: 5px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2); font-weight: 600; }
.btn-primary kbd { background: rgba(255,255,255,.18); border-color: rgba(255,255,255,.3); color: #fff; }

.input, select.input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); outline: none; transition: border-color .12s, box-shadow .12s;
}
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
label.field { display: grid; gap: 6px; font-weight: 600; font-size: 13px; color: var(--text-2); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); }
.badge.blue { background: var(--accent-soft); color: var(--accent); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.red { background: var(--danger-soft); color: var(--danger); }
.badge.gray { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }

table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12px; font-weight: 600; color: var(--text-3); padding: 10px 12px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .r { text-align: right; }
.tbl tbody tr.click { cursor: pointer; }
.tbl tbody tr.click:hover { background: var(--surface-2); }

/* Modal */
.modal-back { position: fixed; inset: 0; background: rgba(10,12,11,.55); display: grid; place-items: center; z-index: 50; padding: 16px; animation: fade .12s; }
.modal { background: var(--surface); border-radius: 16px; width: min(520px, 100%); max-height: calc(100vh - 32px); overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.3); border: 1px solid var(--border); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px 0; }
.modal-body { padding: 16px 20px 20px; display: grid; gap: 14px; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 0 20px 20px; }
@keyframes fade { from { opacity: 0 } }

/* Toast */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 100; }
.toast { background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600; box-shadow: var(--shadow); animation: fade .15s; }
.toast.err { background: var(--danger); color: #fff; }

/* Cupom / DANFE NFC-e (papel térmico, sempre claro) */
.receipt { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12px; background: #fffef8; color: #111; padding: 16px; border-radius: 8px; border: 1px dashed #ccc; line-height: 1.45; }
.receipt .c { text-align: center; }
.receipt .r { display: flex; justify-content: space-between; gap: 8px; }
.receipt hr { border: 0; border-top: 1px dashed #999; margin: 8px 0; }
.receipt .qr { width: 150px; margin: 10px auto; }
.receipt .qr svg { width: 100%; height: auto; display: block; }
.danfe-alert { text-align: center; font-weight: 800; border: 1.5px solid #111; padding: 4px; margin-top: 6px; }
.alert-box { border-radius: 10px; padding: 10px 12px; font-weight: 600; font-size: 13px; background: var(--warn-soft); color: var(--warn); }
.alert-box.red { background: var(--danger-soft); color: var(--danger); }
.alert-box.green { background: var(--ok-soft); color: var(--ok); }
@media print {
  body * { visibility: hidden; }
  .receipt, .receipt * { visibility: visible; }
  .receipt { position: absolute; left: 0; top: 0; width: 80mm; border: 0; padding: 0; }
}

/* PIN pad */
.pin-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.pin-card { width: min(360px, 100%); padding: 28px; text-align: center; display: grid; gap: 16px; }
.pin-dots { display: flex; justify-content: center; gap: 12px; height: 18px; }
.pin-dots span { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--border); }
.pin-dots span.on { background: var(--brand); border-color: var(--brand); }
.pin-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pin-grid button { padding: 16px; font-size: 20px; font-weight: 700; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); cursor: pointer; }
.pin-grid button:hover { background: var(--brand-soft); }
/* Fonte da marca (Poppins, SIL OFL; licença em assets/fonts/POPPINS-LICENSE.txt). Só no nome SoDan. */
@font-face { font-family: "Poppins"; font-weight: 700; font-style: normal; font-display: swap; src: url(/assets/fonts/poppins-700.woff2) format("woff2"); }
.marca-nome, .logo > span:not(.logo-mark) { font-family: "Poppins", var(--font); font-weight: 700; letter-spacing: -.01em; }
.logo { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 16px; }
.logo-mark { width: 32px; height: 32px; flex: none; display: inline-block; background: url(/assets/logo.svg) center / contain no-repeat; }

/* Botão sol/lua do tema (assets/tema.js) */
.tema-btn { position: fixed; left: 14px; bottom: 14px; z-index: 45; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); box-shadow: var(--shadow); display: grid; place-items: center; cursor: pointer; padding: 0; }
.tema-btn.tema-inline { position: static; box-shadow: none; }
.tema-btn:hover { color: var(--text); border-color: var(--text-3); }
.tema-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
@media print { .tema-btn { display: none; } }

/* Destaque da marca (degradê do logo): usar com moderação */
.marca-grad { background: linear-gradient(120deg, #7b2ff7, #f72585 55%, #ff9a3c); -webkit-background-clip: text; background-clip: text; color: transparent; }
