:root {
    color-scheme: light;
    --bg: #f4f7fb;
    --panel: #ffffff;
    --text: #1f2937;
    --muted: #64748b;
    --line: #d8e0ea;
    --brand: #0f5d8f;
    --brand-dark: #0b4368;
    --danger-bg: #fff4f2;
    --danger: #a33a2c;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    font-size: clamp(2rem, 5vw, 3.5rem);
    line-height: 1;
    margin-bottom: 0;
}

h2 {
    font-size: 1.25rem;
    margin-bottom: 0;
}

button,
.button-link {
    appearance: none;
    border: 0;
    border-radius: 999px;
    background: var(--brand);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    min-height: 2.75rem;
    padding: 0.75rem 1.25rem;
    text-decoration: none;
}

button:hover,
.button-link:hover {
    background: var(--brand-dark);
}

button.secondary {
    background: #e8eef5;
    color: var(--brand-dark);
}

button.small {
    min-height: 2.25rem;
    padding: 0.45rem 0.75rem;
}

button.danger {
    background: var(--danger);
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

label {
    color: var(--muted);
    display: grid;
    font-size: 0.875rem;
    font-weight: 700;
    gap: 0.4rem;
}

input,
select {
    border: 1px solid var(--line);
    border-radius: 0.75rem;
    background: #fff;
    color: var(--text);
    font: inherit;
    min-height: 2.75rem;
    padding: 0.75rem 0.9rem;
}

input[type="checkbox"] {
    min-height: auto;
}

.password-control {
    align-items: center;
    display: flex;
    gap: 0.45rem;
    width: 100%;
}

.password-field {
    display: inline-flex;
    flex: 1;
    position: relative;
}

.password-field input {
    min-width: 12rem;
    padding-right: 3rem;
    width: 100%;
}

.password-toggle {
    background: transparent;
    border-radius: 0.6rem;
    color: var(--muted);
    height: 2.1rem;
    min-height: 0;
    padding: 0;
    position: absolute;
    right: 0.35rem;
    top: 50%;
    transform: translateY(-50%);
    width: 2.1rem;
}

.password-toggle:hover,
.password-toggle:focus {
    background: #e8eef5;
    color: var(--brand-dark);
}

.password-toggle svg {
    fill: none;
    height: 1.25rem;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
    width: 1.25rem;
}

.password-toggle-slash {
    display: none;
}

.password-toggle[aria-pressed="true"] .password-toggle-slash {
    display: block;
}

table {
    border-collapse: collapse;
    width: 100%;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 0.9rem 0;
    text-align: left;
}

th {
    color: var(--muted);
    font-size: 0.8rem;
    text-transform: uppercase;
}

.number {
    text-align: right;
}

.scenario-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.pill {
    background: #e8eef5;
    border-radius: 999px;
    color: var(--brand-dark);
    display: inline-flex;
    font-size: 0.82rem;
    font-weight: 700;
    padding: 0.25rem 0.6rem;
}

.auth-page {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 1rem;
}

.login-card,
.empty-state {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 1.5rem;
    box-shadow: 0 20px 60px rgb(15 45 70 / 10%);
    max-width: 28rem;
    padding: 2rem;
    width: 100%;
}

.login-card form {
    display: grid;
    gap: 1rem;
    margin-top: 1.5rem;
}

.top-nav {
    align-items: center;
    display: flex;
    gap: 1.5rem;
    justify-content: space-between;
    padding: 1rem clamp(1rem, 4vw, 3rem);
}

.site-header {
    padding: 1rem clamp(1rem, 4vw, 3rem) 2rem;
}

.header-actions,
.header-actions form {
    align-items: center;
    display: flex;
    gap: 0.75rem;
}

.dashboard {
    display: grid;
    gap: 1.25rem;
    padding: 0 clamp(1rem, 4vw, 3rem) 3rem;
}

.report-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.report-nav a {
    background: #e8eef5;
    border-radius: 999px;
    color: var(--brand-dark);
    font-weight: 800;
    padding: 0.7rem 1rem;
    text-decoration: none;
}

.report-nav a.active {
    background: var(--brand);
    color: #fff;
}

.panel,
.kpi-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 1.25rem;
    box-shadow: 0 14px 40px rgb(15 45 70 / 7%);
    padding: 1.25rem;
    position: relative;
}

.filters {
    align-items: end;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.checkbox-label {
    align-items: center;
    display: flex;
    flex-direction: row;
    gap: 0.45rem;
    min-height: 2.75rem;
}

.checkbox-label.compact {
    min-height: auto;
}

.inline-form {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.users-table td {
    vertical-align: middle;
}

.kpi-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.membership-kpis {
    grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
}

.kpi-card {
    display: grid;
    gap: 0.4rem;
}

.kpi-card span,
.eyebrow {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.kpi-card strong {
    color: var(--brand-dark);
    font-size: clamp(1.8rem, 3vw, 3rem);
    line-height: 1;
    overflow-wrap: anywhere;
}

.membership-kpis .kpi-card strong {
    font-size: clamp(1.65rem, 2.5vw, 2.75rem);
}

.kpi-card.primary {
    background: linear-gradient(135deg, #0f5d8f, #1582c5);
    color: #fff;
}

.kpi-card.primary span,
.kpi-card.primary strong,
.kpi-card.primary small {
    color: #fff;
}

.funnel-panel {
    overflow: hidden;
}

.funnel {
    align-items: center;
    display: grid;
    gap: 0.75rem;
    justify-items: center;
}

.funnel-step {
    background: linear-gradient(135deg, #0f5d8f, #1582c5);
    border-radius: 1rem;
    color: #fff;
    display: grid;
    gap: 0.35rem;
    justify-items: center;
    padding: 1.25rem;
    text-align: center;
}

.funnel-step span {
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.funnel-step strong {
    font-size: clamp(2.5rem, 6vw, 5rem);
    line-height: 1;
}

.funnel-step small {
    color: rgb(255 255 255 / 85%);
}

.funnel-step-top {
    width: min(100%, 42rem);
}

.funnel-step-bottom {
    background: linear-gradient(135deg, #0b4368, #0f5d8f);
    width: min(88%, 34rem);
}

.funnel-arrow {
    border-left: 1.1rem solid transparent;
    border-right: 1.1rem solid transparent;
    border-top: 1.2rem solid var(--brand);
    height: 0;
    width: 0;
}

.funnel-breakdown {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    justify-content: center;
    margin-top: 0.35rem;
}

.funnel-breakdown span {
    background: rgb(255 255 255 / 16%);
    border-radius: 999px;
    padding: 0.35rem 0.7rem;
}

.funnel-note {
    margin: 1rem 0 0;
    text-align: center;
}

.panel-header {
    align-items: center;
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.muted {
    color: var(--muted);
}

.alert {
    background: var(--danger-bg);
    border: 1px solid #f0c1b9;
    border-radius: 0.8rem;
    color: var(--danger);
    margin-bottom: 1rem;
    padding: 0.9rem 1rem;
}

.alert.success {
    background: #ecfdf3;
    border-color: #b6e7c8;
    color: #166534;
}

.debug-panel {
    border-style: dashed;
}

.debug-grid {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: 1rem;
}

.debug-grid div {
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 0.8rem;
    display: grid;
    gap: 0.25rem;
    padding: 0.8rem;
}

.debug-grid strong,
summary {
    color: var(--muted);
    font-size: 0.78rem;
    text-transform: uppercase;
}

details {
    border-top: 1px solid var(--line);
    padding: 0.9rem 0;
}

summary {
    cursor: pointer;
    font-weight: 800;
}

pre {
    background: #0f172a;
    border-radius: 0.8rem;
    color: #e2e8f0;
    overflow-x: auto;
    padding: 1rem;
    white-space: pre-wrap;
}

#renewals-chart {
    cursor: crosshair;
    display: block;
    width: 100%;
}

.chart-tooltip {
    background: #0f172a;
    border-radius: 0.75rem;
    box-shadow: 0 12px 24px rgb(15 23 42 / 20%);
    color: #fff;
    display: grid;
    gap: 0.2rem;
    opacity: 0;
    padding: 0.55rem 0.75rem;
    pointer-events: none;
    position: absolute;
    transform: translate(-50%, calc(-100% - 0.75rem));
    transition: opacity 120ms ease;
    z-index: 3;
}

.chart-tooltip strong,
.chart-tooltip span {
    white-space: nowrap;
}

.chart-tooltip span {
    color: #cbd5e1;
    font-size: 0.82rem;
}

.chart-tooltip.is-visible {
    opacity: 1;
}

@media (max-width: 760px) {
    .top-nav,
    .site-header,
    .header-actions {
        align-items: flex-start;
        flex-direction: column;
    }

    .kpi-grid {
        grid-template-columns: 1fr;
    }

    .debug-grid {
        grid-template-columns: 1fr;
    }
}

