/* ═══════════════════════════════════════════════════════════
   ContractFlow – App Styles
   ═══════════════════════════════════════════════════════════ */

/* ─── Variables ────────────────────────────────────────────── */
:root {
  --primary:        #C8562A;   /* terracotta */
  --primary-dark:   #A84420;   /* burnt sienna */
  --primary-light:  #FDF0EA;   /* terracotta wash */
  --primary-ring:   rgba(200,86,42,0.22);

  --success:        #5A8330;   /* olive green */
  --success-light:  #EDF4E3;
  --warning:        #C49220;   /* golden amber */
  --warning-light:  #FFF8E4;
  --danger:         #C43020;
  --danger-light:   #FEF2F0;

  --bg:             #FBF6F0;   /* warm cream */
  --surface:        #FFFDF8;   /* warm white */
  --border:         #E8DDD4;   /* warm beige */
  --border-focus:   #D4936A;   /* terracotta focus */

  --text:           #2C1A0E;   /* dark warm brown */
  --text-secondary: #4A2E1C;
  --text-muted:     #8B6858;
  --text-light:     #B89080;

  --shadow-xs:  0 1px 2px rgba(44,26,14,0.06);
  --shadow-sm:  0 1px 3px rgba(44,26,14,0.09), 0 1px 2px rgba(44,26,14,0.05);
  --shadow:     0 4px 6px -1px rgba(44,26,14,0.09), 0 2px 4px -1px rgba(44,26,14,0.05);
  --shadow-md:  0 10px 15px -3px rgba(44,26,14,0.09), 0 4px 6px -2px rgba(44,26,14,0.04);
  --shadow-lg:  0 20px 25px -5px rgba(44,26,14,0.09), 0 10px 10px -5px rgba(44,26,14,0.03);

  --radius-sm:  6px;
  --radius:     10px;
  --radius-md:  14px;
  --radius-lg:  20px;
  --radius-xl:  28px;

  --ease:       cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ─── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}
button { cursor: pointer; font-family: inherit; border: none; background: none; }
input, textarea, select { font-family: inherit; }
a { color: var(--primary); }

/* ─── Layout ─────────────────────────────────────────────────── */
.main    { padding-top: 72px; min-height: 100vh; }
.container { max-width: 1200px; margin: 0 auto; padding: 40px 24px; }
.container--narrow { max-width: 600px; margin: 0 auto; padding: 40px 24px; }

/* ─── Header ─────────────────────────────────────────────────── */
.header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 64px;
  background: rgba(255,255,255,0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Logo */
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}
.logo-mark {
  width: 36px; height: 36px;
  background: var(--primary-light);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
}
.logo-text {
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}

/* Security badge */
.security-badge-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--success);
  background: var(--success-light);
  padding: 5px 12px;
  border-radius: 100px;
  border: 1px solid rgba(5,150,105,0.2);
}

/* ─── Pages ──────────────────────────────────────────────────── */
.page { display: none; }
.page.active { display: block; animation: fadeUp 0.3s var(--ease) both; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 600;
  transition: all 0.15s var(--ease);
  white-space: nowrap;
  outline: none;
}
.btn:focus-visible { box-shadow: 0 0 0 3px var(--primary-ring); }

.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 1px 2px rgba(200,86,42,0.3), 0 0 0 0 var(--primary-ring);
}
.btn-primary:hover {
  background: var(--primary-dark);
  box-shadow: 0 4px 12px rgba(200,86,42,0.35);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); box-shadow: var(--shadow-xs); }

.btn-ghost {
  background: white;
  color: var(--text-secondary);
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow-xs);
}
.btn-ghost:hover {
  border-color: #D1D5DB;
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-danger:hover { background: #B91C1C; transform: translateY(-1px); }

.btn--full { width: 100%; justify-content: center; padding: 12px; }
.btn--sign { font-size: 1rem; padding: 14px; border-radius: var(--radius-md); }
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* Back button */
.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  padding: 6px 10px 6px 6px;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}
.btn-back:hover { color: var(--text); background: var(--border); }

/* ─── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; }

.badge--draft  { background: #F3F4F6; color: #6B7280; }
.badge--draft::before  { background: #9CA3AF; }
.badge--sent   { background: var(--warning-light); color: var(--warning); }
.badge--sent::before   { background: var(--warning); }
.badge--signed { background: var(--success-light); color: var(--success); }
.badge--signed::before { background: var(--success); }

/* ─── Dashboard ──────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 32px;
  flex-wrap: wrap;
}
.page-title {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
}
.page-subtitle { color: var(--text-muted); margin-top: 4px; font-size: 0.95rem; }

.stats-row { display: flex; gap: 12px; }
.stat-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: white;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 20px;
  min-width: 80px;
  box-shadow: var(--shadow-xs);
}
.stat-pill--sent   { border-color: #F0D898; background: var(--warning-light); }
.stat-pill--signed { border-color: #96C878; background: var(--success-light); }
.stat-num { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.04em; color: var(--text); }
.stat-pill--sent   .stat-num { color: var(--warning); }
.stat-pill--signed .stat-num { color: var(--success); }
.stat-lbl { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin-top: 1px; }

/* Filter bar */
.filter-bar {
  display: flex;
  gap: 4px;
  background: white;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  width: fit-content;
  margin-bottom: 28px;
  box-shadow: var(--shadow-xs);
}
.filter-btn {
  padding: 7px 18px;
  border-radius: 7px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: all 0.15s;
}
.filter-btn:hover { color: var(--text); background: var(--border); }
.filter-btn.active {
  background: var(--primary);
  color: white;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(200,86,42,0.3);
}
.archive-bar-link, .archive-bar-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  padding: 6px 0;
  transition: color 0.15s;
}
.archive-bar-link:hover { color: var(--text); }
.archive-bar-back { color: var(--primary); }
.archive-bar-back:hover { color: var(--primary-dark); }
#archive-bar { margin-top: 12px; }

/* Contracts grid */
.contracts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

/* Contract card */
.contract-card {
  background: white;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-xs);
  transition: all 0.2s var(--ease);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.contract-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--secondary, #E07840));
  opacity: 0;
  transition: opacity 0.2s;
}
.contract-card:hover {
  border-color: #E8B898;
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.contract-card:hover::before { opacity: 1; }

.contract-card--signed::before { background: var(--success); opacity: 1; }
.contract-card--sent::before   { background: var(--warning); opacity: 1; }
.contract-card--archived { opacity: 0.65; }
.contract-card--archived::before { background: #9AA8BE; opacity: 1; }

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  flex: 1;
}
.card-body { font-size: 0.85rem; color: var(--text-muted); line-height: 1.5; margin-bottom: 20px; }
.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.card-date { font-size: 0.78rem; color: var(--text-light); }
.card-actions { display: flex; gap: 6px; }

.card-btn {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  transition: all 0.15s;
  font-size: 0.78rem;
}
.card-btn:hover { background: var(--bg); color: var(--text); }
.card-btn--danger:hover { background: var(--danger-light); color: var(--danger); }
.card-btn--archive:hover { background: #EDF0F7; color: #5A6A8A; }

/* Empty state */
.empty-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 72px 24px;
  gap: 12px;
}
.empty-art { margin-bottom: 8px; }
.empty-state h3 { font-size: 1.15rem; font-weight: 700; color: var(--text); }
.empty-state p  { color: var(--text-muted); max-width: 340px; font-size: 0.9rem; margin-bottom: 8px; }

/* ─── Editor ─────────────────────────────────────────────────── */
.editor-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
  gap: 16px;
}
.editor-topbar-actions { display: flex; gap: 10px; }

.editor-layout {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 24px;
  align-items: start;
}

.contract-title-input {
  width: 100%;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  border: none;
  outline: none;
  background: transparent;
  padding: 0 0 16px 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
  transition: border-color 0.2s;
  letter-spacing: -0.02em;
}
.contract-title-input:focus { border-color: var(--primary); }
.contract-title-input::placeholder { color: var(--text-light); }

/* Toolbar */
.toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 10px;
  background: white;
  border: 1.5px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  margin-bottom: 0;
  box-shadow: var(--shadow-xs);
  flex-wrap: wrap;
}
.tool-btn {
  width: 32px; height: 32px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem;
  color: var(--text-secondary);
  transition: all 0.12s;
}
.tool-btn:hover { background: var(--bg); color: var(--text); }
.tool-btn.active { background: var(--primary-light); color: var(--primary); }
.tool-sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }
.tool-select {
  padding: 4px 8px;
  font-size: 0.8rem;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  color: var(--text-secondary);
  background: white;
  cursor: pointer;
  outline: none;
}
.tool-select:focus { border-color: var(--border-focus); }

/* Editor body */
.editor-body {
  min-height: 480px;
  padding: 28px 32px;
  background: white;
  border: 1.5px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  outline: none;
  font-size: 0.95rem;
  line-height: 1.75;
  color: var(--text);
  box-shadow: var(--shadow-xs);
}
.editor-body:focus { border-color: var(--border-focus); }
.editor-body h1 { font-size: 1.5rem; font-weight: 700; margin: 20px 0 10px; letter-spacing: -0.02em; }
.editor-body h2 { font-size: 1.2rem; font-weight: 600; margin: 18px 0 8px; }
.editor-body h3 { font-size: 1rem;  font-weight: 600; margin: 14px 0 6px; }
.editor-body p  { margin-bottom: 10px; }
.editor-body ul, .editor-body ol { margin: 8px 0 8px 24px; }
.editor-body li { margin-bottom: 4px; }
.editor-body p:first-child { color: var(--text-muted); }

/* Sidebar */
.editor-sidebar { display: flex; flex-direction: column; gap: 16px; }
.sidebar-block {
  background: white;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
  box-shadow: var(--shadow-xs);
}
.sidebar-heading {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 14px;
}
.sidebar-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.sidebar-heading-row .sidebar-heading { margin-bottom: 0; }
.btn-icon-subtle {
  display: flex; align-items: center; justify-content: center;
  width: 26px; height: 26px;
  border-radius: 6px;
  color: var(--text-muted);
  transition: all 0.15s;
  flex-shrink: 0;
}
.btn-icon-subtle:hover { background: var(--primary-light); color: var(--primary); }

/* ─── Template editor modal ──────────────────────────────────── */
.tpl-modal {
  width: 620px;
  max-width: 96vw;
  max-height: 88vh;
  text-align: left;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}
.tpl-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.tpl-modal-header h3 { font-size: 1rem; font-weight: 700; margin: 0; }
.tpl-tabs {
  display: flex;
  gap: 2px;
  padding: 12px 24px 0;
  flex-shrink: 0;
}
.tpl-tab {
  font-size: 0.82rem;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 7px 7px 0 0;
  color: var(--text-muted);
  border: 1.5px solid transparent;
  border-bottom: none;
  transition: all 0.15s;
}
.tpl-tab:hover { color: var(--primary); background: var(--primary-light); }
.tpl-tab.active {
  color: var(--primary);
  background: var(--surface);
  border-color: var(--border);
  border-bottom-color: var(--surface);
  position: relative;
  z-index: 1;
}
.tpl-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  background: var(--surface);
  border-top: 1.5px solid var(--border);
  margin-top: -1px;
}
.field-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.field-input {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  background: white;
  transition: border-color 0.15s;
  box-sizing: border-box;
}
.field-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
.tpl-content-editor {
  min-height: 280px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--text);
  background: white;
  transition: border-color 0.15s;
  overflow-y: auto;
}
.tpl-content-editor:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
.tpl-content-editor h2 { font-size: 1.15rem; font-weight: 700; margin: 0 0 10px; }
.tpl-content-editor h3 { font-size: 0.95rem; font-weight: 700; margin: 14px 0 6px; }
.tpl-content-editor p  { margin: 0 0 8px; }
.tpl-content-editor ul { margin: 0 0 8px; padding-left: 20px; }
.tpl-content-editor li { margin-bottom: 3px; }
.tpl-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: white;
}
.info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.info-row:last-child { margin-bottom: 0; }
.info-label { font-size: 0.82rem; color: var(--text-muted); font-weight: 500; }
.info-val   { font-size: 0.82rem; color: var(--text-secondary); font-weight: 500; }

.template-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  border: 1.5px solid transparent;
  margin-bottom: 6px;
  transition: all 0.15s;
  text-align: left;
}
.template-btn:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: #F0C4A8;
}
.template-btn:last-child { margin-bottom: 0; }

/* ─── Send page ───────────────────────────────────────────────── */
.send-card {
  background: white;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 40px;
  box-shadow: var(--shadow-md);
  margin-top: 28px;
}
.send-card-header {
  text-align: center;
  margin-bottom: 36px;
}
.send-icon-wrap {
  width: 64px; height: 64px;
  background: var(--primary-light);
  border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
}
.send-card-header h2 {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 6px;
}
.send-card-header p { color: var(--text-muted); font-size: 0.9rem; }

/* Forms */
.form-group { margin-bottom: 20px; }
.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 7px;
}
.optional { font-weight: 400; color: var(--text-light); }
.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  color: var(--text);
  background: white;
  transition: all 0.15s;
  outline: none;
}
.form-group input:focus,
.form-group textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-ring);
}
.form-group textarea { resize: vertical; line-height: 1.5; }
.field-error { font-size: 0.78rem; color: var(--danger); margin-top: 5px; display: block; }

/* Link result */
.link-result {
  background: var(--success-light);
  border: 1.5px solid #6EE7B7;
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-bottom: 20px;
}
.link-result-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--success);
  margin-bottom: 10px;
}
.link-label { color: var(--success); }
.link-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: white;
  border: 1.5px solid #A7F3D0;
  border-radius: var(--radius);
  padding: 8px 12px;
  margin-bottom: 10px;
}
.link-text {
  flex: 1;
  font-size: 0.8rem;
  color: var(--text-secondary);
  word-break: break-all;
  font-family: 'SF Mono', 'Fira Code', monospace;
}
.btn-copy {
  display: flex; align-items: center; gap: 5px;
  padding: 5px 12px;
  background: var(--primary);
  color: white;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  transition: all 0.15s;
  flex-shrink: 0;
}
.btn-copy:hover { background: var(--primary-dark); }
.btn-copy.copied { background: var(--success); }
.link-note { font-size: 0.78rem; color: #065F46; }

.form-actions { margin-top: 4px; }

/* ─── Sign page ───────────────────────────────────────────────── */
.state-view { animation: fadeUp 0.3s var(--ease) both; }

.sign-layout {
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 28px;
  align-items: start;
}

/* Contract view panel */
.contract-view-panel {
  background: white;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow);
  position: sticky;
  top: 88px;
}
.contract-view-header {
  padding: 24px 28px;
  border-bottom: 1.5px solid var(--border);
  background: var(--bg);
}
.contract-view-meta {
  display: flex; align-items: center; gap: 12px; margin-bottom: 10px;
}
.contract-view-to { font-size: 0.85rem; color: var(--text-muted); }
.contract-view-title {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
}
.contract-view-body {
  padding: 28px 32px;
  font-size: 0.92rem;
  line-height: 1.78;
  color: var(--text-secondary);
  max-height: calc(100vh - 320px);
  overflow-y: auto;
}
.contract-view-body h1, .contract-view-body h2, .contract-view-body h3 {
  color: var(--text);
  margin: 16px 0 8px;
  letter-spacing: -0.02em;
}
.contract-view-body h1 { font-size: 1.3rem; }
.contract-view-body h2 { font-size: 1.1rem; }
.contract-view-body h3 { font-size: 1rem; }
.contract-view-body p  { margin-bottom: 10px; }
.contract-view-body ul, .contract-view-body ol { margin: 8px 0 8px 22px; }

/* Sign card */
.sign-panel { position: sticky; top: 88px; }
.sign-card {
  background: white;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 28px;
  box-shadow: var(--shadow-md);
}
.sign-card h3 {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}
.sign-desc { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 20px; }

/* Sign tabs */
.sign-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 20px;
}
.sign-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px;
  border-radius: 7px;
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: all 0.15s;
}
.sign-tab:hover { color: var(--text); }
.sign-tab.active {
  background: white;
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.sign-tab-pane { display: none; }
.sign-tab-pane.active { display: block; animation: fadeUp 0.2s var(--ease) both; }

/* Canvas */
.canvas-wrap {
  position: relative;
  background: #FDFAF6;
  border: 2px dashed #F0C4A8;
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: crosshair;
  margin-bottom: 10px;
}
.canvas-wrap:hover { border-color: var(--primary); }
#sig-canvas {
  display: block;
  width: 100%;
  height: 180px;
  touch-action: none;
}
.canvas-placeholder {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.85rem;
  color: var(--text-light);
  pointer-events: none;
  transition: opacity 0.2s;
  white-space: nowrap;
}
.canvas-placeholder.hidden { opacity: 0; }

.canvas-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.btn-clear {
  display: flex; align-items: center; gap: 5px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  padding: 5px 10px;
  border-radius: 6px;
  border: 1.5px solid var(--border);
  background: white;
  transition: all 0.15s;
}
.btn-clear:hover { color: var(--danger); border-color: #FCA5A5; background: var(--danger-light); }
.pen-size-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-muted);
}
.pen-size-btn {
  width: 28px; height: 28px;
  border-radius: 6px;
  border: 1.5px solid var(--border);
  background: white;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-secondary);
  transition: all 0.15s;
}
.pen-size-btn:hover { border-color: var(--primary); color: var(--primary); }
.pen-size-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* Type name */
.name-input {
  font-size: 1.1rem !important;
  padding: 12px 16px !important;
  border-radius: var(--radius-md) !important;
}
.typed-preview-area {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-top: 12px;
}
.preview-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.typed-sig-display {
  font-size: 2.2rem;
  line-height: 1.2;
  color: #1e1b4b;
  padding: 8px 4px;
  min-height: 56px;
  font-family: 'Dancing Script', cursive;
  word-break: break-word;
}
.font-options {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}
.font-options-label { font-size: 0.78rem; color: var(--text-muted); font-weight: 500; }
.font-opt {
  padding: 5px 14px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  background: white;
  cursor: pointer;
  transition: all 0.15s;
  font-size: 0.85rem;
}
.font-opt:hover { border-color: var(--primary); }
.font-opt.active { border-color: var(--primary); background: var(--primary-light); }

/* Agreement */
.agreement-label {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
  padding: 16px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  margin: 20px 0;
  transition: border-color 0.15s;
}
.agreement-label:hover { border-color: #C7D2FE; }
.agree-checkbox { display: none; }
.agree-checkmark {
  width: 20px; height: 20px;
  min-width: 20px;
  border: 2px solid var(--border);
  border-radius: 5px;
  background: white;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
  margin-top: 1px;
}
.agree-checkbox:checked ~ .agree-checkmark {
  background: var(--primary);
  border-color: var(--primary);
}
.agree-checkbox:checked ~ .agree-checkmark::after {
  content: '';
  width: 10px; height: 6px;
  border-left: 2px solid white;
  border-bottom: 2px solid white;
  transform: rotate(-45deg) translateY(-1px);
  display: block;
}
.agree-text { font-size: 0.82rem; color: var(--text-secondary); line-height: 1.5; }

/* ─── Success card ───────────────────────────────────────────── */
.success-card {
  background: white;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 40px;
  text-align: center;
  box-shadow: var(--shadow-md);
  margin-top: 28px;
}
.success-card h2 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 16px 0 8px;
}
.success-card p { color: var(--text-muted); }

.success-card--big { padding: 60px 40px; }
.success-anim {
  position: relative;
  width: 80px; height: 80px;
  margin: 0 auto 24px;
}
.success-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--success);
  animation: scaleIn 0.4s var(--ease-spring) both;
}
.success-check {
  position: absolute;
  inset: 16px;
  animation: fadeUp 0.3s 0.2s var(--ease) both;
}
@keyframes scaleIn {
  from { transform: scale(0); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.success-checkmark { margin: 0 auto 16px; display: block; width: fit-content; }
.signed-meta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--success-light);
  color: var(--success);
  font-size: 0.85rem;
  padding: 8px 16px;
  border-radius: 100px;
  margin-top: 16px;
  font-weight: 500;
}
.signed-sig-preview { margin-top: 24px; }
.sig-preview-img {
  max-width: 280px;
  max-height: 100px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
  background: white;
  display: block;
  margin: 8px auto 0;
}

/* ─── Toast ──────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 28px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1F2937;
  color: white;
  padding: 12px 22px;
  border-radius: 100px;
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s var(--ease);
  white-space: nowrap;
  z-index: 1000;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast--success { background: var(--success); }
.toast--danger  { background: var(--danger); }

/* ─── Modal ──────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  animation: fadeIn 0.15s ease both;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: white;
  border-radius: var(--radius-xl);
  padding: 32px;
  width: min(420px, calc(100vw - 48px));
  box-shadow: var(--shadow-xl);
  animation: scaleIn 0.2s var(--ease-spring) both;
  text-align: center;
}
.modal-icon {
  width: 52px; height: 52px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
}
.modal-icon--danger { background: var(--danger-light); color: var(--danger); }
.modal h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 8px; }
.modal p  { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 24px; }
.modal-actions { display: flex; gap: 10px; justify-content: center; }

/* ─── Signature block ────────────────────────────────────────── */
.signature-block {
  background: white;
  border: 1.5px solid #F0C4A8;
  border-top: none;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}
.sig-block-divider {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 32px;
  background: var(--primary-light);
  border-top: 2px dashed #F0C4A8;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary);
}
.sig-block-body {
  padding: 24px 32px 28px;
  display: flex;
  align-items: flex-start;
  gap: 40px;
  flex-wrap: wrap;
}
.sig-block-body--dual {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  padding: 0;
}
.sig-side {
  padding: 24px 28px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.sig-side:first-child {
  border-right: 1px solid var(--border);
}
.sig-side-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}
.sender-sig-img {
  display: block;
  max-height: 72px;
  max-width: 210px;
  object-fit: contain;
  padding: 4px 0;
}
.sig-block-meta {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 200px;
}
.sig-meta-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sig-meta-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
}
.sig-meta-value {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}
.sig-block-image-wrap {
  flex: 1;
  min-width: 200px;
  background: #FDFAF6;
  border: 1.5px solid #F0DDD0;
  border-radius: var(--radius);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sig-block-image {
  max-height: 90px;
  max-width: 100%;
  display: block;
}

/* ─── Password gate ──────────────────────────────────────────── */
#pw-gate {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
.pw-backdrop {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #FDF0EA 0%, #FBF6F0 55%, #F5E4D8 100%);
}
.pw-card {
  position: relative;
  background: white;
  border-radius: var(--radius-xl);
  padding: 44px 40px 40px;
  width: min(440px, calc(100vw - 40px));
  box-shadow: var(--shadow-lg);
  border: 1.5px solid var(--border);
  animation: scaleIn 0.3s var(--ease-spring) both;
  text-align: center;
}
.pw-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 28px;
}
.pw-title {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 6px;
}
.pw-desc {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}
.pw-field-wrap { margin-bottom: 20px; text-align: left; }
.pw-input {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  transition: all 0.15s;
  outline: none;
  letter-spacing: 0.04em;
  display: block;
}
.pw-input:focus { border-color: var(--primary); background: white; box-shadow: 0 0 0 3px var(--primary-ring); }
.pw-error {
  font-size: 0.8rem;
  color: var(--danger);
  margin-top: 7px;
  min-height: 18px;
  font-weight: 500;
}
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%,60%  { transform: translateX(-6px); }
  40%,80%  { transform: translateX(6px); }
}
.pw-input--shake { animation: shake 0.4s ease both; }

/* ─── Signed view panel ──────────────────────────────────────── */
.sign-card--signed { border-color: rgba(5,150,105,0.25) !important; }
.signed-banner {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  padding: 8px 0 4px;
}
.signed-banner h3 {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--success);
  letter-spacing: -0.02em;
}
.signed-banner p { font-size: 0.88rem; color: var(--text-muted); }
.signed-banner strong { color: var(--text); }
.sign-layout--signed .contract-view-panel { position: static; }

/* ─── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #D1D5DB; border-radius: 100px; }
::-webkit-scrollbar-thumb:hover { background: #9CA3AF; }

/* ─── Responsive ─────────────────────────────────────────────── */
@media (max-width: 900px) {
  .editor-layout { grid-template-columns: 1fr; }
  .editor-sidebar { order: -1; display: grid; grid-template-columns: 1fr 1fr; }
  .sign-layout    { grid-template-columns: 1fr; }
  .contract-view-panel { position: static; }
  .sign-panel { position: static; }
}
@media (max-width: 640px) {
  .container { padding: 24px 16px; }
  .page-header { flex-direction: column; }
  .stats-row  { width: 100%; }
  .stat-pill  { flex: 1; }
  .send-card  { padding: 24px; }
  .editor-topbar { flex-direction: column; align-items: flex-start; }
  .editor-topbar-actions { width: 100%; }
  .editor-sidebar { grid-template-columns: 1fr; }
  .contract-view-body { max-height: 320px; }
}
