:root {
    color-scheme: light;
    --bg: #f6f5f1;
    --ink: #15221f;
    --muted: #64716c;
    --panel: #ffffff;
    --line: #dde3dd;
    --green: #1f7a5f;
    --blue: #3157a4;
    --red: #a43131;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
    padding-bottom: env(safe-area-inset-bottom);
}

a {
    color: inherit;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: calc(.85rem + env(safe-area-inset-top)) max(1rem, calc((100vw - 1040px) / 2)) .85rem;
    background: rgba(246, 245, 241, .92);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(14px);
}

@media (display-mode: standalone) {
    .topbar {
        border-bottom-color: rgba(31, 122, 95, .22);
    }
}

.brand {
    font-weight: 800;
    text-decoration: none;
}

.nav {
    display: flex;
    align-items: center;
    gap: .35rem;
}

.nav a,
.nav button,
.button,
button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: .65rem .9rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    font: inherit;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

.nav form {
    margin: 0;
}

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

.danger {
    background: var(--red);
    border-color: var(--red);
    color: #fff;
}

.shell {
    width: min(1040px, calc(100% - 2rem));
    margin: 0 auto;
    padding: 1.4rem 0 4rem;
}

.hero-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin: 1rem 0 1.2rem;
}

h1,
h2 {
    margin: 0;
    line-height: 1.1;
}

h1 {
    font-size: clamp(2rem, 6vw, 3.5rem);
}

h2 {
    font-size: 1.25rem;
}

.eyebrow {
    margin: 0 0 .35rem;
    color: var(--muted);
    font-weight: 800;
    text-transform: uppercase;
    font-size: .78rem;
}

.auth-panel,
.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 1.1rem;
}

.auth-panel {
    width: min(440px, 100%);
    margin: 3rem auto;
}

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

label {
    display: grid;
    gap: .35rem;
    font-weight: 800;
}

input,
textarea,
select {
    width: 100%;
    min-height: 48px;
    padding: .75rem .85rem;
    border: 1px solid #cfd8d1;
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    font: inherit;
}

textarea {
    resize: vertical;
}

.flash {
    margin: 0 0 1rem;
    padding: .8rem 1rem;
    border-radius: 8px;
    font-weight: 700;
}

.flash.success {
    background: #e5f3eb;
    color: #164c37;
}

.flash.error {
    background: #f8e4e4;
    color: #7b1f1f;
}

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

.stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: .75rem;
    margin-bottom: .75rem;
}

.stats article {
    display: grid;
    gap: .25rem;
    padding: 1rem;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.stats span,
small {
    color: var(--muted);
}

.stats strong {
    font-size: 1.8rem;
}

.panel + .panel,
.admin-actions + .panel {
    margin-top: .75rem;
}

.panel-head {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
}

canvas {
    width: 100%;
    max-height: 360px;
}

.entry-list,
.table-list {
    display: grid;
    gap: .6rem;
}

.entry-item,
.user-row {
    display: grid;
    align-items: center;
    gap: .75rem;
    padding: .85rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    text-decoration: none;
}

.entry-item {
    grid-template-columns: 1fr auto auto;
}

.user-row {
    grid-template-columns: 2fr 1fr 1fr 1fr;
}

.user-row span:first-child {
    display: grid;
}

.photo-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: .8rem;
}

.file-box,
figure {
    margin: 0;
    display: grid;
    gap: .5rem;
}

.file-box,
figure .placeholder {
    padding: .75rem;
    border: 1px dashed #b7c5bc;
    border-radius: 8px;
    background: #fbfcfb;
}

.photo-grid img,
.placeholder {
    width: 100%;
    aspect-ratio: 3 / 4;
    object-fit: cover;
    border-radius: 8px;
    background: #edf1ee;
}

.placeholder {
    display: grid;
    place-items: center;
    color: var(--muted);
}

figcaption {
    color: var(--muted);
    font-weight: 700;
}

.admin-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: .75rem;
    margin-bottom: .75rem;
}

.install-banner {
    position: fixed;
    left: max(1rem, env(safe-area-inset-left));
    right: max(1rem, env(safe-area-inset-right));
    bottom: max(1rem, env(safe-area-inset-bottom));
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    width: min(560px, calc(100% - 2rem));
    margin: 0 auto;
    padding: .8rem;
    border: 1px solid rgba(31, 122, 95, .22);
    border-radius: 8px;
    background: rgba(255, 255, 255, .96);
    box-shadow: 0 16px 40px rgba(21, 34, 31, .18);
    backdrop-filter: blur(14px);
}

.install-banner p {
    margin: 0;
    font-weight: 800;
}

.install-actions {
    display: flex;
    gap: .5rem;
    flex-shrink: 0;
}

@media (max-width: 760px) {
    .topbar,
    .hero-row,
    .nav {
        align-items: stretch;
        flex-direction: column;
    }

    .nav {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(3, 1fr);
    }

    .nav form,
    .nav button {
        width: 100%;
    }

    .stats,
    .photo-grid,
    .admin-actions {
        grid-template-columns: 1fr;
    }

    .entry-item,
    .user-row {
        grid-template-columns: 1fr;
    }

    .hero-row .button {
        width: 100%;
    }

    .install-banner {
        align-items: stretch;
        flex-direction: column;
    }

    .install-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }
}
