:root {
    color-scheme: light;
    --bg: #f4f7f6;
    --ink: #17211f;
    --muted: #60706b;
    --line: #d7e0dc;
    --panel: #ffffff;
    --accent: #0f8b8d;
    --accent-dark: #0b6668;
    --warn: #9b3d1f;
    --done: #1f8a4c;
    --done-bg: #e8f6ec;
    --planned-bg: #f1f4f3;
}

* {
    box-sizing: border-box;
}

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

a {
    color: var(--accent-dark);
}

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

.site-header {
    background: var(--panel);
    border-bottom: 1px solid var(--line);
}

.site-header .shell {
    padding: 14px 0;
}

.brand {
    display: inline-flex;
    align-items: center;
}

.brand-logo {
    height: 42px;
    width: auto;
    display: block;
}

.shell {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
    padding: 32px 0;
}

.panel,
.hero,
.timeline,
.map-wrap,
.result-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(23, 33, 31, 0.06);
}

.intro {
    display: grid;
    grid-template-columns: minmax(0, 0.9fr) minmax(320px, 1.1fr);
    gap: 32px;
    align-items: start;
    padding: 32px;
}

.eyebrow {
    margin: 0 0 10px;
    color: var(--accent-dark);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1 {
    margin: 0 0 12px;
    font-size: clamp(2rem, 4vw, 4.25rem);
    line-height: 1;
}

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

.form {
    display: grid;
    gap: 14px;
}

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

label {
    display: grid;
    gap: 6px;
    color: #354541;
    font-size: 0.9rem;
    font-weight: 700;
}

input,
select,
button {
    width: 100%;
    min-height: 44px;
    border-radius: 6px;
    font: inherit;
}

input,
select {
    border: 1px solid var(--line);
    padding: 10px 12px;
    background: #fbfdfc;
    color: var(--ink);
}

button {
    border: 0;
    border-radius: 10px;
    padding: 0 18px;
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    color: #fff;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(15, 139, 141, 0.28);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

button:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 22px rgba(15, 139, 141, 0.34);
}

button:active {
    transform: translateY(0);
    box-shadow: 0 4px 12px rgba(15, 139, 141, 0.28);
}

/* Botao compacto para acoes repetidas/administrativas (linhas de tabela,
   barras de filtro) - o botao padrao acima e um CTA grande demais pra isso. */
.btn-compact {
    width: auto;
    min-height: 34px;
    padding: 0 14px;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 700;
    box-shadow: none;
}

.btn-compact:hover {
    transform: none;
    box-shadow: none;
    filter: brightness(1.08);
}

.btn-compact:active {
    box-shadow: none;
}

/* Barra de ferramentas do admin (filtros, acoes em lote) - separa
   visualmente dos controles soltos que ficavam direto sobre o fundo da pagina. */
.admin-toolbar {
    display: flex;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: wrap;
    background: var(--planned-bg);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 16px;
}

.admin-toolbar label {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--muted);
}

.admin-toolbar input,
.admin-toolbar select {
    margin-top: 4px;
    min-height: 36px;
    font-size: 0.85rem;
}

.admin-toolbar .checkbox-field {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 400;
    min-height: 36px;
}

.admin-toolbar .checkbox-field input {
    width: auto;
    min-height: auto;
    margin-top: 0;
}

.admin-table th {
    white-space: nowrap;
}

.admin-table td,
.admin-table th {
    vertical-align: middle;
}

.admin-table tbody tr:hover {
    background: var(--planned-bg);
}

.result {
    margin-top: 18px;
}

.support-cta {
    margin-top: 18px;
}

.btn-help {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    min-width: 200px;
    min-height: 44px;
    padding: 0 20px;
    margin-top: 8px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    color: #fff;
    font-weight: 800;
    text-decoration: none;
}

.help-page .back {
    display: inline-block;
    margin-bottom: 14px;
}

.help-tabs {
    margin-top: 18px;
}

.help-tab-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 18px;
}

.help-tab-btn {
    width: auto;
    min-height: 40px;
    padding: 0 16px;
    background: #fbfdfc;
    border: 1px solid var(--line);
    color: var(--ink);
    font-weight: 700;
    box-shadow: none;
}

.help-tab-btn:hover {
    background: var(--done-bg);
    box-shadow: none;
    transform: none;
}

.help-tab-btn.active {
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    color: #fff;
    border-color: transparent;
}

.help-tab-panel h2 {
    margin-top: 0;
}

.faq-question {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--ink);
    margin: 0 0 4px;
}

.faq-intro {
    color: #5b675f;
    margin: 0 0 4px;
    line-height: 1.5;
}

.faq-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 14px;
}

.faq-option {
    background: #fbfdfc;
    border: 1px solid var(--line);
    color: var(--ink);
    text-align: left;
    padding: 12px 16px;
    box-shadow: none;
    font-weight: 600;
    min-height: auto;
    line-height: 1.4;
}

.faq-option:hover {
    background: var(--done-bg);
    box-shadow: none;
    transform: none;
}

.faq-option-emphasis {
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    color: #fff;
    border: 0;
}

.faq-option-emphasis:hover {
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    opacity: 0.92;
}

.faq-answer {
    background: var(--planned-bg);
    border-left: 4px solid var(--accent);
    border-radius: 8px;
    padding: 14px 16px;
    margin-top: 10px;
    line-height: 1.6;
}

.faq-answer p {
    margin: 0 0 10px;
}

.faq-answer p:last-child {
    margin-bottom: 0;
}

.faq-answer ul {
    margin: 0 0 10px;
    padding-left: 20px;
}

.faq-answer ul:last-child {
    margin-bottom: 0;
}

.faq-answer li {
    margin-bottom: 8px;
    line-height: 1.55;
}

.faq-answer li:last-child {
    margin-bottom: 0;
}

.faq-resolved-question {
    font-weight: 700;
    margin: 16px 0 0;
}

.faq-final-note {
    color: #5b675f;
    margin: 10px 0 0;
    line-height: 1.5;
}

.faq-back {
    width: auto;
    min-height: auto;
    background: transparent;
    color: var(--accent-dark);
    box-shadow: none;
    font-weight: 700;
    padding: 10px 0 0;
    text-align: left;
}

.faq-back:hover {
    background: transparent;
    box-shadow: none;
    transform: none;
    text-decoration: underline;
}

.faq-form {
    margin-top: 12px;
}

.result-card {
    padding: 22px;
}

.code {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    margin: 8px 0;
    padding: 0 12px;
    border: 1px dashed var(--accent);
    border-radius: 6px;
    background: #edf9f8;
    font-family: Consolas, monospace;
    font-weight: 800;
}

.muted-note {
    font-size: 0.85rem;
    font-style: italic;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}

.actions a,
.actions button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    min-width: 150px;
    min-height: 40px;
    border-radius: 6px;
    text-decoration: none;
}

.actions a {
    padding: 0 14px;
    background: #20312d;
    color: #fff;
    font-weight: 800;
}

.error {
    color: var(--warn);
    font-weight: 700;
}

.tracking .back {
    display: inline-block;
    margin-bottom: 14px;
}

/* Status hero */
.hero {
    padding: 22px 26px;
    margin-bottom: 18px;
}

.hero-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.code-badge {
    font-family: Consolas, monospace;
    font-weight: 800;
    font-size: 0.85rem;
    padding: 4px 10px;
    border-radius: 999px;
    background: #edf9f8;
    color: var(--accent-dark);
    border: 1px solid var(--line);
}

.hero-status {
    margin: 12px 0 10px;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--ink);
}

.hero-eta {
    margin: 10px 0 0;
    font-weight: 700;
    color: var(--accent-dark);
}

.progress-bar {
    width: 100%;
    height: 10px;
    border-radius: 999px;
    background: var(--planned-bg);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--accent), var(--done));
    transition: width 0.3s ease;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 999px;
    font-weight: 800;
    font-size: 0.72rem;
    text-transform: uppercase;
}

.badge-completed {
    background: var(--done-bg);
    color: var(--done);
}

.badge-current {
    background: #edf9f8;
    color: var(--accent-dark);
}

.badge-planned {
    background: var(--planned-bg);
    color: #63716d;
}

.tracking-grid {
    display: grid;
    grid-template-columns: minmax(360px, 1.2fr) minmax(300px, 0.8fr);
    gap: 18px;
}

.timeline {
    padding: 20px;
    max-height: 620px;
    overflow-y: auto;
}

.timeline-title {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    font-weight: 800;
}

.timeline-title small {
    color: var(--muted);
    font-weight: 700;
}

.event {
    position: relative;
    padding: 0 0 14px 22px;
    border-left: 2px solid var(--line);
}

.event:last-child {
    padding-bottom: 0;
    border-left-color: transparent;
}

.event::before {
    content: "";
    position: absolute;
    left: -6px;
    top: 2px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--line);
}

.event.completed::before {
    background: var(--done);
}

.event.current::before {
    background: var(--accent);
    box-shadow: 0 0 0 4px #edf9f8;
}

.event.planned {
    opacity: 0.5;
}

.event.planned strong,
.event.planned span {
    color: var(--muted);
}

.event em {
    position: absolute;
    left: -2px;
    top: 16px;
    color: var(--muted);
    font-size: 0.68rem;
    font-style: normal;
    font-weight: 800;
    transform: translateX(-50%);
}

.event strong {
    display: block;
    font-size: 0.95rem;
}

.event span,
.event time {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 0.84rem;
}

.event small.badge {
    width: fit-content;
    margin-top: 6px;
}

.map-wrap {
    min-height: 480px;
    padding: 14px;
}

#map {
    width: 100%;
    min-height: 420px;
    border-radius: 6px;
    border: 1px solid var(--line);
}

#map-note {
    margin: 10px 0 0;
    font-size: 0.88rem;
}

/* Leaflet map markers, arrows, legend */
.map-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    font-weight: 800;
    font-size: 0.75rem;
    color: #fff;
    border: 2px solid #fff;
    box-shadow: 0 2px 6px rgba(23, 33, 31, 0.35);
}

.marker-origin {
    background: var(--done);
}

.marker-destination {
    background: var(--warn);
}

.marker-hub {
    background: #6c7d78;
}

.marker-current {
    outline: 3px solid var(--accent);
}

.route-arrow {
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 10px solid var(--accent);
}

.map-legend {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 0.78rem;
    line-height: 1.6;
    box-shadow: 0 4px 14px rgba(23, 33, 31, 0.15);
}

.map-legend strong {
    display: block;
    margin-bottom: 4px;
}

.legend-swatch {
    display: inline-block;
    width: 14px;
    height: 4px;
    margin-right: 6px;
    border-radius: 2px;
}

.legend-marker {
    width: 16px;
    height: 16px;
    font-size: 0.6rem;
    vertical-align: middle;
    margin-right: 4px;
}

@media (max-width: 820px) {
    .intro,
    .tracking-grid,
    .grid {
        grid-template-columns: 1fr;
    }

    .tracking-grid {
        display: flex;
        flex-direction: column;
    }

    .shell {
        width: min(100% - 20px, 1120px);
        padding: 18px 0;
    }

    .intro,
    .hero {
        padding: 20px;
    }

    .map-wrap {
        min-height: 380px;
    }

    #map {
        min-height: 300px;
    }
}

/* Dashboard da conta (tenant) */
.dash-shell {
    display: grid;
    grid-template-columns: 230px minmax(0, 1fr);
    gap: 24px;
    align-items: start;
}

.dash-sidebar {
    position: sticky;
    top: 24px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 20px 16px;
    box-shadow: 0 10px 30px rgba(23, 33, 31, 0.06);
}

.dash-brand {
    margin: 4px 8px 16px;
    color: var(--ink);
    font-weight: 800;
    font-size: 1.05rem;
}

.dash-nav {
    display: grid;
    gap: 6px;
}

.dash-nav a {
    display: block;
    padding: 11px 14px;
    border-radius: 10px;
    color: var(--muted);
    font-weight: 700;
    font-size: 0.92rem;
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease;
}

.dash-nav a:hover {
    background: var(--planned-bg);
    color: var(--ink);
}

.dash-nav a.active {
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    color: #fff;
    box-shadow: 0 8px 18px rgba(15, 139, 141, 0.28);
}

.dash-nav form {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
}

.dash-content {
    display: grid;
    gap: 18px;
    min-width: 0;
}

.dash-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 26px;
    box-shadow: 0 10px 30px rgba(23, 33, 31, 0.06);
}

.dash-card h2 {
    margin-top: 0;
}

.dash-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 14px;
    margin-top: 16px;
}

.dash-stat {
    background: var(--planned-bg);
    border-radius: 12px;
    padding: 16px;
}

.dash-stat strong {
    display: block;
    font-size: 1.6rem;
    color: var(--ink);
}

.dash-stat span {
    display: block;
    margin-top: 2px;
    font-size: 0.78rem;
    color: var(--muted);
    text-transform: uppercase;
    font-weight: 700;
}

.badge-ok {
    background: var(--done-bg);
    color: var(--done);
}

.badge-fail {
    background: #fdeceb;
    color: var(--warn);
}

.tag-optional,
.tag-required {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    margin-left: 4px;
}

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

.tag-required {
    color: var(--warn);
}

@media (max-width: 900px) {
    .dash-shell {
        grid-template-columns: 1fr;
    }

    .dash-sidebar {
        position: static;
    }

    .dash-nav {
        display: flex;
        flex-wrap: wrap;
    }

    .dash-nav a {
        flex: 1 1 auto;
        text-align: center;
    }

    .dash-nav form {
        flex: 1 1 100%;
        margin-top: 8px;
        padding-top: 8px;
    }
}

.email-type-block {
    border-top: 1px solid var(--line);
    padding-top: 18px;
    margin-top: 18px;
}

.email-type-block:first-of-type {
    border-top: none;
    padding-top: 0;
    margin-top: 0;
}

.template-mode-toggle {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin: 10px 0;
}

.radio-field {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 400;
}

.radio-field input {
    width: auto;
    min-height: auto;
    margin-top: 0;
}

.template-mode-panel {
    margin-top: 8px;
}

.checkbox-field {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 400;
}

.checkbox-field input {
    width: auto;
    min-height: auto;
    margin-top: 0;
}

.admin-table th,
.admin-table td {
    padding: 10px 12px;
}

.admin-table thead tr {
    background: var(--planned-bg, #f4f7f5);
}
