:root {
  --bg: #f5f9fd;
  --card: #ffffff;
  --line: #d6e4f2;
  --text: #12263c;
  --muted: #5f758c;
  --brand: #0f8bdf;
  --brand-deep: #0c6aac;
  --success: #16895f;
  --error: #c53c3c;
  --shadow: 0 16px 30px rgba(10, 34, 56, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Sora", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 8% -6%, #d7ecff 0%, transparent 45%), radial-gradient(circle at 95% 108%, #ffe3c5 0%, transparent 44%),
    var(--bg);
}

.bg {
  position: fixed;
  border-radius: 50%;
  filter: blur(44px);
  z-index: -1;
  opacity: 0.42;
}

.bg-one {
  width: 320px;
  height: 320px;
  left: -130px;
  top: 40px;
  background: #a9d8ff;
}

.bg-two {
  width: 300px;
  height: 300px;
  right: -110px;
  bottom: 40px;
  background: #ffd3ab;
}

.page {
  width: min(1260px, 96vw);
  margin: 24px auto;
  display: grid;
  gap: 14px;
}

.hero {
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow);
  color: #e9f4ff;
  background: linear-gradient(135deg, #0d3559 0%, #164e80 100%);
}

.hero h1 {
  margin: 0;
  font-family: "Playfair Display", serif;
  font-size: 1.7rem;
}

.hero p {
  margin: 6px 0 0;
  color: #c8ddf0;
}

.lookup-card {
  background: var(--card);
  border: 1px solid #e7eef6;
  border-radius: 16px;
  padding: 14px;
  box-shadow: var(--shadow);
}

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

.lookup-form input {
  flex: 1;
  min-width: 240px;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 11px;
  font-family: inherit;
}

input:focus {
  outline: 2px solid #a7d6ff;
  border-color: #90c7f5;
}

.status {
  min-height: 1.25em;
  margin-bottom: 8px;
  font-size: 0.9rem;
}

.status.success {
  color: var(--success);
}

.status.error {
  color: var(--error);
}

.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 13px;
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
}

.btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.btn.primary {
  color: #fff;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-deep) 100%);
}

.btn.ghost {
  border-color: #c7dbef;
  background: #fff;
  color: #1f496b;
}

.certificate-area {
  display: grid;
  gap: 10px;
}

.certificate-toolbar {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.certificate-sheet {
  position: relative;
  width: 100%;
  aspect-ratio: 297 / 210;
  border-radius: 20px;
  background: linear-gradient(145deg, #fffefb 0%, #f7fbff 70%, #edf4ff 100%);
  border: 2px solid #d7e4f2;
  box-shadow: var(--shadow);
  padding: 34px;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
}

.certificate-sheet.pdf-exporting {
  width: 297mm !important;
  height: 210mm !important;
  max-width: 297mm;
  max-height: 210mm;
  aspect-ratio: auto !important;
}

.sheet-deco {
  position: absolute;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  filter: blur(2px);
  opacity: 0.22;
}

.deco-top {
  top: -180px;
  right: -80px;
  background: radial-gradient(circle, #82c1f4 0%, transparent 72%);
}

.deco-bottom {
  bottom: -180px;
  left: -100px;
  background: radial-gradient(circle, #ffd7ae 0%, transparent 70%);
}

.sheet-header {
  text-align: center;
  position: relative;
  z-index: 1;
}

.sheet-title-row {
  margin-top: 8px;
  display: grid;
  grid-template-columns: 132px 1fr 132px;
  gap: 4px;
  align-items: center;
}

.sheet-title-block {
  text-align: center;
}

.sheet-logo {
  width: 120px;
  max-width: 100%;
  height: auto;
  filter: drop-shadow(0 6px 8px rgba(16, 52, 84, 0.12));
}

.sheet-logo.left {
  justify-self: end;
}

.sheet-logo.right {
  width: 130px;
  justify-self: start;
}

.event-line {
  margin: 0;
  letter-spacing: 0.22em;
  font-size: 0.78rem;
  color: #4e6780;
}

.sheet-header h2 {
  margin: 0 0 6px;
  font-family: "Playfair Display", serif;
  font-size: clamp(2rem, 3vw, 2.9rem);
  color: #123d63;
}

.event-sub {
  margin: 0;
  color: #55718b;
  font-size: 0.95rem;
}

.sheet-body {
  text-align: center;
  align-self: center;
  position: relative;
  z-index: 1;
}

.intro {
  margin: 0 0 8px;
  color: #4f6a83;
  font-size: 1rem;
}

.sheet-body h3 {
  margin: 0;
  font-family: "Playfair Display", serif;
  font-size: clamp(2rem, 3.6vw, 3.2rem);
  color: #0f3558;
  line-height: 1.12;
}

.description {
  width: min(900px, 90%);
  margin: 14px auto 0;
  color: #334b63;
  font-size: 1rem;
  line-height: 1.6;
}

.meta-panel {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.meta-item {
  border: 1px solid #d8e5f3;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.92);
  padding: 8px 10px;
}

.meta-item span {
  display: block;
  font-size: 0.74rem;
  color: #5f7891;
  margin-bottom: 2px;
}

.meta-item strong {
  color: #173b5c;
  font-size: 0.96rem;
}

.sheet-footer {
  position: relative;
  z-index: 1;
  margin-top: 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  align-items: end;
}

.signature {
  position: relative;
  min-height: 88px;
  text-align: center;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 0;
}

.signature::before {
  content: "";
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: 18px;
  border-top: 1px solid #9cb1c8;
}

.signature span {
  font-size: 0.74rem;
  color: #415970;
  display: block;
}

.hidden {
  display: none;
}

@media (max-width: 980px) {
  .certificate-sheet {
    aspect-ratio: auto;
    min-height: 760px;
    grid-template-rows: auto auto auto auto;
  }
  .meta-panel {
    grid-template-columns: 1fr 1fr;
  }
  .sheet-title-row {
    grid-template-columns: 90px 1fr 90px;
    gap: 4px;
  }
  .sheet-logo {
    width: 82px;
  }
  .sheet-logo.right {
    width: 90px;
  }
}

@media (max-width: 640px) {
  .meta-panel,
  .sheet-footer {
    grid-template-columns: 1fr;
  }
  .certificate-toolbar {
    justify-content: stretch;
  }
  .certificate-toolbar .btn {
    flex: 1;
  }
  .sheet-title-row {
    grid-template-columns: 70px 1fr 70px;
    gap: 3px;
  }
  .sheet-logo {
    width: 65px;
  }
  .sheet-logo.right {
    width: 70px;
  }
}

@page {
  size: A4 landscape;
  margin: 0;
}

@media print {
  body {
    background: #fff;
    margin: 0;
  }
  .no-print,
  .hero,
  .lookup-card {
    display: none !important;
  }
  .page {
    margin: 0;
    width: auto;
    gap: 0;
  }
  .certificate-area {
    display: block;
  }
  .certificate-sheet {
    width: 297mm;
    height: 210mm;
    border-radius: 0;
    border-width: 1px;
    box-shadow: none;
    margin: 0;
    page-break-inside: avoid;
  }
  .signature {
    min-height: 96px;
  }
}
