:root {
    color-scheme: light;
    --bg: #f7f7f4;
    --panel: #ffffff;
    --text: #202124;
    --muted: #5f6368;
    --line: #d8ddd7;
    --accent: #26735b;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    min-height: 64px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    background: var(--panel);
}

.brand {
    color: var(--text);
    font-weight: 800;
    text-decoration: none;
}

.app-nav {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    flex-wrap: wrap;
}

.app-nav a {
    color: var(--accent);
    font-weight: 700;
    text-decoration: none;
}

.link-button {
    border: 0;
    background: transparent;
    color: var(--accent);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.app-main,
.page {
    padding: 24px 16px;
}

.app-main {
    flex: 1;
    width: 100%;
}

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

.auth-panel,
.status-panel,
.page-section {
    width: min(100%, 720px);
    margin-inline: auto;
}

.page-section-wide {
    width: min(100%, 860px);
}

.auth-panel,
.status-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 18px 40px rgb(32 33 36 / 8%);
}

.auth-panel:not(.form-panel) {
    width: min(100%, 440px);
}

.form-panel {
    width: min(100%, 720px);
    margin: 0 auto;
}

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

h1 {
    margin: 0 0 12px;
    font-size: clamp(2rem, 10vw, 3rem);
    line-height: 1.05;
}

.form-panel h1,
.auth-panel h1 {
    font-size: clamp(1.75rem, 7vw, 2.35rem);
}

p {
    margin: 0;
    color: var(--muted);
}

.lead {
    max-width: 62ch;
    margin-top: 8px;
}

.form-stack {
    display: grid;
    gap: 16px;
    margin-top: 24px;
}

label {
    display: grid;
    gap: 8px;
    color: var(--muted);
    font-weight: 700;
}

input,
select {
    width: 100%;
    min-height: 48px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--text);
    font: inherit;
}

textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--text);
    font: inherit;
    resize: vertical;
}

.primary-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    border: 0;
    border-radius: 8px;
    padding: 10px 14px;
    background: var(--accent);
    color: #ffffff;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
}

.secondary-button,
.secondary-link {
    color: var(--accent);
    font: inherit;
    font-weight: 800;
    text-align: center;
    text-decoration: none;
}

.secondary-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    border: 1px solid var(--accent);
    border-radius: 8px;
    padding: 10px 14px;
    background: var(--panel);
}

.danger-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 48px;
    border: 1px solid #b5472f;
    border-radius: 8px;
    padding: 10px 14px;
    background: #fff8f5;
    color: #8f2d18;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
}

.flash {
    width: min(100%, 720px);
    margin: 0 auto 16px;
    border-radius: 8px;
    padding: 12px 14px;
    font-weight: 700;
}

.flash-danger {
    background: #fde8e2;
    color: #8f2d18;
}

.flash-success {
    background: #e4f4ea;
    color: #1f6b43;
}

.status-grid {
    display: grid;
    gap: 12px;
    margin-top: 24px;
}

.status-grid article {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.status-grid span {
    color: var(--muted);
    font-weight: 700;
}

.action-row {
    display: grid;
    gap: 12px;
    margin-top: 24px;
}

.compact-actions {
    align-content: start;
}

.page-heading,
.section-heading {
    display: grid;
    gap: 16px;
    margin-bottom: 24px;
}

.card-list {
    display: grid;
    gap: 14px;
}

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

.entity-card,
.timeline-item,
.empty-state,
.content-block {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    padding: 16px;
}

.entity-card {
    display: grid;
    gap: 16px;
}

.timeline-item {
    display: grid;
    gap: 14px;
    border-left: 4px solid var(--accent);
}

.entity-card h2,
.entity-card h3,
.timeline-item h3,
.content-block h2,
.section-heading h2 {
    margin: 0 0 6px;
    font-size: 1.2rem;
    line-height: 1.2;
}

.content-block {
    display: grid;
    gap: 14px;
    margin-top: 18px;
}

.empty-state {
    display: grid;
    gap: 6px;
}

.empty-state strong {
    font-size: 1.05rem;
}

.inline-actions {
    display: grid;
    gap: 10px;
}

.inline-actions form {
    display: grid;
}

.compact-meta {
    margin: 0;
}

.compact-meta div {
    padding-top: 0;
}

.meta-line {
    margin-top: 8px;
    font-weight: 700;
}

.qr-panel {
    display: grid;
    gap: 16px;
    align-items: center;
}

.qr-code-frame {
    width: min(100%, 220px);
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
}

.qr-code-frame svg {
    display: block;
    width: 100%;
    height: auto;
}

.qr-code-frame-large {
    width: min(100%, 320px);
    margin-inline: auto;
}

.qr-link-text {
    margin-top: 8px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f7f9f7;
    color: var(--text);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 0.82rem;
    overflow-wrap: anywhere;
}

.qr-print-page {
    width: min(100%, 640px);
}

.qr-print-card {
    justify-items: center;
    text-align: center;
}

.qr-print-actions {
    justify-content: center;
}

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

dl {
    display: grid;
    gap: 12px;
    margin: 24px 0 0;
}

dl div {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
}

dt {
    color: var(--muted);
    font-weight: 600;
}

dd {
    margin: 0;
    font-weight: 700;
    overflow-wrap: anywhere;
    text-align: right;
}

.app-footer {
    display: flex;
    justify-content: center;
    gap: 8px 14px;
    flex-wrap: wrap;
    padding: 14px 16px 18px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.82rem;
    background: var(--bg);
}

@media (min-width: 720px) {
    .app-main,
    .page {
        padding: 32px 24px;
    }

    .auth-panel,
    .status-panel {
        padding: 24px;
    }

    .page-heading,
    .section-heading {
        grid-template-columns: 1fr auto;
        align-items: start;
    }

    .inline-actions,
    .action-row.compact-actions {
        display: flex;
        align-items: center;
        flex-wrap: wrap;
    }

    .inline-actions form {
        display: inline-grid;
    }

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

    .qr-panel {
        grid-template-columns: auto 1fr;
    }
}

@media print {
    body,
    .app-main {
        background: #ffffff;
    }

    .app-header,
    .app-footer,
    .flash,
    .qr-print-actions {
        display: none !important;
    }

    .app-main {
        padding: 0;
    }

    .content-block.qr-print-card {
        border: 0;
        box-shadow: none;
    }

    .qr-print-page {
        width: 100%;
    }
}
