:root{
  --bg:#f5f8fc;
  --card:#fff;
  --text:#1b2b3a;
  --muted:#6b7a88;
  --blue:#0d3b66;     /* azul escuro */
  --blue-ghost:#0d3b6633;
  --border:#e3e8ef;
}
*{box-sizing:border-box}
body{margin:0;background:var(--bg);font-family:system-ui,-apple-system,Segoe UI,Roboto,Ubuntu,Helvetica,Arial,sans-serif;color:var(--text)}
.auth-mode{background:#eef2f8;min-height:100vh;padding:0;margin:0;}
.login-layout{display:flex;min-height:100vh;flex-wrap:wrap;background:#eef2f8;}
.login-hero{
  flex:1 1 55%;
  min-height:100vh;
  padding:70px 70px 80px;
  background:linear-gradient(135deg,#021129 0%,#082756 55%,#0b3f7b 100%);
  color:#fff;
  display:flex;
  flex-direction:column;
  justify-content:flex-start;
  position:relative;
}
.login-hero::after{
  content:'';
  position:absolute;
  inset:0;
  background:radial-gradient(circle at 20% 20%,rgba(255,255,255,0.18),transparent 50%);
  pointer-events:none;
}
.hero-copy{
  max-width:420px;
  margin-top:40px;
  display:flex;
  flex-direction:column;
  gap:14px;
}
.hero-accent{
  display:inline-block;
  width:140px;
  height:5px;
  border-radius:999px;
  background:rgba(255,255,255,0.35);
}
.hero-copy h1{
  font-size:46px;
  margin:0;
  font-weight:700;
}
.hero-copy p{
  margin:0;
  font-size:18px;
  color:rgba(255,255,255,0.85);
}
.login-card{
  flex:1 1 45%;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  padding:40px 60px;
  text-align:center;
}
.login-form{
  width:100%;
  max-width:420px;
  background:rgba(255,255,255,0.98);
  border-radius:28px;
  box-shadow:0 30px 70px rgba(15,23,42,0.22);
  padding:44px 38px 34px;
  display:flex;
  flex-direction:column;
  gap:16px;
  margin:0 auto;
  border:1px solid #f0f4fb;
}
.login-card__logo{margin-bottom:6px;}
.login-card__logo img{height:54px;width:auto;}
.login-form__title{
  font-size:20px;
  font-weight:600;
  color:#0b2545;
}
.login-field{display:flex;flex-direction:column;gap:6px;font-size:13px;color:#475569;}
.login-field span{font-weight:600;}
.login-form .input{
  border-radius:16px;
  border:1px solid #cfd8e3;
  padding:12px 14px;
}
.login-form .btn.primary{
  border-radius:16px;
  width:100%;
  justify-content:center;
  background:#0b3f7b;
  box-shadow:0 18px 35px rgba(11,63,123,0.28);
}
.login-form .btn.primary:hover{filter:brightness(1.05);}
.login-footer{
  font-size:13px;
  color:#6b7a88;
  text-align:center;
  margin-top:18px;
}
.auth-error{color:#ef4444;margin:8px 0 0;font-size:14px;min-height:18px;text-align:left;width:100%;max-width:420px;}
@media (max-width:960px){
  .login-layout{flex-direction:column;}
  .login-hero{min-height:320px;padding:50px 40px;}
  .login-card{padding:30px;align-items:center;}
  .login-form{max-width:100%;}
}
.header{padding:20px 24px;font-weight:600}
.container{display:grid;grid-template-columns:280px 1fr;gap:24px;padding:0 24px 24px}
.card{background:var(--card);border:1px solid var(--border);border-radius:12px;box-shadow:0 1px 0 rgba(16,24,40,.02)}
.card .hd{padding:16px 18px;font-weight:600;border-bottom:1px solid var(--border)}
.card .bd{padding:16px 18px}
.card.menu .bd{display:flex;flex-direction:column;gap:10px;max-height:calc(100vh - 160px);overflow-y:auto;padding-right:10px;}
.menu .item{display:block;width:100%;text-align:left;padding:12px 14px;border:1px solid var(--border);border-radius:10px;background:#fff;color:var(--text);cursor:pointer}
.menu .item.active{outline:2px solid var(--blue-ghost); font-weight: 600;}
.btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;border-radius:10px;padding:10px 14px;border:0;background:var(--blue);color:#fff;font-weight:600;cursor:pointer;transition:transform .12s ease,box-shadow .12s ease}
.btn:hover{filter:brightness(1.2)}
.btn:disabled{background:var(--muted);cursor:not-allowed}
.btn-outline{background:#fff;color:var(--blue);border:1px solid var(--blue)}
.btn-outline:hover{background:var(--blue);color:#fff}
.btn-neutral{background:var(--muted);color:#fff}
.btn-neutral:hover{filter:brightness(1.12)}
.btn-success{background:#10b981;color:#fff}
.btn-success:hover{background:#0f9d72}

/* --- Correção do Patch v3 --- */
.btn-danger {
  background: #ef4444; /* Vermelho */
}
.btn-danger:hover {
  background: #dc2626;
}

/* --- Botão Pequeno (Patch v3) --- */
.btn-sm {
  padding: 6px 10px;
  font-weight: 500;
  border-radius: 8px;
}

.input, select, textarea{
  display:block;width:100%;padding:10px 12px;border:1px solid var(--border);border-radius:8px;background:#fff;
  font-family:inherit;font-size:14px;color:var(--text)
}
.input:focus, select:focus, textarea:focus{
  border-color:#2563eb;
  outline:none;
  box-shadow:0 0 0 3px rgba(37,99,235,0.18);
  background:#fff;
}
.input-sm{padding:8px 10px;font-size:13px}
label{display:block;margin-bottom:4px;font-size:13px;font-weight:500;color:var(--muted)}
.table{width:100%;border-collapse:collapse}
.table th{text-align:left;font-size:12px;padding:10px 8px;color:var(--muted);border-bottom:1px solid var(--border)}
.table td{padding:10px 8px;border-bottom:1px solid var(--border);font-size:14px}
.table thead tr{background:#eef2fb}
.table thead th{color:#4f5d6d;font-weight:600;border-bottom:1px solid rgba(15,23,42,0.12)}
.table tbody tr:nth-child(odd){background:#ffffff}
.table tbody tr:nth-child(even){background:#f6f7fb}
.table tbody tr:hover{background:#e8f0ff}
.table tr:last-child td{border-bottom:0}
.table .row-actions { display:flex; justify-content:flex-end; gap:8px; }
.table .row-actions .btn{margin:0}
.table-actions{display:flex;justify-content:flex-end;gap:8px;margin-bottom:12px}
.table-actions .input{max-width:260px}
.page-message{margin-bottom:12px;min-height:18px;font-size:14px}
.section-divider{margin:32px 0;height:1px;background:linear-gradient(90deg,transparent,rgba(13,59,102,.18),transparent)}

/* --- Indicadores de Status (Patch v2) --- */
.card .hd.status-vencendo {
  border-left: 5px solid #f59e0b; /* Laranja */
  padding-left: 14px;
}
.card .hd.status-andamento {
  border-left: 5px solid #10b981; /* Verde */
  padding-left: 14px;
}
.card .hd.status-encerrado {
  border-left: 5px solid #ef4444; /* Vermelho */
  padding-left: 14px;
}
.card .hd.status-parcelas {
  border-left: 5px solid #2563eb; /* Azul */
  padding-left: 14px;
}

/* --- Scroll nas Tabelas (Patch v3) --- */
.table-container {
  max-height: 300px;
  overflow-y: auto;
}

/* --- Filtros de Relatório (Patch v4) --- */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
  padding: 0 0 16px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.filters--rel label{
  display:flex;
  flex-direction:column;
  gap:6px;
  font-size:13px;
  color:var(--muted);
}
.filter-range{
  display:flex;
  align-items:center;
  gap:6px;
}
.filter-range__sep{
  font-size:12px;
  color:var(--muted);
}
.filter-actions{
  display:flex;
  gap:8px;
  margin-left:auto;
}
.rel-indicators-grid{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(260px,1fr));
  gap:14px;
  margin:20px 0;
}
.rel-indicator-value{
  font-size:36px;
  font-weight:700;
  color:#0d3b66;
}
.rel-chart-grid{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(320px,1fr));
  gap:14px;
  margin-bottom:24px;
}
.rel-tempo-table th,
.rel-tempo-table td{
  font-size:13px;
  padding:8px 10px;
}
.contract-attachments-block{
  margin-top:16px;
  border-top:1px solid var(--border);
  padding-top:12px;
}
.contract-attachments__header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin-bottom:10px;
}
.contract-attachments__header h4{
  margin:0;
  font-size:16px;
}
.contract-attachments__body{
  display:flex;
  flex-direction:column;
  gap:10px;
}
.attachment-item{
  display:flex;
  justify-content:space-between;
  align-items:center;
  border:1px solid var(--border);
  border-radius:10px;
  padding:10px 12px;
}
.attachment-item .muted{
  font-size:12px;
}

/* --- Estilos Gerenciamento O.C. (Patch v6) --- */
.oc-grid {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 20px;
  min-height: 60vh;
}
.oc-tip{margin:0 0 12px;font-size:13px;line-height:1.4}
.oc-sidebar .card {
  margin-bottom: 16px;
}
.oc-insumo-list .item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-weight: 500;
  border-radius: 0;
}
.oc-insumo-list .item:first-child { border-radius: 8px 8px 0 0;}
.oc-insumo-list .item:last-child { border-bottom: none; border-radius: 0 0 8px 8px;}
.oc-insumo-list .item:hover {
  background: var(--bg);
}
.oc-insumo-list .item.active {
  background: var(--blue-ghost);
  color: var(--blue);
  font-weight: 600;
}
.oc-insumo-list .btn-del-insumo {
  background: none; border: none; color: var(--muted); cursor: pointer;
  display: none;
}
.oc-insumo-list .item:hover .btn-del-insumo { display: inline-block; }
.oc-insumo-list .btn-del-insumo:hover { color: #ef4444; }

.btn-manage-insumos{width:100%;margin:12px 0 18px;display:block}
.oc-header-bar{display:flex;flex-wrap:wrap;align-items:flex-end;justify-content:space-between;gap:16px;margin-bottom:16px}
.oc-filter-bar label{display:flex;flex-direction:column;gap:6px;font-size:13px;color:var(--muted)}
.oc-filter-bar select{min-width:200px}
.oc-actions{display:flex;justify-content:flex-end;gap:10px}
.oc-placeholder{color:var(--muted);padding:28px;border:2px dashed var(--border);border-radius:14px;text-align:center;background:rgba(13,59,102,0.03)}
.oc-empty{padding:18px;border:1px dashed var(--border);border-radius:10px;text-align:center;background:#f8fafc;color:var(--muted);line-height:1.6}

.oc-status {
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}
.oc-status.ABERTA { background: #10b98133; color: #057a55; }
.oc-status.ENCERRADA { background: #6b7a8833; color: var(--muted); }
.oc-status.CANCELADA { background: #ef444433; color: #c81e1e; }

.oc-saldo-bar {
  width: 100%;
  background: var(--border);
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  margin-top: 4px;
}
.oc-saldo-bar-inner {
  height: 100%;
  background: var(--blue);
  transition: width 0.3s ease;
}

/* --- Modal (Patch v6) --- */
.modal-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.2s ease;
  visibility: hidden; /* Added for smoother transition */
}
.modal-backdrop.visible { /* Added for smoother transition */
  opacity: 1;
  visibility: visible;
}
.modal-content {
  background: white;
  border-radius: 12px;
  width: 100%;
  max-width: 800px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
  transform: scale(0.95);
  transition: transform 0.2s ease;
}
.modal-backdrop.visible .modal-content { /* Added for smoother transition */
    transform: scale(1);
}
.modal-header {
  padding: 16px 20px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-body {
  padding: 20px;
  max-height: 70vh;
  overflow-y: auto;
}
.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display:flex;
  justify-content:flex-end;
  gap:12px;
  flex-wrap:wrap;
}
.modal-footer .btn{min-width:120px}
.push-left{margin-right:auto}
.modal-close-btn {
  border: none; background: none; font-size: 20px; cursor: pointer; color: var(--muted);
}
.modal-error{color:#ef4444;margin-bottom:12px;font-size:14px}
.modal-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* Detalhes e Saldos no Modal */
.oc-detail-header {
  background: var(--bg);
  padding: 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}
.oc-detail-header div {
  font-size: 14px;
}
.oc-detail-header strong {
  display: block;
  font-size: 20px;
  color: var(--text);
}
.oc-detail-header .saldo-positivo { color: #057a55; }
.oc-detail-header .saldo-negativo { color: #c81e1e; }

.insumo-form{display:flex;flex-wrap:wrap;gap:12px;align-items:flex-end;margin-bottom:12px}
.insumo-field{flex:1;min-width:220px;display:flex;flex-direction:column;gap:6px}
.insumo-field span{font-size:13px;font-weight:500;color:var(--muted)}

.global-modal-backdrop{
  position:fixed;
  inset:0;
  background:rgba(15,23,42,0.35);
  display:flex;
  align-items:center;
  justify-content:center;
  opacity:0;
  pointer-events:none;
  transition:opacity .2s ease;
  z-index:999;
}
.global-modal-backdrop.visible{
  opacity:1;
  pointer-events:all;
}
.global-modal{
  background:#fff;
  border-radius:12px;
  box-shadow:0 24px 60px rgba(15,23,42,0.25);
  width:min(640px, calc(100vw - 24px));
  max-height:90vh;
  overflow:hidden;
}
.global-modal__content{display:flex;flex-direction:column;max-height:90vh}
.global-modal__header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:18px 22px;
  border-bottom:1px solid rgba(148,163,184,0.2);
  font-size:18px;
  font-weight:600;
}
.global-modal__close{
  background:none;
  border:none;
  font-size:24px;
  cursor:pointer;
  color:var(--muted);
}
.global-modal__body{
  padding:20px 22px;
  overflow-y:auto;
}
.global-modal__footer,
.global-modal__actions{
  display:flex;
  gap:12px;
  justify-content:flex-end;
  padding:16px 22px;
  border-top:1px solid rgba(148,163,184,0.15);
}
.global-modal__loading{text-align:center;color:var(--muted);padding:20px 0;}
.contract-detail__grid{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(200px,1fr));
  gap:12px;
}
.contract-detail__grid dt{
  font-size:12px;
  text-transform:uppercase;
  color:var(--muted);
  margin-bottom:4px;
}
.contract-detail__grid dd{
  margin:0;
  font-size:15px;
  color:var(--text);
}
.contract-detail__notes{grid-column:1 / -1}
.link-button{
  background:none;
  border:none;
  color:var(--primary,#0a66c2);
  text-decoration:underline;
  cursor:pointer;
  padding:0;
  font:inherit;
}
.user-permission-modal p{margin:0 0 12px 0;}
.user-permission-form fieldset{
  border:1px solid rgba(148,163,184,0.3);
  padding:12px 16px;
  border-radius:8px;
  margin:0 0 12px 0;
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(180px,1fr));
  gap:8px;
}
.user-permission-form legend{
  font-size:13px;
  font-weight:600;
  padding:0 6px;
}
.user-permission-form .checkbox{
  display:flex;
  align-items:center;
  gap:8px;
  font-size:14px;
}
.user-permission-form .form-feedback{margin-top:10px;font-size:14px}
.contract-edit-form .grid-2{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(200px,1fr));
  gap:14px;
  margin-bottom:12px;
}
.contract-edit-form label{display:flex;flex-direction:column;gap:6px;font-size:14px;color:var(--muted)}
.auditoria-form{display:flex;flex-direction:column;gap:14px;margin-bottom:12px}
.auditoria-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:14px}
.auditoria-grid label{display:flex;flex-direction:column;gap:6px;font-size:13px;color:var(--muted)}
.auditoria-grid .auditoria-full{grid-column:1 / -1}
.auditoria-actions{display:flex;gap:10px;align-items:center}
.audit-modal{display:flex;flex-direction:column;gap:8px;font-size:14px}
.audit-json{background:#0f172a0f;border:1px solid rgba(15,23,42,0.12);border-radius:8px;padding:12px;font-family:'Fira Code',Menlo,monospace;font-size:13px;max-height:240px;overflow:auto}

.file-picker{
  display:flex;
  align-items:center;
  gap:12px;
  flex-wrap:wrap;
}

.file-picker__name{
  font-size:.9rem;
  color:var(--muted,#6b7280);
}

.file-input-native{
  position:absolute;
  width:1px;
  height:1px;
  padding:0;
  margin:-1px;
  overflow:hidden;
  clip:rect(0,0,0,0);
  border:0;
}

.btn-file{
  min-width:120px;
}
