/* Certificate Engine — app chrome */
:root {
  --ce-ink: #161411;
  --ce-ink-soft: #3a342c;
  --ce-muted: #7a7164;
  --ce-line: rgba(22, 20, 17, 0.1);
  --ce-paper: #f4f0e8;
  --ce-panel: #fffdf9;
  --ce-gold: #b08d4f;
  --ce-gold-soft: rgba(176, 141, 79, 0.16);
  --ce-ok: #1f6b4a;
  --ce-danger: #8b2e1f;
  --ce-shadow: 0 18px 48px rgba(22, 20, 17, 0.14);
  --ce-font: "DM Sans", system-ui, sans-serif;
  --ce-display: "Cormorant Garamond", Georgia, serif;
  --ce-sidebar: 380px;
}

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

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--ce-font);
  color: var(--ce-ink);
  background:
    radial-gradient(900px 480px at 0% 0%, rgba(176, 141, 79, 0.14), transparent 55%),
    radial-gradient(700px 420px at 100% 10%, rgba(26, 23, 20, 0.06), transparent 50%),
    linear-gradient(165deg, #ebe4d6 0%, #dcd4c4 55%, #d2c9b6 100%);
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

.ce-app {
  display: grid;
  grid-template-columns: minmax(300px, var(--ce-sidebar)) 1fr;
  min-height: 100vh;
}

.ce-sidebar {
  background: var(--ce-panel);
  border-right: 1px solid var(--ce-line);
  padding: 20px 18px 28px;
  overflow-y: auto;
  max-height: 100vh;
  position: sticky;
  top: 0;
}

.ce-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}
.ce-brand__mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: #1a1714;
  display: grid;
  place-items: center;
  box-shadow: var(--ce-shadow);
  flex-shrink: 0;
}
.ce-brand__mark img {
  width: 28px;
  height: 28px;
}
.ce-brand h1 {
  margin: 0;
  font-family: var(--ce-display);
  font-size: 1.55rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.1;
}
.ce-brand p {
  margin: 2px 0 0;
  font-size: 0.78rem;
  color: var(--ce-muted);
}

.ce-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}
.ce-server-banner {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 0.8rem;
  line-height: 1.4;
  background: rgba(139, 46, 31, 0.08);
  color: var(--ce-danger);
}
.ce-server-banner.is-ok {
  background: rgba(31, 107, 74, 0.1);
  color: var(--ce-ok);
}
.ce-server-banner.is-warn {
  background: rgba(176, 141, 79, 0.16);
  color: #6b5420;
}
.ce-login-btn {
  display: none;
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 10px;
  background: #1a1714;
  color: #f7f3ea !important;
  text-align: center;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.9rem;
}
.ce-login-btn:not([hidden]) {
  display: block;
}
.ce-login-btn:hover {
  background: #2c2620;
  color: #fff !important;
}
body.ce-module-page {
  padding-top: 0;
}
.ce-id-status {
  margin: 0 0 10px;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--ce-muted);
}
.ce-id-status.is-issued {
  color: var(--ce-ok);
  font-weight: 600;
}
#f-certno[readonly] {
  background: #f3eee4;
  font-family: ui-monospace, Consolas, monospace;
  letter-spacing: 0.03em;
}
.ce-btn {
  appearance: none;
  border: 1px solid var(--ce-line);
  background: #fff;
  border-radius: 10px;
  padding: 11px 12px;
  font-weight: 600;
  font-size: 0.86rem;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}
.ce-btn:hover {
  border-color: rgba(176, 141, 79, 0.55);
  background: #fffaf0;
}
.ce-btn:active {
  transform: translateY(1px);
}
.ce-btn--primary {
  background: #1a1714;
  color: #f7f3ea;
  border-color: #1a1714;
  grid-column: 1 / -1;
}
.ce-btn--primary:hover {
  background: #2c2620;
  border-color: #2c2620;
  color: #fff;
}
.ce-btn--ghost {
  background: transparent;
}

.ce-paper-card {
  background: linear-gradient(180deg, #fffefb, #f6f0e4);
  border: 1px solid rgba(176, 141, 79, 0.35);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 18px;
  box-shadow: 0 8px 24px rgba(176, 141, 79, 0.08);
}
.ce-paper-card__title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ce-gold);
  margin-bottom: 8px;
}
.ce-paper-card__size {
  font-family: var(--ce-display);
  font-size: 1.35rem;
  font-weight: 600;
  margin: 0 0 4px;
  line-height: 1.15;
}
.ce-paper-card__dims {
  font-size: 0.82rem;
  color: var(--ce-ink-soft);
  margin: 0 0 10px;
}
.ce-paper-card dl {
  margin: 0;
  display: grid;
  gap: 8px;
}
.ce-paper-card dt {
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ce-muted);
  margin-bottom: 2px;
}
.ce-paper-card dd {
  margin: 0;
  font-size: 0.84rem;
  line-height: 1.4;
  color: var(--ce-ink);
}
.ce-paper-card__tip {
  margin: 12px 0 0;
  padding: 10px;
  border-radius: 8px;
  background: rgba(31, 107, 74, 0.08);
  color: var(--ce-ok);
  font-size: 0.8rem;
  line-height: 1.45;
}

.ce-section {
  margin-bottom: 16px;
}
.ce-section__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.ce-section__title {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ce-muted);
}
.ce-section__hint {
  font-size: 0.72rem;
  color: var(--ce-gold);
  font-weight: 600;
}

.ce-field {
  margin-bottom: 10px;
}
.ce-field label {
  display: block;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--ce-ink-soft);
  margin-bottom: 5px;
}
.ce-field label .opt {
  font-weight: 500;
  color: var(--ce-muted);
}
.ce-field input,
.ce-field select,
.ce-field textarea {
  width: 100%;
  border: 1px solid var(--ce-line);
  background: #fff;
  border-radius: 9px;
  padding: 10px 11px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.ce-field input:focus,
.ce-field select:focus,
.ce-field textarea:focus {
  border-color: rgba(176, 141, 79, 0.7);
  box-shadow: 0 0 0 3px var(--ce-gold-soft);
}
.ce-field textarea {
  min-height: 72px;
  resize: vertical;
}
.ce-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.ce-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.ce-chip {
  appearance: none;
  border: 1px solid var(--ce-line);
  background: #fff;
  border-radius: 999px;
  padding: 7px 11px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--ce-ink-soft);
}
.ce-chip.is-active {
  background: #1a1714;
  color: #f7f3ea;
  border-color: #1a1714;
}

.ce-photos-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.ce-photo-slot {
  position: relative;
  border: 1px dashed rgba(176, 141, 79, 0.55);
  border-radius: 10px;
  background: #faf6ee;
  aspect-ratio: 1;
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-align: center;
  padding: 8px;
}
.ce-photo-slot:hover {
  border-style: solid;
  background: #fff8eb;
}
.ce-photo-slot.has-image {
  border-style: solid;
  border-color: rgba(176, 141, 79, 0.4);
}
.ce-photo-slot img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.ce-photo-slot span {
  position: relative;
  z-index: 1;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ce-muted);
}
.ce-photo-slot.has-image span {
  display: none;
}
.ce-photo-slot em {
  position: relative;
  z-index: 1;
  font-style: normal;
  font-size: 0.7rem;
  color: var(--ce-muted);
}
.ce-photo-slot.has-image em {
  display: none;
}
.ce-photo-slot input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.ce-photo-slot__clear {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 2;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: rgba(26, 23, 20, 0.75);
  color: #fff;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  display: none;
}
.ce-photo-slot.has-image .ce-photo-slot__clear {
  display: grid;
  place-items: center;
}

.ce-details {
  border: 1px solid var(--ce-line);
  border-radius: 12px;
  padding: 0;
  margin-bottom: 12px;
  background: #fff;
}
.ce-details > summary {
  list-style: none;
  cursor: pointer;
  padding: 12px 14px;
  font-size: 0.82rem;
  font-weight: 650;
  color: var(--ce-ink-soft);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.ce-details > summary::-webkit-details-marker {
  display: none;
}
.ce-details > summary::after {
  content: "+";
  font-weight: 500;
  color: var(--ce-muted);
}
.ce-details[open] > summary::after {
  content: "–";
}
.ce-details__body {
  padding: 0 14px 14px;
  border-top: 1px solid var(--ce-line);
  padding-top: 12px;
}

.ce-logo-block {
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--ce-line);
}
.ce-logo-block__hint {
  margin: 0 0 10px;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--ce-ok);
  background: rgba(31, 107, 74, 0.08);
  border-radius: 8px;
  padding: 8px 10px;
}
.ce-logo-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.ce-logo-slot {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 96px;
  border: 1px dashed rgba(176, 141, 79, 0.55);
  border-radius: 10px;
  background: #faf6ee;
  cursor: pointer;
  text-align: center;
  padding: 10px 8px;
  overflow: hidden;
}
.ce-logo-slot--dark {
  background: #1a1714;
  border-color: rgba(216, 189, 133, 0.45);
}
.ce-logo-slot--dark span,
.ce-logo-slot--dark em {
  color: rgba(247, 243, 234, 0.65) !important;
}
.ce-logo-slot:hover {
  border-style: solid;
}
.ce-logo-slot.has-image {
  border-style: solid;
  border-color: rgba(176, 141, 79, 0.5);
}
.ce-logo-slot img {
  max-width: 72%;
  max-height: 56px;
  width: auto;
  height: auto;
  object-fit: contain;
  position: relative;
  z-index: 1;
}
.ce-logo-slot span {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ce-muted);
  z-index: 1;
}
.ce-logo-slot em {
  font-style: normal;
  font-size: 0.68rem;
  color: var(--ce-muted);
  z-index: 1;
}
.ce-logo-slot.has-image span,
.ce-logo-slot.has-image em {
  display: none;
}
.ce-logo-slot input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.ce-logo-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 8px;
}
.ce-logo-actions .ce-btn {
  padding: 8px 8px;
  font-size: 0.74rem;
}

.ce-stage-wrap {
  padding: 24px 20px 40px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
}
.ce-stage-bar {
  width: min(100%, 920px);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
}
.ce-stage-bar h2 {
  margin: 0;
  font-family: var(--ce-display);
  font-size: 1.35rem;
  font-weight: 600;
}
.ce-stage-bar p {
  margin: 2px 0 0;
  font-size: 0.8rem;
  color: var(--ce-ink-soft);
}
.ce-zoom {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--ce-muted);
}
.ce-zoom input[type="range"] {
  width: 120px;
}

.ce-stage {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-bottom: 40px;
}
.ce-stage-frame {
  position: relative;
  margin: 0 auto;
}
.ce-stage-scaler {
  transform-origin: top left;
  box-shadow: var(--ce-shadow);
  transition: transform 0.12s ease;
  will-change: transform;
}

.ce-print-only {
  display: none;
}

@media (max-width: 980px) {
  .ce-app {
    grid-template-columns: 1fr;
  }
  .ce-sidebar {
    position: relative;
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--ce-line);
  }
  .ce-stage-wrap {
    min-height: auto;
    padding-top: 16px;
  }
}

@media print {
  html,
  body {
    background: #fff !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  .ce-no-print {
    display: none !important;
  }
  .ce-app {
    display: block;
  }
  .ce-stage-wrap {
    padding: 0 !important;
    min-height: 0 !important;
    overflow: visible !important;
  }
  .ce-stage {
    padding: 0 !important;
    display: block !important;
  }
  .ce-stage-frame {
    width: auto !important;
    height: auto !important;
  }
  .ce-stage-scaler {
    transform: none !important;
    box-shadow: none !important;
  }
  .ce-print-only {
    display: block;
  }
}

.ce-inv-import {
  margin-bottom: 18px;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid rgba(176, 141, 79, 0.35);
  background: linear-gradient(180deg, #fffefb, #f6f0e4);
}
.ce-inv-search {
  position: relative;
}
.ce-inv-search__field {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--ce-line);
  background: #fff;
  border-radius: 10px;
  padding: 0 12px;
}
.ce-inv-search__field:focus-within {
  border-color: rgba(176, 141, 79, 0.7);
  box-shadow: 0 0 0 3px var(--ce-gold-soft);
}
.ce-inv-search__icon {
  color: var(--ce-muted);
  font-size: 1rem;
  line-height: 1;
}
.ce-inv-search__field input {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 11px 0;
  outline: none;
  box-shadow: none !important;
}
.ce-inv-suggest {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  z-index: 40;
  max-height: 280px;
  overflow: auto;
  background: #fff;
  border: 1px solid var(--ce-line);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(22, 20, 17, 0.14);
}
.ce-inv-suggest__item {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--ce-line);
  background: #fff;
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
}
.ce-inv-suggest__item:last-child {
  border-bottom: 0;
}
.ce-inv-suggest__item:hover,
.ce-inv-suggest__item:focus {
  background: #fff8eb;
  outline: none;
}
.ce-inv-suggest__thumb {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
  background: #efe6d4;
}
.ce-inv-suggest__thumb.is-empty {
  display: grid;
  place-items: center;
  font-size: 0.65rem;
  color: var(--ce-muted);
}
.ce-inv-suggest__title {
  display: block;
  font-size: 0.86rem;
  font-weight: 650;
  color: var(--ce-ink);
  line-height: 1.25;
}
.ce-inv-suggest__meta {
  display: block;
  margin-top: 2px;
  font-size: 0.72rem;
  color: var(--ce-muted);
}
.ce-inv-suggest__price {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ce-ink-soft);
  white-space: nowrap;
}
.ce-inv-suggest__empty,
.ce-inv-suggest__msg {
  padding: 14px 12px;
  font-size: 0.82rem;
  color: var(--ce-muted);
}
.ce-inv-picked {
  margin: 10px 0 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(31, 107, 74, 0.1);
  color: var(--ce-ok);
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.35;
}
.ce-inv-hint {
  margin: 8px 0 0;
  font-size: 0.74rem;
  color: var(--ce-muted);
  line-height: 1.4;
}

/* Dynamic @page injected via JS; fallback */
@page {
  margin: 0;
}
