/* ============================================================================
   CARE MAIS CORE — design system
   Marca: azul #307EB2 · verde #42D7A0 · grafite #58595B
   Tema claro padrão; escuro via [data-theme="dark"].
   ============================================================================ */

:root {
    --care-azul:        #307EB2;
    --care-azul-escuro: #235F87;
    --care-azul-claro:  #E8F2F9;
    --care-verde:       #42D7A0;
    --care-verde-escuro:#1FA877;
    --care-verde-claro: #E6FAF2;
    --care-grafite:     #58595B;
    --care-gradiente:   linear-gradient(135deg, #307EB2 0%, #3AA9A8 55%, #42D7A0 100%);

    --bg:          #F4F7FA;
    --bg-card:     #FFFFFF;
    --bg-muted:    #EEF2F6;
    --bg-hover:    #F7FAFC;
    --borda:       #E2E8EF;
    --borda-forte: #CBD5E1;
    --texto:       #16212E;
    --texto-suave: #4B5B6D;
    --texto-fraco: #8594A6;

    --sucesso: #16A36B;  --sucesso-bg: #E6F7EF;
    --perigo:  #D64545;  --perigo-bg:  #FCEBEB;
    --alerta:  #C98A0B;  --alerta-bg:  #FDF4E0;
    --info:    #307EB2;  --info-bg:    #E8F2F9;

    --side-bg:     #0E2233;
    --side-bg-2:   #15314A;
    --side-texto:  #C9D6E3;
    --side-fraco:  #7F95AB;

    --fonte-titulo: 'Poppins', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --fonte:        'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

    --raio:    10px;
    --raio-lg: 16px;
    --sombra:  0 1px 2px rgba(15, 34, 51, .06), 0 1px 3px rgba(15, 34, 51, .04);
    --sombra-md: 0 8px 24px rgba(15, 34, 51, .10);
    --side-w: 252px;
    --top-h:  64px;
}

[data-theme="dark"] {
    --bg:          #0B141D;
    --bg-card:     #111D29;
    --bg-muted:    #172636;
    --bg-hover:    #152433;
    --borda:       #1F3144;
    --borda-forte: #2B435B;
    --texto:       #E5ECF3;
    --texto-suave: #B3C2D1;
    --texto-fraco: #7D90A5;
    --care-azul-claro:  rgba(48, 126, 178, .16);
    --care-verde-claro: rgba(66, 215, 160, .14);
    --sucesso-bg: rgba(22, 163, 107, .16);
    --perigo-bg:  rgba(214, 69, 69, .16);
    --alerta-bg:  rgba(201, 138, 11, .16);
    --info-bg:    rgba(48, 126, 178, .18);
    --side-bg:    #07111A;
    --side-bg-2:  #0F2030;
    --sombra:     0 1px 2px rgba(0, 0, 0, .3);
}

/* ------------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--fonte);
    font-size: 14px;
    line-height: 1.5;
    color: var(--texto);
    background: var(--bg);
}
h1, h2, h3, h4 { font-family: var(--fonte-titulo); font-weight: 600; margin: 0 0 .5em; line-height: 1.25; }
h1 { font-size: 22px; } h2 { font-size: 18px; } h3 { font-size: 15px; }
a { color: var(--care-azul); text-decoration: none; }
a:hover { text-decoration: underline; }
p { margin: 0 0 .75em; }
small, .texto-fraco { color: var(--texto-fraco); }
.texto-suave { color: var(--texto-suave); }
hr { border: 0; border-top: 1px solid var(--borda); margin: 20px 0; }
code { font-size: 12px; background: var(--bg-muted); padding: 2px 6px; border-radius: 4px; }
.visivel-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: rgba(120, 140, 160, .35); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }

/* ------------------------------------------------------------ app shell */
.app { display: flex; min-height: 100vh; }

.side {
    position: fixed; inset: 0 auto 0 0;
    width: var(--side-w);
    background: var(--side-bg);
    color: var(--side-texto);
    display: flex; flex-direction: column;
    z-index: 40;
    transition: transform .25s ease;
}
.side__marca { display: flex; align-items: center; height: var(--top-h); padding: 0 22px; border-bottom: 1px solid rgba(255,255,255,.06); }
.side__marca img { height: 34px; width: auto; }
.side__nav { flex: 1; overflow-y: auto; padding: 12px 12px 24px; }
.side__rotulo { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--side-fraco); padding: 16px 12px 6px; }
.side__nav a {
    display: flex; align-items: center; gap: 12px;
    padding: 9px 12px; border-radius: 8px;
    color: var(--side-texto); font-weight: 500;
    text-decoration: none;
}
.side__nav a:hover { background: var(--side-bg-2); color: #fff; }
.side__nav a.ativo { background: linear-gradient(90deg, rgba(48,126,178,.35), rgba(66,215,160,.12)); color: #fff; box-shadow: inset 3px 0 0 var(--care-verde); }
.side__nav svg { flex: none; opacity: .85; }
.side__rodape { padding: 14px 22px; font-size: 11px; color: var(--side-fraco); border-top: 1px solid rgba(255,255,255,.06); }

.principal { flex: 1; margin-left: var(--side-w); min-width: 0; display: flex; flex-direction: column; }

.topo {
    position: sticky; top: 0; z-index: 30;
    height: var(--top-h);
    display: flex; align-items: center; gap: 12px;
    padding: 0 28px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--borda);
}
.topo__titulo { font-family: var(--fonte-titulo); font-weight: 600; font-size: 16px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topo__acoes { display: flex; align-items: center; gap: 6px; }
.btn-icone {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border-radius: 10px;
    background: transparent; border: 1px solid transparent; color: var(--texto-suave);
    cursor: pointer;
}
.btn-icone:hover { background: var(--bg-muted); color: var(--texto); }
.btn-menu { display: none; }
.perfil { display: flex; align-items: center; gap: 10px; padding: 4px 6px 4px 4px; border-radius: 999px; }
.perfil__avatar {
    width: 34px; height: 34px; border-radius: 50%;
    display: grid; place-items: center;
    background: var(--care-gradiente); color: #fff; font-weight: 600; font-size: 13px;
}
.perfil__nome { font-weight: 600; font-size: 13px; line-height: 1.2; }
.perfil__nivel { font-size: 11px; color: var(--texto-fraco); }

.conteudo { padding: 28px; max-width: 1400px; width: 100%; }

.overlay-side { display: none; }

@media (max-width: 960px) {
    .side { transform: translateX(-100%); }
    .side.aberta { transform: none; box-shadow: var(--sombra-md); }
    .overlay-side.ativo { display: block; position: fixed; inset: 0; background: rgba(8, 18, 28, .5); z-index: 35; }
    .principal { margin-left: 0; }
    .btn-menu { display: inline-flex; }
    .topo { padding: 0 16px; }
    .conteudo { padding: 18px 16px; }
    .perfil__texto { display: none; }
}

/* ---------------------------------------------------------- cabeçalhos */
.cabecalho { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.cabecalho h1 { margin: 0; }
.cabecalho p { margin: 4px 0 0; color: var(--texto-suave); }
.cabecalho__acoes { display: flex; gap: 8px; flex-wrap: wrap; }
.migalha { font-size: 12px; color: var(--texto-fraco); margin-bottom: 6px; }
.migalha a { color: var(--texto-fraco); }

/* --------------------------------------------------------------- cards */
.card { background: var(--bg-card); border: 1px solid var(--borda); border-radius: var(--raio-lg); box-shadow: var(--sombra); }
.card__corpo { padding: 20px; }
.card__cabecalho { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--borda); }
.card__cabecalho h2, .card__cabecalho h3 { margin: 0; }
.card + .card { margin-top: 20px; }

.grade { display: grid; gap: 16px; }
.grade-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grade-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grade-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .grade-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grade-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px)  { .grade-2, .grade-3, .grade-4 { grid-template-columns: 1fr; } }

.kpi { padding: 18px 20px; display: flex; flex-direction: column; gap: 6px; position: relative; overflow: hidden; }
.kpi__rotulo { font-size: 12px; font-weight: 500; color: var(--texto-suave); }
.kpi__valor { font-family: var(--fonte-titulo); font-size: 26px; font-weight: 600; line-height: 1.1; }
.kpi__nota { font-size: 12px; color: var(--texto-fraco); }
.kpi::after { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--care-gradiente); }
.kpi--alerta::after { background: var(--alerta); }
.kpi--perigo::after { background: var(--perigo); }

/* ------------------------------------------------------------- botões */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 38px; padding: 0 16px;
    border-radius: var(--raio); border: 1px solid transparent;
    font: inherit; font-weight: 600; font-size: 13px;
    cursor: pointer; text-decoration: none; white-space: nowrap;
    transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primario { background: var(--care-azul); color: #fff; }
.btn-primario:hover { background: var(--care-azul-escuro); }
.btn-verde { background: var(--care-verde-escuro); color: #fff; }
.btn-verde:hover { background: #178a61; }
.btn-secundario { background: var(--bg-card); color: var(--texto); border-color: var(--borda-forte); }
.btn-secundario:hover { background: var(--bg-muted); }
.btn-perigo { background: var(--perigo); color: #fff; }
.btn-perigo:hover { background: #b93636; }
.btn-fantasma { background: transparent; color: var(--texto-suave); }
.btn-fantasma:hover { background: var(--bg-muted); color: var(--texto); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; border-radius: 8px; }
.btn-bloco { width: 100%; }
.form-inline { display: inline; margin: 0; }

/* ----------------------------------------------------------- formulários */
.form-grade { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
.col-12 { grid-column: span 12; } .col-8 { grid-column: span 8; } .col-6 { grid-column: span 6; }
.col-4 { grid-column: span 4; } .col-3 { grid-column: span 3; } .col-2 { grid-column: span 2; }
@media (max-width: 760px) { .form-grade > [class*="col-"] { grid-column: span 12; } }

.campo { display: flex; flex-direction: column; gap: 6px; }
.campo label, .rotulo { font-size: 12px; font-weight: 600; color: var(--texto-suave); }
.campo .ajuda { font-size: 12px; color: var(--texto-fraco); }
.obrigatorio::after { content: ' *'; color: var(--perigo); }

input[type=text], input[type=email], input[type=password], input[type=number], input[type=date],
input[type=time], input[type=datetime-local], input[type=tel], input[type=search], input[type=url], select, textarea {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    font: inherit;
    color: var(--texto);
    background: var(--bg-card);
    border: 1px solid var(--borda-forte);
    border-radius: var(--raio);
    transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; min-height: 90px; padding: 10px 12px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--care-azul); box-shadow: 0 0 0 3px rgba(48, 126, 178, .18); }
input[readonly] { background: var(--bg-muted); }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--care-azul); }
.form-acoes { display: flex; justify-content: flex-end; gap: 8px; padding-top: 8px; }

.filtros { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 16px; }
.filtros .campo { min-width: 160px; }
.filtros .campo--busca { flex: 1; min-width: 220px; }

/* -------------------------------------------------------------- tabelas */
.tabela-wrap { overflow-x: auto; }
table.tabela { width: 100%; border-collapse: collapse; }
.tabela th {
    text-align: left; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
    color: var(--texto-fraco); padding: 12px 16px; border-bottom: 1px solid var(--borda); white-space: nowrap;
}
.tabela td { padding: 12px 16px; border-bottom: 1px solid var(--borda); vertical-align: middle; }
.tabela tr:last-child td { border-bottom: 0; }
.tabela tbody tr:hover { background: var(--bg-hover); }
.tabela .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tabela .acoes { text-align: right; white-space: nowrap; }
.tabela__sub { display: block; font-size: 12px; color: var(--texto-fraco); }

.vazio { text-align: center; padding: 48px 20px; color: var(--texto-fraco); }
.vazio strong { display: block; color: var(--texto); font-size: 15px; margin-bottom: 4px; }

/* --------------------------------------------------------------- badges */
.badge {
    display: inline-flex; align-items: center; gap: 6px;
    height: 22px; padding: 0 9px; border-radius: 999px;
    font-size: 11px; font-weight: 600; white-space: nowrap;
    background: var(--bg-muted); color: var(--texto-suave);
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge--sucesso { background: var(--sucesso-bg); color: var(--sucesso); }
.badge--perigo  { background: var(--perigo-bg);  color: var(--perigo); }
.badge--alerta  { background: var(--alerta-bg);  color: var(--alerta); }
.badge--info    { background: var(--info-bg);    color: var(--info); }
.badge--neutro  { background: var(--bg-muted);   color: var(--texto-suave); }

/* --------------------------------------------------------------- alertas */
.alerta { display: block; padding: 12px 16px; border-radius: var(--raio); margin-bottom: 16px; font-weight: 500; border: 1px solid transparent; }
.alerta--sucesso { background: var(--sucesso-bg); color: var(--sucesso); border-color: rgba(22,163,107,.25); }
.alerta--erro    { background: var(--perigo-bg);  color: var(--perigo);  border-color: rgba(214,69,69,.25); }
.alerta--aviso   { background: var(--alerta-bg);  color: var(--alerta);  border-color: rgba(201,138,11,.25); }
.alerta--info    { background: var(--info-bg);    color: var(--info);    border-color: rgba(48,126,178,.25); }

/* ------------------------------------------------------------------ abas */
.abas { display: flex; gap: 4px; border-bottom: 1px solid var(--borda); margin-bottom: 20px; overflow-x: auto; }
.abas a, .abas button {
    padding: 10px 14px; border: 0; background: none; cursor: pointer;
    font: inherit; font-weight: 600; color: var(--texto-fraco);
    border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; text-decoration: none;
}
.abas .ativo { color: var(--care-azul); border-bottom-color: var(--care-azul); }

/* ------------------------------------------------------------- listas */
.lista-def { display: grid; grid-template-columns: 160px 1fr; gap: 8px 16px; margin: 0; }
.lista-def dt { color: var(--texto-fraco); font-size: 12px; font-weight: 600; }
.lista-def dd { margin: 0; }

.paginacao { display: flex; gap: 4px; justify-content: center; padding: 16px; }
.paginacao a { min-width: 34px; height: 34px; display: grid; place-items: center; border-radius: 8px; border: 1px solid var(--borda); color: var(--texto-suave); }
.paginacao a.ativo { background: var(--care-azul); border-color: var(--care-azul); color: #fff; }
.paginacao a:hover { text-decoration: none; background: var(--bg-muted); }
.paginacao a.ativo:hover { background: var(--care-azul-escuro); }

pre.sql { max-height: 260px; overflow: auto; background: var(--bg-muted); padding: 12px; border-radius: var(--raio); font-size: 12px; margin: 0; }
details summary { cursor: pointer; font-weight: 600; color: var(--care-azul); }

/* ---------------------------------------------------------------- login */
.login {
    min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr;
    background: var(--bg);
}
.login__arte {
    position: relative; overflow: hidden;
    background: var(--care-gradiente);
    color: #fff; padding: 56px;
    display: flex; flex-direction: column; justify-content: space-between;
}
.login__arte::before, .login__arte::after {
    content: ''; position: absolute; border-radius: 28px; transform: rotate(-12deg);
    background: rgba(255,255,255,.08);
}
.login__arte::before { width: 340px; height: 120px; right: -60px; top: 32%; }
.login__arte::after  { width: 120px; height: 340px; right: 50px; top: 18%; }
.login__arte img { height: 64px; width: auto; position: relative; }
.login__arte h2 { font-size: 32px; max-width: 420px; position: relative; }
.login__arte p { opacity: .9; max-width: 400px; position: relative; }
.login__form { display: flex; align-items: center; justify-content: center; padding: 32px 20px; }
.login__caixa { width: 100%; max-width: 380px; }
.login__caixa .logo-mobile { display: none; height: 44px; margin-bottom: 24px; }
.login__caixa h1 { font-size: 24px; }
.login__caixa form { display: flex; flex-direction: column; gap: 16px; margin-top: 24px; }
.login__opcoes { display: flex; justify-content: space-between; align-items: center; font-size: 13px; }
@media (max-width: 860px) {
    .login { grid-template-columns: 1fr; }
    .login__arte { display: none; }
    .login__caixa .logo-mobile { display: block; }
}

/* -------------------------------------------------------------- erros */
.pagina-erro { min-height: 70vh; display: grid; place-items: center; text-align: center; }
.pagina-erro .codigo { font-family: var(--fonte-titulo); font-size: 72px; font-weight: 700; background: var(--care-gradiente); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------------------------------------------------------- utilitários */
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: 16px; }
.flex { display: flex; } .gap-1 { gap: 8px; } .gap-2 { gap: 16px; } .centro { align-items: center; } .entre { justify-content: space-between; }
.direita { text-align: right; } .negrito { font-weight: 600; } .nowrap { white-space: nowrap; }
.oculto { display: none !important; }

/* itens de menu ainda não implementados */
.side__nav .em-breve { display: flex; align-items: center; gap: 12px; padding: 9px 12px; color: var(--side-fraco); opacity: .55; cursor: default; font-weight: 500; }
.side__nav .em-breve small { margin-left: auto; font-size: 10px; border: 1px solid rgba(255,255,255,.15); border-radius: 999px; padding: 0 6px; color: var(--side-fraco); }

/* ajustes */
.grade > .card + .card { margin-top: 0; }
.login__arte img { align-self: flex-start; object-fit: contain; max-width: 260px; height: auto; }
.side__nav .em-breve small { white-space: nowrap; }
