/* Contract signing (04/11/26): the Fixed Price Contract sheet (cs-), the customer's iPad / QR pages (sg-),
   the designer's Contract page (ct-) and the small settings pages. Uses the colours in app.css. */

/* ---------------------------------------------------------------------------------------------------------
   The contract sheet – A4, laid out like the paper form
   --------------------------------------------------------------------------------------------------------- */
.cs-sheet { background: #fff; color: #222; width: 100%; max-width: 210mm; margin: 0 auto; padding: 12mm 12mm 10mm; box-sizing: border-box;
    font-size: 10.5pt; line-height: 1.35; box-shadow: var(--nx-shadow); border: 1px solid var(--nx-line); border-radius: 6px; }
.cs-sheet + .cs-sheet { margin-top: 18px; }
.cs-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 10px; flex-wrap: wrap; }
.cs-brand { display: flex; align-items: center; gap: 14px; }
.cs-logo { height: 42px; width: auto; }
.cs-company { font-size: 8.5pt; color: #444; line-height: 1.3; }
.cs-title { font-weight: 900; font-size: 13pt; letter-spacing: .2px; white-space: nowrap; }
.cs-number { color: var(--nx-green-strong); margin-left: 6px; }
.cs-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.cs-row-top { grid-template-columns: 1.15fr 1fr; }
.cs-box { border: 1px solid #333; padding: 7px 9px 8px; margin-bottom: 10px; break-inside: avoid; }
.cs-row .cs-box { margin-bottom: 0; }
.cs-box h3 { margin: 0 0 5px; font-size: 9pt; font-weight: 900; text-transform: uppercase; letter-spacing: .4px; }
.cs-h { font-size: 11pt; font-weight: 900; text-transform: uppercase; margin: 12px 0 6px; letter-spacing: .3px; }
.cs-kv { width: 100%; border-collapse: collapse; }
.cs-kv th { text-align: left; font-weight: 400; color: #555; width: 38%; padding: 2px 8px 2px 0; vertical-align: top; font-size: 9pt; }
.cs-kv td { padding: 2px 0; border-bottom: 1px solid #ddd; min-height: 1.2em; vertical-align: top; font-weight: 700; }
.cs-kv.cs-tight { margin-top: 6px; }
.cs-money td { text-align: right; font-variant-numeric: tabular-nums; }
.cs-money th { width: 62%; }
.cs-ref { margin-top: 6px; font-size: 8.5pt; color: #555; }
.cs-na, .cs-sub { color: #666; font-size: 9pt; }
.cs-sub { font-weight: 700; margin-top: 4px; }
.cs-text { font-weight: 700; min-height: 1.3em; }
.cs-pre { white-space: pre-line; }
.cs-list { width: 100%; border-collapse: collapse; margin-top: 6px; font-size: 9pt; }
.cs-list th { text-align: left; border-bottom: 1px solid #333; padding: 2px 6px 2px 0; font-weight: 900; font-size: 8.5pt; }
.cs-list td { border-bottom: 1px solid #e3e3e3; padding: 2px 6px 2px 0; vertical-align: top; }
.cs-num { text-align: right; }
.cs-code { font-family: Consolas, "SFMono-Regular", Menlo, monospace; font-size: 8.5pt; word-break: break-all; }
.cs-yn { width: 44px; text-align: center; font-weight: 700; }
.cs-small { font-size: 8pt; color: #555; margin: 6px 0 0; }
.cs-terms p { margin: 0 0 3px; font-size: 8.5pt; }
.cs-signatures { border: 1px solid #333; margin-top: 10px; break-inside: avoid; }
.cs-sig-row { display: grid; grid-template-columns: 130px 1fr 150px; align-items: center; min-height: 64px; }
.cs-sig-row + .cs-sig-row { border-top: 1px solid #333; }
.cs-sig-label { padding: 6px 9px; font-size: 9pt; color: #444; }
.cs-sig-box { position: relative; height: 64px; display: flex; align-items: center; gap: 10px; padding: 2px 6px; border-left: 1px solid #ccc; }
.cs-sig-box img { max-height: 58px; max-width: 70%; object-fit: contain; }
.cs-sig-name { font-size: 9pt; color: #444; }
.cs-sig-hint { color: var(--nx-green-strong); font-weight: 700; font-size: 9pt; }
.cs-sig-date { padding: 6px 9px; border-left: 1px solid #333; height: 100%; display: flex; align-items: center; gap: 8px; font-weight: 700; box-sizing: border-box; }
.cs-sig-date span { font-weight: 400; color: #444; font-size: 9pt; }
.cs-foot { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-top: 8px; font-size: 7.5pt; color: #444; text-align: right; flex-wrap: wrap; }
.cs-note { font-weight: 900; font-size: 9pt; text-transform: uppercase; color: #222; text-align: left; }
.cs-record .cs-audit th { width: 22%; }
.cs-record .cs-audit td { font-weight: 400; }

@media (max-width: 700px) {
    .cs-sheet { padding: 14px 12px; font-size: 13px; border-radius: 0; }
    .cs-row, .cs-row-top { grid-template-columns: 1fr; }
    .cs-row .cs-box { margin-bottom: 0; }
    .cs-sig-row { grid-template-columns: 1fr; }
    .cs-sig-date { border-left: 0; border-top: 1px solid #ccc; }
    .cs-sig-box { border-left: 0; }
}

/* ---------------------------------------------------------------------------------------------------------
   The customer's side: the iPad waiting screen and the signing page
   --------------------------------------------------------------------------------------------------------- */
.sg-app { min-height: 100vh; background: #eef0ec; }
.sg-wait { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: 48px 24px 32px;
    box-sizing: border-box; color: #fff; text-align: center;
    background: radial-gradient(1200px 700px at 50% 30%, #3a3737 0%, var(--nx-charcoal) 60%, #1b1a1a 100%); }
.sg-wait-logo { height: 64px; width: auto; opacity: .95; }
.sg-wait-kicker { color: var(--nx-green); font-weight: 900; letter-spacing: 3px; text-transform: uppercase; font-size: 13px; margin-bottom: 14px; }
.sg-wait h1 { font-size: clamp(36px, 6vw, 64px); font-weight: 900; margin: 0 0 12px; letter-spacing: -.5px; }
.sg-wait p { font-size: 20px; color: #cfd2cd; margin: 0; }
.sg-wait-status { font-size: 14px; color: #aeb3ad; display: flex; align-items: center; gap: 8px; }
.sg-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--nx-green); box-shadow: 0 0 0 0 rgba(56,174,43,.6); animation: sg-pulse 2s infinite; }
.sg-off .sg-dot { background: #d98c1f; animation: none; }
.sg-wait-error { justify-content: center; gap: 18px; }
@keyframes sg-pulse { 0% { box-shadow: 0 0 0 0 rgba(56,174,43,.6); } 70% { box-shadow: 0 0 0 12px rgba(56,174,43,0); } 100% { box-shadow: 0 0 0 0 rgba(56,174,43,0); } }

.sg-page { padding-bottom: 40px; }
.sg-top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 14px; padding: 12px max(18px, env(safe-area-inset-left)); background: rgba(255,255,255,.96);
    border-bottom: 1px solid var(--nx-line); backdrop-filter: blur(8px); }
.sg-top-logo { height: 34px; width: auto; }
.sg-top-text { flex: 1; min-width: 0; }
.sg-top-title { font-weight: 900; font-size: 18px; }
.sg-top-sub { color: var(--nx-ink-2); font-size: 14px; }
.sg-handback { display: inline-block; padding: 10px 16px; border-radius: 10px; border: 1px solid var(--nx-line); color: var(--nx-ink); font-weight: 700; background: #fff; }
.sg-doc { padding: 20px 16px 0; }
.sg-panel { max-width: 210mm; margin: 20px auto 0; background: #fff; border-radius: 16px; box-shadow: var(--nx-shadow-lift); padding: 22px 24px 24px; box-sizing: border-box; }
.sg-panel h2 { margin: 0 0 14px; font-size: 22px; font-weight: 900; }
.sg-check { display: flex; gap: 14px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--nx-line); border-radius: 12px; margin-bottom: 10px; font-size: 16px; cursor: pointer; }
.sg-check input { width: 26px; height: 26px; flex: none; accent-color: var(--nx-green-strong); margin: 0; }
.sg-name { display: flex; flex-direction: column; gap: 6px; font-weight: 700; font-size: 14px; color: var(--nx-ink-2); margin: 14px 0; }
.sg-name input { font: inherit; font-size: 18px; color: var(--nx-ink); padding: 12px 14px; border: 1px solid #cfd3cc; border-radius: 10px; }
.sg-pad-wrap { position: relative; border: 2px dashed #b9c0b6; border-radius: 14px; background: #fbfcfa; height: 240px; touch-action: none; }
.sg-pad { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; z-index: 2; }
.sg-pad-line { position: absolute; left: 24px; right: 24px; bottom: 56px; border-bottom: 1px solid #b9c0b6; z-index: 1; pointer-events: none; }
.sg-pad-line span { position: absolute; left: 0; top: 6px; font-size: 12px; color: var(--nx-ink-3); text-transform: uppercase; letter-spacing: 1px; }
.sg-clear { position: absolute; top: 10px; right: 10px; z-index: 3; border: 1px solid var(--nx-line); background: #fff; border-radius: 8px; padding: 8px 14px; font: inherit; font-weight: 700; color: var(--nx-ink-2); }
.sg-submit { display: block; width: 100%; margin-top: 16px; padding: 18px; border: 0; border-radius: 14px; background: var(--nx-green-strong); color: #fff; font: inherit; font-size: 20px; font-weight: 900; cursor: pointer; }
.sg-submit:disabled { background: #b8beb6; cursor: default; }
.sg-error { margin-top: 12px; padding: 10px 14px; border-radius: 10px; background: #fdecea; color: #a1302a; font-weight: 700; }
.sg-fine { font-size: 12.5px; color: var(--nx-ink-3); margin: 12px 0 0; }
.sg-done, .sg-msg { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; padding: 24px; background: rgba(39,37,37,.55); backdrop-filter: blur(6px); }
.sg-msg { position: static; min-height: 100vh; box-sizing: border-box; background: #eef0ec; }
.sg-done[hidden] { display: none; }
.sg-done-card, .sg-msg-card { background: #fff; border-radius: 22px; padding: 36px 40px; text-align: center; max-width: 520px; box-shadow: var(--nx-shadow-lift); }
.sg-done-card h1, .sg-msg-card h1 { font-size: 32px; font-weight: 900; margin: 8px 0; }
.sg-done-card p, .sg-msg-card p { font-size: 18px; color: var(--nx-ink-2); margin: 0 0 6px; }
.sg-msg-logo { height: 40px; width: auto; margin-bottom: 10px; }
.sg-done-tick { width: 76px; height: 76px; margin: 0 auto; border-radius: 50%; background: var(--nx-green-strong); color: #fff; font-size: 44px; line-height: 76px; font-weight: 900;
    animation: sg-pop .45s cubic-bezier(.2,1.4,.4,1); }
@keyframes sg-pop { from { transform: scale(.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------------------------------------------------------------------------------------------------------
   The designer's Contract page
   --------------------------------------------------------------------------------------------------------- */
.ct-rev-select { min-width: 260px; }
.ct-status { display: flex; flex-wrap: wrap; align-items: center; gap: 16px 20px; }
.ct-status.pending { border-color: #e7c27a; background: #fffaf0; }
.ct-status.signed { border-color: var(--nx-green); background: var(--nx-green-soft); }
.ct-status-main { display: flex; align-items: center; gap: 14px; flex: 1; min-width: 280px; }
.ct-status-icon { color: var(--nx-green-strong); font-size: 34px !important; width: 34px !important; height: 34px !important; }
.ct-status-title { font-weight: 900; font-size: 17px; }
.ct-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.ct-hint { flex-basis: 100%; font-size: 13px; color: var(--nx-ink-2); background: #f7f8f5; border-radius: 10px; padding: 8px 12px; }
.ct-pulse { width: 14px; height: 14px; border-radius: 50%; background: #d98c1f; flex: none; animation: ct-pulse 1.6s infinite; }
@keyframes ct-pulse { 0% { box-shadow: 0 0 0 0 rgba(217,140,31,.55); } 70% { box-shadow: 0 0 0 12px rgba(217,140,31,0); } 100% { box-shadow: 0 0 0 0 rgba(217,140,31,0); } }
.ct-qr-wrap { display: flex; align-items: center; }
.ct-qr { width: 150px; height: 150px; background: #fff; border-radius: 10px; padding: 6px; box-sizing: border-box; border: 1px solid var(--nx-line); }
.ct-qr svg { width: 100%; height: 100%; display: block; }
.ct-online { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #c4c8c2; margin-left: 8px; }
.ct-online.on { background: #7be26c; box-shadow: 0 0 0 3px rgba(123,226,108,.25); }
.ct-grid { display: grid; grid-template-columns: minmax(380px, 1fr) minmax(0, 1.05fr); gap: 20px; align-items: start; }
@media (max-width: 1200px) { .ct-grid { grid-template-columns: 1fr; } }
.ct-preview { position: sticky; top: 76px; }
.ct-preview-label { font-size: 12px; font-weight: 900; letter-spacing: 1.2px; text-transform: uppercase; color: var(--nx-ink-3); margin-bottom: 8px; }
.ct-preview-scale { max-height: calc(100vh - 120px); overflow: auto; border-radius: 8px; }
.ct-preview-scale .cs-sheet { font-size: 9.5pt; }
.ct-install { display: flex; flex-direction: column; gap: 6px; }
.ct-install-row { display: grid; grid-template-columns: minmax(150px, 1.1fr) auto 1.4fr; gap: 10px; align-items: center; }
.ct-install-name { font-size: 14px; font-weight: 700; }
.ct-yn { display: inline-flex; border: 1px solid var(--nx-line); border-radius: 9px; overflow: hidden; }
.ct-yn button { border: 0; background: #fff; padding: 6px 12px; font: inherit; font-size: 13px; font-weight: 700; color: var(--nx-ink-2); cursor: pointer; }
.ct-yn button + button { border-left: 1px solid var(--nx-line); }
.ct-yn button.on.yes { background: var(--nx-green-strong); color: #fff; }
.ct-yn button.on.no { background: #6b706a; color: #fff; }
@media (max-width: 600px) { .ct-install-row { grid-template-columns: 1fr auto; } .ct-install-row input { grid-column: 1 / -1; } }

/* My signature, Signing iPads */
.ms-pad { height: 200px; }
.ms-saved { border: 1px solid var(--nx-line); border-radius: 12px; padding: 16px; background: #fbfcfa; text-align: center; }
.ms-saved img { max-width: 100%; max-height: 140px; }
.pair-steps { margin: 0 0 14px; padding-left: 20px; font-size: 14px; line-height: 1.6; }
.pair-qr { width: 200px; height: 200px; margin-bottom: 12px; }
.pair-link { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pair-link code { font-size: 12px; background: #f3f4f1; border-radius: 8px; padding: 6px 8px; word-break: break-all; }
.rev-list li.dev-revoked { opacity: .55; }

/* The signed contract page (/contracts/{id}) */
.cv-bar { display: flex; align-items: center; gap: 16px; max-width: 210mm; margin: 16px auto; font-size: 14px; flex-wrap: wrap; }
.cv-bar a { font-weight: 700; }
.cv-bar button { margin-left: auto; border: 0; border-radius: 10px; background: var(--nx-green-strong); color: #fff; font: inherit; font-weight: 700; padding: 9px 16px; cursor: pointer; }
.cv-state { padding: 4px 10px; border-radius: 999px; font-weight: 800; font-size: 12.5px; background: #eceee9; }
.cv-state.cv-signed { background: var(--nx-green-soft); color: var(--nx-green-dark); }
.cv-ok { color: var(--nx-green-dark) !important; font-weight: 700 !important; }
.cv-bad { color: #a1302a !important; font-weight: 900 !important; }

@media print {
    @page { size: A4; margin: 9mm 0 8mm; }
    html, body { background: #fff !important; }
    .no-print, .cv-bar { display: none !important; }
    .cs-sheet { box-shadow: none; border: 0; border-radius: 0; max-width: none; width: 210mm; margin: 0; padding: 2mm 12mm 0; font-size: 9.5pt; }
    .cs-sheet + .cs-sheet { margin-top: 0; break-before: page; }
    .cs-box, .cs-signatures, .cs-list tr { break-inside: avoid; }
}
