:root {
  --bg: #f4f1ea;
  --card: #ffffff;
  --ink: #2c2c2c;
  --muted: #777;
  --brand: #7a4019;
  --brand-dark: #5c2f12;
  --accent: #2e7d32;
  --danger: #c62828;
  --line: #e3ddd0;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}

a { color: var(--brand); }

header.topbar {
  background: var(--brand);
  color: #fff;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 50;
}
header.topbar h1 { margin: 0; font-size: 1.25rem; letter-spacing: .5px; }
header.topbar .links a { color: #fff; margin-left: 18px; text-decoration: none; opacity: .9; }
header.topbar .links a:hover { opacity: 1; text-decoration: underline; }

.container { max-width: 1100px; margin: 0 auto; padding: 24px; }

.cart-btn {
  background: var(--brand-dark);
  color: #fff;
  border: none;
  border-radius: 30px;
  padding: 9px 18px;
  cursor: pointer;
  font-size: .95rem;
}
.cart-btn .count {
  background: #fff;
  color: var(--brand-dark);
  border-radius: 50%;
  padding: 1px 8px;
  margin-left: 6px;
  font-weight: 700;
  font-size: .85rem;
}

/* Grade de livros */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
}
.book {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.book .cover {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  background: #ece5d8;
}
.book .cover.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: .85rem;
  text-align: center;
  padding: 10px;
}
.book .body { padding: 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.book .title { font-weight: 700; font-size: 1rem; }
.book .author { color: var(--muted); font-size: .85rem; }
.book .price { color: var(--brand-dark); font-weight: 700; font-size: 1.15rem; margin-top: 4px; }
.book .stock { font-size: .8rem; color: var(--muted); }
.book .stock.out { color: var(--danger); font-weight: 600; }

.qty-row { display: flex; align-items: center; gap: 8px; margin-top: auto; padding-top: 10px; }
.qty-row input { width: 60px; padding: 6px; border: 1px solid var(--line); border-radius: 8px; }

button.primary {
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 9px 14px;
  cursor: pointer;
  font-size: .9rem;
  font-weight: 600;
}
button.primary:hover { background: var(--brand-dark); }
button.primary:disabled { background: #bbb; cursor: not-allowed; }

button.ghost {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
}
button.success { background: var(--accent); color: #fff; border: none; border-radius: 8px; padding: 8px 14px; cursor: pointer; font-weight: 600; }
button.warn { background: var(--danger); color: #fff; border: none; border-radius: 8px; padding: 8px 14px; cursor: pointer; font-weight: 600; }

/* Modal / Drawer */
.overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, .45);
  display: none;
  z-index: 100;
}
.overlay.open { display: block; }

.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 420px;
  max-width: 92vw;
  background: var(--bg);
  box-shadow: -4px 0 20px rgba(0,0,0,.2);
  transform: translateX(100%);
  transition: transform .25s ease;
  z-index: 110;
  display: flex;
  flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer header {
  padding: 18px;
  background: var(--brand);
  color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.drawer header h2 { margin: 0; font-size: 1.1rem; }
.drawer .content { padding: 18px; overflow-y: auto; flex: 1; }
.drawer .footer { padding: 18px; border-top: 1px solid var(--line); background: var(--card); }
.close-x { background: none; border: none; color: #fff; font-size: 1.5rem; cursor: pointer; }

.cart-item {
  display: flex; gap: 12px;
  background: var(--card);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 10px;
  align-items: center;
}
.cart-item img { width: 48px; height: 64px; object-fit: cover; border-radius: 6px; background: #ece5d8; }
.cart-item .info { flex: 1; font-size: .9rem; }
.cart-item .info small { color: var(--muted); }
.cart-item .remove { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 1.2rem; }

.total-line {
  display: flex; justify-content: space-between;
  font-size: 1.2rem; font-weight: 700; margin: 10px 0;
}

/* Formulários */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 5px; }
.field input, .field textarea {
  width: 100%; padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px; font-size: .95rem;
  background: #fff;
}
.field input[type="file"] { padding: 7px; }

.pix-box {
  background: #fff7ee;
  border: 1px dashed var(--brand);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 12px;
}
.pix-box .key {
  font-family: monospace;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  word-break: break-all;
  display: flex; justify-content: space-between; gap: 8px; align-items: center;
}
.pix-box .amount { font-weight: 700; color: var(--brand-dark); font-size: 1.05rem; }
.copy-btn { background: var(--brand); color:#fff; border:none; border-radius:6px; padding:4px 10px; cursor:pointer; font-size:.8rem; white-space: nowrap; }

.msg { padding: 12px 14px; border-radius: 8px; margin: 10px 0; font-size: .9rem; }
.msg.error { background: #fdecea; color: var(--danger); border: 1px solid #f5c6cb; }
.msg.ok { background: #e8f5e9; color: var(--accent); border: 1px solid #c8e6c9; }

.thanks {
  text-align: center;
  padding: 30px 16px;
}
.thanks .check { font-size: 3rem; color: var(--accent); }
.thanks h2 { color: var(--brand-dark); }

.empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* ---------- Admin ---------- */
.tabs { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.tabs button {
  background: var(--card); border: 1px solid var(--line);
  padding: 9px 18px; border-radius: 30px; cursor: pointer; font-weight: 600;
}
.tabs button.active { background: var(--brand); color: #fff; border-color: var(--brand); }

table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); font-size: .9rem; vertical-align: top; }
th { background: #efe8da; }
tr:last-child td { border-bottom: none; }

.badge { padding: 3px 10px; border-radius: 20px; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.badge.pendente { background: #fff3cd; color: #856404; }
.badge.confirmado { background: #d4edda; color: #155724; }
.badge.nao_confirmado { background: #f8d7da; color: #721c24; }

.card-form {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 24px;
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }

.login-box {
  max-width: 360px; margin: 80px auto;
  background: var(--card); padding: 30px;
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.login-box h2 { margin-top: 0; color: var(--brand-dark); }

.thumb-admin { width: 44px; height: 58px; object-fit: cover; border-radius: 4px; background: #ece5d8; }
.proof-thumb { width: 70px; height: 70px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); margin: 2px; }
.profit { color: var(--accent); font-weight: 600; }
.order-items { margin: 0; padding-left: 18px; font-size: .85rem; }

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  table { font-size: .8rem; }
}
