:root {
  --ink: #16130f;
  --ink-soft: #4a433a;
  --muted: #6b6156;
  --paper: #f7f5f0;
  --panel: #fffefb;
  --line: #e5e0d3;
  --line-strong: #cfc6ac;
  --gold: #b8912a;
  --gold-deep: #8f6f1c;
  --gold-bg: #f6efd8;
  --brick: #8b3a3a;
  --brick-bg: #f3e6e2;
  --signal-bg: #eef1e6;
  --signal-text: #4a6b3a;

  --font-display: 'Space Grotesk', 'Segoe UI', sans-serif;
  --font-body: 'IBM Plex Sans', 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html { color-scheme: light; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--gold-deep); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---------- Nameplate header ---------- */

header.topbar { background: var(--ink); border-bottom: 3px solid var(--gold); }

.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 84px;
  gap: 20px;
  flex-wrap: wrap;
}

.mark { display: flex; align-items: center; gap: 10px; }
.mark img { height: 64px; width: auto; display: block; }
.mark .wordmark {
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: #b8b0a0;
}

.topbar nav { display: flex; align-items: center; gap: 18px; font-size: 0.87rem; color: #cfcbc0; }
.topbar nav a { color: #cfcbc0; }
.topbar nav a:hover { color: #fff; }
.topbar nav .who { color: #8f8a7d; }

.panel-btn {
  background: transparent;
  border: 1px solid #4a4438;
  color: #cfcbc0;
  font: inherit;
  font-size: 0.85rem;
  padding: 6px 13px;
  border-radius: 3px;
  cursor: pointer;
}
.panel-btn:hover { border-color: var(--gold); color: #fff; }

/* ---------- Layout ---------- */

main { max-width: 1180px; margin: 0 auto; padding: 32px 24px 64px; }
main.center-column { max-width: 420px; padding-top: 64px; }

.page-head { margin-bottom: 24px; }
.page-head h1 { font-family: var(--font-display); font-size: 1.6rem; font-weight: 600; letter-spacing: -0.01em; margin: 0 0 4px; }
.page-head p { margin: 0; color: var(--muted); font-size: 0.93rem; }

/* ---------- Auth panel ---------- */

.plate { background: var(--panel); border: 1px solid var(--line-strong); border-top: 3px solid var(--gold); border-radius: 2px; padding: 30px 32px; }
.plate h1 { font-family: var(--font-display); font-size: 1.4rem; font-weight: 600; margin: 0 0 6px; }
.plate .lede { color: var(--muted); font-size: 0.9rem; margin: 0 0 24px; line-height: 1.5; }

.field { margin-bottom: 16px; }
.field:last-of-type { margin-bottom: 0; }
.field label { display: block; font-size: 0.78rem; font-weight: 500; color: var(--ink-soft); margin-bottom: 5px; }

input[type="text"], input[type="email"], input[type="password"], input[type="search"],
input[type="number"], input[type="date"], input[type="file"], select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  font: inherit;
  font-size: 0.94rem;
  background: #fff;
  color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(184, 145, 42, 0.16); }

button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--ink); color: #fff; border: none; padding: 10px 18px; border-radius: 3px;
  font: inherit; font-size: 0.92rem; font-weight: 500; cursor: pointer;
}
button:hover, .btn:hover { background: #2a251c; text-decoration: none; }
.btn.gold { background: var(--gold-deep); }
.btn.gold:hover { background: var(--gold); }
.btn.outline { background: transparent; color: var(--ink-soft); border: 1px solid var(--line-strong); }
.btn.outline:hover { background: var(--gold-bg); color: var(--gold-deep); }
.btn.danger { background: var(--brick); }
.btn.danger:hover { background: #742f2f; }
.btn.small { padding: 6px 12px; font-size: 0.82rem; }

form.stack { margin-top: 20px; }
form.stack button[type="submit"] { width: 100%; margin-top: 22px; }

.plate-links { display: flex; justify-content: space-between; margin-top: 20px; font-size: 0.85rem; }
.plate-links a { color: var(--muted); }
.plate-links a:hover { color: var(--gold-deep); }

/* ---------- Notices ---------- */

.notice { padding: 11px 15px; border-radius: 3px; font-size: 0.87rem; margin-bottom: 18px; border-left: 3px solid transparent; }
.notice.ok { background: var(--signal-bg); color: var(--signal-text); border-color: #6b8a52; }
.notice.err { background: var(--brick-bg); color: var(--brick); border-color: var(--brick); }

/* ---------- Banners ---------- */

.banner-strip { margin-bottom: 26px; border-radius: 3px; overflow: hidden; border: 1px solid var(--line); }
.banner-strip a, .banner-strip .banner-slide { display: block; }
.banner-strip img { width: 100%; display: block; }

/* ---------- Filter strip ---------- */

.controls { display: flex; flex-wrap: wrap; align-items: end; gap: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 3px; padding: 16px 18px; margin-bottom: 26px; }
.controls .field { margin-bottom: 0; flex: 1 1 200px; min-width: 160px; }
.controls .actions { display: flex; gap: 8px; }

.empty { text-align: center; padding: 70px 20px; color: var(--muted); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.empty strong { color: var(--ink); display: block; margin-bottom: 6px; font-size: 1.05rem; }

/* ---------- Product list ---------- */

.product-list { border-top: 1px solid var(--line); }
.product-row { display: grid; grid-template-columns: 56px minmax(0, 1fr) 130px; gap: 16px; align-items: center; padding: 14px 4px; border-bottom: 1px solid var(--line); }
.product-row.clickable { cursor: pointer; }
.product-row.clickable:hover { background: var(--gold-bg); }

.thumb { width: 56px; height: 56px; border: 1px solid var(--line); border-radius: 2px; background: #fff; display: flex; align-items: center; justify-content: center; overflow: hidden; flex-shrink: 0; }
.thumb img { width: 100%; height: 100%; object-fit: contain; }
.thumb.large { width: 220px; height: 220px; }
.thumb .no-img { font-size: 0.62rem; color: #b6b0a2; text-align: center; letter-spacing: 0.02em; }

.info { min-width: 0; }
.brand { font-size: 0.72rem; font-weight: 600; letter-spacing: 0.04em; color: var(--gold-deep); text-transform: uppercase; }
.name { display: block; font-size: 0.98rem; font-weight: 500; color: var(--ink); line-height: 1.35; margin-top: 1px; }
.specs { font-size: 0.8rem; color: var(--muted); margin-top: 3px; font-family: var(--font-display); letter-spacing: 0.01em; }
.specs span + span { margin-left: 10px; padding-left: 10px; border-left: 1px solid var(--line-strong); }

.price-col { text-align: right; }
.price { font-family: var(--font-display); font-size: 1.15rem; font-weight: 600; color: var(--gold-deep); white-space: nowrap; }
.price.large { font-size: 1.7rem; }
.price.unavailable { font-family: var(--font-body); font-size: 0.85rem; font-weight: 400; color: var(--muted); }

.avail { display: inline-flex; align-items: center; gap: 6px; font-size: 0.76rem; padding: 3px 9px; border-radius: 20px; margin-top: 6px; }
.avail.EM_ESTOQUE { background: var(--signal-bg); color: var(--signal-text); }
.avail.ULTIMAS_UNIDADES { background: var(--gold-bg); color: var(--gold-deep); }
.avail.VERIFICAR_ESTOQUE { background: #eee; color: var(--muted); }
.avail-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ---------- Pagination ---------- */

.pager { display: flex; justify-content: center; gap: 6px; margin-top: 30px; font-family: var(--font-display); }
.pager a, .pager span { min-width: 30px; padding: 6px 8px; text-align: center; border: 1px solid var(--line); border-radius: 2px; font-size: 0.85rem; color: var(--ink-soft); }
.pager .current { background: var(--ink); color: #fff; border-color: var(--ink); }
.pager a:hover { border-color: var(--gold); text-decoration: none; }
.pager .disabled { color: var(--line-strong); }
.pager .ellipsis { border: none; color: var(--muted); padding: 6px 2px; }
.pager-hint { text-align: center; font-size: 0.8rem; color: var(--muted); margin-top: 10px; }

/* ---------- Product detail page ---------- */

.product-detail { display: grid; grid-template-columns: 260px 1fr; gap: 32px; }
.product-detail .meta-block { margin-top: 18px; }
.product-detail h2 { font-family: var(--font-display); font-size: 1rem; font-weight: 600; margin: 22px 0 8px; }
.product-detail p { margin: 0; color: var(--ink-soft); line-height: 1.6; }

/* Descrição/especificações vêm como HTML do editor rico do Bling, com estilo inline próprio
   (fonte, tamanho) -- só garantimos que não estoure a largura e que imagem embutida não vaze. */
.rich-text { color: var(--ink-soft); line-height: 1.6; max-width: 100%; overflow-wrap: break-word; }
.rich-text img { max-width: 100%; height: auto; }
.rich-text table { max-width: 100%; }

/* ---------- Admin ---------- */

.data-table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); }
.data-table th, .data-table td { padding: 11px 14px; border-bottom: 1px solid var(--line); text-align: left; font-size: 0.88rem; vertical-align: middle; }
.data-table th { font-family: var(--font-display); font-weight: 600; font-size: 0.72rem; letter-spacing: 0.04em; color: var(--muted); text-transform: uppercase; background: var(--paper); }
.data-table tr:last-child td { border-bottom: none; }
.data-table img.thumb-sm { width: 44px; height: 44px; object-fit: cover; border-radius: 2px; border: 1px solid var(--line); }

.tag { display: inline-flex; align-items: center; gap: 5px; font-size: 0.78rem; font-weight: 500; padding: 3px 9px; border-radius: 20px; }
.tag.active { background: var(--signal-bg); color: var(--signal-text); }
.tag.blocked { background: var(--brick-bg); color: var(--brick); }

.stat-strip { display: flex; gap: 1px; background: var(--line); border: 1px solid var(--line); margin-bottom: 28px; }
.stat { flex: 1; background: var(--panel); padding: 18px 20px; }
.stat .label { font-size: 0.76rem; color: var(--muted); }
.stat .value { font-family: var(--font-display); font-size: 1.5rem; font-weight: 600; margin-top: 3px; }
.stat .value.warn { color: var(--brick); }

.section { background: var(--panel); border: 1px solid var(--line); border-radius: 2px; padding: 22px 24px; margin-bottom: 20px; }
.section h2 { font-family: var(--font-display); font-size: 1.05rem; font-weight: 600; margin: 0 0 12px; }
.section p { margin: 0 0 14px; color: var(--ink-soft); font-size: 0.9rem; }
.section form { display: inline-block; }
.section .inline-form { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.section .inline-form .field { margin-bottom: 0; flex: 1 1 140px; }

.admin-nav { display: flex; gap: 4px; margin-bottom: 22px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.admin-nav a { padding: 10px 4px; font-size: 0.88rem; color: var(--muted); border-bottom: 2px solid transparent; margin-right: 18px; }
.admin-nav a.active { color: var(--ink); border-color: var(--gold); font-weight: 500; }
.admin-nav a:hover { color: var(--ink); text-decoration: none; }

.log-line { font-family: var(--font-display); font-size: 0.78rem; padding: 7px 0; border-bottom: 1px solid var(--line); color: var(--ink-soft); }
.log-line .ev { color: var(--gold-deep); font-weight: 600; margin-right: 8px; }

@media (max-width: 640px) {
  main { padding: 22px 16px 48px; }
  .plate { padding: 24px 20px; }
  .controls { flex-direction: column; align-items: stretch; }
  .product-row { grid-template-columns: 48px 1fr; grid-template-rows: auto auto; }
  .product-row .price-col { grid-column: 1 / -1; text-align: left; padding-left: 64px; margin-top: -4px; }
  .stat-strip { flex-direction: column; }
  .product-detail { grid-template-columns: 1fr; }
  .thumb.large { width: 100%; height: auto; aspect-ratio: 1/1; }
}
