:root {
  color-scheme: light;
  --bg: #eef2f6;
  --panel: #ffffff;
  --line: #cfd8e3;
  --text: #1f2937;
  --muted: #5b687c;
  --primary: #145388;
  --primary-strong: #0f416b;
  --success: #227a54;
  --success-strong: #1b5e40;
  --warning: #b45309;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(360px, 520px) minmax(0, 1fr);
  gap: 16px;
  min-height: 100vh;
  padding: 16px;
}

.side-panel,
.viewer-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.side-panel {
  overflow-y: auto;
  padding: 18px;
}

.brand h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
}

.brand p {
  margin: 6px 0 18px;
  color: var(--muted);
  font-size: 14px;
}

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

.field {
  display: grid;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
}

input,
select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: 13px Arial, Helvetica, sans-serif;
  padding: 8px 10px;
}

input[type="file"] {
  padding: 7px;
}

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

.button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.button:disabled {
  cursor: wait;
  opacity: .7;
}

.button.primary {
  background: var(--success);
}

.button.primary:hover {
  background: var(--success-strong);
}

.button.secondary {
  background: var(--primary);
}

.button.secondary:hover {
  background: var(--primary-strong);
}

.certificate {
  min-height: 118px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  color: var(--text);
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-line;
}

.signature-state {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.signature-state span {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  background: #f8fafc;
}

.status {
  min-height: 18px;
  margin: 0;
  color: var(--warning);
  font-size: 13px;
}

.viewer-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.viewer-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 50px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
}

.icon-button {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 6px;
  background: var(--primary);
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.coordinates {
  margin-left: auto;
  color: var(--muted);
  font-size: 13px;
}

.canvas-wrap {
  position: relative;
  display: grid;
  place-items: start center;
  overflow: auto;
  padding: 18px;
  background: #f8fafc;
}

#pdfCanvas {
  display: block;
  max-width: 100%;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 10px 28px rgba(31, 41, 55, .12);
}

.signature-preview {
  position: absolute;
  width: 150px;
  height: 50px;
  border: 2px solid var(--success);
  border-radius: 8px;
  background: rgba(34, 122, 84, .16);
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px;
}

.qr-mark {
  width: 34px;
  height: 34px;
  border: 1px solid var(--success);
  background:
    linear-gradient(90deg, var(--success) 2px, transparent 2px) 0 0 / 8px 8px,
    linear-gradient(var(--success) 2px, transparent 2px) 0 0 / 8px 8px,
    #fff;
}

.preview-text {
  color: var(--success);
  font-size: 11px;
  font-weight: 700;
}

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

  .side-panel {
    overflow-y: visible;
  }
}

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

  .grid-two,
  .signature-state {
    grid-template-columns: 1fr;
  }
}
