/* Pedido conjunto Blackworks — dark charcoal, white text, restrained lime accent. */
:root {
  --bg: #151515;
  --surface: #1f1f1f;
  --surface-2: #2a2a2a;
  --line: #3a3a3a;
  --text: #f4f4f2;
  --muted: #b9b9b4;
  --accent: #c8f04a;
  --accent-ink: #121400;
  --warn: #f2b84b;
  --warn-bg: #2d2412;
  --ok: #8fe3a4;
  --error: #ff8a80;
  --error-bg: #331a18;
  --radius: 12px;
  --tap: 44px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font);
  padding-bottom: env(safe-area-inset-bottom);
}
body.participant { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
@media (min-width: 900px) { body.participant { padding-bottom: 24px; } }

a { color: var(--accent); }
img { max-width: 100%; display: block; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 8px; top: -60px; z-index: 50; background: var(--accent); color: var(--accent-ink);
  padding: 10px 14px; border-radius: 8px; font-weight: 700;
}
.skip-link:focus { top: 8px; }
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Buttons & inputs ------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: var(--tap); min-width: var(--tap); padding: 0 16px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: #5a5a5a; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn-accent { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-accent:hover { filter: brightness(1.05); border-color: var(--accent); }
.btn-ghost { background: transparent; }
.btn-danger { background: transparent; color: var(--error); border-color: #6b3531; }
.btn-block { width: 100%; }
.btn-icon { padding: 0; width: var(--tap); font-size: 1.5rem; line-height: 1; background: transparent; }
.btn-link { background: none; border: 0; color: var(--accent); text-decoration: underline; padding: 0 4px; min-height: var(--tap); font: inherit; cursor: pointer; }

input, textarea, select {
  font: inherit; color: var(--text); background: #101010; border: 1px solid var(--line);
  border-radius: 10px; min-height: var(--tap); padding: 8px 12px; width: 100%;
}
textarea { min-height: 88px; resize: vertical; }
label { display: block; font-weight: 600; margin: .75rem 0 .25rem; }
.form-error { color: var(--error); min-height: 1.5em; margin: .25rem 0; }

/* Layout ---------------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 16px; background: rgba(21,21,21,.96); border-bottom: 1px solid var(--line);
}
.brand { display: flex; flex-direction: column; min-width: 0; }
.brand-title { font-weight: 800; letter-spacing: .02em; text-transform: uppercase; font-size: 1rem; line-height: 1.5; margin: 0; }
.brand-sub { color: var(--muted); font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn-order { display: none; }
@media (min-width: 900px) { .btn-order:not([hidden]) { display: inline-flex; } }
.count {
  display: inline-grid; place-items: center; min-width: 26px; height: 26px; padding: 0 6px; border-radius: 13px;
  background: var(--accent-ink); color: var(--accent); font-size: .85rem;
}

.notice {
  margin: 12px 16px 0; padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--muted); font-size: .92rem;
}
.banner {
  margin: 12px 16px 0; padding: 12px 14px; border-radius: var(--radius); background: var(--surface-2);
  border-left: 4px solid var(--accent);
}
.banner.closed { border-left-color: var(--warn); background: var(--warn-bg); }
.banner.error { border-left-color: var(--error); background: var(--error-bg); }

.identity, .previous {
  margin: 12px 16px 0; padding: 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line);
}
.identity-title { font-size: 1.1rem; }
.join-form { display: flex; gap: 8px; }
.join-form input { flex: 1; }

main#catalogo { padding: 0 16px; max-width: 1400px; margin: 0 auto; }
main#catalogo:focus { outline: none; }
.tools { position: sticky; top: 64px; z-index: 10; background: var(--bg); padding: 12px 0 8px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 10px 0 4px; scrollbar-width: thin; }
.chip {
  flex: 0 0 auto; min-height: var(--tap); padding: 0 14px; border-radius: 22px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font: inherit; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
.status { color: var(--muted); margin: 8px 0; min-height: 1.5em; }
.status.error { color: var(--error); }

/* Product grid ----------------------------------------------------------- */
.grid {
  list-style: none; margin: 0; padding: 0; display: grid; gap: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
@media (min-width: 640px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1000px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; } }
@media (min-width: 1300px) { .grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.card {
  display: flex; flex-direction: column; width: 100%; height: 100%; text-align: left; padding: 0; cursor: pointer;
  background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; font: inherit;
}
.card:hover { border-color: #5a5a5a; }
.photo { aspect-ratio: 4 / 5; background: #0e0e0e; width: 100%; overflow: hidden; }
.photo img { width: 100%; height: 100%; object-fit: cover; }
.photo.empty { display: grid; place-items: center; color: var(--muted); font-size: .85rem; }
.card-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card-name { font-weight: 700; font-size: .95rem; line-height: 1.3; text-transform: uppercase; }
.badge {
  display: inline-block; align-self: flex-start; font-size: .75rem; line-height: 1.3; padding: 3px 8px; border-radius: 6px;
  background: var(--warn-bg); color: var(--warn); border: 1px solid #5a4620;
}
.badge.neutral { background: var(--surface-2); color: var(--muted); border-color: var(--line); }
.price { font-weight: 700; }
.price.pending { color: var(--muted); font-weight: 500; font-size: .9rem; }
.in-order { color: var(--accent); font-size: .85rem; font-weight: 600; }

/* Dialogs ----------------------------------------------------------------- */
.dialog {
  width: min(720px, 100vw); max-width: 100vw; max-height: 100dvh; padding: 0; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--bg); color: var(--text);
}
.dialog::backdrop { background: rgba(0,0,0,.72); }
.dialog.small { width: min(440px, 100vw); }
.dialog-inner { padding: 16px; }
.dialog-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  position: sticky; top: -16px; background: var(--bg); padding: 8px 0; margin-top: -8px; z-index: 2;
}
.dialog-head h2 { margin: 0; }
@media (max-width: 640px) {
  .dialog { width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; border: 0; }
  .dialog.small { height: auto; margin: auto 0 0; border-radius: var(--radius) var(--radius) 0 0; }
}
.drawer { margin-right: 0; height: 100dvh; max-height: 100dvh; border-radius: 0; }
@media (min-width: 641px) { .drawer { width: min(520px, 100vw); } }

.pd-layout { display: grid; gap: 16px; }
@media (min-width: 700px) { .pd-layout { grid-template-columns: 1fr 1fr; } }
.gallery-main { aspect-ratio: 4 / 5; background: #0e0e0e; border-radius: 10px; overflow: hidden; }
.gallery-main img { width: 100%; height: 100%; object-fit: cover; }
.thumbs { display: flex; gap: 8px; margin-top: 8px; overflow-x: auto; }
.thumb { width: 56px; height: 70px; flex: 0 0 auto; padding: 0; border: 2px solid transparent; border-radius: 8px; overflow: hidden; background: #0e0e0e; cursor: pointer; }
.thumb[aria-current="true"] { border-color: var(--accent); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
fieldset { border: 0; padding: 0; margin: 12px 0 0; }
legend { font-weight: 700; margin-bottom: 6px; }
.options { display: flex; flex-wrap: wrap; gap: 8px; }
.opt { position: relative; }
.opt input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.opt span {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; min-width: 56px; min-height: var(--tap);
  padding: 4px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); cursor: pointer; font-weight: 700;
}
.opt small { font-weight: 500; font-size: .7rem; color: var(--warn); }
.opt input:checked + span { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.opt input:checked + span small { color: var(--accent-ink); }
.opt input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.qty { display: inline-flex; align-items: center; gap: 4px; }
.qty output, .qty .qv { min-width: 36px; text-align: center; font-weight: 700; }
.caveat { font-size: .88rem; color: var(--muted); border-left: 3px solid var(--warn); padding-left: 10px; margin: 12px 0; }
.stock-line { margin: 8px 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.inline-ok { color: var(--ok); min-height: 1.5em; margin-top: 8px; }

/* Order drawer -------------------------------------------------------------- */
.state-chip { display: inline-block; padding: 4px 10px; border-radius: 8px; font-weight: 700; font-size: .85rem; background: var(--surface-2); }
.state-chip.confirmed { background: #1f3322; color: var(--ok); }
.state-chip.pending { background: var(--warn-bg); color: var(--warn); }
.state-chip.cancelled { background: var(--error-bg); color: var(--error); }
.lines { list-style: none; margin: 12px 0; padding: 0; display: grid; gap: 10px; }
.line { display: grid; grid-template-columns: 64px 1fr; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.line .photo { aspect-ratio: 4 / 5; border-radius: 6px; }
.line-name { font-weight: 700; text-transform: uppercase; font-size: .92rem; }
.line-meta { color: var(--muted); font-size: .88rem; }
.line-controls { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.totals { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 10px; }
.save-state { color: var(--muted); font-size: .9rem; min-height: 1.5em; }
.save-state.error { color: var(--error); }
.success-box { border: 1px solid #2f5d38; background: #16261a; color: var(--ok); padding: 12px; border-radius: 10px; margin: 12px 0; }
.link-box { border: 1px solid var(--line); background: var(--surface); padding: 12px; border-radius: 10px; margin: 16px 0; }
.link-box code, .secret { display: block; word-break: break-all; background: #0c0c0c; padding: 8px; border-radius: 8px; margin: 8px 0; font-size: .85rem; }
details { margin: 12px 0; }
summary { cursor: pointer; min-height: var(--tap); display: flex; align-items: center; font-weight: 600; }

.mobile-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: rgba(21,21,21,.97); border-top: 1px solid var(--line);
}
.mobile-bar .btn { justify-content: space-between; min-height: 52px; }
@media (min-width: 900px) { .mobile-bar { display: none !important; } }

.toast {
  position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60;
  background: #f4f4f2; color: #111; padding: 10px 16px; border-radius: 10px; font-weight: 600; max-width: calc(100vw - 32px);
  opacity: 0; pointer-events: none; transition: opacity .15s;
}
.toast.show { opacity: 1; }
.toast.error { background: var(--error); color: #1a0000; }
@media (min-width: 900px) { .toast { bottom: 24px; } }

.notfound { max-width: 520px; margin: 15vh auto; padding: 0 16px; text-align: center; }

/* Admin ---------------------------------------------------------------------- */
body.admin .panel { max-width: 1200px; margin: 16px auto; padding: 0 16px 48px; }
body.admin .panel.narrow { max-width: 420px; }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 10px 16px; border-bottom: 1px solid var(--line); max-width: 1200px; margin: 0 auto; }
.tab { flex: 0 0 auto; min-height: var(--tap); padding: 0 14px; border-radius: 10px; border: 1px solid transparent; background: none; color: var(--text); font: inherit; cursor: pointer; }
.tab[aria-current="page"] { background: var(--surface-2); border-color: var(--line); font-weight: 700; }
body.admin #admin-status { max-width: 1200px; margin: 8px auto; padding: 0 16px; }
.card-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 12px 0; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.row > * { flex: 0 1 auto; }
.row .grow { flex: 1 1 220px; }
.row label { margin-top: 0; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; }
.table-wrap { overflow-x: auto; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); font-size: .8rem; }
.pill.ok { background: #1f3322; color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.err { background: var(--error-bg); color: var(--error); }
.santi-text { width: 100%; min-height: 320px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .95rem; }
.switch { display: flex; align-items: center; gap: 10px; }
.switch input { width: 24px; height: 24px; min-height: 0; accent-color: var(--accent); }
.order-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin: 10px 0; background: var(--surface); }
.order-card h3 { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.order-card ul { margin: 6px 0; padding-left: 20px; }
