/* Herda variáveis de cores do styles.css (carregado antes) */

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font-body);
    display: block;
    height: auto;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    /* Reserva a calha da barra de rolagem sempre — evita o "pulo" horizontal da
       página (header e .admin-main são centralizados) ao trocar entre abas com
       alturas diferentes (uma com scrollbar, outra sem). */
    scrollbar-gutter: stable;
    overflow-y: scroll;
}

/* ── Header ──────────────────────────────────────── */
.admin-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 14px 32px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.admin-header-inner {
    max-width: 1036px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.admin-header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.admin-logo {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

.admin-title {
    font-family: var(--font-display);
    font-size: 17px;
    font-weight: 600;
    color: var(--primary);
    letter-spacing: -0.4px;
}

.admin-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    padding: 6px 12px;
    transition: all 0.2s;
}

.admin-back-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* ── Main ────────────────────────────────────────── */
.admin-main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 28px 32px 60px;
    display: flex;
    flex-direction: column;
    gap: 32px;
}

/* ── Cards de resumo ─────────────────────────────── */
.admin-cards {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 16px;
}

.admin-card {
    min-width: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: var(--shadow-sm);
}

.admin-card-icon {
    font-size: 26px;
    line-height: 1;
}

.admin-card-info {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.admin-card-value {
    font-family: var(--font-display);
    font-size: clamp(20px, 2.2vw, 26px);
    font-weight: 600;
    color: var(--primary);
    letter-spacing: -0.5px;
    line-height: 1.2;
    overflow-wrap: anywhere;
    font-variant-numeric: tabular-nums;
}

.admin-card-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ── Seções ──────────────────────────────────────── */
.admin-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.admin-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
    gap: 12px 20px;
    flex-wrap: wrap;
}

.admin-section-header > div { min-width: 0; flex-wrap: wrap; }
.admin-section { scroll-margin-top: 100px; }
.admin-section-body { padding: 20px 22px; }
#metricas-rota-resumo { margin: 0; padding: 16px 22px 6px; line-height: 1.6; }
.admin-table-actions { display: flex; align-items: center; gap: 4px; }

.admin-section-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
}

.admin-section-sub {
    font-size: 12px;
    font-weight: 400;
    color: var(--text-muted);
    margin-left: 6px;
}

/* ── Tabelas ─────────────────────────────────────── */
.admin-table-wrap {
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

.admin-table th {
    background: var(--bg);
    color: var(--text-muted);
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 10px 18px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.admin-table td {
    padding: 12px 18px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    vertical-align: middle;
}

.admin-table tbody tr:last-child td { border-bottom: none; }

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

.admin-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 32px !important;
    font-size: 13px;
}

/* ── Badges ──────────────────────────────────────── */
.badge-admin {
    background: var(--primary-light);
    color: var(--primary);
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.badge-user {
    background: var(--bg);
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.badge-erro {
    background: var(--danger-bg);
    color: var(--danger-text);
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    text-transform: uppercase;
}

.badge-guardrail {
    background: var(--warning-bg);
    color: var(--warning-text);
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    text-transform: uppercase;
}

.badge-fora {
    background: var(--bg);
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    text-transform: uppercase;
}

/* ── Botões ──────────────────────────────────────── */
.admin-btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: opacity 0.2s;
}
.admin-btn-primary:hover { opacity: 0.85; }

.admin-btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: none;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    color: var(--text-muted);
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
}
.admin-btn-secondary:hover { border-color: var(--primary); color: var(--primary); }

.admin-btn-danger {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px 6px;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
    display: inline-flex;
    align-items: center;
}
.admin-btn-danger:hover { background: var(--danger-bg); color: var(--danger); }

.admin-btn-reset {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px 6px;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
    display: inline-flex;
    align-items: center;
}
.admin-btn-reset:hover { background: var(--primary-light); color: var(--primary); }

.badge-sucesso {
    background: var(--success-bg);
    color: var(--success-text);
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.badge-locked {
    background: var(--danger-bg-strong);
    color: var(--danger);
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-left: 6px;
}

/* ── Modal ───────────────────────────────────────── */
.admin-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    z-index: 100;
}
.admin-modal-overlay.open { display: block; }

.admin-modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(420px, calc(100vw - 32px));
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.18);
    z-index: 101;
}
.admin-modal.open { display: block; }

.admin-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px 14px;
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    border-bottom: 1px solid var(--border);
}

.admin-modal-close {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
    padding: 0 4px;
}
.admin-modal-close:hover { color: var(--text); }

.admin-modal-body { padding: 20px 22px; display: flex; flex-direction: column; gap: 14px; }

.admin-field { display: flex; flex-direction: column; gap: 6px; }

.admin-field label {
    font-size: 12px;
    font-weight: 700;
    color: var(--text);
}

.admin-field small { color: var(--text-muted); font-weight: 400; }

.admin-field input {
    width: 100%;
    min-width: 0;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    background: var(--bg);
    color: var(--text);
    transition: border-color 0.2s;
}
.admin-field input:focus {
    border-color: var(--primary);
    box-shadow: var(--focus-ring);
    background: var(--surface);
}

.admin-modal-feedback {
    font-size: 12px;
    min-height: 16px;
}
.admin-modal-feedback.ok { color: var(--success); }
.admin-modal-feedback.err { color: var(--danger); }

.admin-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 22px 18px;
    border-top: 1px solid var(--border);
}

/* ── Seletor de período ──────────────────────────── */
.periodo-selector {
    display: flex;
    gap: 2px;
    background: var(--border);
    border-radius: 8px;
    padding: 2px;
}

.periodo-btn {
    background: transparent;
    border: none;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    font-family: inherit;
}

.periodo-btn:hover { color: var(--text); }

.periodo-btn.active {
    background: var(--surface);
    color: var(--primary);
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* ── Gráficos de uso ─────────────────────────────── */
/*
   Layout:
   ┌─────────────────────────────────┐
   │   Perguntas por dia  (full)     │
   ├──────────────┬──────────────────┤
   │ Distribuição │  Horários pico   │
   └──────────────┴──────────────────┘
*/
.admin-charts-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
}

.admin-chart-card {
    padding: 18px 20px 20px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

/* Linha de baixo: sem borda inferior */
.admin-chart-card:nth-last-child(-n+2):not(.admin-chart-wide) {
    border-bottom: none;
}

/* Último card da linha 2: sem borda direita */
.admin-chart-card:last-child {
    border-right: none;
}

/* Linha de cima (wide): ocupa tudo, sem borda direita */
.admin-chart-wide {
    grid-column: 1 / -1;
    border-right: none;
}

.admin-chart-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 14px;
}

.admin-chart-wrap {
    position: relative;
    height: 200px;
}
.admin-chart-empty { height: 100%; display: grid; place-items: center; padding: 24px; text-align: center; color: var(--text-muted); font-size: 13px; }

/* ── Botão desbloquear ───────────────────────────── */
.admin-btn-unlock {
    background: var(--success-bg);
    border: 1px solid var(--success);
    color: var(--success-text);
    border-radius: 6px;
    padding: 4px 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: filter 0.15s;
}
.admin-btn-unlock:hover { filter: brightness(0.95); }

/* ── Seletor de perfil ───────────────────────────── */
.admin-role-select {
    border: 1px solid var(--border);
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 5px;
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
}
.admin-role-select:focus { outline: 2px solid var(--primary-light); outline-offset: 1px; }

/* Botão de uso ilimitado continua sendo uma ação de alternância, não um seletor. */
.admin-role-btn {
    border: none;
    cursor: pointer;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 999px;
    font-family: inherit;
    transition: opacity 0.15s;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.admin-role-btn:hover { opacity: 0.75; }

/* ── Ícone do stat card (SVG em vez de emoji) ────── */
.admin-card-icon {
    color: var(--primary);
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

/* ── Linhas expansíveis nas tabelas ──────────────── */
.admin-row-expandable { cursor: pointer; transition: background 0.15s; }
.admin-row-expandable:hover, .admin-row-active { background: var(--primary-light, #f3e8ff) !important; }
.admin-row-expanded td { padding: 0 !important; }
.admin-expand-content {
    padding: 12px 16px;
    font-size: 13px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    border-bottom: 2px solid var(--primary);
    white-space: pre-wrap;
    word-break: break-word;
}

/* SQL gerado (auditoria) dentro de uma linha expandida */
.admin-sql {
    margin: 6px 0 0;
    padding: 10px 12px;
    background: #1e1e2e;
    color: #e0e0e0;
    border-radius: 6px;
    font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
    font-size: 12px;
    line-height: 1.45;
    white-space: pre;
    overflow-x: auto;
    max-height: 360px;
    overflow-y: auto;
}

/* ── Indicador de item novo nas tabelas ──────────── */
.row-novo td:first-child {
    border-left: 3px solid var(--primary);
}
.row-novo {
    background: rgba(var(--primary-rgb), 0.06) !important;
}
.badge-novo {
    display: inline-block;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--primary);
    color: white;
    border-radius: 4px;
    padding: 1px 5px;
    vertical-align: middle;
    margin-left: 5px;
    line-height: 1.6;
}

.badge-novo-lido {
    cursor: pointer;
    transition: background 0.15s, opacity 0.15s;
}
.badge-novo-lido:hover {
    background: var(--primary-dark);
    opacity: 0.85;
}

/* ── Indicador online hoje ───────────────────────── */
.online-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--success);
    margin-right: 5px;
    vertical-align: middle;
}

/* ── Sino de notificações ────────────────────────── */
.sino-wrap {
    position: relative;
}
.sino-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1.5px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}
.sino-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light, #f3e8ff);
}
.sino-btn.sino-ativo {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light, #f3e8ff);
    animation: sino-shake 0.5s ease 0.3s;
}
@keyframes sino-shake {
    0%,100% { transform: rotate(0deg); }
    20%      { transform: rotate(-12deg); }
    40%      { transform: rotate(12deg); }
    60%      { transform: rotate(-8deg); }
    80%      { transform: rotate(8deg); }
}
.sino-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    background: var(--danger);
    color: white;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid var(--surface);
    line-height: 1;
}
.sino-popover {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 280px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    z-index: 500;
    overflow: hidden;
}
.sino-popover-inner {
    padding: 4px 0;
}
.sino-popover-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    padding: 10px 16px 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
}
.sino-popover-empty {
    font-size: 13px;
    color: var(--text-muted);
    padding: 16px;
    text-align: center;
    line-height: 1.5;
}
.sino-popover-item {
    width: 100%;
    border: none;
    background: transparent;
    font: inherit;
    text-align: left;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 16px;
    cursor: pointer;
    transition: background 0.15s;
    gap: 8px;
}
.sino-popover-item:hover {
    background: var(--primary-light, #f3e8ff);
}
.sino-popover-label {
    font-size: 13px;
    color: var(--text);
    flex: 1;
}
.sino-popover-count {
    font-size: 12px;
    font-weight: 700;
    color: white;
    background: var(--danger);
    border-radius: 999px;
    padding: 2px 8px;
    min-width: 28px;
    text-align: center;
}
.sino-popover-footer {
    padding: 8px 12px 10px;
    border-top: 1px solid var(--border);
    margin-top: 4px;
    display: flex;
    justify-content: center;
}
.sino-marcar-lidas {
    display: flex;
    align-items: center;
    gap: 5px;
    background: none;
    border: 1.5px solid var(--border);
    border-radius: 7px;
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
    width: 100%;
    justify-content: center;
}
.sino-marcar-lidas:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light, #f3e8ff);
}

/* ── Botão voltar ao topo ────────────────────────── */
.btn-topo {
    position: fixed;
    bottom: 32px;
    right: 28px;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0,0,0,0.22);
    opacity: 0;
    transform: translateY(12px);
    pointer-events: none;
    transition: opacity 0.22s, transform 0.22s;
    z-index: 400;
}
.btn-topo:hover { opacity: 0.85; }
.btn-topo-visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* ── Abas de navegação ───────────────────────────── */
.admin-tabs {
    overflow-x: auto;
    display: flex;
    gap: 3px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 4px;
    box-shadow: var(--shadow-sm);
}

.admin-tab-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: transparent;
    border: none;
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
    position: relative;
}

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

.admin-tab-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 8px rgba(var(--primary-rgb), 0.25);
}

.admin-tab-btn.active svg { stroke: white; }

.admin-tab-dot {
    display: none;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--danger);
    flex-shrink: 0;
}
.admin-tab-dot.visible { display: inline-block; }

/* Esconde dot no botão ativo (a cor vermelha fica pouco visível) */
.admin-tab-btn.active .admin-tab-dot {
    background: var(--danger-text);
}

.admin-tab-panel {
    display: none;
    flex-direction: column;
    gap: 24px;
}

.admin-tab-panel.active {
    display: flex;
}

/* ── Piloto do Agente Analítico ─────────────────── */
.piloto-descricao { margin: 5px 0 0; max-width: 680px; line-height: 1.45; }
.piloto-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.piloto-label { display: block; margin-bottom: 7px; font-size: 13px; font-weight: 700; color: var(--text); }
.piloto-label span { color: var(--text-muted); font-weight: 500; }
.piloto-prompts {
    width: 100%; min-height: 240px; resize: vertical; box-sizing: border-box;
    border: 1.5px solid var(--border); border-radius: 10px; padding: 12px;
    background: var(--bg); color: var(--text); font: 13px/1.55 var(--font-mono, monospace);
    outline: none;
}
.piloto-prompts:focus { border-color: var(--primary); }
.piloto-status { min-height: 20px; margin-top: 14px; color: var(--text-muted); font-size: 13px; }
.piloto-resumo { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.piloto-resumo:empty { display: none; }
.piloto-resumo-item {
    padding: 5px 9px; border-radius: 999px; background: var(--bg);
    color: var(--text-muted); font-size: 12px; font-weight: 600;
}
.piloto-resumo-item.ok { background: var(--success-bg); color: var(--success-text); }
.piloto-resumo-item.alerta { background: var(--warning-bg); color: var(--warning-text); }
.piloto-resumo-item.erro { background: var(--danger-bg); color: var(--danger-text); }
.piloto-resultados { display: grid; gap: 10px; }
.piloto-resultado {
    border: 1px solid var(--border); border-radius: 10px; padding: 13px;
    background: var(--surface);
}
.piloto-resultado-topo { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.piloto-resultado-numero { color: var(--text-muted); font-size: 12px; font-weight: 700; }
.piloto-resultado-status { border-radius: 999px; padding: 3px 8px; font-size: 11px; font-weight: 700; }
.piloto-resultado-status.ok { background: var(--success-bg); color: var(--success-text); }
.piloto-resultado-status.alerta { background: var(--warning-bg); color: var(--warning-text); }
.piloto-resultado-status.erro { background: var(--danger-bg); color: var(--danger-text); }
.piloto-resultado-tempo { margin-left: auto; color: var(--text-muted); font-size: 12px; }
.piloto-pergunta { margin: 10px 0 5px; font-weight: 700; font-size: 13px; white-space: pre-wrap; }
.piloto-resposta { margin: 0; color: var(--text); font-size: 13px; line-height: 1.5; white-space: pre-wrap; }
.piloto-metadados { margin-top: 9px; color: var(--text-muted); font-size: 12px; }
.piloto-trilha { margin-top: 10px; color: var(--text-muted); font-size: 12px; }
.piloto-trilha summary { cursor: pointer; font-weight: 700; color: var(--primary); }
.piloto-trilha p { margin: 7px 0 0; line-height: 1.45; white-space: pre-wrap; }

/* ── Responsivo ──────────────────────────────────── */
@media (max-width: 768px) {
    /* Nenhum conteúdo deve alargar a página além da viewport (as tabelas rolam
       dentro do próprio .admin-table-wrap) — backstop contra scroll horizontal. */
    body { overflow-x: hidden; }
    .admin-main { padding: 20px 16px 40px; min-width: 0; max-width: 100%; }
    .admin-header { padding: 12px 16px; }
    .admin-cards { grid-template-columns: repeat(2, 1fr); }
    .admin-cards .admin-card:last-child { grid-column: span 2; }
    .admin-modal { width: calc(100vw - 32px); }
    .admin-charts-grid { grid-template-columns: 1fr; }
    .admin-chart-card { border-right: none !important; }
    .admin-chart-wide { grid-column: 1; }
    .admin-chart-card:nth-last-child(-n+2):not(.admin-chart-wide) { border-bottom: 1px solid var(--border); }
    .admin-chart-card:last-child { border-bottom: none; }
    .admin-tabs { overflow-x: auto; gap: 2px; padding: 3px; }
    .admin-tab-btn { flex: none; padding: 8px 10px; font-size: 12px; gap: 4px; }
    .admin-tab-btn svg { display: none; }
    .piloto-resultado-tempo { margin-left: 0; }

    /* Cabeçalho de seção: título e cluster de controles quebram em linhas
       em vez de forçar a seção a ficar mais larga que a tela ("esticado"). */
    .admin-section-header { flex-wrap: wrap; gap: 10px 12px; }
    .admin-section-header > div { flex-wrap: wrap; }
    /* O filtro de usuários tinha largura fixa de 160px (inline) — ocupa a linha
       inteira no mobile e para de empurrar a largura da seção. */
    .admin-section-header input[type="text"] { flex: 1 1 100%; width: auto !important; min-width: 0; }
}

/* ── Mobile pequeno ≤ 480px ──────────────────────── */
@media (max-width: 480px) {
    .admin-main { padding: 16px 12px 40px; }
    .admin-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .admin-cards .admin-card:last-child { grid-column: span 2; }
    .admin-card { padding: 16px 12px; gap: 8px; }
    .admin-card-icon svg { width: 22px; height: 22px; }
    .admin-title { font-size: 15px; }
    .admin-header-left { gap: 8px; }
    .admin-back-btn { white-space: nowrap; padding: 8px; font-size: 12px; }
    .admin-header-inner { gap: 8px; }
    .admin-header-inner { flex-wrap: wrap; }
    .admin-header-inner > div:last-child { margin-left: auto; }
    .admin-section-header, .admin-section-body { padding: 16px; }
    .sino-popover { position: fixed; top: 80px; right: 12px; width: min(320px, calc(100vw - 24px)); }
}

/* Mesma área de toque e feedback em todos os controles do painel. */
.admin-btn-primary, .admin-btn-secondary, .periodo-btn, .admin-role-select,
.admin-modal-close, .admin-btn-danger, .admin-btn-reset, .admin-btn-unlock,
.admin-role-btn { min-height: 36px; }
.admin-modal-close, .admin-btn-danger, .admin-btn-reset, .admin-btn-unlock { min-width: 36px; justify-content: center; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
.admin-btn-confirm-danger { background: var(--danger); color: var(--surface); padding: 8px 14px; border-radius: 8px; border: none; font: 600 13px var(--font-body); min-height: 36px; cursor: pointer; }
.piloto-resultado { overflow-wrap: anywhere; }
@media (pointer: coarse) {
    .admin-tab-btn, .periodo-btn, .admin-btn-primary, .admin-btn-secondary,
    .admin-role-select, .admin-role-btn, .admin-modal-close,
    .admin-btn-danger, .admin-btn-reset, .admin-btn-unlock { min-height: 44px; }
}
