:root {
  --brand: #63b632;
  --brand-dark: #4a9025;
  --brand-darker: #3d7820;
  --brand-deeper: #2f5f18;
  --brand-light: #8bc966;
  --brand-lighter: #b3dda9;
  --brand-pale: #d4efcf;
  --brand-bg: #eef8ea;
  --brand-tint: rgba(99, 182, 50, 0.1);
  --brand-tint-strong: rgba(99, 182, 50, 0.18);
  --surface: #ffffff;
  --text: #1a1a1a;
  --text-muted: #5a6b52;
  --danger: #c0392b;
  --border: #cfe6c4;
  --shadow: 0 2px 12px rgba(99, 182, 50, 0.12);
  --radius: 14px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

html, body {
  overscroll-behavior: none;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--brand-bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100dvh;
}

svg path {
  fill: currentColor;
}

.hidden {
  display: none !important;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  background: var(--surface);
}

.app-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(12px + var(--safe-top)) 16px 12px;
  background: var(--brand);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 50;
}

.app-bar__back {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
}

.app-bar__back svg {
  width: 22px;
  height: 22px;
}

.app-bar__back.hidden {
  visibility: hidden;
  pointer-events: none;
}

.app-bar__title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  flex: 1;
}

.app-bar__icon svg {
  width: 28px;
  height: 28px;
}

.screen {
  padding: 16px;
  padding-bottom: calc(16px + var(--safe-bottom));
}

.screen--center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100dvh - 64px - var(--safe-top));
  text-align: center;
}

.splash {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  background: var(--brand-bg);
}

.splash__logo {
  width: 152px;
  height: 110px;
  margin-bottom: 16px;
}

.splash__title {
  margin: 0 0 24px;
  color: var(--brand-darker);
  font-size: 1.4rem;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--brand-pale);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.alert {
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 0.95rem;
  text-align: center;
}

.alert--danger {
  background: #fdecea;
  color: var(--danger);
  border: 1px solid #f5c6cb;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--brand-darker);
}

.field input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
  background: var(--brand-bg);
}

.field input:focus {
  outline: 2px solid var(--brand-lighter);
  border-color: var(--brand);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 8px;
}

.btn {
  padding: 12px 18px;
  border: none;
  border-radius: var(--radius);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.btn--primary {
  background: var(--brand);
  color: #fff;
}

.btn--primary:active {
  background: var(--brand-dark);
}

.btn--secondary {
  background: var(--brand-pale);
  color: var(--brand-darker);
}

.btn--ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn--block {
  width: 100%;
}

.card-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.home-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  background: var(--brand-tint);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
  width: 100%;
  font: inherit;
  color: inherit;
  transition: background 0.15s;
}

.home-card:active {
  background: var(--brand-tint-strong);
}

.home-card__title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--brand-darker);
}

.home-card__preview {
  flex-shrink: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: right;
}

.qr-box {
  display: inline-block;
  padding: 6px;
  background: #fff;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.qr-box canvas,
.qr-box img {
  display: block;
}

.qr-box--lg {
  padding: 12px;
}

.qr-box--lg canvas,
.qr-box--lg img {
  width: 260px !important;
  height: 260px !important;
}

.carte-name {
  margin: 20px 0;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--brand-darker);
}

.detail-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: var(--brand-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.detail-row__label {
  font-weight: 600;
  color: var(--brand-darker);
}

.detail-row__value {
  color: var(--text-muted);
  text-align: right;
}

.info-section {
  margin-bottom: 16px;
  padding: 16px;
  background: var(--brand-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.info-section h3 {
  margin: 0 0 10px;
  font-size: 1rem;
  color: var(--brand-darker);
}

.info-section ul {
  margin: 0;
  padding-left: 18px;
  color: var(--text-muted);
}

.info-section a {
  color: var(--brand-dark);
  font-weight: 600;
}

.info-text a {
  display: block;
  text-align: center;
  margin: 6px 0;
  font-weight: 600;
  color: #3d7820;
}

.info-footer {
  margin-top: 12px;
  font-weight: bold;
  font-size: 0.9rem;
  color: #3d7820;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 200;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 320px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow);
}

.modal h2 {
  margin: 0 0 16px;
  color: var(--brand-darker);
}

.loading-text {
  color: var(--text-muted);
  font-size: 0.9rem;
}

@media (min-width: 481px) {
  body {
    background: linear-gradient(180deg, var(--brand-pale) 0%, var(--brand-bg) 160px);
  }

  #app {
    box-shadow: 0 0 40px rgba(99, 182, 50, 0.15);
  }
}
