:root {
  --blue: #0b4c8c;
  --blue-2: #083965;
  --green: #179a63;
  --green-2: #0e6c48;
  --ink: #17212b;
  --muted: #607080;
  --line: #dbe4ec;
  --soft: #f4f8fb;
  --white: #ffffff;
  --danger: #b42318;
  --warning: #9a6500;
  --radius: 8px;
  font-family: Inter, Segoe UI, Arial, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background: #eef4f7;
}
button, input, select, textarea {
  font: inherit;
}
button {
  border: 0;
  border-radius: 6px;
  background: var(--blue);
  color: var(--white);
  padding: 10px 12px;
  cursor: pointer;
  min-height: 40px;
}
button.secondary {
  background: var(--white);
  color: var(--blue);
  border: 1px solid var(--line);
}
button.success { background: var(--green); }
button.danger { background: var(--danger); }
.danger-outline { color: var(--danger) !important; border-color: #efc2bd !important; }
button:disabled {
  opacity: .5;
  cursor: not-allowed;
}
button:hover:not(:disabled) { filter: brightness(.94); }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 3px solid rgba(23,154,99,.28);
  outline-offset: 2px;
}
input, select, textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: var(--white);
  color: var(--ink);
}
textarea { min-height: 86px; resize: vertical; }
label {
  display: grid;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: #34495e;
}
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(11,76,140,.94), rgba(23,154,99,.88)),
    #0b4c8c;
}
.login-panel {
  width: min(420px, 100%);
  background: var(--white);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: 0 24px 60px rgba(0,0,0,.24);
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}
.brand img {
  width: 58px;
  height: 58px;
  object-fit: contain;
}
.brand strong { display: block; font-size: 18px; }
.brand span { color: var(--muted); font-size: 13px; }
.login form { display: grid; gap: 14px; }
.hint {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}
.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}
.sidebar {
  background: #071d31;
  color: var(--white);
  padding: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar .brand { margin-bottom: 24px; }
.sidebar .brand img {
  width: 44px;
  height: 44px;
  background: var(--white);
  border-radius: 6px;
  padding: 3px;
}
.sidebar .brand span { color: #b9cad8; }
.nav {
  display: grid;
  gap: 6px;
}
.nav button {
  background: transparent;
  color: #d9e8f2;
  text-align: left;
  border: 1px solid transparent;
}
.nav button.active, .nav button:hover {
  background: rgba(255,255,255,.1);
  border-color: rgba(255,255,255,.12);
}
.sidebar-footer {
  margin-top: 24px;
  display: grid;
  gap: 10px;
  color: #b9cad8;
  font-size: 13px;
}
.main {
  min-width: 0;
  padding: 22px;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}
h1 {
  margin: 0;
  font-size: 24px;
  letter-spacing: 0;
}
h2 {
  margin: 0 0 12px;
  font-size: 18px;
}
h3 { margin: 18px 0 10px; font-size: 15px; }
.subtitle {
  margin: 4px 0 0;
  color: var(--muted);
}
.grid {
  display: grid;
  gap: 14px;
}
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.dashboard-lists { grid-template-columns: minmax(0, 1.3fr) minmax(0, .7fr); }
.section-gap { margin-top: 14px; }
.panel, .card {
  min-width: 0;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.metric {
  display: grid;
  gap: 8px;
}
.metric span { color: var(--muted); font-size: 13px; }
.metric strong { font-size: 24px; }
.toolbar {
  display: flex;
  gap: 10px;
  align-items: end;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.toolbar label { min-width: 180px; flex: 1; }
.compact-toolbar { margin: 0 0 12px; }
.field-with-action {
  display: flex;
  gap: 6px;
  align-items: stretch;
}
.field-with-action input { min-width: 0; }
.field-with-action button { flex: 0 0 auto; white-space: nowrap; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.span-2 { grid-column: span 2; }
.span-4 { grid-column: span 4; }
.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
}
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 780px;
}
.compact-table { min-width: 100%; }
th, td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
th {
  background: #f7fafc;
  font-size: 12px;
  color: #475767;
  text-transform: uppercase;
}
tr:last-child td { border-bottom: 0; }
.status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 700;
  background: #eaf4ff;
  color: var(--blue);
}
.status.vencido, .status.suspenso, .status.cancelado { background: #fff0ee; color: var(--danger); }
.status.ativo, .status.assinado, .status.pago { background: #eaf8f1; color: var(--green-2); }
.status.implantacao, .status.enviado, .status.parcialmente_pago { background: #fff8e8; color: var(--warning); }
.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.actions button, .actions a {
  min-height: 34px;
  padding: 7px 9px;
  border-radius: 6px;
  text-decoration: none;
  background: var(--white);
  color: var(--blue);
  border: 1px solid var(--line);
  font-size: 13px;
}
.actions select { width: auto; min-width: 128px; min-height: 34px; padding: 6px 8px; }
.notice {
  border-left: 4px solid var(--green);
  background: #eefaf4;
  padding: 10px 12px;
  border-radius: 6px;
  color: #124d35;
  margin-bottom: 12px;
}
.error {
  border-left-color: var(--danger);
  background: #fff0ee;
  color: var(--danger);
}
.mobile-menu { display: none; }
.overdue-summary {
  margin-top: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.overdue-summary span { color: var(--muted); font-size: 13px; font-weight: 700; }
.overdue-summary strong { color: var(--danger); font-size: 22px; }
dialog {
  width: min(980px, calc(100vw - 32px));
  max-height: calc(100vh - 40px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  color: var(--ink);
  background: var(--white);
  box-shadow: 0 24px 70px rgba(0,0,0,.28);
}
dialog::backdrop { background: rgba(7,29,49,.58); }
.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
}
.dialog-form { margin-top: 18px; }
.dialog-actions { display: flex; justify-content: flex-end; margin-top: 16px; }
.icon-button {
  width: 40px;
  min-width: 40px;
  height: 40px;
  padding: 0;
  font-weight: 800;
}
.button-link { display: inline-flex; align-items: center; }
.section-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.document-list { display: grid; border-top: 1px solid var(--line); }
.document-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.document-row:last-child { border-bottom: 0; }
.document-row strong, .document-row span { display: block; }
.document-row span { color: var(--muted); font-size: 12px; margin-top: 3px; }
.readiness { display: inline-block; margin-top: 6px; font-size: 12px; font-weight: 700; }
.readiness.ready { color: var(--green-2); }
.readiness.pending { color: var(--warning); }
.contract-readiness {
  border-left: 4px solid var(--warning);
  background: #fff8e8;
  padding: 12px 14px;
  margin-bottom: 16px;
}
.contract-readiness.ready { border-left-color: var(--green); background: #eefaf4; }
.contract-readiness p { margin: 6px 0 0; }
.contract-readiness ul { margin: 8px 0 0; padding-left: 20px; }
.warning-notice { border-left-color: var(--warning); background: #fff8e8; color: #684600; }
.tabs { display: flex; gap: 6px; margin: 14px 0; }
.tabs button { background: var(--white); color: var(--blue); border: 1px solid var(--line); }
.tabs button.active { background: var(--blue); color: var(--white); border-color: var(--blue); }
.intelligence-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  background: #071d31;
  color: var(--white);
  padding: 18px;
  border-left: 6px solid var(--green);
}
.intelligence-summary h2, .intelligence-summary p { margin: 0; }
.intelligence-summary p { color: #b9cad8; margin-top: 5px; }
.intelligence-summary > strong { font-size: 19px; }
.insight-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.insight-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-top: 4px solid var(--green);
  padding: 14px;
  border-radius: var(--radius);
  display: grid;
  gap: 8px;
}
.insight-card.priority-alta { border-top-color: var(--danger); }
.insight-card.priority-media { border-top-color: var(--warning); }
.insight-card > span { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.insight-card > strong { font-size: 16px; }
.insight-card p { color: var(--muted); margin: 0; min-height: 42px; }
.insight-card button { justify-self: start; }
.question-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.intelligence-answer { margin-top: 12px; padding: 14px; background: var(--soft); border-left: 4px solid var(--blue); }
.intelligence-answer p { margin: 6px 0; }
.intelligence-answer span { color: var(--muted); font-size: 12px; }

@media (max-width: 900px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .sidebar {
    position: static;
    height: auto;
    padding: 12px 14px;
    min-width: 0;
    overflow: hidden;
  }
  .sidebar .brand { margin-bottom: 12px; }
  .nav {
    display: flex;
    overflow-x: auto;
    max-width: 100%;
    gap: 6px;
    padding-bottom: 4px;
  }
  .nav button { flex: 0 0 auto; white-space: nowrap; }
  .sidebar-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; }
  .sidebar-footer button { width: auto; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: minmax(0, 1fr); }
  .insight-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: 1fr; }
  .span-2, .span-4 { grid-column: auto; }
  .main { padding: 16px; }
  .topbar { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 560px) {
  .login-panel { padding: 20px; }
  table { min-width: 680px; }
  .compact-table { min-width: 520px; }
  .toolbar { display: grid; }
  .toolbar label { min-width: 0; }
  dialog { width: calc(100vw - 16px); max-height: calc(100vh - 16px); padding: 16px; }
  .dialog-header h2 { font-size: 17px; }
  .overdue-summary { align-items: flex-start; flex-direction: column; }
  .field-with-action, .document-row, .intelligence-summary { align-items: stretch; flex-direction: column; }
  .field-with-action button { width: 100%; }
  .insight-grid, .question-form { grid-template-columns: minmax(0, 1fr); }
}
