@import url('https://fonts.googleapis.com/css2?family=Archivo:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ------------------------------------------------------------------ *
 * Tokens
 * ------------------------------------------------------------------ */

:root {
  --ink:      #05060a;
  --surface:  #0b0d13;
  --raised:   #11141c;
  --line:     #1b1f28;
  --line-soft:#14171e;
  --text:     #dedcd7;
  --muted:    #6f7686;
  --brass:    #d8b26a;
  --brass-dim:#7a6538;
  --danger:   #d9564b;
  --ok:       #6da88d;

  --sans: 'Archivo', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --radius: 6px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --rail: 216px;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

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

a { color: var(--brass); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.015em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 0.95rem; }
p { margin: 0 0 1rem; max-width: 68ch; }

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

.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.hidden { display: none !important; }

/* ------------------------------------------------------------------ *
 * The gate
 * ------------------------------------------------------------------ */

.gate {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 2rem 1.25rem;
  position: relative;
  overflow: hidden;
}

.gate-card {
  width: min(400px, 100%);
  position: relative;
  z-index: 1;
}

.wordmark {
  font-family: var(--mono);
  font-size: 2.2rem;
  font-weight: 500;
  letter-spacing: -0.04em;
  margin: 0 0 0.25rem;
}
.wordmark::after {
  content: '';
  display: inline-block;
  width: 0.5ch;
  height: 1.05em;
  margin-left: 0.15ch;
  background: var(--brass);
  vertical-align: -0.15em;
  animation: blink 1.6s steps(1) infinite;
}

@keyframes blink { 0%, 55% { opacity: 1; } 56%, 100% { opacity: 0; } }

.gate-lede { color: var(--muted); margin-bottom: 2rem; }

.tabs {
  display: flex;
  gap: 1.5rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 1.5rem;
}

.tab {
  appearance: none;
  background: none;
  border: 0;
  padding: 0 0 0.75rem;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
  position: relative;
  transition: color 0.2s var(--ease);
}
.tab:hover { color: var(--text); }
.tab[aria-selected='true'] { color: var(--text); }
.tab[aria-selected='true']::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 1px;
  background: var(--brass);
  animation: slide-in 0.28s var(--ease);
}

@keyframes slide-in { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* ------------------------------------------------------------------ *
 * Forms
 * ------------------------------------------------------------------ */

.field { margin-bottom: 1rem; }

label {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

input, select, textarea {
  width: 100%;
  padding: 0.6rem 0.7rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
  transition: border-color 0.18s var(--ease), background 0.18s var(--ease);
}
input:focus, select:focus, textarea:focus {
  border-color: var(--brass-dim);
  background: var(--raised);
  outline: none;
}
input[type='text'].code-input, input.mono { font-family: var(--mono); letter-spacing: 0.06em; }
textarea { min-height: 110px; resize: vertical; font-family: var(--mono); font-size: 0.85rem; }

.hint { font-size: 0.78rem; margin-top: 0.35rem; min-height: 1.1em; }
.hint.bad { color: var(--danger); }
.hint.good { color: var(--ok); }

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--raised);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.12s var(--ease), border-color 0.18s var(--ease), background 0.18s var(--ease), opacity 0.18s;
}
.btn:hover { border-color: var(--brass-dim); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }

.btn-primary {
  background: var(--brass);
  border-color: var(--brass);
  color: #16130c;
  width: 100%;
}
.btn-primary:hover { background: #e5c07d; border-color: #e5c07d; }

.btn-quiet { background: none; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); }
.btn-sm { padding: 0.35rem 0.6rem; font-size: 0.82rem; }

.form-error {
  border-left: 2px solid var(--danger);
  padding: 0.5rem 0.75rem;
  margin-bottom: 1rem;
  background: rgba(224, 96, 85, 0.08);
  font-size: 0.88rem;
  animation: shake 0.32s var(--ease);
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* ------------------------------------------------------------------ *
 * Shell
 * ------------------------------------------------------------------ */

.shell { display: grid; grid-template-columns: var(--rail) 1fr; min-height: 100dvh; }

.rail {
  border-right: 1px solid var(--line);
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  position: sticky;
  top: 0;
  height: 100dvh;
}

.rail-mark { font-family: var(--mono); font-size: 1.1rem; letter-spacing: -0.03em; padding-left: 0.6rem; }

.nav { display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  appearance: none;
  background: none;
  border: 0;
  border-radius: var(--radius);
  padding: 0.5rem 0.6rem;
  text-align: left;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
  position: relative;
  transition: color 0.18s var(--ease), background 0.18s var(--ease);
}
.nav-item:hover { color: var(--text); background: var(--surface); }
.nav-item[aria-current='page'] { color: var(--text); background: var(--surface); }
.nav-item[aria-current='page']::before {
  content: '';
  position: absolute;
  left: -1rem;
  top: 20%;
  bottom: 20%;
  width: 2px;
  background: var(--brass);
  animation: grow 0.24s var(--ease);
}

@keyframes grow { from { transform: scaleY(0); } to { transform: scaleY(1); } }

.rail-foot { margin-top: auto; font-size: 0.82rem; color: var(--muted); }
.rail-user { display: flex; align-items: center; gap: 0.5rem; padding: 0 0.6rem 0.75rem; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); flex: none; }
.dot.admin { background: var(--brass); }

.main { padding: 2.5rem 2.5rem 4rem; }
.view { max-width: 880px; }
.view-wide { max-width: none; }
.view-head { margin-bottom: 2rem; }
.view-head p { color: var(--muted); margin: 0.35rem 0 0; }

/* View transition */
.view-enter { animation: view-in 0.26s var(--ease); }
@keyframes view-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* ------------------------------------------------------------------ *
 * Home destinations
 * ------------------------------------------------------------------ */

.destinations {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
}

.destination {
  appearance: none;
  text-align: left;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.15rem 1.2rem 1.25rem;
  cursor: pointer;
  display: grid;
  gap: 0.35rem;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease), transform 0.15s var(--ease);
}
.destination:hover {
  border-color: var(--brass-dim);
  background: var(--raised);
  transform: translateY(-2px);
}
.destination:active { transform: none; }

.destination svg {
  width: 22px;
  height: 22px;
  stroke: var(--brass);
  fill: none;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  margin-bottom: 0.5rem;
}

.destination-title { font-weight: 600; font-size: 1rem; }
.destination-note { color: var(--muted); font-size: 0.85rem; line-height: 1.4; }
.destination-count { font-family: var(--mono); color: var(--brass); font-size: 0.82rem; }

/* ------------------------------------------------------------------ *
 * Dialogs
 * ------------------------------------------------------------------ */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  background: rgba(2, 3, 5, 0.72);
  animation: overlay-in 0.18s var(--ease);
}
.overlay.leaving { animation: overlay-out 0.16s var(--ease) forwards; }

@keyframes overlay-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes overlay-out { to { opacity: 0; } }

.dialog {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 2px solid var(--brass-dim);
  border-radius: var(--radius);
  padding: 1.35rem 1.4rem 1.2rem;
  animation: dialog-in 0.22s var(--ease);
}
.overlay.leaving .dialog { animation: dialog-out 0.16s var(--ease) forwards; }

@keyframes dialog-in {
  from { opacity: 0; transform: translateY(8px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}
@keyframes dialog-out { to { opacity: 0; transform: translateY(4px); } }

.dialog-title { font-size: 1.05rem; margin-bottom: 0.35rem; }
.dialog-note { color: var(--muted); font-size: 0.88rem; margin: 0 0 1.1rem; max-width: none; }
.dialog-fields { margin-bottom: 1.2rem; }
.dialog-fields .field:last-child { margin-bottom: 0; }
.dialog-fields textarea { min-height: 80px; font-family: var(--sans); font-size: 0.9rem; }

.dialog-actions { display: flex; justify-content: flex-end; gap: 0.5rem; }
.dialog-actions .btn { width: auto; }

.btn-solid { background: var(--brass); border-color: var(--brass); color: #16130c; }
.btn-solid:hover { background: #e5c07d; border-color: #e5c07d; }
.btn-solid-danger { background: var(--danger); border-color: var(--danger); color: #1c0c0a; }
.btn-solid-danger:hover { background: #e8695e; border-color: #e8695e; }

body.is-locked { overflow: hidden; }

/* ------------------------------------------------------------------ *
 * Panels, stats, tables
 * ------------------------------------------------------------------ */

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 1.5rem; }
.stat { background: var(--surface); padding: 1rem 1.1rem; }
.stat-value { font-family: var(--mono); font-size: 1.5rem; line-height: 1.2; }
.stat-label { font-size: 0.8rem; color: var(--muted); }

table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th { text-align: left; font-weight: 500; color: var(--muted); font-size: 0.8rem; padding: 0 0.6rem 0.6rem; }
td { padding: 0.65rem 0.6rem; border-top: 1px solid var(--line-soft); vertical-align: middle; }
tr:hover td { background: rgba(255, 255, 255, 0.015); }
td.actions { text-align: right; white-space: nowrap; }
td.actions .btn { margin-left: 0.35rem; }

.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-family: var(--mono);
  line-height: 1.5;
  white-space: nowrap;
  vertical-align: middle;
  padding: 0.12rem 0.4rem;
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--muted);
}

/* A long ban reason must never stretch its row. */
.user-cell { display: flex; flex-direction: column; gap: 0.15rem; max-width: 26ch; }
.user-name { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.user-reason {
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.badge.open { color: var(--brass); border-color: var(--brass-dim); }
.badge.used { color: var(--ok); border-color: rgba(127, 182, 154, 0.4); }
.badge.revoked, .badge.banned { color: var(--danger); border-color: rgba(224, 96, 85, 0.4); }

.empty { color: var(--muted); padding: 1.5rem 0; text-align: center; font-size: 0.9rem; }

/* ------------------------------------------------------------------ *
 * Invites — the one place the design raises its voice
 * ------------------------------------------------------------------ */

.invite-list { display: grid; gap: 0.6rem; }

.invite {
  display: flex;
  align-items: center;
  gap: 1rem;
  border: 1px solid var(--line);
  border-left: 2px solid var(--brass-dim);
  border-radius: var(--radius);
  background: var(--raised);
  padding: 0.75rem 1rem;
}
.invite.is-spent { border-left-color: var(--line); opacity: 0.6; }
.invite-code { font-family: var(--mono); font-size: 0.95rem; letter-spacing: 0.05em; flex: 1; word-break: break-all; }
.invite.is-spent .invite-code { text-decoration: line-through; text-decoration-color: var(--muted); }
.invite-meta { font-size: 0.78rem; color: var(--muted); }

.invite-fresh { animation: stamp 0.42s var(--ease); }
@keyframes stamp {
  0%   { opacity: 0; transform: scale(0.96) translateY(-4px); border-left-color: var(--brass); }
  60%  { opacity: 1; transform: scale(1.005); }
  100% { opacity: 1; transform: none; }
}

/* ------------------------------------------------------------------ *
 * Shop
 * ------------------------------------------------------------------ */

.notice {
  border-left: 2px solid var(--brass);
  background: rgba(216, 178, 106, 0.06);
  padding: 0.6rem 0.85rem;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
}
.notice-soft { border-left-color: var(--muted); background: rgba(255, 255, 255, 0.025); margin: 0.75rem 0 0; }

.catalogue { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 1rem; }

.product {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 1.25rem 1.3rem 1.3rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.product h2 { font-size: 1.05rem; }
.product-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.product-summary { color: var(--muted); font-size: 0.88rem; margin: 0.25rem 0 0; max-width: none; }
.product-flags { display: grid; gap: 0.3rem; justify-items: end; text-align: right; }

.slots { display: grid; gap: 0.4rem; }
.slot-bar { height: 3px; background: var(--line); border-radius: 2px; overflow: hidden; }
.slot-fill {
  display: block;
  height: 100%;
  background: var(--brass-dim);
  transition: width 0.4s var(--ease);
}
.slot-fill.is-full { background: var(--danger); }
.slot-note { font-size: 0.8rem; color: var(--muted); }

.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 0.5rem; }

.plan {
  appearance: none;
  font: inherit;
  color: var(--text);
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.6rem 0.5rem;
  cursor: pointer;
  display: grid;
  gap: 0.15rem;
  text-align: center;
  transition: border-color 0.18s var(--ease), background 0.18s var(--ease), transform 0.12s var(--ease);
}
.plan:hover:not([disabled]) { border-color: var(--brass); background: rgba(216, 178, 106, 0.07); transform: translateY(-1px); }
.plan[disabled] { opacity: 0.4; cursor: not-allowed; }
.plan-days { font-size: 0.85rem; }
.plan-price { font-family: var(--mono); font-size: 0.95rem; color: var(--brass); }

.pay-with { display: flex; align-items: center; gap: 0.6rem; }
.pay-with label { margin: 0; }
.pay-with select { width: auto; padding: 0.35rem 0.5rem; font-size: 0.85rem; }

/* ------------------------------------------------------------------ *
 * Access and orders
 * ------------------------------------------------------------------ */

.access-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0.75rem; margin-bottom: 1.5rem; }

.access-card {
  border: 1px solid var(--line);
  border-left: 2px solid var(--ok);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0.9rem 1rem;
  display: grid;
  gap: 0.15rem;
}
.access-product { font-weight: 600; }
.access-left { font-family: var(--mono); color: var(--ok); font-size: 0.95rem; }
.access-until { color: var(--muted); font-size: 0.8rem; }

.order { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 1rem 1.15rem; margin-bottom: 0.75rem; }
.order:last-child { margin-bottom: 0; }
.order-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.pay-line { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.75rem; font-family: var(--mono); font-size: 0.82rem; background: var(--ink); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.5rem 0.65rem; }
.pay-line span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ------------------------------------------------------------------ *
 * Catalogue editor
 * ------------------------------------------------------------------ */

.form-note { font-size: 0.82rem; margin: 0.9rem 0 0; }
.product-meta { display: flex; gap: 0.35rem; flex-wrap: wrap; }

.plan-grid {
  margin-top: 1.25rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.plan-grid-head {
  padding: 0.5rem 0.85rem;
  font-size: 0.8rem;
  color: var(--muted);
  background: var(--raised);
  border-bottom: 1px solid var(--line);
}

.plan-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.85rem;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
  margin: 0;
  font-size: 0.9rem;
  color: var(--text);
  transition: background 0.15s var(--ease);
}
.plan-row:last-child { border-bottom: 0; }
.plan-row:hover { background: rgba(255, 255, 255, 0.02); }
.plan-row input[type='checkbox'] { width: 15px; height: 15px; accent-color: var(--brass); cursor: pointer; }
.plan-row-days { font-size: 0.9rem; }
.plan-row-price { display: flex; align-items: center; gap: 0.3rem; }
.plan-row-price .currency { color: var(--muted); font-family: var(--mono); font-size: 0.85rem; }
.plan-row-price input { width: 88px; padding: 0.3rem 0.45rem; font-family: var(--mono); font-size: 0.85rem; text-align: right; }

/* ------------------------------------------------------------------ *
 * Toasts
 * ------------------------------------------------------------------ */

.toasts { position: fixed; right: 1.25rem; bottom: 1.25rem; display: grid; gap: 0.5rem; z-index: 40; }

.toast {
  border: 1px solid var(--line);
  border-left: 2px solid var(--brass);
  background: var(--raised);
  border-radius: var(--radius);
  padding: 0.65rem 0.9rem;
  font-size: 0.88rem;
  max-width: 320px;
  animation: toast-in 0.26s var(--ease);
}
.toast.bad { border-left-color: var(--danger); }
.toast.good { border-left-color: var(--ok); }
.toast.leaving { animation: toast-out 0.2s var(--ease) forwards; }

@keyframes toast-in { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(12px); } }

/* Banned screen */
.ban-screen { min-height: 100dvh; display: grid; place-items: center; text-align: center; padding: 2rem; }
.ban-screen h1 { color: var(--danger); font-size: 1.4rem; margin-bottom: 0.5rem; }

/* Admin sub-navigation */
.subnav { display: flex; gap: 0.4rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.subnav .tab { padding: 0.35rem 0.7rem; border: 1px solid transparent; border-radius: var(--radius); }
.subnav .tab[aria-selected='true'] { border-color: var(--line); background: var(--surface); }
.subnav .tab[aria-selected='true']::after { display: none; }

.row { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: flex-end; }
.row-spaced { margin-top: 0.75rem; }
.panel-head input[type='search'],
.panel-head select { width: auto; max-width: 220px; padding: 0.35rem 0.55rem; font-size: 0.85rem; }
.row .field { flex: 1 1 160px; margin-bottom: 0; }
.row .btn { flex: none; }

/* ------------------------------------------------------------------ *
 * Responsive
 * ------------------------------------------------------------------ */

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .rail {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 1rem;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 0.9rem 1rem;
    overflow-x: auto;
  }
  .rail-mark { padding-left: 0; }
  .nav { flex-direction: row; }
  .nav-item[aria-current='page']::before { left: 0.6rem; right: 0.6rem; top: auto; bottom: -0.35rem; width: auto; height: 2px; }
  .rail-foot { margin-top: 0; margin-left: auto; }
  .rail-user { padding: 0; }
  .rail-user-name { display: none; }
  .main { padding: 1.5rem 1.15rem 3rem; }
  .catalogue { grid-template-columns: 1fr; }
  .toasts { left: 1rem; right: 1rem; }
  .toast { max-width: none; }
  table { font-size: 0.82rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
