/* ── Reset & Base ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:    #1a56db;
  --primary-d:  #1344b0;
  --danger:     #e02424;
  --success:    #057a55;
  --bg:         #f3f4f6;
  --card:       #ffffff;
  --border:     #e5e7eb;
  --text:       #111827;
  --text-muted: #6b7280;
  --radius:     12px;
  --shadow:     0 2px 12px rgba(0,0,0,.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── Header ───────────────────────────────────────────────────── */
.header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.header-inner {
  max-width: 1200px; margin: 0 auto;
  padding: 0 20px; height: 56px;
  display: flex; align-items: center; justify-content: space-between;
}
.logo { display: flex; align-items: center; gap: 8px; }
.logo-icon { font-size: 22px; }
.logo-text { font-size: 18px; font-weight: 700; color: var(--primary); }
.version { font-size: 12px; color: var(--text-muted); }

/* ── Screens ──────────────────────────────────────────────────── */
.screen { display: none; max-width: 1200px; margin: 0 auto; padding: 24px 20px; }
.screen.active { display: block; }

.screen-header {
  display: flex; align-items: center; gap: 16px; margin-bottom: 24px;
}
.screen-header h2 { font-size: 20px; font-weight: 700; }

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border-radius: 8px; border: none;
  font-size: 14px; font-weight: 600; cursor: pointer; transition: all .15s;
}
.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover { background: #d1d5db; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #c81e1e; }
.btn-lg { padding: 14px 28px; font-size: 16px; border-radius: 10px; }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-full { width: 100%; margin-top: 16px; padding: 14px; }
.btn-back {
  background: none; border: none; cursor: pointer;
  font-size: 14px; color: var(--primary); font-weight: 600;
  padding: 6px 0;
}

/* ── Hero ─────────────────────────────────────────────────────── */
.hero {
  text-align: center; padding: 48px 20px 40px;
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 32px;
}
.hero-icon { font-size: 56px; margin-bottom: 16px; }
.hero h1 { font-size: 28px; font-weight: 800; margin-bottom: 12px; line-height: 1.3; }
.hero p { color: var(--text-muted); margin-bottom: 28px; font-size: 15px; }

/* ── Contracts list ───────────────────────────────────────────── */
.contracts-section h2 { font-size: 18px; font-weight: 700; margin-bottom: 16px; }
.contracts-list { display: flex; flex-direction: column; gap: 12px; }
.empty-msg { color: var(--text-muted); text-align: center; padding: 32px; }

.contract-card {
  background: var(--card); border-radius: var(--radius);
  border: 1px solid var(--border); padding: 16px 20px;
  display: flex; align-items: center; gap: 16px;
  box-shadow: var(--shadow);
}
.contract-card .icon { font-size: 28px; }
.contract-card .info { flex: 1; }
.contract-card .info strong { display: block; font-size: 14px; }
.contract-card .info span { font-size: 12px; color: var(--text-muted); }
.contract-card .actions { display: flex; gap: 8px; }

/* ── Upload ───────────────────────────────────────────────────── */
.upload-zone {
  background: var(--card); border: 2px dashed var(--primary);
  border-radius: var(--radius); padding: 56px 24px;
  text-align: center; cursor: pointer; transition: background .15s;
}
.upload-zone:hover { background: #eff6ff; }
.upload-icon { font-size: 48px; margin-bottom: 16px; }
.upload-sub { color: var(--text-muted); margin: 8px 0; }
.upload-progress {
  display: flex; align-items: center; justify-content: center;
  gap: 12px; margin-top: 24px; font-size: 15px;
}

/* ── Sign layout ──────────────────────────────────────────────── */
.sign-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 20px;
  align-items: start;
}
@media (max-width: 800px) {
  .sign-layout { grid-template-columns: 1fr; }
}

/* ── Sign panel ───────────────────────────────────────────────── */
.sign-panel {
  background: var(--card); border-radius: var(--radius);
  border: 1px solid var(--border); padding: 20px;
  display: flex; flex-direction: column; gap: 16px;
  position: sticky; top: 72px;
}
.sign-panel h3 { font-size: 13px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 8px; }

.signer-info { display: flex; flex-direction: column; gap: 6px; }
.signer-info label { font-size: 13px; font-weight: 600; color: var(--text-muted); }
.signer-info input {
  padding: 8px 12px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 14px; outline: none;
}
.signer-info input:focus { border-color: var(--primary); }

.tool-buttons { display: flex; gap: 8px; }
.tool-btn {
  flex: 1; padding: 10px; border-radius: 8px; border: 2px solid var(--border);
  background: var(--bg); cursor: pointer; font-size: 13px; font-weight: 600;
  transition: all .15s;
}
.tool-btn.active {
  border-color: var(--primary); background: #eff6ff; color: var(--primary);
}

#sig-pad {
  width: 100%; border: 2px solid var(--border); border-radius: 8px;
  cursor: crosshair; background: #fafafa; touch-action: none;
}
.pad-actions { text-align: right; margin-top: 6px; }

.page-controls { display: flex; align-items: center; gap: 12px; }
#page-indicator { font-size: 14px; font-weight: 600; }

.placed-items-list { display: flex; flex-direction: column; gap: 6px; max-height: 120px; overflow-y: auto; }
.placed-item {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg); border-radius: 6px; padding: 6px 10px; font-size: 12px;
}
.placed-item button {
  background: none; border: none; cursor: pointer; color: var(--danger); font-size: 14px;
}

/* ── PDF panel ────────────────────────────────────────────────── */
.pdf-panel { display: flex; flex-direction: column; gap: 8px; }
.pdf-container {
  position: relative; background: #525659;
  border-radius: var(--radius); overflow: hidden;
  min-height: 400px; display: flex; justify-content: center;
}
#pdf-canvas { display: block; max-width: 100%; }
.sig-overlay {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  cursor: crosshair;
}
.pdf-hint { font-size: 12px; color: var(--text-muted); text-align: center; }
.pdf-loading {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  gap: 12px; background: #525659; color: #fff; font-size: 14px;
}

/* Signature stickers on overlay */
.sig-sticker {
  position: absolute; cursor: move; user-select: none;
  border: 2px dashed rgba(26,86,219,.6); border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
}
.sig-sticker img { max-width: 100%; max-height: 100%; pointer-events: none; }
.sig-sticker .remove-btn {
  position: absolute; top: -10px; right: -10px;
  background: var(--danger); color: #fff; border: none;
  border-radius: 50%; width: 20px; height: 20px;
  font-size: 12px; cursor: pointer; display: none;
  align-items: center; justify-content: center;
}
.sig-sticker:hover .remove-btn { display: flex; }

/* ── Spinner ──────────────────────────────────────────────────── */
.spinner {
  width: 24px; height: 24px; border: 3px solid rgba(255,255,255,.3);
  border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Modal ────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 200;
}
.modal {
  position: fixed; inset: 0; z-index: 201;
  display: flex; align-items: center; justify-content: center; pointer-events: none;
}
.modal-box {
  background: var(--card); border-radius: var(--radius);
  padding: 40px 32px; text-align: center; max-width: 360px; width: 90%;
  box-shadow: 0 20px 60px rgba(0,0,0,.2); pointer-events: all;
}
.modal-icon { font-size: 52px; margin-bottom: 12px; }
.modal-box h2 { font-size: 22px; margin-bottom: 8px; }
.modal-box p  { color: var(--text-muted); margin-bottom: 24px; }
.modal-actions { display: flex; gap: 12px; justify-content: center; }
