/* Estilo compartilhado: painel do lojista e painel admin */
/* =========================================================
   TEMAS — mude as cores aqui
   dark  = amarelo + preto
   light = amarelo + branco
   ========================================================= */
:root, [data-theme="dark"] {
  --brand: #FFD400; --brand-ink: #0A0A0A;
  --bg: #0A0A0A; --surface: #141414; --surface-2: #1C1C1C; --border: #2A2A2A;
  --text: #F5F5F5; --muted: #9A9A9A;
  --ok: #3DDC84; --warn: #FFB020; --bad: #FF5A5A; --info: #5AA9FF;
}
[data-theme="light"] {
  --brand: #FFCC00; --brand-ink: #0A0A0A;
  --bg: #F6F6F3; --surface: #FFFFFF; --surface-2: #FAFAF7; --border: #E7E5DE;
  --text: #111111; --muted: #6B6B6B;
  --ok: #12A150; --warn: #C27C00; --bad: #D92D2D; --info: #1F6FEB;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: Inter, system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }
.hidden { display: none !important; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 20px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; padding: 4px 10px 22px; }
.logo-mark { width: 34px; height: 34px; border-radius: 10px; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; font-weight: 900; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 14px 10px 6px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; color: var(--muted); font-weight: 500; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--brand); color: var(--brand-ink); font-weight: 700; }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-foot { margin-top: auto; padding: 12px; border: 1px solid var(--border); border-radius: 12px; font-size: 12px; color: var(--muted); }
.sidebar-foot b { color: var(--text); display: block; font-size: 13px; }

.main { min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 28px; border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 5; }
.topbar h1 { font-size: 18px; font-weight: 700; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.icon-btn { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); display: grid; place-items: center; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; font-weight: 800; border: 0; }
.menu-btn { display: none; }
.content { padding: 28px; display: flex; flex-direction: column; gap: 20px; }
.test-banner { background: color-mix(in srgb, var(--brand) 18%, transparent); border: 1px solid var(--brand); border-radius: 12px; padding: 10px 14px; font-size: 13px; }

/* ---------- componentes ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 20px; }
.card h3 { font-size: 15px; font-weight: 700; margin-bottom: 14px; display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.stat-label { color: var(--muted); font-size: 13px; }
.stat-value { font-size: 26px; font-weight: 800; margin: 8px 0 6px; letter-spacing: -.02em; }
.delta { font-size: 12px; font-weight: 600; }
.delta.up { color: var(--ok); } .delta.down { color: var(--bad); }
.stat-hero { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.stat-hero .stat-label, .stat-hero .muted { color: var(--brand-ink); opacity: .7; }
.stat-hero .delta { color: var(--brand-ink); }

.btn { border: 0; border-radius: 10px; padding: 10px 16px; font-weight: 700; background: var(--brand); color: var(--brand-ink); }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn.dark { background: var(--brand-ink); color: var(--brand); }
.btn.sm { padding: 6px 12px; font-size: 13px; }
.btn:disabled { opacity: .6; cursor: wait; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 500; }
.chip.active { background: var(--text); color: var(--bg); border-color: var(--text); }
input, select { font: inherit; background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; width: 100%; }
input:focus, select:focus { outline: 2px solid var(--brand); outline-offset: -1px; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.field { margin-bottom: 14px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; }

.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.b-ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, transparent); }
.b-warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); }
.b-bad { color: var(--bad); background: color-mix(in srgb, var(--bad) 14%, transparent); }
.b-info { color: var(--info); background: color-mix(in srgb, var(--info) 14%, transparent); }
.method { display: inline-flex; align-items: center; gap: 6px; }
.method i { font-style: normal; width: 22px; height: 22px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); display: grid; place-items: center; font-size: 10px; font-weight: 800; }

.list-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: 0; }
.bar { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-top: 6px; }
.bar > span { display: block; height: 100%; background: var(--brand); border-radius: 99px; }

.key-box { display: flex; gap: 8px; align-items: center; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 14px; }
.key-box code { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.muted { color: var(--muted); }
.empty { color: var(--muted); padding: 24px 0; text-align: center; }
.toast { position: fixed; bottom: 20px; right: 20px; background: var(--brand); color: var(--brand-ink); padding: 12px 18px; border-radius: 12px; font-weight: 700; opacity: 0; transform: translateY(10px); transition: .2s; pointer-events: none; z-index: 50; max-width: 360px; }
.toast.show { opacity: 1; transform: none; }
.toast.error { background: var(--bad); color: #fff; }

/* ---------- login ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth .card { width: 100%; max-width: 380px; padding: 28px; }
.auth h2 { font-size: 22px; margin: 18px 0 4px; }
.auth .err { color: var(--bad); font-weight: 600; min-height: 1.2em; margin-top: 10px; }

/* ---------- responsivo ---------- */
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-2 { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; width: 260px; z-index: 20; transform: translateX(-100%); transition: .2s; }
  .sidebar.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.5); }
  .menu-btn { display: grid; }
  .topbar, .content { padding-left: 16px; padding-right: 16px; }
  .grid-4 { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
}

/* ---------- avisos de status da conta ---------- */
.test-banner.warn { background: color-mix(in srgb, var(--warn) 14%, transparent); border-color: var(--warn); }
.test-banner.bad { background: color-mix(in srgb, var(--bad) 14%, transparent); border-color: var(--bad); }

/* ---------- diálogo (editar lojista no admin) ---------- */
dialog { margin: auto; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); color: var(--text); padding: 24px; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 32px); }
dialog::backdrop { background: rgba(0,0,0,.55); }
dialog h3 { font-size: 17px; margin-bottom: 4px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.btn.danger { background: var(--bad); color: #fff; }
.btn.ok { background: var(--ok); color: #0A0A0A; }
.tabs-row { display: flex; gap: 8px; flex-wrap: wrap; }
.nav-item.active .badge { color: var(--brand-ink); background: rgba(0,0,0,.14); }
.grid-2 > *, .grid-4 > * { min-width: 0; }   /* tabelas largas rolam dentro do card, não empurram a página */

/* ---------- gráfico (chart.js) ---------- */
.pc { position: relative; min-height: 200px; }
.pc svg { display: block; overflow: visible; touch-action: pan-y; }
.pc text { fill: var(--muted); font-size: 11px; font-family: Inter, system-ui, sans-serif; }
.pc-guide, .pc-dot { opacity: 0; transition: opacity .12s; }
.pc.hover .pc-guide, .pc.hover .pc-dot { opacity: 1; }
.pc-tip { position: absolute; transform: translate(-50%, calc(-100% - 14px)); background: var(--text); color: var(--bg); padding: 6px 10px; border-radius: 8px; font-size: 12px; line-height: 1.35; pointer-events: none; opacity: 0; transition: opacity .12s; white-space: nowrap; display: flex; flex-direction: column; align-items: center; }
.pc-tip span { opacity: .7; }
.pc.hover .pc-tip { opacity: 1; }

/* ---------- tabela de vendas vira cartões no celular ---------- */
@media (max-width: 760px) {
  table.cards thead { display: none; }
  table.cards tr { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "cli amt" "prod st" "met date" "act act"; gap: 6px 12px; padding: 14px 4px; border-bottom: 1px solid var(--border); }
  table.cards tbody tr:hover { background: transparent; }
  table.cards td { padding: 0; border: 0; white-space: normal; }
  table.cards .c-id, table.cards .c-net { display: none; }
  table.cards .c-cli { grid-area: cli; font-weight: 600; }
  table.cards .c-amt { grid-area: amt; text-align: right; }
  table.cards .c-prod { grid-area: prod; color: var(--muted); }
  table.cards .c-st { grid-area: st; justify-self: end; }
  table.cards .c-met { grid-area: met; color: var(--muted); }
  table.cards .c-date { grid-area: date; justify-self: end; color: var(--muted); font-size: 12px; }
  table.cards .c-act { grid-area: act; }
  table.cards .c-act:empty { display: none; }
}

/* ---------- logo ---------- */
img.logo-mark { background: none; object-fit: contain; }
.wordmark { font-weight: 800; letter-spacing: -.02em; white-space: nowrap; }
.wordmark .wm-o { width: .9em; height: .9em; vertical-align: -.1em; margin: 0 .02em 0 .04em; }

/* ---------- adquirentes (admin) ---------- */
.acq-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
.acq { border: 1px solid var(--border); border-radius: 14px; padding: 18px; background: var(--surface-2); }
.acq.on { border-color: color-mix(in srgb, var(--brand) 55%, var(--border)); }
.acq-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.acq-cfg { display: grid; grid-template-columns: 1fr 1fr 1.3fr; gap: 12px; margin-top: 16px; align-items: end; }
.acq-cfg input.prio { width: 100%; text-align: center; }
.acq-cfg .radio { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 13px; padding: 10px 0; margin: 0; cursor: pointer; }
.acq-cfg .radio input { width: auto; }
.acq-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.acq-stats div { display: flex; flex-direction: column; gap: 3px; }
.acq-stats span { font-size: 11px; color: var(--muted); }
.acq-stats b { font-size: 14px; }
.switch { position: relative; display: inline-block; width: 44px; height: 26px; margin: 0; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--border); border-radius: 99px; cursor: pointer; transition: .15s; }
.switch span::before { content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; background: var(--text); border-radius: 50%; transition: .15s; }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::before { transform: translateX(18px); background: var(--brand-ink); }
.switch input:disabled + span { opacity: .4; cursor: not-allowed; }
@media (max-width: 760px) { .acq-grid { grid-template-columns: 1fr; } .acq-cfg { grid-template-columns: 1fr 1fr; } .acq-stats { grid-template-columns: 1fr 1fr; } }
.caps { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.cap { font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); }
.cap.yes { color: var(--ok); } .cap.no { color: var(--muted); text-decoration: line-through; opacity: .75; }
.cap.info { color: var(--info); } .cap.link { color: var(--text); }
.cap.link:hover { border-color: var(--brand); }
.setup { margin-top: 14px; padding: 12px 14px; border-radius: 10px; border: 1px dashed var(--border); background: var(--surface); font-size: 13px; }
.setup-row { display: grid; grid-template-columns: 16px auto 1fr; gap: 8px; align-items: baseline; margin-top: 6px; }
.setup-row .ok { color: var(--ok); } .setup-row .miss { color: var(--bad); } .setup-row .opt { color: var(--muted); }
.setup-row code { font-size: 12px; }
.prio-na { font-size: 12px; color: var(--muted); padding: 11px 0; text-align: center; border: 1px dashed var(--border); border-radius: 10px; }
.notes { margin: 12px 0 0 18px; font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
@media (max-width: 760px) { .setup-row { grid-template-columns: 16px 1fr; } .setup-row .muted { grid-column: 2; } }

/* ---------- roteamento (admin) ---------- */
.auto-box { display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface-2); flex-wrap: wrap; }
.auto-box.on { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 9%, var(--surface)); }
.auto-box p { color: var(--muted); font-size: 13px; margin: 4px 0; line-height: 1.45; }
.auto-box small { color: var(--muted); font-size: 12px; }
.auto-ico { width: 42px; height: 42px; border-radius: 12px; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; flex-shrink: 0; }
.auto-ico svg { width: 22px; height: 22px; }
.section-label { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 18px 0 10px; }
.section-label .muted { text-transform: none; letter-spacing: 0; font-weight: 500; }
.route-list { display: flex; flex-direction: column; gap: 10px; }
.route-row { display: grid; grid-template-columns: 22px 34px minmax(160px, 1fr) minmax(240px, 300px) 56px auto; align-items: center; gap: 10px;
  padding: 14px 16px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface-2); border-left: 4px solid var(--border); }
.route-row.first { border-left-color: var(--brand); }
.route-row.dragging { opacity: .45; }
.drag { color: var(--muted); cursor: grab; letter-spacing: -2px; user-select: none; }
.pos { font-weight: 800; font-size: 15px; color: var(--muted); }
.route-row.first .pos { color: var(--brand); }
.rname b { font-size: 15px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rtags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.cost-chip { font: inherit; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; border: 1px solid color-mix(in srgb, var(--brand) 50%, var(--border)); background: transparent; color: var(--text); cursor: pointer; }
.cost-chip:hover { background: color-mix(in srgb, var(--brand) 15%, transparent); }
.rstat { text-align: center; }
.rstat b { display: block; font-size: 20px; font-weight: 800; }
.rstat span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.rstat.warn b { color: var(--warn); } .rstat.ok b { color: var(--ok); }
.ring { position: relative; width: 52px; height: 52px; }
.ring svg { width: 52px; height: 52px; }
.ring-bg { fill: none; stroke: var(--border); stroke-width: 5; }
.ring-fg { fill: none; stroke: var(--brand); stroke-width: 5; stroke-linecap: round; }
.ring span { position: absolute; inset: 0; display: grid; place-items: center; font-size: 12px; font-weight: 800; }
.rbtns { display: flex; gap: 4px; }
.icon-btn.sm { width: 30px; height: 30px; border-radius: 8px; font-size: 13px; }
.icon-btn:disabled { opacity: .35; cursor: default; }
.ab-box { margin-top: 14px; padding: 16px; border-radius: 14px; border: 1px solid var(--info); background: color-mix(in srgb, var(--info) 7%, var(--surface)); }
.ab-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.ab-arms { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ab-arm { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); }
.ab-tag { width: 30px; height: 30px; border-radius: 8px; background: var(--info); color: #fff; display: grid; place-items: center; font-weight: 800; flex-shrink: 0; }
.rhist { margin-top: 16px; font-size: 13px; }
.rhist summary { cursor: pointer; color: var(--muted); font-weight: 600; }
.rhist div { padding: 6px 0; border-bottom: 1px solid var(--border); }
@media (max-width: 900px) {
  .route-row { grid-template-columns: 22px 30px 1fr auto; grid-template-areas: "d p n r" "s s s s" "b b b b"; row-gap: 12px; }
  .route-row .drag { grid-area: d; } .route-row .pos { grid-area: p; } .route-row .rname { grid-area: n; min-width: 0; }
  .route-row .ring { grid-area: r; } .route-row .rstats { grid-area: s; } .route-row .rbtns { grid-area: b; justify-content: flex-end; }
  .ab-arms { grid-template-columns: 1fr; }
}

.rstats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

/* ---------- login (split) ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; padding: 0; place-items: stretch; }
.auth-brand { position: relative; overflow: hidden; background: #0A0A0A; color: #F5F5F5; padding: 40px 48px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-brand::before { content: ""; position: absolute; width: 520px; height: 520px; right: -160px; bottom: -160px; border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--brand) 55%, transparent), transparent 70%); opacity: .55; }
.auth-brand::after { content: ""; position: absolute; inset: 0; background-image: radial-gradient(rgba(255,255,255,.06) 1px, transparent 1px); background-size: 22px 22px; }
.auth-brand > * { position: relative; z-index: 1; }
.auth-brand-top { display: flex; align-items: center; gap: 10px; font-size: 22px; }
.auth-brand-top .logo-mark { width: 40px; height: 40px; border-radius: 11px; }
.auth-hero h1 { font-size: 46px; line-height: 1.05; letter-spacing: -.03em; font-weight: 800; }
.auth-hero h1 span { color: #FFD400; }
.auth-hero p { color: #A3A3A3; font-size: 16px; margin: 16px 0 22px; max-width: 420px; }
.auth-hero ul { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.auth-hero li { display: flex; gap: 10px; align-items: center; color: #D4D4D4; }
.auth-hero li::before { content: "✓"; width: 22px; height: 22px; border-radius: 50%; background: #FFD400; color: #0A0A0A; font-size: 12px; font-weight: 900; display: grid; place-items: center; flex-shrink: 0; }
.auth-brand-foot { color: #737373; font-size: 12px; }
.auth-side { display: grid; place-items: center; padding: 32px 20px; background: var(--bg); }
.auth-side .card { width: 100%; max-width: 400px; padding: 36px 32px; border-radius: 20px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.auth-side .card .logo { display: none; }
.auth h2 { font-size: 26px; margin: 0 0 6px; letter-spacing: -.02em; }
.auth-side input { padding: 13px 14px; }
.auth-side .btn { padding: 14px; font-size: 15px; margin-top: 4px; }
@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; }
  .auth-brand { padding: 24px 20px; min-height: auto; }
  .auth-hero h1 { font-size: 30px; } .auth-hero ul, .auth-brand-foot { display: none; } .auth-hero p { margin-bottom: 0; }
}
/* logo: o "O" da marca em amarelo, como o botão de ligar */
.wordmark .wm-o { color: var(--brand); filter: drop-shadow(0 0 6px color-mix(in srgb, var(--brand) 45%, transparent)); }
img.logo-mark { box-shadow: 0 6px 18px rgba(0,0,0,.35), 0 0 0 1px rgba(255,212,0,.08); }
