:root {
  color-scheme: light dark;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

body {
  max-width: 640px;
  margin: 0 auto;
  padding: 1.5rem;
  line-height: 1.4;
}

/* Author CSS always beats the UA stylesheet's own `[hidden] { display: none }` rule, regardless
   of specificity — so any class that sets `display` (`.dropdown-item`'s `display: block`, `.btn`'s
   `display: inline-block`, etc.) silently overrides `hidden`. Confirmed live: tab-admin/
   logout-button rendered fully visible to a logged-out guest even with `.hidden = true` correctly
   set, because `.dropdown-item { display: block }` won. This one rule keeps `hidden` authoritative
   everywhere, current and future uses alike, instead of patching each affected class one at a time. */
[hidden] {
  display: none !important;
}

header {
  margin-bottom: 1.5rem;
  position: relative;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.subtitle {
  color: #666;
  margin-top: 0.6rem;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.wordmark {
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
  margin-right: auto;
}

.primary-nav {
  display: flex;
  gap: 0.5rem;
}

.tab {
  padding: 0.6rem 1rem;
  border: 1px solid #888;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
}

.tab.active {
  background: #2563eb;
  color: white;
  border-color: #2563eb;
}

.account-menu {
  position: relative;
}

/* On a narrow phone viewport, `.topbar`'s flex-wrap could previously drop `.account-menu` onto
   its own second line by itself — landing it at the *left* edge (only `.wordmark` had
   `margin-right: auto`, so the wrapped line had nothing to push it right). The dropdown, anchored
   `right: 0` to that displaced button, then extended left and got clipped off the viewport —
   confirmed via headless-Chrome screenshots at 360-390px widths. Fix: keep the wordmark and
   account-menu locked together on the first line (there's always room for those two alone), and
   force the nav tabs onto their own full-width row instead, so the avatar never moves. */
@media (max-width: 560px) {
  .wordmark {
    order: 1;
  }

  .account-menu {
    order: 2;
  }

  .primary-nav {
    order: 3;
    flex-basis: 100%;
    flex-wrap: wrap;
  }
}

.avatar-button {
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  border: 1px solid #888;
  background: transparent;
  color: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  font-size: 0.8rem;
  font-weight: 700;
}

.avatar-button:hover,
.avatar-button[aria-expanded="true"] {
  border-color: #2563eb;
  color: #2563eb;
}

.dropdown {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  min-width: 12rem;
  max-width: calc(100vw - 2rem);
  background: white;
  border: 1px solid #ccc;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  padding: 0.4rem;
  z-index: 10;
}

/* The avatar icon relies on `currentColor`/`color: inherit`, which happens to auto-invert to a
   light color in Chromium via `color-scheme: light dark` (:root) — not guaranteed on every
   engine (notably older Safari/iOS), so both the button and the dropdown it opens get explicit
   dark-mode colors here rather than depending on that implicit inheritance. Without this, the
   dropdown in particular rendered as a solid white box with barely-legible text against a dark
   page — confirmed via a real headless-Chrome screenshot in prefers-color-scheme: dark. */
@media (prefers-color-scheme: dark) {
  .avatar-button {
    border-color: #6b7280;
    color: #e5e7eb;
  }

  .avatar-button:hover,
  .avatar-button[aria-expanded="true"] {
    border-color: #60a5fa;
    color: #60a5fa;
  }

  .dropdown {
    background: #1e2230;
    border-color: #3a3f4e;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
  }

  .dropdown-item:hover {
    background: rgba(96, 165, 250, 0.18);
  }

  .dropdown-item.active {
    color: #60a5fa;
  }

  .dropdown-divider {
    background: #3a3f4e;
  }

  .dropdown-lang label {
    color: #9aa1b0;
  }

  .dropdown-lang select {
    border-color: #3a3f4e;
    color: #e5e7eb;
  }
}

.dropdown-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.55rem 0.6rem;
  border: none;
  background: transparent;
  color: inherit;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  box-sizing: border-box;
}

.dropdown-item:hover {
  background: rgba(37, 99, 235, 0.1);
}

.dropdown-item.active {
  color: #2563eb;
  font-weight: 600;
}

.dropdown-divider {
  height: 1px;
  background: #e5e5e5;
  margin: 0.4rem 0.2rem;
}

.dropdown-lang {
  padding: 0.2rem 0.6rem 0.3rem;
}

.dropdown-lang label {
  display: block;
  font-size: 0.75rem;
  color: #666;
  margin: 0 0 0.25rem;
}

.dropdown-lang select {
  width: 100%;
  padding: 0.4rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  background: transparent;
  box-sizing: border-box;
}

fieldset {
  border: 1px solid #ccc;
  border-radius: 8px;
  margin-bottom: 1rem;
}

label {
  display: block;
  margin: 0.5rem 0;
  font-size: 0.9rem;
}

input {
  display: block;
  width: 100%;
  padding: 0.4rem;
  margin-top: 0.2rem;
  box-sizing: border-box;
}

button[type="submit"],
#btn-start-camera,
#btn-stop-camera {
  padding: 0.6rem 1.2rem;
  border-radius: 6px;
  border: none;
  background: #2563eb;
  color: white;
  cursor: pointer;
}

.error {
  color: #b91c1c;
  margin-top: 0.75rem;
}

#qr-result {
  margin-top: 1.5rem;
  text-align: center;
}

#qr-img {
  max-width: 280px;
  border: 1px solid #ddd;
  border-radius: 8px;
}

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

.actions a,
#scanned-vcf-download {
  padding: 0.5rem 1rem;
  border-radius: 6px;
  background: #16a34a;
  color: white;
  text-decoration: none;
}

.hint {
  color: #666;
  font-size: 0.85rem;
  margin-top: 1rem;
}

.scan-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1rem;
}

.file-fallback {
  font-size: 0.85rem;
  color: #666;
}

#scan-video {
  width: 100%;
  max-width: 480px;
  border-radius: 8px;
  background: #000;
}

#scan-result {
  margin-top: 1.5rem;
  padding: 1rem;
  border: 1px solid #ddd;
  border-radius: 8px;
}

.eyebrow {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #666;
  margin: 0 0 0.6rem;
}

/* ---------- shared button variants (tier choice, payment stepper) ---------- */

.btn {
  display: inline-block;
  padding: 0.55rem 0.9rem;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  box-sizing: border-box;
  text-align: center;
}

.tier-card button.btn {
  width: 100%;
}

/* Wins over the generic `button[type="submit"]` blue-fill rule further up this file (higher
   specificity via the extra .btn-outline class) — the free-tier action must look outlined, not
   filled, to read as the secondary choice next to the featured Verified card. */
.tier-card button[type="submit"].btn-outline {
  background: transparent;
  color: #2563eb;
  border: 1.5px solid #2563eb;
}

.tier-card button[type="submit"].btn-outline:hover {
  background: rgba(37, 99, 235, 0.08);
}

.btn-outline {
  border: 1.5px solid #2563eb;
  color: #2563eb;
  background: transparent;
}

.btn-outline:hover {
  background: rgba(37, 99, 235, 0.08);
}

.btn-solid {
  border: none;
  background: #16a34a;
  color: white;
}

.btn-solid:hover {
  filter: brightness(1.05);
}

.btn-ghost {
  border: 1px solid #888;
  background: transparent;
  color: inherit;
}

/* ---------- tier choice (create form) ---------- */

.tier-choice {
  margin-top: 1.2rem;
  padding-top: 1rem;
  border-top: 1px dashed #ccc;
}

.tier-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.tier-card {
  position: relative;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 1rem 1.1rem 1.2rem;
}

.tier-card.featured {
  border-color: #ca8a04;
  background: linear-gradient(180deg, rgba(202, 138, 4, 0.07), transparent 55%);
}

.ribbon {
  position: absolute;
  top: -0.6rem;
  right: 1rem;
  background: #ca8a04;
  color: white;
  font-size: 0.65rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.22rem 0.5rem;
  border-radius: 3px;
}

.tier-name {
  font-weight: 700;
  margin: 0 0 0.15rem;
}

.tier-price {
  font-size: 1.2rem;
  margin: 0.2rem 0 0.7rem;
}

.mono {
  font-variant-numeric: tabular-nums;
}

.tier-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
  font-size: 0.85rem;
  color: #555;
}

.tier-list li {
  padding: 0.3rem 0;
  border-top: 1px solid #eee;
}

.tier-list li:first-child {
  border-top: none;
}

.paid-currency-label {
  display: block;
  font-size: 0.78rem;
  color: #666;
  margin: 0.3rem 0 0.8rem;
}

.paid-currency-label select {
  display: block;
  width: auto;
  margin-top: 0.25rem;
  padding: 0.35rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  background: transparent;
}

/* ---------- payment stepper ---------- */

.stepper {
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid #ddd;
  border-radius: 8px;
}

.steps {
  display: flex;
  align-items: center;
}

.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  flex: 1;
  text-align: center;
}

.step .dot {
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  border: 1.5px solid #ccc;
  color: #888;
}

.step.done .dot {
  background: #16a34a;
  border-color: #16a34a;
  color: white;
}

.step.current .dot {
  border-color: #2563eb;
  color: #2563eb;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.15);
}

.step .label {
  font-size: 0.78rem;
  color: #888;
}

.step.current .label {
  color: #111;
  font-weight: 600;
}

.connector {
  flex: 1;
  height: 1.5px;
  background: #ddd;
  margin-bottom: 1.6rem;
}

.connector.done {
  background: #16a34a;
}

.payment-panel-body {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px dashed #ddd;
}

.step-actions {
  display: flex;
  gap: 0.7rem;
  margin-top: 0.9rem;
}

.step-actions .btn {
  flex: 1;
}

/* ---------- dashboard: card grid + branded card tiles ---------- */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: 1rem;
}

.new-card-tile {
  aspect-ratio: 16 / 10;
  border-radius: 10px;
  border: 1.5px dashed #bbb;
  background: transparent;
  color: #888;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  cursor: pointer;
  font-size: 0.85rem;
}

.new-card-tile:hover {
  border-color: #2563eb;
  color: #2563eb;
}

.new-card-tile .plus {
  font-size: 1.4rem;
  line-height: 1;
}

.card-tile-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.card-tile-actions a,
.card-tile-actions button {
  font-size: 0.78rem;
  padding: 0.3rem 0.55rem;
  border-radius: 6px;
  border: 1px solid #888;
  background: transparent;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}

.biz-card {
  position: relative;
  aspect-ratio: 16 / 10;
  border-radius: 10px;
  padding: 0.8rem 0.9rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: #f6f7fb;
  background: linear-gradient(155deg, #1b2340 0%, #2b3563 100%);
  overflow: hidden;
}

.biz-card.card-expired {
  opacity: 0.55;
}

.biz-card .name {
  font-weight: 700;
  font-size: 0.95rem;
}

.biz-card .org {
  font-size: 0.72rem;
  color: rgba(246, 247, 251, 0.72);
  margin-top: 0.1rem;
}

.status-chip {
  align-self: flex-start;
  font-size: 0.62rem;
  letter-spacing: 0.02em;
  padding: 0.2rem 0.45rem;
  border-radius: 3px;
}

.status-chip.verified {
  background: #ca8a04;
  color: #241a04;
}

.status-chip.free {
  background: rgba(255, 255, 255, 0.16);
  color: #f6f7fb;
}

.status-chip.soon {
  background: #dc2626;
  color: white;
}

.corner-seal {
  position: absolute;
  top: -0.4rem;
  right: 0.7rem;
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 50%;
  background: #ca8a04;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.62rem;
  font-weight: 700;
  color: #241a04;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.35);
}

.card-logo-badge {
  position: absolute;
  top: 0.6rem;
  left: 0.7rem;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 4px;
  background: white;
  padding: 2px;
  object-fit: contain;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

/* ---------- profile page logo (server-rendered, ProfileRoutes.scala) ---------- */

.card-logo {
  max-width: 96px;
  max-height: 96px;
  object-fit: contain;
  margin-bottom: 0.5rem;
}

.admin-stats {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.3rem 1rem;
  font-size: 0.9rem;
}

.admin-stats dt {
  color: #666;
}

.admin-stats dd {
  margin: 0;
  font-weight: 600;
  text-align: right;
}

#admin-feedback-list {
  list-style: none;
  padding: 0;
  font-size: 0.9rem;
}

#admin-feedback-list li {
  padding: 0.4rem 0;
  border-bottom: 1px solid #ddd;
}

footer {
  margin-top: 2.5rem;
  padding-top: 1rem;
  border-top: 1px solid #ddd;
}

footer fieldset {
  font-size: 0.9rem;
}

#feedback-message {
  width: 100%;
  box-sizing: border-box;
  padding: 0.4rem;
  margin-top: 0.2rem;
  font-family: inherit;
}

#feedback-thanks {
  color: #16a34a;
  margin-left: 0.5rem;
}
