:root {
    --primaria: #A12FDB;
    --primaria-escura: #8820bd;
    --primaria-clara: #f4e8fc;
    --lateral: #2b1040;
    --lateral-2: #3d1759;
    --lateral-ativo: #4d1d70;
    --fundo: #f3f6f7;
    --cartao: #ffffff;
    --texto: #17343b;
    --suave: #6b8087;
    --borda: #e0e8e7;
    --campo: #f6faf9;
    --erro: #d23b4e;
    --ok: #1f9d68;
    --aviso: #e8912d;
    --raio: 12px;
    --sombra: 0 1px 2px rgba(23, 52, 59, .05), 0 6px 20px rgba(23, 52, 59, .04);
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    color: var(--texto);
    background: var(--fundo);
}

h1, h2 { font-weight: 500; margin: 0; letter-spacing: -.01em; }
a { color: var(--primaria); text-decoration: none; }
a:hover { text-decoration: underline; }

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

.sidebar {
    width: 272px;
    flex: 0 0 272px;
    background: var(--lateral);
    color: #e9dff2;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 24px 18px;
}

.marca { display: block; padding: 0 6px 22px; border-bottom: 1px solid rgba(255, 255, 255, .1); }
.marca:hover { text-decoration: none; }
.marca img { display: block; width: 118px; height: auto; }

.menu { margin-top: 26px; flex: 1; }
.menu-rotulo { font-size: 11px; letter-spacing: .16em; color: #a98cc2; padding: 0 12px; margin-bottom: 10px; }

.menu-rotulo-sec { margin-top: 26px; }
.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 10px;
    color: #e9dff2;
    font-size: 15px;
    position: relative;
}
.menu-item:hover { background: rgba(255, 255, 255, .06); text-decoration: none; color: #fff; }
.menu-item.ativo { background: var(--lateral-ativo); color: #fff; font-weight: 600; }
.menu-item.ativo::before {
    content: "";
    position: absolute;
    left: -18px;
    top: 8px;
    bottom: 8px;
    width: 4px;
    border-radius: 0 4px 4px 0;
    background: var(--primaria);
}

.menu-grupo summary {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 10px;
    cursor: pointer;
    color: #e9dff2;
    font-size: 15px;
}
.menu-grupo summary::-webkit-details-marker { display: none; }
.menu-grupo summary:hover { background: rgba(255, 255, 255, .06); }
.menu-grupo summary .seta { margin-left: auto; transition: transform .15s; }
.menu-grupo[open] summary .seta { transform: rotate(180deg); }

.menu-sub {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 4px 0 0 14px;
    padding: 11px 12px;
    border-radius: 10px;
    color: #cdbbdc;
    font-size: 15px;
    position: relative;
}
.menu-sub:hover { background: rgba(255, 255, 255, .06); text-decoration: none; color: #fff; }
.menu-sub.ativo { background: var(--lateral-ativo); color: #fff; font-weight: 600; }
.menu-sub.ativo::before {
    content: "";
    position: absolute;
    left: -32px;
    top: 8px;
    bottom: 8px;
    width: 4px;
    border-radius: 0 4px 4px 0;
    background: var(--primaria);
}

.usuario-box {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, .1);
}
.usuario-dados { min-width: 0; flex: 1; }
.usuario-nome { font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.usuario-papel { font-size: 12px; color: #bfa8d3; }
.btn-sair { background: none; border: 0; color: #cdbbdc; cursor: pointer; padding: 8px; border-radius: 8px; }
.btn-sair:hover { background: rgba(255, 255, 255, .08); color: #fff; }

.avatar {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--primaria);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 13px;
    flex: 0 0 auto;
}
.avatar-claro { width: 34px; height: 34px; background: var(--primaria-clara); color: var(--primaria); }

.principal { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topo {
    height: 74px;
    background: #fff;
    border-bottom: 1px solid var(--borda);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 40px;
    position: sticky;
    top: 0;
    z-index: 5;
}
.trilha { color: var(--suave); font-size: 15px; }
.trilha span { margin: 0 8px; }
.trilha b { color: var(--texto); font-weight: 600; }
.topo-usuario { margin-left: auto; display: flex; align-items: center; gap: 10px; font-weight: 600; }
.btn-menu { display: none; background: none; border: 0; cursor: pointer; color: var(--texto); padding: 6px; }

.conteudo { padding: 30px 40px 60px; max-width: 1480px; width: 100%; }

/* ---------- cabeçalho de página ---------- */
.pagina-topo { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 26px; flex-wrap: wrap; }
.pagina-topo h1 { font-size: 34px; line-height: 1.15; }
.miga { font-size: 12px; color: var(--suave); margin-bottom: 6px; }
.sub { color: var(--suave); margin: 6px 0 0; font-size: 14px; }
.acoes { display: flex; gap: 12px; }

/* ---------- botões ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 46px;
    padding: 0 22px;
    border-radius: 10px;
    border: 1px solid transparent;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, box-shadow .15s;
}
.btn:hover { text-decoration: none; }
.btn-primario { background: var(--primaria); color: #fff; box-shadow: 0 6px 16px rgba(161, 47, 219, .28); }
.btn-primario:hover { background: var(--primaria-escura); }
.btn-claro { background: #fff; color: var(--texto); border-color: var(--borda); }
.btn-claro:hover { background: var(--campo); }
.btn-pequeno { height: 36px; padding: 0 16px; font-size: 13px; }
.btn-bloco { width: 100%; }

/* ---------- alertas ---------- */
.alerta { padding: 12px 16px; border-radius: 10px; margin-bottom: 20px; font-weight: 500; }
.alerta-ok { background: #e6f6ee; color: #14724b; border: 1px solid #bfe6d2; }
.alerta-erro { background: #fdecee; color: #a8283a; border: 1px solid #f5c3ca; }
.alerta-erro:empty { display: none; }
.validation-summary-valid { display: none; }

/* ---------- formulário em cartão ---------- */
.grade { display: grid; grid-template-columns: 276px 1fr; gap: 24px; align-items: start; }

.resumo {
    background: var(--lateral);
    color: #fff;
    border-radius: 16px;
    padding: 28px;
    position: sticky;
    top: 98px;
}
.resumo-icone { width: 58px; height: 58px; border-radius: 14px; background: var(--lateral-2); display: grid; place-items: center; color: #c9a3e6; }
.resumo-sub { font-size: 11px; letter-spacing: .16em; color: #b79bcf; margin-top: 44px; }
.resumo-titulo { font-size: 22px; margin: 8px 0 14px; word-break: break-word; }
.resumo-lista { margin: 22px 0 0; }
.resumo-lista > div { padding: 12px 0; border-top: 1px solid rgba(255, 255, 255, .1); }
.resumo-lista dt { font-size: 11px; color: #b79bcf; }
.resumo-lista dd { margin: 4px 0 0; font-weight: 600; font-size: 14px; word-break: break-word; }
.progresso { margin-top: 18px; padding-top: 16px; border-top: 1px solid rgba(255, 255, 255, .1); }
.progresso-topo { display: flex; justify-content: space-between; font-size: 11px; color: #b79bcf; }
.progresso-topo b { color: #fff; }
.progresso-trilho { height: 6px; border-radius: 6px; background: rgba(255, 255, 255, .12); margin-top: 10px; overflow: hidden; }
.progresso-barra { height: 100%; width: 0; background: var(--primaria); border-radius: 6px; transition: width .25s; }

.selo {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    background: #fff1d6;
    color: #a56a0b;
}
.selo[data-status="EM USO"], .selo.ok { background: #dff5ea; color: #14724b; }
#rs-status { background: rgba(255, 255, 255, .14); color: #fff; }
#rs-status.ok { background: #dff5ea; color: #14724b; }
#rs-status.aviso { background: #fff1d6; color: #a56a0b; }

.cartao { background: var(--cartao); border: 1px solid var(--borda); border-radius: 16px; box-shadow: var(--sombra); }
.cartao-pad { padding: 24px 28px; margin-bottom: 20px; }

.abas { display: flex; gap: 8px; padding: 0 28px; border-bottom: 1px solid var(--borda); overflow-x: auto; }
.aba {
    background: none;
    border: 0;
    border-bottom: 2px solid transparent;
    padding: 22px 14px 16px;
    margin-bottom: -1px;
    font: inherit;
    font-weight: 600;
    color: var(--suave);
    cursor: pointer;
    white-space: nowrap;
}
.aba:hover { color: var(--texto); }
.aba.ativa { color: var(--primaria); border-bottom-color: var(--primaria); }
.aba.tem-erro { color: var(--erro); }

.painel { display: none; padding: 30px 30px 34px; }
.painel.ativo { display: block; }
.painel-topo { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; }
.painel-topo h2 { font-size: 22px; }
.obrig { font-size: 12px; color: var(--suave); }

.campos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 24px; }
.campo { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.campo.largo { grid-column: 1 / -1; }
.campo label { font-weight: 600; font-size: 13px; }

.form-cartao { max-width: 560px; }

.campo select {
    height: 46px;
    padding: 0 14px;
    border: 1px solid var(--borda);
    border-radius: 10px;
    background: var(--campo);
    color: var(--texto);
    font: inherit;
    width: 100%;
}
.campo select:focus { outline: 0; border-color: var(--primaria); box-shadow: 0 0 0 3px rgba(161, 47, 219, .15); background: #fff; }

.campo input {
    height: 46px;
    padding: 0 14px;
    border: 1px solid var(--borda);
    border-radius: 10px;
    background: var(--campo);
    color: var(--texto);
    font: inherit;
    width: 100%;
}
.campo input::placeholder { color: #a5b5b9; }
.campo input:focus { outline: 0; border-color: var(--primaria); box-shadow: 0 0 0 3px rgba(161, 47, 219, .15); background: #fff; }
.campo input[readonly] { background: #eceff0; color: #5d7076; cursor: not-allowed; }
.campo.tem-erro input, .campo input.input-validation-error { border-color: var(--erro); }
.msg-erro, .field-validation-error { color: var(--erro); font-size: 12px; font-weight: 500; }
.dica { color: var(--suave); font-size: 12px; }

/* ---------- pesquisa e tabela ---------- */
.pesquisa { display: grid; grid-template-columns: 1fr 1fr auto; gap: 20px; align-items: end; }
.pesquisa-acoes { display: flex; gap: 10px; }

.tabela-info { color: var(--suave); font-size: 13px; margin-bottom: 12px; }
.tabela-rolagem { overflow-x: auto; }
.tabela { width: 100%; border-collapse: collapse; }
.tabela th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--suave); padding: 10px 12px; border-bottom: 1px solid var(--borda); white-space: nowrap; }
.tabela td { padding: 14px 12px; border-bottom: 1px solid var(--borda); vertical-align: middle; }
.tabela tbody tr:hover { background: var(--campo); }
.td-acao { text-align: right; white-space: nowrap; }
.vazio { text-align: center; color: var(--suave); padding: 36px 0; margin: 0; }

/* ---------- login e cadastro de usuário ---------- */
.auth-body { background: #fff; }
.auth { display: grid; grid-template-columns: minmax(340px, 46%) 1fr; min-height: 100vh; }
.auth-lado {
    background: linear-gradient(160deg, var(--lateral) 0%, #4b1a70 100%);
    color: #fff;
    padding: 48px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.auth-lado .marca { border-bottom: 0; padding: 0; }
.auth-lado .marca img { width: 190px; }
.auth-texto h2 { font-size: 34px; line-height: 1.2; max-width: 420px; }
.auth-texto p { color: #d4c1e4; max-width: 420px; margin-top: 14px; font-size: 16px; }

.auth-form { display: flex; flex-direction: column; justify-content: center; padding: 48px; max-width: 520px; width: 100%; margin: 0 auto; }
.auth-form h1 { font-size: 30px; }
.form-auth { display: flex; flex-direction: column; gap: 18px; margin-top: 26px; }
.auth-rodape { margin-top: 24px; color: var(--suave); }

/* ---------- responsivo ---------- */
@media (max-width: 1100px) {
    .grade { grid-template-columns: 1fr; }
    .resumo { position: static; }
    .resumo-sub { margin-top: 20px; }
}

@media (max-width: 900px) {
    .sidebar { position: fixed; left: 0; top: 0; z-index: 20; transform: translateX(-100%); transition: transform .2s; }
    .sidebar.aberta { transform: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .35); }
    .btn-menu { display: inline-flex; }
    .topo, .conteudo { padding-left: 18px; padding-right: 18px; }
    .campos { grid-template-columns: 1fr; }
    .pesquisa { grid-template-columns: 1fr; }
    .auth { grid-template-columns: 1fr; }
    .auth-lado { padding: 28px; gap: 24px; }
    .auth-texto h2 { font-size: 24px; }
    .auth-form { padding: 28px 18px; }
    .topo-nome { display: none; }
}

@media (max-width: 640px) {
    .tabela thead { display: none; }
    .tabela, .tabela tbody, .tabela tr, .tabela td { display: block; width: 100%; }
    .tabela tr { border: 1px solid var(--borda); border-radius: 12px; padding: 8px 12px; margin-bottom: 12px; }
    .tabela td { border: 0; padding: 6px 0; display: flex; justify-content: space-between; gap: 12px; }
    .tabela td::before { content: attr(data-rotulo); color: var(--suave); font-size: 12px; }
    .td-acao { justify-content: flex-end; }
    .td-acao::before { content: none; }
}
