:root {
    --bg: #f6f7f4;
    --panel: #ffffff;
    --ink: #1d2433;
    --muted: #687083;
    --line: #d9deea;
    --primary: #176b87;
    --primary-dark: #0f4d61;
    --success: #197a4f;
    --danger: #b33131;
    --warning: #9a6300;
    --soft-success: #e8f5ee;
    --soft-danger: #fae9e9;
    --soft-warning: #fff2d7;
    --shadow: 0 14px 40px rgba(29, 36, 51, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 16px;
    line-height: 1.5;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    min-height: 76px;
    padding: 0 32px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(12px);
}

.brand {
    display: inline-flex;
    align-items: center;
    min-width: 132px;
    color: var(--ink);
    font-weight: 800;
    font-size: 20px;
}

.brand-logo {
    display: block;
    width: min(520px, 48vw);
    height: auto;
    max-height: 58px;
    object-fit: contain;
}

.nav {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.nav a {
    color: var(--ink);
    border-radius: 6px;
    padding: 8px 10px;
}

.nav a:hover {
    background: #eef3f2;
    text-decoration: none;
}

.page,
.install-page {
    width: min(1180px, calc(100vw - 32px));
    margin: 0 auto;
    padding: 32px 0 64px;
}

.page-title,
.section-heading,
.install-hero {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
}

.page-title {
    margin-bottom: 22px;
}

h1,
h2 {
    margin: 0;
    line-height: 1.15;
}

h1 {
    font-size: clamp(28px, 4vw, 42px);
}

h2 {
    font-size: 20px;
}

p {
    margin: 8px 0 0;
}

.muted,
.help,
.page-title span,
.section-heading span {
    color: var(--muted);
}

.help {
    display: block;
    margin-top: 6px;
    font-size: 14px;
}

.panel,
.public-card,
.login-panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.panel {
    margin-bottom: 22px;
    padding: 22px;
}

.panel.narrow {
    max-width: 760px;
}

.danger-panel {
    border-color: #e9bcbc;
    background: var(--soft-danger);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}

.stat {
    min-height: 108px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.stat span {
    display: block;
    color: var(--muted);
    font-size: 14px;
}

.stat strong {
    display: block;
    margin-top: 10px;
    font-size: 30px;
    line-height: 1.1;
}

.split {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
    gap: 22px;
    align-items: start;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 720px;
}

th,
td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

th {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.actions form {
    margin: 0;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    border-radius: 999px;
    padding: 3px 9px;
    font-size: 13px;
    font-weight: 700;
    background: #eef1f7;
    color: var(--muted);
}

.badge.active {
    background: var(--soft-success);
    color: var(--success);
}

.badge.inactive {
    background: var(--soft-warning);
    color: var(--warning);
}

.badge.archived {
    background: #eef1f7;
    color: #59606f;
}

.badge.signature-not_required {
    background: #e7f3f6;
    color: var(--primary-dark);
}

.badge.signature-unsigned {
    background: var(--soft-warning);
    color: var(--warning);
}

.badge.signature-signed {
    background: var(--soft-success);
    color: var(--success);
}

.badge.signature-disabled {
    background: #eef1f7;
    color: #59606f;
}

.badge.signature-declined {
    background: var(--soft-danger);
    color: var(--danger);
}

.badge.signal-hot {
    background: #ffe3dd;
    color: #a13725;
}

.badge.signal-warm {
    background: #fff2d7;
    color: #8a5700;
}

.badge.signal-silent {
    background: #eef1f7;
    color: #59606f;
}

.badge.signal-new {
    background: #e7f3f6;
    color: var(--primary-dark);
}

.signal-meta {
    margin-top: 5px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.35;
    max-width: 180px;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 9px 14px;
    background: #ffffff;
    color: var(--ink);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}

.button:hover {
    background: #f0f4f4;
    text-decoration: none;
}

.button.primary {
    border-color: var(--primary);
    background: var(--primary);
    color: #ffffff;
}

.button.primary:hover {
    background: var(--primary-dark);
}

.button.danger {
    border-color: #e0adad;
    color: var(--danger);
}

.button.small {
    min-height: 34px;
    padding: 6px 10px;
    font-size: 14px;
}

.button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.button-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.button-row form {
    margin: 0;
}

.form-grid {
    display: grid;
    gap: 16px;
}

label {
    display: grid;
    gap: 7px;
    font-weight: 700;
}

.check-label {
    display: grid;
    grid-template-columns: 22px minmax(0, 1fr);
    align-items: start;
    gap: 10px;
    font-weight: 700;
}

.check-label input {
    width: 18px;
    min-height: 18px;
    margin-top: 3px;
}

.fieldset {
    display: grid;
    gap: 16px;
    margin: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
}

.fieldset legend {
    padding: 0 6px;
    font-weight: 800;
}

input,
textarea,
select {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px 12px;
    background: #ffffff;
    color: var(--ink);
    font: inherit;
    font-weight: 500;
}

textarea {
    resize: vertical;
}

.copy-input {
    min-width: 260px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
}

.notice {
    margin-bottom: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px 16px;
    background: #ffffff;
}

.notice.success {
    border-color: #b9dec9;
    background: var(--soft-success);
    color: var(--success);
}

.notice.danger {
    border-color: #e7b8b8;
    background: var(--soft-danger);
    color: var(--danger);
}

.notice.warning {
    border-color: #f0d39b;
    background: var(--soft-warning);
    color: var(--warning);
}

.note-box {
    margin-top: 16px;
    border-left: 4px solid var(--primary);
    padding: 12px 14px;
    background: #f3f8f7;
    color: #324055;
}

.activity-list {
    display: grid;
    gap: 12px;
}

.activity-item {
    display: grid;
    gap: 3px;
    border-bottom: 1px solid var(--line);
    padding-bottom: 12px;
}

.activity-item span {
    color: var(--muted);
    font-size: 14px;
}

.install-body,
.login-body,
.public-body {
    display: grid;
    place-items: start center;
}

.install-hero {
    margin-bottom: 22px;
    border-bottom: 1px solid var(--line);
    padding-bottom: 22px;
}

.install-logo,
.auth-logo,
.public-logo {
    display: block;
    width: min(100%, 520px);
    height: auto;
    max-height: 58px;
    object-fit: contain;
}

.install-logo {
    margin-bottom: 18px;
}

.auth-logo,
.public-logo {
    margin-bottom: 18px;
}

.install-meta {
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 8px 12px;
    background: #ffffff;
    color: var(--muted);
    font-weight: 700;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--primary);
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
}

.checklist {
    display: grid;
    gap: 10px;
    margin-top: 18px;
}

.check-row {
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr);
    gap: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 13px;
    background: #ffffff;
}

.check-row.ok {
    border-color: #b9dec9;
    background: var(--soft-success);
}

.check-row.fail {
    border-color: #e7b8b8;
    background: var(--soft-danger);
}

.check-icon {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.75);
    font-weight: 900;
}

.check-row code,
.plain-list code {
    display: inline-block;
    margin-top: 7px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 5px;
    padding: 3px 6px;
    background: rgba(255, 255, 255, 0.7);
    overflow-wrap: anywhere;
}

.plain-list {
    margin: 10px 0 18px;
    padding-left: 20px;
}

.login-panel,
.public-card {
    width: min(520px, calc(100vw - 32px));
    margin: 8vh auto 0;
    padding: 28px;
}

.public-page {
    width: min(720px, calc(100vw - 32px));
    margin: 0 auto;
    padding: 32px 0;
}

.offer-shell {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    height: 100vh;
    overflow: hidden;
    background: #ffffff;
}

.offer-shell-header {
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 58px;
    border-bottom: 1px solid var(--line);
    padding: 10px 18px;
    background: #ffffff;
}

.offer-logo {
    display: block;
    width: min(300px, 40vw);
    height: auto;
    max-height: 34px;
    object-fit: contain;
    flex: 0 0 auto;
}

.offer-shell-title {
    display: grid;
    gap: 1px;
    min-width: 0;
    flex: 1 1 auto;
}

.offer-shell-header span {
    color: var(--muted);
    font-size: 13px;
}

.offer-frame {
    width: 100%;
    height: 100%;
    border: 0;
    background: #ffffff;
}

.offer-shell.with-signature-panel {
    display: block;
    height: auto;
    min-height: 100vh;
    overflow: auto;
}

.offer-shell.with-signature-panel .offer-frame {
    display: block;
    height: 100vh;
    min-height: 520px;
}

.signature-panel {
    width: min(820px, calc(100vw - 32px));
    margin: 56px auto 72px;
    border-top: 1px solid var(--line);
    padding: 44px 0 0;
    background: #ffffff;
}

.signature-panel h2 {
    margin-bottom: 22px;
}

.signature-form {
    gap: 18px;
}

.signature-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.signature-form .note-box {
    margin-top: 0;
}

.signature-form .button {
    justify-self: start;
}

.offer-print-button {
    flex: 0 0 auto;
}

@media print {
    .offer-shell-header {
        display: none;
    }
}

@media (max-width: 860px) {
    .topbar,
    .page-title,
    .section-heading,
    .install-hero {
        align-items: stretch;
        flex-direction: column;
    }

    .stats-grid,
    .split,
    .signature-fields {
        grid-template-columns: 1fr;
    }

    .topbar {
        position: static;
        padding: 16px;
    }

    .brand-logo {
        width: min(420px, 88vw);
        max-height: 48px;
    }

    .nav {
        width: 100%;
    }

    .nav a {
        padding: 7px 8px;
    }

    .panel {
        padding: 18px;
    }

    table {
        min-width: 640px;
    }

    .offer-shell-header {
        flex-wrap: wrap;
        align-items: flex-start;
    }

    .offer-shell-title {
        flex-basis: calc(100% - 150px);
    }

    .offer-print-button {
        width: 100%;
    }
}
