:root {
    --teal: #2c4f5f;
    --teal-dark: #193945;
    --aqua: #64bfb9;
    --aqua-soft: #dff3f1;
    --ink: #1f3037;
    --muted: #61727a;
    --paper: #ffffff;
    --canvas: #f4f6f5;
    --line: #dce4e3;
    --danger: #a33b45;
    --warning: #a36115;
    --success: #26735f;
    --shadow: 0 16px 45px rgba(25, 57, 69, 0.1);
    --radius: 18px;
    --small-radius: 11px;
    --content: min(1120px, calc(100vw - 32px));
    --client-content: min(720px, calc(100vw - 28px));
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    color-scheme: light;
    scroll-behavior: smooth;
}

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

button,
input,
select,
textarea {
    color: inherit;
    font: inherit;
}

a {
    color: var(--teal);
    text-underline-offset: 0.2em;
}

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

h1,
h2,
h3 {
    color: var(--teal-dark);
    letter-spacing: -0.035em;
    line-height: 1.12;
}

h1 {
    margin-bottom: 16px;
    font-size: clamp(2rem, 7vw, 3.5rem);
}

h2 {
    margin-bottom: 12px;
    font-size: clamp(1.45rem, 4vw, 2rem);
}

h3 {
    margin-bottom: 8px;
    font-size: 1.08rem;
}

:focus-visible {
    outline: 3px solid var(--aqua);
    outline-offset: 3px;
}

.skip-link {
    position: fixed;
    top: 8px;
    left: 8px;
    z-index: 1000;
    padding: 10px 14px;
    border-radius: 8px;
    background: var(--teal-dark);
    color: #fff;
    transform: translateY(-150%);
}

.skip-link:focus {
    transform: translateY(0);
}

.app-shell {
    width: var(--content);
    margin-inline: auto;
}

.client-shell {
    width: var(--client-content);
    margin-inline: auto;
}

.app-header,
.client-header {
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.96);
}

.app-header__inner,
.client-header__inner {
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.app-brand,
.client-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--teal-dark);
    font-weight: 800;
    text-decoration: none;
}

.brand-mark {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: 11px;
    background: var(--teal);
    color: #fff;
    font-size: 0.9rem;
}

.brand-logo {
    width: auto;
    max-width: 160px;
    height: 36px;
    object-fit: contain;
}

.app-nav {
    display: flex;
    align-items: center;
    gap: 4px;
}

.app-nav a,
.nav-button {
    padding: 10px 12px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 700;
    text-decoration: none;
}

.app-nav a:hover,
.app-nav a[aria-current="page"],
.nav-button:hover {
    background: var(--aqua-soft);
    color: var(--teal-dark);
}

.app-main {
    padding-block: clamp(28px, 6vw, 64px);
}

.page-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 28px;
}

.page-heading h1 {
    margin-bottom: 6px;
    font-size: clamp(2rem, 5vw, 3rem);
}

.eyebrow {
    margin-bottom: 8px;
    color: var(--success);
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

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

.hint {
    margin: 6px 0 0;
    font-size: 0.86rem;
}

.button {
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 19px;
    border: 1px solid var(--teal);
    border-radius: 12px;
    background: var(--teal);
    color: #fff;
    cursor: pointer;
    font-weight: 800;
    line-height: 1.2;
    text-decoration: none;
}

.button:hover {
    border-color: var(--teal-dark);
    background: var(--teal-dark);
}

.button--secondary {
    border-color: var(--line);
    background: var(--paper);
    color: var(--teal-dark);
}

.button--secondary:hover {
    border-color: var(--aqua);
    background: var(--aqua-soft);
}

.button--quiet {
    min-height: 40px;
    padding: 8px 12px;
    border-color: transparent;
    background: transparent;
    color: var(--teal);
}

.button--danger {
    border-color: #f2d8db;
    background: #fff7f8;
    color: var(--danger);
}

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

.card {
    padding: clamp(20px, 4vw, 32px);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--paper);
    box-shadow: var(--shadow);
}

.card + .card {
    margin-top: 18px;
}

.stat-grid,
.dashboard-grid,
.summary-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.stat-grid + section {
    margin-top: 36px;
}

.stat {
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: var(--small-radius);
    background: var(--paper);
}

.stat span {
    display: block;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 700;
}

.stat strong {
    display: block;
    margin-top: 6px;
    color: var(--teal-dark);
    font-size: 1.65rem;
}

.stat .stat-date {
    font-size: 1.15rem;
}

.case-list {
    display: grid;
    gap: 10px;
    margin-top: 22px;
}

.case-row {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(120px, 0.6fr) minmax(140px, 0.7fr) auto;
    align-items: center;
    gap: 18px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: var(--paper);
    color: inherit;
    text-decoration: none;
}

.case-row:hover {
    border-color: var(--aqua);
    box-shadow: 0 8px 24px rgba(25, 57, 69, 0.08);
}

.case-row strong,
.case-row span {
    display: block;
}

.case-row small {
    color: var(--muted);
}

.status {
    width: fit-content;
    display: inline-flex;
    align-items: center;
    padding: 5px 9px;
    border-radius: 999px;
    background: #edf1f1;
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 800;
    text-transform: capitalize;
}

.status--submitted {
    background: #e2f3ec;
    color: var(--success);
}

.status--in_progress,
.status--invited {
    background: #fff1da;
    color: var(--warning);
}

.empty-state {
    padding: 44px 22px;
    border: 1px dashed #c7d3d2;
    border-radius: var(--radius);
    text-align: center;
}

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

.field {
    min-width: 0;
}

.field--wide {
    grid-column: 1 / -1;
}

.field label,
.field-label {
    display: block;
    margin-bottom: 7px;
    color: var(--teal-dark);
    font-size: 0.9rem;
    font-weight: 800;
}

input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
    width: 100%;
    min-height: 50px;
    padding: 11px 13px;
    border: 1px solid #bbc9c8;
    border-radius: 10px;
    background: #fff;
}

textarea {
    min-height: 110px;
    resize: vertical;
}

input:hover,
select:hover,
textarea:hover {
    border-color: #829b99;
}

.check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
}

.check input {
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
    margin-top: 2px;
    accent-color: var(--teal);
}

.alert {
    margin-bottom: 18px;
    padding: 13px 15px;
    border: 1px solid #c8e1dc;
    border-radius: 10px;
    background: #edf8f5;
    color: #1e5d50;
}

.alert--error {
    border-color: #efc8cc;
    background: #fff5f6;
    color: var(--danger);
}

.alert p:last-child {
    margin-bottom: 0;
}

.magic-link {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.magic-link input {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.78rem;
}

.client-body {
    background:
        radial-gradient(circle at 90% 0%, var(--aqua-soft), transparent 34%),
        var(--canvas);
}

.case-heading {
    margin-top: 16px;
}

.chart-grid {
    margin-top: 22px;
}

.discussion-card {
    margin-top: 22px;
}

.discussion-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 18px;
}

.discussion-point {
    padding: 16px;
    border: 1px solid var(--line);
    border-left: 4px solid var(--aqua);
    border-radius: 10px;
    background: #f8fbfa;
}

.discussion-point--attention {
    border-left-color: #d9a85e;
    background: #fffaf2;
}

.discussion-point h3 {
    font-size: 1rem;
}

.discussion-point p {
    margin-bottom: 7px;
    color: var(--muted);
    font-size: 0.88rem;
}

.discussion-point small {
    color: var(--teal-dark);
    font-weight: 800;
}

.chart-card h2 {
    font-size: 1.25rem;
}

.donut {
    width: min(200px, 70%);
    display: grid;
    margin: 20px auto;
    aspect-ratio: 1;
    place-items: center;
    border-radius: 50%;
}

.donut::before {
    width: 58%;
    aspect-ratio: 1;
    border-radius: 50%;
    background: #fff;
    content: "";
    grid-area: 1 / 1;
}

.donut > span {
    z-index: 1;
    display: grid;
    grid-area: 1 / 1;
    color: var(--teal-dark);
    font-size: 1.2rem;
    font-weight: 900;
    text-align: center;
}

.donut small {
    color: var(--muted);
    font-size: 0.7rem;
    font-weight: 600;
}

.chart-legend {
    display: grid;
    gap: 7px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.chart-legend li {
    display: grid;
    grid-template-columns: 10px 1fr auto;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
}

.chart-legend i {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.bar-chart {
    display: grid;
    gap: 24px;
    margin-top: 28px;
}

.bar-chart > div {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 7px;
    font-size: 0.85rem;
}

.bar-chart i {
    height: 14px;
    grid-column: 1 / -1;
    overflow: hidden;
    border-radius: 999px;
    background: #edf1f1;
}

.bar-chart b {
    min-width: 2px;
    height: 100%;
    display: block;
    border-radius: inherit;
    background: var(--aqua);
}

.bar-chart .bar--debt {
    background: #d98572;
}

.bar-chart .bar--spend {
    background: #d9a85e;
}

.case-data h2 {
    font-size: 1.4rem;
}

.data-table {
    display: grid;
}

.data-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 16px;
    padding: 13px 0;
    border-top: 1px solid var(--line);
}

.data-row:first-child {
    border-top: 0;
}

.data-row span,
.data-row small {
    display: block;
}

.data-row small {
    color: var(--muted);
}

.note-list {
    display: grid;
    gap: 10px;
    margin-top: 24px;
}

.note-list article {
    padding: 15px;
    border-left: 3px solid var(--aqua);
    border-radius: 0 9px 9px 0;
    background: #f5f9f8;
}

.note-list article p {
    margin-bottom: 5px;
}

.note-list small {
    color: var(--muted);
}

.settings-nav {
    display: flex;
    gap: 8px;
    margin-bottom: 18px;
}

.settings-nav a {
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    font-size: 0.82rem;
    font-weight: 800;
    text-decoration: none;
}

.settings-section {
    scroll-margin-top: 18px;
}

.admin-list,
.rule-list {
    display: grid;
    gap: 10px;
    margin-block: 18px;
}

.admin-row,
.rule-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 14px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: #fbfcfc;
}

.admin-row span,
.admin-row small,
.rule-row small {
    display: block;
}

.admin-row small,
.rule-row small {
    color: var(--muted);
}

.rule-row {
    grid-template-columns: minmax(0, 1fr) auto;
}

.rule-row > label:last-child {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 0.82rem;
    font-weight: 800;
}

.rule-row input[type="number"] {
    width: 86px;
    min-height: 42px;
}

@media (max-width: 760px) {
    .settings-nav {
        overflow-x: auto;
    }

    .settings-nav a {
        white-space: nowrap;
    }

    .admin-row,
    .rule-row {
        grid-template-columns: 1fr;
        align-items: start;
    }
}

.client-header {
    position: sticky;
    top: 0;
    z-index: 20;
}

.client-progress {
    height: 4px;
    background: #e8eeee;
}

.client-progress span {
    height: 100%;
    display: block;
    background: var(--tenant-accent, var(--aqua));
    transition: width 250ms ease;
}

.client-main {
    padding-block: clamp(26px, 6vw, 58px) 80px;
}

.client-intro {
    margin-bottom: 24px;
}

.client-intro h1 {
    max-width: 16ch;
}

.client-intro > p:not(.eyebrow) {
    max-width: 58ch;
    color: var(--muted);
    font-size: 1.05rem;
}

.trust-list {
    display: grid;
    gap: 13px;
    margin: 26px 0;
    padding: 0;
    list-style: none;
}

.trust-list li {
    display: flex;
    align-items: flex-start;
    gap: 11px;
}

.trust-list li::before {
    width: 24px;
    height: 24px;
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    border-radius: 50%;
    background: var(--aqua-soft);
    color: var(--teal);
    content: "✓";
    font-size: 0.8rem;
    font-weight: 900;
}

.client-card {
    padding: clamp(20px, 5vw, 38px);
    border: 1px solid var(--line);
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: var(--shadow);
}

.client-card__section + .client-card__section {
    margin-top: 28px;
    padding-top: 28px;
    border-top: 1px solid var(--line);
}

.client-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 26px;
}

.autosave-status {
    min-height: 22px;
    color: var(--muted);
    font-size: 0.78rem;
}

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

.choice {
    position: relative;
    display: block;
}

.choice input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.choice span {
    min-height: 132px;
    display: block;
    padding: 20px;
    border: 2px solid var(--line);
    border-radius: 14px;
    background: #fff;
    cursor: pointer;
}

.choice strong,
.choice small {
    display: block;
}

.choice small {
    margin-top: 7px;
    color: var(--muted);
}

.choice input:checked + span {
    border-color: var(--tenant-accent, var(--aqua));
    background: var(--aqua-soft);
}

.choice input:focus-visible + span {
    outline: 3px solid var(--aqua);
    outline-offset: 3px;
}

.recommended {
    display: inline-block;
    margin-bottom: 8px;
    color: var(--success);
    font-size: 0.7rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

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

.repeat-row {
    position: relative;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fbfcfc;
}

.repeat-row .button--danger {
    position: absolute;
    top: 8px;
    right: 8px;
    min-height: 34px;
    padding: 6px 9px;
    font-size: 0.75rem;
}

.repeat-row .field-label {
    padding-right: 60px;
}

.section-details {
    margin-top: 12px;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: #fff;
}

.section-details summary {
    padding: 17px;
    color: var(--teal-dark);
    cursor: pointer;
    font-weight: 800;
}

.section-details__body {
    display: grid;
    gap: 15px;
    padding: 0 17px 18px;
}

.money-field {
    position: relative;
}

.money-field::before {
    position: absolute;
    top: 13px;
    left: 13px;
    color: var(--muted);
    content: "£";
    font-weight: 800;
}

.money-field input {
    padding-left: 29px !important;
}

.not-sure {
    margin-top: 7px;
    font-size: 0.82rem;
}

.review-section {
    padding: 18px 0;
    border-top: 1px solid var(--line);
}

.review-section:first-child {
    padding-top: 0;
    border-top: 0;
}

.review-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.review-heading a {
    font-size: 0.85rem;
    font-weight: 800;
}

.summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 22px 0;
}

.summary-figure {
    padding: 16px;
    border-radius: 12px;
    background: #f4f8f7;
}

.summary-figure span,
.summary-figure strong {
    display: block;
}

.summary-figure span {
    color: var(--muted);
    font-size: 0.8rem;
}

.summary-figure strong {
    margin-top: 4px;
    color: var(--teal-dark);
    font-size: 1.35rem;
}

.start-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(circle at 12% 16%, #dff3f1, transparent 32%),
        var(--canvas);
}

.start-panel {
    width: min(520px, 100%);
    padding: clamp(26px, 6vw, 46px);
    border: 1px solid var(--line);
    border-radius: 24px;
    background: #fff;
    box-shadow: var(--shadow);
    text-align: center;
}

.loading-mark {
    width: 48px;
    height: 48px;
    margin: 0 auto 20px;
    border: 4px solid var(--aqua-soft);
    border-top-color: var(--aqua);
    border-radius: 50%;
    animation: spin 900ms linear infinite;
}

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

.app-footer,
.client-footer {
    padding-block: 28px;
    color: var(--muted);
    font-size: 0.82rem;
    text-align: center;
}

.app-footer p,
.client-footer p {
    margin-bottom: 7px;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 18px;
}

.legal-page {
    max-width: 860px;
}

.legal-page h1 {
    margin-bottom: 6px;
}

.legal-page h2 {
    margin-top: 34px;
    font-size: 1.35rem;
}

.legal-page p,
.legal-page li {
    max-width: 74ch;
}

.legal-updated {
    color: var(--muted);
    font-size: 0.86rem;
}

.legal-summary {
    margin-block: 26px;
    padding: 20px;
    border-left: 4px solid var(--aqua);
    border-radius: 0 12px 12px 0;
    background: var(--aqua-soft);
}

.legal-summary p:last-child {
    margin-bottom: 0;
}

.cookie-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.cookie-card {
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fbfcfc;
}

.cookie-card h3 {
    margin-bottom: 15px;
}

.cookie-card dl,
.cookie-card dd {
    margin: 0;
}

.cookie-card dl {
    display: grid;
    gap: 13px;
}

.cookie-card dt {
    color: var(--teal-dark);
    font-size: 0.82rem;
    font-weight: 800;
}

.cookie-card dd {
    margin-top: 2px;
    color: var(--ink);
    font-size: 0.9rem;
}

[hidden] {
    display: none !important;
}

@media (max-width: 760px) {
    .app-header__inner {
        min-height: 64px;
        align-items: flex-start;
        flex-direction: column;
        padding-block: 12px;
    }

    .app-nav {
        width: 100%;
        overflow-x: auto;
        padding-bottom: 2px;
    }

    .app-nav a {
        white-space: nowrap;
    }

    .page-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .stat-grid,
    .dashboard-grid,
    .discussion-list {
        grid-template-columns: 1fr;
    }

    .case-row {
        grid-template-columns: 1fr auto;
        gap: 10px;
    }

    .case-row > :nth-child(2),
    .case-row > :nth-child(3) {
        grid-column: 1;
    }

    .case-row > :last-child {
        grid-column: 2;
        grid-row: 1;
    }

    .form-grid,
    .choice-grid,
    .repeat-row {
        grid-template-columns: 1fr;
    }

    .cookie-list {
        grid-template-columns: 1fr;
    }

    .client-body .app-header__inner {
        min-height: 64px;
        align-items: center;
        flex-direction: row;
        padding-block: 8px;
    }

    .client-body .app-nav {
        width: auto;
    }

    .client-actions {
        align-items: stretch;
        flex-direction: column-reverse;
    }

    .client-actions .button {
        width: 100%;
    }

    .magic-link {
        align-items: stretch;
        flex-direction: column;
    }
}

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