:root {
    --bg: #f2f4f8;
    --card: #ffffff;
    --text: #142033;
    --muted: #687386;
    --border: #dbe1e8;
    --primary: #16b85c;
    --primary-dark: #10994a;
    --danger: #c53b3b;
    --success-bg: #e9f9ef;
    --success-text: #176b39;
    --radius: 14px;
}

* {
    box-sizing: border-box;
}

html {
    background: var(--bg);
}

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

button,
input,
textarea {
    font: inherit;
}

.login-body {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
}

.login-shell {
    width: 100%;
    max-width: 420px;
}

.login-card,
.form-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 12px 35px rgba(20, 32, 51, 0.08);
}

.login-card {
    padding: 30px;
}

.brand-mark {
    display: grid;
    width: 54px;
    height: 54px;
    margin-bottom: 22px;
    place-items: center;
    border-radius: 16px;
    background: var(--text);
    color: #fff;
    font-weight: 800;
}

h1 {
    margin: 0;
    font-size: 1.55rem;
}

.subtitle,
.form-title p {
    margin: 7px 0 24px;
    color: var(--muted);
}

label,
legend {
    color: var(--text);
    font-size: 0.92rem;
    font-weight: 650;
}

input[type="text"],
input[type="password"],
input[type="tel"],
input[type="date"],
textarea {
    width: 100%;
    margin-top: 8px;
    padding: 13px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
    color: var(--text);
    outline: none;
}

textarea {
    resize: vertical;
}

input:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(22, 184, 92, 0.12);
}

button {
    width: 100%;
    min-height: 48px;
    margin-top: 22px;
    border: 0;
    border-radius: 10px;
    background: var(--primary);
    color: #fff;
    font-weight: 750;
    cursor: pointer;
}

button:hover {
    background: var(--primary-dark);
}

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

.topbar {
    position: sticky;
    z-index: 20;
    top: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 68px;
    padding:
        max(12px, env(safe-area-inset-top))
        18px
        12px;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(12px);
}

.topbar strong,
.topbar small {
    display: block;
}

.topbar small {
    margin-top: 2px;
    color: var(--muted);
}

.logout-link {
    color: var(--danger);
    text-decoration: none;
    font-weight: 700;
}

.page-shell {
    width: min(100%, 680px);
    margin: 0 auto;
    padding: 20px 14px 50px;
}

.form-card {
    padding: 22px;
}

.form-title {
    padding-bottom: 18px;
    border-bottom: 1px solid var(--border);
}

.field,
fieldset {
    margin: 22px 0 0;
}

fieldset {
    padding: 0;
    border: 0;
}

legend {
    margin-bottom: 10px;
}

.choice-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.choice,
.check-option {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 46px;
    padding: 11px 13px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
}

.choice input,
.check-option input {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

.check-list {
    display: grid;
    gap: 9px;
}

.gps-status {
    margin-top: 16px;
    padding: 12px 14px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 650;
}

.gps-loading {
    background: #fff8df;
    color: #755a09;
}

.gps-ok {
    background: var(--success-bg);
    color: var(--success-text);
}

.gps-error {
    background: #fdecec;
    color: #9d2424;
}

.alert {
    margin-bottom: 16px;
    padding: 14px;
    border-radius: 10px;
    line-height: 1.45;
}

.alert-error {
    background: #fdecec;
    color: #9d2424;
}

.alert-success {
    background: var(--success-bg);
    color: var(--success-text);
}

[hidden] {
    display: none !important;
}

@media (max-width: 480px) {
    .login-card {
        padding: 24px 20px;
    }

    .form-card {
        padding: 18px 16px;
        border-radius: 12px;
    }

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


/* ==========================================================
   Mappi Rua — Formulário V2
   ========================================================== */

.app-body {
    padding-bottom: calc(92px + env(safe-area-inset-bottom));
}

.form-eyebrow {
    display: block;
    margin-bottom: 6px;
    color: var(--primary-dark);
    font-size: 0.74rem;
    font-weight: 850;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.form-section {
    margin-top: 28px;
    padding-top: 26px;
    border-top: 1px solid var(--border);
}

.section-title {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 20px;
}

.section-number {
    flex: 0 0 auto;
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border-radius: 11px;
    background: rgba(22, 184, 92, 0.12);
    color: var(--primary-dark);
    font-size: 0.85rem;
    font-weight: 900;
}

.section-title h2 {
    margin: 0;
    color: var(--text);
    font-size: 1.12rem;
    line-height: 1.2;
}

.section-title p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 0.86rem;
    line-height: 1.4;
}

.choice-button {
    position: relative;
    justify-content: center;
    min-height: 54px;
    font-weight: 800;
    overflow: hidden;
}

.choice-button input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.choice-button:has(input:checked) {
    border-color: var(--primary);
    background: rgba(22, 184, 92, 0.1);
    color: var(--primary-dark);
    box-shadow: 0 0 0 3px rgba(22, 184, 92, 0.09);
}

.date-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1.45fr;
    gap: 10px;
}

.date-part {
    width: 100%;
    min-height: 58px;
    margin-top: 8px;
    padding: 12px 8px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    color: var(--text);
    font-size: 1.18rem;
    font-weight: 850;
    letter-spacing: 0.1em;
    text-align: center;
    outline: none;
}

.date-part:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(22, 184, 92, 0.12);
}

.cep-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 112px;
    gap: 10px;
    align-items: end;
}

.secondary-button {
    width: 100%;
    min-height: 48px;
    margin-top: 8px;
    border: 1px solid rgba(20, 32, 51, 0.15);
    background: #eef2f6;
    color: var(--text);
    box-shadow: none;
}

.secondary-button:hover {
    background: #e2e8ef;
}

.address-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr);
    gap: 12px;
}

.address-grid .field {
    margin-top: 18px;
}

.field-uf {
    max-width: 110px;
}

.field-help,
.field-error {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 0.78rem;
    line-height: 1.4;
}

.field-error,
.field-help-error {
    color: #a52b2b;
}

.field-help-warning {
    color: #8a6100;
}

.field-help-success {
    color: var(--success-text);
}

.photo-field input[type="file"] {
    width: 100%;
    margin-top: 8px;
    padding: 14px;
    border: 1px dashed var(--border);
    border-radius: 12px;
    background: #f8fafc;
}

.photo-preview {
    display: block;
    width: 100%;
    max-height: 320px;
    margin-top: 14px;
    border-radius: 14px;
    object-fit: cover;
    background: #edf1f5;
}

.submit-button {
    min-height: 58px;
    margin-top: 30px;
    border-radius: 13px;
    box-shadow: 0 14px 28px rgba(22, 184, 92, 0.18);
}

.alert-success strong,
.alert-success span {
    display: block;
}

.alert-success span {
    margin-top: 4px;
    font-size: 0.85rem;
}

.floating-menu {
    position: fixed;
    z-index: 100;
    right: 10px;
    bottom: max(10px, env(safe-area-inset-bottom));
    left: 10px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    width: min(calc(100% - 20px), 660px);
    min-height: 68px;
    margin: 0 auto;
    padding: 7px;
    border: 1px solid rgba(20, 32, 51, 0.1);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 18px 45px rgba(20, 32, 51, 0.18);
    backdrop-filter: blur(18px);
}

.floating-menu-item {
    display: flex;
    min-width: 0;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 3px;
    padding: 7px 4px;
    border-radius: 14px;
    color: var(--muted);
    font-size: 0.65rem;
    font-weight: 750;
    line-height: 1.15;
    text-align: center;
    text-decoration: none;
}

.floating-menu-icon {
    display: grid;
    width: 26px;
    height: 26px;
    place-items: center;
    border-radius: 9px;
    font-size: 1rem;
    font-weight: 900;
}

.floating-menu-item.is-active {
    background: rgba(22, 184, 92, 0.1);
    color: var(--primary-dark);
}

.floating-menu-danger {
    color: var(--danger);
}

.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

@media (max-width: 480px) {
    .page-shell {
        padding-right: 10px;
        padding-left: 10px;
    }

    .form-card {
        padding: 18px 15px 24px;
    }

    .address-grid {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .field-uf {
        max-width: none;
    }

    .floating-menu {
        right: 6px;
        left: 6px;
        width: calc(100% - 12px);
    }

    .floating-menu-item {
        font-size: 0.59rem;
    }
}


/* ==========================================================
   Mappi Rua — Modal de sucesso + menu inferior V6
   ========================================================== */

.success-modal-backdrop {
    position: fixed;
    z-index: 1000;
    inset: 0;
    display: grid;
    place-items: center;
    padding:
        max(20px, env(safe-area-inset-top))
        18px
        max(20px, env(safe-area-inset-bottom));
    background: rgba(7, 20, 38, 0.72);
    backdrop-filter: blur(8px);
    animation: successBackdropIn 180ms ease-out;
}

.success-modal {
    width: min(100%, 420px);
    padding: 30px 24px 24px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 24px;
    background: #ffffff;
    color: var(--text);
    box-shadow:
        0 24px 70px rgba(5, 18, 36, 0.32),
        0 4px 18px rgba(5, 18, 36, 0.12);
    text-align: center;
    animation: successModalIn 220ms ease-out;
}

.success-modal-icon {
    display: grid;
    width: 72px;
    height: 72px;
    margin: 0 auto 20px;
    place-items: center;
    border-radius: 50%;
    background: #e5f8ed;
    color: #108a43;
}

.success-modal-icon svg {
    width: 38px;
    height: 38px;
}

.success-modal h2 {
    margin: 0;
    color: #0c2950;
    font-size: 1.55rem;
    line-height: 1.15;
}

.success-modal > p {
    margin: 10px 0 22px;
    color: var(--muted);
    font-size: 0.95rem;
    line-height: 1.45;
}

.success-modal-protocol {
    margin-bottom: 22px;
    padding: 14px;
    border: 1px solid #d8e2ee;
    border-radius: 14px;
    background: #f5f8fc;
    text-align: left;
}

.success-modal-protocol span {
    display: block;
    margin-bottom: 5px;
    color: #687386;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.success-modal-protocol strong {
    display: block;
    overflow-wrap: anywhere;
    color: #0c2950;
    font-size: 0.9rem;
    line-height: 1.4;
}

.success-modal-button {
    display: grid;
    width: 100%;
    min-height: 54px;
    place-items: center;
    border-radius: 14px;
    background: #16b85c;
    color: #ffffff;
    font-size: 1rem;
    font-weight: 850;
    text-decoration: none;
    box-shadow: 0 12px 24px rgba(22, 184, 92, 0.22);
}

.success-modal-button:active {
    transform: translateY(1px);
}

.floating-menu {
    min-height: 72px;
    padding: 7px 10px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 23px;
    background: #0c2950;
    box-shadow:
        0 18px 44px rgba(4, 16, 34, 0.34),
        0 3px 12px rgba(4, 16, 34, 0.18);
}

.floating-menu-item {
    min-height: 56px;
    padding: 8px;
    border-radius: 16px;
    color: #ffffff;
    opacity: 0.76;
    transition:
        opacity 160ms ease,
        background 160ms ease,
        transform 160ms ease;
}

.floating-menu-item:hover,
.floating-menu-item:focus-visible {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    opacity: 1;
}

.floating-menu-item:active {
    transform: scale(0.94);
}

.floating-menu-item.is-active {
    background: rgba(255, 255, 255, 0.16);
    color: #ffffff;
    opacity: 1;
}

.floating-menu-danger {
    color: #ffffff;
}

.floating-menu-svg {
    width: 31px;
    height: 31px;
    pointer-events: none;
}

.floating-menu-icon {
    display: none;
}

@keyframes successBackdropIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes successModalIn {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.96);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@media (max-width: 480px) {
    .success-modal {
        padding: 28px 20px 20px;
        border-radius: 22px;
    }

    .floating-menu {
        min-height: 70px;
        padding: 6px 8px;
        border-radius: 21px;
    }

    .floating-menu-item {
        min-height: 54px;
    }

    .floating-menu-svg {
        width: 30px;
        height: 30px;
    }
}
