:root {
  --ink: #1b2430;
  --ink-soft: #5b6675;
  --line: #dde2e8;
  --surface: #ffffff;
  --page-bg: #f4f6f8;
  --accent: #7CB829;
  --accent-soft: #eef7e1;
  --accent-strong: #6aa020;
  --spm-blue: #1A9ACC;
  --spm-navy: #2C3E6B;
  --danger: #d9534f;
  --danger-soft: #fcebeb;
  --radius: 10px;
  --font-sans: Arial, Helvetica, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--page-bg);
  color: var(--ink);
  line-height: 1.5;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.topbar .brand {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.2px;
}

.topbar .brand span {
  color: var(--accent);
}

.topbar .brand img {
  height: 30px;
  display: block;
}

.wrap {
  max-width: 880px;
  margin: 0 auto;
  padding: 32px 20px 60px;
}

.wrap.wide {
  max-width: 1180px;
}

h1 {
  font-size: 22px;
  font-weight: 600;
  margin: 0 0 6px;
}

h2 {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 12px;
}

p.lede {
  color: var(--ink-soft);
  margin: 0 0 28px;
  font-size: 14px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
}

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin: 16px 0 6px;
  color: var(--ink);
}

label:first-child { margin-top: 0; }

input[type="text"],
input[type="email"],
input[type="file"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: var(--surface);
  color: var(--ink);
}

input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.hint {
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 4px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 8px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
}

.btn:hover { background: var(--accent-strong); }
.btn:disabled { background: #b4b2a9; cursor: not-allowed; }

.btn.secondary {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn.secondary:hover { border-color: var(--ink-soft); }

.btn.danger { background: var(--danger); }

.row { display: flex; gap: 12px; align-items: center; }
.row.between { justify-content: space-between; }

.error-banner {
  background: var(--danger-soft);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}

.error-banner.show { display: block; }

.success-banner {
  background: var(--accent-soft);
  color: var(--accent-strong);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
}

/* Editor layout */
.editor-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 20px;
  align-items: start;
}

.tool-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  position: sticky;
  top: 20px;
}

.field-tool {
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  margin-bottom: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  font-size: 13px;
  font-weight: 600;
  cursor: grab;
  color: var(--ink);
}

.field-tool:hover { border-color: var(--accent); color: var(--accent); }

.pdf-viewer {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}

.page-wrap {
  position: relative;
  margin: 0 auto 16px;
  box-shadow: 0 0 0 1px var(--line);
}

.page-wrap canvas { display: block; width: 100%; height: auto; }

.placed-field {
  position: absolute;
  border: 1.5px dashed var(--accent);
  background: rgba(15, 110, 86, 0.08);
  border-radius: 4px;
  font-size: 11px;
  color: var(--accent-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: move;
  user-select: none;
}

.placed-field .remove {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 16px;
  height: 16px;
  background: var(--danger);
  color: #fff;
  border-radius: 50%;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.signer-field {
  position: absolute;
  border: 1.5px solid var(--accent);
  border-radius: 4px;
  background: rgba(255,255,255,0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.signer-field.filled {
  border-style: solid;
  background: var(--accent-soft);
}

.signer-field input[type="text"] {
  width: 100%;
  height: 100%;
  border: none;
  background: transparent;
  padding: 0 4px;
  font-size: 12px;
}

.signer-field img { max-width: 100%; max-height: 100%; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(27,36,48,0.5);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal-backdrop.show { display: flex; }

.modal-backdrop.green-tint {
  background: rgba(124, 184, 41, 0.55);
}

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  width: 400px;
  max-width: 92vw;
}

#sigCanvas {
  border: 1px solid var(--line);
  border-radius: 8px;
  width: 100%;
  height: 160px;
  touch-action: none;
  cursor: crosshair;
}

.consent-box {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--page-bg);
  border-radius: 8px;
  padding: 14px;
  font-size: 13px;
  color: var(--ink-soft);
  margin: 20px 0;
}

.consent-box input { margin-top: 3px; }

.status-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

/* App nav (Home / Agreements / Templates / Insights / Admin) */
.app-nav {
  background: var(--accent);
  display: flex;
  align-items: stretch;
  height: 40px;
}

.app-nav a {
  color: #fff;
  padding: 0 18px;
  height: 40px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  border-right: 1px solid rgba(255,255,255,0.2);
  white-space: nowrap;
  display: flex;
  align-items: center;
  text-decoration: none;
}

.app-nav a:hover { background: var(--spm-blue); }
.app-nav a.active { background: var(--spm-navy); }

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

.topbar .welcome strong {
  color: var(--accent-strong);
}

.topbar .logout-link {
  font-size: 13px;
  color: var(--spm-blue);
  text-decoration: none;
  font-weight: 600;
  margin-left: 14px;
}

/* Dashboard */
.dash-banner {
  background: linear-gradient(135deg, var(--spm-navy), var(--accent-strong));
  color: #fff;
  padding: 36px 20px;
  text-align: center;
  border-radius: 0 0 var(--radius) var(--radius);
}

.dash-banner h1 {
  color: #fff;
  font-size: 22px;
  font-weight: 600;
  margin: 0 0 20px;
}

.dash-banner .btn {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.4);
}

.dash-banner .btn:hover {
  background: rgba(255,255,255,0.25);
}

.dash-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 20px;
  align-items: start;
  margin-top: 24px;
}

.overview-card .overview-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

.overview-card .overview-row:last-child { border-bottom: none; }
.overview-card .overview-count { font-weight: 700; font-size: 16px; color: var(--ink); }
.overview-card .overview-count.muted { color: var(--ink-soft); font-weight: 600; }

.activity-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.activity-row:last-child { border-bottom: none; }
.activity-title { font-size: 14px; font-weight: 600; color: var(--ink); }
.activity-meta { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.activity-status { font-size: 12px; font-weight: 600; white-space: nowrap; margin-left: 16px; }
.activity-status.signed { color: var(--accent-strong); }
.activity-status.expiring { color: #b5851b; }
.activity-status.waiting { color: var(--spm-blue); }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--ink-soft);
  font-size: 14px;
}
