:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f3f4f6;
  color: #111827;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: #f3f4f6; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 18px;
  background: rgba(255,255,255,.92);
  border-bottom: 1px solid #d7dce2;
  backdrop-filter: blur(12px);
}
.brand { font-weight: 800; }
.topbar nav { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.topbar form { margin: 0; }
.topbar button, .topbar a { border: 0; background: transparent; color: #374151; padding: 6px; }
.current-user {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 4px 9px;
  border: 1px solid #aeb7c4;
  border-radius: 6px;
  background: #111827;
  color: #fff;
  font-weight: 800;
  max-width: 34vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.page { width: min(980px, 100%); margin: 0 auto; padding: 18px; }

.login-panel {
  width: min(380px, calc(100vw - 36px));
  margin: 12vh auto 0;
  padding: 28px;
  background: #fff;
  border: 1px solid #d7dce2;
  border-radius: 8px;
}
.login-mark { display: grid; gap: 6px; margin-bottom: 20px; }
.login-mark span { display: block; height: 11px; border-radius: 4px; }
.login-mark span:nth-child(1) { background: #ff5a5f; }
.login-mark span:nth-child(2) { background: #00a6a6; }
.login-mark span:nth-child(3) { background: #ffd166; }
h1 { margin: 0 0 18px; font-size: 28px; line-height: 1.1; }
.error { padding: 10px 12px; background: #fee2e2; color: #991b1b; border-radius: 6px; }
.notice { padding: 11px 12px; background: #e0f2fe; color: #075985; border: 1px solid #bae6fd; border-radius: 6px; }
.muted { color: #6b7280; }

.form { display: grid; gap: 14px; }
.form label { display: grid; gap: 6px; font-weight: 650; color: #374151; }
.form input, .form textarea, .form select {
  width: 100%;
  border: 1px solid #c7cdd6;
  border-radius: 6px;
  padding: 11px 12px;
  background: #fff;
  color: #111827;
}
.form textarea { resize: vertical; }
.form input[readonly], .form textarea[readonly] {
  background: #eef1f5;
  color: #4b5563;
  border-color: #cfd6df;
}
.form input[readonly]::placeholder, .form textarea[readonly]::placeholder {
  color: #7b8492;
  opacity: 1;
}
.primary, button.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 6px;
  padding: 11px 14px;
  min-height: 42px;
  background: #111827;
  color: #fff;
  font-weight: 760;
}
.danger {
  border: 1px solid #fecaca;
  border-radius: 6px;
  padding: 8px 10px;
  background: #fff1f2;
  color: #9f1239;
}

.wallet-strip {
  display: grid;
  gap: 16px;
  padding-bottom: 32px;
}
.hidden-cards {
  margin: 4px 0 30px;
}
.hidden-cards summary {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 10px 13px;
  border: 1px solid #c7cdd6;
  border-radius: 6px;
  background: #fff;
  color: #111827;
  font-weight: 800;
  cursor: pointer;
}
.hidden-strip { margin-top: 16px; }
.hidden-wallet-card { opacity: .82; }
.wallet-card {
  display: grid;
  gap: 12px;
  min-height: 260px;
  padding: 16px;
  border-radius: 8px;
  background: var(--primary);
  color: var(--accent);
  box-shadow: 0 10px 28px rgba(17,24,39,.14);
}
.wallet-card-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.wallet-card-head span { font-size: 22px; font-weight: 850; overflow-wrap: anywhere; }
.wallet-card-head small { opacity: .82; }
.wallet-card img {
  width: 100%;
  height: 180px;
  object-fit: contain;
  padding: 12px;
  background: #fff;
  border-radius: 6px;
}
.wallet-card img.generated-code {
  height: 190px;
  padding: 16px;
  image-rendering: crisp-edges;
}
.wallet-card p { margin: 0; font-weight: 650; opacity: .9; }
.empty-code {
  min-height: 180px;
  display: grid;
  place-items: center;
  padding: 12px;
  background: #fff;
  color: #111827;
  border-radius: 6px;
  overflow-wrap: anywhere;
}
.empty-state {
  min-height: 55vh;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 16px;
}

.detail-card {
  min-height: calc(100vh - 88px);
  display: grid;
  gap: 16px;
  padding: 16px;
  border-radius: 8px;
  background: var(--primary);
  color: var(--accent);
}
.detail-card header { display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 2px solid currentColor; padding-bottom: 12px; }
.detail-card h1 { margin: 0; font-size: clamp(22px, 7vw, 42px); overflow-wrap: anywhere; }
.scan-zone {
  display: grid;
  place-items: center;
  min-height: 48vh;
  background: #fff;
  color: #111827;
  border-radius: 8px;
  padding: 14px;
}
.scan-zone img { width: 100%; max-height: 68vh; object-fit: contain; }
.original-image-link {
  display: grid;
  place-items: center;
  width: 100%;
}
.scan-zone strong { font-size: clamp(24px, 8vw, 56px); overflow-wrap: anywhere; text-align: center; }
.generated-scan-zone {
  display: grid;
  place-items: center;
  min-height: 78vh;
  margin: 10vh 0 12vh;
  padding: 28px 16px;
  background: #fff;
  border-radius: 8px;
}
.generated-scan-zone img {
  width: 100%;
  max-width: 760px;
  max-height: 58vh;
  object-fit: contain;
  image-rendering: crisp-edges;
}
.original-scan-zone {
  min-height: 34vh;
}
.original-scan-zone::before {
  content: "Photo originale";
  align-self: end;
  justify-self: start;
  color: #4b5563;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.details { display: grid; gap: 8px; background: rgba(255,255,255,.12); border-radius: 6px; padding: 12px; }
.details p { display: grid; gap: 3px; margin: 0; overflow-wrap: anywhere; }
.details b { font-size: 12px; text-transform: uppercase; opacity: .75; }

.admin-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.admin-head h1 { margin: 0; }
.admin-list, .user-list { display: grid; gap: 10px; }
.admin-row, .user-row {
  display: grid;
  grid-template-columns: 72px 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  background: #fff;
  border: 1px solid #d7dce2;
  border-radius: 8px;
}
.admin-row input { width: 64px; border: 1px solid #c7cdd6; border-radius: 6px; padding: 8px; }
.admin-row a { display: grid; gap: 2px; }
.admin-row span { color: #6b7280; font-size: 14px; overflow-wrap: anywhere; }
.admin-row button:not(.danger), .edit-form button:not(.primary) {
  border: 1px solid #c7cdd6;
  border-radius: 6px;
  background: #fff;
  padding: 8px 10px;
}
.scan-state { color: #6b7280; overflow-wrap: anywhere; }
.scan-state.found { color: #047857; }
.scan-state.not_found, .scan-state.error { color: #b45309; }
.scan-summary {
  margin: 0;
  padding: 10px 12px;
  background: #f8fafc;
  border: 1px solid #d7dce2;
  border-radius: 6px;
  color: #374151;
  overflow-wrap: anywhere;
}
.edit-form, .user-create {
  padding: 16px;
  background: #fff;
  border: 1px solid #d7dce2;
  border-radius: 8px;
}
.preview { width: 100%; max-height: 260px; object-fit: contain; background: #f9fafb; border-radius: 6px; border: 1px solid #e5e7eb; }
.two-cols { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.color-grid label { gap: 8px; }
.color-picker {
  display: grid;
  grid-template-columns: 96px 1fr;
  align-items: stretch;
  gap: 10px;
}
.color-picker input[type="color"] {
  width: 96px;
  height: 58px;
  padding: 4px;
  cursor: pointer;
}
.color-picker span {
  display: grid;
  place-items: center start;
  min-height: 58px;
  padding: 0 12px;
  border: 1px solid #c7cdd6;
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 700;
  background: #f9fafb;
}
.share-box {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 12px;
  border: 1px solid #d7dce2;
  border-radius: 6px;
}
.share-box legend { padding: 0 5px; color: #374151; font-weight: 700; }
.check { display: flex !important; grid-template-columns: auto 1fr; align-items: center; }
.check input { width: auto; }
.user-create { margin-bottom: 16px; }
.user-row { grid-template-columns: 1fr 1.5fr auto auto auto; }
.user-row input[type="password"] { min-width: 0; border: 1px solid #c7cdd6; border-radius: 6px; padding: 8px; }
.user-row button { border: 1px solid #c7cdd6; border-radius: 6px; background: #fff; padding: 8px 10px; }

@media (min-width: 780px) {
  .wallet-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
  .page { padding: 12px; }
  .topbar { padding: 10px 12px; }
  .topbar nav { gap: 6px; }
  .current-user { max-width: 26vw; }
  .wallet-card { min-height: 230px; }
  .admin-row { grid-template-columns: 58px 1fr; }
  .admin-row button { grid-column: 1 / -1; }
  .user-row { grid-template-columns: 1fr; }
  .two-cols { grid-template-columns: 1fr; }
}
