/* =========================================================
   LicitaControl - Estilos gerais
   ========================================================= */

:root {
    --navy: #0e1b3d;
    --navy-dark: #0a1430;
    --navy-light: #16295c;
    --blue: #2563eb;
    --blue-dark: #1d4ed8;
    --green: #16a34a;
    --orange: #f59e0b;
    --red: #ef4444;
    --purple: #7c3aed;
    --teal: #0d9488;
    --bg: #f4f6fb;
    --card: #ffffff;
    --border: #e5e9f2;
    --text: #1f2937;
    --text-muted: #6b7280;
    --radius: 12px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
}

a { color: inherit; text-decoration: none; }

.icon { width: 18px; height: 18px; display: inline-block; vertical-align: middle; }
.icon-lg { width: 24px; height: 24px; }
.icon-sm { width: 14px; height: 14px; }

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

.sidebar {
    width: 224px;
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--navy) 0%, var(--navy-dark) 100%);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    transition: width .18s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px 14px;
    color: #fff;
    font-size: 18px;
    font-weight: 700;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand .brand-accent { color: #4f8dff; }
.sidebar-brand .brand-logo { display: flex; flex-shrink: 0; }
.brand-logo-chip {
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
    width: 30px; height: 30px; border-radius: 8px; background: #fff; padding: 4px;
}
.brand-logo-chip img { width: 100%; height: 100%; object-fit: contain; }
body.sidebar-collapsed .brand-logo-chip { margin: 0 auto; }

.sidebar-toggle {
    margin-left: auto;
    flex-shrink: 0;
    background: transparent;
    border: none;
    color: #9fb0d9;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    border-radius: 6px;
}
.sidebar-toggle:hover { background: rgba(255,255,255,.1); color: #fff; }
.sidebar-toggle .icon { width: 15px; height: 15px; transition: transform .18s ease; }

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 8px 8px;
    /* Rolagem discreta: fina e na cor do próprio menu, só aparece quando
       tem conteúdo suficiente para rolar (Segurança/E-mail, Integrações
       etc. adicionaram mais itens à barra lateral). */
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.16) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 5px; height: 5px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,.16);
    border-radius: 10px;
}
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.28); }
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 7px 10px;
    margin-bottom: 1px;
    border-radius: 8px;
    color: #b9c3dc;
    font-size: 13.5px;
    font-weight: 500;
    transition: background .15s, color .15s;
}
.sidebar-nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-nav a.active { background: var(--blue); color: #fff; }
.sidebar-nav a .icon { width: 17px; height: 17px; flex-shrink: 0; }
.sidebar-nav .nav-badge {
    margin-left: auto;
    background: var(--red);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 10px;
}

.nav-submenu-wrap { margin-bottom: 1px; }
.nav-submenu-toggle {
    display: flex;
    align-items: center;
    width: 100%;
    gap: 11px;
    padding: 7px 10px;
    border: none;
    background: transparent;
    border-radius: 8px;
    color: #b9c3dc;
    font-size: 13.5px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: background .15s, color .15s;
}
.nav-submenu-toggle:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-submenu-toggle .icon { width: 17px; height: 17px; flex-shrink: 0; }
.nav-submenu-chevron { margin-left: auto; display: flex; }
.nav-submenu-chevron .icon { width: 14px; height: 14px; transition: transform .18s ease; }
.nav-submenu-wrap.open .nav-submenu-chevron .icon { transform: rotate(180deg); }
.nav-submenu-items {
    display: none;
    flex-direction: column;
    padding-left: 20px;
    border-left: 1px solid rgba(255,255,255,.08);
    margin-left: 21px;
}
.nav-submenu-wrap.open .nav-submenu-items { display: flex; }
.nav-submenu-items a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    margin-bottom: 1px;
    border-radius: 8px;
    color: #b9c3dc;
    font-size: 13px;
    font-weight: 500;
    transition: background .15s, color .15s;
}
.nav-submenu-items a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-submenu-items a.active { background: var(--blue); color: #fff; }
.nav-submenu-items a .icon { width: 15px; height: 15px; flex-shrink: 0; }

.sidebar-footer {
    padding: 12px 14px;
    border-top: 1px solid rgba(255,255,255,.08);
    font-size: 12.5px;
}
.sidebar-footer .org-name { color: #fff; font-weight: 600; display:flex; align-items:center; gap:8px; }
.sidebar-footer .org-meta { color: #8b96b8; margin-top: 2px; }
.sidebar-footer select {
    width: 100%;
    margin-top: 8px;
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.15);
    color: #fff;
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 12.5px;
}
/* A lista de opções do <select> é renderizada pelo navegador com fundo
   branco, mesmo quando o <select> fechado tem fundo escuro. Sem esta
   regra, o texto (branco, herdado do select) fica branco sobre fundo
   branco e só aparece quando o mouse passa por cima (destaque do
   navegador). Aqui forçamos texto escuro sobre fundo claro nas opções,
   para o texto ficar sempre visível. */
.sidebar-footer select option {
    color: #1a1a2e;
    background: #fff;
}

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

.topbar {
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 10px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 20;
}
.topbar .search-box {
    flex: 1;
    max-width: 280px;
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 7px;
    padding: 6px 10px;
    color: var(--text-muted);
}
.topbar .search-box .icon { width: 15px; height: 15px; flex-shrink: 0; }
.topbar .search-box input {
    border: none;
    background: transparent;
    outline: none;
    flex: 1;
    min-width: 0;
    font-size: 13px;
}
.topbar-icons { display: flex; align-items: center; gap: 18px; margin-left: auto; }
.topbar-icons .icon-btn {
    position: relative;
    color: #6b7280;
    cursor: pointer;
}
.topbar-icons .icon-btn .dot {
    position: absolute;
    top: -6px; right: -8px;
    background: var(--red);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 10px;
    line-height: 1.3;
}
.user-chip { display: flex; align-items: center; gap: 10px; cursor: pointer; position: relative; }
.user-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--navy); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 14px;
}
.user-chip .user-name { font-weight: 600; }
.user-menu {
    display: none;
    position: absolute;
    right: 0; top: 46px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,.12);
    min-width: 200px;
    z-index: 30;
    overflow: hidden;
}
.user-chip.open .user-menu { display: block; }
.user-menu a { display: flex; gap: 10px; align-items:center; padding: 11px 16px; font-size: 13.5px; color: var(--text); }
.user-menu a:hover { background: var(--bg); }

.content { padding: 26px; flex: 1; }

/* ---------- Menu lateral fixado (modo compacto, só ícones) ---------- */
body.sidebar-collapsed .sidebar { width: 64px; }
body.sidebar-collapsed .sidebar-brand { justify-content: center; padding: 16px 6px; gap: 0; }
body.sidebar-collapsed .sidebar-brand .brand-text { display: none; }
body.sidebar-collapsed .sidebar-toggle { margin-left: 0; }
body.sidebar-collapsed .sidebar-toggle .icon { transform: rotate(180deg); }
body.sidebar-collapsed .sidebar-nav a { justify-content: center; padding: 9px 0; gap: 0; }
body.sidebar-collapsed .sidebar-nav a span { display: none; }
body.sidebar-collapsed .nav-submenu-toggle { justify-content: center; padding: 9px 0; gap: 0; }
body.sidebar-collapsed .nav-submenu-toggle span { display: none; }
body.sidebar-collapsed .nav-submenu-chevron { display: none; }
body.sidebar-collapsed .nav-submenu-items {
    display: none !important;
    position: absolute;
    left: 64px;
    margin-left: 0;
    padding-left: 8px;
    border-left: none;
    background: var(--navy-light);
    border-radius: 8px;
    min-width: 180px;
    box-shadow: 0 8px 24px rgba(0,0,0,.25);
    z-index: 30;
}
body.sidebar-collapsed .nav-submenu-wrap { position: relative; }
body.sidebar-collapsed .nav-submenu-wrap:hover .nav-submenu-items { display: flex !important; }
body.sidebar-collapsed .nav-submenu-items a span { display: inline; }
body.sidebar-collapsed .sidebar-footer { padding: 12px 6px; text-align: center; }
body.sidebar-collapsed .sidebar-footer .org-name { justify-content: center; }
body.sidebar-collapsed .sidebar-footer .org-name span,
body.sidebar-collapsed .sidebar-footer .org-meta,
body.sidebar-collapsed .sidebar-footer form { display: none; }

.page-header { margin-bottom: 22px; display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 12px; }
.page-header h1 { margin: 0 0 4px; font-size: 26px; font-weight: 700; color: #111827; }
.page-header p { margin: 0; color: var(--text-muted); }
.breadcrumb { font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }
.breadcrumb a { color: var(--blue); }

/* ---------- Cards ---------- */
.card {
    background: var(--card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 20px;
}
.card + .card { margin-top: 20px; }
/* Dentro das grades lado a lado (three-col/two-col/two-col-even), os cards
   são "irmãos" no sentido do CSS mas ficam em COLUNAS, não empilhados - a
   regra acima (pensada para cards um embaixo do outro) não deve valer aqui,
   senão o 2º/3º card ganham uma margem no topo e a grade (que já estica
   todos para a mesma altura) faz esses cards ficarem mais baixos que o 1º. */
.three-col > .card + .card,
.two-col > .card + .card,
.two-col-even > .card + .card { margin-top: 0; }

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 18px;
    margin-bottom: 20px;
}
@media (max-width: 1100px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .kpi-grid { grid-template-columns: 1fr; } }
.kpi-grid.kpi-grid-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 900px) { .kpi-grid.kpi-grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .kpi-grid.kpi-grid-3 { grid-template-columns: 1fr; } }

.kpi-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    display: flex;
    gap: 14px;
    align-items: flex-start;
}
.kpi-icon {
    width: 48px; height: 48px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    color: #fff; flex-shrink: 0;
}
.kpi-icon.blue { background: var(--blue); }
.kpi-icon.green { background: var(--green); }
.kpi-icon.orange { background: var(--orange); }
.kpi-icon.red { background: var(--red); }
.kpi-icon.purple { background: var(--purple); }
.kpi-icon.teal { background: var(--teal); }
.kpi-body .kpi-label { font-size: 13px; color: var(--text-muted); margin-bottom: 4px; }
.kpi-body .kpi-value { font-size: 22px; font-weight: 700; color: #111827; line-height: 1.2; }
.kpi-body .kpi-sub { font-size: 12.5px; color: var(--text-muted); margin-top: 3px; }

.two-col { display: grid; grid-template-columns: 1fr 1.4fr; gap: 20px; align-items: stretch; }
.two-col > .card { display: flex; flex-direction: column; min-width: 0; }
@media (max-width: 950px) { .two-col { grid-template-columns: 1fr; } }

.two-col-even { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: stretch; }
.two-col-even > .card { display: flex; flex-direction: column; min-width: 0; }
@media (max-width: 950px) { .two-col-even { grid-template-columns: 1fr; } }

.card-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-title h3 { margin: 0; font-size: 16.5px; font-weight: 700; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    border-radius: 8px;
    border: 1px solid transparent;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    background: #fff;
    color: var(--text);
}
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-outline { background: #fff; border-color: var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); }
.btn-danger { background: var(--red); color: #fff; }
.btn-success { background: var(--green); color: #fff; }
.btn-sm { padding: 6px 10px; font-size: 12.5px; }
.btn-icon { padding: 7px; border-radius: 7px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
@media (max-width: 900px) { .form-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } }
.form-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.form-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 700px) { .form-grid.cols-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 420px) { .form-grid.cols-4 { grid-template-columns: 1fr; } }

.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 4px; }
.form-group label { font-size: 13.5px; font-weight: 600; color: #374151; }
.form-group label .req { color: var(--red); }
.form-group .hint { font-size: 12px; color: var(--text-muted); }

/* Campo bloqueado para digitação manual (ex: dados que só mudam por uma
   consulta de CNPJ) - mesmo visual de .readonly-value, aplicado direto no
   input/textarea original para não precisar duplicar HTML. */
input[readonly], textarea[readonly] { background: #f3f4f6; color: #4b5563; cursor: default; }

.permissoes-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 16px;
}
@media (max-width: 700px) { .permissoes-grid { grid-template-columns: 1fr 1fr; } }
.permissao-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
}
.permissao-item input[type="checkbox"] { width: 15px; height: 15px; flex-shrink: 0; accent-color: var(--blue); cursor: pointer; }

input[type=text], input[type=password], input[type=email], input[type=number],
input[type=date], input[type=tel], select, textarea {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    color: var(--text);
    width: 100%;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
textarea { resize: vertical; min-height: 80px; }

.section-title {
    display: flex; align-items: center; gap: 8px;
    font-size: 15px; font-weight: 700; color: #111827;
    padding-bottom: 10px; margin-bottom: 18px;
    border-bottom: 1px solid var(--border);
}

.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); }

/* ---------- Grade de informações com ícone (ex.: Dados do Contrato) ---------- */
.section-title-lg { font-size: 19px; padding-bottom: 14px; margin-bottom: 6px; }
.info-card-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 36px; }
@media (max-width: 800px) { .info-card-grid { grid-template-columns: 1fr; } }
.info-col { display: flex; flex-direction: column; }
.info-item { display: flex; gap: 14px; align-items: flex-start; padding: 13px 0; border-bottom: 1px solid var(--border); }
.info-item.no-border { border-bottom: none; }
.info-item-block { padding-top: 16px; margin-top: 2px; border-top: 1px solid var(--border); }
/* Duas informações lado a lado ocupando uma única "linha" da lista (ex.:
   Data de Assinatura + Vigência) - a borda/respiro fica no par inteiro, e
   cada .info-item interno perde a própria borda/padding para não duplicar. */
.info-pair { display: flex; gap: 20px; padding: 13px 0; border-bottom: 1px solid var(--border); }
.info-pair > .info-item { flex: 1; padding: 0; border-bottom: none; min-width: 0; }
.info-icon {
    width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0;
    background: #eaf1fd; color: var(--blue);
    display: flex; align-items: center; justify-content: center;
}
.info-icon .icon { width: 18px; height: 18px; }
.info-body { min-width: 0; }
.info-label { font-size: 11px; color: var(--text-muted); margin-bottom: 3px; }
.info-value { font-size: 13px; font-weight: 700; color: #111827; line-height: 1.35; word-break: break-word; }
.info-value.text-block { font-weight: 500; white-space: pre-line; }

/* ---------- Checkbox empilhado (ex.: Tipo de Aditivo com múltipla escolha) ---------- */
.checkbox-stack { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.checkbox-stack label { display: flex; align-items: center; gap: 9px; font-size: 14px; font-weight: 500; color: var(--text); cursor: pointer; }
.checkbox-stack input[type="checkbox"] { width: 16px; height: 16px; flex-shrink: 0; accent-color: var(--blue); cursor: pointer; }

/* ---------- Painel condicional dentro de formulário (aparece conforme a escolha) ---------- */
.subform-panel { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px; margin-top: 18px; }

/* ---------- Valor calculado/somente leitura dentro de formulário ---------- */
.readonly-value {
    padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
    background: #f3f4f6; color: #111827; font-size: 14px; font-weight: 600;
}

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 22px; }
.tabs a { padding: 12px 18px; font-weight: 600; color: var(--text-muted); border-bottom: 2px solid transparent; }
.tabs a.active { color: var(--blue); border-color: var(--blue); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data-table th {
    text-align: left; padding: 12px 14px; color: var(--text-muted);
    font-weight: 600; border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.data-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data-table tr:last-child td { border-bottom: none; }
table.data-table tr:hover td { background: #fafbfd; }
table.data-table tfoot td { font-weight: 700; background: #fafbfd; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.actions-cell { display: flex; gap: 6px; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 700; }
.badge-ok, .badge-pago, .badge-ativo, .badge-homologada { background: #dcfce7; color: #15803d; }
.badge-atencao, .badge-pendente { background: #fef3c7; color: #b45309; }
.badge-critico, .badge-cancelado, .badge-encerrado, .badge-inativo { background: #fee2e2; color: #b91c1c; }
.badge-info, .badge-andamento { background: #dbeafe; color: #1d4ed8; }
.badge-neutro { background: #e5e7eb; color: #374151; }

.empty-state { text-align: center; padding: 50px 20px; color: var(--text-muted); }
.empty-state .icon { width: 44px; height: 44px; margin-bottom: 12px; color: #cbd5e1; }

/* ---------- Alerts / flash ---------- */
.alert { padding: 13px 16px; border-radius: 10px; margin-bottom: 16px; font-size: 13.5px; font-weight: 500; display:flex; align-items:center; gap:10px;}
.alert-success { background: #dcfce7; color: #15803d; }
.alert-danger { background: #fee2e2; color: #b91c1c; }
.alert-info { background: #dbeafe; color: #1d4ed8; }
.alert-warning { background: #fef3c7; color: #b45309; }

.helper-box { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; padding: 12px 16px; border-radius: 10px; font-size: 13px; display: flex; gap: 10px; align-items: center; }

/* ---------- Login page ---------- */
.login-wrap {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--navy) 0%, #16295c 60%, var(--blue) 130%);
    padding: 20px;
}
.login-card {
    background: #fff; border-radius: 16px; padding: 40px 36px; width: 100%; max-width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.login-card .brand { text-align: center; margin-bottom: 8px; font-size: 24px; font-weight: 800; color: var(--navy); }
.login-card .brand .brand-accent { color: var(--blue); }
.login-card .subtitle { text-align: center; color: var(--text-muted); margin-bottom: 28px; font-size: 13.5px; }
.login-card .btn-primary { width: 100%; justify-content: center; padding: 11px; margin-top: 6px; }
.login-footer { text-align: center; margin-top: 22px; font-size: 12px; color: rgba(255,255,255,.75); }
.login-card-logo { display: flex; justify-content: center; margin-bottom: 14px; }
.login-card-logo img { width: 52px; height: 52px; object-fit: contain; }

/* ---------- Login split-screen (login.php) ---------- */
.auth-page { min-height: 100vh; display: flex; }
.auth-hero {
    flex: 1 1 52%; background: linear-gradient(135deg, var(--navy) 0%, #16295c 55%, var(--blue) 130%);
    color: #fff; display: flex; flex-direction: column; justify-content: center;
    padding: 60px 64px; position: relative; overflow: hidden;
}
.auth-hero::after {
    content: ''; position: absolute; inset: 0;
    background: radial-gradient(circle at 85% 15%, rgba(255,255,255,.08), transparent 45%),
                radial-gradient(circle at 10% 90%, rgba(255,255,255,.06), transparent 40%);
    pointer-events: none;
}
.auth-hero-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 44px; position: relative; }
.auth-hero-logo .brand-logo-chip { width: 44px; height: 44px; border-radius: 10px; padding: 6px; }
.auth-hero-logo .brand-text { font-size: 22px; font-weight: 800; color: #fff; }
.auth-hero-logo .brand-text .brand-accent { color: #7db4ff; }
.auth-hero h1 { font-size: 33px; line-height: 1.28; font-weight: 800; margin: 0 0 14px; max-width: 460px; position: relative; }
.auth-hero p.lead { color: rgba(255,255,255,.78); font-size: 14.5px; line-height: 1.6; max-width: 420px; margin: 0 0 32px; position: relative; }
.auth-hero-badges { display: flex; flex-direction: column; gap: 11px; max-width: 420px; position: relative; }
.auth-hero-badge { display: flex; align-items: center; gap: 12px; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.14); border-radius: 12px; padding: 12px 16px; font-size: 13.5px; font-weight: 500; }
.auth-hero-badge .icon { color: #7db4ff; flex-shrink: 0; }
.auth-hero-footer { margin-top: 44px; font-size: 12px; color: rgba(255,255,255,.55); position: relative; }

/* ---------- Login com arte de fundo em tela cheia (login.php) ---------- */
.login-wrap-image {
    position: relative;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    justify-content: flex-end;
    padding: 24px 7vw;
}
.login-wrap-image::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,.65), rgba(0,0,0,0) 42%);
    pointer-events: none;
}
.login-wrap-image .login-card { box-shadow: 0 25px 70px rgba(0,0,0,.5); }
.login-wrap-image .login-footer { color: rgba(255,255,255,.9); text-shadow: 0 1px 4px rgba(0,0,0,.6); position: relative; }
@media (max-width: 900px) {
    .login-wrap-image { justify-content: center; padding: 20px; background-position: 65% center; }
}
.auth-panel { flex: 1 1 48%; display: flex; align-items: center; justify-content: center; background: #fff; padding: 40px 24px; }
.auth-form-wrap { width: 100%; max-width: 380px; }
.auth-form-wrap .login-card-logo img { width: 46px; height: 46px; }
.auth-form-wrap h2 { font-size: 21px; font-weight: 800; color: var(--navy); margin: 0 0 4px; text-align: center; }
.auth-form-wrap .subtitle { text-align: center; color: var(--text-muted); font-size: 13.5px; margin: 0 0 24px; }
.auth-form-wrap .btn { width: 100%; justify-content: center; padding: 11px; }
.auth-input-icon { position: relative; }
.auth-input-icon input { padding-left: 40px; }
.auth-input-icon .icon-slot { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; display: flex; }
.auth-input-icon .auth-toggle-pwd { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; color: var(--text-muted); padding: 6px; display: flex; border-radius: 6px; }
.auth-input-icon .auth-toggle-pwd:hover { background: var(--bg); color: var(--text); }
.auth-input-icon input[type=password], .auth-input-icon input[type=text].auth-pwd-field { padding-right: 40px; }
.auth-row-between { display: flex; align-items: center; justify-content: space-between; margin: 2px 0 18px; font-size: 13px; flex-wrap: wrap; gap: 8px; }
.auth-checkbox { display: flex; align-items: center; gap: 7px; color: var(--text-muted); cursor: pointer; user-select: none; }
.auth-checkbox input { width: 15px; height: 15px; accent-color: var(--blue); cursor: pointer; }
.auth-link { color: var(--blue); text-decoration: none; font-weight: 600; }
.auth-link:hover { text-decoration: underline; }
.auth-divider { display: flex; align-items: center; gap: 12px; margin: 20px 0; color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.auth-footer-note { text-align: center; margin-top: 28px; font-size: 12px; color: var(--text-muted); }
.auth-back-link { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-muted); text-decoration: none; margin-bottom: 18px; }
.auth-back-link:hover { color: var(--text); }
@media (max-width: 880px) {
    .auth-hero { display: none; }
    .auth-panel { background: linear-gradient(135deg, var(--navy) 0%, #16295c 60%, var(--blue) 130%); min-height: 100vh; }
    .auth-form-wrap { background: #fff; border-radius: 16px; padding: 34px 28px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
}

/* ---------- Misc ---------- */
.footer-note { text-align: center; padding: 20px; color: var(--text-muted); font-size: 12.5px; }
.text-muted { color: var(--text-muted); }
.text-danger { color: var(--red); }
.input-invalido { border-color: var(--red) !important; }
.mt-0 { margin-top: 0; }
.d-flex { display: flex; }
.gap-8 { gap: 8px; }
.align-center { align-items: center; }
.w-100 { width: 100%; }
.donut-wrap { display: flex; flex-direction: row; align-items: center; gap: 24px; flex-wrap: wrap; flex: 1; }
.donut-chart-wrap { flex-shrink: 0; }
/* max-width evita que a legenda estique até a ponta do card quando ele
   fica mais largo - o valor (empurrado por margin-left:auto) ficaria
   longe demais do texto. Sobra do card fica como espaço neutro à direita. */
.donut-legend { flex: 1; min-width: 170px; max-width: 230px; }
@media (max-width: 480px) { .donut-wrap { flex-direction: column; } }
.donut-legend .leg-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.donut-legend .leg-row:last-child { border-bottom: none; }
.leg-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.leg-row .leg-value { margin-left: auto; font-weight: 700; }
.progress-bar-track { background: var(--border); border-radius: 6px; height: 8px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: var(--blue); border-radius: 6px; }
.pill-filter { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.pill-filter select, .pill-filter input { width: auto; min-width: 160px; max-width: 320px; }
.pill-filter .search-input {
    display: flex; align-items: center; gap: 8px;
    border: 1px solid var(--border); border-radius: 8px;
    padding: 0 12px; background: #fff; flex: 1; min-width: 220px; max-width: 340px;
}
.pill-filter .search-input .icon { width: 16px; height: 16px; color: var(--text-muted); flex-shrink: 0; }
.pill-filter .search-input input {
    border: none; background: transparent; padding: 10px 0;
    width: 100%; min-width: 0; max-width: none;
}
.pill-filter .search-input input:focus { outline: none; box-shadow: none; }
.pill-filter .search-input:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.required-note { font-size: 12.5px; color: var(--text-muted); margin-top: 10px; }
.item-row-remove { color: var(--red); cursor: pointer; }
.stack-sm > * + * { margin-top: 10px; }
.link-btn { color: var(--blue); font-weight: 600; cursor: pointer; }
.password-warning-banner {
    background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412;
    padding: 12px 16px; border-radius: 10px; margin-bottom: 18px; font-size: 13.5px;
}

/* ---------- Dashboard: 3ª linha de cards, cards clicáveis, tendência ---------- */
/* Larguras diferentes de propósito: Execução Financeira é o mais largo,
   Central de Alertas é o mais estreito. Em telas menores (ou zoom alto),
   quebra para 1 coluna em vez de espremer os 3 cards lado a lado até
   quebrar o layout interno (rótulos do gráfico colidindo com o eixo, etc.). */
.three-col { display: grid; grid-template-columns: 1.2fr 1.1fr 0.85fr; gap: 18px; margin-bottom: 20px; align-items: stretch; }
.three-col > .card { display: flex; flex-direction: column; min-width: 0; }
@media (max-width: 1150px) {
    .three-col { grid-template-columns: 1fr; }
}

.kpi-card.kpi-clickable { position: relative; text-decoration: none; color: inherit; transition: box-shadow .15s, transform .15s; }
.kpi-card.kpi-clickable:hover { box-shadow: 0 6px 18px rgba(15,23,42,.08); transform: translateY(-2px); border-color: var(--blue); }
.kpi-card.kpi-clickable .kpi-arrow { position: absolute; top: 16px; right: 16px; width: 16px; height: 16px; color: var(--text-muted); }
.kpi-card.kpi-clickable .kpi-body { padding-right: 20px; }

.kpi-trend { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 700; margin-top: 3px; }
.kpi-trend.up { color: var(--green); }
.kpi-trend.down { color: var(--red); }
.kpi-trend .icon { width: 12px; height: 12px; }

.progress-bar-fill.green { background: var(--green); }
.progress-bar-fill.orange { background: var(--orange); }

/* ---------- Dashboard: gráfico de barras (sem dependência externa) ---------- */
.bar-chart-wrap { display: flex; gap: 20px; padding-top: 28px; }
.bar-axis {
    display: flex; flex-direction: column; justify-content: space-between;
    height: 170px; flex-shrink: 0; text-align: right;
    font-size: 11px; color: var(--text-muted); padding-right: 2px;
}
.bar-plot-col { flex: 1; min-width: 0; }
.bar-plot { position: relative; height: 170px; border-bottom: 1px solid var(--border); }
.bar-gridline { position: absolute; left: 0; right: 0; height: 1px; background: var(--border); opacity: .6; }
.bar-chart { position: relative; z-index: 1; display: flex; align-items: flex-end; justify-content: space-around; gap: 24px; height: 100%; }
.bar-col { display: flex; align-items: flex-end; justify-content: center; height: 100%; flex: 1; }
.bar-col .bar {
    position: relative;
    width: 100%; max-width: 56px; min-height: 0;
    border-radius: 6px 6px 0 0;
}
.bar-col .bar-value {
    position: absolute; top: -22px; left: 50%; transform: translateX(-50%);
    white-space: nowrap; font-size: 12.5px; font-weight: 700; color: #111827;
}
.bar-labels { display: flex; justify-content: space-around; gap: 24px; margin-top: 10px; }
.bar-labels .bar-label { flex: 1; font-size: 12.5px; color: var(--text-muted); text-align: center; }

/* ---------- Dashboard: número central no donut ---------- */
.donut-chart-wrap { position: relative; display: inline-flex; }
.donut-center {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    text-align: center; pointer-events: none;
}
.donut-center-value { font-size: 24px; font-weight: 800; color: #111827; line-height: 1; }
.donut-center-label { font-size: 11.5px; color: var(--text-muted); margin-top: 3px; }

/* ---------- Dashboard: Central de Alertas ---------- */
.alert-list { display: flex; flex-direction: column; gap: 2px; }
.alert-list-item { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--border); text-decoration: none; color: inherit; }
.alert-list-item:last-child { border-bottom: none; }
.alert-list-icon { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; color: #fff; flex-shrink: 0; }
.alert-list-icon.red { background: var(--red); }
.alert-list-icon.orange { background: var(--orange); }
.alert-list-icon.blue { background: var(--blue); }
.alert-list-icon.purple { background: var(--purple); }
.alert-list-body { flex: 0 1 auto; min-width: 0; }
.alert-list-body .alert-list-title { font-size: 13.5px; font-weight: 600; color: #111827; }
.alert-list-body .alert-list-sub { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.alert-list-count { font-size: 15px; font-weight: 800; color: #111827; margin-left: 24px; flex-shrink: 0; }

/* ---------- Contrato: abas de navegação (Visão Geral / Dados / Aditivos / etc.) ---------- */
.tabs-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.tab-btn {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 18px; border-radius: 10px; border: 1px solid var(--border);
    background: #fff; color: var(--text); font-size: 14px; font-weight: 600;
    font-family: inherit; cursor: pointer; white-space: nowrap;
    transition: background .15s, color .15s, border-color .15s;
}
.tab-btn:hover { border-color: var(--blue); color: var(--blue); }
.tab-btn.active { background: var(--blue); border-color: var(--blue); color: #fff; }
.tab-btn .icon { width: 18px; height: 18px; flex-shrink: 0; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- Combo com busca: <select data-busca> vira digitável (ver assets/js/app.js) ---------- */
.combo-busca { position: relative; }
.combo-busca-select-oculto { display: none; }
.combo-busca-input { width: 100%; }
.combo-busca-lista {
    position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 25;
    background: #fff; border: 1px solid var(--border); border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,.12);
    max-height: 260px; overflow-y: auto; padding: 4px;
}
.combo-busca-item { padding: 9px 10px; border-radius: 6px; font-size: 13.5px; color: var(--text); cursor: pointer; }
.combo-busca-item:hover, .combo-busca-item.destaque { background: var(--bg); }
.combo-busca-item.ativo { font-weight: 700; color: var(--blue); }
.combo-busca-vazio { padding: 9px 10px; font-size: 13.5px; color: var(--text-muted); }

/* ---------- Modal genérico (ex.: "Definir Permissões" em Usuários > Sistemas Vinculados) ---------- */
.modal-overlay {
    display: none; position: fixed; inset: 0; z-index: 1000;
    background: rgba(14, 27, 61, .55);
    align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal-box {
    background: var(--card); border-radius: var(--radius);
    width: 100%; max-width: 560px; max-height: 85vh;
    display: flex; flex-direction: column;
    box-shadow: 0 24px 64px rgba(0,0,0,.28);
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.modal-header h3 { margin: 0; font-size: 16.5px; font-weight: 700; }
.modal-close {
    background: none; border: none; font-size: 22px; line-height: 1;
    color: var(--text-muted); cursor: pointer; padding: 2px 6px; border-radius: 6px;
}
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-footer {
    display: flex; justify-content: flex-end; gap: 10px;
    padding: 14px 20px; border-top: 1px solid var(--border); flex-shrink: 0;
}
