:root {
  --bg: #eef1f4;
  --panel: #ffffff;
  --panel-2: #f7f9fb;
  --line: #c9d0d8;
  --line-strong: #8994a1;
  --text: #17202a;
  --muted: #627082;
  --accent: #0f766e;
  --accent-dark: #0b5751;
  --red: #b91c1c;
  --red-soft: #fee2e2;
  --gold: #b7791f;
  --shadow: 0 16px 34px rgba(31, 41, 55, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 22px;
  background: #eef1f4;
}

button,
input,
select {
  font: inherit;
}

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 18px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.topbar h1,
.topbar p,
.section-title h2,
.preview-toolbar h2,
.preview-toolbar p,
.block-title h3,
.result-panel p {
  margin: 0;
}

.topbar h1 {
  font-size: 19px;
  line-height: 1.2;
  letter-spacing: 0;
}

.topbar p,
.preview-toolbar p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: end;
}

.quiet-link,
.download-link,
button {
  min-height: 34px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 12px;
  font-weight: 700;
  font-size: 13px;
  text-decoration: none;
  line-height: 1.15;
}

button,
.download-link {
  border: 1px solid var(--accent-dark);
  color: #fff;
  background: var(--accent);
  cursor: pointer;
}

button.quiet,
.quiet-link {
  border: 1px solid var(--line);
  color: var(--text);
  background: #fff;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.56;
}

.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(330px, 420px) minmax(520px, 1fr);
  min-height: 0;
}

.tool-panel,
.preview-panel {
  min-height: calc(100vh - 69px);
  overflow: auto;
}

.tool-panel {
  background: var(--panel);
  border-right: 1px solid var(--line);
}

.control-form {
  padding: 14px;
  display: grid;
  gap: 12px;
}

.control-section,
.preview-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  overflow: hidden;
}

.section-title,
.block-title,
.preview-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.section-title,
.block-title {
  min-height: 42px;
  padding: 9px 10px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.section-title h2,
.block-title h3,
.preview-toolbar h2 {
  font-size: 14px;
  line-height: 1.2;
  letter-spacing: 0;
}

.section-title span,
.block-title span {
  min-width: 28px;
  min-height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
  color: var(--muted);
  background: var(--panel-2);
  font-size: 12px;
  font-weight: 750;
}

.file-drop {
  margin: 10px;
  min-height: 74px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  gap: 11px;
  padding: 10px;
  background: #fff;
  cursor: pointer;
}

.file-drop input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
}

.file-drop b,
.file-drop small {
  display: block;
  overflow-wrap: anywhere;
}

.file-drop b {
  font-size: 13px;
}

.file-drop small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.file-icon {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--accent);
  background: #e7f5f2;
}

.file-icon.red {
  color: var(--red);
  background: var(--red-soft);
}

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

.field,
.switch {
  min-width: 0;
}

.field {
  display: grid;
  gap: 5px;
}

.field.wide {
  grid-column: 1 / -1;
}

.field span,
.switch span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
}

.field input,
.field select {
  width: 100%;
  min-width: 0;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 0 8px;
  font-size: 13px;
}

.field select {
  padding-right: 28px;
}

.switch {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 9px;
  background: #fff;
}

.switch input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.compact input {
  text-align: right;
}

.form-actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  justify-content: end;
  gap: 8px;
  padding: 12px 0 0;
  background: linear-gradient(to top, #fff 72%, rgba(255, 255, 255, 0));
}

.preview-panel {
  background: #dfe5eb;
  display: flex;
  flex-direction: column;
}

.preview-toolbar {
  min-height: 58px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.preview-grid {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(360px, 0.84fr) minmax(420px, 1.16fr);
  gap: 14px;
  padding: 14px;
  align-items: start;
}

.preview-block {
  min-width: 0;
  background: #fff;
}

#stampCanvas {
  width: 100%;
  aspect-ratio: 19 / 9;
  display: block;
  background: linear-gradient(45deg, #f4f6f8 25%, transparent 25%),
    linear-gradient(-45deg, #f4f6f8 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f4f6f8 75%),
    linear-gradient(-45deg, transparent 75%, #f4f6f8 75%);
  background-color: #fff;
  background-size: 18px 18px;
  background-position: 0 0, 0 9px, 9px -9px, -9px 0;
}

.pdf-preview {
  display: block;
  width: 100%;
  height: min(72vh, 760px);
  border: 0;
  background: #fff;
}

.result-panel {
  grid-column: 1 / -1;
  border: 1px solid #8bbf9f;
  border-left-width: 4px;
  border-radius: 8px;
  padding: 12px;
  background: #f0fdf4;
}

.result-panel strong {
  font-size: 14px;
}

.result-panel p {
  margin-top: 4px;
  color: #2f6846;
  font-size: 13px;
}

.hidden {
  display: none;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 10;
  max-width: min(560px, calc(100vw - 28px));
  padding: 9px 12px;
  border-radius: 6px;
  color: #fff;
  background: #17202a;
  box-shadow: var(--shadow);
  font-size: 13px;
}

.toast.error {
  background: var(--red);
}

.login-shell {
  width: min(430px, 100%);
}

.login-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.login-heading {
  padding: 22px 22px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}

.login-heading h1,
.login-heading p {
  margin: 0;
}

.login-heading h1 {
  font-size: 22px;
  letter-spacing: 0;
}

.login-heading p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.login-form {
  display: grid;
  gap: 13px;
  padding: 18px 22px 22px;
}

.login-field {
  display: grid;
  gap: 6px;
}

.login-field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.login-field input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  color: var(--text);
  background: #fff;
}

.slider-check {
  display: grid;
  gap: 6px;
}

.slider-track {
  position: relative;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  overflow: hidden;
  user-select: none;
}

.slider-track.verified {
  border-color: #5ca678;
  background: #f0fdf4;
}

.slider-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: #d8f3e3;
}

.slider-thumb {
  position: absolute;
  z-index: 2;
  top: 3px;
  left: 3px;
  width: 34px;
  height: 34px;
  padding: 0;
  touch-action: none;
}

#sliderText {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  pointer-events: none;
}

.login-message {
  min-height: 18px;
  margin: -2px 0 0;
  color: var(--red);
  font-size: 13px;
}

.login-form > button {
  width: 100%;
  min-height: 38px;
}

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

  .tool-panel,
  .preview-panel {
    min-height: auto;
  }

  .tool-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 760px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions,
  .form-actions {
    justify-content: start;
  }

  .field-grid,
  .preview-grid {
    grid-template-columns: 1fr;
  }

  .pdf-preview {
    height: 560px;
  }
}
