/* ---------------------------------------------------------------
   Handtekening-tool — interface
   --------------------------------------------------------------- */

:root {
  --bg:        #f4f5f7;
  --panel:     #ffffff;
  --line:      #e3e5e9;
  --line-soft: #eef0f3;
  --ink:       #1c1e21;
  --ink-soft:  #6b7280;
  --ink-faint: #9aa1ab;
  /* Merkkleur #a18bf9, met tinten uit dezelfde kleurtoon (252°).
     Wit op #a18bf9 haalt maar 2,8:1 contrast, te weinig om te lezen;
     daarom staat er diep paars op de accentkleur (6,4:1, ook bij hover) en
     gebruiken links op wit de donkere tint (6,8:1). */
  --accent:      #a18bf9;
  --accent-dk:   #896ef7;
  --accent-deep: #5c3dd6;
  --accent-ink:  #1a0f40;
  --accent-bg:   #efecfe;
  --accent-line: #d4cafc;
  --accent-ring: rgba(161, 139, 249, .45);
  --warn-bg:   #fff8e6;
  --warn-line: #f3dfa8;
  --warn-ink:  #8a6100;
  --danger:    #b42318;
  --radius:    10px;
  --shadow:    0 1px 2px rgba(16, 24, 40, .05), 0 4px 16px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-deep); }

h1, h2, h3 { margin: 0; font-weight: 600; }

/* --------------------------------------------------- login / setup */

.gate {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.gate-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 32px;
}

.gate-card h1 { font-size: 19px; }

.gate-intro {
  color: var(--ink-soft);
  margin: 8px 0 24px;
}

.gate-hint {
  color: var(--ink-faint);
  font-size: 12px;
  margin: -8px 0 20px;
}

.gate-error {
  background: #fef3f2;
  border: 1px solid #fecdc9;
  color: var(--danger);
  border-radius: 8px;
  padding: 10px 12px;
  margin: 0 0 20px;
}

/* ------------------------------------------------------- app frame */

.app {
  display: flex;
  min-height: 100vh;
  align-items: stretch;
}

.sidebar {
  width: 232px;
  flex: 0 0 232px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  font-weight: 600;
  font-size: 15px;
  padding: 0 8px;
  line-height: 1.35;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav a {
  display: block;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--ink-soft);
  text-decoration: none;
  font-weight: 500;
}

.nav a:hover { background: var(--bg); color: var(--ink); }

.nav a.is-active {
  background: var(--accent);
  color: var(--accent-ink);
}

.sidebar-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: flex-start;
}

.link-quiet {
  color: var(--ink-faint);
  font-size: 12px;
  text-decoration: none;
  padding-left: 4px;
}

.link-quiet:hover { color: var(--ink); text-decoration: underline; }

.main {
  flex: 1 1 auto;
  min-width: 0;
  padding: 32px 36px 64px;
}

.loading { color: var(--ink-faint); }

/* --------------------------------------------------------- headers */

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.page-head h1 { font-size: 20px; }

.page-head p {
  margin: 6px 0 0;
  color: var(--ink-soft);
  max-width: 62ch;
}

.head-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* --------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font: inherit;
  font-weight: 500;
  line-height: 1.2;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover { background: var(--bg); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.btn-primary:hover { background: var(--accent-dk); border-color: var(--accent-dk); }

.btn-danger { color: var(--danger); border-color: #f0c7c3; }
.btn-danger:hover { background: #fef3f2; }

.btn-block { width: 100%; }

.btn-sm { padding: 5px 10px; font-size: 13px; }

.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ----------------------------------------------------------- cards */

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card + .card { margin-top: 20px; }

.card-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-head h2 { font-size: 15px; }

.card-head p { margin: 3px 0 0; color: var(--ink-soft); font-size: 13px; }

.card-body { padding: 20px; }

/* ---------------------------------------------------------- tables */

.table { width: 100%; border-collapse: collapse; }

.table th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ink-faint);
  font-weight: 600;
  padding: 10px 20px;
  border-bottom: 1px solid var(--line-soft);
}

.table td {
  padding: 12px 20px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}

.table tr:last-child td { border-bottom: 0; }

.table tr:hover td { background: #fbfcfd; }

.table .cell-actions {
  text-align: right;
  white-space: nowrap;
}

.table .cell-actions .btn + .btn { margin-left: 6px; }

.cell-title { font-weight: 600; }

.cell-sub { color: var(--ink-soft); font-size: 13px; }

.checkcell { width: 40px; }

/* ------------------------------------------------------------ tags */

.tag {
  display: inline-block;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--ink-soft);
}

.tag-manual { background: #fff8e6; border-color: var(--warn-line); color: var(--warn-ink); }
.tag-ok     { background: #ecfdf3; border-color: #b9e6c8; color: #05603a; }

/* ----------------------------------------------------------- forms */

.field { display: block; margin-bottom: 16px; }

.field > span {
  display: block;
  font-weight: 500;
  margin-bottom: 5px;
  font-size: 13px;
}

.field input[type="text"],
.field input[type="email"],
.field input[type="url"],
.field input[type="password"],
.field select,
.field textarea {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: #fff;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.field .hint {
  display: block;
  color: var(--ink-faint);
  font-size: 12px;
  margin-top: 4px;
}

.field > span.field-color { display: flex; gap: 8px; align-items: center; }
.field-color input[type="text"] { flex: 1 1 auto; min-width: 0; }
.field-color input[type="color"] {
  width: 40px;
  height: 38px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  flex: 0 0 auto;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0 20px;
}

.code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.6;
  tab-size: 2;
}

textarea.code { min-height: 420px; white-space: pre; }

.fieldset-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ink-faint);
  font-weight: 600;
  margin: 4px 0 12px;
  padding-top: 20px;
  border-top: 1px solid var(--line-soft);
}

.fieldset-title:first-child { padding-top: 0; border-top: 0; }

/* --------------------------------------------------------- preview */

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

@media (max-width: 1100px) {
  .split { grid-template-columns: minmax(0, 1fr); }
}

.preview-frame {
  width: 100%;
  min-height: 260px;
  border: 0;
  background: #fff;
  display: block;
}

.preview-wrap {
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.placeholder-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.placeholder-list code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 2px 6px;
  cursor: pointer;
}

.placeholder-list code:hover { border-color: var(--accent); color: var(--accent-deep); }

.placeholder-list code.is-unknown { border-color: var(--warn-line); background: var(--warn-bg); color: var(--warn-ink); }

/* --------------------------------------------------------- banners */

.banner {
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 20px;
  border: 1px solid var(--line);
  background: var(--panel);
}

.banner-warn { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn-ink); }

.empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--ink-soft);
}

.empty h3 { font-size: 15px; margin-bottom: 6px; }

.empty p { margin: 0 0 18px; }

/* ----------------------------------------------------------- modal */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, .45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 20px;
  overflow-y: auto;
  z-index: 50;
}

.modal {
  background: var(--panel);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(16, 24, 40, .25);
  width: 100%;
  max-width: 640px;
  margin: auto;
}

.modal-wide { max-width: 1080px; }

.modal-head {
  padding: 20px 24px;
  border-bottom: 1px solid var(--line-soft);
}

.modal-head h2 { font-size: 16px; }

.modal-head p { margin: 4px 0 0; color: var(--ink-soft); font-size: 13px; }

.modal-body { padding: 24px; }

.modal-foot {
  padding: 16px 24px;
  border-top: 1px solid var(--line-soft);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.modal-foot .spacer { margin-right: auto; }

/* ------------------------------------------------------- checklist */

.checklist {
  border: 1px solid var(--line);
  border-radius: 8px;
  max-height: 260px;
  overflow-y: auto;
}

.checklist label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
}

.checklist label:last-child { border-bottom: 0; }
.checklist label:hover { background: var(--bg); }

/* ----------------------------------------------------------- toast */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1c1e21;
  color: #fff;
  padding: 11px 18px;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(16, 24, 40, .2);
  z-index: 100;
  max-width: 90vw;
}

.toast[hidden] { display: none; }

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

@media (max-width: 720px) {
  .app { flex-direction: column; }
  .sidebar { width: auto; flex: none; height: auto; position: static; border-right: 0; border-bottom: 1px solid var(--line); }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .main { padding: 24px 18px 48px; }
}

/* ------------------------------------------------- werkruimte-badge */

.workspace-badge {
  background: var(--accent-bg);
  border: 1px solid var(--accent-line);
  border-radius: 10px;
  padding: 12px 14px;
}

.workspace-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--accent-deep);
  font-weight: 600;
}

.workspace-badge strong {
  display: block;
  font-size: 15px;
  line-height: 1.3;
  margin: 2px 0 12px;
  overflow-wrap: anywhere;
}

.field > span.check-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 0;
}

.check-inline input[type="checkbox"] { flex: 0 0 auto; }

.checklist .cell-sub { color: var(--ink-faint); }

.page-head code,
.card-head code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
}

/* ------------------------------------------------ batch genereren */

.scope-choice {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin-bottom: 12px;
}

.scope-choice label {
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
}

.bulk-summary {
  margin: 16px 0 0;
  padding: 11px 13px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink-soft);
}

.checklist[hidden] { display: none; }

/* --------------------------------------------------- import-koppeling */

.check-row { margin-bottom: 18px; }

.check-row label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.map-list {
  border: 1px solid var(--line);
  border-radius: 8px;
  max-height: 340px;
  overflow-y: auto;
}

.map-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: 16px;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-soft);
}

.map-row:last-child { border-bottom: 0; }

.map-row .map-name {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.map-row .cell-sub {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.map-row select {
  font: inherit;
  color: var(--ink);
  background: #fff;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  width: 100%;
}

.map-row select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.field input[type="file"] {
  width: 100%;
  font: inherit;
  padding: 9px 11px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

@media (max-width: 640px) {
  .map-row { grid-template-columns: minmax(0, 1fr); gap: 8px; }
}

/* --------------------------------------------------- selectiebalk */

.select-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  background: var(--panel);
  border: 1px solid var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
  border-radius: var(--radius);
  padding: 11px 16px;
  margin-bottom: 16px;
  font-weight: 500;
}

.select-bar[hidden] { display: none; }

.select-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.table .checkcell {
  width: 44px;
  padding-right: 0;
}

.table .checkcell input {
  display: block;
  margin: 0;
  cursor: pointer;
}

/* ------------------------------------------- keuze bij bestaande */

.mode-choice {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.mode-choice label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 11px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
}

.mode-choice label:hover { background: var(--bg); }

.mode-choice input { margin-top: 3px; flex: 0 0 auto; }

.mode-choice label > span {
  display: block;
  min-width: 0;
}

.mode-choice .hint { display: block; margin-top: 1px; }

/* ------------------------------------------------- brede tabellen */

/* Zes kolommen passen niet altijd. Liever horizontaal schuiven dan
   namen en telefoonnummers over meerdere regels laten afbreken. */
.card { overflow-x: auto; }

.table { min-width: 600px; }

.table .cell-sub,
.table .cell-title,
.table .tag {
  white-space: nowrap;
}

/* De naamkolom krijgt voorrang op de vaste kolommen ernaast. */
.table td:nth-child(2) { width: 100%; }

/* Laatste kolom iets krapper: scheelt net genoeg om de schuifbalk
   op een 1280px-scherm te vermijden. */
.table td.cell-actions,
.table th:last-child { padding-right: 14px; }

/* Tabelcellen iets krapper: scheelt bij zes kolommen zo'n 70px. */
.table th,
.table td { padding-left: 14px; padding-right: 14px; }

/* Het e-mailadres krijgt voorrang, maar mag als laatste redmiddel
   afkappen. De volledige waarde staat dan in de tooltip. */
.table .cell-email {
  max-width: 340px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Compacte actieknop met alleen een teken; de betekenis staat in de tooltip. */
.btn-icon {
  min-width: 30px;
  padding-left: 8px;
  padding-right: 8px;
  font-size: 15px;
  line-height: 1;
}

/* ------------------------------------------------ herkomst en download */

/* De metaregel onder een handtekening mag wél afbreken: die kolom heeft
   ruimte zat, in tegenstelling tot de personenlijst. */
.table .cell-meta { white-space: normal; }

.meta-dot { color: var(--ink-faint); padding: 0 3px; }

.meta-pending { color: var(--warn-ink); }

.head-meta {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--ink-faint);
  max-width: none;
}

/* Selectiebalk binnen een sjabloongroep: geen losse kaart, maar een strook
   tussen de kop en de tabel. */
.select-bar-inline {
  border: 0;
  border-bottom: 1px solid var(--accent-line);
  border-radius: 0;
  box-shadow: none;
  background: var(--accent-bg);
  margin: 0;
  padding: 10px 14px;
}

/* Elk deel van de metaregel blijft op één regel; afbreken gebeurt tussen
   de delen, niet midden in een datum of tijdstip. */
.meta-part { white-space: nowrap; }

/* Informatieve melding, in de accentkleur in plaats van waarschuwingsgeel. */
.banner-info {
  background: var(--accent-bg);
  border-color: var(--accent-line);
  color: var(--ink);
}
