/* Minimalista, responsivo, sem frescura. */
:root{
  --bg:#0b0d0c;
  --card:#121412;
  --muted:#B2BDA0;
  --text:#EBEFE3;
  --accent:#526534;
  --accent2:#2F3B1C;
  --border:#2F3B1C;
  --danger:#b91c1c;
  --warn:#a16207;
  --ok:#15803d;
}

*{box-sizing:border-box}
html,body{
  margin:0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  color:var(--text);
}


.topbar{
  position:sticky; top:0; z-index:50;
  display:flex; gap:14px; justify-content:space-between; align-items:center;
  padding:14px 16px;
  border-bottom:1px solid var(--border);
  background: rgba(11,15,17,.82);
  backdrop-filter: blur(8px);
}

.brand{display:flex; gap:12px; align-items:center; min-width: 240px;}
.logo{width:40px; height:40px}
.title{font-weight:800; letter-spacing:.2px}
.subtitle{color:var(--muted); font-size:12px}

.actions{display:flex; gap:10px; align-items:center; flex-wrap:wrap}

.container{max-width:1100px; margin:0 auto; padding:18px 16px 26px}

.panel{
  background: rgba(18,24,27,.85);
  border:1px solid var(--border);
  border-radius:16px;
  padding:14px;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
}

.panel-row{display:flex; gap:12px; align-items:end; flex-wrap:wrap}
.field{display:flex; flex-direction:column; gap:6px; min-width:160px}
.field.grow{flex:1; min-width:240px}
label{font-size:12px; color:var(--muted)}
input,select{
  background:#0d1316;
  color:var(--text);
  border:1px solid var(--border);
  border-radius:12px;
  padding:10px 10px;
  outline:none;
}
input:focus,select:focus{border-color: rgba(15,118,110,.7)}

.hint{color:var(--muted); font-size:12px}
code{background:#0d1316; padding:2px 6px; border-radius:8px; border:1px solid var(--border)}

.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  text-align:center;
  background: linear-gradient(180deg, rgba(82,101,52,.95), rgba(47,59,28,.95));
  border:1px solid rgba(82,101,52,.55);
  color:var(--text);
  padding:10px 12px;
  border-radius:12px;
  cursor:pointer;
  font-weight:700;
}
.btn:hover{filter:brightness(1.05)}
.btn:active{transform: translateY(1px)}
.btn-ghost{
  background:#0d1316;
  border:1px solid var(--border);
  color:var(--text);
}
.spacer{flex:1}
.status{color:var(--muted); font-size:12px}

.grid{display:grid; gap:12px; margin-top:14px}
.kpis{grid-template-columns: repeat(4, minmax(0, 1fr));}
.two{grid-template-columns: repeat(2, minmax(0, 1fr));}

@media (max-width: 900px){
  .kpis{grid-template-columns: repeat(2, minmax(0, 1fr));}
  .two{grid-template-columns: 1fr;}
}

.card{
  background: rgba(18,24,27,.9);
  border:1px solid var(--border);
  border-radius:16px;
  padding:14px;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
  position:relative;
}
.card-label{color:var(--muted); font-size:12px}
.card-value{font-size:28px; font-weight:900; margin-top:6px}
.badge{
  position:absolute; top:12px; right:12px;
  padding:6px 10px;
  border-radius:999px;
  border:1px solid var(--border);
  font-size:12px;
  color:var(--text);
  background:#0d1316;
}
.badge.ok{border-color: rgba(21,128,61,.6)}
.badge.warn{border-color: rgba(161,98,7,.7)}
.badge.bad{border-color: rgba(185,28,28,.7)}

.card-header{display:flex; justify-content:space-between; gap:12px; align-items:flex-start}
.card-title{font-weight:800}
.card-sub{color:var(--muted); font-size:12px; margin-top:2px}

.table-wrap{overflow:auto; border-radius:14px; border:1px solid var(--border)}
.table{width:100%; border-collapse:collapse; min-width:780px; background:#0d1316}
.table th,.table td{
  padding:10px 10px; border-bottom:1px solid var(--border); text-align:left; font-size:13px;
}
.table th{color:var(--muted); font-weight:700; position:sticky; top:0; background:#0d1316}
.table tr:hover td{background: rgba(15,118,110,.08)}

.list{display:flex; flex-direction:column; gap:10px; margin-top:10px}
.item{
  display:flex; justify-content:space-between; gap:10px; align-items:center;
  padding:10px; border:1px solid var(--border); border-radius:14px; background:#0d1316;
}
.item strong{display:block}
.item small{color:var(--muted)}
.footer{
  padding:18px 16px;
  border-top:1px solid var(--border);
  color:var(--muted);
  text-align:center;
}


@media print{
  .topbar, .panel, .actions, #btnReload, #btnToggleDetails, #btnExport, #btnPrint { display:none !important; }
  body{ background:#fff !important; color:#000 !important; }
  .card, .panel{ box-shadow:none !important; background:#fff !important; border:1px solid #ddd !important; }
  .badge{ border:1px solid #ddd !important; background:#fff !important; }
  .table{ background:#fff !important; }
  .table th{ position:static !important; }
}


/* Mobile header fix */
@media (max-width: 600px){
  .topbar{
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .brand{
    min-width: 0;
    width: 100%;
  }
  .actions{
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .actions .btn, .actions a.btn{
    width: 100%;
    text-align: center;
  }
}


a{ color: var(--text); text-decoration: none; }
a:hover{ text-decoration: none; }


.btn-full{ width:100%; }


/* Cadastro overflow fix */
#dataTable{ min-width: 0 !important; }
#dataTable td, #dataTable th{ max-width: 220px; }
@media (max-width: 600px){
  #dataTable td, #dataTable th{ max-width: 160px; }
}


/* Cadastro (Novo aluno/turma) — evitar vazamento no mobile */
#formsGrid .panel-row{ flex-wrap: wrap; }
#formsGrid .field{ min-width: 0; flex: 1 1 160px; }
#formsGrid input, #formsGrid select{ width: 100%; max-width: 100%; }
#alunoFormCard, #turmaFormCard{ overflow: hidden; }

@media (max-width: 600px){
  #formsGrid .field{ flex-basis: 100%; }
}


.table.mini{ min-width: 0; }
.table.mini th, .table.mini td{ font-size: 13px; }

/* Overflow guard (mobile) */
@media (max-width: 600px){
  .table{ min-width: 0 !important; }
  .table-wrap{ overflow-x: auto; }
}


/* Buttons that should occupy the full row inside the header actions grid */
@media (max-width: 600px){
  .actions .span-2{ grid-column: 1 / -1; width:100%; }
}
