/* ============================================================================
   Perícia de dados — tokens da tela de cobranças (rch-*) e ritmo 5/8/13/21/34.
   Verde = em ordem/depois, vermelho = crítico, âmbar = alta, azul = média.
   ========================================================================== */
.pda { transition: opacity .2s ease; }
.pda.is-busy .pda-list { opacity: .55; pointer-events: none; }

/* Estado geral */
.pda-hero {
    --tone: var(--rch-paid);
    display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 21px;
    background: radial-gradient(120% 160% at 0% 0%, color-mix(in srgb, var(--tone) 12%, transparent), transparent 55%), var(--rch-bg);
    border-color: color-mix(in srgb, var(--tone) 30%, var(--rch-border));
}
.pda-hero.is-alert { --tone: var(--rch-risk); }
.pda-ring { position: relative; width: 89px; height: 89px; flex: none; }
.pda-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.pda-ring circle { fill: none; stroke-width: 8; }
.pda-ring-track { stroke: color-mix(in srgb, var(--rch-muted) 22%, transparent); }
.pda-ring-value {
    stroke: var(--rch-paid); stroke-linecap: round;
    transition: stroke-dasharray .8s cubic-bezier(.2, .8, .2, 1);
    animation: pda-ring-in 1s cubic-bezier(.2, .8, .2, 1) both;
}
.pda-ring > span { position: absolute; inset: 0; display: grid; place-items: center; color: var(--rch-muted); font-family: var(--gf-number-font-family); font-size: .8rem; font-weight: 700; }
.pda-ring > span strong { color: var(--rch-text); font-size: 1.3rem; }
.pda-ring > span { grid-auto-flow: column; align-content: center; justify-content: center; }
.pda-hero-copy { display: grid; gap: 5px; min-width: 0; }
.pda-eyebrow { color: color-mix(in srgb, var(--tone) 70%, var(--rch-text)); font-size: .68rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.pda-hero-copy h2 { font-size: 1.6rem !important; letter-spacing: -.01em; }
.pda-hero-copy p { margin: 0; color: var(--rch-muted); font-size: .85rem; font-weight: 600; line-height: 1.55; }
.pda-hero-copy p strong { color: var(--rch-text); }
.pda-hero-side { display: grid; justify-items: end; gap: 13px; }
.pda-severities { display: grid; grid-template-columns: repeat(3, 89px); gap: 8px; }
.pda-severity {
    --tone: var(--rch-planned);
    display: grid; gap: 2px; padding: 8px 13px; text-align: start; cursor: pointer;
    border: 1px solid color-mix(in srgb, var(--tone) 30%, var(--rch-border)); border-radius: var(--gf-radius);
    background: color-mix(in srgb, var(--tone) 8%, var(--rch-soft)); color: var(--rch-text);
    transition: transform .2s ease, border-color .2s ease, background .2s ease, opacity .2s ease;
}
.pda-severity strong { font-family: var(--gf-number-font-family); font-size: 1.3rem; line-height: 1.1; color: color-mix(in srgb, var(--tone) 75%, var(--rch-text)); }
.pda-severity span { color: var(--rch-muted); font-size: .72rem; font-weight: 800; }
.pda-severity:hover:not(:disabled) { transform: translateY(-2px); border-color: color-mix(in srgb, var(--tone) 60%, transparent); }
.pda-severity.is-selected { border-color: var(--tone); background: color-mix(in srgb, var(--tone) 20%, var(--rch-soft)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--tone) 20%, transparent); }
.pda-severity:disabled { cursor: default; opacity: .5; }
.pda-severity.is-risk { --tone: var(--rch-risk); }
.pda-severity.is-attention { --tone: var(--rch-attention); }
.pda-severity.is-open { --tone: var(--rch-open); }

/* Áreas */
.pda-areas { display: flex; flex-wrap: wrap; gap: 8px; }
.pda-area {
    display: inline-flex; align-items: center; gap: 8px; min-height: 34px; padding: 5px 13px 5px 8px;
    border: 1px solid var(--rch-border); border-radius: 999px; background: var(--rch-bg); color: var(--rch-muted);
    font-size: .8rem; font-weight: 700; cursor: help;
    animation: rch-in .4s cubic-bezier(.2, .8, .2, 1) both; animation-delay: calc(min(var(--i), 12) * 30ms);
    transition: border-color .2s ease, background .2s ease, color .2s ease;
}
.pda-area.has-issues { color: var(--rch-text); cursor: pointer; border-color: color-mix(in srgb, var(--rch-risk) 40%, var(--rch-border)); }
.pda-area.has-issues:hover { background: color-mix(in srgb, var(--rch-risk) 8%, var(--rch-bg)); }
.pda-area.is-selected { background: color-mix(in srgb, var(--rch-risk) 16%, var(--rch-bg)); border-color: var(--rch-risk); }
.pda-area-count {
    display: inline-grid; place-items: center; min-width: 21px; height: 21px; padding: 0 5px; border-radius: 999px;
    background: var(--rch-risk); color: #fff; font-family: var(--gf-number-font-family); font-size: .72rem; font-weight: 800;
}
.pda-area-ok { width: 21px; height: 21px; padding: 3px; border-radius: 999px; color: var(--rch-paid); background: color-mix(in srgb, var(--rch-paid) 14%, transparent); }

/* Filtro e lista */
.pda-filterbar { display: flex; align-items: center; gap: 13px; color: var(--rch-muted); font-size: .8rem; font-weight: 700; }
.pda-clear { border: 0; background: none; padding: 0; color: var(--rch-open); font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.pda-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 610px), 1fr)); gap: 21px; align-items: stretch; transition: opacity .2s ease; }
.pda-card {
    --tone: var(--rch-planned);
    display: flex; flex-direction: column; gap: 13px; min-width: 0; padding: 21px;
    border: 1px solid color-mix(in srgb, var(--tone) 26%, var(--rch-border)); border-radius: var(--gf-radius-lg, 13px);
    background: linear-gradient(180deg, color-mix(in srgb, var(--tone) 7%, transparent), transparent 89px), var(--rch-bg);
    box-shadow: inset 0 3px 0 color-mix(in srgb, var(--tone) 70%, transparent);
    animation: rch-in .45s cubic-bezier(.2, .8, .2, 1) both; animation-delay: calc(min(var(--i), 10) * 55ms);
}
.pda-card.is-risk { --tone: var(--rch-risk); }
.pda-card.is-attention { --tone: var(--rch-attention); }
.pda-card.is-open { --tone: var(--rch-open); }
.pda-card-head { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 8px; }
.pda-card-head h3 { flex-basis: 100%; margin: 3px 0 0 !important; font-size: 1.05rem !important; letter-spacing: -.005em; }
.pda-card-area { color: var(--rch-muted); font-size: .72rem; font-weight: 700; }
.pda-record {
    display: flex; align-items: center; justify-content: space-between; gap: 13px; padding: 8px 13px;
    border-radius: var(--gf-radius); background: var(--rch-soft); border: 1px solid var(--rch-border);
}
.pda-record > div { display: grid; gap: 2px; min-width: 0; }
.pda-record strong { font-family: var(--gf-number-font-family); font-size: .85rem; font-variant-numeric: tabular-nums; }
.pda-record span { overflow: hidden; color: var(--rch-muted); font-size: .8rem; text-overflow: ellipsis; white-space: nowrap; }
.pda-open { display: inline-flex; align-items: center; gap: 5px; flex: none; color: var(--rch-open); font-size: .8rem; font-weight: 700; text-decoration: none; }
.pda-open:hover { text-decoration: underline; text-underline-offset: 3px; }
.pda-open-icon { width: 16px; height: 16px; }
.pda-problem { margin: 0; font-size: .92rem; font-weight: 600; line-height: 1.55; }
.pda-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); gap: 8px; margin: 0; }
.pda-facts > div { display: grid; gap: 3px; min-width: 0; padding: 8px 13px; border-radius: var(--gf-radius); background: var(--rch-soft); }
.pda-facts dt { color: var(--rch-muted); font-size: .68rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.pda-facts dd { margin: 0; font-size: .85rem; font-weight: 700; overflow-wrap: anywhere; }
.pda-origin { display: flex; gap: 8px; margin: 0; color: var(--rch-muted); font-size: .8rem; line-height: 1.55; }
.pda-origin b { color: var(--rch-text); }
.pda-origin-icon { width: 16px; height: 16px; flex: none; margin-top: 2px; }

/* Correção */
.pda-fix {
    display: grid; gap: 13px; padding: 13px 21px; margin-top: auto;
    border-radius: var(--gf-radius); border: 1px solid color-mix(in srgb, var(--rch-paid) 35%, var(--rch-border));
    background: linear-gradient(135deg, color-mix(in srgb, var(--rch-paid) 10%, transparent), transparent 70%), var(--rch-soft);
}
.pda-fix.is-manual { border-color: var(--rch-border); background: var(--rch-soft); }
.pda-fix-head { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 8px; }
.pda-fix-head span { color: color-mix(in srgb, var(--rch-paid) 70%, var(--rch-text)); font-size: .72rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.pda-fix.is-manual .pda-fix-head span { color: var(--rch-muted); }
.pda-fix-head strong { flex-basis: 100%; font-size: .95rem; }
.pda-fix-icon { width: 18px; height: 18px; color: var(--rch-paid); animation: pda-glow 2.6s ease-in-out infinite; }
.pda-fix.is-manual .pda-fix-icon { color: var(--rch-muted); animation: none; }
.pda-diff { display: grid; gap: 5px; margin: 0; padding: 0; list-style: none; }
.pda-diff li, .pda-modal-diff li {
    display: grid; grid-template-columns: minmax(89px, 144px) minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 8px;
    font-size: .85rem;
}
.pda-diff li > span, .pda-modal-diff li > span { color: var(--rch-muted); font-size: .72rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.pda-diff del, .pda-modal-diff del { color: color-mix(in srgb, var(--rch-risk) 70%, var(--rch-text)); text-decoration-thickness: 1px; overflow-wrap: anywhere; }
.pda-diff ins, .pda-modal-diff ins { color: color-mix(in srgb, var(--rch-paid) 75%, var(--rch-text)); font-weight: 800; text-decoration: none; overflow-wrap: anywhere; }
.pda-diff b, .pda-modal-diff b { color: var(--rch-muted); }
.pda-diff li.is-same em, .pda-modal-diff li.is-same em { grid-column: 2 / -1; color: var(--rch-text); font-style: normal; font-weight: 700; }
.pda-diff li.is-same small, .pda-modal-diff li.is-same small { color: var(--rch-muted); font-size: .72rem; font-weight: 600; }
.pda-fix-reason { margin: 0; color: var(--rch-muted); font-size: .8rem; line-height: 1.55; }
.pda-fix-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* Vazio */
.pda-empty { flex-direction: row; align-items: center; gap: 21px; border-color: color-mix(in srgb, var(--rch-paid) 35%, var(--rch-border)); }
.pda-empty > div { display: grid; gap: 3px; }
.pda-empty span { color: var(--rch-muted); font-size: .85rem; }
.pda-empty-icon { width: 55px !important; height: 55px !important; max-width: none !important; max-height: none !important; flex: none; color: var(--rch-paid); animation: pda-pop .6s cubic-bezier(.2, 1.4, .4, 1) both; }

/* Modal de confirmação (fora do workspace: tokens do tema direto) */
.pda-modal-diff, .pda-modal-list { display: grid; gap: 8px; margin: 13px 0 0; padding: 0; list-style: none; text-align: start; }
.pda-modal-diff { --rch-muted: var(--gf-text-muted); --rch-risk: var(--gf-accent-risk); --rch-paid: var(--gf-accent-paid); --rch-text: var(--gf-text); }
.pda-modal-list li { display: grid; gap: 2px; padding: 8px 13px; border-radius: var(--gf-radius); background: var(--gf-surface-raised); }
.pda-modal-list span { color: var(--gf-text-muted); font-size: .8rem; }
.pda-modal-note { margin: 13px 0 0; color: var(--gf-text-muted); font-size: .8rem; line-height: 1.55; text-align: start; }

@keyframes pda-ring-in { from { stroke-dasharray: 0 214; } }
@keyframes pda-glow { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .6; transform: scale(.9); } }
@keyframes pda-pop { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: none; } }

@media (max-width: 1100px) {
    .pda-hero { grid-template-columns: auto minmax(0, 1fr); }
    .pda-hero-side { grid-column: 1 / -1; justify-items: stretch; }
    .pda-severities { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
    .pda-hero { grid-template-columns: minmax(0, 1fr); justify-items: start; padding: 13px; }
    .pda-hero-side { justify-self: stretch; }
    .pda-hero-side .fi-btn { width: 100%; }
    .pda-diff li.is-same em, .pda-modal-diff li.is-same em { grid-column: 1 / -1; }
    .pda-ring { width: 72px; height: 72px; }
    .pda-hero-copy h2 { font-size: 1.3rem !important; }
    .pda-card { padding: 13px; }
    .pda-fix { padding: 13px; }
    .pda-diff li, .pda-modal-diff li { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); }
    .pda-diff li > span, .pda-modal-diff li > span { grid-column: 1 / -1; }
    .pda-record { flex-direction: column; align-items: flex-start; }
}
@media (prefers-reduced-motion: reduce) {
    .pda-card, .pda-area, .pda-ring-value, .pda-fix-icon, .pda-empty-icon { animation: none !important; }
    .pda-severity, .pda-ring-value { transition: none; }
}
