/* ============================================================
   APKK — Sistema de Gestão (tema corporativo, padrão DWM)
   Navbar escura + menu lateral + paleta azul/cinza claro.
   ============================================================ */

:root {
    --navy:      #16233e;   /* navbar / sidebar */
    --navy-2:    #1d2e4f;   /* hover sidebar */
    --navy-3:    #243a63;
    --primary:   #2563eb;   /* azul ação */
    --primary-d: #1d4ed8;
    --bg:        #eef1f6;   /* fundo da página */
    --surface:   #ffffff;
    --border:    #e3e8f0;
    --text:      #1f2a3d;
    --muted:     #6b7689;
    --success:   #16a34a;
    --success-b: #dcfce7;
    --warn:      #b45309;
    --warn-b:    #fef3c7;
    --danger:    #dc2626;
    --danger-b:  #fee2e2;
    --info:      #2563eb;
    --info-b:    #e0ebfd;
    --ouro:      #c8a24a;
    --shadow:    0 1px 3px rgba(16,26,46,.08), 0 1px 2px rgba(16,26,46,.06);
    --nav-h:     56px;
    --sb-w:      244px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0; padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', system-ui, -apple-system, Segoe UI, sans-serif;
    font-size: 14.5px;
    line-height: 1.5;
}

h1,h2,h3,h4 { font-family: 'Inter', sans-serif; color: var(--text); margin: 0 0 .6rem; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------- Navbar (topo fixo) ---------------- */
.navbar {
    position: fixed; top: 0; left: 0; right: 0; height: var(--nav-h);
    background: var(--navy); color: #eaf0fb; z-index: 1030;
    display: flex; align-items: center; gap: .9rem; padding: 0 1rem;
    box-shadow: 0 1px 0 rgba(255,255,255,.04), 0 2px 8px rgba(0,0,0,.18);
}
.nav-toggle {
    background: transparent; border: none; color: #cdd8ee; font-size: 1.4rem;
    cursor: pointer; padding: .2rem .45rem; border-radius: 6px; line-height: 1;
}
.nav-toggle:hover { background: rgba(255,255,255,.08); color: #fff; }
.navbar-brand { display: flex; align-items: center; gap: .6rem; color: #fff; }
.navbar-brand:hover { text-decoration: none; }
.navbar-brand img.logo-img { height: 38px; width: 38px; border-radius: 50%; background: #fff; padding: 1px; object-fit: contain; }
.navbar-brand .kanji { font-family: 'Oswald', serif; color: var(--ouro); font-size: 1.4rem; }
.brand-txt { display: flex; flex-direction: column; line-height: 1.1; }
.brand-txt strong { font-size: .95rem; font-weight: 600; }
.brand-txt small { color: #9fb2d4; font-size: .68rem; letter-spacing: 1.5px; text-transform: uppercase; }
.navbar-spacer { flex: 1; }
.navbar-right { display: flex; align-items: center; gap: .5rem; }
.dojo-chip {
    display: inline-flex; align-items: center; gap: .4rem;
    background: rgba(255,255,255,.08); color: #dbe6fb;
    padding: .32rem .7rem; border-radius: 20px; font-size: .82rem; font-weight: 500;
}
.dojo-chip i { color: var(--ouro); }
.navbar-right .trocar { color: #9fb2d4; font-size: .78rem; }
.navbar-user { display: inline-flex; align-items: center; gap: .4rem; color: #dbe6fb; font-size: .85rem; padding-left: .3rem; }
.btn-sair {
    display: inline-flex; align-items: center; gap: .4rem; color: #fff;
    background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.14);
    padding: .35rem .75rem; border-radius: 6px; font-size: .82rem;
}
.btn-sair:hover { background: var(--danger); border-color: var(--danger); text-decoration: none; }

/* ---------------- Sidebar (menu lateral) ---------------- */
.sidebar {
    position: fixed; top: var(--nav-h); bottom: 0; left: 0; width: var(--sb-w);
    background: var(--navy); color: #c4d0e6; z-index: 1020;
    overflow-y: auto; padding: .6rem 0 2rem; transition: transform .2s ease;
    border-right: 1px solid rgba(255,255,255,.05);
}
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 4px; }
.menu-section { color: #6f80a3; font-size: .68rem; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; padding: 1rem 1.1rem .3rem; }
.menu-item {
    display: flex; align-items: center; gap: .7rem; padding: .6rem 1.1rem;
    color: #c4d0e6; font-size: .9rem; border-left: 3px solid transparent;
}
.menu-item:hover { background: var(--navy-2); color: #fff; text-decoration: none; }
.menu-item i { font-size: 1.05rem; width: 20px; text-align: center; color: #8fa3c8; }
.menu-item.active { background: var(--navy-3); color: #fff; border-left-color: var(--primary); font-weight: 600; }
.menu-item.active i { color: #fff; }

/* ---------------- Layout principal ---------------- */
.app-main { margin-left: var(--sb-w); padding: 1.4rem 1.6rem 3rem; min-height: calc(100vh - var(--nav-h)); margin-top: var(--nav-h); transition: margin .2s ease; }
body.nav-closed .sidebar { transform: translateX(-100%); }
body.nav-closed .app-main { margin-left: 0; }
.sb-overlay { display: none; }
@media (max-width: 992px) {
    .app-main { margin-left: 0; }
    .sidebar { transform: translateX(-100%); box-shadow: 2px 0 16px rgba(0,0,0,.35); }
    body.nav-open .sidebar { transform: translateX(0); }
    body.nav-open .sb-overlay { display: block; position: fixed; inset: var(--nav-h) 0 0 0; background: rgba(8,14,28,.45); z-index: 1015; }
    .brand-txt { display: none; }
}

/* ---------------- Cabeçalho de página ---------------- */
.cabecalho-pagina {
    display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .8rem;
    margin-bottom: 1.2rem; padding-bottom: .9rem; border-bottom: 1px solid var(--border);
}
.cabecalho-pagina h1 { margin: 0; }

/* ---------------- Flash ---------------- */
.flash { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid; font-size: .92rem; }
.flash-sucesso { background: var(--success-b); border-color: #bbf7d0; color: #14532d; }
.flash-erro    { background: var(--danger-b); border-color: #fecaca; color: #991b1b; }
.flash-aviso   { background: var(--warn-b); border-color: #fde68a; color: #92400e; }

/* ---------------- Cards / stats ---------------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px,1fr)); gap: 1rem; margin-bottom: 1.6rem; }
.card-stat { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 1.1rem 1.2rem; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.card-stat::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--primary); }
.card-stat .numero { font-size: 2.1rem; font-weight: 700; color: var(--text); line-height: 1; }
.card-stat .rotulo { color: var(--muted); text-transform: uppercase; letter-spacing: .5px; font-size: .74rem; margin-top: .35rem; font-weight: 600; }

.painel-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 1.2rem; }
@media (max-width: 800px) { .painel-grid { grid-template-columns: 1fr; } }

.box { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 1.2rem 1.3rem; box-shadow: var(--shadow); margin-bottom: 1.2rem; }
.box > h2:first-child { margin-top: 0; }

/* ---------------- Tabelas ---------------- */
table.lista { width: 100%; border-collapse: collapse; background: var(--surface); box-shadow: var(--shadow); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
table.lista th, table.lista td { padding: .65rem .85rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.lista th { background: #f7f9fc; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; font-size: .72rem; }
table.lista tr:last-child td { border-bottom: none; }
table.lista tbody tr:hover td { background: #f9fbfe; }
table.lista th a.th-sort { color: inherit; text-decoration: none; cursor: pointer; display: inline-flex; align-items: center; gap: .25rem; white-space: nowrap; }
table.lista th a.th-sort:hover { color: var(--primary); }
table.lista th a.th-sort i { font-size: .7rem; color: var(--primary); }
.acoes-cel { display: flex; gap: .35rem; align-items: center; flex-wrap: wrap; }

/* ---------------- Formulários ---------------- */
form.formulario { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 1.4rem; box-shadow: var(--shadow); max-width: none; }
.campo { margin-bottom: 1rem; }
.campo label { display: block; font-weight: 600; margin-bottom: .3rem; font-size: .85rem; color: #374151; }
.campo input, .campo select, .campo textarea {
    width: 100%; padding: .55rem .7rem; border: 1px solid #cfd8e6; border-radius: 7px;
    font-family: inherit; font-size: .92rem; background: #fff; color: var(--text); transition: border .15s, box-shadow .15s;
}
.campo input:focus, .campo select:focus, .campo textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.campo textarea { min-height: 90px; resize: vertical; }
.linha-campos { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.linha-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
.linha-4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 1rem; }
@media (max-width: 760px) { .linha-3, .linha-4 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 600px) { .linha-campos, .linha-3, .linha-4 { grid-template-columns: 1fr; } }
form.formulario.full { max-width: none; }
.form-secao { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: var(--primary); border-bottom: 1px solid var(--border); padding-bottom: .35rem; margin: 1.4rem 0 1rem; }
.form-secao:first-child { margin-top: 0; }
.ajuda { color: var(--muted); font-size: .78rem; margin-top: .25rem; }

/* ---------------- Botões ---------------- */
.btn {
    display: inline-flex; align-items: center; gap: .4rem; justify-content: center;
    font-family: inherit; font-weight: 600; font-size: .86rem; padding: .5rem .95rem;
    border: 1px solid transparent; border-radius: 7px; background: var(--primary); color: #fff; cursor: pointer; text-decoration: none; transition: background .15s, box-shadow .15s;
}
.btn:hover { background: var(--primary-d); text-decoration: none; box-shadow: 0 2px 6px rgba(37,99,235,.25); }
.btn-tinta { background: var(--navy); }
.btn-tinta:hover { background: var(--navy-2); }
.btn-sec { background: #fff; color: var(--primary); border-color: #c7d4ea; }
.btn-sec:hover { background: #f1f5fd; color: var(--primary-d); box-shadow: none; }
.btn-sm { padding: .32rem .6rem; font-size: .78rem; border-radius: 6px; }
.btn-perigo { background: var(--danger); }
.btn-perigo:hover { background: #b91c1c; }
.btn-link { background: none; color: var(--muted); padding: 0; border: none; font-weight: 500; }
.btn-link:hover { color: var(--text); background: none; box-shadow: none; }
.acoes-form { margin-top: 1.2rem; display: flex; gap: .6rem; align-items: center; }
.inline-form { display: inline; }
.pill-list { display: flex; flex-wrap: wrap; gap: .5rem; }

/* ---------------- Selos / status ---------------- */
.selo { display: inline-block; font-size: .72rem; font-weight: 600; text-transform: capitalize; padding: .2rem .6rem; border-radius: 20px; background: #eef1f6; color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.selo-confirmada, .selo-inscricoes_abertas, .selo-aprovado, .selo-finalizada { background: var(--success-b); color: #166534; border-color: #bbf7d0; }
.selo-pendente, .selo-rascunho, .selo-aguardando { background: var(--warn-b); color: var(--warn); border-color: #fde68a; }
.selo-cancelada, .selo-reprovado { background: var(--danger-b); color: #991b1b; border-color: #fecaca; }
.selo-em_andamento, .selo-pronta, .selo-inscricoes_encerradas { background: var(--info-b); color: #1e40af; border-color: #bfdbfe; }

/* ---------------- Faixa ---------------- */
.faixa-chip { display: inline-flex; align-items: center; gap: .4rem; }
.faixa-cor { width: 14px; height: 14px; border-radius: 3px; border: 1px solid rgba(0,0,0,.25); display: inline-block; }

/* ============================================================
   Chaveamento
   ============================================================ */
.chave { display: flex; gap: 2.2rem; overflow-x: auto; padding: 1rem .2rem 1.5rem; align-items: stretch; }
.fase-col { display: flex; flex-direction: column; justify-content: space-around; min-width: 230px; gap: 1rem; }
.fase-titulo { font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--primary); text-align: center; border-bottom: 2px solid var(--border); padding-bottom: .3rem; margin-bottom: .4rem; font-size: .85rem; }
.luta-card { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--muted); border-radius: 8px; box-shadow: var(--shadow); overflow: hidden; }
.luta-card.pronta { border-left-color: var(--ouro); }
.luta-card.finalizada { border-left-color: var(--success); }
.luta-card .luta-cab { display: flex; justify-content: space-between; align-items: center; background: #f7f9fc; padding: .25rem .6rem; font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }
.competidor { display: flex; justify-content: space-between; align-items: center; padding: .45rem .6rem; border-bottom: 1px dashed var(--border); font-size: .88rem; }
.competidor:last-child { border-bottom: none; }
.competidor .nome { font-weight: 500; }
.competidor .aca { color: var(--muted); font-size: .76rem; }
.competidor.vencedor { background: var(--success-b); }
.competidor.vencedor .nome { color: #166534; font-weight: 700; }
.competidor.vencedor .nome::after { content: ' ✓'; color: var(--success); }
.competidor.vago { color: var(--muted); font-style: italic; }
.campeao-faixa { background: linear-gradient(135deg, var(--navy), var(--navy-3)); color: #fff; border-left: 4px solid var(--ouro); padding: 1rem 1.2rem; border-radius: 10px; margin: 1rem 0; display: flex; align-items: center; gap: .8rem; }
.campeao-faixa .kanji-min { color: var(--ouro); font-size: 1.6rem; font-family: 'Oswald'; }
.campeao-faixa strong { font-size: 1.25rem; color: #fff; }

/* ---------------- Login / públicas ---------------- */
.login-wrap { max-width: 400px; margin: 5rem auto; padding: 0 1rem; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-top: 4px solid var(--primary); border-radius: 12px; padding: 2.2rem 2rem; box-shadow: 0 10px 30px rgba(16,26,46,.12); text-align: center; }
.login-card .logo-img { height: 92px; width: 92px; border-radius: 50%; background: #fff; object-fit: contain; margin-bottom: .5rem; }
.login-card .kanji { font-family: 'Oswald'; font-size: 2.4rem; color: var(--primary); }
.login-card h1 { font-size: 1.15rem; margin-top: .4rem; }
.login-card form { text-align: left; margin-top: 1.2rem; }

/* topo simples (inscrição pública) */
.topo { background: var(--navy); color: #fff; border-bottom: 3px solid var(--primary); }
.topo-inner { max-width: 1180px; margin: 0 auto; padding: .7rem 1.2rem; display: flex; align-items: center; gap: 1rem; }
.topo .marca { display: flex; align-items: center; gap: .7rem; color: #fff; }
.topo .logo-img { height: 42px; width: 42px; border-radius: 50%; background: #fff; object-fit: contain; }
.topo .kanji { font-family: 'Oswald'; color: var(--ouro); font-size: 1.6rem; }
.marca-txt { display: flex; flex-direction: column; line-height: 1.1; }
.marca-txt strong { font-size: 1rem; }
.marca-txt small { color: #9fb2d4; font-size: .68rem; letter-spacing: 1.5px; text-transform: uppercase; }
.conteudo { max-width: 720px; margin: 0 auto; padding: 1.6rem 1.2rem 3rem; }

/* ---------------- Misc ---------------- */
.muted { color: var(--muted); }
.vazio { color: var(--muted); font-style: italic; padding: 1.2rem; text-align: center; background: var(--surface); border: 1px dashed var(--border); border-radius: 10px; }
.copia-link { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.copia-link input { flex: 1; min-width: 240px; padding: .5rem .6rem; border: 1px solid #cfd8e6; border-radius: 7px; background: #f7f9fc; font-family: monospace; font-size: .82rem; }

/* ---------------- Rodapé ---------------- */
.rodape { border-top: 1px solid var(--border); background: var(--surface); }
.rodape-inner { max-width: 1180px; margin: 0 auto; padding: .9rem 1.2rem; display: flex; align-items: center; gap: .7rem; font-size: .8rem; color: var(--muted); }
.kanji-min { color: var(--primary); font-family: 'Oswald'; font-size: 1.1rem; }
.app-footer { margin-left: var(--sb-w); transition: margin .2s ease; }
body.nav-closed .app-footer { margin-left: 0; }
@media (max-width: 992px) { .app-footer { margin-left: 0; } }

/* ---------------- Relatórios / filtros ---------------- */
.filtros { display: flex; flex-wrap: wrap; gap: .8rem; align-items: flex-end; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 1rem 1.2rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.filtros .campo { margin: 0; min-width: 160px; }
.relatorio-cabecalho { display: none; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
tfoot td { font-weight: 700; background: #f7f9fc; }

/* ---------------- Impressão (Salvar como PDF) ---------------- */
@media print {
    @page { margin: 14mm; }
    body { background: #fff; }
    .navbar, .sidebar, .sb-overlay, .app-footer, .no-print, .cabecalho-pagina .btn, .filtros { display: none !important; }
    .app-main { margin: 0 !important; padding: 0 !important; }
    .relatorio-cabecalho { display: flex !important; align-items: center; gap: .8rem; border-bottom: 2px solid #16233e; padding-bottom: .6rem; margin-bottom: 1rem; }
    .relatorio-cabecalho img { height: 54px; }
    .box, table.lista { box-shadow: none !important; border: 1px solid #ccc !important; }
    table.lista th { background: #eef1f6 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    a[href]::after { content: ''; }
}
