:root {
    color-scheme: light;
    --navy: #10243e;
    --navy-soft: #1c3859;
    --teal: #087e8b;
    --teal-dark: #05616b;
    --surface: #ffffff;
    --canvas: #f3f7fa;
    --border: #d8e2ea;
    --muted: #607286;
    --danger: #a52a35;
    --shadow: 0 24px 60px rgba(16, 36, 62, .12);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-width: 320px;
    min-height: 100vh;
    color: var(--navy);
    background:
        radial-gradient(circle at 12% 10%, rgba(8, 126, 139, .11), transparent 28rem),
        linear-gradient(145deg, #f8fbfd, var(--canvas));
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input { font: inherit; }
button { cursor: pointer; }

.page-shell {
    display: grid;
    grid-template-rows: auto 1fr auto;
    min-height: 100vh;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: min(1120px, calc(100% - 40px));
    margin: 0 auto;
    padding: 24px 0;
}

.brand {
    display: inline-flex;
    gap: 12px;
    align-items: center;
    color: inherit;
    text-decoration: none;
}

.brand-mark {
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    color: #fff;
    border-radius: 13px;
    background: linear-gradient(145deg, var(--teal), var(--navy-soft));
    font-size: 1.25rem;
    font-weight: 800;
}

.brand strong, .brand small { display: block; }
.brand strong { font-size: 1.05rem; letter-spacing: .01em; }
.brand small { margin-top: 2px; color: var(--muted); font-size: .76rem; }

.content {
    display: grid;
    align-content: center;
    width: min(980px, calc(100% - 32px));
    margin: 20px auto 60px;
}

#loading-screen, #login-screen, #organization-screen { width: min(480px, 100%); justify-self: center; }

.card {
    padding: clamp(28px, 6vw, 44px);
    border: 1px solid rgba(216, 226, 234, .86);
    border-radius: 24px;
    background: rgba(255, 255, 255, .97);
    box-shadow: var(--shadow);
}

.card[hidden], [hidden] { display: none !important; }

.eyebrow {
    margin: 0 0 10px;
    color: var(--teal-dark);
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .13em;
    text-transform: uppercase;
}

h1 { margin: 0; font-size: clamp(1.75rem, 5vw, 2.25rem); line-height: 1.12; }
.intro { margin: 16px 0 28px; color: var(--muted); line-height: 1.6; }

form { display: grid; gap: 10px; }
label { margin-top: 8px; font-size: .88rem; font-weight: 700; }

input {
    width: 100%;
    min-height: 48px;
    padding: 11px 13px;
    color: var(--navy);
    border: 1px solid var(--border);
    border-radius: 11px;
    background: #fbfdfe;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}

input:focus {
    border-color: var(--teal);
    box-shadow: 0 0 0 4px rgba(8, 126, 139, .12);
}

.primary-button, .organization-button {
    min-height: 48px;
    border: 0;
    border-radius: 11px;
    font-weight: 750;
}

.primary-button {
    margin-top: 18px;
    color: #fff;
    background: linear-gradient(135deg, var(--teal), var(--teal-dark));
    box-shadow: 0 10px 22px rgba(8, 126, 139, .2);
}

.primary-button:hover { filter: brightness(.96); }
.primary-button:disabled, .organization-button:disabled, .text-button:disabled { cursor: wait; opacity: .62; }
#renewal-confirm:disabled { cursor: default; }

.text-button {
    padding: 9px 12px;
    color: var(--navy-soft);
    border: 1px solid var(--border);
    border-radius: 9px;
    background: rgba(255, 255, 255, .72);
    font-size: .86rem;
    font-weight: 700;
}

.organization-list { display: grid; gap: 10px; }
.organization-button {
    display: grid;
    gap: 4px;
    justify-items: start;
    padding: 15px 16px;
    color: var(--navy);
    border: 1px solid var(--border);
    background: #f8fbfc;
    text-align: left;
}

.organization-button:hover, .organization-button:focus-visible {
    border-color: var(--teal);
    background: #effafb;
}

.organization-button small { color: var(--muted); font-weight: 500; }

.message {
    margin-top: 16px;
    padding: 13px 15px;
    color: var(--danger);
    border: 1px solid rgba(165, 42, 53, .2);
    border-radius: 11px;
    background: #fff4f5;
    font-size: .9rem;
    line-height: 1.45;
}

.message.success {
    color: #166534;
    border-color: #bbdfc5;
    background: #f0fdf4;
}

.status-card { display: flex; gap: 14px; align-items: center; justify-content: center; color: var(--muted); }
.status-card p { margin: 0; }
.loader {
    width: 22px;
    height: 22px;
    border: 3px solid var(--border);
    border-top-color: var(--teal);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

.success-icon {
    display: grid;
    width: 48px;
    height: 48px;
    margin-bottom: 20px;
    place-items: center;
    color: #fff;
    border-radius: 50%;
    background: var(--teal);
    font-size: 1.35rem;
    font-weight: 800;
}

.identity-summary { margin: 28px 0 0; border-top: 1px solid var(--border); }
.identity-summary div { display: flex; justify-content: space-between; gap: 24px; padding: 15px 0; border-bottom: 1px solid var(--border); }
.identity-summary dt { color: var(--muted); font-size: .86rem; }
.identity-summary dd { margin: 0; font-size: .9rem; font-weight: 750; text-align: right; overflow-wrap: anywhere; }

.customer-tabs { display: flex; gap: 6px; margin-top: 34px; padding: 5px; border: 1px solid var(--border); border-radius: 12px; background: #f3f7fa; }
.customer-tab { flex: 1; padding: 11px 14px; color: var(--muted); border: 0; border-radius: 8px; background: transparent; font-weight: 750; }
.customer-tab.is-active { color: var(--navy); background: var(--surface); box-shadow: 0 3px 10px rgba(16,36,62,.08); }
.customer-tab:focus-visible { outline: 3px solid rgba(8,126,139,.2); }
.customer-panel { margin-top: 22px; padding-top: 8px; }
.section-heading { margin-bottom: 18px; }
.section-heading h2 { margin: 0; font-size: 1.35rem; }
.subscriptions-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.subscription-card { padding: 18px; border: 1px solid var(--border); border-radius: 14px; background: #f8fbfc; }
.subscription-card-header { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.subscription-card h3 { margin: 0; font-size: 1rem; line-height: 1.35; }
.subscription-plan { margin: 5px 0 16px; color: var(--muted); font-size: .84rem; }
.subscription-status { flex: 0 0 auto; padding: 4px 8px; color: var(--navy-soft); border-radius: 999px; background: #e5eef5; font-size: .68rem; font-weight: 800; letter-spacing: .035em; text-transform: uppercase; }
.subscription-status[data-status="active"], .subscription-status[data-status="trialing"] { color: #075e54; background: #dff4ef; }
.subscription-status[data-status="payment_failed"], .subscription-status[data-status="canceled"], .subscription-status[data-status="expired"] { color: var(--danger); background: #fae8ea; }
.subscription-details { display: grid; gap: 10px; margin: 0; }
.subscription-details div { display: flex; justify-content: space-between; gap: 18px; }
.subscription-details dt { color: var(--muted); font-size: .78rem; }
.subscription-details dd { margin: 0; font-size: .8rem; font-weight: 750; text-align: right; }
.subscription-trial-note { margin: 14px 0 0; padding-top: 12px; border-top: 1px solid var(--border); color: #075e54; font-size: .78rem; font-weight: 650; line-height: 1.5; }
.subscription-actions { display: grid; gap: 9px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.modify-subscription { min-height: 42px; margin: 0; }
.modify-subscription:disabled { cursor: not-allowed; opacity: .58; box-shadow: none; }
.secondary-action { min-height: 40px; color: var(--navy-soft); border: 1px solid var(--border); border-radius: 10px; background: #fff; font-weight: 750; }
.secondary-action:disabled { cursor: not-allowed; opacity: .55; }
.cancellation-summary { padding: 11px 12px; border-radius: 10px; background: #f2f5f7; color: var(--navy-soft); font-size: .78rem; line-height: 1.5; }
.change-tracking { padding: 11px 12px; border-radius: 10px; background: #eef6f7; font-size: .78rem; line-height: 1.45; }
.change-tracking strong, .change-tracking span { display: block; }
.change-tracking span { margin-top: 3px; color: var(--muted); }
.subscriptions-notice { margin: 0; padding: 18px; color: var(--muted); border: 1px dashed var(--border); border-radius: 12px; background: #fbfdfe; text-align: center; }
.subscriptions-error { color: var(--danger); border-color: rgba(165, 42, 53, .22); background: #fff4f5; }
.payments-table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--border); border-radius: 14px; }
.payments-table { width: 100%; border-collapse: collapse; background: var(--surface); font-size: .84rem; }
.payments-table th, .payments-table td { padding: 14px 13px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.payments-table th { color: var(--muted); background: #f8fbfc; font-size: .72rem; letter-spacing: .04em; text-transform: uppercase; }
.payments-table tr:last-child td { border-bottom: 0; }
.payments-table td:nth-child(3), .payments-table th:nth-child(3) { white-space: nowrap; text-align: right; }
.payment-documents { display: flex; flex-wrap: wrap; gap: 7px; color: var(--muted); }
.document-link { display: inline-flex; padding: 5px 8px; color: var(--teal-dark); border: 1px solid rgba(8,126,139,.25); border-radius: 7px; background: #effafb; font-weight: 700; text-decoration: none; }
.document-link:hover { text-decoration: underline; }

.modal-backdrop { position: fixed; z-index: 20; inset: 0; display: grid; place-items: center; padding: 22px; background: rgba(11, 28, 48, .62); overflow-y: auto; }
.change-modal { position: relative; width: min(680px, 100%); max-height: calc(100vh - 44px); padding: clamp(24px, 5vw, 38px); border-radius: 20px; background: var(--surface); box-shadow: 0 28px 80px rgba(8, 22, 38, .3); overflow-y: auto; }
.change-modal h2 { margin: 0; font-size: 1.55rem; }
.change-modal.is-response { width: min(440px, 100%); padding: 34px; overflow: visible; }
.change-modal.is-response > .eyebrow, .change-modal.is-response > h2, .change-modal.is-response > .modal-intro { display: none; }
.change-step { min-height: 330px; }
.change-step h3 { margin: 0 0 16px; font-size: 1rem; }
.modal-intro { margin-bottom: 20px; }
.modal-close { position: absolute; top: 15px; right: 16px; width: 38px; height: 38px; color: var(--muted); border: 1px solid var(--border); border-radius: 50%; background: #fff; font-size: 1.45rem; line-height: 1; }
.change-current-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 22px; }
.change-current-summary div { display: grid; gap: 4px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: #f8fbfc; }
.change-current-summary span, .change-current-summary small, .field-help { color: var(--muted); font-size: .72rem; }
.change-current-summary strong { font-size: .88rem; }
.quantity-control { display: grid; grid-template-columns: 48px 1fr 48px; gap: 8px; margin-top: 8px; }
.quantity-control button { color: var(--teal-dark); border: 1px solid var(--border); border-radius: 10px; background: #f3f8f9; font-size: 1.25rem; font-weight: 800; }
.quantity-control input { text-align: center; font-weight: 800; }
.field-help { margin: 7px 0 0; }
.field-error { margin: 8px 0 0; color: var(--danger); font-size: .78rem; }
.change-primary-action { width: 100%; margin-top: 22px; }
.change-review-quantities { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.change-review-quantities div { display: flex; justify-content: space-between; gap: 16px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: #f8fbfc; }
.change-review-quantities span { color: var(--muted); font-size: .78rem; }
.change-review-quantities strong { font-size: .88rem; }
.quote-notice { margin-top: 18px; padding: 14px; color: var(--muted); border-radius: 10px; background: #f5f8fa; text-align: center; }
.quote-error { color: var(--danger); background: #fff4f5; }
.quote-summary { margin-top: 18px; padding: 17px; border: 1px solid rgba(8,126,139,.24); border-radius: 13px; background: #f3fbfb; }
.quote-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.quote-heading small { color: var(--muted); }
.change-kind { padding: 5px 9px; color: var(--teal-dark); border-radius: 999px; background: #dff4ef; font-size: .72rem; font-weight: 800; text-transform: uppercase; }
.quote-summary dl { display: grid; gap: 9px; margin: 0; }
.quote-summary dl div { display: flex; justify-content: space-between; gap: 18px; padding-bottom: 8px; border-bottom: 1px solid rgba(8,126,139,.12); }
.quote-summary dt { color: var(--muted); font-size: .8rem; }
.quote-summary dd { margin: 0; font-size: .84rem; font-weight: 800; text-align: right; }
.quote-summary .quote-total { font-size: .95rem; }
.change-condition { margin: 14px 0 0; color: var(--navy-soft); font-size: .8rem; line-height: 1.5; }
.acceptance-row { display: grid; grid-template-columns: 22px 1fr; gap: 10px; align-items: start; margin-top: 18px; color: var(--navy-soft); font-size: .82rem; line-height: 1.45; }
.acceptance-row input { width: 18px; min-height: 18px; margin: 2px 0 0; accent-color: var(--teal); }
.change-review-actions { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; align-items: end; }
.change-review-actions .text-button { min-height: 48px; }
.change-confirm { width: 100%; }
.change-back-loading { margin-top: 18px; }
.change-response-step { display: grid; justify-items: center; gap: 13px; text-align: center; }
.change-response-step[hidden] { display: none; }
.change-response-icon { display: grid; width: 54px; height: 54px; place-items: center; color: #fff; border-radius: 50%; background: #16835d; font-size: 1.55rem; font-weight: 850; }
.change-response-step h3 { max-width: 22rem; margin: 0; font-size: 1.18rem; line-height: 1.35; }
.change-response-step p { margin: 0; color: var(--muted); font-size: .86rem; line-height: 1.55; white-space: pre-line; }
.change-response-step .primary-button { width: 100%; margin-top: 4px; }
.renewal-modal { width: min(560px, 100%); }
.renewal-summary { margin: 0 0 18px; border-top: 1px solid var(--border); }
.renewal-summary div { display: flex; justify-content: space-between; gap: 18px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.renewal-summary dt { color: var(--muted); font-size: .8rem; }
.renewal-summary dd { margin: 0; font-size: .84rem; font-weight: 800; text-align: right; }
.renewal-copy { color: var(--navy-soft); font-size: .88rem; line-height: 1.6; }
.renewal-copy p { margin: 0 0 12px; }

footer { padding: 20px; color: var(--muted); font-size: .74rem; text-align: center; }
noscript { display: block; padding: 16px; color: #fff; background: var(--danger); text-align: center; }

@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 520px) {
    .topbar { width: min(100% - 28px, 1120px); padding: 18px 0; }
    .content { margin-top: 8px; }
    .card { border-radius: 18px; }
    .brand small { display: none; }
    .subscriptions-list { grid-template-columns: 1fr; }
    .customer-tabs { align-items: stretch; }
    .customer-tab { padding: 10px 8px; font-size: .78rem; }
    .payments-table, .payments-table tbody, .payments-table tr, .payments-table td { display: block; }
    .payments-table thead { display: none; }
    .payments-table tr { padding: 10px 14px; border-bottom: 1px solid var(--border); }
    .payments-table tr:last-child { border-bottom: 0; }
    .payments-table td { display: grid; grid-template-columns: 8rem 1fr; gap: 12px; padding: 8px 0; border: 0; text-align: right; }
    .payments-table td::before { content: attr(data-label); color: var(--muted); font-weight: 700; text-align: left; }
    .payments-table td:nth-child(3) { text-align: right; }
    .payment-documents { justify-content: end; }
    .modal-backdrop { padding: 10px; place-items: end center; }
    .change-modal { max-height: calc(100vh - 20px); border-radius: 18px 18px 0 0; }
    .change-modal.is-response { padding: 30px 24px 24px; border-radius: 18px; }
    .change-current-summary { grid-template-columns: 1fr; }
    .change-review-quantities { grid-template-columns: 1fr; }
    .change-review-actions { grid-template-columns: 1fr; }
    .quote-heading, .quote-summary dl div { align-items: start; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
