:root {
  --bg: #f6f7f4;
  --surface: #ffffff;
  --ink: #151817;
  --muted: #64706a;
  --line: #dfe4df;
  --accent: #007f73;
  --accent-strong: #005f56;
  --danger: #b42318;
  --shadow: 0 18px 50px rgba(26, 34, 30, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px clamp(18px, 4vw, 56px);
  background: rgba(246, 247, 244, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.app-brand,
.app-topbar nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-brand {
  text-decoration: none;
}

.app-brand img {
  display: block;
  width: min(210px, 52vw);
  max-height: 42px;
  object-fit: contain;
}

.app-topbar nav a,
.app-topbar nav button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.app-main {
  width: min(1160px, calc(100% - 36px));
  margin: 0 auto;
  padding: clamp(34px, 6vw, 72px) 0;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 12px;
  font-size: clamp(2.1rem, 5vw, 4rem);
  line-height: 1.02;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 8px;
  font-size: 1.35rem;
}

p {
  color: var(--muted);
  line-height: 1.55;
}

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 11px 16px;
  border: 1px solid var(--ink);
  border-radius: 8px;
  font-weight: 900;
  text-decoration: none;
  cursor: pointer;
}

.button.primary {
  background: var(--ink);
  color: var(--surface);
}

.button.secondary {
  background: var(--surface);
}

.button.disabled,
.button:disabled {
  opacity: 0.58;
  cursor: not-allowed;
}

.button.is-success {
  border-color: var(--accent);
  background: #e8f7f1;
  color: var(--accent);
}

.button.danger {
  width: 100%;
  border-color: var(--danger);
  background: var(--surface);
  color: var(--danger);
}

.button.wide {
  width: 100%;
}

.auth-panel,
.form-shell {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(320px, 1.1fr);
  gap: 22px;
  align-items: start;
}

.stack,
.card-editor,
.side-panel,
.empty-state,
.public-card,
.card-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 12px 34px rgba(26, 34, 30, 0.07);
}

.stack,
.card-editor,
.side-panel,
.empty-state,
.public-card {
  display: grid;
  gap: 16px;
  padding: 22px;
}

.card-editor,
.side-panel,
.crop-tool {
  min-width: 0;
}

.notice.error {
  padding: 12px;
  border-radius: 8px;
  background: #fff0ed;
  color: var(--danger);
  font-weight: 800;
}

.notice.success {
  padding: 12px;
  border-radius: 8px;
  background: #e8f7f1;
  color: var(--accent-strong);
  font-weight: 800;
}

.field-note {
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: #f0f3ef;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

label,
fieldset {
  display: grid;
  gap: 8px;
}

label {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 800;
}

label small {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.4;
}

fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  margin-bottom: 8px;
  font-weight: 900;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  color: var(--ink);
  font: inherit;
}

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 19px, calc(100% - 13px) 19px;
  background-repeat: no-repeat;
  background-size: 5px 5px, 5px 5px;
}

input[type="color"] {
  width: 80px;
  min-height: 44px;
  padding: 4px;
}

input[type="range"] {
  padding: 0;
}

textarea {
  resize: vertical;
}

.check-row {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.check-row input {
  width: auto;
  min-height: auto;
}

.inline-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  gap: 12px;
}

.page-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.heading-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.plan-pill {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border: 1px solid rgba(0, 127, 115, 0.28);
  border-radius: 8px;
  background: #e8f7f1;
  color: var(--accent-strong);
  font-size: 0.86rem;
  font-weight: 900;
}

.upgrade-strip,
.locked-box,
.pricing-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 12px 34px rgba(26, 34, 30, 0.07);
}

.upgrade-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  padding: 18px;
}

.upgrade-strip h2,
.locked-box h2 {
  margin-bottom: 6px;
}

.upgrade-strip p:last-child,
.locked-box p:last-child {
  margin-bottom: 0;
}

.locked-box {
  display: grid;
  gap: 10px;
  padding: 16px;
  background: #fbfcfa;
}

.locked-box.compact {
  box-shadow: none;
}

.pricing-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.pricing-card {
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 22px;
}

.pricing-card.featured {
  border-color: var(--accent);
  box-shadow: 0 14px 34px rgba(0, 127, 115, 0.14);
}

.pricing-card.nfc-card {
  background: #fbfcfa;
}

.pricing-card h2 {
  color: var(--accent-strong);
  font-size: 1.9rem;
}

.pricing-card ul {
  display: grid;
  gap: 9px;
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.45;
}

.admin-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.42fr) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.admin-create-user {
  position: sticky;
  top: 94px;
}

.admin-users,
.admin-user-card,
.admin-card-list,
.admin-card-item {
  display: grid;
  gap: 14px;
}

.admin-user-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 12px 34px rgba(26, 34, 30, 0.07);
}

.admin-user-head,
.admin-plan-form,
.admin-card-item {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.admin-user-head h2 {
  margin-bottom: 4px;
}

.admin-user-head p:last-child {
  margin-bottom: 0;
  overflow-wrap: anywhere;
}

.admin-plan-form label {
  flex: 1 1 220px;
}

.admin-card-list {
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.admin-card-item {
  padding: 12px;
  border-radius: 8px;
  background: #fbfcfa;
}

.admin-card-item strong,
.admin-card-item span {
  display: block;
}

.admin-card-item span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.empty-state {
  max-width: 620px;
}

.card-list {
  display: grid;
  gap: 14px;
}

.card-row {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  padding: 18px;
}

.card-row .qr-thumb,
.side-panel img {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.crop-tool {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.crop-frame {
  position: relative;
  display: grid;
  overflow: hidden;
  place-items: center;
  background: #eef2ee;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.crop-frame img,
.public-cover img,
.public-logo,
.side-cover-preview img,
.side-avatar-preview img {
  position: absolute;
  top: 50%;
  left: 50%;
  width: calc(100% * var(--crop-scale, 1));
  height: calc(100% * var(--crop-scale, 1));
  object-fit: contain;
  object-position: center;
  transform: translate(
    calc(-50% + var(--crop-translate-x, 0%)),
    calc(-50% + var(--crop-translate-y, 0%))
  );
}

.crop-frame img {
  display: block;
}

.avatar-crop {
  width: 150px;
  height: 150px;
  border: 4px solid var(--surface);
  border-radius: 50%;
  box-shadow: 0 10px 24px rgba(26, 34, 30, 0.12);
}

.cover-crop {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  min-height: 150px;
  border-radius: 8px;
}

.crop-controls {
  display: grid;
  gap: 10px;
}

.meta-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.meta-grid span {
  padding: 9px 10px;
  border-radius: 8px;
  background: #f0f3ef;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.meta-grid strong {
  color: var(--ink);
}

.card-actions,
.side-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.owner-shortcut {
  display: grid;
  grid-column: 1 / -1;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.owner-shortcut[hidden] {
  display: none;
}

.owner-shortcut h3 {
  margin: 0 0 6px;
}

.owner-shortcut p {
  margin-bottom: 0;
}

.owner-shortcut ol {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.45;
}

.shortcut-url {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  align-items: center;
}

.shortcut-url span {
  flex: 1 1 260px;
  min-width: 0;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 800;
  overflow-wrap: anywhere;
}

.side-panel {
  position: sticky;
  top: 94px;
}

.side-panel a {
  overflow-wrap: anywhere;
}

.side-card-preview {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  text-align: center;
}

.side-cover-preview {
  position: relative;
  overflow: hidden;
  height: 120px;
  background: linear-gradient(135deg, var(--card-accent), #151817);
}

.side-avatar-preview {
  position: relative;
  display: block;
  overflow: hidden;
  width: 86px;
  height: 86px;
  margin: -43px auto 8px;
  border: 4px solid var(--surface);
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.14);
}

.side-card-preview p {
  margin: 0;
  padding: 0 14px 14px;
  color: var(--ink);
  font-weight: 900;
}

.public-card {
  --card-accent: var(--accent);
  position: relative;
  overflow: hidden;
  width: min(460px, 100%);
  margin: 0 auto;
  padding: 0 0 22px;
  text-align: center;
}

.public-cover {
  position: relative;
  overflow: hidden;
  height: 150px;
  background: linear-gradient(135deg, var(--card-accent), #151817);
}

.public-cover img {
  display: block;
}

.public-identity {
  display: grid;
  gap: 12px;
  padding: 0 22px;
  transform: translateY(-56px);
  margin-bottom: -56px;
}

.public-avatar {
  display: grid;
  width: 116px;
  height: 116px;
  margin: 0 auto;
  place-items: center;
  border: 5px solid var(--surface);
  border-radius: 50%;
  background: var(--card-accent);
  color: var(--surface);
  font-size: 2rem;
  font-weight: 900;
}

.public-logo-frame {
  position: relative;
  display: block;
  overflow: hidden;
  width: 116px;
  height: 116px;
  margin: 0 auto;
  border: 5px solid var(--surface);
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.16);
}

.public-logo {
  display: block;
}

.public-card .button.primary {
  border-color: var(--card-accent);
  background: var(--card-accent);
}

.public-actions {
  display: grid;
  gap: 10px;
  padding: 0 22px;
}

.public-actions a {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  color: var(--ink);
  font-weight: 900;
  text-decoration: none;
}

.public-note {
  margin: 0 22px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  text-align: left;
}

.powered-by {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 4px 22px 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-decoration: none;
}

.powered-by img {
  display: block;
  width: 120px;
  max-height: 28px;
  object-fit: contain;
}

.print-sheet {
  display: grid;
  width: min(760px, 100%);
  margin: 0 auto;
  gap: 24px;
}

.print-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--muted);
  font-weight: 900;
}

.print-brand img {
  display: block;
  width: min(260px, 80%);
  max-height: 70px;
  object-fit: contain;
}

.print-card {
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  text-align: center;
  box-shadow: var(--shadow);
}

.print-card img {
  width: min(420px, 100%);
  height: auto;
}

.print-card a {
  max-width: 100%;
  color: var(--muted);
  font-weight: 900;
  overflow-wrap: anywhere;
}

.print-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
}

@media (max-width: 820px) {
  .app-topbar,
  .page-heading,
  .upgrade-strip {
    align-items: flex-start;
    flex-direction: column;
  }

  .auth-panel,
  .form-shell,
  .card-row,
  .inline-grid,
  .pricing-grid,
  .admin-layout {
    grid-template-columns: 1fr;
  }

  .side-panel,
  .admin-create-user {
    position: static;
  }

  .admin-user-head,
  .admin-plan-form,
  .admin-card-item {
    align-items: stretch;
    flex-direction: column;
  }

  .cover-crop {
    min-height: 0;
  }

  .side-cover-preview {
    height: auto;
    aspect-ratio: 16 / 9;
  }

  .card-actions {
    width: 100%;
  }

  .card-actions .button {
    flex: 1;
  }
}

@media print {
  @page {
    margin: 14mm;
  }

  body {
    background: #ffffff;
  }

  .app-main {
    width: 100%;
    padding: 0;
  }

  .print-actions {
    display: none;
  }

  .print-card {
    box-shadow: none;
    break-inside: avoid;
  }
}
