:root {
    color-scheme: light;
    --page: #f3f6fa;
    --surface: #ffffff;
    --surface-soft: #f7f9fc;
    --ink: #172b3f;
    --muted: #5d6f82;
    --line: #d9e2ec;
    --brand: #173e67;
    --brand-hover: #0f3155;
    --focus: #e89a24;
    --success: #177245;
    --success-bg: #e8f6ef;
    --danger: #a22b2b;
    --danger-bg: #fff0f0;
    --warning: #7a5310;
    --warning-bg: #fff6df;
    --shadow: 0 18px 50px rgba(23, 62, 103, 0.12);
    --radius: 18px;
}

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

html {
    min-width: 320px;
    background: var(--page);
    -webkit-text-size-adjust: 100%;
}

body {
    min-height: 100vh;
    min-height: 100svh;
    margin: 0;
    color: var(--ink);
    background:
        radial-gradient(circle at 8% 0%, rgba(41, 112, 174, 0.13), transparent 34rem),
        var(--page);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
}

button,
input {
    font: inherit;
}

button,
input[type="file"] {
    cursor: pointer;
}

a {
    color: var(--brand);
}

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

h1 {
    margin-bottom: 0.75rem;
    font-size: clamp(1.75rem, 7vw, 2.5rem);
    line-height: 1.12;
    letter-spacing: -0.025em;
}

h2 {
    margin-bottom: 0.5rem;
    font-size: 1.25rem;
    line-height: 1.25;
}

.shell,
.admin-shell {
    width: min(100% - 2rem, 1120px);
    margin-inline: auto;
}

.shell {
    display: grid;
    min-height: 100vh;
    min-height: 100svh;
    align-content: center;
    padding-block: 2rem;
}

.admin-shell {
    padding-block: 1.25rem 3rem;
}

.card {
    border: 1px solid rgba(217, 226, 236, 0.9);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.access-card,
.login-card {
    width: min(100%, 31rem);
    margin-inline: auto;
    padding: clamp(1.4rem, 6vw, 2.4rem);
}

.brand-mark {
    display: grid;
    width: 3rem;
    height: 3rem;
    margin-bottom: 1.5rem;
    place-items: center;
    border-radius: 14px;
    color: #fff;
    background: var(--brand);
    font-size: 1.35rem;
    font-weight: 800;
    box-shadow: 0 8px 22px rgba(23, 62, 103, 0.24);
}

.eyebrow {
    margin-bottom: 0.45rem;
    color: var(--brand);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

.supporting,
.field-help,
.privacy-note,
.progress-text,
.upload-card p,
.history-card p {
    color: var(--muted);
}

.supporting {
    margin-bottom: 1.5rem;
}

.person-name {
    margin-bottom: 0.75rem;
    font-size: clamp(1.35rem, 5.5vw, 1.8rem);
    font-weight: 750;
    line-height: 1.25;
}

.stack {
    display: grid;
    gap: 0.8rem;
}

.secondary-action {
    margin-top: 0.75rem;
}

.field-label {
    color: var(--ink);
    font-size: 0.92rem;
    font-weight: 700;
}

.pin-input,
.text-input {
    width: 100%;
    min-height: 3.25rem;
    border: 1px solid #b9c7d5;
    border-radius: 12px;
    color: var(--ink);
    background: #fff;
    font-size: 16px;
    outline: none;
    transition: border-color 120ms ease, box-shadow 120ms ease;
}

.pin-input {
    padding: 0.7rem 0.85rem;
    font-size: clamp(1.35rem, 7vw, 1.8rem);
    font-variant-numeric: tabular-nums;
    font-weight: 750;
    letter-spacing: 0.1em;
    text-align: center;
}

.text-input {
    padding: 0.75rem 0.9rem;
}

.pin-input:focus,
.text-input:focus,
.file-picker:focus-within {
    border-color: var(--brand);
    box-shadow: 0 0 0 4px rgba(23, 62, 103, 0.14);
}

.field-help {
    margin-top: -0.35rem;
    font-size: 0.84rem;
}

.button {
    display: inline-flex;
    min-height: 3rem;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: 12px;
    padding: 0.72rem 1.1rem;
    font-weight: 750;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    transition: background-color 120ms ease, border-color 120ms ease, transform 120ms ease;
}

.button:hover:not(:disabled) {
    transform: translateY(-1px);
}

.button:focus-visible,
a:focus-visible,
input:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 3px;
}

.button:disabled {
    cursor: wait;
    opacity: 0.62;
}

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

.button-primary:hover:not(:disabled) {
    background: var(--brand-hover);
    border-color: var(--brand-hover);
}

.button-ghost {
    color: var(--brand);
    background: transparent;
    border-color: #b9c7d5;
}

.button-ghost:hover:not(:disabled) {
    background: var(--surface-soft);
}

.button-small {
    min-height: 2.55rem;
    padding: 0.55rem 0.85rem;
    font-size: 0.9rem;
}

.notice {
    margin-bottom: 1.25rem;
    border: 1px solid transparent;
    border-radius: 12px;
    padding: 0.85rem 1rem;
    overflow-wrap: anywhere;
}

.notice-error {
    border-color: #efb7b7;
    color: var(--danger);
    background: var(--danger-bg);
}

.notice-success {
    border-color: #addac3;
    color: var(--success);
    background: var(--success-bg);
}

.privacy-note {
    width: min(100%, 31rem);
    margin: 1rem auto 0;
    font-size: 0.8rem;
    text-align: center;
}

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

.admin-header h1 {
    margin-bottom: 0;
}

.admin-page .card {
    margin-bottom: 1rem;
    padding: 1.15rem;
    box-shadow: 0 10px 34px rgba(23, 62, 103, 0.08);
}

.login-card {
    margin-top: clamp(2rem, 12vh, 7rem);
}

.upload-card,
.batch-heading {
    display: grid;
    gap: 1rem;
}

.upload-card p {
    margin-bottom: 0;
}

.upload-form {
    display: grid;
    gap: 0.75rem;
}

.file-picker {
    display: grid;
    gap: 0.45rem;
    min-height: 3.25rem;
    align-content: center;
    border: 1px dashed #9db0c2;
    border-radius: 12px;
    padding: 0.75rem 0.9rem;
    color: var(--brand);
    background: var(--surface-soft);
    font-weight: 700;
}

.file-picker input {
    width: 100%;
    color: var(--muted);
    font-size: 0.86rem;
}

.batch-heading {
    align-items: start;
    margin-bottom: 1rem;
}

.batch-heading h2 {
    overflow-wrap: anywhere;
}

.status-badge,
.row-state {
    display: inline-flex;
    width: fit-content;
    border-radius: 999px;
    padding: 0.3rem 0.65rem;
    font-size: 0.76rem;
    font-weight: 800;
    line-height: 1.2;
    text-transform: lowercase;
}

.status-completed,
.state-ready {
    color: var(--success);
    background: var(--success-bg);
}

.status-processing,
.state-validated,
.state-wp_creating,
.state-wp_created,
.state-indigo_creating {
    color: var(--brand);
    background: #eaf2fa;
}

.status-partial,
.state-failed_wp,
.state-failed_indigo,
.state-conflict {
    color: var(--danger);
    background: var(--danger-bg);
}

.status-validated {
    color: var(--warning);
    background: var(--warning-bg);
}

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

.metrics div {
    display: grid;
    min-width: 0;
    gap: 0.1rem;
    border-radius: 12px;
    padding: 0.75rem;
    background: var(--surface-soft);
}

.metrics strong {
    font-size: clamp(1.2rem, 5vw, 1.7rem);
    font-variant-numeric: tabular-nums;
}

.metrics span {
    color: var(--muted);
    font-size: 0.75rem;
}

.progress-text {
    min-height: 1.5em;
    margin: 0.75rem 0 0;
    font-size: 0.9rem;
}

.table-wrap {
    max-width: 100%;
    margin-top: 1rem;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 12px;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    min-width: 760px;
    border-collapse: collapse;
    font-size: 0.86rem;
}

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

th {
    color: var(--muted);
    background: var(--surface-soft);
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

tbody tr:last-child td {
    border-bottom: 0;
}

td code {
    font-size: 0.82rem;
    overflow-wrap: anywhere;
}

td small {
    display: block;
    max-width: 18rem;
    margin-top: 0.35rem;
    color: var(--danger);
    line-height: 1.35;
}

.error-list {
    margin: 0.65rem 0 0;
    padding-left: 1.25rem;
}

.batch-list {
    display: grid;
    gap: 0.5rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.batch-list a {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    justify-content: space-between;
    border-radius: 10px;
    padding: 0.72rem 0.8rem;
    background: var(--surface-soft);
    text-decoration: none;
}

.batch-list a:hover {
    background: #edf3f9;
}

.batch-list span {
    min-width: 0;
    overflow-wrap: anywhere;
}

.batch-list strong {
    flex: 0 0 auto;
    font-variant-numeric: tabular-nums;
}

@media (min-width: 700px) {
    .admin-shell {
        padding-block: 2rem 4rem;
    }

    .admin-page .card {
        padding: 1.5rem;
    }

    .upload-card {
        grid-template-columns: minmax(0, 1fr) minmax(20rem, 0.9fr);
        align-items: center;
    }

    .upload-form {
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: end;
    }

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

    .metrics {
        width: min(100%, 34rem);
        gap: 0.75rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition: none !important;
    }
}

@media print {
    .button,
    .upload-card,
    .admin-header form {
        display: none !important;
    }

    body,
    .card {
        background: #fff;
        box-shadow: none;
    }
}
