:root {
    color-scheme: light;
    --ink: #1f2933;
    --muted: #657386;
    --line: #d8e0e7;
    --surface: #ffffff;
    --soft: #f4f7f8;
    --teal: #1b8a84;
    --teal-dark: #116761;
    --gold: #b7791f;
    --rose: #b8325f;
    --danger: #b42318;
    --focus: #2b6cb0;
    --shadow: 0 10px 28px rgba(31, 41, 51, 0.09);
}

* {
    box-sizing: border-box;
}

html {
    font-family: Arial, Helvetica, sans-serif;
    color: var(--ink);
    background: var(--soft);
    letter-spacing: 0;
}

body {
    margin: 0;
    min-width: 320px;
}

a {
    color: var(--teal-dark);
}

img {
    max-width: 100%;
}

.site-header,
.site-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 18px clamp(18px, 4vw, 48px);
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.site-footer {
    margin-top: 42px;
    border-top: 1px solid var(--line);
    border-bottom: 0;
    color: var(--muted);
    flex-wrap: wrap;
}

.site-footer div,
.site-footer nav,
.organisation-card,
.brand,
.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.site-footer div,
.organisation-card div,
.brand span {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
}

.brand {
    color: var(--ink);
    text-decoration: none;
}

.brand-logo {
    width: 48px;
    height: 48px;
}

.brand small,
.organisation-card span {
    color: var(--muted);
    font-size: 0.88rem;
}

.organisation-card img {
    width: 52px;
    height: 52px;
}

.header-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
}

.user-chip {
    padding: 8px 11px;
    background: #e8f4f2;
    color: var(--teal-dark);
    border-radius: 999px;
    font-size: 0.88rem;
}

.page-shell {
    width: min(1180px, calc(100% - 32px));
    margin: 28px auto 0;
}

.hero-strip,
.wizard-head,
.admin-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 22px;
}

.hero-strip h1,
.wizard-head h1,
.admin-head h1,
.panel h1,
.panel h2 {
    margin: 0;
    line-height: 1.12;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--gold);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
}

.hero-meta {
    color: var(--muted);
    text-align: right;
}

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

.form-card,
.panel,
.admin-card,
.permission-row {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.form-card {
    display: grid;
    grid-template-columns: 74px 1fr;
    gap: 16px;
    align-items: center;
    min-height: 132px;
    padding: 20px;
    text-decoration: none;
    color: var(--ink);
}

.form-card:hover,
.form-card:focus-visible {
    border-color: var(--teal);
    transform: translateY(-1px);
}

.form-card img {
    width: 74px;
    height: 74px;
}

.form-card strong {
    display: block;
    margin-bottom: 6px;
}

.form-card small {
    color: var(--muted);
    line-height: 1.35;
}

.panel {
    padding: clamp(18px, 3vw, 30px);
}

.admin-shell > .panel {
    padding: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
}

.admin-shell > .panel > h2 {
    margin-bottom: 14px;
}

.narrow-panel {
    max-width: 640px;
    margin-inline: auto;
}

.notice {
    display: grid;
    gap: 8px;
    padding: 14px;
    margin: 18px 0;
    background: #fff8e7;
    border: 1px solid #e8c878;
    border-radius: 8px;
}

.flash {
    padding: 12px 14px;
    margin-bottom: 18px;
    border-radius: 8px;
    background: #e8f4f2;
    border: 1px solid #9fd2cd;
}

.flash-error {
    background: #fff0f3;
    border-color: #e7a4b8;
    color: #8a1740;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    padding: 9px 15px;
    border: 1px solid var(--teal-dark);
    border-radius: 8px;
    background: var(--teal);
    color: #ffffff;
    text-decoration: none;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
}

.button:hover,
.button:focus-visible {
    background: var(--teal-dark);
}

.button-secondary {
    background: #ffffff;
    color: var(--teal-dark);
}

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

.button-small {
    min-height: 32px;
    padding: 6px 10px;
    font-size: 0.88rem;
}

.stacked-form,
.fields-grid,
.admin-card {
    display: grid;
    gap: 16px;
}

label span {
    display: block;
    margin-bottom: 6px;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    min-height: 42px;
    padding: 10px 11px;
    border: 1px solid #c8d2dc;
    border-radius: 8px;
    background: #ffffff;
    color: var(--ink);
    font: inherit;
}

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

input:focus,
select:focus,
textarea:focus {
    outline: 3px solid rgba(43, 108, 176, 0.18);
    border-color: var(--focus);
}

.field.invalid input,
.field.invalid select,
.field.invalid textarea,
.js-invalid {
    border-color: var(--danger);
}

.field-note,
.field-error {
    margin: 7px 0 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.field-error {
    color: var(--danger);
}

.wizard-form {
    margin-top: 14px;
}

.fields-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field,
.uploaded-list {
    min-width: 0;
}

.field:has(textarea),
.field:has(input[type="file"]),
.uploaded-list {
    grid-column: 1 / -1;
}

.choice-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.choice-list label,
.inline-choice {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 36px;
    padding: 7px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f9fbfb;
}

.choice-list input,
.inline-choice input,
.check-row input {
    width: auto;
    min-height: 0;
}

.stepper {
    display: flex;
    gap: 10px;
    padding: 0;
    margin: 0;
    list-style: none;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.stepper li {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
}

.stepper span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: #ffffff;
    font-weight: 700;
}

.stepper .active span {
    background: var(--teal);
    color: #ffffff;
    border-color: var(--teal);
}

.stepper .done span {
    background: #dceee9;
    color: var(--teal-dark);
}

.wizard-actions,
.row-actions,
.table-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.wizard-actions {
    justify-content: flex-end;
    margin-top: 22px;
}

.uploaded-list {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 12px;
    background: #f9fbfb;
    border: 1px dashed #b9c8d2;
    border-radius: 8px;
}

.upload-pill {
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #ffffff;
    padding: 7px 10px;
    cursor: pointer;
}

.tabs,
.subtabs {
    display: flex;
    gap: 8px;
    margin-bottom: 18px;
    overflow-x: auto;
}

.tabs a,
.subtabs a {
    flex: 0 0 auto;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    color: var(--ink);
    text-decoration: none;
}

.tabs a.active,
.subtabs a.active {
    border-color: var(--teal);
    color: var(--teal-dark);
    background: #e8f4f2;
}

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

.two-col {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.admin-card {
    padding: 16px;
    box-shadow: none;
}

.new-card {
    border-style: dashed;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.check-row label {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.wrap {
    align-items: flex-start;
}

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

.permission-row {
    display: grid;
    gap: 10px;
    padding: 14px;
    margin-bottom: 12px;
    box-shadow: none;
}

.table-wrap {
    overflow-x: auto;
}

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

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

th {
    background: #eef3f5;
    color: #334155;
    font-size: 0.88rem;
}

td a {
    display: inline-block;
    margin: 2px 8px 2px 0;
}

.raw-table input {
    min-width: 150px;
}

code {
    white-space: pre-wrap;
}

@media (max-width: 840px) {
    .site-header,
    .hero-strip,
    .wizard-head,
    .admin-head,
    .permission-grid {
        align-items: flex-start;
        flex-direction: column;
    }

    .organisation-card {
        align-items: flex-start;
    }

    .hero-meta {
        text-align: left;
    }

    .fields-grid,
    .two-col,
    .permission-grid {
        grid-template-columns: 1fr;
    }

    .form-card {
        grid-template-columns: 58px 1fr;
        min-height: 112px;
    }

    .form-card img {
        width: 58px;
        height: 58px;
    }
}

@media (max-width: 560px) {
    .page-shell {
        width: min(100% - 20px, 1180px);
    }

    .site-header,
    .site-footer {
        padding: 14px 12px;
    }

    .header-actions,
    .wizard-actions {
        width: 100%;
        justify-content: stretch;
    }

    .button,
    .header-actions .button {
        width: 100%;
    }
}
