:root {
  --bg: #f3f6fb;
  --surface: #ffffff;
  --surface-soft: #f7f9fd;
  --line: #d9e2ef;
  --text: #142033;
  --muted: #607089;
  --primary: #2257c7;
  --primary-strong: #173f97;
  --danger: #be2f3b;
  --success: #17834d;
  --warning: #b87400;
  --shadow: 0 18px 40px rgba(18, 38, 63, 0.10);
  --radius: 18px;
  --radius-sm: 12px;
  --max: 1320px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: Inter, Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
}

body {
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand h1 {
  font-size: 1.3rem;
  line-height: 1.1;
  margin: 0;
}

.brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.brand-badge {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  color: white;
  display: grid;
  place-items: center;
  font-weight: 800;
  letter-spacing: 0.04em;
  box-shadow: var(--shadow);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.main {
  max-width: var(--max);
  margin: 0 auto;
  padding: 26px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}

.panel + .panel {
  margin-top: 20px;
}

.panel-head {
  margin-bottom: 18px;
}

.panel-head h2 {
  margin: 0;
  font-size: 1.15rem;
}

.panel-head p {
  margin: 6px 0 0;
  color: var(--muted);
}

.auth-panel {
  max-width: 560px;
  margin: 40px auto;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.tab-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 600;
}

.tab-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.grid {
  display: grid;
  gap: 20px;
  margin-bottom: 20px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.form-grid label span,
.subhead h3 {
  font-size: 0.92rem;
  font-weight: 700;
}

.form-grid .full {
  grid-column: 1 / -1;
}

input,
select,
textarea,
button {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: white;
  color: var(--text);
  border-radius: 12px;
  padding: 12px 14px;
  outline: none;
}

textarea {
  resize: vertical;
  min-height: 90px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(34, 87, 199, 0.12);
}

.btn {
  border: 0;
  border-radius: 12px;
  padding: 12px 16px;
  cursor: pointer;
  font-weight: 700;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-strong);
}

.btn-light {
  background: var(--surface-soft);
  color: var(--text);
  border: 1px solid var(--line);
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.status-pill,
.user-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 0.92rem;
  font-weight: 700;
}

.status-pill.online {
  background: rgba(23, 131, 77, 0.12);
  color: var(--success);
}

.status-pill.offline {
  background: rgba(190, 47, 59, 0.12);
  color: var(--danger);
}

.user-badge {
  background: var(--surface-soft);
  border: 1px solid var(--line);
}

.card-list {
  display: grid;
  gap: 12px;
}

.card {
  border: 1px solid var(--line);
  background: var(--surface-soft);
  border-radius: 14px;
  padding: 14px;
}

.card h3,
.card h4 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.card p {
  margin: 5px 0;
  color: var(--muted);
  line-height: 1.45;
}

.info-box,
.code-box,
.scan-result {
  margin-top: 14px;
  border-radius: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
}

.code-box {
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 120px;
}

.subhead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.passenger-row {
  display: grid;
  grid-template-columns: 180px 1fr 1fr auto;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
  margin-bottom: 10px;
}

.ticket-preview-list {
  display: grid;
  gap: 16px;
}

.ticket-sheet {
  background: white;
  border: 1px dashed #b7c4d7;
  border-radius: 18px;
  overflow: hidden;
}

.ticket-main,
.ticket-stub {
  padding: 18px;
}

.ticket-main {
  display: grid;
  grid-template-columns: 1fr 180px;
  gap: 16px;
}

.ticket-stub {
  background: #f8fbff;
}

.tear-line {
  border-top: 2px dashed #93a4bd;
}

.ticket-title {
  font-size: 1.2rem;
  font-weight: 800;
  margin-bottom: 10px;
}

.ticket-meta {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

.ticket-meta strong {
  color: var(--text);
}

.ticket-qr img {
  width: 100%;
  max-width: 180px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
  padding: 8px;
}

.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.toast-wrap {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: grid;
  gap: 10px;
  z-index: 30;
}

.toast {
  min-width: 260px;
  max-width: 360px;
  border-radius: 14px;
  padding: 14px 16px;
  background: #12263f;
  color: white;
  box-shadow: var(--shadow);
}

.toast.success {
  background: var(--success);
}

.toast.error {
  background: var(--danger);
}

.small {
  font-size: 0.9rem;
  color: var(--muted);
}

@media (max-width: 980px) {
  .grid.two,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .ticket-main {
    grid-template-columns: 1fr;
  }

  .passenger-row {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .main {
    padding: 16px;
  }
}

@media print {
  .topbar,
  .tabs,
  .btn,
  .toast-wrap {
    display: none !important;
  }

  body {
    background: white;
  }

  .ticket-sheet {
    border: 0;
    box-shadow: none;
    page-break-inside: avoid;
  }
}