:root {
  color-scheme: light;
  --bg: #ecefed;
  --panel: #ffffff;
  --ink: #151817;
  --muted: #68716d;
  --line: #d8dedb;
  --accent: #126fbd;
  --accent-ink: #ffffff;
  --green: #2f6f4e;
  --danger: #af2e2e;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #f6f7f5 0%, var(--bg) 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

.shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 24px auto;
}

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  background: rgba(236, 239, 237, 0.96);
  padding: 18px;
}

.auth-screen[hidden] {
  display: none;
}

.auth-panel {
  width: min(430px, 100%);
  display: grid;
  gap: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 55px rgba(28, 35, 31, 0.14);
  padding: 24px;
}

.auth-brand {
  margin-bottom: 8px;
}

.login-error {
  color: var(--danger);
  font-weight: 800;
}

.workbench {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 18px;
  align-items: stretch;
}

.panel,
.preview-area {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 55px rgba(28, 35, 31, 0.10);
}

.controls {
  padding: 22px;
  position: relative;
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 26px;
  min-width: 0;
}

.controls > .brand {
  padding-right: 86px;
}

.brand > div {
  min-width: 0;
}

.brand-logo {
  display: block;
  flex: 0 0 58px;
  width: 58px;
  height: 58px;
  max-width: 58px;
  max-height: 58px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid #202724;
  background: #111;
}

.brand-logo.small {
  flex-basis: 54px;
  width: 54px;
  height: 54px;
  max-width: 54px;
  max-height: 54px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1;
  overflow-wrap: anywhere;
}

.brand p,
.preview-head p {
  color: var(--muted);
  margin-top: 6px;
}

.form {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 7px;
  font-weight: 700;
}

label span {
  font-size: 14px;
}

select,
input,
button {
  width: 100%;
  min-height: 46px;
  border-radius: 8px;
  font: inherit;
}

select,
input {
  border: 1px solid #bfc8c4;
  background: #fbfcfb;
  color: var(--ink);
  padding: 0 12px;
}

input {
  text-transform: none;
}

.split {
  display: grid;
  grid-template-columns: 0.7fr 1.3fr;
  gap: 12px;
}

button {
  margin-top: 4px;
  border: 0;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 900;
  cursor: pointer;
}

.ghost-btn {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
}

.auth-hint,
.access-note,
.order-form p,
#orderStatus {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.access-note {
  margin-top: 14px;
}

.access-note.public {
  color: #765e00;
}

.nfc-help {
  display: grid;
  gap: 8px;
  border: 1px solid #d2ddd8;
  border-radius: 8px;
  background: #f7fbf9;
  padding: 12px;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.45;
}

.nfc-help strong {
  font-size: 14px;
}

.nfc-help p {
  color: var(--muted);
}

.nfc-help details {
  border-top: 1px solid #dce4e0;
  padding-top: 8px;
}

.nfc-help summary {
  color: var(--accent);
  cursor: pointer;
  font-weight: 800;
}

.nfc-help ul {
  margin: 8px 0;
  padding-left: 18px;
  color: var(--muted);
}

button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.generation-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.generation-actions.admin {
  grid-template-columns: 1fr 1fr;
}

.generation-actions .ghost-btn {
  border: 1px solid #9fb0a8;
}

.logout-btn {
  position: absolute;
  top: 18px;
  right: 18px;
  width: auto;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.preview-area {
  min-height: calc(100vh - 48px);
  padding: 22px;
  display: grid;
  grid-template-rows: auto minmax(300px, 1fr) auto;
  gap: 16px;
}

.preview-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

h2 {
  font-size: 22px;
}

.badge {
  min-width: 74px;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.badge.running {
  color: #765e00;
  border-color: #e5c75a;
  background: #fff8d7;
}

.badge.succeeded {
  color: var(--green);
  border-color: #b9d8c5;
  background: #f0fbf4;
}

.badge.failed {
  color: var(--danger);
  border-color: #efb8b8;
  background: #fff1f1;
}

.preview-frame {
  display: grid;
  place-items: center;
  border: 1px dashed #c9d0cc;
  border-radius: 8px;
  background: #f8faf8;
  min-height: 300px;
  overflow: hidden;
}

.preview-frame img {
  width: min(100%, 620px);
  max-height: 70vh;
  object-fit: contain;
  padding: 16px;
}

.result-panel {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 14px;
  align-items: center;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.result-content {
  min-width: 0;
}

.result-actions {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.result-price {
  display: grid;
  gap: 3px;
  margin: 0;
}

.result-price span {
  color: var(--muted);
  font-size: 13px;
}

.result-price strong {
  font-size: 22px;
}

.result-actions form,
.result-actions button {
  width: auto;
  margin: 0;
}

.result-status {
  margin: 10px 0 0;
  color: var(--green);
  font-weight: 750;
}

.order-panel {
  margin-top: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 55px rgba(28, 35, 31, 0.08);
  padding: 22px;
}

.order-form {
  display: grid;
  gap: 14px;
}

.order-form h2 {
  font-size: 20px;
}

textarea {
  width: 100%;
  min-height: 104px;
  resize: vertical;
  border-radius: 8px;
  border: 1px solid #bfc8c4;
  background: #fbfcfb;
  color: var(--ink);
  padding: 10px 12px;
  font: inherit;
}

.order-actions {
  display: grid;
  grid-template-columns: minmax(180px, 280px) 1fr;
  gap: 12px;
  align-items: center;
}

#orderStatus.ok {
  color: var(--green);
  font-weight: 800;
}

#orderStatus.failed {
  color: var(--danger);
  font-weight: 800;
}

.generated-preview {
  width: 160px;
  height: 112px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.downloads {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.downloads a {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  border-radius: 8px;
  padding: 0 12px;
  background: #202724;
  color: #fff;
  text-decoration: none;
  font-weight: 800;
}

.downloads a.primary {
  background: var(--green);
}

.product-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: -8px 0 16px;
}

.tab-btn {
  min-height: 40px;
  margin: 0;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-weight: 900;
}

.tab-btn.active {
  background: #202724;
  color: #fff;
  border-color: #202724;
}

.auto-form {
  gap: 14px;
}

.split.three {
  grid-template-columns: 0.7fr 1.1fr 0.9fr;
}

.auto-preview {
  width: min(100%, 760px);
  aspect-ratio: 3 / 1;
  display: grid;
  place-items: center;
  padding: 18px;
}

.auto-preview svg {
  width: 100%;
  height: auto;
  max-height: 62vh;
  filter: drop-shadow(0 10px 18px rgba(22, 24, 23, 0.16));
}

.auto-actions {
  display: flex;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.auto-actions button {
  width: auto;
  min-width: 120px;
  padding: 0 16px;
  margin: 0;
  background: #202724;
  color: #fff;
}

.core-nav {
  position: sticky;
  z-index: 10000;
  top: 0;
  width: 100%;
  min-height: 54px;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  border-bottom: 1px solid #2d4338;
  background: #101915;
  color: #f3fbf6;
}

.core-nav a {
  color: inherit;
  font-weight: 500;
  text-decoration: none;
}

.core-nav nav {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}

.core-nav nav::-webkit-scrollbar {
  display: none;
}

.core-nav [aria-current="page"] {
  color: #8ae1b3;
}

.core-nav-logo-link {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
}

.core-nav-logo {
  display: block;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  object-fit: cover;
}

.core-nav-spacer {
  flex: 1;
}

#cartBadge {
  display: inline-grid;
  min-width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 999px;
  background: #72d69b;
  color: #101915;
}

.personal-data-consent {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.personal-data-consent input {
  width: auto;
  margin-top: 3px;
}

@media (max-width: 860px) {
  .core-nav {
    gap: 5px;
    padding: 0 7px;
    font-size: 12px;
  }
  .core-nav nav {
    gap: 6px;
  }
  .core-nav nav a,
  .core-nav nav button {
    white-space: nowrap;
  }
  .core-nav-logo {
    width: 38px;
    height: 38px;
  }
  .shell {
    width: min(100vw - 18px, 640px);
    margin: 9px auto;
  }

  .workbench {
    grid-template-columns: 1fr;
  }

  .preview-area {
    min-height: auto;
  }

  .split,
  .split.three,
  .result-panel,
  .order-actions {
    grid-template-columns: 1fr;
  }

  .result-actions {
    align-items: stretch;
  }

  .auto-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .generated-preview {
    width: 100%;
  }
}
