:root {
  color-scheme: light;
  --ink: #202223;
  --ink-soft: #41474a;
  --muted: #737a7d;
  --paper: #f4f6f5;
  --white: #fff;
  --line: #e2e8e5;
  --green: #008060;
  --green-dark: #004c3f;
  --green-soft: #e5f3ee;
  --amber: #8a5a00;
  --amber-soft: #fff5df;
  --red: #a83232;
  --red-soft: #fff0ef;
  --radius: 16px;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font-size: 14px; line-height: 1.5; }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid #65b69b; outline-offset: 2px; }
.muted, .fine-print, .quiet-label { color: var(--muted); }
.eyebrow { display: block; color: var(--green); font-size: 10px; font-weight: 800; letter-spacing: .15em; line-height: 1.4; }
.brand { display: inline-flex; align-items: center; gap: 11px; }
.brand > span:last-child { display: grid; line-height: 1; }
.brand b { font-size: 15px; letter-spacing: .18em; }
.brand small { margin-top: 5px; font-size: 9px; font-weight: 700; letter-spacing: .2em; }
.brand-mark { display: block; width: 40px; height: 40px; border-radius: 12px; }
.brand-dark { color: var(--ink); }
.brand-light { color: #fff; }
.brand-light .brand-mark { color: #69c9a8; border-color: #426d60; }

.button { display: inline-flex; min-height: 42px; align-items: center; justify-content: center; gap: 8px; padding: 0 16px; border: 1px solid transparent; border-radius: 10px; font-size: 12.5px; font-weight: 700; transition: background .16s, border-color .16s, transform .16s; }
.button:hover { transform: translateY(-1px); }
.button-primary { background: var(--green); color: white; }
.button-primary:hover { background: var(--green-dark); }
.button-secondary { border-color: var(--line); background: white; color: var(--ink); }
.button-soft { min-height: 34px; padding: 0 11px; border-color: #cde5db; background: var(--green-soft); color: var(--green-dark); }
.button-small { min-height: 32px; font-size: 11px; }
.button-wide { width: 100%; }
.text-button { padding: 4px 0; border: 0; background: transparent; color: var(--green-dark); font-size: 11.5px; font-weight: 700; }
.icon-button { display: inline-grid; width: 33px; height: 33px; place-items: center; border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--muted); font-size: 20px; line-height: 1; }
.icon-button:hover { border-color: #c2d7cf; color: var(--ink); }
.danger-icon:hover { border-color: #efc0bd; background: var(--red-soft); color: var(--red); }

.auth-page { display: grid; min-height: 100vh; place-items: center; padding: 30px 16px; background: radial-gradient(ellipse at 75% 4%, #dceee7 0, transparent 38%), var(--paper); }
.auth-card { width: min(100%, 440px); padding: 34px; border: 1px solid var(--line); border-radius: 20px; background: white; box-shadow: 0 24px 70px #1f39321a; }
.auth-card .brand { margin-bottom: 38px; }
.auth-card h1 { margin: 9px 0 7px; font-size: clamp(26px, 5vw, 36px); letter-spacing: -.04em; line-height: 1.12; }
.auth-card > .muted { margin: 0 0 23px; }
.form-stack { display: grid; gap: 14px; margin-top: 22px; }
.form-stack label, .auth-card label, .share-dialog label { display: grid; gap: 6px; color: var(--ink-soft); font-size: 11.5px; font-weight: 700; }
.form-stack input, .auth-card input, .share-dialog input { width: 100%; min-height: 43px; padding: 9px 11px; border: 1px solid #d9e0dc; border-radius: 9px; background: #fff; color: var(--ink); }
.form-stack input:focus, .auth-card input:focus, .share-dialog input:focus { border-color: var(--green); outline: 3px solid #00806019; }
.form-stack hr { width: 100%; margin: 3px 0; border: 0; border-top: 1px solid var(--line); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fine-print { margin: 16px 0 0; font-size: 10.5px; line-height: 1.55; }
.notice { margin: 14px 0; padding: 11px 13px; border: 1px solid transparent; border-radius: 10px; font-size: 12px; line-height: 1.5; }
.notice-error { border-color: #f0c9c6; background: var(--red-soft); color: #862525; }
.notice-success { border-color: #b7dece; background: var(--green-soft); color: var(--green-dark); }
.notice-warning { border-color: #efddae; background: var(--amber-soft); color: #6f4a00; }

.app-header { display: flex; min-height: 72px; align-items: center; justify-content: space-between; gap: 20px; padding: 0 max(24px, calc((100vw - 1200px)/2)); background: #202826; color: white; }
.header-user { display: flex; align-items: center; gap: 22px; color: #cbd4d0; font-size: 11.5px; }
.header-user form { display: inline; }
.header-user .text-button { color: #b6d5ca; }
.dashboard-shell { width: min(100% - 40px, 1160px); margin: 0 auto; padding: 48px 0 30px; }
.welcome-row { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 30px; }
.welcome-row h1 { margin: 8px 0 6px; font-size: clamp(26px, 4vw, 36px); letter-spacing: -.045em; line-height: 1.15; }
.welcome-row p { margin: 0; color: var(--muted); font-size: 13px; }
.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 22px; }
.metric-card { display: grid; gap: 3px; padding: 19px 20px; border: 1px solid var(--line); border-radius: 14px; background: white; }
.metric-card span { color: var(--muted); font-size: 11px; font-weight: 650; }
.metric-card strong { font-size: 28px; letter-spacing: -.04em; }
.metric-card small { color: var(--muted); font-size: 10.5px; }
.contracts-panel { overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: white; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 21px 22px; }
.section-heading h2 { margin: 3px 0 0; font-size: 18px; letter-spacing: -.02em; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th { padding: 11px 16px; background: #f8faf9; color: #76817c; font-size: 9px; font-weight: 800; letter-spacing: .11em; }
td { padding: 14px 16px; border-top: 1px solid #edf0ee; color: var(--ink-soft); font-size: 11.5px; vertical-align: middle; }
td strong, td small { display: block; }
td strong { color: var(--ink); font-size: 12px; }
td small { margin-top: 3px; color: var(--muted); font-size: 10.5px; }
.actions-heading { text-align: right; }
.row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 7px; white-space: nowrap; }
.status { display: inline-flex; min-height: 23px; align-items: center; padding: 2px 9px; border-radius: 99px; font-size: 9.5px; font-weight: 750; white-space: nowrap; }
.status-pending { background: #fff2d6; color: #815700; }
.status-completed { background: var(--green-soft); color: var(--green-dark); }
.status-expired { background: #eef0ef; color: #5b6460; }
.status-cancelled { background: var(--red-soft); color: #922b27; }
.hash-chip { color: var(--muted); font: 9px/1.3 "Consolas", monospace; }
.empty-state { display: grid; justify-items: center; padding: 56px 20px 62px; text-align: center; }
.empty-icon { display: grid; width: 45px; height: 45px; place-items: center; margin-bottom: 12px; border-radius: 15px; background: var(--green-soft); color: var(--green); font-size: 23px; }
.empty-state h3 { margin: 0 0 6px; font-size: 17px; }
.empty-state p { max-width: 430px; margin: 0 0 18px; color: var(--muted); font-size: 12px; }
.security-note { display: flex; align-items: flex-start; gap: 10px; margin: 18px 0 0; padding: 12px 15px; border: 1px solid #d8e8e1; border-radius: 12px; background: #eef7f3; }
.security-dot { display: inline-block; flex: 0 0 8px; width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; background: #1c9a70; box-shadow: 0 0 0 4px #1c9a7018; }
.security-note p { margin: 0; color: #52635c; font-size: 10.5px; }
.security-note strong { color: var(--green-dark); }
.app-footer { display: flex; justify-content: space-between; gap: 20px; padding: 22px 2px; color: #89928e; font-size: 9px; letter-spacing: .06em; }
.app-footer a { color: #596a62; font-size: 10.5px; letter-spacing: 0; }
.share-dialog { width: min(100% - 28px, 520px); padding: 27px; border: 1px solid var(--line); border-radius: 17px; box-shadow: 0 25px 90px #15251e33; }
.share-dialog::backdrop { background: #101b17a6; backdrop-filter: blur(3px); }
.share-dialog h2 { margin: 6px 0; font-size: 25px; letter-spacing: -.035em; }
.share-dialog > .muted { margin: 6px 0 18px; font-size: 12px; }
.dialog-close { display: flex; justify-content: flex-end; margin: -12px -12px 12px; }
.copy-field { display: flex; gap: 8px; }
.copy-field input { min-width: 0; font-size: 11px; }
.toast { position: fixed; z-index: 20; bottom: 20px; left: 50%; max-width: min(90vw, 520px); padding: 11px 16px; transform: translate(-50%, 12px); border-radius: 10px; background: #202826; color: white; font-size: 12px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

.sign-page { min-height: 100vh; background: #f3f6f4; }
.sign-header { display: flex; height: 68px; align-items: center; justify-content: space-between; padding: 0 max(20px, calc((100vw - 1080px)/2)); border-bottom: 1px solid var(--line); background: white; }
.secure-label { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 10.5px; }
.secure-label .security-dot { margin: 0; }
.sign-shell { width: min(100% - 32px, 920px); margin: 34px auto 42px; }
.sign-intro { padding: 28px 30px; border: 1px solid #d6e8df; border-radius: 16px; background: linear-gradient(120deg, #fff, #f1f8f5); }
.sign-intro h1 { margin: 7px 0; font-size: clamp(27px, 4vw, 36px); letter-spacing: -.045em; line-height: 1.15; }
.sign-intro > p { margin: 0; color: var(--muted); font-size: 12.5px; }
.sign-meta { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-top: 24px; }
.sign-meta > span { display: grid; gap: 4px; padding: 11px 13px; border: 1px solid #e4ece8; border-radius: 10px; background: #ffffffc9; }
.sign-meta small { color: var(--muted); font-size: 8.5px; font-weight: 800; letter-spacing: .1em; }
.sign-meta strong { font-size: 11px; }
.document-heading { padding: 25px 0 10px; }
.document-heading h2 { margin: 4px 0; font-size: 19px; }
.document-heading p { margin: 0; color: var(--muted); font-size: 11.5px; }
.signed-document { width: min(100%, 900px); margin: 0 auto; padding: 0; }
.signed-document > .doc { width: 100%; padding: 48px 54px 58px; border: 1px solid var(--line); border-radius: 5px; background: #fff; box-shadow: 0 12px 40px #1d31261a; color: #171918; font: 13.5px/1.68 "Segoe UI", Arial, sans-serif; text-align: justify; }
.doc-brand { display: flex; align-items: center; justify-content: center; gap: 14px; padding-bottom: 17px; margin-bottom: 23px; border-bottom: 1px solid #ddd; }
.doc-brand svg { width: 46px; height: 46px; }
.doc-brand .w { display: flex; flex-direction: column; line-height: 1.05; }
.doc-brand .w b { font-size: 20px; letter-spacing: .19em; }
.doc-brand .w span { margin-top: 4px; color: #666; font-size: 8.5px; letter-spacing: .15em; text-transform: uppercase; }
.doc-head { margin-bottom: 23px; text-align: center; }
.doc-head h1 { margin: 0 0 5px; font-size: 17px; letter-spacing: .06em; text-transform: uppercase; }
.doc-head p { margin: 0; color: #555; font-size: 11px; }
.doc p { margin: 0 0 9px; }
.doc h2 { margin: 20px 0 6px; font-size: 12px; letter-spacing: .04em; text-transform: uppercase; }
.doc h3 { margin: 14px 0 4px; font-size: 12px; }
.doc ol, .doc ul { padding-left: 24px; }
.doc li { margin-bottom: 4px; }
.doc .fill { white-space: pre-line; }
.doc .firmas { margin-top: 28px; }
.doc .firmas-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; margin-top: 22px; }
.doc .firma { text-align: center; }
.doc .firma .cap { margin-top: 7px; font-size: 11px; line-height: 1.4; }
.doc .firma .cap strong, .doc .firma .cap span, .doc .firma .cap small { display: block; }
.doc .firma .cap span { color: #444; font-size: 10px; }
.doc .firma .cap small { margin-top: 5px; color: #666; font-size: 8px; letter-spacing: .12em; }
.signature-image { display: block; width: min(100%, 250px); height: 75px; object-fit: contain; object-position: center bottom; margin: 0 auto; border-bottom: 1px solid #444; }
.signature-pending { min-height: 75px; padding: 35px 5px 8px; border-bottom: 1px solid #aaa; color: #707775; font-size: 9px; font-style: italic; text-align: center; }
.signature-evidence { margin: 7px 0 0; color: #48554e; font-size: 9px; line-height: 1.45; text-align: left; }
.doc .aviso-firma { margin-top: 20px; color: #555; font-size: 9.5px; }
.sign-form-card { margin-top: 19px; padding: 24px; border: 1px solid var(--line); border-radius: 16px; background: white; }
.sign-form-card .section-heading { padding: 0 0 15px; }
.identity-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 15px; }
.identity-grid label, .signature-label { display: grid; gap: 6px; color: var(--ink-soft); font-size: 10.5px; font-weight: 750; }
.identity-grid input { width: 100%; min-height: 39px; padding: 8px 10px; border: 1px solid #e0e6e2; border-radius: 8px; background: #f7f9f8; color: var(--ink-soft); font-size: 12px; }
.required-mark { color: #b63a33; }
.signature-pad { overflow: hidden; margin-top: 7px; border: 1px solid #d8e1dc; border-radius: 10px; background: #fcfdfc; }
.signature-pad canvas { display: block; width: 100%; height: 150px; touch-action: none; cursor: crosshair; }
.signature-controls { display: flex; align-items: center; justify-content: space-between; margin: 6px 2px 16px; color: var(--muted); font-size: 10px; }
.consent-check { display: flex; align-items: flex-start; gap: 10px; padding: 12px; border: 1px solid #e1e9e5; border-radius: 10px; background: #f8fbf9; color: var(--ink-soft); font-size: 11px; line-height: 1.5; }
.consent-check input { flex: 0 0 17px; width: 17px; height: 17px; margin-top: 1px; accent-color: var(--green); }
.privacy-copy { margin: 10px 0 15px; color: var(--muted); font-size: 10px; line-height: 1.5; }
.sign-submit .button { min-height: 48px; }
.sign-form-card > .fine-print { padding-top: 3px; }
.completion-banner { display: flex; align-items: center; gap: 15px; margin-bottom: 18px; padding: 20px; border: 1px solid #c5e1d4; border-radius: 15px; background: var(--green-soft); }
.completion-check { display: grid; flex: 0 0 39px; width: 39px; height: 39px; place-items: center; border-radius: 50%; background: var(--green); color: white; font-size: 20px; }
.completion-banner > div { flex: 1; }
.completion-banner h1 { margin: 3px 0 2px; font-size: 21px; }
.completion-banner p { margin: 0; color: #51635b; font-size: 11px; }
.document-integrity { display: grid; gap: 5px; margin: 15px auto 35px; padding: 13px 16px; border: 1px solid var(--line); border-radius: 10px; background: white; }
.document-integrity span { color: var(--muted); font-size: 8.5px; font-weight: 800; letter-spacing: .12em; }
.document-integrity code { overflow-wrap: anywhere; color: var(--green-dark); font: 10px/1.5 Consolas, monospace; }
.document-integrity small { color: var(--muted); font-size: 9px; }
.evidence-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 15px; }
.evidence-summary > div { display: grid; gap: 4px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: white; }
.evidence-summary small { color: var(--muted); font-size: 8px; font-weight: 800; letter-spacing: .1em; }
.evidence-summary strong { font-size: 11px; }
.evidence-summary span { color: var(--muted); font-size: 10px; }
.evidence-events { margin-top: 15px; }
.evidence-events table { min-width: 820px; }
.evidence-events td { max-width: 420px; overflow-wrap: anywhere; vertical-align: top; }
.evidence-events td small { line-height: 1.5; }
.sign-message { width: min(100% - 32px, 520px); margin: 90px auto; padding: 35px; border: 1px solid var(--line); border-radius: 16px; background: white; text-align: center; }
.sign-message h1 { margin: 12px 0 8px; font-size: 25px; }
.sign-message p { margin: 0; color: var(--muted); font-size: 12px; }
.message-mark { display: inline-grid; width: 43px; height: 43px; place-items: center; border-radius: 50%; background: var(--amber-soft); color: var(--amber); font-size: 22px; }
.sign-footer { padding: 18px; color: #8a9690; font-size: 9px; letter-spacing: .08em; text-align: center; }

.document-page { min-height: 100vh; background: #f3f6f4; }
.document-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 13px max(16px, calc((100vw - 1050px)/2)); border-bottom: 1px solid var(--line); background: white; }
.document-toolbar > div { display: grid; flex: 1; text-align: center; }
.document-toolbar strong { font-size: 11px; }
.document-toolbar small { color: var(--muted); font-size: 9px; }
.document-page .signed-document { margin-top: 24px; }

@media (max-width: 760px) {
  .app-header { padding: 0 18px; }
  .header-user > span { display: none; }
  .dashboard-shell { width: min(100% - 28px, 620px); padding-top: 31px; }
  .welcome-row { align-items: flex-start; flex-direction: column; }
  .welcome-row .button { width: 100%; }
  .metric-grid { gap: 8px; }
  .metric-card { padding: 13px 11px; }
  .metric-card strong { font-size: 23px; }
  .metric-card small { font-size: 9px; }
  .section-heading { padding: 17px; }
  .table-wrap { overflow: visible; }
  table, tbody, tr, td { display: block; width: 100%; }
  thead { display: none; }
  tbody { padding: 0 14px; }
  tr { display: grid; grid-template-columns: 1fr auto; gap: 7px 10px; padding: 14px 0; border-top: 1px solid #edf0ee; }
  td { padding: 0; border: 0; }
  td:nth-child(2) { grid-column: 1; font-size: 10.5px; }
  td:nth-child(3) { grid-column: 2; grid-row: 1; justify-self: end; }
  td:nth-child(4) { grid-column: 1; color: var(--muted); font-size: 10px; }
  td:nth-child(5) { grid-column: 1 / -1; justify-content: flex-start; margin-top: 4px; }
  .app-footer { flex-direction: column; gap: 5px; }
  .sign-header { height: 60px; padding: 0 15px; }
  .secure-label { font-size: 9px; }
  .sign-shell { width: min(100% - 20px, 620px); margin-top: 16px; }
  .sign-intro { padding: 20px 17px; }
  .sign-meta { grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 17px; }
  .sign-meta > span:last-child { grid-column: 1 / -1; }
  .signed-document > .doc { padding: 28px 20px; font-size: 11px; line-height: 1.6; }
  .doc .firmas-grid { gap: 14px; }
  .doc-brand svg { width: 38px; height: 38px; }
  .sign-form-card { padding: 17px; }
  .identity-grid { grid-template-columns: 1fr; gap: 10px; }
  .completion-banner { align-items: flex-start; flex-wrap: wrap; padding: 16px; }
  .completion-banner .button { width: 100%; }
  .document-toolbar { flex-wrap: wrap; }
  .document-toolbar > div { order: 3; flex-basis: 100%; }
  .document-toolbar .button { min-height: 37px; padding: 0 10px; font-size: 10.5px; }
  .form-grid { grid-template-columns: 1fr; }
  .evidence-summary { grid-template-columns: 1fr 1fr; }
  .evidence-events .table-wrap { overflow-x: auto; }
  .evidence-events table { display: table; width: 100%; }
  .evidence-events tbody { display: table-row-group; padding: 0; }
  .evidence-events tr { display: table-row; padding: 0; border-top: 0; }
  .evidence-events td { display: table-cell; width: auto; padding: 12px; border-top: 1px solid #edf0ee; }
  .auth-card { padding: 25px 21px; }
}

@media print {
  body, .sign-page, .document-page { background: white !important; }
  .no-print, .sign-header, .sign-form-card, .sign-footer, .sign-intro, .document-heading,
  .document-toolbar { display: none !important; }
  .sign-shell, .signed-document, .document-page .signed-document { width: 100%; max-width: none; margin: 0; }
  .signed-document > .doc { max-width: none; padding: 10mm 12mm; border: 0; box-shadow: none; font-size: 10.5pt; }
  .doc .firmas, .doc .firmas-grid, .doc .firma { break-inside: avoid; }
  .signature-image { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .document-integrity { break-inside: avoid; border: 0; padding: 5mm 12mm 0; box-shadow: none; }
  @page { margin: 16mm 15mm; }
}
