:root {
  --expell-red: #a61935;
  --expell-red-dark: #7e1027;
  --expell-blue: #0077c8;
  --expell-blue-dark: #003c5f;
  --ink: #163043;
  --muted: #687785;
  --line: #d9e1e8;
  --paper: #ffffff;
  --surface: #f4f7fa;
  --success: #147a5c;
  --shadow: 0 18px 42px rgba(14, 38, 58, 0.15);
}

* {
  box-sizing: border-box;
}

body {
  position: relative;
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 18px 18px, rgba(0, 119, 200, 0.18) 1px, transparent 1.6px),
    radial-gradient(circle at 42px 42px, rgba(166, 25, 53, 0.13) 1px, transparent 1.6px),
    linear-gradient(115deg, rgba(0, 119, 200, 0.08), transparent 32%),
    linear-gradient(245deg, rgba(166, 25, 53, 0.08), transparent 36%),
    linear-gradient(135deg, #f8fbfd 0%, #eef4f8 52%, #fbfcfd 100%);
  background-size: 48px 48px, 48px 48px, 100% 100%, 100% 100%, 100% 100%;
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(90deg, rgba(0, 60, 95, 0.05) 1px, transparent 1px),
    linear-gradient(0deg, rgba(0, 60, 95, 0.04) 1px, transparent 1px);
  background-size: 96px 96px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.75), transparent 88%);
  pointer-events: none;
}

button,
input {
  font: inherit;
}

button {
  min-height: 42px;
  border: 1px solid rgba(196, 214, 226, 0.95);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
  padding: 0 16px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.78);
}

button:hover {
  border-color: var(--expell-blue);
}

button.primary {
  border-color: var(--expell-red);
  background: linear-gradient(135deg, var(--expell-red), var(--expell-red-dark));
  color: #ffffff;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(360px, 470px) minmax(560px, 1fr);
  gap: 24px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px;
}

.control-panel,
.preview-panel {
  position: relative;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(196, 214, 226, 0.88);
  border-radius: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.control-panel::before,
.preview-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    linear-gradient(120deg, rgba(0, 119, 200, 0.12), transparent 28%),
    linear-gradient(300deg, rgba(166, 25, 53, 0.09), transparent 32%);
  pointer-events: none;
}

.control-panel > *,
.preview-panel > * {
  position: relative;
  z-index: 1;
}

.control-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 22px;
}

.brand-row,
.preview-header,
.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
}

.brand-row {
  justify-content: flex-start;
  min-width: 0;
  gap: 30px;
}

.brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 96px;
  height: 54px;
  border-left: 6px solid var(--expell-red);
  color: var(--expell-red);
  font-size: 30px;
  font-weight: 900;
  line-height: 1;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--expell-blue);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  color: var(--expell-blue-dark);
}

h1 {
  font-size: 25px;
  line-height: 1.05;
  white-space: nowrap;
}

h2 {
  font-size: 24px;
}

.panel-grid {
  display: grid;
  gap: 14px;
}

.upload-box {
  display: grid;
  gap: 8px;
  min-height: 150px;
  padding: 20px;
  border: 1px dashed rgba(0, 119, 200, 0.45);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.86), rgba(244, 249, 252, 0.72)),
    linear-gradient(90deg, rgba(0, 119, 200, 0.08), rgba(166, 25, 53, 0.06));
  cursor: pointer;
}

.upload-box input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.upload-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 40px;
  border-radius: 6px;
  background: var(--expell-blue);
  color: #ffffff;
  font-size: 14px;
  font-weight: 900;
}

.upload-box small,
.status-bar,
td {
  color: var(--muted);
}

.actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.print-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.status-bar {
  align-items: flex-start;
  padding: 12px;
  border: 1px solid rgba(20, 122, 92, 0.18);
  border-left: 4px solid var(--success);
  border-radius: 6px;
  background: rgba(238, 248, 244, 0.78);
  font-size: 13px;
}

.validation-details {
  display: grid;
  gap: 6px;
  margin: -10px 0 0;
  padding: 10px 12px 10px 28px;
  border: 1px solid rgba(166, 25, 53, 0.18);
  border-radius: 6px;
  background: rgba(255, 245, 247, 0.78);
  color: var(--expell-red-dark);
  font-size: 12px;
  line-height: 1.35;
}

.validation-details:empty {
  display: none;
}

.data-table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--expell-blue-dark);
  background: #f2f6f9;
}

.client-row {
  cursor: pointer;
}

.client-row:hover td {
  background: #f8fbfd;
}

.client-row.is-selected td {
  background: #eaf5fb;
  color: var(--expell-blue-dark);
  font-weight: 700;
}

.preview-panel {
  min-width: 0;
  padding: 22px;
}

.format-pill {
  border: 1px solid #cbd7e1;
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  padding: 8px 12px;
}

.certificate-scale {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 122px);
  padding: 24px 0 4px;
}

.certificate {
  position: relative;
  width: 297mm;
  height: 210mm;
  overflow: hidden;
  background: var(--paper);
  box-shadow: 0 22px 60px rgba(13, 37, 56, 0.24);
  color: var(--expell-blue-dark);
}

.certificate-preview-frame {
  width: 166.32mm;
  height: 117.6mm;
}

.certificate-preview-card {
  transform: scale(0.56);
  transform-origin: top left;
}

.certificate::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(135deg, transparent 0 60%, rgba(0, 119, 200, 0.12) 60.2% 66%, transparent 66.2%),
    linear-gradient(135deg, transparent 0 68%, rgba(166, 25, 53, 0.88) 68.2% 76%, transparent 76.2%),
    linear-gradient(135deg, transparent 0 78%, rgba(0, 119, 200, 0.92) 78.2% 80%, transparent 80.2%);
  pointer-events: none;
}

.certificate::after {
  content: "";
  position: absolute;
  right: -65mm;
  bottom: -85mm;
  width: 190mm;
  height: 160mm;
  background: linear-gradient(135deg, rgba(0, 119, 200, 0.08), rgba(126, 16, 39, 0.26));
  transform: rotate(45deg);
}

.cert-logo {
  position: absolute;
  top: 24mm;
  right: 30mm;
  z-index: 2;
  display: grid;
  justify-items: end;
  color: var(--expell-red);
}

.cert-logo strong {
  display: block;
  font-size: 38px;
  line-height: 0.9;
}

.cert-logo span {
  color: var(--expell-red-dark);
  font-size: 12px;
  font-weight: 700;
}

.cert-check {
  position: absolute;
  top: 23mm;
  left: 24mm;
  width: 34mm;
  height: 34mm;
  border: 2.2mm solid var(--expell-blue-dark);
  border-radius: 7mm;
}

.cert-check::after {
  content: "";
  position: absolute;
  left: 8mm;
  top: -1mm;
  width: 14mm;
  height: 26mm;
  border: solid var(--expell-blue);
  border-width: 0 3.5mm 3.5mm 0;
  transform: rotate(45deg);
}

.cert-content {
  position: relative;
  z-index: 2;
  width: 160mm;
  padding: 63mm 0 0 24mm;
}

.cert-title {
  margin: 0;
  color: var(--expell-blue-dark);
  font-size: 32px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.cert-product {
  margin: 2mm 0 7mm;
  color: var(--expell-blue-dark);
  font-size: 18px;
}

.cert-body {
  max-width: 135mm;
  margin: 0;
  color: #24485f;
  font-size: 13.5px;
  line-height: 1.25;
}

.cert-body strong {
  color: var(--expell-blue-dark);
}

.cert-date {
  margin-top: 7mm;
  color: #24485f;
  font-size: 13.5px;
}

.cert-date strong {
  color: var(--expell-blue-dark);
}

.cert-contact {
  margin-top: 12mm;
  color: var(--expell-blue);
  font-weight: 900;
}

.cert-contact .phone {
  display: block;
  font-size: 28px;
}

.cert-contact .site {
  display: block;
  margin-top: 2mm;
  font-size: 18px;
}

.iso-seal {
  position: absolute;
  right: 34mm;
  bottom: 39mm;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 25mm;
  height: 25mm;
  border: 1.4mm solid var(--expell-blue);
  border-radius: 50%;
  background: #ffffff;
  color: var(--expell-blue-dark);
  font-size: 8px;
  font-weight: 900;
  text-align: center;
  line-height: 1.05;
  box-shadow: 0 8px 20px rgba(8, 45, 70, 0.18);
}

.iso-seal span {
  display: block;
  color: var(--expell-red);
  font-size: 11px;
}

.certificate {
  background: #ffffff;
  color: #003150;
}

.certificate::before,
.certificate::after {
  display: none;
}

.certificate-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  user-select: none;
  pointer-events: none;
}

.field-cover,
.cert-product,
.cert-body,
.cert-date {
  position: absolute;
}

.field-cover {
  display: none;
  z-index: 1;
  background: #ffffff;
}

.field-cover--product {
  left: 6.5%;
  top: 38.7%;
  width: 50%;
  height: 4.2%;
}

.field-cover--body {
  left: 6.45%;
  top: 47.2%;
  width: 59%;
  height: 16.4%;
}

.field-cover--date {
  left: 6.6%;
  top: 66.7%;
  width: 29%;
  height: 4.3%;
}

.cert-product {
  z-index: 2;
  left: 7.2%;
  top: 37.35%;
  width: 56%;
  margin: 0;
  color: #003150;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 8.6mm;
  font-weight: 400;
  line-height: 1.05;
}

.cert-body {
  z-index: 2;
  left: 7.2%;
  top: 45.35%;
  width: 61%;
  max-width: none;
  margin: 0;
  color: #003150;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 6.65mm;
  font-weight: 400;
  line-height: 1.15;
}

.cert-body--compact {
  font-size: 6.05mm;
  line-height: 1.13;
}

.cert-body strong,
.cert-date strong {
  color: #003150;
  font-weight: 900;
}

.no-break {
  white-space: nowrap;
}

.body-line {
  display: block;
  white-space: nowrap;
}

.cert-date {
  z-index: 2;
  left: 7.2%;
  top: 66%;
  margin: 0;
  color: #003150;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 6.75mm;
  font-weight: 400;
  line-height: 1;
}

.cert-check,
.cert-logo,
.cert-content,
.cert-contact,
.iso-seal {
  display: none;
}

.print-page {
  background: #ffffff;
}

.print-stack {
  display: grid;
  gap: 24px;
  padding: 24px;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .certificate-scale {
    min-height: 720px;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 12px;
  }

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

  .brand-row,
  .preview-header,
  .status-bar {
    align-items: flex-start;
    flex-direction: column;
  }

  .certificate-preview-frame {
    width: 95.04mm;
    height: 67.2mm;
  }

  .certificate-preview-card {
    transform: scale(0.32);
    transform-origin: top left;
  }
}

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

@media print {
  body {
    background: #ffffff;
  }

  .app-shell,
  .control-panel,
  .preview-panel,
  .preview-header {
    display: block;
    padding: 0;
    border: 0;
    box-shadow: none;
  }

  .control-panel,
  .preview-header {
    display: none;
  }

  .certificate-scale {
    display: block;
    min-height: 0;
    padding: 0;
  }

  .certificate,
  .certificate-preview-card {
    width: 297mm;
    height: 210mm;
    transform: none;
    box-shadow: none;
    break-after: page;
    page-break-after: always;
  }

  .certificate:last-child {
    break-after: auto;
    page-break-after: auto;
  }

  .print-stack {
    display: block;
    padding: 0;
  }
}
