/* ============================================================================
   Controle Interno · MobGov — Folha de estilos
   Visual padronizado com o sistema BDA "Controle de Missões"
   (paleta, tipografia, sombras, raios e espaçamentos).

   As cores e a fonte ficam centralizadas em :root (variáveis CSS) para
   facilitar a manutenção.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600;700&display=swap');

/* ----------------------------- Design tokens ----------------------------- */
:root {
    /* cores (mesmas do sistema BDA) */
    --primary: #556b2f;
    --primary-dark: #3d4f1f;
    --primary-light: #6b8e23;
    --accent: #8b7355;
    --accent-light: #a0926e;
    --danger: #c0392b;
    --danger-dark: #a93226;
    --danger-light: #fdecea;
    --warning: #d4a017;
    --warning-dark: #b8860b;
    --warning-light: #fdf3d7;
    --success: #556b2f;
    --success-light: #edf2e4;
    --info: #2563eb;
    --info-light: #e8effc;
    --purple: #7c3aed;
    --purple-light: #f1eafd;

    --bg: #f5f5f0;
    --bg-strong: #ecece4;
    --surface: #ffffff;
    --surface-hover: #fafaf7;

    --text: #2c3e1a;
    --text-secondary: #5a6b4a;
    --text-muted: #8a9a7a;

    --border: #d4d9c8;
    --border-strong: #b8c0a8;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.07);
    --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.10);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.18);

    --radius: 12px;
    --radius-lg: 16px;
    --radius-sm: 8px;

    --transition: 0.18s ease;

    /* foco visível (acessibilidade) */
    --focus-ring: 0 0 0 3px rgba(255, 255, 255, 0.55), 0 0 0 5px var(--primary-light);
}

/* ------------------------------- Base ------------------------------------ */
* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: 'IBM Plex Mono', 'Courier New', monospace;
    font-size: 0.92rem;
    line-height: 1.5;
}

h1, h2, h3, h4 { margin: 0; line-height: 1.25; }

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

button { font-family: inherit; }

:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
    border-radius: 6px;
}

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

/* ------------------------------ Cabeçalho -------------------------------- */
header {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary), var(--primary-light));
    background-attachment: fixed;
    color: #fff;
    padding: 18px 20px 14px;
    position: relative;
    overflow: hidden;
}

header::before, header::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    pointer-events: none;
}

header::before { width: 260px; height: 260px; top: -140px; right: -60px; }
header::after { width: 340px; height: 340px; bottom: -230px; left: 10%; }

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    position: relative;
    z-index: 1;
}

.header-logo {
    width: 52px; height: 52px;
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: var(--shadow);
}

.header-text { min-width: 0; }

.header-text h1 {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.header-text h2 {
    font-size: 0.78rem;
    font-weight: 500;
    margin-top: 3px;
    color: rgba(255, 255, 255, 0.92);
    background: rgba(255, 255, 255, 0.13);
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 30px;
    padding: 2px 12px;
    display: inline-block;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.header-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.header-date {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.92);
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 8px;
    padding: 5px 11px;
    white-space: nowrap;
}

.header-chip {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.92);
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 8px;
    padding: 5px 11px;
    white-space: nowrap;
}

/* Estado de persistência (chip no cabeçalho) */
.sync-status { display: flex; align-items: center; gap: 8px; }
.sync-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.sync-dot.sync-ok { background: #22c55e; box-shadow: 0 0 6px #22c55e; }
.sync-dot.sync-off { background: #6b7280; }
.sync-dot.sync-loading { background: #eab308; animation: syncPulse 1s infinite; }
.sync-dot.sync-error { background: #ef4444; box-shadow: 0 0 6px #ef4444; }
.sync-dot.sync-dirty { background: var(--warning); box-shadow: 0 0 6px var(--warning); }
@keyframes syncPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
.sync-label { font-size: 0.72rem; color: var(--text-secondary); white-space: nowrap; }
header .sync-label { color: #fff; }

/* ------------------------------- Abas ------------------------------------ */
.tabs {
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 14px 12px 0;
    max-width: 1200px;
    margin: 0 auto;
}

.tab {
    padding: 9px 22px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.8rem;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    cursor: pointer;
    border-radius: 30px;
    transition: background var(--transition), color var(--transition);
}

.tab:hover { background: var(--bg-strong); color: var(--text); }

.tab.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 3px 8px rgba(85, 107, 47, 0.35);
}

.tab-content { max-width: 1200px; margin: 14px auto 28px; padding: 0 12px; }
.tab-content[hidden] { display: none; }

/* --------------------------- Faixa de avisos ----------------------------- */
.alert-strip {
    margin: 0 0 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.alert {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    border: 1px solid;
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 0.85rem;
}

.alert .alert-icon { flex-shrink: 0; }
.alert .alert-msg { flex: 1 1 260px; }

.alert-warning { background: var(--warning-light); border-color: var(--warning); color: #6b4e06; }
.alert-info { background: var(--info-light); border-color: var(--info); color: #1e40af; }
.alert-danger { background: var(--danger-light); border-color: var(--danger); color: #7f1d1d; }

.alert .btn { margin-left: 2px; }

/* ----------------------------- Cards de status --------------------------- */
.stats-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin: 16px 0;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition), box-shadow var(--transition);
}

.stat-card.clickable { cursor: pointer; }
.stat-card.clickable:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--border-strong);
}

.stat-card.active {
    border-color: var(--primary);
    background: var(--success-light);
    box-shadow: 0 0 0 2px var(--primary-light);
}

.stat-number { font-size: 1.3rem; font-weight: 700; color: var(--text); display: block; }
.stat-label { font-size: 0.68rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }
.stat-card.is-money .stat-number { color: var(--primary-dark); }

.stat-card.stat-positive { border-left: 4px solid var(--success); }
.stat-card.stat-warn { border-left: 4px solid var(--warning); }
.stat-card.stat-over { border-left: 4px solid var(--danger); }

/* Barra de consumo do card "Total disponível" */
.stat-card .avl-bar {
    display: block;
    height: 6px;
    margin-top: 8px;
    background: var(--border);
    border-radius: 999px;
    overflow: hidden;
}
.stat-card .avl-fill {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--success), var(--primary));
    transition: width .3s ease;
}
.stat-card.stat-warn .avl-fill { background: var(--warning); }
.stat-card.stat-warn .stat-number { color: var(--warning); }
.stat-card.stat-over .avl-fill { background: var(--danger); }
.stat-card.stat-over .stat-number { color: var(--danger); }
.avl-msg {
    display: block;
    margin-top: 4px;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--danger);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

/* ------------------------------ Botões ----------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: filter var(--transition), transform var(--transition), box-shadow var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn:active { transform: translateY(1px); }

.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 2px 6px rgba(0,0,0,0.18); }
.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); }
.btn-secondary:hover { background: var(--surface-hover); }

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

.btn-link { background: none; border: none; color: var(--primary-dark); padding: 8px 10px; text-decoration: underline; }
.btn-link:hover { color: var(--primary); }

.btn-small { padding: 7px 12px; font-size: 0.78rem; }

.btn-icon {
    width: 32px; height: 32px; padding: 0;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-secondary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.btn-icon:hover { background: var(--bg-strong); color: var(--text); border-color: var(--border-strong); }
.btn-icon.danger:hover { background: var(--danger-light); color: var(--danger); border-color: var(--danger); }

/* ------------------------------ Toolbar ---------------------------------- */
.toolbar {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 14px;
}

.toolbar-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.toolbar-search { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.search-box {
    flex: 1 1 240px;
    position: relative;
}

.search-box input {
    width: 100%;
    padding: 10px 14px 10px 38px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    font-family: inherit;
    font-size: 0.85rem;
    color: var(--text);
    transition: border-color var(--transition), background var(--transition);
}

.search-box::before {
    content: '🔍';
    position: absolute;
    left: 12px; top: 50%;
    transform: translateY(-50%);
    font-size: 0.85rem;
    opacity: 0.6;
    pointer-events: none;
}

input, select, textarea {
    font-family: inherit;
    font-size: 0.85rem;
    color: var(--text);
}

input[type="search"]::-webkit-search-cancel-button { cursor: pointer; }

/* ------------------------- Área de filtros ------------------------------- */
.toolbar-filters {
    background: var(--bg);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.toolbar-filters[hidden] { display: none; }

.filter-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }

.filter-group { display: flex; flex-direction: column; gap: 4px; flex: 1 1 150px; min-width: 130px; }

.filter-group label {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.filter-group select,
.filter-group input {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    transition: border-color var(--transition);
}

.filter-group select:focus,
.filter-group input:focus { border-color: var(--primary-light); }

.filter-row .btn { align-self: center; }

/* Chips de filtros ativos */
.active-chips { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.active-chips[hidden] { display: none; }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--primary);
    color: #fff;
    border-radius: 30px;
    padding: 4px 6px 4px 12px;
    font-size: 0.75rem;
    font-weight: 500;
}
.chip .chip-x {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #fff;
    width: 18px; height: 18px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.7rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.chip .chip-x:hover { background: rgba(255, 255, 255, 0.35); color: #fff; }

/* ------------------------- Dropdown "Mais ações" -------------------------- */
.dropdown { position: relative; }

.dropdown-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    min-width: 230px;
    padding: 6px;
    z-index: 60;
    animation: dropdownIn 0.14s ease;
}
.dropdown-menu[hidden] { display: none; }

@keyframes dropdownIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

.dropdown-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 9px 12px;
    border: none;
    background: none;
    border-radius: 6px;
    font-size: 0.82rem;
    color: var(--text);
    cursor: pointer;
}
.dropdown-item:hover { background: var(--bg); color: var(--primary-dark); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-item.danger:hover { background: var(--danger-light); color: var(--danger-dark); }

.dropdown-sep { border-top: 1px solid var(--border); margin: 5px 8px; }

/* ----------------------------- Tabela ------------------------------------ */
.table-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.data-table { width: 100%; border-collapse: collapse; }

.data-table thead th {
    position: sticky;
    top: 0;
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: #fff;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    padding: 12px 12px;
    text-align: left;
    border-bottom: 2px solid var(--primary-light);
    z-index: 5;
}

.data-table tbody td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    font-size: 0.82rem;
}

.data-table tbody tr { transition: background var(--transition); }
.data-table tbody tr:hover { background: var(--surface-hover); }

/* cabeçalho ordenável */
.sort-btn {
    background: none;
    border: none;
    color: inherit;
    font: inherit;
    font-weight: inherit;
    letter-spacing: inherit;
    text-transform: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 4px;
    border-radius: 4px;
}
.sort-btn .sort-icon::after { content: '↕'; opacity: 0.55; font-size: 0.75rem; }

th[aria-sort="ascending"] .sort-icon::after { content: '▲'; opacity: 1; }
th[aria-sort="descending"] .sort-icon::after { content: '▼'; opacity: 1; }

/* alinhamentos de coluna */
.th-price, .td-price { text-align: right; }
.th-price .sort-btn { flex-direction: row-reverse; }
.td-price { font-weight: 600; white-space: nowrap; }

.th-date, .td-date { white-space: nowrap; }

.td-route { max-width: 320px; }
.route { display: flex; align-items: center; gap: 6px; min-width: 0; }
.route-span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.route-arrow { color: var(--text-muted); flex-shrink: 0; }

.td-pass .pass-name { font-weight: 600; }
.td-pass .pass-id { font-size: 0.72rem; color: var(--text-muted); }

.td-actions { white-space: nowrap; text-align: right; display: flex; gap: 6px; justify-content: flex-end; }
.data-table td.td-actions { display: table-cell; text-align: right; }
.td-actions .btn-icon { margin-left: 4px; }

/* linha de detalhes expansíveis */
.detail-row td { background: var(--bg); }
.detail-panel {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 8px 18px;
    padding: 4px 2px;
}
.detail-field { font-size: 0.78rem; color: var(--text-secondary); min-width: 0; }
.detail-field strong { display: block; font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-muted); margin-bottom: 2px; }
.detail-field span { color: var(--text); word-break: break-word; }

/* total no rodapé da tabela */
.data-table tfoot td {
    padding: 11px 12px;
    background: var(--bg-strong);
    border-top: 2px solid var(--border-strong);
    font-weight: 700;
    color: var(--primary-dark);
    font-size: 0.8rem;
}

/* estado de carregamento (skeleton) */
.skeleton { background: linear-gradient(90deg, #ecece4 25%, #f7f7f2 50%, #ecece4 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 5px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skeleton-cell { height: 16px; }
.skeleton-row .td-date { width: 90px; margin-right: auto; }

/* ----------------------- Cards (aparelhos pequenos) ----------------------- */
.cards-list { display: none; flex-direction: column; gap: 12px; padding: 12px; }
.card-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.card-item .card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.card-item .card-title { font-weight: 700; font-size: 0.95rem; }
.card-item .card-meta { font-size: 0.78rem; color: var(--text-secondary); }
.card-item .card-route { display: flex; gap: 6px; align-items: center; font-size: 0.85rem; color: var(--text); }
.card-item .card-price { font-weight: 700; font-size: 1.05rem; color: var(--primary-dark); }
.card-item .card-actions { display: flex; gap: 8px; margin-top: 4px; flex-wrap: wrap; }
.card-item .detail-panel { margin-top: 6px; }
.card-item .detail-field strong { color: var(--text-muted); }

/* ----------------------------- Rodapé da tabela --------------------------- */
.table-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 12px 14px;
    border-top: 1px solid var(--border);
    background: var(--surface);
}

.table-info { font-size: 0.8rem; color: var(--text-secondary); }

.pagination { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; }

.page-btn {
    min-width: 34px; height: 34px;
    padding: 0 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.page-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary-dark); background: var(--bg); }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-btn:disabled { opacity: 0.45; cursor: default; }
.page-ellipsis { color: var(--text-muted); padding: 0 2px; }

.per-page { display: flex; align-items: center; gap: 6px; font-size: 0.78rem; color: var(--text-secondary); }
.per-page select { padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }

/* ----------------------------- Estado vazio ------------------------------- */
.empty-state {
    text-align: center;
    padding: 50px 20px;
    color: var(--text-muted);
}
.empty-state svg { margin-bottom: 10px; color: var(--border-strong); }
.empty-state h3 { color: var(--text); font-size: 1.1rem; margin-bottom: 6px; }
.empty-state p { margin: 0 0 14px; font-size: 0.85rem; }

/* ------------------------------- Badges ----------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 30px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.2px;
    white-space: nowrap;
}
.badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.badge-success { background: var(--success-light); color: var(--primary-dark); }
.badge-info { background: var(--info-light); color: var(--info); }
.badge-warning { background: var(--warning-light); color: var(--warning-dark); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-purple { background: var(--purple-light); color: var(--purple); }
.badge-muted { background: var(--bg-strong); color: var(--text-muted); }
.badge-muted::before { background: var(--border-strong); }

/* ------------------------------- Modais ----------------------------------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(30, 40, 15, 0.55);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    backdrop-filter: blur(2px);
    overscroll-behavior: contain;
}
.modal-overlay[hidden] { display: none; }

body:has(.modal-overlay:not([hidden])) { overflow: hidden; }

.modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-height: calc(100dvh - 32px);
    display: flex;
    flex-direction: column;
    width: 100%;
    animation: modalIn 0.18s ease;
    overscroll-behavior: contain;
}

.modal-small { max-width: 460px; }
.modal-large { max-width: 760px; }

@keyframes modalIn {
    from { opacity: 0; transform: translateY(14px) scale(0.98); }
    to { opacity: 1; transform: none; }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 16px 20px;
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: #fff;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    flex: 0 0 auto;
}
.modal-header h3 { font-size: 1.05rem; font-weight: 600; }

.modal-close {
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    border-radius: 8px;
    width: 32px; height: 32px;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
}
.modal-close:hover { background: rgba(255, 255, 255, 0.28); }

.modal-body { padding: 18px 20px; overflow-y: auto; flex: 1 1 auto; min-height: 0; overscroll-behavior: contain; }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    background: var(--bg);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    flex-wrap: wrap;
    flex: 0 0 auto;
}

.modal-hint { font-size: 0.8rem; color: var(--text-secondary); margin: 0 0 14px; }

.confirm-msg { margin: 0; font-size: 0.9rem; color: var(--text); }
.confirm-msg strong { display: block; margin-top: 8px; font-size: 0.82rem; color: var(--text-secondary); }

/* ------------------------- Formulário de corrida --------------------------- */
#form-corrida {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    margin: 0;
}
.form-sections { display: flex; flex-direction: column; gap: 18px; }

.form-section h4 {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px 16px;
}

@media (max-width: 800px) {
    .form-grid { grid-template-columns: repeat(2, 1fr); }
}

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

.form-field { display: flex; flex-direction: column; gap: 5px; }
.form-field.full { grid-column: 1 / -1; }

.form-field label { font-size: 0.72rem; font-weight: 600; color: var(--text-secondary); }
.form-field .req { color: var(--danger); }

.form-field input,
.form-field select,
.form-field textarea {
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    width: 100%;
    transition: border-color var(--transition), background var(--transition);
}
.form-field textarea { resize: vertical; min-height: 62px; }

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus { border-color: var(--primary-light); background: var(--surface); }

.form-field.has-error input,
.form-field.has-error select,
.form-field.has-error textarea { border-color: var(--danger); background: var(--danger-light); }

.field-error { font-size: 0.72rem; color: var(--danger); }

.form-error {
    background: var(--danger-light);
    border: 1px solid var(--danger);
    color: #7f1d1d;
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    margin-bottom: 14px;
    font-size: 0.82rem;
}

/* ------------------------ Lista de linhas incompletas ---------------------- */
.incomplete-list { display: flex; flex-direction: column; gap: 10px; }

.incomplete-item {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.incomplete-item .inc-title { font-weight: 600; font-size: 0.88rem; }
.incomplete-item .inc-sub { font-size: 0.8rem; color: var(--text-secondary); }
.incomplete-item .inc-tag {
    align-self: flex-start;
    margin-top: 6px;
    background: var(--warning-light);
    color: var(--warning-dark);
    border: 1px solid var(--warning);
    border-radius: 30px;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 2px 10px;
}

/* ------------------------------- Resumo ------------------------------------ */
.grid-resumo {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
    margin-top: 16px;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 16px;
}
.panel h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}
.panel-body { display: flex; flex-direction: column; gap: 10px; }

.resumo-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 0.85rem; }
.resumo-row .resumo-label { color: var(--text-secondary); }
.resumo-row .resumo-value { font-weight: 700; color: var(--text); }
.resumo-row .resumo-value.primary { color: var(--primary-dark); }

.hbar { display: flex; flex-direction: column; gap: 4px; }
.hbar .hbar-label { display: flex; justify-content: space-between; font-size: 0.78rem; color: var(--text-secondary); }
.hbar .hbar-track { height: 9px; border-radius: 20px; background: var(--bg-strong); overflow: hidden; }
.hbar .hbar-fill { height: 100%; border-radius: 20px; background: linear-gradient(90deg, var(--primary-light), var(--primary)); min-width: 2px; }

.resumo-toolbar { flex-direction: row; align-items: flex-end; }

/* -------------------------------- Toasts ----------------------------------- */
.toast-container {
    position: fixed;
    bottom: 18px;
    right: 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 200;
    max-width: 340px;
}

.toast {
    background: var(--text);
    color: #fff;
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    font-size: 0.82rem;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: flex-start;
    gap: 10px;
    animation: toastIn 0.22s ease;
    border-left: 4px solid var(--success);
}
.toast.toast-warning { border-left-color: var(--warning); }
.toast.toast-error { border-left-color: var(--danger); }
.toast.toast-info { border-left-color: var(--info); }

@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }
.toast.out { animation: toastOut 0.2s ease forwards; }
@keyframes toastOut { to { opacity: 0; transform: translateX(20px); } }

/* -------------------------------- Footer ----------------------------------- */
footer {
    border-top: 1px solid var(--border);
    background: var(--surface);
    margin-top: 24px;
    padding: 18px 12px;
}
.footer-content { max-width: 1200px; margin: 0 auto; display: flex; flex-direction: column; gap: 4px; }
.footer-content p { margin: 0; font-size: 0.78rem; color: var(--text-secondary); }
.footer-content strong { color: var(--primary-dark); }
.footer-muted { color: var(--text-muted) !important; }

/* ----------------------------- Responsivo ---------------------------------- */
@media (max-width: 900px) {
    /* transforma a tabela em cards */
    .data-table { display: none; }
    .cards-list { display: flex; }
    .table-footer { justify-content: center; }
}

@media (max-width: 600px) {
    html { font-size: 15px; }
    .header-content { gap: 10px; }
    .header-text h1 { font-size: 1.05rem; }
    .header-logo { width: 44px; height: 44px; }
    .header-date { display: none; }
    .toolbar-search { flex-direction: column; align-items: stretch; }
    .search-box { flex: 1 1 auto; }
    .btn.inline-full { width: 100%; }
    .stats-bar { gap: 8px; }
    .stat-card { padding: 10px 12px; }
    .stat-number { font-size: 1.3rem; }
    .modal-body { padding: 14px 16px; }
    .resumo-toolbar { flex-direction: column; align-items: stretch; }
}

@media (max-width: 380px) {
    html { font-size: 14px; }
    .tab { padding: 8px 14px; font-size: 0.72rem; }
}

/* Acessibilidade: respeita redução de movimento */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}