/* ============================================================
   Faturamento AIH — CSS do redesign
   (Pages/Faturamento/Sus/AIH.razor + Components/BuscaEvolucaoFaturamento.razor)

   Transcrição fiel do protótipo do Claude Design
   ("Faturamento AIH.dc.html" + tokens do MedCare Design System).

   Mesmo padrão de prescricao-modal.css / evolucao-modal.css: os tokens
   --t-* do protótipo são declarados DENTRO de .aihroot, então os valores
   daqui vencem sem vazar para o resto do app (YNEX/mc-page).

   Tema escuro: o protótipo traz a própria paleta escura (.aih-dark).
   Ela vale em três situações:
     1. tema global do app  -> [data-theme-mode="dark"] .aihroot
     2. escolha local       -> .aihroot.aih-dark      (botão do cabeçalho)
     3. claro forçado       -> .aihroot.aih-light     (vence o global)
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ============================================================
   1. TOKENS
   ============================================================ */
.aihroot {
    --t-bg: #f1f5f9;
    --t-surface: #ffffff;
    --t-surface2: #f8fafc;
    --t-border: #e2e8f0;
    --t-inb: #cbd5e1;
    --t-text: #334155;
    --t-strong: #0b1f3a;
    --t-muted: #64748b;
    --t-faint: #94a3b8;
    --t-input: #ffffff;
    --t-blue: #1a4a9e;
    --t-bluebg: #eff6ff;
    --t-link: #2563eb;
    --t-red: #dc2626;
    --t-redbg: #fef2f2;
    --t-redb: #fecaca;
    --t-amber: #b45309;
    --t-amberbg: #fffbeb;
    --t-amberb: #fde68a;
    --t-green: #059669;
    --t-greenbg: #ecfdf5;
    --t-teal: #0891b2;
    --t-tealbg: #ecfeff;
    --t-purple: #7c3aed;
    --t-purplebg: #f5f3ff;
    --t-indigo: #4f46e5;
    --t-indigobg: #eef2ff;
    --t-overlay: rgba(11, 31, 58, .5);
    --t-tabact: #eff6ff;
    --t-thead: #f8fafc;

    /* Tokens de marca usados diretamente pelo protótipo */
    --mc-green: #059669;
    --mc-red: #dc2626;
    --mc-pink: #db2777;
    --mc-blue-900: #1e3a5f;

    --t-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --t-grad: linear-gradient(135deg, #1a4a9e, #2563eb);
    --t-shadow-modal: 0 24px 70px -24px rgba(2, 10, 30, .55);
    --t-ease: cubic-bezier(.16, 1, .3, 1);
}

/* Paleta escura — declarada uma vez e reaproveitada pelos três seletores */
.aihroot.aih-dark,
[data-theme-mode="dark"] .aihroot:not(.aih-light) {
    --t-bg: #0b1220;
    --t-surface: #0f172a;
    --t-surface2: #131e33;
    --t-border: #233350;
    --t-inb: #33445f;
    --t-text: #cbd5e1;
    --t-strong: #f1f5f9;
    --t-muted: #8fa3bd;
    --t-faint: #64748b;
    --t-input: #131e33;
    --t-blue: #7cabf8;
    --t-bluebg: rgba(37, 99, 235, .16);
    --t-link: #7cabf8;
    --t-red: #f87171;
    --t-redbg: rgba(220, 38, 38, .14);
    --t-redb: rgba(248, 113, 113, .35);
    --t-amber: #fbbf24;
    --t-amberbg: rgba(217, 119, 6, .13);
    --t-amberb: rgba(251, 191, 36, .3);
    --t-green: #34d399;
    --t-greenbg: rgba(5, 150, 105, .15);
    --t-teal: #22d3ee;
    --t-tealbg: rgba(8, 145, 178, .15);
    --t-purple: #a78bfa;
    --t-purplebg: rgba(124, 58, 237, .15);
    --t-indigo: #818cf8;
    --t-indigobg: rgba(79, 70, 229, .16);
    --t-overlay: rgba(2, 6, 17, .68);
    --t-tabact: rgba(37, 99, 235, .16);
    --t-thead: #131e33;
}

/* ============================================================
   2. RAIZ / RESET LOCAL
   ============================================================ */
.aihroot {
    font-family: var(--t-font);
    color: var(--t-text);
    text-wrap: pretty;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* Só a página (o overlay dos modais não recebe fundo/altura).
   O .main-content do YNEX tem `padding: 0 .5rem`; a margem negativa devolve esses
   8px para a tela sangrar de ponta a ponta, como no protótipo — as margens de 22px
   dos cartões passam a ser as únicas, exatamente como desenhado.
   A altura desconta a barra do topo (`.app-content { margin-block-start: 4rem }`). */
.aihroot.aih-page-root {
    min-height: calc(100vh - 4rem);
    background: var(--t-bg);
    margin: 0 -0.5rem;
    padding-bottom: 1px;
}

.aihroot *,
.aihroot *::before,
.aihroot *::after { box-sizing: border-box; }

.aihroot button,
.aihroot input,
.aihroot select,
.aihroot textarea { font-family: var(--t-font); }

.aihroot a { color: var(--t-link); text-decoration: none; }
.aihroot a:hover { color: var(--t-blue); }

.aihroot input::placeholder,
.aihroot textarea::placeholder { color: var(--t-faint); }

.aihroot ::-webkit-scrollbar { width: 10px; height: 10px; }
.aihroot ::-webkit-scrollbar-thumb {
    background: var(--t-inb);
    border-radius: 6px;
    border: 2px solid transparent;
    background-clip: content-box;
}
.aihroot ::-webkit-scrollbar-track { background: transparent; }

.aih-spacer { flex: 1; }
.aih-nums { font-variant-numeric: tabular-nums; }

/* Ícone de carregando (botão Buscar / listas em carga) */
.aihroot .ri-loader-4-line { animation: aih-spin .9s linear infinite; }
@keyframes aih-spin { to { transform: rotate(360deg); } }

/* ============================================================
   3. CABEÇALHO DA PÁGINA
   ============================================================ */
.aih-topbar {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 22px;
    background: var(--t-surface);
    border-bottom: 1px solid var(--t-border);
}
/* Sem marca e sem divisória: o header global do YNEX já mostra o logo logo acima
   desta barra (o protótipo é uma tela solta, por isso trazia os dois). */
.aih-topbar__title {
    font: 800 15px var(--t-font);
    color: var(--t-strong);
    letter-spacing: -.3px;
}
.aih-topbar__crumb { font: 500 11px var(--t-font); color: var(--t-faint); }
.aih-topbar__crumb a { color: inherit; }
.aih-topbar__crumb a:hover { color: var(--t-link); }

/* ============================================================
   4. ÁTOMOS DE FORMULÁRIO
   ============================================================ */
.aih-label {
    display: block;
    font: 600 11px var(--t-font);
    color: var(--t-muted);
    margin-bottom: 4px;
}
.aih-label .aih-label__soft { color: var(--t-faint); font-weight: 500; }

.aih-input,
.aih-select,
.aih-textarea {
    width: 100%;
    height: 30px;
    padding: 0 10px;
    font: 500 12.5px var(--t-font);
    color: var(--t-strong);
    background: var(--t-input);
    border: 1px solid var(--t-inb);
    border-radius: 8px;
    outline: none;
    box-sizing: border-box;
    transition: border-color .15s var(--t-ease), box-shadow .15s var(--t-ease);
}
.aih-select { padding: 0 8px; }
.aih-textarea {
    height: 58px;
    padding: 8px 10px;
    resize: vertical;
    line-height: 1.45;
}
.aih-input:focus,
.aih-select:focus,
.aih-textarea:focus {
    border-color: var(--t-link);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .16);
}
.aih-input:disabled,
.aih-select:disabled { opacity: .6; cursor: not-allowed; }

/* Estados de crítica (equivalente ao is-invalid do Bootstrap) */
.aih-input.is-invalid,
.aih-select.is-invalid,
.aih-textarea.is-invalid { border: 1.5px solid var(--t-red); }
.aih-input.is-warn,
.aih-select.is-warn { border: 1px solid var(--t-amber); }

/* Campo compacto usado dentro de tabelas */
.aih-input--xs,
.aih-select--xs {
    height: 28px;
    width: auto;
    padding: 0 8px;
    font: 500 12px var(--t-font);
    border-radius: 7px;
}
.aih-select--xs { padding: 0 6px; }
.aih-input--num { width: 56px; text-align: center; }
.aih-input--cns { width: 118px; }
.aih-input--cmpt { width: 70px; }

.aih-hint {
    font: 500 10.5px var(--t-font);
    color: var(--t-faint);
    margin-top: 4px;
    line-height: 1.4;
}
.aih-hint--err { font-weight: 600; color: var(--t-red); }
.aih-hint--warn { font-weight: 600; color: var(--t-amber); }
.aih-hint--ok { font-weight: 600; color: var(--t-green); }

.aih-check {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font: 600 12px var(--t-font);
    color: var(--t-text);
    cursor: pointer;
    margin: 0;
}
.aih-check input[type="checkbox"] { accent-color: var(--t-purple); margin: 0; }
.aihroot input[type="checkbox"].aih-cb { accent-color: #1a4a9e; margin: 0; }

/* ============================================================
   5. BOTÕES
   ============================================================ */
.aih-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 30px;
    padding: 0 14px;
    font: 600 12.5px var(--t-font);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none;
    transition: filter .15s var(--t-ease), background .15s var(--t-ease);
}
.aih-btn:hover { filter: brightness(1.04); }
.aih-btn:disabled,
.aih-btn.is-disabled { cursor: not-allowed; opacity: .5; filter: none; }

.aih-btn--primary { color: #fff; background: var(--t-grad); }
.aih-btn--primary:hover { color: #fff; }
.aih-btn--green { color: #fff; background: var(--mc-green); }
.aih-btn--green:hover { color: #fff; }
.aih-btn--ghost {
    color: var(--t-link);
    background: transparent;
    border: 1px solid var(--t-inb);
}
.aih-btn--ghost:hover { background: var(--t-surface2); color: var(--t-link); }
.aih-btn--surface {
    color: var(--t-link);
    background: var(--t-surface);
    border: 1px solid var(--t-inb);
}
.aih-btn--surface:hover { color: var(--t-link); }
.aih-btn--amber {
    color: var(--t-amber);
    background: var(--t-amberbg);
    border: 1px solid var(--t-amberb);
}
.aih-btn--amber:hover { color: var(--t-amber); }
.aih-btn--red {
    color: var(--t-red);
    background: transparent;
    border: 1px solid var(--t-redb);
}
.aih-btn--red:hover { background: var(--t-redbg); color: var(--t-red); }
.aih-btn--redsolid {
    color: var(--t-red);
    background: var(--t-redbg);
    border: 1px solid var(--t-redb);
    font-weight: 700;
}
.aih-btn--purple {
    color: var(--t-purple);
    background: var(--t-purplebg);
    border: 1px solid var(--t-border);
}
.aih-btn--purple:hover { color: var(--t-purple); }

.aih-btn--sm { height: 28px; padding: 0 11px; font-size: 11.5px; }
.aih-btn--md { height: 32px; padding: 0 14px; }
.aih-btn--lg { height: 34px; padding: 0 16px; }
.aih-btn--tight { padding: 0 12px; }

/* Botões-ícone quadrados */
.aih-ico {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 7px;
    border: 1px solid var(--t-inb);
    background: transparent;
    color: var(--t-muted);
    cursor: pointer;
    font-size: 14px;
    padding: 0;
    transition: background .15s var(--t-ease);
}
.aih-ico--teal { color: var(--t-teal); }
.aih-ico--teal:hover { background: var(--t-tealbg); }
.aih-ico--amber { color: var(--t-amber); }
.aih-ico--amber:hover { background: var(--t-amberbg); }
.aih-ico--blue { color: var(--t-blue); }
.aih-ico--blue:hover { background: var(--t-bluebg); }
.aih-ico--muted:hover { background: var(--t-surface2); }
.aih-ico--red { color: var(--t-red); border-color: var(--t-redb); }
.aih-ico--red:hover { background: var(--t-redbg); }

.aih-ico--30 { width: 30px; height: 30px; border-radius: 8px; font-size: 15px; }
.aih-ico--30.aih-ico--link { color: var(--t-link); }
.aih-ico--close {
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--t-muted);
    font-size: 17px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
}
.aih-ico--close:hover { background: var(--t-surface2); }

/* Botãozinho "remover" de dentro das caixas de item selecionado */
.aih-ico--x {
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--t-muted);
    cursor: pointer;
    font-size: 13px;
    padding: 0;
    flex-shrink: 0;
}
.aih-ico--x:hover { background: var(--t-surface2); color: var(--t-red); }

.aih-ico--del {
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 7px;
    border: 1px solid var(--t-redb);
    background: transparent;
    color: var(--t-red);
    cursor: pointer;
    font-size: 13px;
    padding: 0;
}
.aih-ico--del:hover { background: var(--t-redbg); }

/* ============================================================
   6. BARRA DE FILTROS + CARTÃO DA LISTA
   ============================================================ */
.aih-filtros {
    margin: 14px 22px 0;
    padding: 12px 14px;
    background: var(--t-surface);
    border: 1px solid var(--t-border);
    border-radius: 12px;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr 1fr auto;
    gap: 10px;
    align-items: end;
}
.aih-filtros__acoes { display: flex; gap: 8px; }

.aih-listcard {
    margin: 14px 22px 22px;
    background: var(--t-surface);
    border: 1px solid var(--t-border);
    border-radius: 12px;
    overflow: hidden;
}
.aih-listcard__tabs {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px 0;
}
.aih-listcard__bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--t-border);
    flex-wrap: wrap;
}
.aih-listcard__scroll { overflow-x: auto; }

/* Abas do topo da lista (sublinhado) */
.aih-ltab {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 8px 14px;
    font: 600 12.5px var(--t-font);
    color: var(--t-muted);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    white-space: nowrap;
}
.aih-ltab.is-active {
    font-weight: 700;
    color: var(--t-blue);
    border-bottom-color: var(--t-blue);
}
.aih-ltab__count {
    min-width: 18px;
    height: 18px;
    padding: 0 6px;
    border-radius: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font: 700 10.5px var(--t-font);
    background: var(--t-surface2);
    color: var(--t-muted);
}
.aih-ltab.is-active .aih-ltab__count { background: var(--t-bluebg); color: var(--t-blue); }

/* Busca com lupa embutida */
.aih-search { position: relative; width: 230px; }
.aih-search > i {
    position: absolute;
    left: 9px;
    top: 8px;
    font-size: 13px;
    color: var(--t-faint);
    pointer-events: none;
}
.aih-search .aih-input { padding: 0 26px 0 28px; }
.aih-search__clear {
    position: absolute;
    right: 6px;
    top: 6px;
    width: 18px;
    height: 18px;
    border: none;
    background: transparent;
    color: var(--t-faint);
    cursor: pointer;
    font-size: 13px;
    line-height: 1;
    padding: 0;
}
.aih-search--wide { width: auto; flex: 1; }
.aih-search--wide .aih-input { height: 32px; padding: 0 10px 0 30px; }
.aih-search--wide > i { left: 10px; top: 9px; font-size: 14px; }

/* ============================================================
   7. TABELAS
   ============================================================ */
.aih-tbl {
    width: 100%;
    border-collapse: collapse;
}
.aih-tbl--lista { min-width: 980px; }
.aih-tbl th {
    font: 700 10.5px var(--t-font);
    letter-spacing: .7px;
    color: var(--t-faint);
    text-transform: uppercase;
    text-align: left;
    padding: 9px 10px;
    border-bottom: 1px solid var(--t-border);
    background: var(--t-thead);
    white-space: nowrap;
}
.aih-tbl th.aih-th--check { width: 34px; padding: 9px 10px; }
.aih-tbl th.aih-th--end { text-align: right; padding: 9px 14px; }
.aih-tbl td {
    padding: 9px 10px;
    border-bottom: 1px solid var(--t-border);
    vertical-align: middle;
}
.aih-tbl td.aih-td--center { text-align: center; }
.aih-tbl td.aih-td--end { padding: 9px 14px; }
.aih-tbl tbody tr:hover { background: var(--t-surface2); }
.aih-tbl tbody tr.is-selected { background: var(--t-amberbg); }
.aih-tbl--flush td { padding: 10px 12px; border-bottom: none; }
.aih-tbl--flush th { padding: 9px 12px; }

.aih-acoes { display: flex; gap: 5px; justify-content: flex-end; }

/* Célula do paciente */
.aih-pac { display: flex; align-items: center; gap: 8px; }
.aih-pac__pront {
    display: inline-flex;
    padding: 2px 7px;
    border-radius: 6px;
    font: 700 10.5px var(--t-font);
    letter-spacing: .4px;
    background: var(--t-bluebg);
    color: var(--t-blue);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.aih-pac__nome { font: 700 12.5px var(--t-font); color: var(--t-strong); }
.aih-pac__cns {
    font: 500 10.5px var(--t-font);
    color: var(--t-faint);
    font-variant-numeric: tabular-nums;
}
.aih-pac__cns.is-err { color: var(--t-red); font-weight: 600; }

/* Célula da internação */
.aih-int__num {
    font: 600 12px var(--t-font);
    color: var(--t-strong);
    font-variant-numeric: tabular-nums;
}
.aih-int__meta { display: flex; align-items: center; gap: 5px; margin-top: 3px; flex-wrap: wrap; }
.aih-int__per {
    font: 500 10.5px var(--t-font);
    color: var(--t-muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* Célula dos médicos */
.aih-meds {
    display: grid;
    gap: 1px;
    font: 500 10.5px var(--t-font);
    color: var(--t-muted);
}
.aih-meds__rot { font-weight: 700; color: var(--t-faint); font-size: 9.5px; }
.aih-meds__nome {
    display: inline-block;
    max-width: 170px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: bottom;
}

/* Célula CID · Procedimento */
.aih-td--cidproc { max-width: 240px; }
.aih-cidproc {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    overflow: hidden;
}
.aih-cidproc + .aih-cidproc { margin-top: 3px; }
.aih-cidproc__desc {
    font: 500 10.5px var(--t-font);
    color: var(--t-muted);
    overflow: hidden;
    text-overflow: ellipsis;
}
.aih-td--dash { font: 600 12px var(--t-font); color: var(--t-faint); }

/* ============================================================
   8. PILLS / BADGES / CHIPS
   ============================================================ */
.aih-pill {
    display: inline-flex;
    align-items: center;
    padding: 1px 7px;
    border-radius: 20px;
    font: 700 10px var(--t-font);
    white-space: nowrap;
}
.aih-pill--blue { background: var(--t-bluebg); color: var(--t-blue); }
.aih-pill--amber { background: var(--t-amberbg); color: var(--t-amber); }
.aih-pill--green { background: var(--t-greenbg); color: var(--t-green); }
.aih-pill--teal { background: var(--t-tealbg); color: var(--t-teal); }
.aih-pill--purple { background: var(--t-purplebg); color: var(--t-purple); }
.aih-pill--muted { background: var(--t-surface2); color: var(--t-muted); }
.aih-pill--dias { padding: 1px 6px; }

.aih-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 1.5px 6px;
    border-radius: 6px;
    font: 700 10.5px var(--t-font);
    letter-spacing: .4px;
    white-space: nowrap;
}
.aih-tag--cid { background: var(--t-redbg); color: var(--t-red); }
.aih-tag--proc {
    background: var(--t-bluebg);
    color: var(--t-blue);
    font-variant-numeric: tabular-nums;
}
.aih-tag--teal { background: var(--t-tealbg); color: var(--t-teal); }
.aih-tag--dark {
    padding: 2px 8px;
    font-size: 11px;
    background: var(--mc-blue-900);
    color: #fff;
    font-variant-numeric: tabular-nums;
}

.aih-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 20px;
    font: 700 11px var(--t-font);
    white-space: nowrap;
}
.aih-status--err { background: var(--t-redbg); color: var(--t-red); }
.aih-status--ok { background: var(--t-greenbg); color: var(--t-green); }
.aih-status--warn {
    background: var(--t-amberbg);
    border: 1px solid var(--t-amberb);
    color: var(--t-amber);
}
.aih-status--blue { background: var(--t-bluebg); color: var(--t-blue); }
.aih-status--muted { background: var(--t-surface2); color: var(--t-muted); }

.aih-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 7px;
    font: 600 11px var(--t-font);
    background: var(--t-surface2);
    border: 1px solid var(--t-border);
    color: var(--t-text);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* ============================================================
   9. MODAIS
   ============================================================ */
.aih-overlay {
    position: fixed;
    inset: 0;
    background: var(--t-overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1060;
}
.aih-modal {
    width: 95%;
    height: 95%;
    background: var(--t-surface);
    border: 1px solid var(--t-border);
    border-radius: 14px;
    box-shadow: var(--t-shadow-modal);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}
.aih-modal__head {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 12px 18px;
    border-bottom: 1px solid var(--t-border);
    flex-shrink: 0;
}
.aih-modal__ico {
    width: 30px;
    height: 30px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    flex-shrink: 0;
}
.aih-modal__ico--amber { background: var(--t-amberbg); color: var(--t-amber); }
.aih-modal__ico--blue { background: var(--t-bluebg); color: var(--t-blue); }
.aih-modal__ico--teal { background: var(--t-tealbg); color: var(--t-teal); }
.aih-modal__ico--green { background: var(--t-greenbg); color: var(--t-green); }
.aih-modal__title {
    font: 800 14.5px var(--t-font);
    color: var(--t-strong);
    letter-spacing: -.2px;
}
.aih-modal__sub { font: 600 11px var(--t-font); color: var(--t-muted); }
.aih-modal__tabs {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 14px;
    border-bottom: 1px solid var(--t-border);
    overflow-x: auto;
    flex-shrink: 0;
}
.aih-modal__body {
    flex: 1;
    min-height: 0;          /* sem isto o corpo não encolhe e o rodapé some do modal */
    overflow: auto;
    padding: 16px 20px;
    background: var(--t-surface2);
}
.aih-modal__foot {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 18px;
    border-top: 1px solid var(--t-border);
    flex-shrink: 0;
    background: var(--t-surface);
}
.aih-modal__foot-note { font: 500 11.5px var(--t-font); color: var(--t-faint); }

/* Abas em pílula dos modais */
.aih-tab {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 0 13px;
    height: 34px;
    border-radius: 9px;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    font: 600 12.5px var(--t-font);
    color: var(--t-muted);
    background: transparent;
    border: 1px solid transparent;
}
.aih-tab.is-active {
    font-weight: 700;
    color: var(--t-blue);
    background: var(--t-tabact);
    border-color: var(--t-border);
}
.aih-tab__badge {
    min-width: 17px;
    height: 17px;
    padding: 0 5px;
    border-radius: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font: 700 10px var(--t-font);
    background: var(--mc-red);
    color: #fff;
}
.aih-tab__badge--warn { background: var(--t-amberbg); color: var(--t-amber); }
.aih-tab__cnt {
    min-width: 17px;
    height: 17px;
    padding: 0 5px;
    border-radius: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font: 700 10px var(--t-font);
    background: var(--t-surface2);
    color: var(--t-muted);
}
.aih-tab__cnt--green { background: var(--t-greenbg); color: var(--t-green); }
.aih-tab__cnt--teal { background: var(--t-tealbg); color: var(--t-teal); }
.aih-tab__cnt--red { background: var(--t-redbg); color: var(--t-red); }
.aih-tab__cnt--purple { background: var(--t-purplebg); color: var(--t-purple); }
.aih-tab__ok { color: var(--t-green); }

/* ============================================================
   10. CARTÕES DE SEÇÃO (corpo dos modais)
   ============================================================ */
.aih-stack { display: grid; gap: 12px; }
.aih-stack--lg { gap: 16px; }
.aih-stack--sm { gap: 8px; }
.aih-stack--xs { gap: 5px; }

.aih-card {
    background: var(--t-surface);
    border: 1px solid var(--t-border);
    border-radius: 12px;
    padding: 14px 16px;
}
.aih-card--flush { padding: 0; overflow: hidden; }
.aih-card--dashed { border: 1.5px dashed var(--t-inb); }
.aih-card--pad16 { padding: 16px; }

.aih-sec {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.aih-sec--tight { margin-bottom: 10px; }
.aih-sec__ico {
    width: 24px;
    height: 24px;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    flex-shrink: 0;
}
.aih-sec__ico--letra { font: 800 11px var(--t-font); }
.aih-sec__ico--blue { background: var(--t-bluebg); color: var(--t-blue); }
.aih-sec__ico--teal { background: var(--t-tealbg); color: var(--t-teal); }
.aih-sec__ico--indigo { background: var(--t-indigobg); color: var(--t-indigo); }
.aih-sec__ico--purple { background: var(--t-purplebg); color: var(--t-purple); }
.aih-sec__ico--red { background: var(--t-redbg); color: var(--t-red); }
.aih-sec__ico--muted { background: var(--t-surface2); color: var(--t-muted); }
.aih-sec__t {
    font: 700 11.5px var(--t-font);
    letter-spacing: .8px;
    color: var(--t-strong);
    text-transform: uppercase;
}
.aih-sec__t--muted { color: var(--t-muted); }
.aih-sec__chip {
    display: inline-flex;
    padding: 2px 8px;
    border-radius: 20px;
    font: 700 10px var(--t-font);
    background: var(--t-purplebg);
    color: var(--t-purple);
}
.aih-sec__chip--off {
    letter-spacing: .5px;
    background: var(--t-surface2);
    border: 1px solid var(--t-border);
    color: var(--t-faint);
}
.aih-sec--barra {
    padding: 12px 16px;
    border-bottom: 1px solid var(--t-border);
    margin-bottom: 0;
}

/* Grade de 12 colunas do protótipo */
.aih-g12 {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 12px;
}
.aih-g12 > .c1 { grid-column: span 1; }
.aih-g12 > .c2 { grid-column: span 2; }
.aih-g12 > .c3 { grid-column: span 3; }
.aih-g12 > .c4 { grid-column: span 4; }
.aih-g12 > .c5 { grid-column: span 5; }
.aih-g12 > .c6 { grid-column: span 6; }
.aih-g12 > .c7 { grid-column: span 7; }
.aih-g12 > .c8 { grid-column: span 8; }
.aih-g12 > .c9 { grid-column: span 9; }
.aih-g12 > .c10 { grid-column: span 10; }
.aih-g12 > .c11 { grid-column: span 11; }
.aih-g12 > .c12 { grid-column: span 12; }

.aih-g3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.aih-g2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.aih-g21 { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; }
.aih-g12x { display: grid; grid-template-columns: 1fr 2fr; gap: 12px; }
.aih-g2 > .span2, .aih-g21 > .span2 { grid-column: span 2; }

.aih-row { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }

/* ============================================================
   11. CAIXA DE ITEM SELECIONADO / VAZIO
   ============================================================ */
.aih-selbox {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 6px 5px 12px;
    border-radius: 8px;
    min-height: 30px;
    box-sizing: border-box;
}
.aih-selbox--green { background: var(--t-greenbg); border: 1px solid var(--t-green); }
.aih-selbox--blue { background: var(--t-bluebg); border: 1px solid var(--t-blue); }
.aih-selbox--teal { background: var(--t-tealbg); border: 1px solid var(--t-teal); }
.aih-selbox__cod {
    font: 700 12px var(--t-font);
    font-variant-numeric: tabular-nums;
    letter-spacing: .4px;
    white-space: nowrap;
}
.aih-selbox--green .aih-selbox__cod { color: var(--t-green); }
.aih-selbox--blue .aih-selbox__cod { color: var(--t-blue); }
.aih-selbox--teal .aih-selbox__cod { color: var(--t-teal); }
.aih-selbox__desc {
    font: 600 12px var(--t-font);
    color: var(--t-strong);
    flex: 1;
    line-height: 1.3;
    min-width: 0;
}
.aih-selbox--green > i { color: var(--t-green); font-size: 14px; }
.aih-selbox--blue > i { color: var(--t-blue); font-size: 14px; }

.aih-emptybox {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    font: 500 11.5px var(--t-font);
    color: var(--t-faint);
    border: 1.5px dashed var(--t-border);
    border-radius: 8px;
    min-height: 28px;
    box-sizing: border-box;
}

/* ============================================================
   12. ALERTAS / INCONSISTÊNCIAS
   ============================================================ */
.aih-alert {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 10px;
    line-height: 1.45;
}
.aih-alert--red {
    background: var(--t-redbg);
    border: 1px solid var(--t-redb);
    border-left: 4px solid var(--t-red);
}
.aih-alert--red .aih-alert__txt { font: 600 13.5px var(--t-font); color: var(--t-red); flex: 1; }
.aih-alert--red > i { color: var(--t-red); font-size: 15px; flex-shrink: 0; }
.aih-alert--amber {
    background: var(--t-amberbg);
    border: 1px solid var(--t-amberb);
    border-left: 4px solid var(--t-amber);
}
.aih-alert--amber .aih-alert__txt { font: 600 13.5px var(--t-font); color: var(--t-amber); flex: 1; }
.aih-alert--amber > i { color: var(--t-amber); font-size: 15px; flex-shrink: 0; }
.aih-alert--ent {
    background: var(--t-surface);
    border: 1px solid var(--t-border);
    border-left: 4px solid var(--t-inb);
}
.aih-alert--ent .aih-alert__txt { font: 600 13px var(--t-font); color: var(--t-muted); flex: 1; }
.aih-alert--info {
    align-items: flex-start;
    gap: 10px;
    padding: 10px 14px;
    background: var(--t-bluebg);
    border: 1px solid var(--t-border);
}
.aih-alert--info > i { color: var(--t-blue); font-size: 15px; margin-top: 1px; }
.aih-alert--info .aih-alert__txt { font: 500 12px var(--t-font); color: var(--t-text); line-height: 1.55; }
.aih-alert--green {
    background: var(--t-greenbg);
    border: 1px solid var(--t-green);
    border-left: 4px solid var(--t-green);
}
.aih-alert--green .aih-alert__txt { font: 600 13px var(--t-font); color: var(--t-green); flex: 1; }
.aih-alert--sm { padding: 9px 12px; border-radius: 9px; }
.aih-alert--sm .aih-alert__txt { font-size: 13px; line-height: 1.4; }

.aih-grp {
    display: flex;
    align-items: center;
    gap: 8px;
    font: 700 13px var(--t-font);
    margin-bottom: 8px;
}
.aih-grp--red { color: var(--t-red); }
.aih-grp--amber { color: var(--t-amber); }
.aih-grp--muted { color: var(--t-muted); font-size: 12px; }
.aih-grp > i { font-size: 15px; }
.aih-grp--sm { font-size: 12.5px; }

.aih-bullet {
    display: flex;
    align-items: baseline;
    gap: 8px;
    font: 600 12.5px var(--t-font);
    color: var(--t-red);
    line-height: 1.45;
}
.aih-bullet__dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--t-red);
    flex-shrink: 0;
    transform: translateY(-2px);
}

/* Gaveta de inconsistências do rodapé */
.aih-drawer {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 57px;
    max-height: 60%;
    overflow: auto;
    background: var(--t-surface);
    border-top: 1px solid var(--t-border);
    box-shadow: 0 -20px 44px -22px rgba(2, 10, 30, .5);
    padding: 14px 20px;
    z-index: 5;
}

/* Estado vazio centralizado */
.aih-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 70px 20px;
    color: var(--t-faint);
}
.aih-empty > i { font-size: 30px; }
.aih-empty__t { font: 500 13px var(--t-font); text-align: center; }
.aih-empty--sm { padding: 36px 20px; }
.aih-empty--sm > i { font-size: 26px; }
.aih-empty--sm .aih-empty__t { font-size: 12.5px; max-width: 560px; line-height: 1.55; }
.aih-empty--ok { color: var(--t-green); }

.aih-nota {
    padding: 10px 16px;
    border-top: 1px solid var(--t-border);
    font: 500 11px var(--t-font);
    color: var(--t-faint);
    line-height: 1.5;
}
.aih-nota a { font-weight: 600; }

/* ============================================================
   13. MODAL DETALHES — faixa de resumo e conteúdo
   ============================================================ */
.aih-resumo {
    display: flex;
    align-items: center;
    gap: 22px;
    padding: 9px 18px;
    background: var(--t-surface2);
    border-bottom: 1px solid var(--t-border);
    flex-shrink: 0;
    overflow-x: auto;
}
.aih-resumo__item { white-space: nowrap; }
.aih-resumo__item--cid { max-width: 340px; overflow: hidden; }
.aih-resumo__k {
    font: 600 9.5px var(--t-font);
    letter-spacing: .6px;
    color: var(--t-faint);
    text-transform: uppercase;
}
.aih-resumo__v {
    font: 700 12.5px var(--t-font);
    color: var(--t-strong);
    font-variant-numeric: tabular-nums;
}
.aih-resumo__cid { display: flex; align-items: center; gap: 6px; }
.aih-resumo__cid span:last-child {
    font: 500 10.5px var(--t-font);
    color: var(--t-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Cartões de evolução */
.aih-evo {
    background: var(--t-surface);
    border: 1px solid var(--t-border);
    border-left: 3px solid var(--t-muted);
    border-radius: 10px;
    padding: 12px 14px;
}
.aih-evo--blue { border-left-color: var(--t-blue); }
.aih-evo--green { border-left-color: var(--t-green); }
.aih-evo--indigo { border-left-color: var(--t-indigo); }
.aih-evo--teal { border-left-color: var(--t-teal); }
.aih-evo__head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.aih-evo__pill {
    display: inline-flex;
    align-items: center;
    padding: 2px 9px;
    border-radius: 20px;
    font: 700 11px var(--t-font);
    background: var(--t-surface2);
    color: var(--t-muted);
}
.aih-evo--blue .aih-evo__pill { background: var(--t-bluebg); color: var(--t-blue); }
.aih-evo--green .aih-evo__pill { background: var(--t-greenbg); color: var(--t-green); }
.aih-evo--indigo .aih-evo__pill { background: var(--t-indigobg); color: var(--t-indigo); }
.aih-evo--teal .aih-evo__pill { background: var(--t-tealbg); color: var(--t-teal); }
.aih-evo__prof { font: 700 12px var(--t-font); color: var(--t-strong); }
.aih-evo__dt {
    font: 500 11.5px var(--t-font);
    color: var(--t-faint);
    font-variant-numeric: tabular-nums;
}
.aih-evo__txt {
    font: 500 13px var(--t-font);
    color: var(--t-text);
    line-height: 1.6;
    white-space: pre-wrap;
}
.aih-evo__sinais { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }

/* Linha de sinais vitais */
.aih-sv {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    background: var(--t-surface);
    border: 1px solid var(--t-border);
    border-radius: 10px;
    padding: 10px 14px;
}
.aih-sv__dt {
    font: 600 11.5px var(--t-font);
    color: var(--t-faint);
    font-variant-numeric: tabular-nums;
    width: 130px;
    flex-shrink: 0;
}
.aih-sv__prof { font: 500 11px var(--t-font); color: var(--t-muted); }

/* Cabeçalho de prescrição */
.aih-presc__head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 16px;
    border-bottom: 1px solid var(--t-border);
    flex-wrap: wrap;
}
.aih-presc__med { font: 700 12px var(--t-font); color: var(--t-strong); }
.aih-presc__dt {
    font: 500 11.5px var(--t-font);
    color: var(--t-faint);
    font-variant-numeric: tabular-nums;
}
.aih-presc__txt {
    padding: 10px 16px;
    font: 500 12.5px var(--t-font);
    color: var(--t-muted);
    white-space: pre-wrap;
    border-bottom: 1px solid var(--t-border);
}
.aih-tbl--presc td:first-child { padding-left: 16px; font: 600 12.5px var(--t-font); color: var(--t-strong); }
.aih-tbl--presc th:first-child { padding-left: 16px; }
.aih-tbl--presc td { font: 500 12.5px var(--t-font); color: var(--t-text); padding: 8px 12px; }
.aih-tbl--presc td:last-child { padding-right: 16px; font-weight: 600; }
.aih-tbl--presc th:last-child { padding-right: 16px; }

/* Linha de procedimento AIH no modal de detalhes */
.aih-procline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.aih-procline__n {
    display: inline-flex;
    width: 20px;
    height: 20px;
    border-radius: 6px;
    align-items: center;
    justify-content: center;
    font: 700 11px var(--t-font);
    background: var(--t-bluebg);
    color: var(--t-blue);
    flex-shrink: 0;
}
.aih-procline__cod {
    font: 700 12px var(--t-font);
    color: var(--t-blue);
    font-variant-numeric: tabular-nums;
    letter-spacing: .4px;
}
.aih-procline__desc { font: 600 12.5px var(--t-font); color: var(--t-strong); }
.aih-procline__meta {
    font: 500 11.5px var(--t-font);
    color: var(--t-muted);
    font-variant-numeric: tabular-nums;
}

/* ============================================================
   14. LISTA SUSPENSA DOS AUTOCOMPLETES
   ============================================================ */
.aih-ac { position: relative; }
.aih-ac__lista {
    position: absolute;
    left: 0;
    top: 100%;
    z-index: 99999;
    min-width: 300px;
    width: 100%;
    max-height: 320px;
    overflow-y: auto;
    margin-top: 4px;
    background: var(--t-surface);
    border: 1px solid var(--t-border);
    border-radius: 10px;
    box-shadow: 0 18px 44px -18px rgba(2, 10, 30, .45);
    padding: 4px;
}
.aih-ac__item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 6px 10px;
    border: none;
    background: transparent;
    border-radius: 7px;
    font: 500 12px var(--t-font);
    color: var(--t-text);
    cursor: pointer;
    line-height: 1.4;
}
.aih-ac__item:hover { background: var(--t-surface2); color: var(--t-strong); }
.aih-ac__item code {
    font: 700 11.5px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    color: var(--t-blue);
    background: var(--t-bluebg);
    padding: 1px 5px;
    border-radius: 5px;
}

/* ============================================================
   15. RESPONSIVO
   Sem media queries de largura na composição interna (o protótipo
   é de escala fixa); só as grades externas colapsam para não
   estourar a tela em monitores pequenos.
   ============================================================ */
@media (max-width: 1400px) {
    .aih-filtros { grid-template-columns: repeat(3, 1fr) auto; }
}
@media (max-width: 992px) {
    .aih-filtros { grid-template-columns: repeat(2, 1fr); }
    .aih-filtros__acoes { grid-column: 1 / -1; }
    .aih-g3, .aih-g2, .aih-g21, .aih-g12x { grid-template-columns: 1fr; }
    .aih-g12 > [class*="c"] { grid-column: span 12; }
    .aih-modal { width: 100%; height: 100%; border-radius: 0; }
}

/* ============================================================
   16. IMPRESSÃO — o modal de laudo continua com iframe do YNEX
   ============================================================ */
@media print {
    .aih-overlay { position: static; background: none; }
    .aih-modal { width: 100%; height: auto; box-shadow: none; border: none; }
    .aih-modal__head, .aih-modal__foot, .aih-modal__tabs { display: none !important; }
}

/* ============================================================
   17. VARIANTES DE MODAL EXTRAS
   (impressão do laudo e inclusão em lote — não constam do
   protótipo, montados com os mesmos átomos)
   ============================================================ */
.aih-modal--md { width: min(760px, 95%); height: auto; max-height: 90%; }
.aih-modal--a4 { width: min(1000px, 95%); }

.aih-card--critnova {
    background: var(--t-redbg);
    border: 1px solid var(--t-redb);
    border-left: 4px solid var(--t-red);
    border-radius: 10px;
    padding: 12px 16px;
}

/* Linha de opção com rádio (escolher lote existente) */
.aih-optrow {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--t-border);
    background: var(--t-surface);
    cursor: pointer;
    margin: 0;
}
.aih-optrow:hover { background: var(--t-surface2); }
.aih-optrow.is-on { border-color: var(--t-blue); background: var(--t-bluebg); }
.aih-optrow input[type="radio"] { accent-color: #1a4a9e; margin: 0; flex-shrink: 0; }

/* ============================================================
   18. PONTE PARA OS COMPONENTES REAPROVEITADOS
   SigtapBadge, FatAutocomplete, AihProcedimentosRealizadosEditor e
   BuscaEvolucaoFaturamento continuam com o markup Bootstrap deles.
   Aqui as classes do YNEX/Bootstrap são remapeadas para os tokens do
   design — DENTRO de .aihroot apenas, sem vazar para o resto do app.
   ============================================================ */

/* ---- Campos ---- */
.aihroot .form-control,
.aihroot .form-select,
.aihroot .form-control-sm,
.aihroot .form-select-sm {
    height: 30px;
    min-height: 30px;
    padding: 0 10px;
    font: 500 12.5px var(--t-font) !important;
    color: var(--t-strong);
    background: var(--t-input);
    border: 1px solid var(--t-inb);
    border-radius: 8px;
    box-shadow: none;
}
.aihroot .form-select,
.aihroot .form-select-sm { padding: 0 26px 0 8px; }
.aihroot textarea.form-control,
.aihroot textarea.form-control-sm { height: auto; min-height: 58px; padding: 8px 10px; line-height: 1.45; }
.aihroot .form-control:focus,
.aihroot .form-select:focus {
    border-color: var(--t-link);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .16);
}
.aihroot .form-control.is-invalid,
.aihroot .form-select.is-invalid { border: 1.5px solid var(--t-red); background-image: none; }
.aihroot .form-label { display: block; font: 600 11px var(--t-font) !important; color: var(--t-muted); margin-bottom: 4px; }

/* ---- Autocomplete do faturamento ---- */
.aihroot .fat-autocomplete { position: relative; }
.aihroot .aih-fat.is-err .form-control { border: 1.5px solid var(--t-red); }
.aihroot .fat-autocomplete-list {
    background: var(--t-surface);
    border: 1px solid var(--t-border);
    border-radius: 10px;
    box-shadow: 0 18px 44px -18px rgba(2, 10, 30, .45);
    padding: 4px;
}
.aihroot .fat-autocomplete-item {
    padding: 6px 10px;
    border-radius: 7px;
    font: 500 12px var(--t-font) !important;
    color: var(--t-text);
}
.aihroot .fat-autocomplete-item:hover { background: var(--t-surface2); color: var(--t-strong); }

/* ---- Listas de sugestão em list-group (editor de procedimentos) ---- */
/* aih-modal.css usa !important no padding vertical de .aih-modal-edicao .list-group-item */
.aihroot .list-group-item {
    background: transparent;
    border: none;
    border-radius: 7px;
    padding: 6px 10px !important;
    font: 500 12px var(--t-font) !important;
    color: var(--t-text);
}
.aihroot .list-group-item:hover { background: var(--t-surface2); color: var(--t-strong); }
.aihroot code {
    font: 700 11.5px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace !important;
    color: var(--t-blue);
    background: var(--t-bluebg);
    padding: 1px 5px;
    border-radius: 5px;
}

/* ---- Badge do SIGTAP (componente clicável) ---- */
/* custom-size-adjustments.css infla .badge com `padding: .305em .55em !important` */
.aihroot .sigtap-badge,
.aihroot .badge.bg-primary-transparent {
    display: inline-flex;
    align-items: center;
    padding: 1.5px 6px !important;
    border-radius: 6px;
    font: 700 10.5px var(--t-font) !important;
    letter-spacing: .4px;
    background: var(--t-bluebg);
    color: var(--t-blue);
    font-variant-numeric: tabular-nums;
}

/* ---- Botões do editor de procedimentos ---- */
.aihroot .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 30px;
    padding: 0 12px !important;
    font: 600 12px var(--t-font) !important;
    border-radius: 8px;
    border: 1px solid transparent;
    box-shadow: none;
}
/* `.table .btn-sm` do custom-size-adjustments.css usa !important em padding/line-height */
.aihroot .btn-sm { height: 28px; padding: 0 10px !important; font-size: 11.5px !important;
    line-height: 1 !important; border-radius: 7px; }
.aihroot .btn-primary { color: #fff; background: var(--t-grad); border: none; }
.aihroot .btn-success { color: #fff; background: var(--mc-green); border: none; }
.aihroot .btn-outline-secondary { color: var(--t-link); background: transparent; border-color: var(--t-inb); }
.aihroot .btn-outline-secondary:hover { background: var(--t-surface2); color: var(--t-link); }
.aihroot .btn-outline-danger { color: var(--t-red); background: transparent; border-color: var(--t-redb); }
.aihroot .btn-outline-danger:hover { background: var(--t-redbg); color: var(--t-red); }
.aihroot .btn-outline-info { color: var(--t-teal); background: transparent; border-color: var(--t-inb); }
.aihroot .btn-outline-primary { color: var(--t-link); background: transparent; border-color: var(--t-inb); }
.aihroot .btn-warning { color: var(--t-amber); background: var(--t-amberbg); border-color: var(--t-amberb); }
.aihroot .btn:disabled { opacity: .5; }

/* ---- Tabelas Bootstrap dentro do escopo ---- */
.aihroot .table { --bs-table-bg: transparent; margin-bottom: 0; color: var(--t-text); }
/* custom-tables.css usa !important em .table thead th / .table td (padding, borda e
   background). Sem !important aqui, a tabela do editor sairia com o espaçamento do YNEX
   em vez do desenho. */
.aihroot .table > thead > tr > th {
    font: 700 10.5px var(--t-font) !important;
    letter-spacing: .7px;
    color: var(--t-faint) !important;
    text-transform: uppercase;
    padding: 9px 12px !important;
    border-bottom: 1px solid var(--t-border) !important;
    background: var(--t-thead) !important;
}
.aihroot .table > tbody > tr > td {
    padding: 10px 12px !important;
    border-bottom: 1px solid var(--t-border) !important;
    vertical-align: middle;
    color: var(--t-text) !important;
    font-size: 12.5px !important;
}
.aihroot .table > tbody > tr:hover > td { background: var(--t-surface2) !important; }
.aihroot .table-light,
.aihroot .table > thead.table-light > tr > th { background: var(--t-thead) !important; }

/* ---- Alertas Bootstrap dentro do escopo ---- */
.aihroot .alert {
    padding: 10px 14px;
    border-radius: 10px;
    font: 500 12px var(--t-font) !important;
    line-height: 1.55;
    margin-bottom: 10px;
}
.aihroot .alert-info { background: var(--t-bluebg); border: 1px solid var(--t-border); color: var(--t-text); }
.aihroot .alert-success { background: var(--t-greenbg); border: 1px solid var(--t-green); color: var(--t-green); }
.aihroot .alert-warning { background: var(--t-amberbg); border: 1px solid var(--t-amberb); color: var(--t-amber); }
.aihroot .alert-danger { background: var(--t-redbg); border: 1px solid var(--t-redb); color: var(--t-red); }
.aihroot .alert-secondary, .aihroot .alert-light { background: var(--t-surface2); border: 1px solid var(--t-border); color: var(--t-muted); }

/* ---- Cartões Bootstrap dentro do escopo ---- */
.aihroot .card {
    background: var(--t-surface);
    border: 1px solid var(--t-border);
    border-radius: 12px;
    box-shadow: none;
}
.aihroot .card-header { background: transparent; border-bottom: 1px solid var(--t-border); }

/* ---- Casca dos modais reaproveitados (BuscaEvolucaoFaturamento e o
        sub-modal de SIGTAP do editor de procedimentos). A tipografia
        deles continua vindo do CSS próprio; aqui só superfície e forma. ---- */
.aihroot .modal-content,
.bef-modal .modal-content {
    background: var(--t-surface, #fff);
    border: 1px solid var(--t-border, #e2e8f0);
    border-radius: 14px;
    box-shadow: 0 24px 70px -24px rgba(2, 10, 30, .55);
}
.aihroot .modal-header,
.bef-modal .modal-header {
    background: transparent;
    border-bottom: 1px solid var(--t-border, #e2e8f0);
    padding: 12px 18px;
}
.aihroot .modal-body,
.bef-modal .modal-body { background: var(--t-surface2, #f8fafc); padding: 16px 20px; }
.aihroot .modal-footer,
.bef-modal .modal-footer {
    background: var(--t-surface, #fff);
    border-top: 1px solid var(--t-border, #e2e8f0);
    padding: 11px 18px;
}

/* ---- Editor de procedimentos realizados (AihProcedimentosRealizadosEditor) ----
   O componente também roda em /internacao/{id}, fora deste escopo — por isso ele
   mantém o markup Bootstrap e expõe só ganchos `aihpe-*`. Vestidos aqui, dentro de
   .aihroot, a barra de título vira o cabeçalho do cartão do protótipo. */
.aihroot .aih-procedimentos-editor .aihpe-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 !important;
    padding: 12px 16px;
    border-bottom: 1px solid var(--t-border);
}
.aihroot .aih-procedimentos-editor .aihpe-head strong {
    font: 700 11.5px var(--t-font) !important;
    letter-spacing: .8px;
    color: var(--t-strong);
    text-transform: uppercase;
    flex: 1;
}
.aihroot .aih-procedimentos-editor .aihpe-head strong i { color: var(--t-teal); }
.aihroot .aih-procedimentos-editor .aihpe-vazio {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 12px 16px !important;
    padding: 10px !important;
    font: 500 11.5px var(--t-font) !important;
    color: var(--t-faint) !important;
    background: transparent !important;
    border: 1.5px dashed var(--t-border) !important;
    border-radius: 8px;
}
.aihroot .aih-procedimentos-editor .table-responsive { padding: 0; }
.aihroot .aih-procedimentos-editor .table { margin-bottom: 0 !important; }
.aihroot .aih-procedimentos-editor .aihpe-ordem {
    display: inline-flex;
    width: 20px;
    height: 20px;
    border-radius: 6px;
    align-items: center;
    justify-content: center;
    font: 700 11px var(--t-font) !important;
    padding: 0 !important;
    background: var(--t-bluebg) !important;
    color: var(--t-blue) !important;
}
.aihroot .aih-procedimentos-editor .aihpe-cod {
    font: 700 12px var(--t-font) !important;
    color: var(--t-blue) !important;
    background: transparent !important;
    padding: 0 !important;
    letter-spacing: .4px;
    font-variant-numeric: tabular-nums;
}
.aihroot .aih-procedimentos-editor .aihpe-desc {
    font: 600 12px var(--t-font) !important;
    color: var(--t-strong) !important;
}
.aihroot .aih-procedimentos-editor .form-control,
.aihroot .aih-procedimentos-editor .form-select {
    height: 28px;
    min-height: 28px;
    border-radius: 7px;
    font-size: 12px !important;
}

/* ---- Busca na documentação (BuscaEvolucaoFaturamento) ----
   Este modal tem escala tipográfica PRÓPRIA e maior de propósito: é onde o faturista
   lê o trecho da documentação para decidir o vínculo SIGTAP (ver o cabeçalho de
   wwwroot/css/busca-evolucao-faturamento.css). A ponte acima veste as superfícies com
   os tokens do design, mas NÃO pode encolher esse texto — daí a reposição abaixo. */
.aihroot .bef-modal .form-control,
.aihroot .bef-modal .form-select {
    font-size: 14px !important;
    height: auto;
    min-height: 34px;
    padding: 0.35rem 0.7rem;
}
.aihroot .bef-modal .btn {
    font-size: 13.5px !important;
    height: auto;
    padding: 0.35rem 0.7rem !important;
    line-height: 1.4 !important;
}
.aihroot .bef-modal .alert { font-size: 14px !important; }
.aihroot .bef-modal .badge { font-size: 12px !important; padding: 0.25em 0.6em !important; }
.aihroot .bef-modal .list-group-item { font-size: 13.5px !important; padding: 0.4rem 0.7rem !important; }
.aihroot .bef-modal .table > tbody > tr > td { font-size: 14px !important; }
.aihroot .bef-modal .bef-campo-termo { height: auto !important; padding: 0.5rem 0.75rem !important; }
