:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --ink: #102033;
  --muted: #667085;
  --line: #d7dee8;
  --panel: #ffffff;
  --bg: #eef3f8;
  --accent: #1f6feb;
  --green: #157347;
  --red: #b42318;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--bg); }
a { color: inherit; }
button, .button-link {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  justify-content: center;
}
button.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  font: inherit;
  background: white;
}
label { display: grid; gap: 6px; font-weight: 700; font-size: 13px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }
.topbar {
  height: 58px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 22px;
  background: white;
  border-bottom: 1px solid var(--line);
}
.brand { font-size: 18px; font-weight: 800; text-decoration: none; }
.user { margin-left: auto; color: var(--muted); font-size: 13px; }
.shell { padding: 22px; }
.layout { display: grid; grid-template-columns: 360px 1fr; gap: 18px; align-items: start; }
.editor-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; align-items: start; }
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}
.panel.narrow { max-width: 520px; margin: 48px auto; }
.stack { display: grid; gap: 14px; }
.table { display: grid; gap: 8px; }
.row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  text-decoration: none;
}
.row span { color: var(--muted); }
code { color: #475569; font-size: 12px; word-break: break-all; }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.pdf-stage {
  position: relative;
  max-width: 920px;
  min-height: 620px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #dce6f1;
}
.pdf-stage img { display: block; width: 100%; user-select: none; }
.stamp-box {
  position: absolute;
  left: 55%;
  top: 70%;
  width: 260px;
  height: 82px;
  min-width: 170px;
  min-height: 58px;
  padding: 9px;
  background: rgba(255, 255, 255, 0.9);
  border: 2px solid var(--accent);
  border-radius: 6px;
  cursor: move;
  display: grid;
  align-content: center;
  gap: 2px;
  font-size: 12px;
}
.stamp-box span { font-weight: 800; font-size: 14px; }
.stamp-box small { color: var(--muted); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.stamp-box i {
  position: absolute;
  width: 14px;
  height: 14px;
  right: -7px;
  bottom: -7px;
  border-radius: 50%;
  background: var(--accent);
  cursor: nwse-resize;
}
.readonly .stamp-box { pointer-events: none; }
.mini-list { display: grid; gap: 8px; margin-top: 10px; }
.template-item { background: #f1f5f9; color: var(--ink); justify-content: flex-start; }
.check { display: flex; grid-template-columns: auto 1fr; gap: 10px; align-items: start; font-weight: 600; }
.check input { width: auto; margin-top: 3px; }
.valid { color: var(--green); font-weight: 800; }
.invalid { color: var(--red); font-weight: 800; }
.details { display: grid; grid-template-columns: 180px 1fr; gap: 10px; }
.details dt { font-weight: 800; }
.details dd { margin: 0; word-break: break-all; }

@media (max-width: 900px) {
  .layout, .editor-grid { grid-template-columns: 1fr; }
  .shell { padding: 12px; }
}
