:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --success: #15803d;
  --warning: #b45309;
  --danger: #b91c1c;
  --radius: 12px;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }

code {
  padding: 2px 6px;
  border-radius: 6px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 0.92em;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 0.85rem;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.site-nav a {
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--muted);
}

.site-nav a:hover { background: #f3f4f6; color: var(--text); }

.page-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 64px;
}

.page-title,
.hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 20px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
}

.hero.compact { align-items: center; }

h1, h2, h3, p { margin-top: 0; }

h1 {
  margin-bottom: 8px;
  font-size: clamp(1.9rem, 4vw, 3rem);
  line-height: 1.05;
  letter-spacing: -0.03em;
}

h2 { margin-bottom: 14px; font-size: 1.25rem; }
h3 { margin-bottom: 10px; font-size: 1rem; }

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.lead {
  margin: 0;
  max-width: 720px;
  color: var(--muted);
  font-size: 1.02rem;
}

.card {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}

.form-card { max-width: 900px; }
.mini-card { min-width: 260px; box-shadow: none; }

.grid { display: grid; gap: 18px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 20px; }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cards { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

.stack { display: flex; flex-direction: column; gap: 12px; }
.stack.compact { gap: 8px; }

.actions,
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.row-between,
.sale-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
}

.field { display: flex; flex-direction: column; gap: 7px; }
.field span { color: var(--muted); font-size: 0.92rem; font-weight: 700; }
.field small { color: var(--muted); font-size: 0.86rem; line-height: 1.35; }

input,
textarea,
select,
button { font: inherit; }

input,
textarea,
select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  outline: none;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

textarea { resize: vertical; min-height: 100px; }

.checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f9fafb;
}

.checkbox input { width: auto; accent-color: var(--accent); }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 9px 14px;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
}

.button:hover { background: #f9fafb; }
.button.primary { border-color: var(--accent); background: var(--accent); color: #fff; }
.button.primary:hover { background: var(--accent-dark); }
.button.danger { border-color: #fecaca; background: #fef2f2; color: var(--danger); }
.button.danger:hover { background: #fee2e2; }
.button.ghost { opacity: 0.6; cursor: not-allowed; }
.button.small { min-height: 32px; padding: 7px 10px; font-size: 0.9rem; }

.list-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

a.list-item:hover { border-color: #bfdbfe; background: #f8fbff; }
.list-item.static { cursor: default; }

.muted { color: var(--muted); }
.small-text { font-size: 0.9rem; }

.alert { padding: 11px 12px; border-radius: 10px; font-weight: 700; }
.alert.success { background: #ecfdf5; color: var(--success); border: 1px solid #bbf7d0; }
.alert.error { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }

.pill {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  padding: 5px 9px;
  border-radius: 999px;
  background: #f3f4f6;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.pill.approved,
.pill.used,
.pill.published { background: #dcfce7; color: var(--success); }
.pill.pending_review,
.pill.awaiting_receipt,
.pill.draft { background: #fef3c7; color: var(--warning); }
.pill.rejected,
.pill.cancelled,
.pill.expired,
.pill.closed { background: #fee2e2; color: var(--danger); }
.pill.neutral { background: #f3f4f6; color: var(--muted); }
.pill.admin { background: #dbeafe; color: #1d4ed8; }
.pill.operator { background: #ede9fe; color: #6d28d9; }

.callout {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f9fafb;
}

.callout.warning { border-color: #fde68a; background: #fffbeb; }

.outlined {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f9fafb;
}

.inline-meta { display: flex; flex-wrap: wrap; gap: 8px; color: var(--muted); }
.inline-meta span { padding: 6px 9px; border-radius: 999px; background: #f3f4f6; }

.tag-list { display: flex; flex-wrap: wrap; gap: 8px; }
.tag { padding: 6px 9px; border-radius: 8px; background: #eef2ff; color: #3730a3; font-size: 0.9rem; font-weight: 700; }

.preview-card { min-height: 620px; }
.ticket-preview-frame { width: 100%; min-height: 560px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }

.table-wrap { overflow-x: auto; border-radius: 10px; border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { padding: 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-size: 0.82rem; text-transform: uppercase; }
tr:last-child td { border-bottom: 0; }
.env-table td:first-child { width: 220px; }

.inline-form { display: inline-flex; margin: 0; }
.price { font-size: 1.15rem; font-weight: 900; }
.align-right { text-align: right; }
.top-gap { margin-top: 16px; }
.prose { line-height: 1.65; }
.ticket-card { display: flex; flex-direction: column; gap: 8px; }
.sale-panel { margin-bottom: 20px; }

.auth-shell {
  min-height: calc(100vh - 160px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  align-items: center;
  gap: 20px;
}

.auth-copy,
.auth-card {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
}

.operator-body { background: var(--bg); }
.operator-shell { max-width: 980px; margin: 0 auto; padding: 20px; }
.operator-header { display: flex; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.operator-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.status-panel { text-align: right; }
#camera-preview { width: 100%; min-height: 220px; border-radius: 10px; background: #111827; object-fit: cover; }
.result-box { min-height: 160px; padding: 16px; border: 1px dashed #d1d5db; border-radius: 10px; background: #f9fafb; }
.result-box.success { border-color: #86efac; background: #f0fdf4; }
.result-box.error { border-color: #fca5a5; background: #fef2f2; }

@media (max-width: 900px) {
  .site-header,
  .page-title,
  .hero,
  .operator-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .grid.two,
  .grid.three,
  .operator-grid,
  .auth-shell { grid-template-columns: 1fr; }

  .page-shell { width: min(100% - 24px, 1180px); padding-top: 18px; }
  .card, .page-title, .hero, .auth-copy, .auth-card { padding: 16px; }
  .list-item, .row-between, .sale-panel-head { flex-direction: column; }
  .align-right, .status-panel { text-align: left; }
}

/* Простая админская карточка и вкладки мероприятия */
.compact-card {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
}

.event-card-main { min-width: 0; }
.event-card-main h1 { margin-bottom: 10px; font-size: clamp(1.5rem, 3vw, 2.25rem); }
.event-card-side { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.compact-actions { justify-content: flex-end; }
.top-gap-small { margin-top: 10px; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.stat-card {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.stat-card span { display: block; color: var(--muted); font-size: 0.82rem; font-weight: 700; }
.stat-card strong { display: block; margin-top: 4px; font-size: 1.35rem; }

.admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 18px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
}

.tab-link {
  padding: 9px 12px;
  border: 1px solid transparent;
  border-radius: 9px;
  color: var(--muted);
  font-weight: 800;
}

.tab-link:hover { background: #f3f4f6; color: var(--text); }
.tab-link.active { border-color: #bfdbfe; background: #eff6ff; color: var(--accent-dark); }
.no-gap-bottom { margin-bottom: 0 !important; }

@media (max-width: 900px) {
  .compact-card,
  .event-card-side { align-items: flex-start; flex-direction: column; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .compact-actions { justify-content: flex-start; }
}

#camera-preview { overflow: hidden; }
#camera-preview video { width: 100% !important; border-radius: 10px; object-fit: cover; }
#camera-preview canvas { display: none; }
.scan-toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 50; width: min(92vw, 420px); }
.scan-toast.hidden { display: none; }
.scan-toast-card { border-radius: 18px; padding: 16px 18px; box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25); border: 1px solid #e5e7eb; background: #ffffff; }
.scan-toast.success .scan-toast-card { border-color: #86efac; background: #f0fdf4; }
.scan-toast.error .scan-toast-card { border-color: #fca5a5; background: #fef2f2; }
.scan-toast-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.scan-toast-title { margin-top: 4px; font-weight: 800; font-size: 1.15rem; }
.scan-toast-text { margin-top: 6px; white-space: pre-line; color: #374151; }
