:root {
  --primary: #1976d2;
  --primary-dark: #1565c0;
  --bg: #f7f9fc;
  --text: #1a1a1a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app-header {
  background: #fff;
  padding: 12px 16px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  text-align: center;
  color: var(--primary);
}

.view {
  display: none;
  padding: 16px;
  padding-bottom: 80px;
}

.view.active {
  display: block;
}

.ticket-options {
  display: flex;
  gap: 12px;
  flex-direction: column;
}

.ticket-card {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.ticket-card h2 {
  margin: 0 0 4px;
}

.ticket-card .price {
  margin: 0 0 12px;
  font-weight: 600;
  color: var(--primary-dark);
}

button {
  width: 100%;
  border: none;
  border-radius: 999px;
  padding: 12px 16px;
  background: var(--primary);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

button:active {
  background: var(--primary-dark);
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  border-top: 1px solid #e0e6f0;
  display: flex;
}

.bottom-nav button {
  flex: 1;
  border-radius: 0;
  padding: 10px 0;
  font-size: 14px;
}

.ticket-print {
  margin-top: 16px;
}

.hidden {
  display: none;
}

.ticket-preview {
  background: #e3e7f0;
  padding: 12px;
  display: flex;
  justify-content: center;
}

.ticket-paper {
  width: 52mm;
  max-width: 100%;
  background: #fff;
  padding: 8px;
  border-radius: 4px;
  text-align: center;
  font-size: 12px;
}

.ticket-paper h3 {
  margin: 2px 0 4px;
}

#tp-qr canvas,
#tp-qr img {
  margin: 4px auto;
}

/* Print: narrow, only ticket */
@media print {
  body * {
    visibility: hidden;
  }

  .ticket-paper,
  .ticket-paper * {
    visibility: visible;
  }

  .ticket-paper {
    position: absolute;
    left: 0;
    top: 0;
    width: 52mm;
  }
}

.manual-check {
  background: #fff;
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 12px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.manual-row {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.manual-row input {
  flex: 1;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid #c5d0e6;
  font-size: 14px;
}

.manual-result {
  margin-top: 6px;
  font-size: 14px;
}

.manual-result.ok {
  color: green;
}

.manual-result.err {
  color: red;
}

.scan-text {
  margin-top: 4px;
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  /* center validation text */
}

.scan-visual {
  margin-top: 8px;
  text-align: center;
}

.scan-icon {
  font-size: 64px;
  line-height: 1;
}

.scan-countdown {
  margin-top: 2px;
  font-size: 14px;
  color: #555;
}

.ticket-paper-small {
  margin-top: 8px;
  font-size: 11px;
}

.history-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.history-item {
  background: #fff;
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 10px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
  font-size: 13px;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.history-status {
  font-weight: 600;
}

.history-time {
  font-size: 12px;
  color: #666;
}

.history-body div {
  margin-top: 2px;
  word-break: break-all;
}

.history-actions {
  margin-top: 8px;
}

.history-item.validated .history-status {
  color: #2e7d32;
}

.history-item.already_used .history-status {
  color: #f57c00;
}

.history-item.expired .history-status,
.history-item.not_found .history-status {
  color: #c62828;
}

.tickets-list {
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
}

.ticket-item {
  background: #fff;
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 10px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
  font-size: 13px;
}

.ticket-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.ticket-id {
  font-weight: 600;
  word-break: break-all;
}

.ticket-type {
  font-size: 12px;
  color: #1565c0;
}

.ticket-body div {
  margin-top: 2px;
}

.ticket-actions {
  margin-top: 8px;
}

.ticket-item.used .ticket-id {
  color: #f57c00;
}

.ticket-item.unused .ticket-id {
  color: #2e7d32;
}

.station-form {
  margin-top: 8px;
  background: #fff;
  border-radius: 12px;
  padding: 8px 10px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
  font-size: 13px;
}

.station-row {
  display: flex;
  flex-direction: column;
  margin-bottom: 6px;
}

.station-row label {
  font-size: 12px;
  margin-bottom: 2px;
}

.station-row select {
  padding: 6px 8px;
  border-radius: 999px;
  border: 1px solid #c5d0e6;
  font-size: 13px;
}

.station-form button {
  margin-top: 4px;
}

.route-box {
  margin-top: 8px;
  background: #fff;
  border-radius: 12px;
  padding: 8px 10px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
  font-size: 13px;
  display: none;
  text-align: center;
  /* center contents */
}

.route-label {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 600;
  color: #1565c0;
  text-align: center;
  /* ensure centered */
}

.route-display {
  text-align: center;
}

.route-line {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.route-point {
  padding: 2px 6px;
  border-radius: 999px;
  background: #e3f2fd;
  color: #1565c0;
  font-weight: 500;
  max-width: 120px;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.route-arrow {
  font-size: 18px;
}

.scan-result-box {
  margin-top: 8px;
  background: #fff;
  border-radius: 12px;
  padding: 8px 10px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
  font-size: 14px;
}

.scan-result {
  text-align: center;
}