@font-face {
  font-family: "Montserrat";
  src: url("assets/Montserrat-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Montserrat";
  src: url("assets/Montserrat-Bold.ttf") format("truetype");
  font-weight: 700 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #111827;
  --muted: #69788d;
  --line: #d5e0ec;
  --blue: #2769aa;
  --blue-dark: #174d80;
  --green: #20876d;
  --orange: #f49a21;
  --paper: #ffffff;
  --page-bg: #edf3f8;
}

* { box-sizing: border-box; }

html { background: var(--page-bg); }

body {
  margin: 0;
  background:
    radial-gradient(circle at 5% 0%, rgba(244, 154, 33, 0.08), transparent 25%),
    radial-gradient(circle at 100% 8%, rgba(32, 135, 109, 0.08), transparent 26%),
    var(--page-bg);
  color: var(--ink);
  font-family: "Montserrat", Arial, sans-serif;
}

button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }

.app-shell { padding: 18px; }

.workspace {
  width: min(1540px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(280px, 350px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.control-panel,
.account-widget,
.preview-heading {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 14px 34px rgba(21, 40, 64, 0.08);
}

.control-panel {
  position: sticky;
  top: 14px;
  max-height: calc(100vh - 28px);
  overflow: auto;
  padding: 18px;
}

.library-link {
  width: max-content;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 13px;
  border: 1px solid #cddbea;
  border-radius: 999px;
  background: #fff;
  color: var(--blue-dark);
  font-size: 0.78rem;
  font-weight: 800;
  text-decoration: none;
}

.library-link svg,
.button-stack svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand-block {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 13px;
  align-items: center;
  margin: 14px 0 18px;
  padding: 14px;
  border: 1px solid #d8e3ee;
  border-top: 4px solid var(--orange);
  border-radius: 8px;
  background: linear-gradient(135deg, #fffaf2, #f8fbff 60%);
}

.brand-mark {
  width: 56px;
  height: 56px;
  object-fit: contain;
  border: 1px solid #dde5ee;
  border-radius: 7px;
  background: #fff;
  box-shadow: 0 8px 18px rgba(16, 32, 50, 0.1);
}

.brand-block p,
.preview-heading p {
  margin: 0 0 3px;
  color: var(--green);
  font-size: 0.68rem;
  font-weight: 900;
  text-transform: uppercase;
}

.brand-block h1 {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.06;
}

.brand-block span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.73rem;
  line-height: 1.3;
}

.controls { display: grid; gap: 12px; }

.controls label {
  display: grid;
  gap: 6px;
  color: #34445a;
  font-size: 0.78rem;
  font-weight: 800;
}

.controls input,
.controls select,
.controls textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid #ccdaea;
  border-radius: 7px;
  outline: 0;
  background: #fbfdff;
  color: #172033;
  font-size: 0.83rem;
  font-weight: 700;
}

.controls input,
.controls select { min-height: 43px; padding: 0 12px; }
.controls textarea { resize: vertical; padding: 11px 12px; line-height: 1.4; }

.controls input:focus,
.controls select:focus,
.controls textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(39, 105, 170, 0.1);
}

.controls small {
  color: #7a8798;
  font-size: 0.66rem;
  font-weight: 600;
}

.field-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.button-stack { display: grid; gap: 9px; margin-top: 16px; }

.button-stack button {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 1px solid #cbd9e8;
  border-radius: 7px;
  background: #fff;
  color: #173f69;
  font-weight: 900;
}

.button-stack button:hover { border-color: var(--blue); background: #f7fbff; }

.button-stack .primary-btn {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.button-stack .primary-btn:hover { background: var(--blue-dark); }
.button-stack button:disabled { opacity: 0.58; cursor: wait; }

.activity-panel { min-width: 0; display: grid; gap: 14px; }

.preview-heading {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 16px 20px;
}

.preview-heading h2 { margin: 0; font-size: 1.25rem; }

#diploma-count {
  padding: 8px 11px;
  border-radius: 999px;
  background: #eef5fb;
  color: var(--blue-dark);
  font-size: 0.72rem;
  font-weight: 900;
}

.diploma-pages {
  width: min(100%, 740px);
  margin: 0 auto;
  display: grid;
  gap: 20px;
}

.diploma-page {
  position: relative;
  width: 100%;
  aspect-ratio: 297 / 210;
  overflow: hidden;
  border: 1px solid #c9d7e6;
  border-radius: 7px;
  background: #fff;
  box-shadow: 0 22px 56px rgba(20, 36, 58, 0.14);
}

.diploma-page svg { width: 100%; height: 100%; display: block; }

@media (max-width: 980px) {
  .workspace { grid-template-columns: 1fr; }
  .control-panel { position: static; max-height: none; }
}

@media (max-width: 620px) {
  .app-shell { padding: 10px; }
  .control-panel { padding: 14px; }
  .field-pair { grid-template-columns: 1fr; }
  .preview-heading { align-items: flex-start; }
  .preview-heading h2 { font-size: 1rem; }
  .diploma-pages { gap: 12px; }
}

@media print {
  @page {
    size: 297mm 210mm;
    margin: 0;
  }

  html, body {
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    background: #fff !important;
  }

  * {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  .control-panel,
  .account-widget,
  .preview-heading { display: none !important; }

  .app-shell,
  .workspace,
  .activity-panel,
  .diploma-pages {
    position: static !important;
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    height: auto !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    gap: 0 !important;
  }

  .diploma-page {
    position: relative !important;
    display: block !important;
    width: 296.8mm !important;
    height: 209.7mm !important;
    min-height: 0 !important;
    max-height: 209.7mm !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    aspect-ratio: auto !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    break-inside: avoid-page !important;
    page-break-inside: avoid !important;
    break-after: page !important;
    page-break-after: always !important;
  }

  .diploma-page svg {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
  }

  .diploma-page:last-child {
    break-after: auto !important;
    page-break-after: auto !important;
  }
}
