:root {
  --bg: #1b1014;
  --bg-2: #27161c;
  --card: #2f1c24;
  --line: rgba(243, 193, 92, 0.28);
  --gold: #f3c15c;
  --gold-2: #ffe7a8;
  --rose: #e8a0b0;
  --wine: #8b2e45;
  --ink: #fff7ee;
  --muted: #e3cfc0;
  --shadow: 0 28px 70px rgba(40, 8, 18, 0.45);
  --font-serif: "Cormorant Garamond", "Times New Roman", serif;
  --font-sans: "Outfit", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  color: var(--ink);
  background:
    radial-gradient(1000px 620px at 8% -12%, rgba(243, 193, 92, 0.28), transparent 58%),
    radial-gradient(900px 540px at 100% 0%, rgba(232, 160, 176, 0.22), transparent 52%),
    linear-gradient(180deg, #24141a 0%, #1b1014 45%, #140c10 100%);
  font-family: var(--font-sans);
}
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; }
.wrap { width: min(1180px, calc(100% - 28px)); margin: 0 auto; padding-bottom: 120px; }
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 0 10px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}
.brand img { width: 52px; height: 52px; object-fit: contain; }
.brand strong { display: block; font-family: var(--font-serif); font-size: 1.35rem; }
.brand em { display: block; color: var(--muted); font-style: normal; font-size: 0.82rem; }
.btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--gold-2), var(--gold));
  color: #1b1014;
  font-weight: 600;
  padding: 12px 18px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn-danger { background: #8b2e45; color: #fff; }
.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card, .sheet-card, .form-wide {
  width: min(460px, 100%);
  background: rgba(47, 28, 36, 0.88);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 28px;
  box-shadow: var(--shadow);
}
.form-wide { width: min(640px, 100%); margin: 16px auto 48px; }
h1, h2, h3 { font-family: var(--font-serif); font-weight: 600; margin: 18px 0 8px; }
.lede, .fine, .lock-note { color: var(--muted); line-height: 1.55; }
.lock-note {
  border: 1px dashed var(--line);
  border-radius: 16px;
  padding: 12px 14px;
  margin: 8px 0 24px;
}
.form { display: grid; gap: 14px; margin-top: 18px; }
label { display: grid; gap: 6px; font-size: 0.9rem; color: var(--muted); }
input, select, textarea {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #1b1014;
  color: var(--ink);
  padding: 12px 14px;
}
.check { display: flex; align-items: center; gap: 10px; }
.check input { width: auto; }
.flash { margin: 14px 0; padding: 12px 14px; border-radius: 14px; }
.flash-error { background: rgba(139, 46, 69, 0.45); }
.flash-ok { background: rgba(243, 193, 92, 0.18); color: var(--gold-2); }
.folder { margin: 28px 0; }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.tile {
  position: relative;
  overflow: hidden;
  border-radius: 18px;
  background: #12090c;
  border: 2px solid transparent;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.tile.selected { border-color: var(--gold); }
.tile img {
  aspect-ratio: 1;
  width: 100%;
  object-fit: cover;
  pointer-events: none;
}
.shield, .lightbox-shield {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: repeating-linear-gradient(
    -24deg,
    transparent 0 42px,
    rgba(243, 193, 92, 0.05) 42px 44px
  );
}
.tile-meta {
  position: relative;
  z-index: 3;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 10px;
}
.code { font-size: 0.78rem; letter-spacing: 0.04em; color: var(--gold-2); }
.pick {
  border: 0;
  background: rgba(255, 247, 238, 0.1);
  color: var(--ink);
  border-radius: 999px;
  padding: 6px 10px;
  cursor: pointer;
}
.tile.selected .pick { background: var(--gold); color: #1b1014; }
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(10, 6, 8, 0.92);
  display: grid;
  place-items: center;
  gap: 12px;
  padding: 24px;
}
.lightbox img {
  max-height: min(72vh, 720px);
  max-width: min(92vw, 900px);
  pointer-events: none;
  border-radius: 16px;
}
.lightbox-code { margin: 0; color: var(--gold-2); }
.tray {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 30;
  width: min(640px, calc(100% - 24px));
}
.tray-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: rgba(47, 28, 36, 0.95);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 10px 10px 18px;
  box-shadow: var(--shadow);
}
.sheet {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(10, 6, 8, 0.72);
  display: grid;
  place-items: end center;
  padding: 16px;
}
.sheet-card { width: min(560px, 100%); margin-bottom: 12px; max-height: 92vh; overflow: auto; }
.sheet-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 12px; }
.order-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.order-line input { width: 72px; }
.codes { padding-left: 18px; }
.table { display: grid; gap: 10px; }
.row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  background: rgba(47, 28, 36, 0.7);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px 16px;
}
.row span { display: block; color: var(--muted); font-size: 0.88rem; }
.row-actions { display: flex; align-items: center; gap: 12px; }
.row-actions a { color: var(--gold); }
.pill { font-size: 0.75rem; padding: 4px 8px; border-radius: 999px; }
.pill.on { background: rgba(243, 193, 92, 0.2); color: var(--gold-2); }
.pill.off { background: rgba(139, 46, 69, 0.4); }
.top-actions { display: flex; gap: 8px; align-items: center; }
.empty { color: var(--muted); padding: 24px 0; }
.codes-line { color: var(--gold-2) !important; }
[hidden] { display: none !important; }
@media (max-width: 640px) {
  .row, .top { flex-direction: column; align-items: flex-start; }
  .grid { grid-template-columns: repeat(2, 1fr); }
}
