:root {
  --bg: #f0f4f8;
  --surface: #ffffff;
  --text: #1a2332;
  --muted: #5c6b7f;
  --accent: #0d6efd;
  --accent-hover: #0b5ed7;
  --border: #d8e0ea;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  --radius: 10px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}
.app-header {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.app-header__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.app-header__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.app-header h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.app-header .btn {
  padding: 6px 12px;
  font-size: 0.8125rem;
  border-radius: 6px;
  flex-shrink: 0;
}
.lang-menu {
  position: relative;
}
.btn-lang {
  border: 1px solid var(--border);
  background: var(--surface);
}
.lang-menu__dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 116px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 6px;
  z-index: 200;
}
.lang-menu__item {
  width: 100%;
  border: none;
  border-radius: 6px;
  background: transparent;
  padding: 7px 10px;
  text-align: left;
  font: inherit;
  color: var(--text);
  cursor: pointer;
}
.lang-menu__item:hover {
  background: rgba(13, 110, 253, 0.08);
}
.app-header__hints {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px 16px;
}
.app-header__hint {
  margin: 0;
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--muted);
  flex: 1 1 12rem;
  min-width: 0;
}
.header-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: end;
}
.header-filter {
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
  min-width: 130px;
  font-size: 0.78rem;
  color: var(--muted);
}
.header-filter select {
  font: inherit;
  font-size: 0.7rem;
  color: var(--text);
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}
.header-filter select:focus-visible {
  outline: 2px solid rgba(13, 110, 253, 0.35);
  outline-offset: 1px;
}
.header-app-option {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.header-app-option__label {
  display: inline-flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.72rem;
  line-height: 1.35;
  color: var(--muted);
  cursor: pointer;
  max-width: 100%;
}
.header-app-option__label input {
  margin-top: 2px;
  accent-color: var(--accent);
  flex-shrink: 0;
}
.header-app-option__label span {
  min-width: 0;
}
.app-header__hint--report {
  flex: 0 1 20rem;
  text-align: right;
}
@media (max-width: 520px) {
  .app-header__hint--report {
    flex-basis: 100%;
    text-align: left;
  }
}
.btn {
  font: inherit;
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  transition: background 0.15s ease;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.btn-ghost {
  background: transparent;
  color: var(--muted);
}
.btn-ghost:hover { background: rgba(0, 0, 0, 0.06); color: var(--text); }
main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 16px 48px;
}
.stats-footer {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 50;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  max-width: min(100vw - 32px, 420px);
  padding: 8px 12px;
  font-size: 0.8rem;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.stats-footer__sep {
  opacity: 0.5;
  user-select: none;
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr));
  gap: 12px;
}
.card {
  position: relative;
  min-height: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.card--checked {
  background: #e8f5e9;
  border-color: #66bb6a;
}
.card--checked .card-code-row,
.card--checked .card-meta {
  background: rgba(76, 175, 80, 0.12);
  border-color: rgba(56, 142, 60, 0.35);
}
.card-check {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #2e7d32;
  color: #fff;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  pointer-events: none;
  z-index: 2;
}
.card--checked .card-check {
  display: flex;
}
.card-qr-row {
  flex: 0 0 auto;
  padding: 10px 8px 8px;
}
.card-qr {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 8px;
}
.card-code-row {
  flex-shrink: 0;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-top: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.02);
}
.card-code {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  font-size: clamp(0.65rem, 2vw, 0.8rem);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  word-break: break-all;
  text-align: left;
  line-height: 1.35;
}
.card-copy-btn {
  flex-shrink: 0;
  align-self: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.card-copy-btn:hover {
  background: rgba(13, 110, 253, 0.08);
  color: var(--accent);
  border-color: rgba(13, 110, 253, 0.35);
}
.card-copy-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.card-copy-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.card-copy-btn--done {
  color: #2e7d32;
  border-color: #81c784;
  background: rgba(76, 175, 80, 0.12);
}
.card-copy-btn svg {
  display: block;
}
.card-report-btn {
  flex-shrink: 0;
  align-self: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid rgba(230, 81, 0, 0.45);
  border-radius: 8px;
  background: rgba(230, 81, 0, 0.06);
  color: #e65100;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.card-report-btn:hover:not(:disabled) {
  background: rgba(230, 81, 0, 0.12);
  border-color: rgba(230, 81, 0, 0.65);
}
.card-report-btn:focus-visible {
  outline: 2px solid #e65100;
  outline-offset: 2px;
}
.card-report-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.card-report-btn--reported {
  color: var(--muted);
  border-color: var(--border);
  background: rgba(0, 0, 0, 0.04);
}
.card-report-btn svg {
  display: block;
}
.card-qr:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.card-qr:focus:not(:focus-visible) {
  outline: none;
}
.card-qr img {
  width: 100%;
  max-width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  transition: opacity 0.7s ease;
}
/* Viewport taller than wide: smaller QR for vertical space */
@media (max-aspect-ratio: 1/1) {
  .card-qr img {
    width: 50%;
    max-width: 50%;
  }
}
.card-qr.card-qr--fading {
  pointer-events: none;
}
.card-qr.card-qr--fading img {
  opacity: 0.12;
}
.card-meta {
  flex-shrink: 0;
  padding: 8px 10px;
  font-size: 0.7rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.02);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}
.card-meta-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.card-open-app-btn {
  width: 100%;
  min-height: 32px;
  border: 1px solid rgba(13, 110, 253, 0.45);
  border-radius: 8px;
  background: rgba(13, 110, 253, 0.08);
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.card-open-app-btn:hover:not(:disabled) {
  background: rgba(13, 110, 253, 0.14);
  border-color: rgba(13, 110, 253, 0.6);
}
.card-open-app-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.card-open-app-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.card-status-message {
  font-size: 0.75rem;
  line-height: 1.35;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-meta time { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.continent-badge {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  line-height: 1.2;
}
.continent-badge__label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
.flag-img {
  display: block;
  width: 28px;
  height: auto;
  max-height: 22px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 2px;
}
.continent-options .flag-img {
  width: 28px;
  max-height: 21px;
}
.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 48px 16px;
  font-size: 0.95rem;
}
.status-bar {
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 12px;
  min-height: 1.2em;
}
dialog {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  max-width: min(100vw - 32px, 440px);
  width: 100%;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
}
dialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
}
.dialog-inner {
  padding: 20px 20px 16px;
}
.dialog-inner h2 {
  margin: 0 0 16px;
  font-size: 1.1rem;
}
.dialog-inner label[for="codes-input"],
.dialog-inner label[for="status-message-input"] {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--muted);
}
#codes-input,
#status-message-input {
  width: 100%;
  min-height: 140px;
  padding: 10px 12px;
  font: inherit;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  resize: vertical;
}
#status-message-input {
  min-height: 72px;
  margin-top: 10px;
}
#codes-input:focus,
#status-message-input:focus {
  outline: 2px solid rgba(13, 110, 253, 0.35);
  outline-offset: 1px;
}
.continent-fieldset {
  border: none;
  margin: 16px 0 0;
  padding: 0;
}
.continent-fieldset legend {
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 8px;
  color: var(--muted);
}
.continent-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.continent-options label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  background: var(--surface);
}
.continent-options input { accent-color: var(--accent); }
.continent-options input:checked ~ .continent-name { font-weight: 600; }
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 10000;
  max-width: min(90vw, 360px);
  padding: 12px 20px;
  background: #323232;
  color: #fff;
  font-size: 0.9rem;
  line-height: 1.4;
  text-align: center;
  border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.28);
  transform: translateX(-50%) translateY(16px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.28s ease, transform 0.28s ease, visibility 0.28s;
}
.toast.toast--visible {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}
