:root {
    color-scheme: light;
    --ink: #052f35;
    --teal: #06363a;
    --green: #9ce600;
    --green-dark: #6fa900;
    --paper: #f5f8f3;
    --white: #ffffff;
    --muted: #5c6e70;
    --danger: #a72b25;
    --shadow: 0 18px 48px rgba(4, 47, 53, 0.12);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--paper);
}

body {
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;
    color: var(--ink);
    background:
        radial-gradient(circle at 90% 0%, rgba(156, 230, 0, 0.15), transparent 28rem),
        var(--paper);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

.app-shell {
    min-height: 100vh;
    min-height: 100dvh;
}

.app-shell.booting {
    visibility: hidden;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 6.5rem;
    padding: max(0.75rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) 0.75rem max(1rem, env(safe-area-inset-left));
    background: rgba(255, 255, 255, 0.92);
    border-bottom: 1px solid rgba(5, 47, 53, 0.1);
    backdrop-filter: blur(14px);
}

.brand {
    display: flex;
    align-items: center;
    min-width: 0;
    color: inherit;
    text-decoration: none;
}

.brand__logo {
    width: clamp(4.25rem, 16vw, 6rem);
    height: clamp(4.25rem, 16vw, 6rem);
    object-fit: contain;
    flex: 0 0 auto;
}

.brand__title {
    margin-left: clamp(0.4rem, 2vw, 1rem);
    font-size: clamp(1rem, 4.4vw, 1.75rem);
    font-weight: 850;
    line-height: 1;
    letter-spacing: -0.035em;
    white-space: nowrap;
}

.brand__title.reveal {
    animation: title-reveal 420ms ease-out both;
}

.main-content {
    display: grid;
    place-items: start center;
    padding: clamp(2rem, 8vw, 5rem) 1rem;
}

.card {
    width: min(100%, 32rem);
    padding: clamp(1.4rem, 5vw, 2.25rem);
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(5, 47, 53, 0.1);
    border-radius: 1.5rem;
    box-shadow: var(--shadow);
}

.card h1 {
    margin: 0 0 0.8rem;
    font-size: clamp(1.8rem, 7vw, 2.6rem);
    line-height: 1.05;
    letter-spacing: -0.045em;
}

.card p {
    color: var(--muted);
    line-height: 1.55;
}

.eyebrow {
    margin: 0 0 0.5rem;
    color: var(--green-dark) !important;
    font-size: 0.78rem;
    font-weight: 850;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.stacked-form {
    display: grid;
    gap: 1rem;
    margin-top: 1.5rem;
}

.stacked-form label {
    display: grid;
    gap: 0.45rem;
    font-weight: 750;
}

.stacked-form input,
.stacked-form select,
.stacked-form textarea {
    width: 100%;
    min-height: 3.4rem;
    padding: 0.75rem 0.9rem;
    color: var(--ink);
    background: var(--white);
    border: 2px solid #bdcbca;
    border-radius: 0.8rem;
    outline: none;
}

.stacked-form textarea {
    min-height: 6rem;
    resize: vertical;
}

.stacked-form input:focus,
.stacked-form select:focus,
.stacked-form textarea:focus {
    border-color: var(--green-dark);
    box-shadow: 0 0 0 4px rgba(156, 230, 0, 0.22);
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 3.25rem;
    padding: 0.7rem 1.15rem;
    color: inherit;
    text-decoration: none;
    border: 0;
    border-radius: 0.8rem;
    font-weight: 850;
    cursor: pointer;
}

.button--primary {
    color: var(--teal);
    background: var(--green);
    box-shadow: 0 8px 18px rgba(111, 169, 0, 0.2);
}

.button--quiet {
    min-height: 2.75rem;
    color: var(--teal);
    background: #e9f0eb;
}

.button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.alert {
    width: min(100%, 32rem);
    margin-bottom: 1rem;
    padding: 0.9rem 1rem;
    color: var(--danger);
    background: #fff2f0;
    border: 1px solid #efc2bd;
    border-radius: 0.8rem;
    font-weight: 700;
}

.alert--success {
    color: #275c18;
    background: #effbe9;
    border-color: #b9dfa9;
}

.credential-card {
    width: min(100%, 46rem);
    margin-bottom: 1.25rem;
    padding: 1.25rem;
    color: var(--ink);
    background: #effbe9;
    border: 2px solid #83bb68;
    border-radius: 1rem;
}

.credential-card h2 {
    margin: 0 0 0.8rem;
}

.credential-card dl {
    display: grid;
    gap: 0.6rem;
}

.credential-card dl div {
    display: grid;
    grid-template-columns: 10rem 1fr;
    gap: 0.75rem;
}

.credential-card dt {
    font-weight: 800;
}

.credential-card dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.locations-page {
    width: min(100%, 72rem);
}

.page-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.page-heading h1 {
    margin: 0;
    font-size: clamp(2rem, 7vw, 3.5rem);
    letter-spacing: -0.05em;
}

.page-heading p:not(.eyebrow) {
    margin-bottom: 0;
    color: var(--muted);
}

.location-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
    align-items: start;
}

.stacked-form fieldset {
    min-width: 0;
    margin: 0;
    padding: 1rem;
    border: 1px solid #d5e0da;
    border-radius: 1rem;
}

.stacked-form legend {
    padding: 0 0.4rem;
    font-size: 1rem;
    font-weight: 850;
}

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

.form-grid__wide {
    grid-column: 1 / -1;
}

.location-grid .card {
    width: 100%;
}

.location-form-card {
    width: 100%;
}

.location-grid h2 {
    margin-top: 0;
}

.optional,
.form-hint {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 500;
}

.form-hint {
    margin: -0.35rem 0 0 !important;
}

.location-list {
    display: grid;
    gap: 0.8rem;
}

.location-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem;
    background: #f3f7f4;
    border: 1px solid #dbe5df;
    border-radius: 1rem;
}

.location-row h3,
.location-row p {
    margin: 0 0 0.35rem;
}

.location-actions,
.form-actions {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.immutable-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.25rem;
    margin-bottom: 1rem;
    padding: 0.75rem;
    color: var(--muted);
    background: #eef3ef;
    border-radius: 0.75rem;
    font-size: 0.86rem;
}

.location-row p {
    font-size: 0.85rem;
    overflow-wrap: anywhere;
}

.status {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 850;
}

.status--active {
    color: #275c18;
    background: #dff6d5;
}

.status--inactive {
    color: #6d4b17;
    background: #f5e6cb;
}

.splash {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: none;
    place-items: center;
    overflow: hidden;
    background: var(--white);
}

.splash__logo {
    width: min(82vw, 34rem);
    height: min(82vw, 34rem);
    object-fit: contain;
    transform-origin: top left;
    will-change: transform;
}

@keyframes title-reveal {
    from { opacity: 0; transform: translateX(-0.8rem); }
    to { opacity: 1; transform: translateX(0); }
}

@media (max-width: 1024px), (pointer: coarse) {
    .splash.active {
        display: grid;
    }

    .brand__logo {
        width: clamp(4.25rem, 16vw, 8rem);
        height: clamp(4.25rem, 16vw, 8rem);
    }

    .brand__title.boot-hidden {
        opacity: 0;
    }
}

@media (max-width: 520px) {
    .app-header {
        min-height: 5.4rem;
    }

    .brand__logo {
        width: 4.25rem;
        height: 4.25rem;
    }

    .logout-form .button {
        min-height: 2.6rem;
        padding-inline: 0.75rem;
        font-size: 0.88rem;
    }
}

@media (max-width: 780px) {
    .form-grid {
        grid-template-columns: 1fr;
    }

    .form-grid__wide {
        grid-column: auto;
    }

    .location-row {
        align-items: flex-start;
        flex-direction: column;
    }

    .location-row form,
    .location-row .button,
    .location-actions {
        width: 100%;
    }

    .location-actions,
    .form-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .credential-card dl div {
        grid-template-columns: 1fr;
        gap: 0.15rem;
    }
}

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