:root {
  --bg: #f3f5fa;
  --surface: #ffffff;
  --ink: #0f1b2d;
  --muted: #64748b;
  --line: #e3e8f0;
  --side: #0b1d3a;
  --side-2: #10284f;
  --side-ink: #b9c6dc;
  --navy: #0b1d3a;
  --accent: #2563eb;
  --accent-2: #1d4ed8;
  --accent-soft: #e8efff;
  --accent-ink: #ffffff;
  --ok: #0f7b4f;
  --ok-bg: #e3f6ed;
  --warn: #9a5b00;
  --warn-bg: #fff3dc;
  --err: #c0262d;
  --err-bg: #fdeaea;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 27, 45, .05), 0 4px 14px rgba(15, 27, 45, .04);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 14.5px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; letter-spacing: -.02em; font-weight: 700; }
h2 { font-size: 15px; margin: 0 0 12px; font-weight: 650; letter-spacing: -.01em; }
h3 { font-size: 13.5px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* ---------- estrutura ---------- */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.side { background: linear-gradient(180deg, var(--side) 0%, #0a1830 100%); color: var(--side-ink); padding: 18px 12px 80px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #24406e transparent; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: #fff; font-size: 15.5px; padding: 4px 10px 18px; letter-spacing: -.01em; }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  display: grid; place-items: center; color: #fff; font-size: 14px; box-shadow: 0 4px 12px rgba(37, 99, 235, .45); }
.nav-group { font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em; color: #6f83a6; font-weight: 700; padding: 14px 12px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; color: var(--side-ink); padding: 8px 12px; border-radius: 9px; margin-bottom: 1px; font-size: 13.5px; }
.nav a:hover { background: rgba(255, 255, 255, .06); text-decoration: none; color: #fff; }
.nav a.on { background: var(--accent); color: #fff; font-weight: 600; box-shadow: 0 4px 12px rgba(37, 99, 235, .35); }
.nav svg { width: 17px; height: 17px; flex: none; opacity: .9; }
.side form.logout-f { position: fixed; bottom: 0; left: 0; width: 248px; padding: 12px; background: #0a1830; border-top: 1px solid rgba(255,255,255,.06); }
.side .logout { width: 100%; background: transparent; border: 1px solid rgba(255,255,255,.16); color: var(--side-ink); justify-content: center; }
.main { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(243, 245, 250, .88); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; padding: 10px 32px; }
.topbar .crumb { font-weight: 600; color: var(--muted); font-size: 13px; }
.content { padding: 22px 32px 60px; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.head p { margin: 4px 0 0; }

/* ---------- componentes ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.grid { display: grid; gap: 16px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }
.stat .n { font-size: 26px; font-weight: 750; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.stat .l { color: var(--muted); font-size: 12.5px; }
.kpi { position: relative; overflow: hidden; }
.kpi .ico { position: absolute; right: 16px; top: 16px; width: 36px; height: 36px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }
.kpi .ico svg { width: 18px; height: 18px; }
.kpi .lbl { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.kpi .n { font-size: 26px; font-weight: 750; letter-spacing: -.03em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.delta { font-size: 12px; font-weight: 600; padding: 1px 7px; border-radius: 999px; }
.delta.up { background: var(--ok-bg); color: var(--ok); }
.delta.down { background: var(--err-bg); color: var(--err); }
.btn, button { font: inherit; display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); padding: 8px 14px; border-radius: 9px; cursor: pointer; white-space: nowrap; font-weight: 500; }
.btn:hover, button:hover { border-color: #c4cede; text-decoration: none; }
.btn.primary, button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover, button.primary:hover { background: var(--accent-2); }
.btn.sm, button.sm { padding: 5px 10px; font-size: 12.5px; }
.btn.danger, button.danger { color: var(--err); }
.btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 650; background: #f8fafd; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td, table tr:hover td { background: #fafcff; }
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; box-shadow: var(--shadow); }
.thumb { width: 42px; height: 42px; border-radius: 8px; object-fit: cover; background: #eef2f7; border: 1px solid var(--line); display: block; }
.t-title { font-weight: 600; max-width: 460px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; border: 1px solid transparent; white-space: nowrap; }
.pf-shopee { background: #fff0eb; color: #c2410c; border-color: #fbd3c4; }
.pf-mercadolivre { background: #fff8c5; color: #6b5a00; border-color: #efe28a; }
.pf-tiktok { background: #eef1f5; color: #111; border-color: #d5dbe3; }
.pf-shein { background: #f3f4f6; color: #000; border-color: #d1d5db; }
.st-publicado, .st-concluido, .st-ok, .st-aplicado { background: var(--ok-bg); color: var(--ok); }
.st-importado, .st-desfeito { background: var(--accent-soft); color: #1e40af; }
.st-pendente, .st-na_fila, .st-rodando, .st-aplicando, .st-desfazendo, .st-rascunho { background: var(--warn-bg); color: var(--warn); }
.st-erro, .st-falhou { background: var(--err-bg); color: var(--err); }
.cls-A { background: #dcfce7; color: #166534; } .cls-B { background: #fef3c7; color: #92400e; } .cls-C { background: #f1f5f9; color: #475569; }

.flash { padding: 11px 14px; border-radius: 10px; margin-bottom: 14px; border: 1px solid; }
.flash.ok { background: var(--ok-bg); color: var(--ok); border-color: #b5e3cc; }
.flash.erro { background: var(--err-bg); color: var(--err); border-color: #f5c2c2; }

form.stack label, .field { display: block; margin-bottom: 14px; }
label .lbl, .field .lbl { display: block; font-weight: 600; font-size: 12.5px; margin-bottom: 5px; }
.req { color: var(--accent); }
input[type=text], input[type=password], input[type=number], input[type=search], input[type=datetime-local], select, textarea {
  font: inherit; width: 100%; padding: 8px 11px; border: 1px solid #d3dbe7; border-radius: 9px; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 3px solid #c7d7fe; border-color: var(--accent); }
textarea { min-height: 110px; resize: vertical; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.steps { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.step { padding: 6px 12px; border-radius: 999px; background: #e7ecf4; color: var(--muted); font-size: 13px; font-weight: 600; }
.step.on { background: var(--navy); color: #fff; }
.step.done { background: var(--accent-soft); color: var(--accent-2); }
.choice { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; margin-bottom: 8px; background: #fff; cursor: pointer; }
.choice:hover { border-color: var(--accent); }
.choice input { margin-top: 4px; }
.log { font: 12.5px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; max-height: 520px; overflow: auto; }
.log div { padding: 3px 0; border-bottom: 1px dashed var(--line); }
.log .bad { color: var(--err); }
.log .good { color: var(--ok); }
.progress { height: 8px; background: #e7ecf4; border-radius: 999px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.empty { text-align: center; padding: 36px 20px; color: var(--muted); }
.sticky-bar { position: sticky; bottom: 12px; background: var(--navy); color: #fff; padding: 12px 16px; border-radius: 12px; margin-top: 14px; display: none; box-shadow: 0 10px 30px rgba(11,29,58,.3); }
.sticky-bar.show { display: flex; }
.sticky-bar select { width: auto; min-width: 200px; }
.prod-head { display: flex; gap: 14px; align-items: center; }
.prod-head img { width: 64px; height: 64px; border-radius: 10px; object-fit: cover; border: 1px solid var(--line); }
code { background: #eef2f8; padding: 2px 6px; border-radius: 5px; font-size: 12.5px; word-break: break-all; }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(160deg, #0b1d3a, #1d4ed8); }
.login-card { width: 100%; max-width: 380px; }

/* seletor de loja / topo */
.store-pick { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.store-pick select { width: auto; max-width: 100%; min-width: 220px; font-weight: 600; background: #fff; }
.bell { position: relative; }
.bell > summary { list-style: none; cursor: pointer; width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: #fff; display: grid; place-items: center; color: var(--ink); }
.bell > summary::-webkit-details-marker { display: none; }
.bell > summary svg { width: 18px; height: 18px; }
.bell .dot { position: absolute; top: -5px; right: -5px; background: var(--err); color: #fff; font-size: 10.5px; font-weight: 700; min-width: 18px; height: 18px; border-radius: 999px; display: grid; place-items: center; padding: 0 5px; }
.bell .panel { position: absolute; right: 0; top: 46px; width: 360px; max-width: calc(100vw - 32px); background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 18px 40px rgba(15,27,45,.16); overflow: hidden; z-index: 40; }
.bell .panel a.it { display: block; padding: 10px 14px; border-bottom: 1px solid var(--line); color: var(--ink); }
.bell .panel a.it:hover { background: #f6f9ff; text-decoration: none; }
.bell .panel .t { font-weight: 600; font-size: 13px; }
.bell .panel .b { font-size: 12px; color: var(--muted); }
.nk { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--accent); }
.nk-venda { background: #16a34a; } .nk-prazo { background: #f59e0b; } .nk-reclamacao { background: #dc2626; } .nk-ads { background: #7c3aed; }

/* aviso diário de envio */
.ship-banner { background: linear-gradient(90deg, #0b1d3a, #163a75); color: #e6edfa; border-radius: 12px; padding: 12px 16px; margin-bottom: 18px; display: flex; gap: 14px; align-items: flex-start; box-shadow: var(--shadow); }
.ship-banner .ic { width: 34px; height: 34px; border-radius: 9px; background: rgba(255,255,255,.12); display: grid; place-items: center; flex: none; }
.ship-banner .ic svg { width: 18px; height: 18px; }
.ship-banner .lines { flex: 1; display: grid; gap: 4px; font-size: 13px; }
.ship-banner strong { color: #fff; }
.ship-banner .pill { background: rgba(255,255,255,.14); color: #fff; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; margin-left: 6px; white-space: nowrap; }
.ship-banner .x { background: transparent; border: 0; color: #9fb3d6; padding: 2px 6px; }
.ship-banner a { color: #9cc0ff; }

/* abas */
.nav-count { margin-left: auto; background: #ef4444; color: #fff; font-size: 10.5px; font-weight: 700; padding: 1px 7px; border-radius: 999px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 16px; background: #e8edf5; padding: 4px; border-radius: 11px; width: fit-content; max-width: 100%; }
.tabs a { padding: 6px 14px; border-radius: 8px; color: var(--muted); font-size: 13px; font-weight: 600; }
.tabs a.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(15,27,45,.12); }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.msg { margin-bottom: 14px; }
.msg-head { display: flex; gap: 12px; align-items: flex-start; }
.msg-head .thumb { flex: none; }
.msg-q { background: #f2f5fa; border-radius: 10px; padding: 10px 12px; margin: 10px 0; white-space: pre-wrap; }
.msg-hist { font-size: 13px; color: var(--muted); border-left: 3px solid var(--line); padding-left: 10px; margin: 8px 0; }
.msg textarea { min-height: 90px; }
.ai-note { font-size: 12px; padding: 6px 10px; border-radius: 8px; margin-top: 6px; }
.ai-note.ok { background: var(--ok-bg); color: var(--ok); }
.ai-note.warn { background: var(--warn-bg); color: var(--warn); }
.charcount { font-size: 12px; color: var(--muted); }
button:disabled, .btn:disabled { opacity: .45; cursor: not-allowed; }

/* gráficos */
.bars { display: flex; align-items: flex-end; gap: 3px; height: 180px; padding-top: 10px; }
.bars .b { flex: 1; display: flex; flex-direction: column-reverse; min-width: 3px; border-radius: 4px 4px 0 0; overflow: hidden; background: #eef2f8; position: relative; }
.bars .b span { display: block; width: 100%; }
.bars .b:hover { outline: 2px solid #c7d7fe; }
.axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 6px; }
.hbar { height: 8px; background: #eef2f8; border-radius: 999px; overflow: hidden; }
.hbar span { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.donut { width: 150px; height: 150px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.donut .hole { width: 96px; height: 96px; border-radius: 50%; background: #fff; display: grid; place-items: center; text-align: center; font-size: 12px; color: var(--muted); }
.donut .hole strong { display: block; font-size: 16px; color: var(--ink); }
.heat td { padding: 0; height: 22px; text-align: center; font-size: 10px; border: 1px solid #fff; }
.chip { display: inline-flex; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); background: #fff; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.chip.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.chip:hover { text-decoration: none; border-color: #b9c6dc; }
.action { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--line); }
.action:last-child { border-bottom: 0; }
.action.done { opacity: .5; }
.action .tag { flex: none; min-width: 120px; }
.analysis { white-space: pre-wrap; line-height: 1.6; }

@media (max-width: 960px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .g-main { grid-template-columns: 1fr !important; }
  .side { position: static; height: auto; padding: 12px; overflow: visible; }
  .nav { display: flex; overflow-x: auto; gap: 4px; }
  .nav-group { display: none; }
  .nav a { white-space: nowrap; }
  .side form.logout-f { position: static; width: auto; background: transparent; border: 0; padding: 8px 0 0; }
  .brand { padding-bottom: 10px; }
  .topbar { padding: 10px 16px; position: static; }
  .content { padding: 18px 16px 50px; }
  .g4, .g3, .g2 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .g4, .g3, .g2 { grid-template-columns: 1fr; }
  .store-pick select { min-width: 0; flex: 1; }
  .topbar { flex-wrap: wrap; }
  .store-pick { width: 100%; margin-left: 0; }
}
