:root {
  --bg: #15161d;
  --surface: #1e202a;
  --surface-2: #262936;
  --border: #343747;
  --text: #ecedf3;
  --muted: #9096ac;
  --accent: #e8a33d;
  --accent-dim: #a97328;
  --good: #4cc38a;
  --bad: #e2574c;
  --radius: 10px;
  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  background-image:
    radial-gradient(circle at 15% 0%, rgba(232, 163, 61, 0.06), transparent 40%),
    radial-gradient(circle at 85% 20%, rgba(76, 195, 138, 0.05), transparent 35%);
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100vh;
}

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

/* ---------- topbar ---------- */

.topbar {
  border-bottom: 1px solid var(--border);
  background: rgba(21, 22, 29, 0.85);
  backdrop-filter: blur(6px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-inner {
  max-width: 1040px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand { display: flex; align-items: baseline; gap: 10px; }
.brand-mark {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent);
  font-size: 1.15rem;
}
.brand-sub { color: var(--muted); font-size: 0.85rem; }

.topbar-right { display: flex; align-items: center; gap: 14px; }
.whoami { color: var(--muted); font-size: 0.9rem; }

/* ---------- layout ---------- */

.page {
  max-width: 1040px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

.section { margin-bottom: 44px; }

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.eyebrow {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  color: var(--accent);
  margin-bottom: 4px;
}

h1, h2, h3 {
  font-family: var(--font-display);
  margin: 0;
  font-weight: 700;
}
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; color: var(--text); }

.owner-label {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--muted);
  margin: 22px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--border);
}
.owner-block:first-child .owner-label { margin-top: 0; }

/* ---------- flash ---------- */

.flash-stack { margin-bottom: 20px; display: flex; flex-direction: column; gap: 8px; }
.flash {
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  border: 1px solid var(--border);
}
.flash-success { border-color: var(--good); color: var(--good); background: rgba(76,195,138,0.08); }
.flash-error { border-color: var(--bad); color: var(--bad); background: rgba(226,87,76,0.08); }

/* ---------- buttons ---------- */

.btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.88rem;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.08s ease, border-color 0.15s ease;
}
.btn:hover { border-color: var(--accent); }
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #1a1408; }
.btn-primary:hover { background: #f3ae4a; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-block { width: 100%; }

/* ---------- ticket stub ---------- */

.stub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
}

.stub {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr 68px;
}

.stub-mine { border-color: rgba(232, 163, 61, 0.35); }

.stub-main {
  padding: 18px 16px;
  min-width: 0;
}

.stub-name {
  font-size: 0.92rem;
  color: var(--text);
  font-weight: 600;
  overflow-wrap: break-word;
  margin-bottom: 10px;
}

.stub-count {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 2rem;
  color: var(--accent);
  line-height: 1;
}

.stub-barcode {
  margin-top: 14px;
  height: 16px;
  background-image: repeating-linear-gradient(
    90deg,
    var(--border) 0px, var(--border) 2px,
    transparent 2px, transparent 5px
  );
  opacity: 0.7;
}

.stub-stub {
  border-left: 1px dashed var(--border);
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 6px;
}

.stub-notch {
  position: absolute;
  right: 68px;
  width: 16px;
  height: 16px;
  background: var(--bg);
  border-radius: 50%;
  transform: translateX(-50%);
}
.stub-notch-top { top: -8px; }
.stub-notch-bottom { bottom: -8px; }

.adjust-form { display: flex; flex-direction: column; gap: 6px; align-items: center; }

.btn-adjust {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 1.1rem;
  font-family: var(--font-mono);
  cursor: pointer;
  line-height: 1;
}
.btn-increase:hover { border-color: var(--good); color: var(--good); }
.btn-decrease:hover { border-color: var(--bad); color: var(--bad); }
.btn-adjust:disabled { opacity: 0.3; cursor: not-allowed; }

.btn-delete {
  border: none;
  background: none;
  color: var(--muted);
  font-size: 0.72rem;
  cursor: pointer;
  padding: 2px 4px;
}
.btn-delete:hover { color: var(--bad); }

.stub-readonly { opacity: 0.88; }
.stub-locked { justify-content: center; }
.locked-tag {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--muted);
  letter-spacing: 0.06em;
  writing-mode: vertical-rl;
}

.empty-state {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 30px;
  text-align: center;
  color: var(--muted);
}

/* ---------- auth ---------- */

.auth-wrap {
  min-height: calc(100vh - 60px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 28px;
  text-align: center;
}

.auth-header { margin-bottom: 24px; }
.auth-tagline { color: var(--muted); font-size: 0.88rem; margin-top: 6px; }
.auth-footer { margin-top: 18px; font-size: 0.85rem; color: var(--muted); }

.form-stack { display: flex; flex-direction: column; gap: 14px; text-align: left; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 0.85rem; color: var(--muted); }
.field input {
  font-family: var(--font-body);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 0.95rem;
}
.field input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.error-card { padding: 44px 28px; }
.error-code {
  font-family: var(--font-mono);
  font-size: 3rem;
  color: var(--bad);
  margin: 6px 0;
}

/* ---------- dialog ---------- */

.dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 26px;
  width: 100%;
  max-width: 380px;
}
.dialog::backdrop { background: rgba(0,0,0,0.55); }
.dialog h3 { margin-bottom: 4px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

@media (max-width: 520px) {
  .topbar-inner, .page { padding-left: 16px; padding-right: 16px; }
  .stub-grid { grid-template-columns: 1fr; }
}
