/* ── TOP 10 DELIVERY — APP DO ENTREGADOR v2 (KHP-044) ── */

:root {
    --background: #0A0A0C;
    --surface: #121214;
    --surface-secondary: #19191C;
    --surface-tertiary: #222226;
    --text: #F3F4F6;
    --muted: #9CA3AF;
    --primary: #FF6B35;
    --primary-hover: #E85A2A;
    --primary-glow: rgba(255, 107, 53, 0.25);
    --success: #10B981;
    --success-hover: #059669;
    --success-glow: rgba(16, 185, 129, 0.25);
    --danger: #EF4444;
    --danger-hover: #DC2626;
    --blue: #3B82F6;
    --border: rgba(255, 255, 255, 0.08);
    --border-bright: rgba(255, 255, 255, 0.16);
    --shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
    --transition: 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--background);
    color: var(--text);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 15px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    line-height: 1.5;
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-thumb { background: var(--surface-tertiary); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* ── HEADER & NAV ── */
.top-bar {
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.logo-brand {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    color: var(--primary);
    font-size: 18px;
    letter-spacing: -0.5px;
    line-height: 1.2;
}
.logo-brand span { color: var(--text); font-weight: 500; }

/* KHP-053C: Branding com empresa + entregador */
.top-bar-center {
    flex: 1;
    text-align: center;
    min-width: 0;
    padding: 0 10px;
}
.top-bar-sub {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 12px;
    color: var(--muted);
    margin-top: 2px;
    flex-wrap: wrap;
}
.top-bar-sub #empresa-nome {
    font-weight: 600;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 160px;
}
.top-bar-sub #entregador-nome {
    font-weight: 500;
    color: var(--muted);
    opacity: 0.8;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 120px;
}

.btn-icon {
    background: var(--surface-secondary);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 22px;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}
.btn-icon:active { background: var(--surface-tertiary); transform: scale(0.95); }

.status-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 700;
    font-family: 'Space Grotesk', sans-serif;
    background: var(--surface-secondary);
    padding: 6px 14px;
    border-radius: 100px;
    border: 1px solid var(--border);
    cursor: pointer;
}

.dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--danger);
    transition: var(--transition);
}
.dot.online {
    background: var(--success);
    box-shadow: 0 0 10px var(--success-glow), 0 0 4px var(--success);
}

/* ── STATES ── */
.app-state {
    display: none;
    flex: 1;
    flex-direction: column;
    padding: 20px;
    max-width: 540px;
    width: 100%;
    margin: 0 auto;
    animation: fadeIn 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
.app-state.active { display: flex; }
#state-mapa-view.app-state { max-width: 100%; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.state-container {
    text-align: center;
    justify-content: center;
    align-items: center;
    height: 100%;
    gap: 20px;
    padding-top: 40px;
    padding-bottom: 40px;
}

.status-icon { font-size: 64px; margin-bottom: 8px; user-select: none; }

/* ── PULSE RADAR ── */
.pulse-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 120px;
    height: 120px;
    margin-bottom: 12px;
}
.pulse-ring {
    position: absolute;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: var(--primary-glow);
    border: 2px solid var(--primary);
    animation: pulseRing 2s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
}
@keyframes pulseRing {
    0% { transform: scale(0.8); opacity: 0.8; }
    50% { transform: scale(1.4); opacity: 0.3; }
    100% { transform: scale(1.9); opacity: 0; }
}

/* ── BUTTONS ── */
.btn-toggle-status {
    padding: 18px 36px;
    border-radius: 100px;
    border: none;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 15px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: var(--transition);
    width: 100%;
    max-width: 280px;
    box-shadow: var(--shadow);
}
.btn-online { background: var(--success); color: #052E16; }
.btn-online:active { transform: scale(0.98); background: var(--success-hover); }
.btn-offline { background: var(--surface-tertiary); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.3); }
.btn-offline:active { transform: scale(0.98); background: rgba(239, 68, 68, 0.15); }

.btn-sm {
    background: var(--surface-secondary);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 18px;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}
.btn-sm:active { background: var(--surface-tertiary); transform: scale(0.95); }

/* ── SECTION LABEL ── */
.section-label {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--muted);
    margin-bottom: 12px;
}

/* ── SIDEBAR ── */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    display: none;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.sidebar-overlay.open { display: flex; animation: fadeIn 0.2s ease; }

.sidebar-sheet {
    background: var(--surface);
    border-right: 1px solid var(--border-bright);
    width: 280px;
    max-width: 80vw;
    height: 100vh;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 30px rgba(0, 0, 0, 0.5);
    animation: slideInLeft 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes slideInLeft {
    from { transform: translateX(-100%); }
    to { transform: translateX(0); }
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
}
.sidebar-items { display: flex; flex-direction: column; gap: 4px; }
.sidebar-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 12px;
    border-radius: 12px;
    background: none;
    border: none;
    color: var(--text);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    width: 100%;
    text-align: left;
    font-family: 'Inter', sans-serif;
}
.sidebar-item:active { background: var(--surface-secondary); }
.sidebar-icon { font-size: 20px; }
.sidebar-divider { height: 1px; background: var(--border); margin: 8px 0; }

/* ── DETAIL HEADER (Back button + title) ── */
.detail-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}
.order-numero {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 16px;
    font-weight: 700;
    color: var(--muted);
}

/* ── CARD PEDIDO ── */
.card-pedido {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 22px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.badge-etapa {
    padding: 6px 14px;
    border-radius: 100px;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-block;
    align-self: flex-start;
}
.etapa-preparo { background: rgba(59, 130, 246, 0.12); color: var(--blue); border: 1px solid rgba(59, 130, 246, 0.25); }
.etapa-rota { background: rgba(255, 107, 53, 0.12); color: var(--primary); border: 1px solid rgba(255, 107, 53, 0.25); }

.cliente-info h2 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    margin-top: 2px;
}
.cliente-phone-actions { display: flex; gap: 10px; margin-top: 8px; }
.btn-phone {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 8px;
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    text-decoration: none;
    font-size: 13px;
    font-weight: 700;
    border: 1px solid rgba(16, 185, 129, 0.2);
    transition: var(--transition);
}
.btn-phone:active { background: rgba(16, 185, 129, 0.2); }

.endereco-box {
    background: var(--surface-secondary);
    padding: 16px;
    border-radius: 14px;
    border: 1px solid var(--border);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
}
.endereco-box strong { font-family: 'Space Grotesk', sans-serif; color: var(--primary); }

/* ── ACTION BAR ── */
.action-bar { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }
.btn-action {
    padding: 15px;
    border-radius: 14px;
    border: none;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 13px;
    letter-spacing: 0.3px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}
.btn-primary { background: var(--primary); color: #1A0B00; }
.btn-primary:active { background: var(--primary-hover); transform: scale(0.98); }
.btn-success { background: var(--success); color: #052E16; }
.btn-success:active { background: var(--success-hover); transform: scale(0.98); }
.btn-outline { background: var(--surface-secondary); border: 1px solid var(--border-bright); color: var(--text); }
.btn-outline:active { background: var(--surface-tertiary); transform: scale(0.98); }
.btn-danger-outline { background: rgba(239, 68, 68, 0.08); border: 1px solid rgba(239, 68, 68, 0.3); color: var(--danger); }
.btn-danger-outline:active { background: rgba(239, 68, 68, 0.2); }

/* ── FILA INTELLIGENTE ── */
.fila-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.fila-actions { display: flex; gap: 8px; align-items: center; }
.fila-count {
    font-size: 13px;
    color: var(--muted);
    font-weight: 600;
    font-family: 'Space Grotesk', sans-serif;
}
.fila-lista {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 20px;
}
.fila-empty {
    text-align: center;
    color: var(--muted);
    padding: 60px 20px;
    font-size: 14px;
}
.fila-sortable { display: flex; flex-direction: column; gap: 10px; }

.fila-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}
.fila-card:active { transform: scale(0.98); background: var(--surface-secondary); }
.fila-card.dragging { opacity: 0.5; transform: scale(0.95); }

.fila-posicao {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: #1A0B00;
    font-weight: 800;
    font-size: 15px;
    font-family: 'Space Grotesk', sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.fila-info { flex: 1; min-width: 0; }
.fila-cliente {
    font-weight: 700;
    font-size: 15px;
    color: var(--text);
    margin-bottom: 2px;
}
.fila-endereco {
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.fila-side { text-align: right; flex-shrink: 0; }
.fila-status {
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    padding: 3px 8px;
    border-radius: 100px;
    display: inline-block;
    margin-bottom: 4px;
}
.fila-taxa {
    font-size: 14px;
    font-weight: 700;
    color: var(--primary);
    font-family: 'Space Grotesk', sans-serif;
}

/* ── MAPA ── */
.mapa-topbar {
    position: relative;
    height: 0;
    z-index: 1000;
}
.mapa-container {
    flex: 1;
    width: 100%;
    min-height: calc(100vh - 60px);
    z-index: 1;
}
.btn-route-optimize {
    background: var(--primary);
    color: #1A0B00;
    border: none;
    padding: 10px 18px;
    border-radius: 100px;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(255, 107, 53, 0.4);
    transition: var(--transition);
}
.btn-route-optimize:active { transform: scale(0.96); }

.mapa-legenda {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 100px;
    padding: 8px 18px;
    display: flex;
    gap: 18px;
    z-index: 1000;
    box-shadow: var(--shadow);
}
.legenda-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 700;
    color: var(--muted);
}

/* ── SLIDE TO CONFIRM COMPONENT (ARRASTAR PARA CONFIRMAR) ── */
.slide-confirm-container {
    position: relative;
    width: 100%;
    height: 56px;
    background: var(--surface2, #242630);
    border: 1px solid var(--border, rgba(255,255,255,0.1));
    border-radius: 28px;
    overflow: hidden;
    user-select: none;
    touch-action: pan-y;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 2px 6px rgba(0,0,0,0.3);
}

.slide-confirm-fill {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 0;
    background: linear-gradient(90deg, #FF6B35, #10B981);
    border-radius: 28px;
    opacity: 0.85;
    transition: background 0.2s ease;
}

/* Slide de CONCLUIR fica verde puro ao completar */
#slide-finalizar-entrega .slide-confirm-fill {
    background: linear-gradient(90deg, #059669, #10B981);
}

/* Slide de CONCLUIR — handle fica verde quando arrastado */
#slide-finalizar-entrega .slide-confirm-handle {
    background: #10B981;
    color: #fff;
    transition: background 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 16px rgba(16,185,129,0.5);
}

.slide-confirm-label {
    position: relative;
    z-index: 2;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 14px;
    font-weight: 700;
    color: var(--text, #FFFFFF);
    letter-spacing: 0.5px;
    pointer-events: none;
    text-transform: uppercase;
}

.slide-confirm-handle {
    position: absolute;
    left: 4px;
    top: 4px;
    width: 48px;
    height: 48px;
    background: #FFFFFF;
    color: #1A0B00;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 800;
    cursor: grab;
    z-index: 3;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.slide-confirm-handle:active {
    cursor: grabbing;
}
.legenda-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

/* Leaflet custom markers */
.marcador-cliente .marker-numero {
    width: 32px;
    height: 32px;
    background: var(--blue);
    color: white;
    font-weight: 800;
    font-size: 14px;
    font-family: 'Space Grotesk', sans-serif;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}
.marcador-restaurante {
    font-size: 30px;
    text-align: center;
    line-height: 36px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}
.seta-rota {
    font-size: 18px;
    opacity: 0.7;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3));
}

/* ── FINANCEIRO ── */
.financeiro-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    width: 100%;
}
.fin-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 18px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.fin-label {
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.3px;
}
.fin-value {
    font-size: 20px;
    font-weight: 800;
    font-family: 'Space Grotesk', sans-serif;
}
.fin-value.primary { color: var(--primary); }

/* ── FINANCEIRO DASHBOARD (KHP-044.2) ── */
#state-financeiro.app-state { overflow-y: auto; padding-bottom: 40px; }

/* Totem cards */
.fin-summary-row {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}
.fin-totem {
    flex: 1;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    text-align: center;
}
.fin-totem-primary {
    border-color: var(--primary);
    background: linear-gradient(180deg, rgba(255,107,53,0.08) 0%, rgba(255,107,53,0.02) 100%);
}
.fin-totem-icon { font-size: 24px; }
.fin-totem-value {
    font-size: 18px;
    font-weight: 800;
    font-family: 'Space Grotesk', sans-serif;
    color: var(--text);
}
.fin-totem-primary .fin-totem-value { color: var(--primary); }
.fin-totem-label {
    font-size: 10px;
    color: var(--muted);
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.3px;
}

/* Chart wrapper */
.fin-chart-wrapper {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 12px;
}
.fin-chart { min-height: 180px; }
.fin-chart-empty {
    text-align: center;
    padding: 40px 16px;
    color: var(--muted);
    font-size: 13px;
}
.fin-chart-bars {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 6px;
    height: 160px;
    padding-top: 20px;
}
.fin-bar-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    height: 100%;
    min-width: 0;
    gap: 4px;
}
.fin-bar-value {
    font-size: 10px;
    font-weight: 700;
    color: var(--primary);
    font-family: 'Space Grotesk', sans-serif;
    white-space: nowrap;
    text-align: center;
}
.fin-bar-track {
    width: 100%;
    max-width: 40px;
    flex: 1;
    background: var(--surface-tertiary);
    border-radius: 6px 6px 0 0;
    position: relative;
    display: flex;
    align-items: flex-end;
    min-height: 20px;
}
.fin-bar-fill {
    width: 100%;
    background: linear-gradient(180deg, var(--primary) 0%, var(--primary-hover) 100%);
    border-radius: 6px 6px 0 0;
    transition: height 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: 4px;
}
.fin-bar-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.fin-bar-sub {
    font-size: 9px;
    color: var(--muted);
    font-weight: 600;
}

/* Breakdown list */
.fin-breakdown-wrapper {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 12px 16px;
    margin-bottom: 12px;
}
.fin-breakdown { min-height: 40px; }
.fin-breakdown-empty {
    text-align: center;
    padding: 20px;
    color: var(--muted);
    font-size: 13px;
}
.fin-breakdown-list { display: flex; flex-direction: column; gap: 6px; }
.fin-break-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: var(--surface-secondary);
    border-radius: 10px;
}
.fin-break-dia {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    text-transform: capitalize;
}
.fin-break-entregas {
    font-size: 11px;
    color: var(--muted);
    margin-top: 1px;
}
.fin-break-ganhos {
    font-size: 14px;
    font-weight: 800;
    color: var(--primary);
    font-family: 'Space Grotesk', sans-serif;
}

/* Resumo do mês */
.fin-mes-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px;
}
.fin-mes-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 8px;
}
.fin-mes-grid > div {
    background: var(--surface-secondary);
    padding: 12px;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.fin-mes-label {
    font-size: 10px;
    color: var(--muted);
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.3px;
}
.fin-mes-value {
    font-size: 18px;
    font-weight: 800;
    font-family: 'Space Grotesk', sans-serif;
}
.fin-mes-value.primary { color: var(--primary); }

/* ── HISTÓRICO ── */
.historico-lista { flex: 1; overflow-y: auto; }
.historico-list { display: flex; flex-direction: column; gap: 8px; }
.historico-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.hist-left .hist-pedido { font-weight: 700; font-size: 14px; }
.hist-left .hist-cliente { font-size: 12px; color: var(--muted); }
.hist-left .hist-data { font-size: 11px; color: var(--muted); margin-top: 2px; }
.hist-right { text-align: right; }
.hist-valor { font-weight: 700; color: var(--primary); font-family: 'Space Grotesk', sans-serif; }
.hist-status { font-size: 18px; margin-top: 4px; }
.hist-ok { color: var(--success); }
.hist-fail { color: var(--danger); }

/* ── PERFIL ── */
.perfil-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 30px 20px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}
.perfil-avatar { font-size: 72px; }
.perfil-rating { margin: 8px 0; text-align: center; font-size: 14px; min-height: 24px; color: var(--muted); }
.perfil-stats {
    display: flex;
    gap: 24px;
    margin-top: 8px;
    width: 100%;
    justify-content: center;
}
.perfil-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.stat-num {
    font-size: 22px;
    font-weight: 800;
    font-family: 'Space Grotesk', sans-serif;
    color: var(--primary);
}
.stat-label {
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    font-weight: 700;
}

/* ── PERFIL DISTRIBUIÇÃO E AVALIAÇÕES (KHP-044 Fase 3) ── */
#state-perfil.app-state { overflow-y: auto; padding-bottom: 40px; }
#perfil-content { display: flex; flex-direction: column; gap: 12px; }

.perfil-dist-wrapper,
.perfil-avals-wrapper {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px;
}

/* Distribution chart */
.perfil-dist-chart { min-height: 40px; }
.perfil-dist-empty {
    text-align: center;
    padding: 20px;
    color: var(--muted);
    font-size: 13px;
}
.perfil-dist-list { display: flex; flex-direction: column; gap: 8px; }
.perfil-dist-row {
    display: flex;
    align-items: center;
    gap: 10px;
}
.perfil-dist-label {
    width: 36px;
    font-size: 12px;
    font-weight: 700;
    color: var(--text);
    text-align: right;
    flex-shrink: 0;
}
.perfil-dist-track {
    flex: 1;
    height: 14px;
    background: var(--surface-tertiary);
    border-radius: 100px;
    overflow: hidden;
}
.perfil-dist-fill {
    height: 100%;
    border-radius: 100px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 4px;
}
.perfil-dist-pct {
    width: 32px;
    font-size: 11px;
    font-weight: 700;
    color: var(--muted);
    text-align: right;
    flex-shrink: 0;
}
.perfil-dist-count {
    width: 24px;
    font-size: 12px;
    font-weight: 700;
    color: var(--text);
    text-align: center;
    flex-shrink: 0;
}

/* Avaliações list */
.perfil-avals-list { min-height: 40px; }
.perfil-avals-empty {
    text-align: center;
    padding: 20px;
    color: var(--muted);
    font-size: 13px;
}
.perfil-avals-items { display: flex; flex-direction: column; gap: 8px; }
.perfil-aval-item {
    background: var(--surface-secondary);
    border-radius: 12px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.perfil-aval-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.perfil-aval-cliente {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
}
.perfil-aval-pedido {
    font-size: 11px;
    color: var(--muted);
    font-weight: 600;
}
.perfil-aval-data {
    font-size: 11px;
    color: var(--muted);
    margin-left: auto;
}
.perfil-aval-estrelas {
    letter-spacing: 1px;
}
.perfil-aval-comentario {
    font-size: 13px;
    color: var(--muted);
    font-style: italic;
    margin-top: 2px;
    line-height: 1.4;
}

/* ── MODAL DESPACHO ── */
.modal-despacho {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 2500;
    display: none;
    flex-direction: column;
    justify-content: space-between;
    padding: 32px 24px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}
.modal-despacho.open { display: flex; animation: zoomIn 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
@keyframes zoomIn { from { opacity: 0; transform: scale(0.92); } to { opacity: 1; transform: scale(1); } }
.despacho-header { text-align: center; margin-top: 20px; }
.despacho-bell { font-size: 72px; margin-bottom: 12px; animation: ringBell 1s infinite alternate cubic-bezier(0.36, 0.07, 0.19, 0.97); }
@keyframes ringBell { 0% { transform: rotate(-15deg); } 100% { transform: rotate(15deg); } }
.despacho-card {
    background: var(--surface);
    border: 1px solid var(--primary);
    box-shadow: 0 0 30px var(--primary-glow);
    border-radius: 20px;
    padding: 24px;
    text-align: center;
    margin: 20px 0;
}

/* ── MODAL DETALHES ── */
.modal-detalhes {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 2500;
    display: none;
    align-items: flex-end;
    justify-content: center;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}
.modal-detalhes.open { display: flex; animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-detalhes-sheet {
    background: var(--surface);
    border: 1px solid var(--border-bright);
    border-radius: 24px 24px 0 0;
    padding: 24px;
    width: 100%;
    max-width: 540px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
}

/* ── TOAST ── */
#toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text);
    color: #0A0A0C;
    padding: 12px 24px;
    border-radius: 100px;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 13px;
    z-index: 3000;
    box-shadow: var(--shadow);
    display: none;
    white-space: nowrap;
}
#toast.show { display: block; animation: fadeInUp 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
@keyframes fadeInUp { from { opacity: 0; transform: translate(-50%, 20px); } to { opacity: 1; transform: translate(-50%, 0); } }

.hidden { display: none !important; }

/* ── KHP-061: ONBOARDING DE PERMISSÕES ── */
.onb-card {
    background: var(--surface);
    border: 1px solid var(--border-bright);
    border-radius: 24px;
    padding: 28px 24px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow);
    animation: fadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.onb-header { text-align: center; margin-bottom: 24px; }
.onb-logo {
    width: 64px;
    height: 64px;
    border-radius: 18px;
    box-shadow: 0 4px 16px rgba(255,107,53,0.3);
}
.onb-steps { display: flex; flex-direction: column; gap: 12px; margin-bottom: 24px; }
.onb-step {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: var(--surface-secondary);
    border: 1px solid var(--border);
    border-radius: 14px;
    transition: var(--transition);
}
.onb-step-complete { border-color: rgba(16,185,129,0.2); background: rgba(16,185,129,0.05); }
.onb-step-icon { font-size: 28px; flex-shrink: 0; }
.onb-step-content { flex: 1; min-width: 0; }
.onb-step-content h4 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 2px;
}
.onb-step-content p { font-size: 12px; color: var(--muted); line-height: 1.4; }
.onb-step-btn {
    padding: 8px 16px;
    border-radius: 100px;
    border: none;
    background: var(--primary);
    color: #1A0B00;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
    transition: var(--transition);
    flex-shrink: 0;
}
.onb-step-btn:active { transform: scale(0.95); }
.onb-step-ok { font-size: 22px; flex-shrink: 0; }
.onb-footer { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.onb-footer .btn-action { width: 100%; }
.onb-footer .btn-outline {
    background: transparent;
    border: none;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}
