:root {
    --brand: #063f8c;
    --brand-2: #0b63ce;
    --ink: #102033;
    --muted: #667085;
    --line: #d7e0ec;
    --bg: #f3f7fd;
    --card: #ffffff;
    --ok: #0f8a4b;
    --warn: #b45309;
    --danger: #c62828;
}

* { box-sizing: border-box; }

html, body {
    min-height: 100%;
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: var(--bg);
    color: var(--ink);
}

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

button {
    min-height: 42px;
    border: 0;
    border-radius: 8px;
    padding: 0.72rem 0.9rem;
    font-weight: 800;
    cursor: pointer;
}

button:disabled {
    opacity: 0.55;
    cursor: wait;
}

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

.ghost {
    background: #e8eef7;
    color: var(--brand);
}

.small {
    min-height: 36px;
    padding: 0.55rem 0.7rem;
    font-size: 0.84rem;
}

.icon-btn {
    background: #e8eef7;
    color: var(--brand);
    min-height: 36px;
    padding: 0.48rem 0.65rem;
}

.hidden { display: none !important; }

.login-view {
    min-height: 100vh;
    padding: 1.2rem;
    display: grid;
    place-items: center;
}

.login-card {
    width: min(430px, 100%);
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 1.25rem;
    box-shadow: 0 16px 36px rgba(16, 32, 51, 0.12);
}

.login-logo {
    display: block;
    width: 168px;
    max-width: 70%;
    margin: 0 auto 0.9rem;
    background: #fff;
}

.login-card h1 {
    margin: 0;
    color: var(--brand);
    text-align: center;
    font-size: 1.45rem;
}

.login-card p {
    margin: 0.35rem 0 1rem;
    color: var(--muted);
    text-align: center;
}

label {
    display: block;
    margin: 0.75rem 0 0.35rem;
    color: var(--brand);
    font-size: 0.78rem;
    font-weight: 900;
    text-transform: uppercase;
}

input, select, textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0.74rem 0.78rem;
    background: #fff;
    color: var(--ink);
}

textarea {
    resize: vertical;
    min-height: 92px;
}

.login-card button {
    width: 100%;
    margin-top: 0.85rem;
}

.msg {
    min-height: 1.2rem;
    margin-top: 0.8rem;
    color: var(--danger);
    font-size: 0.9rem;
    text-align: center;
}

.app-view {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: calc(env(safe-area-inset-top, 0px) + 0.72rem) 0.9rem 0.72rem;
    background: var(--brand);
    color: #fff;
    box-shadow: 0 8px 18px rgba(16, 32, 51, 0.16);
}

.app-header strong {
    display: block;
    font-size: 1rem;
}

.app-header span {
    display: block;
    margin-top: 0.12rem;
    font-size: 0.76rem;
    color: #dbeafe;
}

.module-nav {
    position: sticky;
    top: 65px;
    z-index: 9;
    display: flex;
    gap: 0.45rem;
    overflow-x: auto;
    padding: 0.65rem 0.8rem;
    border-bottom: 1px solid var(--line);
    background: #fff;
    -webkit-overflow-scrolling: touch;
}

.module-nav button {
    flex: 0 0 auto;
    min-height: 34px;
    padding: 0.48rem 0.68rem;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--brand);
    font-size: 0.8rem;
}

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

.content {
    width: min(860px, 100%);
    margin: 0 auto;
    padding: 0.85rem;
}

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

.metric, .record-card, .report-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0.85rem;
    box-shadow: 0 8px 18px rgba(16, 32, 51, 0.06);
}

.metric strong {
    display: block;
    color: var(--brand);
    font-size: 1.45rem;
}

.metric span {
    color: var(--muted);
    font-size: 0.78rem;
}

.toolbar {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.55rem;
    margin-bottom: 0.8rem;
}

.items-list {
    display: grid;
    gap: 0.7rem;
}

.record-card h3 {
    margin: 0 0 0.35rem;
    color: var(--brand);
    font-size: 1rem;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.record-card p {
    margin: 0 0 0.65rem;
    color: var(--muted);
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.badge {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    margin: 0 0 0.58rem;
    padding: 0.28rem 0.5rem;
    border-radius: 999px;
    background: #e6f6ed;
    color: var(--ok);
    font-size: 0.72rem;
    font-weight: 900;
    overflow-wrap: anywhere;
}

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

.summary div {
    min-width: 0;
    border: 1px solid #e8edf5;
    border-radius: 7px;
    padding: 0.42rem;
    background: #f8fbff;
}

.summary dt {
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 900;
    text-transform: uppercase;
}

.summary dd {
    margin: 0.15rem 0 0;
    font-size: 0.82rem;
    font-weight: 800;
    overflow-wrap: anywhere;
}

.card-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.45rem;
}

.card-actions button {
    min-width: 0;
    min-height: 36px;
    padding: 0.5rem 0.35rem;
    font-size: 0.74rem;
}

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

.pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.7rem;
    margin: 0.85rem 0 1.2rem;
    color: var(--muted);
    font-weight: 800;
}

.modal {
    width: min(720px, calc(100vw - 1rem));
    max-height: calc(100vh - 1rem);
    border: 0;
    border-radius: 10px;
    padding: 0;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
}

.modal::backdrop {
    background: rgba(3, 12, 25, 0.55);
}

.modal header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    padding: 0.85rem;
    border-bottom: 1px solid var(--line);
}

.modal h2 {
    margin: 0;
    color: var(--brand);
    font-size: 1rem;
}

.modal-body {
    max-height: min(70vh, 620px);
    overflow: auto;
    padding: 0.85rem;
}

.modal-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem;
    padding: 0.85rem;
    border-top: 1px solid var(--line);
}

.kv {
    display: grid;
    gap: 0.42rem;
}

.kv div, .related-item {
    border: 1px solid #e8edf5;
    border-radius: 7px;
    padding: 0.55rem;
    background: #f8fbff;
}

.kv dt {
    color: var(--muted);
    font-size: 0.7rem;
    font-weight: 900;
    text-transform: uppercase;
}

.kv dd {
    margin: 0.18rem 0 0;
    overflow-wrap: anywhere;
}

.toast {
    position: fixed;
    left: 0.8rem;
    right: 0.8rem;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 0.8rem);
    z-index: 50;
    display: none;
    padding: 0.82rem 0.9rem;
    border-radius: 9px;
    background: #102033;
    color: #fff;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.24);
}

.toast.show {
    display: block;
}

.empty {
    text-align: center;
    color: var(--muted);
    padding: 1.5rem 0.6rem;
}

.report-section {
    display: grid;
    gap: 0.65rem;
}

.checklist-editor {
    display: grid;
    gap: 0.8rem;
}

.editor-section {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0.8rem;
    background: #f8fbff;
}

.editor-section h3 {
    margin: 0 0 0.65rem;
    color: var(--brand);
    font-size: 0.98rem;
}

.field-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.55rem;
}

.photo-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.55rem;
}

.photo-slot {
    border: 1px solid #dfe7f2;
    border-radius: 8px;
    padding: 0.6rem;
    background: #fff;
}

.photo-slot label {
    margin-top: 0;
}

.existing-link {
    display: inline-block;
    margin: 0 0 0.45rem;
    color: var(--brand);
    font-size: 0.8rem;
    font-weight: 800;
}

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

.inline-actions {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.5rem;
    align-items: end;
}

.mini-list {
    display: grid;
    gap: 0.45rem;
    margin-top: 0.65rem;
}

.mini-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.5rem;
    align-items: center;
    border: 1px solid #dfe7f2;
    border-radius: 8px;
    padding: 0.5rem;
    background: #fff;
}

.mini-row strong,
.mini-row small {
    display: block;
    overflow-wrap: anywhere;
}

.mini-row small {
    margin-top: 0.18rem;
    color: var(--muted);
}

.check-row {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin: 0;
    color: var(--ink);
    font-size: 0.88rem;
    text-transform: none;
}

.check-row input {
    width: auto;
}

.compact {
    padding: 0.7rem 0.4rem;
}

.car-blueprint-mobile {
    display: grid;
    place-items: center;
    margin: 0.2rem 0 0.75rem;
}

.car-shell {
    width: min(320px, 100%);
    min-height: 130px;
    display: grid;
    grid-template-rows: 32px 1fr 32px;
    align-items: center;
    justify-items: center;
    border: 3px solid var(--brand);
    border-radius: 52px;
    background:
        radial-gradient(circle at 18% 18%, #111827 0 11px, transparent 12px),
        radial-gradient(circle at 82% 18%, #111827 0 11px, transparent 12px),
        radial-gradient(circle at 18% 82%, #111827 0 11px, transparent 12px),
        radial-gradient(circle at 82% 82%, #111827 0 11px, transparent 12px),
        #ffffff;
    color: var(--brand);
    box-shadow: inset 0 0 0 8px #eef6ff;
}

.car-shell b {
    display: grid;
    place-items: center;
    width: 44%;
    height: 52px;
    border: 2px solid #8bb7ea;
    border-radius: 16px;
    background: #eaf4ff;
}

.zone-group {
    display: grid;
    gap: 0.45rem;
    margin-top: 0.7rem;
}

.zone-group strong {
    color: var(--brand);
}

.chip-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.42rem;
}

.zone-chip {
    min-height: 32px;
    padding: 0.38rem 0.55rem;
    border: 1px solid #c9d7e8;
    border-radius: 999px;
    background: #fff;
    color: var(--brand);
    font-size: 0.76rem;
    line-height: 1.15;
}

.zone-chip.selected {
    border-color: var(--danger);
    background: #fee2e2;
    color: var(--danger);
}

@media (min-width: 680px) {
    .toolbar {
        grid-template-columns: 1fr 180px 110px;
        align-items: center;
    }

    .dashboard-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .card-actions {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }

    .field-grid,
    .photo-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* v5.103 - mobile mais compacto e sem estouro lateral */
html,
body {
    max-width: 100%;
    overflow-x: hidden;
}

.app-view,
.content,
.login-view,
.login-card,
.report-card,
.record-card,
.metric {
    max-width: 100%;
}

button {
    min-height: 36px;
    padding: 0.52rem 0.68rem;
    border-radius: 7px;
    font-size: 0.84rem;
    line-height: 1.15;
}

.small,
.icon-btn,
.ghost,
.danger {
    min-height: 32px;
    padding: 0.42rem 0.55rem;
    font-size: 0.78rem;
}

input,
select,
textarea {
    min-height: 36px;
    padding: 0.55rem 0.62rem;
    font-size: 0.94rem;
}

label {
    margin: 0.55rem 0 0.25rem;
    font-size: 0.72rem;
}

.app-header {
    padding: calc(env(safe-area-inset-top, 0px) + 0.52rem) 0.72rem 0.52rem;
}

.module-nav {
    top: 56px;
    gap: 0.34rem;
    padding: 0.48rem 0.58rem;
}

.module-nav button {
    min-height: 30px;
    padding: 0.36rem 0.52rem;
    font-size: 0.75rem;
}

.content {
    padding: 0.62rem;
}

.dashboard-grid,
.items-list {
    gap: 0.52rem;
}

.metric,
.record-card,
.report-card {
    padding: 0.68rem;
    border-radius: 7px;
    box-shadow: 0 4px 12px rgba(16, 32, 51, 0.05);
}

.metric strong {
    font-size: 1.18rem;
}

.record-card h3,
.report-card h3 {
    font-size: 0.92rem;
}

.record-card p {
    margin-bottom: 0.45rem;
    font-size: 0.84rem;
}

.card-actions {
    gap: 0.34rem;
}

.card-actions button {
    min-width: 0;
    white-space: nowrap;
}

.field-grid,
.photo-grid,
.dashboard-grid {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.car-shell {
    width: min(280px, 100%);
    min-height: 116px;
}

.zone-chip {
    min-height: 30px;
    padding: 0.32rem 0.48rem;
    font-size: 0.72rem;
}

@media (max-width: 420px) {
    body {
        font-size: 14px;
    }

    .content {
        padding: 0.48rem;
    }

    .dashboard-grid,
    .field-grid,
    .photo-grid {
        grid-template-columns: 1fr;
    }

    .module-nav button {
        font-size: 0.72rem;
    }

    .card-actions {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .card-actions button {
        padding-left: 0.36rem;
        padding-right: 0.36rem;
        font-size: 0.72rem;
    }
}
