:root {
    --navy: #0f1b2d;
    --charcoal: #2a3444;
    --gold: #c9a227;
    --off-white: #f7f4ec;
    --white: #ffffff;
    --success: #1f7a4f;
    --danger: #b42318;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: "Segoe UI", system-ui, sans-serif;
    background: linear-gradient(180deg, var(--off-white) 0%, #ece7db 100%);
    color: var(--charcoal);
    line-height: 1.5;
}
.container { width: 80vw; max-width: none; margin: 0 auto; }
.site-header {
    background: var(--navy);
    color: var(--off-white);
    padding: 1rem 0;
    border-bottom: 3px solid var(--gold);
}
.header-inner { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.brand { display: flex; align-items: center; gap: .75rem; color: inherit; text-decoration: none; }
.brand-mark {
    width: 42px; height: 42px; border-radius: 50%;
    border: 2px solid var(--gold); display: grid; place-items: center;
    font-weight: 700; color: var(--gold);
}
.brand-text { font-weight: 600; letter-spacing: .04em; }
.admin-nav a { color: var(--off-white); margin-left: 1rem; text-decoration: none; opacity: .9; }
.main-content { padding: 2rem 0 4rem; }
.site-footer { text-align: center; padding: 1.5rem; color: #6b7280; font-size: .9rem; }
.card {
    background: var(--white);
    border: 1px solid #e5dfd2;
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 10px 30px rgba(15, 27, 45, .08);
}
.hero-card, .step-card { width: 100%; max-width: none; margin: 0 auto; }
.step-label {
    display: inline-block; font-size: .8rem; text-transform: uppercase;
    letter-spacing: .08em; color: var(--gold); font-weight: 700; margin-bottom: .5rem;
}
h1 { color: var(--navy); margin-top: 0; font-size: 1.6rem; }
.lead { font-size: 1.05rem; }
.muted { color: #6b7280; }
.small { font-size: .9rem; }
.badge {
    display: inline-block; background: var(--navy); color: var(--gold);
    padding: .25rem .6rem; border-radius: 999px; font-size: .75rem; margin-bottom: 1rem;
}
.price-box {
    font-size: 2rem; font-weight: 700; color: var(--navy);
    margin: 1rem 0; padding: 1rem; background: var(--off-white); border-radius: 12px;
}
.price-box span { font-size: 1rem; font-weight: 500; color: var(--charcoal); }
.feature-list { padding-left: 1.2rem; }
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    border: none; border-radius: 10px;
    padding: .8rem 1.2rem; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn-block { display: flex; width: 100%; text-align: center; margin-top: 1rem; }
.btn-primary { background: var(--navy); color: var(--off-white); }
.btn-secondary { background: #e8e2d6; color: var(--navy); }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-icon {
    width: 2.35rem;
    height: 2.35rem;
    padding: 0;
    border-radius: 8px;
    font-size: 1rem;
    flex-shrink: 0;
}
.table-actions a,
.table-actions .link-button,
.link-button {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
}
.contract-box {
    max-height: 360px; overflow: auto; padding: 1rem;
    background: #faf8f3; border: 1px solid #e5dfd2; border-radius: 12px; margin: 1rem 0;
}
.checkbox-row { display: flex; gap: .75rem; align-items: flex-start; margin: 1rem 0; }
.actions { display: flex; gap: .75rem; flex-wrap: wrap; }
.success-card { text-align: center; }
.completion-external { margin-top: 1.25rem; }
.icon-shield {
    width: 72px; height: 72px; margin: 0 auto 1rem; border-radius: 50%;
    background: var(--off-white); border: 3px solid var(--gold);
    display: grid; place-items: center; font-size: 2rem; color: var(--navy); font-weight: 700;
}
.icon-shield.active { border-color: var(--success); color: var(--success); }
.meta-grid, .info-box { display: grid; gap: .75rem; margin: 1rem 0; }
.info-box > div, .meta-grid > div {
    display: flex; justify-content: space-between; gap: 1rem;
    padding: .75rem 1rem; background: var(--off-white); border-radius: 10px;
}
.info-box span, .meta-grid span { color: #6b7280; font-size: .9rem; }
.lock-note { background: #fff8e6; border-left: 4px solid var(--gold); padding: .75rem 1rem; border-radius: 8px; }
.payment-option {
    display: flex; align-items: center; gap: .75rem;
    padding: 1rem; border: 1px solid #e5dfd2; border-radius: 12px; margin-bottom: .75rem;
}
.payment-option:has(input:checked) { border-color: var(--gold); background: #fffdf7; }
.payment-option-bank {
    flex-direction: column;
    align-items: flex-start;
}
.payment-option-bank input[type="radio"] {
    margin-top: 0.15rem;
}
.payment-option-title {
    font-weight: 600;
}
.payment-option-hint {
    display: block;
    margin-top: 0.35rem;
    margin-left: 1.75rem;
    color: #6b7280;
    font-size: 0.9rem;
    line-height: 1.45;
    font-weight: 400;
}
.error-text { color: var(--danger); }
.admin-header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.header-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.data-table { width: 100%; border-collapse: collapse; table-layout: auto; }
.data-table th, .data-table td { padding: .75rem; border-bottom: 1px solid #eee; text-align: left; vertical-align: middle; }
.table-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.table-actions a { text-decoration: none; }
.table-actions a:hover { opacity: .9; }
.table-actions .btn-icon { text-decoration: none; }
.inline-form { display: inline; margin: 0; }
.link-button {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    cursor: pointer;
    text-decoration: underline;
    color: var(--navy);
}
.link-button.danger { color: var(--danger); }
.danger-zone { border: 1px solid #f0c7c3; }
.danger-zone h2 { color: var(--danger); margin-top: 0; }
.stack-form select {
    width: 100%;
    padding: .65rem .75rem;
    border: 1px solid #d8d2c4;
    border-radius: 8px;
    font: inherit;
    background: var(--white);
}
.status-pill { padding: .2rem .55rem; border-radius: 999px; font-size: .8rem; background: #eee; }
.status-active { background: #d1fae5; color: var(--success); }
.status-pending_deposit, .status-signed_pending_payment, .status-pending_signature { background: #fff3cd; }
.stack-form label { display: block; margin-bottom: 1rem; }
.stack-form input, .stack-form textarea { width: 100%; margin-top: .35rem; padding: .7rem; border: 1px solid #ddd; border-radius: 8px; }
.stack-form input[type="file"] { padding: .5rem; background: var(--off-white); }
.contract-pdf-view {
    margin: 1rem 0;
    border: 1px solid #e5dfd2;
    border-radius: 12px;
    overflow: hidden;
    background: #faf8f3;
    position: relative;
}
.contract-pdf-view iframe {
    display: block;
    width: 100%;
    height: 520px;
    min-height: 360px;
    border: 0;
    background: #323639;
}
.mobile-sign-bar {
    display: none;
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
.company-fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 1rem 1.25rem; margin: 1rem 0; }
.company-fieldset legend { font-weight: 700; padding: 0 .5rem; }
.btn-sm { padding: .35rem .75rem; font-size: .875rem; }
.actions-row { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 1rem; }
.copy-box input { width: 100%; padding: .7rem; margin-top: .35rem; }
.timeline { list-style: none; padding: 0; }
.timeline li { padding: .6rem 0; border-bottom: 1px solid #eee; display: flex; justify-content: space-between; gap: 1rem; }
.alert { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; }
.alert.success { background: #d1fae5; color: var(--success); }
.alert.warning { background: #fef3c7; color: #92400e; }
.auth-card { max-width: 420px; margin: 2rem auto; }

/* Login page */
.login-body {
    min-height: 100vh;
    background:
        radial-gradient(ellipse 80% 60% at 50% -10%, rgba(201, 162, 39, .18), transparent),
        linear-gradient(180deg, var(--off-white) 0%, #e8e2d6 100%);
}
.login-body .main-content {
    min-height: calc(100vh - 0px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}
.login-page {
    width: min(420px, 100%);
}
.login-card {
    padding: 2rem 2rem 1.75rem;
    border-top: 4px solid var(--gold);
}
.login-brand {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}
.brand-mark-lg {
    width: 56px;
    height: 56px;
    font-size: 1.1rem;
    flex-shrink: 0;
}
.login-eyebrow {
    margin: 0;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .12em;
    color: var(--gold);
    font-weight: 700;
}
.login-brand h1 {
    margin: .15rem 0 0;
    font-size: 1.75rem;
    line-height: 1.1;
}
.login-subtitle {
    margin: 0 0 1.5rem;
    color: #6b7280;
    font-size: .95rem;
    line-height: 1.5;
}
.login-form .field {
    margin-bottom: 1.1rem;
}
.login-form label {
    display: block;
    margin-bottom: .4rem;
    font-size: .85rem;
    font-weight: 600;
    color: var(--charcoal);
    letter-spacing: .02em;
}
.login-form input {
    display: block;
    width: 100%;
    padding: .8rem 1rem;
    border: 1px solid #d8d0c0;
    border-radius: 10px;
    font-size: 1rem;
    background: #faf8f3;
    color: var(--navy);
    transition: border-color .15s, box-shadow .15s, background .15s;
}
.login-form input::placeholder {
    color: #a8a196;
}
.login-form input:focus {
    outline: none;
    border-color: var(--gold);
    background: var(--white);
    box-shadow: 0 0 0 3px rgba(201, 162, 39, .2);
}
.login-submit {
    margin-top: .5rem;
    padding: .9rem 1.2rem;
    font-size: 1rem;
    letter-spacing: .03em;
    transition: transform .1s, box-shadow .15s;
}
.login-submit:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(15, 27, 45, .25);
}
.alert-error {
    background: #fde8e8;
    color: var(--danger);
    border: 1px solid #f5c2c2;
    margin-bottom: 1.25rem;
    font-size: .9rem;
}
.login-footer-note {
    text-align: center;
    margin-top: 1.25rem;
    font-size: .8rem;
    color: #9ca3af;
    letter-spacing: .04em;
}

.hidden { display: none !important; }

body.modal-open { overflow: hidden; }

.signature-field {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 3 / 1;
    min-height: 120px;
    margin: 1rem 0;
    border: 2px dashed #c9a227;
    border-radius: 12px;
    background: #fffdf7;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}
.signature-field:hover,
.signature-field:focus {
    outline: none;
    border-color: var(--gold);
    background: #fff;
}
.signature-field-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    height: 100%;
    color: #6b7280;
    font-weight: 600;
}
.signature-field-empty i {
    font-size: 1.75rem;
    color: var(--gold);
}
.signature-field-preview {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 1rem;
}
.signature-field-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}
.signature-field-edit {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    border: 1px solid #d8d2c4;
    border-radius: 8px;
    background: #fff;
    padding: 0.35rem 0.65rem;
    font: inherit;
    font-size: 0.85rem;
    cursor: pointer;
}
.signature-field-edit:hover {
    border-color: var(--gold);
}

.signature-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(15, 27, 45, 0.55);
}
.signature-modal {
    width: 100%;
    max-width: 560px;
    max-height: calc(100vh - 2rem);
    overflow: auto;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 20px 60px rgba(15, 27, 45, 0.25);
}
.signature-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem 0.5rem;
}
.signature-modal-header h2 {
    margin: 0;
    font-size: 1.15rem;
}
.signature-modal-close {
    border: none;
    background: transparent;
    font-size: 1.1rem;
    color: #6b7280;
    cursor: pointer;
    padding: 0.25rem;
}
.signature-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 0 1.25rem 1.25rem;
}
.signature-panel {
    margin: 0 1.25rem 1rem;
    border: 1px solid #e5dfd2;
    border-radius: 12px;
    overflow: hidden;
    background: #faf8f3;
}
.signature-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid #e5dfd2;
    background: #fff;
}
.signature-tab {
    flex: 1;
    border: none;
    background: transparent;
    padding: 0.85rem 1rem;
    font: inherit;
    font-weight: 600;
    color: #6b7280;
    cursor: pointer;
}
.signature-tab.is-active {
    color: var(--navy);
    box-shadow: inset 0 -3px 0 var(--gold);
    background: #fffdf7;
}
.signature-pane { display: none; padding: 1rem; }
.signature-pane.is-active { display: block; }
.signature-canvas {
    display: block;
    width: 100%;
    height: 180px;
    border: 1px dashed #c9a227;
    border-radius: 10px;
    background: #fff;
    touch-action: none;
    cursor: crosshair;
}
.signature-pane[data-pane="type"] .signature-canvas {
    height: 120px;
    cursor: default;
}
.signature-tools { margin-top: 0.75rem; }
.signature-type-label {
    display: block;
    margin-bottom: 0.75rem;
    font-weight: 600;
}
.signature-type-label input {
    display: block;
    width: 100%;
    margin-top: 0.35rem;
    padding: 0.75rem;
    border: 1px solid #d8d2c4;
    border-radius: 8px;
    font: inherit;
}
.signature-type-preview-wrap { margin-top: 0.5rem; }

@media (max-width: 768px) {
    body.contract-page {
        padding-bottom: calc(5.5rem + env(safe-area-inset-bottom, 0px));
    }
    .container {
        width: 100%;
        max-width: 100%;
        margin: 0;
        padding-left: 0;
        padding-right: 0;
    }
    .header-inner {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    .main-content {
        padding: 0 0 2rem;
    }
    .site-footer {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    .card,
    .step-card,
    .hero-card {
        width: 100%;
        max-width: 100%;
        margin: 0;
        border-radius: 0;
        border-left: none;
        border-right: none;
        box-shadow: none;
        padding: 1.25rem 1rem;
    }
    .contract-pdf-view {
        margin: 1rem 0;
        width: 100%;
        border-radius: 12px;
        border: 1px solid #e5dfd2;
        overflow: hidden;
        background: #faf8f3;
    }
    .contract-pdf-view iframe {
        width: 100%;
        height: 520px;
        min-height: 360px;
        display: block;
        border: 0;
        background: #323639;
    }
    .mobile-sign-bar {
        display: block;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 90;
        padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom, 0px));
        background: rgba(255, 255, 255, 0.98);
        border-top: 1px solid #e5dfd2;
        box-shadow: 0 -8px 24px rgba(15, 27, 45, 0.12);
        backdrop-filter: blur(8px);
    }
    .mobile-sign-bar .btn {
        width: 100%;
        min-height: 48px;
        font-size: 1rem;
    }
    body.modal-open .mobile-sign-bar {
        display: none;
    }
    .grid-2 { grid-template-columns: 1fr; }
    .grid-3 { grid-template-columns: 1fr; }
    .actions { flex-direction: column; }
    .btn { width: 100%; text-align: center; }
    .signature-modal-overlay {
        padding: 0;
        align-items: stretch;
    }
    .signature-modal {
        width: 100%;
        max-width: 100%;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }
    .signature-modal-header {
        flex-shrink: 0;
        padding-top: calc(1rem + env(safe-area-inset-top, 0px));
    }
    .signature-panel {
        flex: 1;
        min-height: 0;
        margin-bottom: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }
    .signature-pane.is-active {
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }
    .signature-pane[data-pane="draw"].is-active {
        padding-bottom: 0.5rem;
    }
    .signature-canvas {
        flex: 1;
        width: 100%;
        height: auto;
        min-height: 220px;
    }
    .signature-modal-footer {
        flex-shrink: 0;
        flex-direction: column;
        padding-bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
        border-top: 1px solid #e5dfd2;
        background: #fff;
    }
    .signature-modal-footer .btn {
        width: 100%;
    }
}
