:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #16181d;
  --muted: #667085;
  --border: #e4e7ec;
  --accent: #0f9d58;
  --accent-ink: #ffffff;
  --hot: #d92d20;
  --warm: #dc6803;
  --info: #1570ef;
  --ok: #079455;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #181b21;
    --text: #eceef2;
    --muted: #98a2b3;
    --border: #2a2f38;
    --accent: #22c07a;
    --accent-ink: #06130c;
    --hot: #f97066;
    --warm: #fdb022;
    --info: #53b1fd;
    --ok: #47cd89;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
[hidden] { display: none !important; }
h2 { margin: 0 0 4px; font-size: 18px; }
code { background: var(--bg); border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; font-size: 13px; }
.muted { color: var(--muted); margin: 0 0 16px; }
.error { color: var(--hot); min-height: 1.2em; margin: 4px 0; font-size: 14px; }
.success { color: var(--ok); margin: 4px 0; font-size: 14px; font-weight: 600; }
.success:empty { display: none; }
.auth-links { text-align: center; margin: 14px 0 0; font-size: 14px; }
.auth-links a { color: var(--muted); }
.auth-links a:hover { color: var(--text); }

.brand { margin: 0; font-size: 20px; letter-spacing: -0.02em; }
.brand span { color: var(--accent); }

/* Botões e campos */
.btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 8px; padding: 8px 14px; font: inherit; font-weight: 600; cursor: pointer;
  transition: transform .08s, filter .15s, background .15s;
}
.btn:hover { filter: brightness(0.97); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.wide { width: 100%; }
.btn.danger { color: var(--hot); }
input, select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px;
}
textarea { min-height: 120px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
label { display: grid; gap: 4px; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 12px; }

/* Login */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth-card {
  width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 28px;
}
.auth-card .muted { margin-top: 6px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--bg); border-radius: 8px; padding: 3px; margin-bottom: 16px; }
.seg button { border: 0; background: transparent; padding: 7px; border-radius: 6px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgb(0 0 0 / .08); }

/* Topo */
.topbar {
  display: flex; align-items: center; gap: 20px; padding: 12px 24px;
  background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5;
  flex-wrap: wrap;
}
.tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.tabs button {
  border: 0; background: transparent; font: inherit; font-weight: 600; color: var(--muted);
  padding: 8px 12px; border-radius: 8px; cursor: pointer; white-space: nowrap;
}
.tabs button.active { background: var(--bg); color: var(--text); }
.me { display: flex; align-items: center; gap: 8px; }

main { max-width: 1100px; margin: 0 auto; padding: 24px 16px 64px; }

.notice {
  border: 1px solid var(--hot); color: var(--hot); background: color-mix(in srgb, var(--hot) 8%, transparent);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 20px; font-weight: 600;
}

/* Números */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat .sub { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.stat.highlight { border-color: var(--accent); }
.stat.highlight .value { color: var(--accent); }

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input { flex: 1; min-width: 180px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--border); background: var(--surface); color: var(--muted); border-radius: 999px;
  padding: 5px 12px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.chip.active { background: var(--text); border-color: var(--text); color: var(--bg); }

.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 22px 0 8px; }
.count {
  display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 999px;
  background: var(--hot); color: #fff; font-size: 12px; line-height: 20px; text-align: center;
}
.hint {
  border: 1px solid var(--info); background: color-mix(in srgb, var(--info) 8%, transparent);
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 8px; font-size: 14px;
}
.hint a, .hint button { font-weight: 700; }
.due-late { color: var(--hot); font-weight: 700; }
.notice .btn { margin-left: 10px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 12px; }
.card h3 { margin: 0 0 6px; font-size: 16px; }
.pix { display: grid; grid-template-columns: 200px 1fr; gap: 20px; align-items: center; }
.pix img { width: 200px; height: 200px; border-radius: 10px; border: 1px solid var(--border); background: #fff; image-rendering: pixelated; }
.pix textarea { min-height: 84px; font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.big { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table td, .table th { text-align: left; padding: 8px 6px; border-top: 1px solid var(--border); }
.table th { color: var(--muted); font-weight: 600; border-top: 0; }
.support a { font-weight: 700; color: var(--accent); }
@media (max-width: 640px) { .pix { grid-template-columns: 1fr; justify-items: center; } }
.step { font-size: 12px; color: var(--muted); font-weight: 600; }

/* Listas */
.list { display: grid; gap: 8px; }
.row {
  display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px;
}
.row.hot { border-left: 4px solid var(--hot); }
.row .title { font-weight: 700; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row .meta { color: var(--muted); font-size: 13px; }
.row .actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.row pre { white-space: pre-wrap; font: inherit; color: var(--muted); margin: 4px 0 0; font-size: 14px; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; border: 1px dashed var(--border); border-radius: var(--radius); }

.badge { font-size: 12px; font-weight: 700; border-radius: 999px; padding: 2px 9px; background: var(--bg); color: var(--muted); border: 1px solid var(--border); }
.badge.pix_generated, .badge.hot { color: var(--hot); border-color: currentColor; }
.badge.billet_printed { color: var(--warm); border-color: currentColor; }
.badge.abandoned_cart { color: var(--info); border-color: currentColor; }
.badge.approved, .badge.recovered, .badge.active { color: var(--ok); border-color: currentColor; }
.badge.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }

.url { display: flex; gap: 6px; margin-top: 8px; }
.url input { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }

/* Modal */
dialog {
  border: 1px solid var(--border); border-radius: 14px; padding: 0; width: min(520px, calc(100vw - 32px));
  background: var(--surface); color: var(--text);
}
dialog::backdrop { background: rgb(0 0 0 / .45); }
#modal-body { padding: 22px; }
#modal-body h3 { margin: 0 0 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.history { max-height: 260px; overflow: auto; display: grid; gap: 6px; margin: 8px 0 12px; }
.history div { font-size: 13px; border-left: 2px solid var(--border); padding-left: 8px; }
.history time { color: var(--muted); display: block; font-size: 12px; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; font-weight: 600; z-index: 20;
}

@media (max-width: 640px) {
  .topbar { padding: 10px 16px; gap: 10px; }
  .tabs { order: 3; flex-basis: 100%; }
  .row { grid-template-columns: 1fr; }
  .row .actions { justify-content: flex-start; }
}
