/* ==========================
   Root Variables
========================== */
:root {
  /* Colors */
  --bg: #011745;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --text: #152033;
  --muted: #64748b;
  --line: #dbe3ef;

  --brand: #1d4ed8;
  --brand-strong: #2563eb;
  --brand-2: #0f766e;

  --danger: #b91c1c;
  --success: #0f8a5f;

  /* Effects */
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  --shadow-soft: 0 8px 18px rgba(37, 99, 235, 0.18);

  /* Radius */
  --radius-lg: 28px;
  --radius: 18px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --radius-pill: 999px;

  /* Spacing */
  --gap: 16px;
  --gap-sm: 10px;

  /* Transitions */
  --transition: all 0.2s ease;
}

/* ==========================
   Base Styles
========================== */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top, #eef4ff 0%, var(--bg) 55%, #eef2f7 100%);
}

/* ==========================
   Layout
========================== */
.page-shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 18px 48px;
}

/* ==========================
   Hero Section
========================== */
.hero {
  background: linear-gradient(135deg, #0f172a 0%, var(--brand) 55%, var(--brand-2) 100%);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow);
  margin-bottom: 22px;
}

.hero h1 {
  margin: 0 0 10px;
  font-size: clamp(1.6rem, 2.6vw, 2.4rem);
}

.hero p {
  margin: 0;
  max-width: 900px;
  line-height: 1.55;
  color: rgba(255, 255, 255, 0.9);
}

/* ==========================
   Sections
========================== */
.section {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(219, 227, 239, 0.85);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 18px;
  backdrop-filter: blur(8px);
}

.section-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--gap-sm);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.section-header h2 {
  margin: 0;
  font-size: 1.2rem;
}

.section-header .hint {
  margin: 0;
  font-size: 0.94rem;
  color: var(--muted);
}

.form-instructions {
  background: linear-gradient(180deg, #eff6ff 0%, #ffffff 100%);
  border: 1px solid #cfe0ff;
}

/* ==========================
   Grid System
========================== */
[class^="grid-"] {
  display: grid;
  gap: var(--gap);
}

.grid-1 { grid-template-columns: repeat(1, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

.instructions-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

/* ==========================
   Cards
========================== */
.instruction-card,
.check-card,
.preview-box {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #fff;
}

.instruction-card {
  padding: 14px 16px;
}

.instruction-card strong {
  display: block;
  margin-bottom: 6px;
}

.instruction-card span {
  font-size: 0.94rem;
  color: var(--muted);
  line-height: 1.45;
}

.subtle-box {
  background: var(--panel-2);
  border: 1px dashed #cdd7e7;
  border-radius: var(--radius-md);
  padding: 14px;
}

/* ==========================
   Forms
========================== */
.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

label {
  font-weight: 600;
  font-size: 0.95rem;
}

.req {
  color: var(--danger);
  margin-left: 4px;
}

input,
select,
textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: #fff;
  font: inherit;
  color: var(--text);
  transition: var(--transition);
}

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

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(29, 78, 216, 0.65);
  box-shadow: 0 0 0 4px rgba(29, 78, 216, 0.12);
}

:disabled {
  background: var(--panel-2);
  color: #94a3b8;
  cursor: not-allowed;
}

/* ==========================
   Toggles & Buttons
========================== */
.toggle-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap-sm);
}

.toggle-btn {
  flex: 1 1 0;
  min-width: 0;
  padding: 10px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
}

.toggle-btn:hover {
  transform: translateY(-1px);
}

.toggle-btn.active {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-strong) 100%);
  color: #fff;
  border-color: transparent;
  box-shadow: var(--shadow-soft);
}

.btn {
  padding: 13px 18px;
  border-radius: var(--radius-md);
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: var(--transition);
}

.btn:hover { transform: translateY(-1px); }

.btn-primary {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-strong) 100%);
  color: #fff;
  box-shadow: var(--shadow-soft);
}

.btn-secondary {
  background: #e2e8f0;
  color: #0f172a;
}

/* ==========================
   Preview Boxes
========================== */
.preview-wrap {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
}

.preview-box {
  width: 210px;
  height: 210px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--panel-2);
}

.preview-box img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.preview-box.clickable {
  cursor: pointer;
  position: relative;
}

.preview-box.clickable:hover {
  transform: translateY(-2px);
  border-color: var(--brand);
  box-shadow: 0 6px 18px rgba(29, 78, 216, 0.25);
}

.preview-box.signature:hover {
  transform: translateY(-2px);
  border-color: var(--brand);
  box-shadow: 0 6px 18px rgba(29, 78, 216, 0.25);
}

.preview-box.signature {
  cursor: pointer; /* show hand pointer */
}

.preview-box.signature:hover {
  transform: translateY(-2px);
  border-color: var(--brand);
  box-shadow: 0 6px 18px rgba(29, 78, 216, 0.25);
}

.placeholder-text {
  font-size: 0.9rem;
  color: var(--muted);
  text-align: center;
}

.preview-box img + .placeholder-text {
  display: none;
}

/* Signature-specific preview */
.preview-box.signature {
  width: 240px;
  height: 100px;
  border-radius: 10px;
}

.preview-box.signature img {
  object-fit: contain;
  background: #fff;
}

/* ==========================
   Checkbox Grid
========================== */
.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: var(--gap-sm);
}

.check-card {
  padding: 7px;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  position: relative;
  transition: var(--transition);
}

.check-card input {
  position: absolute;
  opacity: 0;
}

.check-card div {
  font-size: 0.79rem;
  width: 100%;
}

.check-card:hover {
  border-color: rgba(29, 78, 216, 0.35);
  background: rgba(29, 78, 216, 0.04);
}

.check-card:active {
  transform: scale(0.97);
}

.check-card:has(input:checked),
.check-card.selected {
  background: #c0e7fc;
  border-color: rgba(29, 78, 216, 0.45);
  box-shadow: 0 0 0 4px rgba(29, 78, 216, 0.08);
}

/* ==========================
   Utilities
========================== */
.hidden { display: none !important; }

.inline-note,
.file-meta {
  font-size: 0.92rem;
  color: var(--muted);
}

/* ==========================
   Alerts / Messages
========================== */
.error-summary {
  display: none;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  background: #fff1f2;
  border: 1px solid #fecdd3;
  color: #9f1239;
}

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

.mini-banner {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: #f8fbff;
  border: 1px solid #dbe7ff;
  color: #334155;
}

/* ==========================
   Footer / Misc
========================== */
.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 12px;
}

.footer-note {
  text-align: center;
  font-size: 0.9rem;
  color: var(--muted);
  margin-top: 18px;
}

.signature-line {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--gap);
}

.auto-date {
  background: var(--panel-2);
  font-weight: 600;
}

.json-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-pill);
  font-size: 0.9rem;
  background: #eff6ff;
  color: var(--brand);
  border: 1px solid #dbeafe;
}

/* ==========================
   Responsive
========================== */
@media (max-width: 1024px) {
  .checkbox-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 980px) {
  .grid-2,
  .grid-3,
  .grid-4,
  .instructions-grid,
  .signature-line {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .checkbox-grid { grid-template-columns: repeat(2, 1fr); }
}