:root {
  --paper: #f5f2ec;
  --paper-raised: #fffdf9;
  --navy: #1b2a4a;
  --navy-soft: #35456a;
  --purple: #6c4c9c;
  --purple-soft: #8b6ebb;
  --rule: #ddd6c8;
  --muted: #6b6558;
  --green: #2f6f52;
  --red: #a3402f;
  --amber: #97701f;
  --shadow: 0 30px 60px -32px rgba(27, 42, 74, 0.4);
  --serif: 'Instrument Serif', Georgia, serif;
  --sans: 'Public Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--navy);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Verticale masthead langs de linkerrand */
.masthead {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 54px;
  background: var(--navy);
  color: var(--paper-raised);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 22px 0;
  z-index: 20;
}

.masthead .vertical {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 600;
}

.masthead .mark {
  width: 16px;
  height: 16px;
  background: var(--purple-soft);
}

.shell {
  position: relative;
  z-index: 1;
  margin-left: 54px;
  padding: 40px clamp(20px, 5vw, 64px) 80px;
  max-width: 1240px;
}

h1, h2, h3 { font-family: var(--serif); font-weight: 400; letter-spacing: -0.02em; margin: 0; }
h1 { font-size: clamp(2.2rem, 5vw, 3.4rem); line-height: 1; }
h2 { font-size: 1.6rem; line-height: 1.15; }
h3 { font-size: 1.15rem; }

.eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

.rule { border: 0; border-top: 1px solid var(--rule); margin: 24px 0; }
.rule.double { border-top: 3px double var(--rule); }

.card {
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  padding: 24px;
}

.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.spread { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; flex-wrap: wrap; }
.grow { flex: 1 1 auto; }

label { display: block; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }

input[type='text'], input[type='email'], input[type='password'], input[type='number'], textarea, select {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--rule);
  background: var(--paper-raised);
  font-family: inherit;
  font-size: 15px;
  color: var(--navy);
  border-radius: 0;
}

input:focus, textarea:focus, select:focus, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--purple);
  outline-offset: 2px;
}

textarea { min-height: 90px; resize: vertical; }

button {
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 12px 22px;
  border: 1px solid var(--navy);
  background: var(--navy);
  color: var(--paper-raised);
  cursor: pointer;
  border-radius: 0;
  transition: background 200ms cubic-bezier(0.2, 0, 0, 1), color 200ms;
}
button:hover { background: var(--purple); border-color: var(--purple); }
button.ghost { background: transparent; color: var(--navy); border-color: var(--rule); }
button.ghost:hover { background: var(--navy); color: var(--paper-raised); border-color: var(--navy); }
button.link { background: none; border: none; color: var(--purple); padding: 4px; text-decoration: underline; font-weight: 500; }
button.link:hover { background: none; color: var(--navy); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.danger { background: transparent; color: var(--red); border-color: var(--red); }
button.danger:hover { background: var(--red); color: var(--paper-raised); }

.pill {
  display: inline-block;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 4px 9px;
  border: 1px solid currentColor;
}
.pill.draft { color: var(--muted); }
.pill.sent { color: var(--amber); }
.pill.completed { color: var(--green); }
.pill.declined, .pill.expired { color: var(--red); }

table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  padding: 0 12px 10px 0;
  border-bottom: 1px solid var(--rule);
}
td { padding: 14px 12px 14px 0; border-bottom: 1px solid var(--rule); vertical-align: middle; }
tr.clickable:hover td { background: rgba(108, 76, 156, 0.06); cursor: pointer; }

.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.notice { padding: 12px 16px; border-left: 3px solid var(--purple); background: rgba(108, 76, 156, 0.07); font-size: 14px; }
.notice.error { border-color: var(--red); background: rgba(163, 64, 47, 0.08); color: var(--red); }
.notice.success { border-color: var(--green); background: rgba(47, 111, 82, 0.08); color: var(--green); }

/* PDF weergave */
.viewer { background: #e9e4da; border: 1px solid var(--rule); padding: 18px; overflow: auto; max-height: 74vh; }
.page-wrap { position: relative; margin: 0 auto 18px; box-shadow: var(--shadow); background: #fff; width: fit-content; }
.page-wrap canvas { display: block; }

.field-box {
  position: absolute;
  border: 1.5px dashed var(--purple);
  background: rgba(108, 76, 156, 0.13);
  font-family: var(--mono);
  font-size: 10px;
  color: var(--purple);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: grab;
  user-select: none;
  overflow: hidden;
}
.field-box.other { border-color: var(--rule); background: rgba(27, 42, 74, 0.05); color: var(--muted); cursor: default; }
.field-box.active { border-style: solid; }
.field-box.filled { background: #fff; border-color: var(--green); }
.field-box img { width: 100%; height: 100%; object-fit: contain; }
.field-box .x {
  position: absolute; top: -9px; right: -9px; width: 18px; height: 18px; line-height: 16px;
  background: var(--navy); color: #fff; font-size: 11px; text-align: center; cursor: pointer;
}

.signature-pad { border: 1px solid var(--rule); background: var(--paper-raised); touch-action: none; width: 100%; height: 180px; display: block; }

.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--rule); margin-bottom: 20px; }
.tabs button {
  background: none; border: none; border-bottom: 2px solid transparent; color: var(--muted);
  padding: 10px 18px; font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase;
}
.tabs button[aria-selected='true'] { color: var(--navy); border-bottom-color: var(--purple); }
.tabs button:hover { background: none; color: var(--navy); }

.timeline { list-style: none; margin: 0; padding: 0; font-family: var(--mono); font-size: 12px; }
.timeline li { padding: 8px 0 8px 18px; border-left: 1px solid var(--rule); position: relative; }
.timeline li::before {
  content: ''; position: absolute; left: -3.5px; top: 15px; width: 6px; height: 6px; background: var(--purple);
}

.hidden { display: none !important; }

.center-shell {
  margin-left: 54px; min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 32px 20px;
  position: relative; z-index: 1;
}
.center-shell .card { width: 100%; max-width: 380px; }

@media (max-width: 720px) {
  .masthead { width: 40px; }
  .shell, .center-shell { margin-left: 40px; padding-left: 16px; padding-right: 16px; }
  .viewer { padding: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
