:root {
  --bg: #0e0e10;
  --fg: #f3f3f3;
  --muted: #9a9a9a;
  --accent: #e8c547;
  --card: #1a1a1d;
  --border: #2a2a2e;
  --sold: #c0392b;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--fg); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif; }
body.gallery-page { overflow: hidden; height: 100vh; display: flex; flex-direction: column; }
body.gallery-page main { flex: 1; min-height: 0; }
a { color: var(--accent); text-decoration: none; }
header {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 14px 32px; border-bottom: 1px solid var(--border);
}
header h1 { margin: 0; font-weight: 300; letter-spacing: 2px; font-size: 22px; text-transform: uppercase; }
header .sub { color: var(--muted); font-size: 13px; }
.raffle-cta { display: inline-flex; align-items: center; gap: 8px; padding: 12px 18px; font-size: 13px; }
.raffle-cta .price-pill { background: rgba(0,0,0,.2); padding: 2px 8px; border-radius: 100px; font-size: 12px; }

main { padding: 0; display: flex; justify-content: center; align-items: center; }

.gallery {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  grid-template-rows: repeat(9, 1fr);
  gap: 0;
  
  aspect-ratio: 4 / 3;
  width: min(100vw, calc((100vh - 100px) * 4 / 3));
  max-height: calc(100vh - 100px);
}
.site-footer {
  height: 15px; line-height: 15px; padding: 0; margin: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; color: var(--muted); letter-spacing: 1px;
  border-top: 1px solid var(--border); overflow: hidden;
}
.cell {
  position: relative;
  overflow: hidden;
  cursor: pointer;
  background: #000;
}
.cell img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .3s ease; }
.cell:hover img { transform: scale(1.06); }
.cell .num {
  position: absolute; top: 4px; left: 6px;
  font-size: 10px; color: rgba(255,255,255,.7);
  background: rgba(0,0,0,.5); padding: 1px 5px; border-radius: 2px;
}
.cell .price-tag {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,.85));
  color: #fff; padding: 14px 6px 6px; font-size: 11px;
  display: flex; justify-content: space-between; align-items: end;
  opacity: 0; transition: opacity .2s ease;
}
.cell:hover .price-tag { opacity: 1; }
.cell.sold::after {
  content: "VENDIDA"; position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%) rotate(-12deg);
  background: var(--sold); color: white; padding: 4px 12px;
  font-size: 11px; letter-spacing: 2px; font-weight: bold;
  pointer-events: none;
}
.cell.sold[data-sold-type="raffle"]::after {
  content: "SORTEADA";
}

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.92);
  display: none; align-items: center; justify-content: center;
  z-index: 1000; padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--card); max-width: 1320px; width: auto; max-height: 96vh;
  display: grid; grid-template-columns: auto 360px; overflow: hidden;
  border: 1px solid var(--border);
}
.modal .img-wrap { background: #000; display: flex; align-items: center; justify-content: center; max-height: 96vh; }
.modal .img-wrap img { max-width: 100%; max-height: 96vh; object-fit: contain; display: block; }
.modal .info { padding: 32px; overflow-y: auto; }
.modal .info .num { color: var(--muted); font-size: 12px; letter-spacing: 2px; }
.modal .info h2 { margin: 8px 0 16px; font-weight: 400; font-size: 24px; line-height: 1.3; }
.modal .info .desc { color: #d0d0d0; font-size: 14px; line-height: 1.6; min-height: 60px; white-space: pre-wrap; }
.modal .info .price {
  margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--border);
  font-size: 28px; color: var(--accent); font-weight: 300;
}
.modal .info .status { display: inline-block; margin-top: 8px; font-size: 12px; padding: 4px 10px; border-radius: 2px; letter-spacing: 1px; }
.modal .info .status.available { background: #1f6f3e; color: #fff; }
.modal .info .status.sold { background: var(--sold); color: #fff; }

.buy-btn { margin-top: 24px; width: 100%; padding: 14px; font-size: 14px; }
.buy-form { margin-top: 24px; display: flex; flex-direction: column; gap: 10px; }
.buy-form h3 { margin: 0 0 6px; font-weight: 400; font-size: 15px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.buy-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.buy-form input {
  padding: 10px; background: #0e0e10; color: var(--fg);
  border: 1px solid var(--border); font-family: inherit; font-size: 14px;
}
.buy-form input:focus { outline: none; border-color: var(--accent); }
.qty-row { display: flex; align-items: center; gap: 6px; }
.qty-row input[type="number"] {
  width: 70px; text-align: center; font-size: 16px; padding: 8px;
  -moz-appearance: textfield; appearance: textfield;
}
.qty-row input::-webkit-outer-spin-button,
.qty-row input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.qty-btn {
  width: 36px; height: 36px; background: #0e0e10; color: var(--fg);
  border: 1px solid var(--border); cursor: pointer; font-size: 18px;
  display: flex; align-items: center; justify-content: center;
}
.qty-btn:hover { border-color: var(--accent); }
.qty-total { margin-left: 8px; color: var(--accent); font-size: 13px; }
.buy-actions { display: flex; gap: 8px; margin-top: 10px; }
.buy-actions .btn { flex: 1; padding: 12px; }
.buy-error { background: var(--sold); color: #fff; padding: 8px 10px; font-size: 13px; }
.buy-success { padding: 16px; background: rgba(31,111,62,.2); border: 1px solid #1f6f3e; }
.buy-success h3 { margin: 0 0 8px; color: #4ad07b; }
.buy-success p { margin: 6px 0; font-size: 14px; }
.buy-success a { color: black; }
.invoice-preview {
  background: #0e0e10; border: 1px solid var(--border); padding: 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px; line-height: 1.5; color: var(--fg);
  white-space: pre-wrap; word-break: break-word;
  margin: 12px 0; max-height: 260px; overflow-y: auto;
}
.buy-success .hint { font-size: 12px; color: var(--muted); }
.wa-btn { display: block; text-align: center; margin-top: 12px; background: #25d366; color: #000; padding: 14px; text-decoration: none; }
.wa-btn:hover { background: #1ebe5a; }
.modal .close {
  position: absolute; top: 16px; right: 20px; color: #fff; font-size: 32px;
  cursor: pointer; background: none; border: none; line-height: 1;
}
.modal .nav-btn {
  position: absolute; top: 50%; transform: translateY(-50%);
  background: rgba(0,0,0,.5); color: white; border: none;
  font-size: 32px; padding: 12px 18px; cursor: pointer;
}
.modal .nav-btn:hover { background: rgba(0,0,0,.8); }
.modal .nav-prev { left: 12px; }
.modal .nav-next { right: 12px; }

@media (max-width: 800px) {
  header { padding: 14px 16px; flex-wrap: wrap; gap: 4px; }
  header h1 { font-size: 18px; }
  header .sub { font-size: 11px; }
  main { padding: 0; }
  .gallery {
    grid-template-columns: repeat(9, 1fr);
    grid-template-rows: none;
    aspect-ratio: auto;
    height: auto;
  }
  .cell { aspect-ratio: 4 / 3; }
  
  .cell .price-tag { display: none; }
  .cell.sold::after { font-size: 8px; padding: 2px 6px; letter-spacing: 1px; }
  .modal-backdrop { padding: 0; }
  .modal { grid-template-columns: 1fr; max-height: 100vh; height: 100vh; overflow-y: auto; }
  .modal .img-wrap { max-height: 60vh; }
  .modal .img-wrap img { max-height: 60vh; }
  .modal .info { padding: 20px; }
  .modal .info h2 { font-size: 18px; }
  .modal .info .price { font-size: 22px; }
  .modal .close { top: 8px; right: 12px; font-size: 36px; z-index: 2; text-shadow: 0 0 8px #000; }
  .modal .nav-btn { font-size: 24px; padding: 10px 12px; }
}

.admin-wrap { max-width: 1400px; margin: 0 auto; padding: 24px; }
.login-box { max-width: 360px; margin: 80px auto; background: var(--card); padding: 32px; border: 1px solid var(--border); }
.login-box h2 { margin-top: 0; font-weight: 300; }
.login-box input, .form-row input, .form-row textarea {
  width: 100%; padding: 10px; background: #0e0e10; color: var(--fg);
  border: 1px solid var(--border); font-family: inherit; font-size: 14px;
}
.login-box button, .btn {
  background: var(--accent); color: #000; border: none; padding: 10px 18px;
  cursor: pointer; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; font-size: 12px;
}
.btn.secondary { background: transparent; color: var(--fg); border: 1px solid var(--border); }
.error { background: #c0392b; color: white; padding: 10px; margin-bottom: 12px; }
.success { background: #1f6f3e; color: white; padding: 10px; margin-bottom: 12px; }

.admin-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px; margin-top: 16px;
}
.admin-card { background: var(--card); border: 1px solid var(--border); padding: 12px; display: flex; gap: 12px; }
.admin-card img { width: 90px; height: 90px; object-fit: cover; flex-shrink: 0; }
.admin-card .fields { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.admin-card .fields label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.admin-card .fields input, .admin-card .fields textarea {
  padding: 6px 8px; font-size: 13px;
  background: #0e0e10; color: var(--fg);
  border: 1px solid var(--border); font-family: inherit;
}
.admin-card .fields input:focus, .admin-card .fields textarea:focus { outline: none; border-color: var(--accent); }
.admin-card .fields textarea { resize: vertical; min-height: 50px; }
.admin-card .num { font-size: 11px; color: var(--muted); letter-spacing: 1px; }
.admin-card .row { display: flex; gap: 8px; align-items: center; }
.admin-card .row label { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--fg); text-transform: none; letter-spacing: 0; }

.admin-bar {
  position: sticky; top: 0; background: var(--bg); padding: 12px 0;
  display: flex; justify-content: space-between; align-items: center;
  border-bottom: 1px solid var(--border); z-index: 10;
}

.modal-narrow { grid-template-columns: 1fr !important; max-width: 560px; }
.modal-narrow .info { padding: 32px; }

.raffle-section { margin-top: 24px; padding: 20px; background: var(--card); border: 1px solid var(--border); }
.raffle-section h2 { margin: 0 0 16px; font-weight: 300; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.stat { background: #0e0e10; border: 1px solid var(--border); padding: 14px; display: flex; flex-direction: column; gap: 4px; }
.stat .n { font-size: 28px; color: var(--accent); font-weight: 300; }
.stat .l { font-size: 12px; color: var(--muted); }
.raffle-section details { margin-top: 12px; border: 1px solid var(--border); padding: 10px 12px; background: #0e0e10; }
.raffle-section summary { cursor: pointer; font-size: 13px; color: var(--fg); padding: 4px 0; }
.draw-table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 13px; }
.draw-table th, .draw-table td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border); }
.draw-table th { color: var(--muted); font-weight: 500; text-transform: uppercase; font-size: 11px; letter-spacing: 1px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
