:root {
  --sidebar-w: 240px;
  --sidebar-w-collapsed: 64px;
  --brand: #1f6feb;
  --ink: #1c2333;
  --muted: #6b7280;
  --bg: #f4f6fb;
}

* { box-sizing: border-box; }
body { background: var(--bg); color: var(--ink); }

/* ---------- Login ---------- */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1f6feb 0%, #143a7b 100%); padding: 1rem;
}
.login-card { background: #fff; border-radius: 14px; padding: 2rem; width: 100%; max-width: 380px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.login-brand { text-align: center; margin-bottom: 1.5rem; }
.login-brand i { font-size: 2.4rem; color: var(--brand); }
.login-brand img { width: 64px; height: 64px; border-radius: 14px; box-shadow: 0 6px 18px rgba(31,111,235,.28); }
.login-brand h1 { font-size: 1.4rem; margin: .4rem 0 0; }
/* mensagens de erro/sucesso nas telas de autenticacao — bem destacadas */
.login-page .alert { border-left-width: 4px; }
.login-page .alert-danger { border-left-color: #dc3545; font-weight: 500; }

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); background: #0f1b33; color: #cdd6e4; flex-shrink: 0;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; transition: width .18s ease;
}
.sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
.sidebar-collapsed .brand-text,
.sidebar-collapsed .nav-text { display: none; }

.sidebar-brand { display: flex; align-items: center; gap: .6rem; padding: 1rem 1.1rem; font-weight: 700; color: #fff; font-size: 1.05rem; }
.sidebar-brand i { font-size: 1.3rem; color: #6ea8fe; }
.sidebar-brand .brand-logo { width: 28px; height: 28px; border-radius: 7px; flex-shrink: 0; }
.sidebar-collapsed .sidebar-brand { justify-content: center; padding-left: 0; padding-right: 0; }
.sidebar-nav { padding: .5rem 0 2rem; }
.sidebar-nav .nav-link { display: flex; align-items: center; gap: .75rem; padding: .6rem 1.1rem; color: #cdd6e4; text-decoration: none; font-size: .92rem; border-left: 3px solid transparent; }
.sidebar-nav .nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-nav .nav-link.active { background: rgba(110,168,254,.15); color: #fff; border-left-color: #6ea8fe; }
.sidebar-nav .nav-link i { font-size: 1.05rem; width: 1.2rem; text-align: center; }
.nav-group-label { padding: 1rem 1.1rem .3rem; font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; color: #7c89a3; }

/* grupos recolhiveis do menu lateral */
.nav-group-toggle {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  padding: .9rem 1.1rem .35rem; background: none; border: 0; cursor: pointer;
  font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; color: #7c89a3;
}
.nav-group-toggle:hover { color: #cdd6e4; }
.nav-caret { font-size: .8rem; transition: transform .15s ease; }
.nav-group.collapsed .nav-caret { transform: rotate(-90deg); }
.nav-group.collapsed .nav-group-items { display: none; }
/* na barra recolhida (so icones) os itens ficam sempre visiveis */
.sidebar-collapsed .nav-group-toggle { justify-content: center; padding: .6rem 0 .2rem; }
.sidebar-collapsed .nav-caret { display: none; }
.sidebar-collapsed .nav-group.collapsed .nav-group-items { display: block; }

.content { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 100vh; }
.topbar {
  display: flex; align-items: center; gap: 1rem; padding: .6rem 1.2rem; background: #fff;
  border-bottom: 1px solid #e5e7eb; position: sticky; top: 0; z-index: 20;
}
.topbar-title { font-weight: 600; }
.topbar-search { flex: 1; max-width: 460px; display: flex; align-items: center; gap: .5rem; background: var(--bg); border: 1px solid #e5e7eb; border-radius: 8px; padding: .3rem .6rem; }
.topbar-search i { color: var(--muted); }
.topbar-search input { border: 0; background: transparent; outline: none; width: 100%; font-size: .9rem; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 1rem; }
.topbar-icon { color: var(--muted); font-size: 1.15rem; text-decoration: none; }
.topbar-icon:hover { color: var(--brand); }
.notif-badge { position: absolute; top: -6px; right: -8px; background: #dc3545; color: #fff; font-size: .65rem; font-weight: 700; line-height: 1; padding: .15rem .3rem; border-radius: 999px; }
/* ocupa toda a largura restante e cresce para preencher a altura da tela */
.main { flex: 1 1 auto; min-width: 0; min-height: 0; width: 100%; padding: 1.4rem 1.4rem 3rem; overflow-x: hidden; }
.main .row { --bs-gutter-x: 1rem; }
.main [class^="col"], .main [class*=" col"] { min-width: 0; }   /* deixa colunas encolherem */

/* ---------- Cards ---------- */
.card { border: 1px solid #e5e7eb; border-radius: 10px; max-width: 100%; }
.card-body { min-width: 0; }                       /* permite o conteudo encolher em vez de empurrar */
.card-body > * { max-width: 100%; }
.card-body pre, .card-body dd { overflow-wrap: anywhere; }
.card .table-responsive { overflow-x: auto; }      /* qualquer tabela larga rola dentro do card */

/* graficos: preenchem uma caixa de altura fixa (maintainAspectRatio:false no JS) */
.chart-box { position: relative; width: 100%; height: 260px; }
.chart-box > canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; }
@media (max-width: 575.98px) { .chart-box { height: 220px; } }
.stat-card { color: inherit; transition: transform .1s ease, box-shadow .1s ease; }
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(31,111,235,.12); }
.stat-icon { width: 48px; height: 48px; border-radius: 10px; display: grid; place-items: center; background: rgba(31,111,235,.1); color: var(--brand); font-size: 1.3rem; }
.stat-value { font-size: 1.5rem; font-weight: 700; line-height: 1; }
.stat-label { color: var(--muted); font-size: .85rem; }

/* faixa de indicadores rapidos: todos os cards numa unica linha, encolhendo para caber */
.stat-strip { display: flex; flex-wrap: wrap; gap: .5rem; }
.stat-strip .stat-card { flex: 1 1 0; min-width: 0; }
.stat-strip .stat-icon { width: 34px; height: 34px; font-size: .95rem; flex: none; border-radius: 8px; }
.stat-strip .stat-text { min-width: 0; }
.stat-strip .stat-value { font-size: 1.1rem; white-space: nowrap; }
.stat-strip .stat-label { font-size: .72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 991.98px) { .stat-strip .stat-card { flex-basis: 30%; } }
@media (max-width: 575.98px)  { .stat-strip .stat-card { flex-basis: 45%; } }

/* Indicadores compactos, todos numa linha (mesmo padrao da faixa acima) */
.metric-strip { display: flex; flex-wrap: wrap; gap: .5rem; }
.metric-strip .metric-tile { flex: 1 1 0; min-width: 0; }
.metric-strip .metric-value { font-weight: 700; font-size: 1rem; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.metric-strip .metric-label { color: var(--muted); font-size: .72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 575.98px) { .metric-strip .metric-tile { flex-basis: 45%; } }
.stat-card.stat-warning .stat-icon { background: rgba(255,193,7,.15); color: #b58100; }
.stat-card.stat-danger .stat-icon { background: rgba(220,53,69,.12); color: #c02535; }

/* ---------- Kanban ---------- */
.kanban-board { display: flex; gap: .75rem; overflow-x: auto; padding-bottom: 1rem; align-items: flex-start; }
.kanban-col { flex: 0 0 260px; background: #eef1f6; border-radius: 10px; }
.kanban-col-head { display: flex; justify-content: space-between; align-items: center; padding: .5rem .6rem; border-bottom: 3px solid #ccc; }
.kanban-cards { min-height: 60px; padding: .5rem; display: flex; flex-direction: column; gap: .5rem; }
.kanban-card {
  position: relative; background: #fff; border: 1px solid #e1e5ec; border-radius: 8px;
  padding: .55rem .6rem; cursor: grab; box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.kanban-card:active { cursor: grabbing; }
.kanban-card a.stretched-link { z-index: 1; }
.kanban-card .badge { position: relative; z-index: 2; }
.kanban-ghost { opacity: .4; }

.table thead th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.table thead th a { color: inherit; text-decoration: none; }
.table thead th a:hover { color: var(--brand); }

@media (max-width: 768px) {
  .sidebar { position: fixed; z-index: 40; transform: translateX(-100%); transition: transform .2s ease; }
  .sidebar-collapsed .sidebar { transform: translateX(0); width: var(--sidebar-w); }
  .sidebar-collapsed .brand-text, .sidebar-collapsed .nav-text { display: inline; }
}
