:root {
  --bg: #FFF8F5;
  --surface: #FFFFFF;
  --surface-2: #FFF1EB;
  --ink: #2A1710;
  --ink-2: #6B5248;
  --line: #F1DDD4;
  --brand: #EE4D2D;
  --brand-ink: #D73211;
  --brand-soft: #FDE4DC;
  --good: #12805C;
  --good-soft: #DDF5EA;
  --warn: #9A6200;
  --warn-soft: #FFF1CC;
  --bad: #C3261B;
  --bad-soft: #FDE2DF;
  --wa: #1FA855;
  --tg: #2A9BD8;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(42, 23, 16, .06), 0 4px 16px rgba(42, 23, 16, .05);
  --font: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17100D; --surface: #211814; --surface-2: #2B1F1A; --ink: #F7ECE7; --ink-2: #C2AAA0; --line: #3A2B25;
    --brand-soft: #4A2018; --good-soft: #123A2C; --warn-soft: #3D2E0A; --bad-soft: #43201C; --good: #4CC79A; --warn: #E8B54A; --bad: #FF7A6E;
    --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.45; -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand-ink); }
.boot { display: grid; place-items: center; min-height: 100vh; color: var(--ink-2); }

/* Layout */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; padding: 20px 14px; border-right: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; gap: 4px; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; padding: 4px 10px 18px; letter-spacing: -.01em; }
.logo img { width: 34px; height: 34px; }
.logo small { display: block; font-weight: 600; font-size: 11px; color: var(--ink-2); letter-spacing: .04em; text-transform: uppercase; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; color: var(--ink-2); text-decoration: none; font-weight: 600; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.on { background: var(--brand-soft); color: var(--brand-ink); }
.nav .ico { width: 22px; text-align: center; }
.side .spacer { flex: 1; }
main { padding: 26px 32px 80px; max-width: 1180px; width: 100%; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.head h1 { margin: 0; font-size: 26px; letter-spacing: -.02em; }
.head p { margin: 4px 0 0; color: var(--ink-2); }
.bottom { display: none; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  main { padding: 18px 16px 96px; }
  .head h1 { font-size: 22px; }
  .bottom { display: flex; position: fixed; inset: auto 0 0 0; background: var(--surface); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 20; overflow-x: auto; }
  .bottom a { flex: 1 0 64px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; font-weight: 600; color: var(--ink-2); text-decoration: none; padding: 4px; border-radius: 10px; }
  .bottom a .ico { font-size: 19px; }
  .bottom a.on { color: var(--brand-ink); background: var(--brand-soft); }
}

/* Componentes */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card h2, .card h3 { margin: 0 0 10px; font-size: 16px; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.g4 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.kpi .v { font-size: 30px; font-weight: 800; letter-spacing: -.02em; }
.kpi .l { color: var(--ink-2); font-size: 13px; font-weight: 600; }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); padding: 8px 14px; border-radius: 10px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.pri { background: var(--brand-ink); border-color: var(--brand-ink); color: #fff; }
.btn.pri:hover { filter: brightness(1.06); }
.btn.wa { background: var(--wa); border-color: var(--wa); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: default; }

label.f { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 700; color: var(--ink-2); }
input[type=text], input[type=number], input[type=password], input[type=time], input[type=date], input[type=datetime-local], input[type=search], select, textarea {
  width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 9px 11px; font-weight: 500; color: var(--ink);
}
textarea { min-height: 90px; resize: vertical; font-family: var(--font); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: transparent; }
.fields { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--brand-ink); }

.switch { position: relative; width: 42px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--line); border-radius: 99px; cursor: pointer; transition: .15s; }
.switch span::after { content: ''; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--good); }
.switch input:checked + span::after { transform: translateX(18px); }

.chip { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); font-size: 13px; font-weight: 700; cursor: pointer; user-select: none; }
.chip.on { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-ink); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 800; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--ink-2); }
.badge.good { background: var(--good-soft); color: var(--good); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.brand { background: var(--brand-soft); color: var(--brand-ink); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: var(--line); }
.dot.good { background: var(--good); } .dot.bad { background: var(--bad); } .dot.warn { background: var(--warn); }

/* Ofertas */
.offers { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.offer { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.offer .img { aspect-ratio: 1; background: var(--surface-2) center / cover no-repeat; position: relative; }
.offer .img .badges { position: absolute; left: 8px; top: 8px; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.offer .body { padding: 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.offer .t { font-weight: 700; font-size: 14px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.offer .p { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.offer .was { color: var(--ink-2); font-size: 13px; text-decoration: line-through; }
.offer .meta { font-size: 12px; color: var(--ink-2); display: flex; gap: 8px; flex-wrap: wrap; }
.offer .foot { display: flex; gap: 6px; margin-top: auto; padding-top: 6px; }

.filters { display: grid; gap: 10px; grid-template-columns: 2fr repeat(4, 1fr); align-items: end; margin-bottom: 16px; }
@media (max-width: 860px) {
  .filters { grid-template-columns: 1fr 1fr; } .filters .wide { grid-column: 1 / -1; }
  .offers { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .offer .body { padding: 10px; } .offer .p { font-size: 18px; } .offer .t { font-size: 13px; }
}

.list { display: flex; flex-direction: column; }
.item { display: flex; gap: 12px; align-items: center; padding: 12px 4px; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.item .grow { flex: 1; min-width: 0; }
.item .name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
pre.msg { white-space: pre-wrap; word-break: break-word; background: var(--surface-2); border-radius: 10px; padding: 10px 12px; margin: 6px 0 0; font-family: var(--font); font-size: 13px; max-height: 220px; overflow: auto; }

.tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { border: 1px solid var(--line); background: var(--surface); padding: 6px 14px; border-radius: 99px; font-weight: 700; cursor: pointer; color: var(--ink-2); }
.tabs button.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.modal-bg { position: fixed; inset: 0; background: rgba(20, 10, 6, .45); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { background: var(--surface); border-radius: 18px; width: min(720px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 20px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal h2 { margin: 0 0 14px; }
.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 700; z-index: 60; box-shadow: var(--shadow); max-width: calc(100vw - 32px); }
.empty { text-align: center; padding: 36px 16px; color: var(--ink-2); }
.empty b { display: block; color: var(--ink); font-size: 16px; margin-bottom: 4px; }
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: min(380px, 100%); padding: 28px; }
.section-title { font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); margin: 22px 0 10px; }
.qr { width: 260px; max-width: 100%; border-radius: 12px; background: #fff; padding: 8px; }
.warnbox { background: var(--warn-soft); color: var(--warn); border-radius: 12px; padding: 10px 14px; font-weight: 600; font-size: 14px; }
.okbox { background: var(--good-soft, rgba(22,163,74,.12)); color: var(--good); border-radius: 12px; padding: 10px 14px; font-weight: 600; font-size: 14px; }

/* Tabelas do painel */
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
table.data th, table.data td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
table.data th:first-child, table.data td:first-child { text-align: left; white-space: normal; min-width: 180px; }
table.data th { font-size: 12px; color: var(--ink-2); font-weight: 700; text-transform: uppercase; letter-spacing: .03em; cursor: pointer; user-select: none; position: sticky; top: 0; background: var(--surface); }
table.data th.on { color: var(--brand-ink); }
table.data tr.total td { font-weight: 800; border-top: 2px solid var(--line); }
.pos { color: var(--good); }
.neg { color: var(--bad); }
.kpi .s { color: var(--ink-2); font-size: 12px; margin-top: 2px; }
.cred { display: grid; gap: 10px; }
.cred h3 { display: flex; align-items: center; gap: 8px; }
.shell > main { min-width: 0; }
