/* =====================================================================
   Shopee Auto — painel (design inspirado no Mercado Livre)
   Tema claro, amarelo/azul, cards arredondados e responsivo.
   ===================================================================== */

:root {
  --ml-yellow: #ffe600;
  --ml-yellow-soft: #fff9bf;
  --ml-blue: #3483fa;
  --ml-blue-dark: #2768cf;
  --ml-blue-soft: #eaf1ff;

  --bg: #eef1f6;
  --surface: #ffffff;
  --surface-2: #f6f7fa;
  --border: #e4e8f0;
  --text: #1b1f27;
  --muted: #6b7280;

  --green: #00a650;
  --yellow: #f5a623;
  --red: #e53935;

  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 10px 30px -18px rgba(16, 24, 40, .35);
  --shadow-hover: 0 2px 6px rgba(16, 24, 40, .06), 0 18px 40px -20px rgba(16, 24, 40, .40);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(255, 230, 0, .20), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(52, 131, 250, .12), transparent 55%),
    var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

/* ------------------------------- topbar ------------------------------ */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  background: rgba(255, 255, 255, .86);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
  background: linear-gradient(90deg, var(--ml-yellow), #ffd400 40%, var(--ml-blue));
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }

.brand-logo {
  height: 46px;
  width: 46px;
  border-radius: 50%;
  object-fit: cover;
  background: #000;
  box-shadow: 0 6px 16px -8px rgba(255, 210, 0, .9);
}

.brand-name {
  font-size: 23px;
  font-weight: 900;
  letter-spacing: -1px;
  line-height: 1;
  color: var(--text);
  user-select: none;
}

.brand-name em {
  font-style: normal;
  color: #e5a700;
  text-shadow: 0 1px 0 rgba(0, 0, 0, .08);
}

.login-logo {
  width: 132px;
  height: 132px;
  border-radius: 50%;
  object-fit: cover;
  background: #000;
  box-shadow: 0 18px 40px -18px rgba(0, 0, 0, .55);
}

.login-brand { display: flex; justify-content: center; margin-bottom: 18px; }

.logo {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: linear-gradient(145deg, var(--ml-yellow), #ffd000);
  font-size: 22px;
  box-shadow: 0 6px 16px -8px rgba(255, 210, 0, .9);
}

.brand h1 { margin: 0; font-size: 18px; letter-spacing: -.2px; }

.subtitle { color: var(--muted); font-size: 12px; }

.topbar-status { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  white-space: nowrap;
}

.badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  opacity: .8;
}

.badge.ok { color: var(--green); background: #eafaf1; border-color: #bfe9d3; }
.badge.warn { color: #a86b00; background: #fff7e0; border-color: #ffe2a8; }
.badge.err { color: var(--red); background: #ffeceb; border-color: #ffc9c6; }

/* ------------------------------- layout ------------------------------ */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 380px) minmax(0, 1fr);
  gap: 22px;
  padding: 22px 24px 40px;
  align-items: start;
  max-width: 1500px;
  margin: 0 auto;
}

.sidebar { min-width: 0; }
.content { min-width: 0; }

@media (min-width: 1025px) {
  .sidebar { position: sticky; top: 86px; }
}

/* -------------------------------- card ------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
  transition: box-shadow .18s ease, transform .18s ease;
}

.card:hover { box-shadow: var(--shadow-hover); }

.card h2 {
  margin: 0 0 14px;
  font-size: 15px;
  letter-spacing: -.2px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card h2::after {
  content: "";
  flex: 1;
  height: 3px;
  max-width: 46px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--ml-yellow), transparent);
}

.sub {
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .9px;
  margin: 16px 0 8px;
  border-top: 1px dashed var(--border);
  padding-top: 12px;
}

.card .sub:first-of-type { border-top: none; padding-top: 0; margin-top: 0; }

/* ------------------------------- campos ------------------------------ */

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }

.field span { font-size: 12px; font-weight: 600; color: var(--muted); }

.field input,
.field select,
.field textarea,
input,
select,
textarea {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

.field input,
.field select,
.field textarea,
textarea { width: 100%; }

.field textarea,
textarea { resize: vertical; min-height: 84px; line-height: 1.45; }

.field input:focus,
.field select:focus,
.field textarea:focus,
textarea:focus,
select:focus {
  outline: none;
  background: #fff;
  border-color: var(--ml-blue);
  box-shadow: 0 0 0 3px rgba(52, 131, 250, .18);
}

select[multiple] {
  padding: 6px;
  min-height: 150px;
}

select[multiple] option {
  padding: 8px 10px;
  border-radius: 8px;
  margin-bottom: 2px;
}

select[multiple] option:checked {
  background: var(--ml-blue-soft) linear-gradient(0deg, var(--ml-blue-soft), var(--ml-blue-soft));
  color: var(--ml-blue-dark);
  font-weight: 600;
}

code {
  background: var(--ml-yellow-soft);
  border: 1px solid #f2e58a;
  border-radius: 6px;
  padding: 1px 5px;
  font-size: 12px;
}

/* ------------------------------- ícones ------------------------------ */

.ico {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  color: inherit;
}

.card h2 .ico { color: var(--ml-blue); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }

.btn svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.1;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn svg.filled { fill: currentColor; stroke: none; }

.btn-ico {
  width: 34px;
  height: 34px;
  padding: 0;
  flex: 0 0 34px;
}

.actions-cell {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: nowrap;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin: 14px 2px 4px;
}

.pager-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.pager-size { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }

.pager-size select { width: auto; padding: 6px 8px; }

.pager .btn { width: auto; }

.logo svg {
  width: 22px;
  height: 22px;
  stroke: #7a5c00;
  fill: none;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.badge.ok::before { animation: pulse 2.2s ease-in-out infinite; }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0, 166, 80, .45); }
  50% { box-shadow: 0 0 0 5px rgba(0, 166, 80, 0); }
}

.muted.ok { color: var(--green); font-weight: 600; }
.muted.warn { color: #a86b00; font-weight: 600; }
.muted.err { color: var(--red); font-weight: 600; }

/* ------------------------------- botões ------------------------------ */

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: center; }

.row-status { grid-template-columns: auto 1fr; gap: 12px; align-items: center; }
.row-status .muted { font-size: 12px; line-height: 1.4; }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 10px 0; }

.btn {
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: transform .12s ease, background .15s ease, box-shadow .15s ease, border-color .15s ease;
  white-space: nowrap;
}

.btn:active { transform: translateY(1px) scale(.995); }

.btn.primary {
  background: var(--ml-blue);
  color: #fff;
  box-shadow: 0 8px 18px -12px rgba(52, 131, 250, .9);
}

.btn.primary:hover { background: var(--ml-blue-dark); box-shadow: 0 12px 22px -12px rgba(52, 131, 250, .95); }

.btn.ghost {
  background: #fff;
  color: var(--text);
  border-color: var(--border);
}

.btn.ghost:hover { background: var(--surface-2); border-color: #d6dbe6; }

.btn.danger {
  background: #fff;
  color: var(--red);
  border-color: #ffd3d0;
}

.btn.danger:hover { background: #fff2f1; border-color: #ffb8b3; }

.btn.small { padding: 6px 10px; font-size: 12px; border-radius: 10px; }

.btn:disabled { opacity: .55; cursor: not-allowed; }

.test-btn { margin-bottom: 6px; }

/* ----------------------------- whatsapp ------------------------------ */

.wa-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 12px;
}

.wa-status::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 4px rgba(107, 114, 128, .12);
}

.wa-status.connected { color: var(--green); background: #eafaf1; border-color: #bfe9d3; }
.wa-status.waiting_qr { color: #a86b00; background: #fff7e0; border-color: #ffe2a8; }
.wa-status.error { color: var(--red); background: #ffeceb; border-color: #ffc9c6; }

.qr-box {
  display: grid;
  place-items: center;
  gap: 8px;
  padding: 14px;
  border-radius: var(--radius-sm);
  background:
    linear-gradient(135deg, rgba(255, 230, 0, .18), rgba(52, 131, 250, .10)),
    #fff;
  border: 1px dashed #d9dee8;
  margin-bottom: 12px;
}

.qr-box img { width: 190px; height: 190px; border-radius: 10px; background: #fff; }
.qr-box p { margin: 0; color: var(--muted); font-size: 12px; }

/* ------------------------------- ofertas ----------------------------- */

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.toolbar h2 { margin: 0; }

.toolbar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-left: auto;
}

.toolbar-actions > * { flex: 1 1 150px; min-width: 130px; width: auto; }
.toolbar-actions .btn { flex: 0 0 auto; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }

.filters > * { flex: 1 1 150px; min-width: 130px; width: auto; }

.filters input,
.filters select { min-width: 130px; }

.muted { color: var(--muted); font-size: 12px; }

.error { color: var(--red); font-weight: 600; }

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
}

.table-wrap table { width: 100%; border-collapse: collapse; min-width: 760px; }

.table-wrap th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--muted);
  background: var(--surface-2);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
}

.table-wrap td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table-wrap tr:last-child td { border-bottom: none; }
.table-wrap tbody tr:hover { background: #fbfcfe; }
.table-wrap.small table { min-width: 480px; }

.prod-cell { display: flex; align-items: center; gap: 10px; min-width: 240px; }
.prod-cell img { width: 38px; height: 38px; border-radius: 10px; object-fit: cover; background: var(--surface-2); }
.prod-cell span { font-weight: 600; }

/* colunas numericas em uma linha so (o titulo pode quebrar) */
.table-wrap td:nth-child(n + 3),
.table-wrap th:nth-child(n + 3) { white-space: nowrap; }

.table-wrap td:nth-child(2) { min-width: 260px; }

.price-old { color: var(--muted); text-decoration: line-through; font-size: 12px; }
.price-new { font-weight: 800; color: var(--text); }

.commission { font-weight: 700; color: var(--ml-blue-dark); }

.tag {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .3px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
}

.tag.gold { background: linear-gradient(135deg, #fff4c2, #ffe680); border-color: #f0d357; color: #7a5c00; }
.tag.hot { background: #ffeceb; border-color: #ffc9c6; color: #c62828; }
.tag.good { background: #eafaf1; border-color: #bfe9d3; color: #007a3d; }
.tag.weak { background: var(--surface-2); color: var(--muted); }
.tag.src-tag { background: var(--ml-blue-soft); border-color: #cfe0ff; color: var(--ml-blue-dark); }

.empty {
  padding: 40px 16px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed #d9dee8;
  border-radius: var(--radius-sm);
  background: #fff;
}

/* --------------------------- comissão por cat ------------------------ */

.cr-list { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }

.cr-item {
  display: grid;
  grid-template-columns: 1fr 90px auto;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.cr-empty { color: var(--muted); font-size: 12px; }

/* ------------------------------- modal ------------------------------- */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, .45);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 50;
}

.modal-card {
  width: min(680px, 100%);
  max-height: 88vh;
  overflow: auto;
  background: #fff;
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 30px 60px -20px rgba(16, 24, 40, .45);
}

.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }

.copy-preview {
  width: 100%;
  min-height: 190px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  white-space: pre-wrap;
}

.bulk-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }

/* ------------------------------- toast ------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  padding: 12px 18px;
  border-radius: 14px;
  background: #12161f;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 18px 40px -18px rgba(0, 0, 0, .6);
  z-index: 100;
  max-width: min(560px, 92vw);
  text-align: center;
  animation: toast-in .18s ease;
}

.toast.ok { border-left: 4px solid var(--green); }
.toast.err { border-left: 4px solid var(--red); }

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.hidden { display: none !important; }

body.travado { overflow: hidden; }

/* ------------------------------- login ------------------------------- */

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    radial-gradient(900px 420px at 15% 0%, rgba(255, 230, 0, .28), transparent 60%),
    radial-gradient(700px 420px at 100% 10%, rgba(52, 131, 250, .18), transparent 55%),
    var(--bg);
}

.login-card {
  width: min(380px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 24px;
  box-shadow: 0 30px 70px -24px rgba(16, 24, 40, .45);
  display: flex;
  flex-direction: column;
}

.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.login-brand h1 { margin: 0; font-size: 19px; letter-spacing: -.2px; }
.login-brand .logo { width: 44px; height: 44px; }

.login-card .btn { margin-top: 6px; }
.login-card .error { min-height: 18px; margin: 10px 0 0; }

/* ---------------------------- responsivo ----------------------------- */

@media (max-width: 1280px) {
  .table-wrap table { min-width: 640px; }
  .table-wrap th, .table-wrap td { padding: 8px 10px; }
  .prod-cell { min-width: 0; }
}

@media (max-width: 1024px) {
  .layout { grid-template-columns: 1fr; padding: 16px 16px 32px; gap: 16px; }
  .sidebar { position: static; }
}

@media (max-width: 640px) {
  body { font-size: 13.5px; }

  .topbar { padding: 12px 14px; flex-wrap: wrap; }
  .brand h1 { font-size: 16px; }
  .brand-name { font-size: 20px; }
  .logo { width: 36px; height: 36px; font-size: 19px; }
  .topbar-status { width: 100%; justify-content: flex-start; }
  .badge { font-size: 11px; padding: 5px 10px; }

  .layout { padding: 12px 12px 28px; }
  .card { padding: 14px; border-radius: 16px; }
  .card h2 { font-size: 14px; }

  .row { grid-template-columns: 1fr; }
  .btn-row { display: grid; grid-template-columns: 1fr 1fr; }
  .btn { width: 100%; }

  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar-actions { margin-left: 0; }
  .filters { flex-direction: column; }
  .filters input, .filters select { min-width: 0; width: 100%; }

  .cr-item { grid-template-columns: 1fr; }
  .modal-card { padding: 16px; border-radius: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
