/* Contracts Page */
.contracts-page {
  max-width: 900px;
  margin: 0 auto;
  padding: 4rem 2rem;
}

.contracts-header { margin-bottom: 2.5rem; }
.contracts-label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #a8956b;
  margin-bottom: 0.5rem;
}
.contracts-headline {
  font-family: 'Playfair Display', serif;
  font-size: 2.25rem;
  font-weight: 700;
  color: #1a1a1a;
  margin-bottom: 0.75rem;
}
.contracts-sub {
  color: #666;
  font-size: 1rem;
  line-height: 1.6;
  max-width: 600px;
}
.contracts-actions {
  display: flex;
  gap: 1rem;
  margin-top: 1.5rem;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  padding: 0.75rem 1.5rem;
  background: #1a1a1a;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 4px;
  text-decoration: none;
  transition: background 0.2s;
}
.btn-primary:hover { background: #333; }
.btn-secondary {
  display: inline-flex;
  align-items: center;
  padding: 0.75rem 1.5rem;
  border: 1.5px solid #1a1a1a;
  color: #1a1a1a;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 4px;
  text-decoration: none;
  transition: background 0.2s;
}
.btn-secondary:hover { background: #f5f4f1; }

.contracts-filters {
  display: flex;
  gap: 1rem;
  margin-bottom: 2rem;
  align-items: flex-end;
}
.filter-group label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #999;
  margin-bottom: 0.4rem;
}
.filter-group select, .filter-group input {
  padding: 0.6rem 0.8rem;
  border: 1.5px solid #e0ddd6;
  border-radius: 4px;
  font-size: 0.9rem;
  font-family: 'DM Sans', sans-serif;
  color: #1a1a1a;
  background: #fff;
  min-width: 140px;
}
.btn-search {
  padding: 0.6rem 1.2rem;
  background: #a8956b;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  transition: background 0.2s;
}
.btn-search:hover { background: #8a7854; }

.contracts-list { display: flex; flex-direction: column; gap: 1rem; }

.contract-card {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 1.5rem;
  align-items: center;
  padding: 1.5rem;
  background: #fff;
  border: 1.5px solid #e8e4dc;
  border-radius: 6px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.contract-card:hover {
  border-color: #c8c0b0;
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
}
.contract-card-info h3 {
  font-family: 'Playfair Display', serif;
  font-size: 1.1rem;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 0.25rem;
}
.contract-number {
  font-size: 0.75rem;
  color: #999;
  font-weight: 500;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}
.contract-meta {
  font-size: 0.85rem;
  color: #666;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}
.contract-meta span { display: flex; align-items: center; gap: 0.3rem; }

.status-badge {
  display: inline-block;
  padding: 0.3rem 0.75rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.status-draft { background: #f0ede6; color: #8a7854; }
.status-pending_signature { background: #fef3c7; color: #92400e; }
.status-signed { background: #d1fae5; color: #065f46; }
.status-archived { background: #f3f4f6; color: #6b7280; }
.status-active { background: #d1fae5; color: #065f46; }

.card-actions { display: flex; gap: 0.5rem; }
.card-actions a, .card-actions button {
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
  font-weight: 500;
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  transition: all 0.2s;
  font-family: 'DM Sans', sans-serif;
}
.card-actions a.view-btn {
  background: #f5f4f1;
  color: #1a1a1a;
  border: 1px solid #e0ddd6;
}
.card-actions a.view-btn:hover { background: #eae7e0; }
.card-actions button.delete-btn {
  background: transparent;
  color: #999;
  border: 1px solid transparent;
}
.card-actions button.delete-btn:hover { color: #c00; border-color: #fcc; }

.contracts-empty {
  text-align: center;
  padding: 4rem 2rem;
  color: #999;
}
.empty-icon { margin-bottom: 1rem; color: #ccc; }
.contracts-empty a { color: #a8956b; text-decoration: none; }
.contracts-empty a:hover { text-decoration: underline; }

.contracts-pagination { margin-top: 2rem; text-align: center; }

/* Form Page */
.contract-form-page {
  max-width: 800px;
  margin: 0 auto;
  padding: 3rem 2rem;
}
.form-header { margin-bottom: 2.5rem; }
.back-link {
  font-size: 0.85rem;
  color: #a8956b;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-bottom: 1.5rem;
}
.back-link:hover { text-decoration: underline; }
.form-title {
  font-family: 'Playfair Display', serif;
  font-size: 2rem;
  font-weight: 700;
  color: #1a1a1a;
  margin-bottom: 0.5rem;
}
.form-sub { color: #777; font-size: 0.95rem; }
.form-status { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem; }
.contract-num-label { font-size: 0.8rem; color: #999; font-weight: 500; }

.contract-form { display: flex; flex-direction: column; gap: 2.5rem; }
.form-section { padding-bottom: 2rem; border-bottom: 1px solid #eae7e0; }
.section-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.25rem;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 1.25rem;
}
.subsection-title {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #a8956b;
  margin-bottom: 1rem;
  margin-top: 1.5rem;
}
.section-desc { color: #777; font-size: 0.9rem; margin-bottom: 1rem; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.form-grid .form-field.full-width { grid-column: 1 / -1; }
.form-field { display: flex; flex-direction: column; gap: 0.4rem; }
.form-field label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #888;
}
.form-field .required { color: #a8956b; }
.form-field input, .form-field select, .form-field textarea {
  padding: 0.75rem 1rem;
  border: 1.5px solid #e0ddd6;
  border-radius: 4px;
  font-size: 0.95rem;
  font-family: 'DM Sans', sans-serif;
  color: #1a1a1a;
  background: #fff;
  transition: border-color 0.2s;
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus {
  outline: none;
  border-color: #a8956b;
}
.form-field textarea { resize: vertical; }
.calculated-field { background: #f9f8f5 !important; color: #888 !important; }

.payment-grid { grid-template-columns: 1fr 1fr 1fr; }
.payment-card {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 1.25rem;
  background: #f9f8f5;
  border-radius: 6px;
  border: 1.5px solid #e8e4dc;
}
.payment-card label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #888;
}
.payment-input-wrap { display: flex; align-items: center; gap: 0.3rem; }
.currency { font-size: 1.1rem; color: #999; font-weight: 500; }
.payment-input-wrap input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border: 1.5px solid #e0ddd6;
  border-radius: 4px;
  font-size: 1rem;
  font-family: 'DM Sans', sans-serif;
  color: #1a1a1a;
  width: 100%;
}
.payment-percent {
  font-size: 0.7rem;
  color: #a8956b;
  font-weight: 600;
  align-self: flex-end;
  text-align: right;
}

.form-actions {
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
  padding-top: 1rem;
}
.btn-cancel {
  padding: 0.8rem 1.5rem;
  border: 1.5px solid #e0ddd6;
  border-radius: 4px;
  font-size: 0.9rem;
  font-weight: 500;
  color: #666;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  font-family: 'DM Sans', sans-serif;
  transition: all 0.2s;
}
.btn-cancel:hover { background: #f5f4f1; }
.btn-submit {
  padding: 0.8rem 2rem;
  background: #1a1a1a;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  transition: background 0.2s;
}
.btn-submit:hover { background: #333; }

/* Document Viewer */
.document-body { background: #f5f4f1; }
.document-toolbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid #e8e4dc;
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.toolbar-actions { display: flex; gap: 0.75rem; }
.btn-edit {
  padding: 0.5rem 1rem;
  background: #f5f4f1;
  color: #1a1a1a;
  border: 1px solid #e0ddd6;
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  transition: all 0.2s;
}
.btn-edit:hover { background: #eae7e0; }
.btn-print {
  padding: 0.5rem 1rem;
  background: #a8956b;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  transition: background 0.2s;
}
.btn-print:hover { background: #8a7854; }

.contract-document {
  max-width: 800px;
  margin: 2.5rem auto;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.10);
  padding: 3.5rem 4rem;
}

.doc-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 2px solid #1a1a1a;
}
.doc-brand { display: flex; align-items: center; gap: 0.75rem; }
.brand-logo {
  width: 40px;
  height: 40px;
  background: #1a1a1a;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Playfair Display', serif;
  font-size: 1.25rem;
  font-weight: 700;
  border-radius: 4px;
}
.brand-name { font-family: 'Playfair Display', serif; font-size: 1.1rem; font-weight: 600; color: #1a1a1a; }
.doc-meta { text-align: right; }
.doc-number { font-size: 0.85rem; color: #999; font-weight: 500; letter-spacing: 0.08em; margin-bottom: 0.3rem; }

.doc-title {
  font-family: 'Playfair Display', serif;
  font-size: 2.5rem;
  font-weight: 700;
  color: #1a1a1a;
  margin-bottom: 2.5rem;
  text-align: center;
}

.doc-section { margin-bottom: 2.5rem; }
.doc-section-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.25rem;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1.5px solid #e8e4dc;
}
.doc-section-body { color: #3a3a3a; font-size: 0.95rem; line-height: 1.7; }

.parties-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
}
.party-block { padding: 1.5rem; background: #f9f8f5; border-radius: 6px; border: 1px solid #e8e4dc; }
.party-role {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: #a8956b;
  margin-bottom: 0.75rem;
}
.party-name { font-family: 'Playfair Display', serif; font-size: 1.1rem; font-weight: 600; color: #1a1a1a; margin-bottom: 0.5rem; }
.party-detail { font-size: 0.85rem; color: #666; margin-top: 0.25rem; }

.doc-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.doc-table td { padding: 0.6rem 0; border-bottom: 1px solid #e8e4dc; vertical-align: top; }
.doc-table td.label { color: #888; font-weight: 600; width: 35%; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; }
.doc-table td.num { text-align: right; }
.doc-table thead th { padding: 0.6rem 0; border-bottom: 2px solid #1a1a1a; text-align: left; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: #888; font-weight: 600; }
.doc-table thead th.num { text-align: right; }

.scope-list { list-style: none; padding: 0; margin: 0; }
.scope-list li {
  padding: 0.5rem 0;
  padding-left: 1.5rem;
  position: relative;
  border-bottom: 1px solid #f0ede6;
}
.scope-list li::before { content: '—'; position: absolute; left: 0; color: #a8956b; }

.payment-table .total-row { background: #f9f8f5; border-radius: 4px; }
.payment-table .total-row td { padding: 0.75rem 0; border-bottom: none; }

.labor-summary { margin-top: 1rem; padding: 0.75rem 1rem; background: #f9f8f5; border-radius: 4px; display: inline-block; }
.placeholder-text { color: #aaa; font-style: italic; font-size: 0.9rem; }

.signatures-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
}
.signature-block { padding-top: 1rem; }
.sig-line {
  border-bottom: 1.5px solid #1a1a1a;
  margin-bottom: 0.4rem;
  height: 40px;
}
.sig-label { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: #888; margin-bottom: 0.3rem; }
.sig-date { font-size: 0.85rem; color: #666; min-height: 1.5rem; margin-bottom: 0.5rem; }
.sig-name-print { font-family: 'Playfair Display', serif; font-size: 0.95rem; font-weight: 600; color: #1a1a1a; }
.sig-date-print { font-size: 0.8rem; color: #999; margin-top: 0.25rem; }

.btn-sign {
  padding: 0.5rem 1rem;
  background: #a8956b;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  transition: background 0.2s;
}
.btn-sign:hover { background: #8a7854; }

.doc-footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid #e8e4dc;
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: #bbb;
}
.footer-brand { font-family: 'Playfair Display', serif; font-style: italic; }

/* Signature Modal */
.signature-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}
.modal-content {
  background: #fff;
  border-radius: 8px;
  padding: 2rem;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.modal-content h3 {
  font-family: 'Playfair Display', serif;
  font-size: 1.25rem;
  margin-bottom: 0.75rem;
}
.modal-content p { color: #666; font-size: 0.9rem; margin-bottom: 1.5rem; }
.modal-actions { display: flex; gap: 0.75rem; justify-content: flex-end; margin-top: 1.5rem; }

@media (max-width: 640px) {
  .contracts-page, .contract-form-page { padding: 2rem 1rem; }
  .contract-document { padding: 2rem 1.5rem; }
  .contracts-filters { flex-wrap: wrap; }
  .form-grid { grid-template-columns: 1fr; }
  .payment-grid { grid-template-columns: 1fr; }
  .parties-grid, .signatures-grid { grid-template-columns: 1fr; }
  .contract-card { grid-template-columns: 1fr; }
  @media print {
    .document-toolbar { display: none; }
    .contract-document { box-shadow: none; margin: 0; }
  }
}