:root {
  color-scheme: light;
  --ink: #17201b;
  --muted: #68726d;
  --paper: #fbfaf6;
  --panel: #f1eee6;
  --line: #d7d0c3;
  --accent: #0f766e;
  --accent-2: #8b2f37;
  --warn: #b45309;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

button, input, select {
  font: inherit;
}

button {
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  padding: 9px 12px;
  border-radius: 6px;
  cursor: pointer;
}

button.secondary {
  background: transparent;
  color: var(--ink);
}

input, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: #fffdfa;
  color: var(--ink);
}

label {
  display: grid;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
}

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

.brand {
  font-family: Georgia, serif;
  font-size: 24px;
  line-height: 1.05;
  margin-bottom: 28px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav button {
  text-align: left;
  background: transparent;
  color: var(--ink);
  border-color: transparent;
}

.nav button.active {
  border-color: var(--line);
  background: #fff9ed;
}

.main {
  padding: 28px;
  display: grid;
  gap: 22px;
  align-content: start;
}

.toolbar, .grid, .form-grid {
  display: grid;
  gap: 12px;
}

.toolbar {
  grid-template-columns: 1fr auto auto;
  align-items: end;
}

.form-grid {
  grid-template-columns: repeat(3, minmax(160px, 1fr));
}

.panel {
  border: 1px solid var(--line);
  background: #fffdfa;
  border-radius: 8px;
  padding: 16px;
}

.list {
  display: grid;
  gap: 10px;
}

.row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
}

.status {
  display: inline-flex;
  width: fit-content;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  color: var(--muted);
}

.designer {
  display: grid;
  grid-template-columns: minmax(420px, 1fr) 320px;
  gap: 16px;
}

.pdf-stage {
  position: relative;
  width: fit-content;
  max-width: 100%;
  border: 1px solid var(--line);
  background: white;
}

#pdfCanvas, #signPdfCanvas {
  display: block;
  max-width: 100%;
}

.field-box {
  position: absolute;
  border: 2px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  cursor: move;
  min-width: 38px;
  min-height: 24px;
}

.field-box.signature {
  border-color: var(--accent-2);
  background: color-mix(in srgb, var(--accent-2) 12%, transparent);
}

.field-label {
  position: absolute;
  top: -20px;
  left: -2px;
  background: var(--ink);
  color: var(--paper);
  font-size: 11px;
  padding: 2px 5px;
  white-space: nowrap;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--accent-2); }

.sign-shell {
  max-width: 980px;
  margin: 0 auto;
  padding: 28px;
}

.sign-layout {
  display: grid;
  grid-template-columns: minmax(420px, 1fr) 300px;
  gap: 18px;
}

.sig-pad {
  border: 1px solid var(--line);
  width: 100%;
  height: 120px;
  background: white;
  touch-action: none;
}

@media (max-width: 900px) {
  .shell, .designer, .sign-layout { grid-template-columns: 1fr; }
  .form-grid, .toolbar { grid-template-columns: 1fr; }
}
