:root {
  --bg: #faf8f6;
  --card: #fff;
  --text: #111;
  --muted: #5c5752;
  --accent: #1a1a1a;
  --accent-btn: #d97d50;
  --downloaded-bg: #e8f4ea;
  --downloaded-border: #2e7d32;
  --font: "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

.site-logo {
  display: block;
  width: 180px;
  max-width: 100%;
  height: auto;
  margin-bottom: 6rem;
}

.panel h1 {
  font-size: 1.65rem;
  margin: 0 0 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.muted {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.45;
}

form label {
  display: block;
  margin: 1rem 0 0.35rem;
  font-size: 0.85rem;
  font-weight: 600;
}

input {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 1rem;
}

button.primary {
  margin-top: 1.25rem;
  width: 100%;
  padding: 0.75rem;
  border: none;
  border-radius: 8px;
  background: var(--accent-btn);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

button.primary:hover:not(:disabled) { filter: brightness(0.95); }

button.primary:disabled,
button.primary.is-loading {
  opacity: 0.85;
  cursor: wait;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.spinner {
  display: inline-block;
  width: 1.05rem;
  height: 1.05rem;
  flex-shrink: 0;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
}

.btn-loading-inner {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

button.primary .btn-loading-inner {
  width: 100%;
}

.ticket-btn.is-loading {
  justify-content: center;
  pointer-events: none;
}

.portal-busy .ticket-list {
  pointer-events: none;
  opacity: 0.5;
}

.portal-notice {
  margin: 0.75rem 0 0;
  padding: 0.75rem 0.9rem;
  border-radius: 8px;
  font-size: 0.9rem;
  line-height: 1.45;
  background: #fff4e8;
  border: 1px solid #e8c4a8;
  color: #5c3d2e;
  white-space: pre-line;
}

.download-progress {
  margin-top: 0.75rem;
  height: 5px;
  background: #e5e1dc;
  border-radius: 999px;
  overflow: hidden;
}

.download-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent-btn);
  border-radius: 999px;
  transition: width 0.3s ease;
}

button.text {
  background: none;
  border: none;
  color: var(--muted);
  text-decoration: underline;
  cursor: pointer;
  font-size: 0.9rem;
}

.header-actions {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.error { color: #b00020; font-size: 0.9rem; margin-top: 0.75rem; }

.portal-header { margin-bottom: 1.25rem; }

.download-all {
  margin-top: 1.25rem;
}

.download-all-hint {
  margin-top: 0.65rem;
  font-size: 0.88rem;
}

.download-all:disabled {
  opacity: 0.7;
  cursor: wait;
}

.ticket-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.ticket-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid #ddd;
  border-radius: 10px;
  background: var(--card);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}

.ticket-btn:hover { border-color: var(--accent); }

.ticket-btn .no {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.8rem;
  min-width: 2rem;
}

.ticket-btn.downloaded {
  background: var(--downloaded-bg);
  border-color: var(--downloaded-border);
  color: #1b5e20;
}

.ticket-btn .label-again {
  display: none;
}

.ticket-btn.downloaded:hover .label-done {
  display: none;
}

.ticket-btn.downloaded:hover .label-again {
  display: inline;
}

.ticket-btn:disabled { opacity: 0.65; cursor: wait; }

dialog {
  border: none;
  border-radius: 12px;
  padding: 1.5rem;
  max-width: 400px;
  width: calc(100% - 2rem);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1rem;
}