@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
  --bg: #f3f2ee;
  --surface: #ffffff;
  --soft: #f8f7f4;
  --ink: #1b1a17;
  --muted: #6d6a62;
  --line: #e4e1d9;
  --accent: #ff5b1f;
  --accent-ink: #ffffff;
  --accent-soft: #ffe9df;
  --green: #14804a;
  --green-soft: #dff5e8;
  --amber: #a85d00;
  --amber-soft: #fff0d0;
  --red: #c0312b;
  --red-soft: #fde4e2;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121211;
    --surface: #1c1b19;
    --soft: #232220;
    --ink: #f4f2ec;
    --muted: #a29e93;
    --line: #34322d;
    --accent-soft: #3a1e12;
    --green: #4fd18b;
    --green-soft: #12301f;
    --amber: #f5b64e;
    --amber-soft: #382a0c;
    --red: #ff7b73;
    --red-soft: #3a1815;
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 13.5px/1.5 "Plus Jakarta Sans", system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }

/* ---------- Barra lateral ---------- */
.topbar { position: fixed; inset: 0 auto 0 0; width: 210px; z-index: 10; background: var(--surface); border-right: 1px solid var(--line); }
.topbar-inner { height: 100%; padding: 16px 12px; display: flex; flex-direction: column; gap: 18px; }
.brand { display: flex; align-items: center; gap: 8px; padding: 0 6px; font-size: 16px; font-weight: 800; letter-spacing: -.4px; color: var(--ink); text-decoration: none; }
.logo { width: 26px; height: 26px; font-size: 13px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 800; }
nav { display: flex; flex-direction: column; gap: 2px; }
nav a { display: flex; align-items: center; padding: 8px 10px; border-radius: 8px; font-size: 13px; color: var(--muted); text-decoration: none; font-weight: 600; transition: color .15s, background .15s; }
nav a:hover { color: var(--ink); background: var(--soft); }
nav a.active { color: var(--accent); background: var(--accent-soft); }
.session { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.status-pill { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--soft); }
.status-pill strong, .status-pill span { display: block; line-height: 1.2; }
.status-pill strong { font-size: 12px; }
.status-pill span { font-size: 10px; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); flex: none; }
.dot.ok { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.dot.off { background: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
#whoami { padding: 0 6px; font-size: 12px; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session .ghost { text-align: left; }

/* ---------- Layout ---------- */
main { margin-left: 210px; padding: 20px 24px 56px; }
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 24px; }
.metric { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; display: flex; flex-direction: column-reverse; }
.metric strong { font-size: 24px; line-height: 1.1; font-weight: 800; letter-spacing: -.6px; }
.metric span { font-size: 12px; color: var(--muted); font-weight: 600; }
.view-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
h1 { font-size: 20px; font-weight: 800; letter-spacing: -.5px; }
.muted { color: var(--muted); margin-top: 1px; font-size: 13px; }
.button-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- Offer cards ---------- */
.offers { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.offer { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; transition: border-color .15s, transform .15s; }
.offer:hover { border-color: var(--accent); transform: none; }
.offer-top { display: flex; justify-content: space-between; align-items: center; }
.store { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); }
.offer h3 { font-size: 14px; line-height: 1.35; font-weight: 700; min-height: 38px; }
.price { display: flex; align-items: baseline; gap: 10px; }
.price strong { font-size: 20px; font-weight: 800; letter-spacing: -.5px; }
.price s { color: var(--muted); font-size: 12px; }
.coupon { align-self: flex-start; padding: 2px 9px; border: 1.5px dashed var(--accent); color: var(--accent); border-radius: 6px; font-weight: 700; font-size: 12px; }
.offer-actions { display: flex; align-items: center; gap: 4px; margin-top: auto; padding-top: 10px; border-top: 1px solid var(--line); }
.offer-actions .primary { margin-left: auto; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 11px; font-weight: 700; }
.draft { background: var(--soft); color: var(--muted); border: 1px solid var(--line); }
.review, .scheduled, .pending, .processing { background: var(--amber-soft); color: var(--amber); }
.approved, .published, .sent { background: var(--green-soft); color: var(--green); }
.failed, .cancelled, .expired { background: var(--red-soft); color: var(--red); }

/* ---------- Tables ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 9px 16px; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; background: var(--soft); border-bottom: 1px solid var(--line); }
td { padding: 10px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td strong, td small { display: block; }
td small { color: var(--muted); font-size: 11.5px; }
td:last-child { text-align: right; white-space: nowrap; }
.empty { padding: 28px 20px; text-align: center; color: var(--muted); }
#offers-empty { background: var(--surface); border: 2px dashed var(--line); border-radius: var(--radius); }

/* ---------- Groups ---------- */
.groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.group { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; }
.group-icon { width: 34px; height: 34px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 800; font-size: 14px; flex: none; }
.group div { margin-right: auto; min-width: 0; }
.group strong, .group small { display: block; }
.group small { color: var(--muted); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Buttons ---------- */
button, select { font: inherit; font-weight: 700; border-radius: 8px; padding: 7px 13px; font-size: 13px; border: 1px solid transparent; cursor: pointer; transition: background .15s, border-color .15s, transform .1s; }
button:active { transform: scale(.97); }
button:disabled { opacity: .55; cursor: progress; }
.primary { background: var(--accent); color: var(--accent-ink); }
.primary:hover { filter: brightness(.93); }
.primary.small { padding: 5px 12px; font-size: 12.5px; }
.secondary, select { background: var(--surface); border-color: var(--line); color: var(--ink); }
.secondary:hover, select:hover { border-color: var(--ink); }
.warn { background: var(--amber-soft); color: var(--amber); }
.warn:hover { filter: brightness(.95); }
.ghost { background: transparent; color: var(--muted); }
.ghost:hover { color: var(--ink); background: var(--soft); }
.text-button { background: transparent; color: var(--ink); padding: 5px 9px; font-size: 12.5px; }
.text-button:hover { background: var(--soft); }

/* ---------- Modais e formulários ---------- */
dialog { width: min(540px, calc(100% - 32px)); padding: 0; border: 0; border-radius: 14px; background: var(--surface); color: var(--ink); box-shadow: 0 30px 80px rgb(0 0 0 / .3); }
dialog::backdrop { background: rgb(20 18 12 / .55); }
dialog form { padding: 20px 22px; }
.modal-title { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.modal-title h2 { font-size: 17px; font-weight: 800; letter-spacing: -.3px; }
.eyebrow { font-size: 11px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .08em; }
.icon { background: var(--soft); color: var(--muted); font-size: 18px; line-height: 1; padding: 3px 9px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
label { display: grid; gap: 4px; font-size: 12.5px; font-weight: 700; margin-bottom: 11px; }
.wide { grid-column: 1 / -1; }
input, textarea { width: 100%; font: inherit; font-weight: 500; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--soft); color: var(--ink); transition: border-color .15s, background .15s; }
label select { width: 100%; }
input:focus, textarea:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent-soft); border-color: var(--accent); background: var(--surface); }
textarea { min-height: 80px; resize: vertical; }
.optional { color: var(--muted); font-weight: 500; font-size: 12px; }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; padding-top: 14px; border-top: 1px solid var(--line); }
.form-error { color: var(--red); font-size: 12px; font-weight: 600; min-height: 4px; }

/* ---------- Login ---------- */
.login-page { min-height: 100vh; display: grid; place-items: center; background: var(--bg); }
.login-card { width: min(360px, calc(100% - 32px)); padding: 28px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.login-card h1 { margin: 6px 0 4px; }
.login-card form { margin-top: 18px; }
.login-card .primary { width: 100%; padding: 9px; }

/* ---------- Responsivo ---------- */
@media (max-width: 860px) {
  .topbar { position: static; width: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .topbar-inner { height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 14px; gap: 8px 14px; }
  nav { order: 3; width: 100%; flex-direction: row; overflow-x: auto; }
  nav a { white-space: nowrap; }
  .session { margin: 0 0 0 auto; flex-direction: row; align-items: center; }
  .status-pill span, #whoami { display: none; }
  main { margin-left: 0; padding: 16px 14px 48px; }
  .metrics { grid-template-columns: 1fr 1fr; margin-bottom: 18px; }
  .table-wrap { overflow-x: auto; }
  table { min-width: 640px; }
  .form-grid { grid-template-columns: 1fr; }
  .wide { grid-column: auto; }
}

/* ---------- Configurações ---------- */
.settings { padding: 16px 18px; margin-bottom: 12px; overflow: visible; }
.settings h2 { font-size: 14px; margin: 2px 0 12px; }
.settings h2:not(:first-child) { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.settings .wide { grid-column: 1 / -1; }
.actions.flat { border-top: 0; padding-top: 0; margin-top: -4px; align-items: center; }
.actions .optional { margin-right: auto; }
#whoami { font-size: 13px; }

.qr-box { display: grid; place-items: center; min-height: 280px; text-align: center; }
.qr-box img { width: 260px; max-width: 100%; image-rendering: pixelated; background: #fff; padding: 8px; border-radius: 10px; }
.status-pill { cursor: pointer; }
.switch { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); cursor: pointer; flex: none; }
