:root {
    --brand: #E31E24;
    --brand-dark: #c41a21;
    --bg-page: #eef1f5;
    --sidebar-bg: #ffffff;
    --card: #ffffff;
    --text: #1a1a1a;
    --muted: #5f6368;
    --border: #dadce0;
    --accent: #1a73e8;
    --ok: #34a853;
    --warn: #f9ab00;
}
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    background: var(--bg-page);
    color: var(--text);
    line-height: 1.5;
}
a { color: var(--accent); }
.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 260px 1fr;
}
.sidebar {
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    padding: 1.25rem 1rem 1rem;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}
.sidebar-brand {
    display: block;
    margin-bottom: 1.35rem;
    text-decoration: none;
}
.sidebar-brand img {
    max-width: 100%;
    height: auto;
    display: block;
}
.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.65rem 0.75rem;
    border-radius: 10px;
    text-decoration: none;
    color: var(--text);
    font-size: 0.92rem;
    font-weight: 500;
    border: 1px solid transparent;
    transition: background 0.15s, color 0.15s;
}
.nav-item:hover {
    background: #f1f3f4;
}
.nav-item.is-active {
    background: var(--brand);
    color: #fff;
    border-color: var(--brand-dark);
}
.nav-item .nav-ico { flex-shrink: 0; color: #5f6368; }
.nav-item.is-active .nav-ico { color: #fff; }
.nav-text { flex: 1; }
.nav-chev {
    opacity: 0.55;
    font-size: 1.1rem;
    font-weight: 700;
}
.nav-item.is-active .nav-chev { opacity: 1; color: #fff; }

.nav-sep {
    height: 1px;
    background: var(--border);
    margin: 0.65rem 0.5rem;
    opacity: 0.85;
}

.impersonate-banner {
    background: linear-gradient(90deg, #fef3c7, #fde68a);
    border-bottom: 1px solid #f59e0b;
    padding: 0.65rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
    font-size: 0.92rem;
    color: #78350f;
}
.impersonate-banner strong { color: #451a03; }
.impersonate-banner a {
    color: #92400e;
    font-weight: 600;
    text-decoration: none;
    border-bottom: 1px solid rgba(146, 64, 14, 0.45);
}
.impersonate-banner a:hover { border-bottom-color: #92400e; }

.sidebar-footer {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}
.user-row {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin-bottom: 0.75rem;
}
.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #222;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    flex-shrink: 0;
}
.user-meta strong { display: block; font-size: 0.9rem; color: var(--text); }
.user-meta span { font-size: 0.82rem; color: var(--muted); }
.btn-logout {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    width: 100%;
    justify-content: center;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    font-size: 0.88rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}
.btn-logout:hover { background: #f8f9fa; }

.main-content { padding: 1.5rem 1.5rem 2rem; }
main { max-width: 920px; margin: 0 auto; }
.card {
    background: var(--card);
    border-radius: 14px;
    padding: 1.5rem 1.5rem 1.75rem;
    border: 1px solid #e8eaed;
    box-shadow: 0 4px 24px rgba(15, 23, 42, 0.06);
}

.page-head { margin-bottom: 1.5rem; }
.page-title { font-size: 1.55rem; font-weight: 700; margin: 0 0 1rem; letter-spacing: -0.02em; color: #000; }
.page-sub { margin: 0.35rem 0 0; font-size: 0.95rem; color: var(--muted); }
.page-actions { margin: 0.75rem 0 0; }
.fin-section-note { color: var(--muted); font-size: 0.9rem; margin: 0; max-width: 42rem; line-height: 1.45; }
.fin-tarifas-sub { font-size: 1.05rem; font-weight: 600; margin: 0.4rem 0 0; color: var(--text); }
.fin-back { margin: 0 0 1rem; font-size: 0.92rem; }
.fin-back a { color: var(--accent); font-weight: 600; text-decoration: none; }
.fin-back a:hover { text-decoration: underline; }
.fin-tarifa-cadastro { margin-top: 1rem; max-width: 28rem; }
.fin-tarifa-cadastro .fin-tipo-select { margin-bottom: 1rem; }
.fin-panel { padding-top: 0.25rem; }
.fin-panel-hint { color: var(--muted); font-size: 0.88rem; margin: 0 0 0.75rem; }

.form-panel .form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem 1.25rem;
}
@media (max-width: 700px) {
    .form-panel .form-grid { grid-template-columns: 1fr; }
}
.field label { display: block; margin-bottom: 0.35rem; font-weight: 600; font-size: 0.88rem; color: var(--text); }
.field .req { color: var(--brand); font-weight: 700; }
.field-full { grid-column: 1 / -1; }
.text-muted { color: var(--muted); font-size: 0.92rem; }

h1 { font-size: 1.35rem; margin: 0 0 1rem; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 0.55rem 0.6rem; border-bottom: 1px solid #e8eaed; }
th { color: var(--muted); font-weight: 600; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.04em; }

/* Tabelas largas (ex.: relatórios): ficam dentro do cartão com scroll horizontal */
.table-scroll {
    overflow-x: auto;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
    margin: 0.35rem 0 0;
}
.table-scroll table {
    width: max-content;
    min-width: 100%;
    margin: 0;
}
.table-scroll th,
.table-scroll td {
    vertical-align: top;
    word-break: break-word;
}
.table-scroll table.report-detalhe {
    min-width: 1180px;
}

.btn {
    display: inline-block;
    padding: 0.55rem 1.1rem;
    background: var(--brand);
    color: #fff;
    border-radius: 8px;
    text-decoration: none;
    border: 0;
    cursor: pointer;
    font-size: 0.92rem;
    font-weight: 600;
}
.btn:hover { filter: brightness(0.95); }
a.btn:focus:not(:focus-visible),
button.btn:focus:not(:focus-visible) { outline: none; }
a.btn:focus-visible,
button.btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
.btn.secondary { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn.secondary:hover { background: #f8f9fa; }

.btn.danger {
    background: #c5221f;
    color: #fff;
    border: 1px solid #a50e0e;
}
.btn.danger:hover { filter: brightness(0.95); }

.btn.btn-compact {
    padding: 0.3rem 0.55rem;
    font-size: 0.78rem;
}

.table-actions-cell {
    white-space: nowrap;
}
.table-actions-cell form {
    display: inline-block;
    vertical-align: middle;
    margin-left: 0.5rem;
}

.badge { display: inline-block; padding: 0.15rem 0.45rem; border-radius: 4px; font-size: 0.75rem; background: #e8eaed; color: #444; }
.badge.aguardando { background: #e8eaed; }
.badge.deslocamento { background: #d2e3fc; color: #174ea6; }
.badge.chegou { background: #fef7e0; color: #b06000; }
.badge.embarcado { background: #e8def8; color: #5c2d91; }
.badge.finalizado { background: #e6f4ea; color: #137333; }
.badge.cancelado { background: #fce8e6; color: #c5221f; }
.badge.mt-em-andamento { background: #fff3e0; color: #e65100; font-weight: 600; }
.badge.mt-disponivel { background: #e6f4ea; color: #137333; font-weight: 600; }
.badge.mt-aguardando { background: #e8f0fe; color: #1967d2; font-weight: 600; }
/* Admin — lista de corridas: prioridade visual pedida (verde / laranja / azul) */
.badge.admin-corrida-aguardando { background: #e8f5e9; color: #1b5e20; font-weight: 600; }
.badge.admin-corrida-andamento { background: #fff3e0; color: #e65100; font-weight: 600; }
.badge.admin-corrida-finalizado { background: #e3f2fd; color: #0d47a1; font-weight: 600; }

label { display: block; margin: 0.5rem 0 0.2rem; color: var(--muted); font-size: 0.85rem; }
/* Checkboxes/radios fora desta regra: width:100% + padding tornava-os um quadrado azul gigante no Chrome/Edge. */
input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
    width: 100%;
    max-width: 100%;
    padding: 0.65rem 0.75rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    font-size: 0.95rem;
}
input[type="checkbox"],
input[type="radio"] {
    width: 1.125rem;
    height: 1.125rem;
    max-width: none;
    padding: 0;
    margin: 0 0.5rem 0 0;
    vertical-align: middle;
    flex-shrink: 0;
    accent-color: var(--brand);
}
input::placeholder, textarea::placeholder { color: #9aa0a6; }
textarea { min-height: 100px; resize: vertical; }
.erro { color: #c5221f; margin: 0.5rem 0; font-size: 0.9rem; }
.form-actions { margin-top: 1.25rem; display: flex; flex-wrap: wrap; gap: 0.65rem; align-items: center; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 700px) { .grid2 { grid-template-columns: 1fr; } }

.public-main { max-width: 520px; margin: 2.5rem auto; padding: 0 1rem; }
body.guest {
    background:
        radial-gradient(1200px 600px at 20% -10%, rgba(227, 30, 36, 0.12), transparent 55%),
        radial-gradient(900px 500px at 110% 20%, rgba(26, 115, 232, 0.10), transparent 50%),
        var(--bg-page);
}
body.guest .public-main .card {
    padding: 2rem 1.75rem 1.75rem;
    box-shadow: 0 18px 50px rgba(15, 23, 42, 0.10);
}
.login-wrap { width: 100%; }
.login-brand img {
    display: block;
    margin: 0 auto 0.75rem;
    max-width: 260px;
    width: 100%;
    height: auto;
}
.login-kicker {
    text-align: center;
    color: var(--muted);
    font-size: 0.92rem;
    margin: 0 0 0.35rem;
    font-weight: 600;
}
.login-wrap h1 {
    text-align: center;
    font-size: 1.6rem;
    margin: 0 0 1rem;
    letter-spacing: -0.02em;
}
.login-hint {
    margin: 1rem 0 0;
    text-align: center;
    font-size: 0.82rem;
    color: var(--muted);
}
.login-alert {
    background: #fef7e0;
    border: 1px solid #f9ab00;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    font-size: 0.9rem;
    margin-bottom: 1rem;
    color: #5f4b00;
}
.login-form input { max-width: 100%; }
.login-submit { margin-top: 1rem; }
.login-submit .btn { width: 100%; padding: 0.72rem 0.9rem; }
.login-erro {
    background: #fce8e6;
    border: 1px solid #e8a398;
    padding: 0.65rem 0.75rem;
    border-radius: 10px;
    color: #c5221f;
}

@media (max-width: 980px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar {
        position: static;
        height: auto;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }
}