/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #f5f7fa; color: #111827; line-height: 1.5; min-height: 100vh; }
a { color: #1a56db; text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
input, select, textarea, button { font: inherit; }

/* ── Variables ── */
:root {
  --blue:    #1a56db;
  --blue-dk: #1549c6;
  --green:   #057a55;
  --green-bg:#d1fae5;
  --yellow:  #92400e;
  --yellow-bg:#fef3c7;
  --red:     #9b1c1c;
  --red-bg:  #fee2e2;
  --gray:    #6b7280;
  --border:  #e5e7eb;
  --radius:  8px;
  --shadow:  0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
}

/* ── Navbar ── */
.navbar { background: #fff; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 100; }
.navbar-inner { max-width: 1200px; margin: 0 auto; padding: 0 20px; height: 56px; display: flex; align-items: center; gap: 24px; }
.navbar-brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1rem; color: #111827; text-decoration: none; }
.navbar-brand svg { color: var(--blue); }
.navbar-links { display: flex; align-items: center; gap: 4px; flex: 1; }
.nav-link { padding: 6px 12px; border-radius: 6px; color: var(--gray); font-size: .9rem; font-weight: 500; transition: background .15s, color .15s; text-decoration: none; }
.nav-link:hover { background: #f3f4f6; color: #111827; }
.nav-link.active { background: #eff6ff; color: var(--blue); }
.navbar-user { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.user-name { font-size: .875rem; color: var(--gray); }

/* ── Container ── */
.container { max-width: 1200px; margin: 0 auto; padding: 28px 20px; }
.container--sm { max-width: 700px; }

/* ── Page header ── */
.page-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; gap: 16px; flex-wrap: wrap; }
.page-title { font-size: 1.5rem; font-weight: 700; color: #111827; }
.page-sub { color: var(--gray); font-size: .9rem; margin-top: 2px; }
.back-link { display: inline-block; color: var(--gray); font-size: .875rem; margin-bottom: 4px; text-decoration: none; }
.back-link:hover { color: #111827; text-decoration: none; }

/* ── Cards ── */
.card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 20px; overflow: hidden; }
.card-header { padding: 14px 20px; border-bottom: 1px solid var(--border); background: #fafafa; }
.card-title { font-size: 1rem; font-weight: 600; color: #111827; }
.card-body { padding: 20px; }
.card-footer { padding: 14px 20px; border-top: 1px solid var(--border); background: #fafafa; }

/* ── Stats grid ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; text-align: center; box-shadow: var(--shadow); }
.stat-value { font-size: 2rem; font-weight: 700; color: var(--blue); }
.stat-label { font-size: .8rem; color: var(--gray); text-transform: uppercase; letter-spacing: .05em; margin-top: 4px; }
.stat-card--success .stat-value { color: var(--green); }
.stat-card--info    .stat-value { color: #0369a1; }
.stat-card--warning .stat-value { color: #d97706; }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 6px; font-size: .875rem; font-weight: 500; cursor: pointer; border: 1.5px solid transparent; transition: all .15s; text-decoration: none; white-space: nowrap; line-height: 1.25; }
.btn-primary { background: var(--blue); color: #fff; border-color: var(--blue); }
.btn-primary:hover { background: var(--blue-dk); border-color: var(--blue-dk); text-decoration: none; color: #fff; }
.btn-outline { background: #fff; color: #374151; border-color: var(--border); }
.btn-outline:hover { background: #f9fafb; border-color: #d1d5db; text-decoration: none; color: #111827; }
.btn-danger-outline { background: #fff; color: #b91c1c; border-color: #fca5a5; }
.btn-danger-outline:hover { background: var(--red-bg); text-decoration: none; }
.btn-sm { padding: 5px 10px; font-size: .8rem; }
.btn-lg { padding: 12px 28px; font-size: 1rem; }
.btn-block { width: 100%; justify-content: center; }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: .875rem; font-weight: 500; color: #374151; margin-bottom: 5px; }
.form-group input,
.form-group select,
.form-group textarea { width: 100%; padding: 9px 12px; border: 1.5px solid #d1d5db; border-radius: 6px; font-size: .9rem; background: #fff; transition: border-color .15s, box-shadow .15s; }
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(26,86,219,.1); outline: none; }
.form-group textarea { resize: vertical; min-height: 80px; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.required { color: #ef4444; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 20px 0; }

/* ── Table ── */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { padding: 10px 16px; text-align: left; font-weight: 600; font-size: .8rem; color: var(--gray); text-transform: uppercase; letter-spacing: .05em; background: #f9fafb; border-bottom: 1px solid var(--border); }
.table td { padding: 12px 16px; border-bottom: 1px solid #f3f4f6; vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #fafafa; }

/* ── Badges ── */
.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.badge-success { background: var(--green-bg); color: var(--green); }
.badge-info    { background: #dbeafe; color: #1e40af; }
.badge-warning { background: var(--yellow-bg); color: var(--yellow); }
.badge-error   { background: var(--red-bg); color: var(--red); }

/* ── Alerts ── */
.alert { padding: 12px 16px; border-radius: 6px; margin-bottom: 16px; font-size: .9rem; }
.alert-success { background: var(--green-bg); color: var(--green); border: 1px solid #a7f3d0; }
.alert-error   { background: var(--red-bg); color: var(--red); border: 1px solid #fca5a5; }
.alert-info    { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

/* ── Auth page ── */
.auth-page { background: linear-gradient(135deg, #eff6ff 0%, #f5f7fa 60%); display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.auth-container { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 40px 36px; width: 100%; max-width: 400px; box-shadow: 0 4px 24px rgba(0,0,0,.08); text-align: center; }
.auth-logo { margin-bottom: 12px; }
.auth-title { font-size: 1.5rem; font-weight: 800; color: #111827; margin-bottom: 4px; }
.auth-subtitle { color: var(--gray); font-size: .875rem; margin-bottom: 28px; }
.auth-form { text-align: left; }

/* ── Status bar ── */
.status-bar .status-bar-content { padding: 16px 20px; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.status-info { display: flex; align-items: center; gap: 8px; font-size: .9rem; font-weight: 500; }
.status-info--success { color: var(--green); }
.status-info--info    { color: #1e40af; }
.status-info--warning { color: var(--yellow); }
.link-copy-wrap { display: flex; gap: 6px; flex: 1; max-width: 480px; }
.link-input { flex: 1; padding: 6px 10px; border: 1.5px solid var(--border); border-radius: 6px; font-size: .8rem; color: var(--gray); background: #f9fafb; }

/* ── Contract layout ── */
.contract-layout { display: grid; grid-template-columns: 1fr 280px; gap: 20px; align-items: start; }
.contract-sidebar {}

/* ── Detail grid ── */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; }
.detail-item { display: flex; flex-direction: column; gap: 2px; }
.detail-item--full { grid-column: 1 / -1; }
.detail-label { font-size: .75rem; font-weight: 500; color: var(--gray); text-transform: uppercase; letter-spacing: .04em; }
.parties-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.party-block { padding: 12px; background: #f9fafb; border-radius: 6px; }
.party-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--blue); font-weight: 600; margin-bottom: 4px; }
.party-name { font-weight: 600; font-size: .95rem; margin-bottom: 2px; }

/* ── Signature ── */
.sig-slot { padding: 12px; background: #f9fafb; border-radius: 6px; }
.sig-label { font-size: .75rem; font-weight: 600; color: var(--gray); margin-bottom: 6px; }
.sig-preview { max-width: 100%; max-height: 80px; border: 1px solid var(--border); border-radius: 4px; background: #fff; display: block; }
.sig-empty { padding: 16px; text-align: center; color: #d1d5db; font-size: .875rem; border: 2px dashed var(--border); border-radius: 6px; }
.sig-pad-wrap { border: 2px solid var(--border); border-radius: 8px; background: #fff; cursor: crosshair; position: relative; }
.sig-canvas { width: 100%; height: 160px; display: block; touch-action: none; border-radius: 8px; }

/* ── Modal ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 20px; }
.modal { background: #fff; border-radius: 10px; width: 100%; max-width: 520px; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 1.05rem; font-weight: 600; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--gray); font-size: 1.4rem; line-height: 1; padding: 4px; }
.modal-body { padding: 20px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); }

/* ── Signer page ── */
.signer-page { background: #f5f7fa; min-height: 100vh; }
.signer-header { background: #fff; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 100; }
.signer-header-inner { max-width: 1100px; margin: 0 auto; padding: 0 20px; height: 52px; display: flex; align-items: center; justify-content: space-between; }
.signer-main { max-width: 1100px; margin: 0 auto; padding: 24px 20px; }
.signer-main--two-col { display: grid; grid-template-columns: 300px 1fr; gap: 24px; align-items: start; }
.signer-summary { position: sticky; top: 68px; }

/* ── Contract text ── */
.contract-section { margin-bottom: 20px; padding-bottom: 20px; border-bottom: 1px solid #f3f4f6; }
.contract-section:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.contract-section h4 { font-size: .9rem; font-weight: 700; color: var(--blue); margin-bottom: 8px; text-transform: uppercase; letter-spacing: .04em; }

/* ── Summary price ── */
.summary-price { border-top: 1px solid var(--border); margin-top: 16px; padding-top: 16px; }
.price-line { display: flex; justify-content: space-between; font-size: .875rem; color: var(--gray); padding: 3px 0; }
.price-caution { border-top: 1px dashed var(--border); margin-top: 6px; padding-top: 6px; }
.price-total { display: flex; justify-content: space-between; font-size: 1rem; font-weight: 700; color: #111827; border-top: 2px solid #111827; margin-top: 8px; padding-top: 8px; }

/* ── Success card ── */
.success-card { background: #fff; border: 1px solid var(--border); border-radius: 12px; max-width: 560px; margin: 40px auto; padding: 48px 40px; text-align: center; box-shadow: var(--shadow); }
.success-icon { font-size: 3rem; margin-bottom: 16px; }
.success-card h1 { font-size: 1.6rem; font-weight: 700; margin-bottom: 12px; }
.success-details { background: #f9fafb; border-radius: 8px; padding: 16px; margin: 24px 0; text-align: left; }
.success-details .detail-item { display: flex; justify-content: space-between; padding: 5px 0; font-size: .9rem; border-bottom: 1px solid var(--border); }
.success-details .detail-item:last-child { border-bottom: none; }

/* ── Contract form ── */
.contract-form .card { margin-bottom: 20px; }

/* ── Empty state ── */
.empty-state { padding: 60px 20px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; color: var(--gray); }

/* ── Actions ── */
.actions { display: flex; gap: 6px; align-items: center; }

/* ── Utilities ── */
.text-sm   { font-size: .875rem; }
.text-muted { color: var(--gray); }
.text-primary { color: var(--blue); }
.fw-medium { font-weight: 500; }
.fw-bold   { font-weight: 700; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
  .contract-layout { grid-template-columns: 1fr; }
  .contract-sidebar { order: -1; }
  .signer-main--two-col { grid-template-columns: 1fr; }
  .signer-summary { position: static; }
  .parties-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .status-bar .status-bar-content { flex-direction: column; align-items: flex-start; }
  .page-header { flex-direction: column; }
  .navbar-user .user-name { display: none; }
}
