:root {
  --navy: #1A3A6E;
  --navy-dark: #122A52;
  --light-blue: #5BA8E0;
  --light-blue-soft: #E8F2FB;
  --bg: #F4F6FA;
  --card: #FFFFFF;
  --text: #1F2937;
  --text-muted: #6B7280;
  --border: #E5E7EB;
  --success: #15803D;
  --error: #B91C1C;
  --error-bg: #FEF2F2;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.10);
  --radius: 12px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

.brand {
  display: flex;
  justify-content: center;
  margin-bottom: 28px;
}
.brand img {
  max-width: 280px;
  width: 100%;
  height: auto;
}

h1 {
  text-align: center;
  font-size: 28px;
  font-weight: 700;
  color: var(--navy);
  margin: 0 0 8px;
  letter-spacing: -0.01em;
}

.lead {
  text-align: center;
  color: var(--text-muted);
  font-size: 16px;
  margin: 0 0 32px;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 28px;
  margin-bottom: 20px;
  border: 1px solid var(--border);
}
.card h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--navy);
  margin: 0 0 16px;
}

label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}

input[type="email"],
input[type="text"] {
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input[type="email"]:focus,
input[type="text"]:focus {
  outline: none;
  border-color: var(--light-blue);
  box-shadow: 0 0 0 3px rgba(91, 168, 224, 0.20);
}

.help-text {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 6px;
}

button.primary,
.primary {
  width: 100%;
  padding: 13px 20px;
  font-size: 16px;
  font-weight: 600;
  background: var(--navy);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-top: 18px;
  transition: background-color 0.15s, transform 0.05s;
  text-align: center;
  text-decoration: none;
  display: inline-block;
}
button.primary:hover:not(:disabled),
.primary:hover:not(:disabled) { background: var(--navy-dark); }
button.primary:active:not(:disabled),
.primary:active:not(:disabled) { transform: translateY(1px); }
button.primary:disabled,
.primary:disabled {
  background: #C7CDD7;
  cursor: not-allowed;
}

button.secondary,
.secondary {
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 500;
  background: #fff;
  color: var(--navy);
  border: 1px solid var(--navy);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color 0.15s;
  text-decoration: none;
  display: inline-block;
}
button.secondary:hover,
.secondary:hover { background: var(--light-blue-soft); }

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 18px;
}
.alert.success { background: #ECFDF5; color: var(--success); border: 1px solid #BBF7D0; }
.alert.error { background: var(--error-bg); color: var(--error); border: 1px solid #FECACA; }
.alert.info { background: var(--light-blue-soft); color: var(--navy); border: 1px solid #BFDBFE; }

/*
 * Existing JS (request-link.js, sign.js) sets status elements to
 * "notice notice-ok" / "notice notice-error" and toggles a "hidden" class.
 * Map those onto the alert visual system above so the JS keeps working
 * without modification.
 */
.hidden { display: none !important; }
.notice { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 18px; }
.notice-ok { background: #ECFDF5; color: var(--success); border: 1px solid #BBF7D0; }
.notice-error { background: var(--error-bg); color: var(--error); border: 1px solid #FECACA; }

/* Doc cards (sign.html) */
.doc-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin: 8px 0 24px;
}
.doc-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.doc-card.viewed { border-color: var(--light-blue); box-shadow: 0 0 0 2px rgba(91, 168, 224, 0.15); }
.doc-card.complete { border-color: var(--success); background: #F0FDF4; }
.doc-card-title {
  font-weight: 600;
  font-size: 15px;
  color: var(--navy);
  margin: 0;
}
.doc-meta {
  font-size: 13px;
  color: var(--text-muted);
  margin: -8px 0 0;
}
.doc-card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.doc-card-status {
  font-size: 13px;
  color: var(--text-muted);
}
.doc-card-status.locked { color: var(--text-muted); }
.doc-card-status.unlocked { color: var(--success); font-weight: 500; }
.doc-card.complete .doc-card-status { color: var(--success); font-weight: 500; }

/* Reference materials (optional, sign.html) */
.ref-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin: 8px 0 4px;
}
.ref-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  background: #FAFBFC;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
}
.ref-card:hover,
.ref-card:focus-visible {
  border-color: var(--light-blue);
  background: var(--light-blue-soft);
  box-shadow: 0 0 0 2px rgba(91, 168, 224, 0.15);
  outline: none;
}
.ref-card-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.ref-card-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--navy);
}
.ref-card-desc {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
}
.ref-card-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.ref-card-action {
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 600;
  color: var(--navy);
  border: 1px solid var(--navy);
  border-radius: 6px;
  padding: 6px 12px;
  background: #fff;
  white-space: nowrap;
}
.ref-card:hover .ref-card-action,
.ref-card:focus-visible .ref-card-action {
  background: var(--navy);
  color: #fff;
}

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}
.checkbox-row input[type="checkbox"] {
  margin-top: 2px;
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--navy);
}
.checkbox-row.disabled { color: var(--text-muted); cursor: not-allowed; }
.checkbox-row.disabled input { cursor: not-allowed; }

/* Signature pad */
.sig-wrap {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  padding: 0;
  position: relative;
  overflow: hidden;
  margin: 8px 0 4px;
}
.sig-wrap canvas {
  display: block;
  width: 100%;
  height: 200px;
  touch-action: none;
}
.sig-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 4px;
  font-size: 13px;
  color: var(--text-muted);
}
.sig-actions button {
  padding: 8px 14px;
  font-size: 13px;
  background: #fff;
  color: var(--navy);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.sig-actions button:hover { background: var(--light-blue-soft); border-color: var(--navy); }

/* Legal text block */
.legal-text {
  background: #FAFBFC;
  border-left: 3px solid var(--light-blue);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  margin: 18px 0;
}

/* Helper for the email shown next to "Signing as" */
.signer-email {
  font-weight: 600;
  color: var(--navy);
}

/* Footer */
footer {
  text-align: center;
  margin-top: 48px;
  font-size: 13px;
  color: var(--text-muted);
}

/* Desktop tweaks */
@media (min-width: 720px) {
  .container { padding: 56px 24px 80px; }
  h1 { font-size: 32px; }
  .card { padding: 32px; }
}

/* ---------------------------------------------------------------------- */
/* In-app PDF viewer (sign.html)                                          */
/* ---------------------------------------------------------------------- */
.pdf-viewer {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
}
.pdf-viewer.hidden { display: none !important; }

.pdf-viewer-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
}

.pdf-viewer-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  background: #fff;
  overflow: hidden;
  margin: auto;
}

@media (min-width: 720px) {
  .pdf-viewer-panel {
    width: min(1040px, 94vw);
    height: min(920px, 94vh);
    border-radius: var(--radius);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
  }
}

.pdf-viewer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--navy);
  color: #fff;
  border-bottom: 1px solid var(--navy-dark);
  flex: 0 0 auto;
}
.pdf-viewer-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pdf-viewer-close {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 28px;
  line-height: 1;
  width: 36px;
  height: 36px;
  cursor: pointer;
  border-radius: 8px;
  flex: 0 0 auto;
  padding: 0;
}
.pdf-viewer-close:hover,
.pdf-viewer-close:focus-visible {
  background: rgba(255, 255, 255, 0.14);
  outline: none;
}
.pdf-viewer-close[disabled],
.pdf-viewer-close[aria-disabled="true"] {
  opacity: 0.35;
  cursor: not-allowed;
}
.pdf-viewer-close[disabled]:hover,
.pdf-viewer-close[aria-disabled="true"]:hover {
  background: transparent;
}
.pdf-viewer.pdf-viewer-locked .pdf-viewer-overlay { cursor: not-allowed; }

.pdf-viewer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 12px;
  background: #F3F4F6;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.pdf-viewer-toolbar-group {
  display: flex;
  align-items: center;
  gap: 6px;
}
.pdf-viewer-toolbar-right { margin-left: auto; }
.pdf-viewer-iconbtn {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  min-width: 36px;
  color: var(--text);
  line-height: 1;
}
.pdf-viewer-iconbtn:hover,
.pdf-viewer-iconbtn:focus-visible {
  background: var(--light-blue-soft);
  border-color: var(--navy);
  color: var(--navy);
  outline: none;
}
.pdf-viewer-fit { font-size: 13px; padding: 6px 12px; }

.pdf-viewer-page {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--text);
}
.pdf-viewer-page input {
  width: 56px;
  padding: 5px 6px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  text-align: center;
  background: #fff;
  -moz-appearance: textfield;
}
.pdf-viewer-page input::-webkit-outer-spin-button,
.pdf-viewer-page input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.pdf-viewer-page-sep { color: var(--text-muted); }

.pdf-viewer-download {
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  color: var(--navy);
  border: 1px solid var(--navy);
  border-radius: 6px;
  padding: 6px 12px;
  background: #fff;
  line-height: 1;
}
.pdf-viewer-download:hover,
.pdf-viewer-download:focus-visible {
  background: var(--light-blue-soft);
  outline: none;
}

.pdf-viewer-body {
  position: relative;
  flex: 1 1 auto;
  overflow: auto;
  background: #525659;
  -webkit-overflow-scrolling: touch;
  outline: none;
}
.pdf-viewer-pages {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 16px 8px 32px;
  min-height: 100%;
}
.pdf-viewer-page-wrap {
  position: relative;
  background: #fff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  border-radius: 2px;
  max-width: 100%;
}
.pdf-viewer-canvas {
  display: block;
  max-width: 100%;
  height: auto;
}

/* Bouncing down-arrow hint shown after 45s if reader hasn't reached the
 * end yet. Lives inside the panel (not the scrolling body) so it stays
 * pinned to the bottom of the viewer regardless of scroll position. */
.pdf-viewer-hint {
  position: absolute;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.78);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  z-index: 5;
}
.pdf-viewer-hint.hidden { display: none !important; }
.pdf-viewer-hint-arrow {
  display: block;
  width: 16px;
  height: 16px;
  border-right: 3px solid #fff;
  border-bottom: 3px solid #fff;
  margin-top: -4px;
  animation: pdf-viewer-bounce 1.1s ease-in-out infinite;
}
@keyframes pdf-viewer-bounce {
  0%, 100% { transform: rotate(45deg) translate(-3px, -3px); }
  50%      { transform: rotate(45deg) translate(3px, 3px); }
}
@media (prefers-reduced-motion: reduce) {
  .pdf-viewer-hint-arrow { animation: none; transform: rotate(45deg); }
}

.pdf-viewer-loading {
  text-align: center;
  color: #fff;
  padding: 40px 16px;
  font-size: 15px;
  letter-spacing: 0.01em;
}

body.pdf-viewer-open { overflow: hidden; }

@media (max-width: 480px) {
  .pdf-viewer-toolbar { padding: 6px 8px; gap: 6px; }
  .pdf-viewer-toolbar-group { gap: 4px; }
  .pdf-viewer-iconbtn { padding: 6px 8px; min-width: 32px; }
  .pdf-viewer-page input { width: 44px; }
  .pdf-viewer-download { padding: 6px 10px; }
  .pdf-viewer-title { font-size: 15px; }
  .pdf-viewer-hint { font-size: 13px; padding: 8px 14px; }
}
