:root {
  /* Paleta da logo Calc Pré Antecipados */
  --brand-navy: #2B3D7E;
  --brand-green: #00A859;
  --brand-gold: #C5A046;
  --primary: #2B3D7E;
  --primary-mid: #3A4F96;
  --accent-cyan: #70C1E3;
  --cta-orange: #C5A046;
  --status-pre: #D64545;
  --status-approved: #00A859;
  --header-teal: #2B3D7E;
  --text: #2C2E35;
  --muted: #6B7280;
  --surface: #FFFFFF;
  --bg: #F7F9FC;
  --border: #E3E8F0;
  --sidebar-w: 208px;
  --radius: 10px;
  --shadow: 0 8px 24px rgba(43, 61, 126, 0.08);
  --font: "Poppins", system-ui, -apple-system, Arial, sans-serif;
  --fs: 0.875rem;      /* 14px — padrão global */
  --fs-sm: 0.8125rem;  /* 13px */
  --fs-xs: 0.75rem;    /* 12px */
  --fs-lg: 1rem;       /* 16px */
}

html { font-size: 16px; }

/* ===== Modal / Popup cadastros ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 20px 16px 24px;
  background: rgba(11, 41, 114, 0.28);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
}
.modal-overlay.is-open {
  display: flex;
  opacity: 1;
  animation: modalFadeIn 0.28s ease forwards;
}
.modal-dialog {
  width: min(640px, 100%);
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 40px);
  overflow-x: hidden;
  overflow-y: auto;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(11, 41, 114, 0.25);
  margin-top: 20px;
  transform: translateY(-18px) scale(0.96);
  opacity: 0;
  box-sizing: border-box;
}
.modal-overlay.is-open .modal-dialog {
  animation: modalSlideIn 0.32s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes modalSlideIn {
  from { opacity: 0; transform: translateY(-18px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-dialog.modal-lg { width: min(820px, 100%); }
.modal-dialog.modal-sm { width: min(440px, 100%); }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.15rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 2;
}
.modal-header h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 650;
  color: var(--brand-navy);
}
.modal-close {
  border: 0;
  background: #E8EDF5;
  color: var(--text);
  width: 34px;
  height: 34px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
}
.modal-close:hover { background: #d9e1ee; }
.modal-body { padding: 1.1rem 1.15rem 1.25rem; min-width: 0; overflow-x: hidden; }
.modal-footer {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
  padding: 0.9rem 1.15rem 1.15rem;
  border-top: 1px solid var(--border);
}
body.modal-open { overflow: hidden; }

/* ===== Searchable Select (DIV + LIST) ===== */
.ss-wrap {
  position: relative;
  width: 100%;
  min-width: 140px;
  z-index: 1;
}
.ss-wrap.is-open {
  z-index: 500;
}
.ss-native {
  position: absolute !important;
  opacity: 0 !important;
  pointer-events: none !important;
  width: 1px !important;
  height: 1px !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  clip: rect(0 0 0 0);
}
.ss-control {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  border-bottom: 1.5px solid #B7C2D3;
  background: transparent;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.ss-wrap.is-open .ss-control,
.ss-control:focus-within {
  border-bottom-color: var(--primary);
}
.ss-wrap.is-invalid .ss-control,
.input.is-invalid,
select.is-invalid {
  border-bottom-color: #B42318 !important;
  box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.22);
  border-radius: 6px;
}
.input.is-invalid,
select.is-invalid {
  border: 1.5px solid #B42318;
}
.ss-input {
  flex: 1;
  min-width: 0;
  border: none !important;
  background: transparent;
  padding: 0.45rem 0.1rem;
  font-family: inherit;
  font-size: var(--fs);
  color: var(--text);
  outline: none;
}
.ss-input::placeholder { color: #98A2B3; }
.ss-caret,
.ss-clear {
  border: 0;
  background: transparent;
  color: var(--muted);
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ss-clear {
  display: none;
  font-size: 1.1rem;
  line-height: 1;
}
.ss-wrap.has-value .ss-clear { display: inline-flex; }
.ss-caret:hover,
.ss-clear:hover { background: #E8EDF5; color: var(--brand-navy); }
.ss-list {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  z-index: 600;
  max-height: 240px;
  overflow: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 14px 34px rgba(11, 41, 114, 0.18);
  padding: 0.35rem;
}
.ss-wrap.is-open .ss-list { display: block; animation: ssPop 0.16s ease; }
@keyframes ssPop {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.ss-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  font-family: inherit;
  font-size: var(--fs);
  color: var(--text);
  cursor: pointer;
}
.ss-item:hover,
.ss-item.is-active { background: #F0F6FF; }
.ss-item.is-selected {
  background: rgba(6, 70, 165, 0.1);
  color: var(--brand-navy);
  font-weight: 600;
}
.ss-item-hint {
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 500;
}
.ss-empty {
  padding: 0.75rem 0.65rem;
  color: var(--muted);
  font-size: 0.88rem;
}
.ss-wrap.is-disabled { opacity: 0.6; pointer-events: none; }
table.data .ss-wrap { min-width: 160px; }
table.data .ss-list { min-width: 220px; }

/* ===== Pagination ===== */
.pagination-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.9rem;
  padding: 0.65rem 0.1rem;
}
.pagination-info {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 500;
}
.pagination-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

/* ===== Toasts + Confirm ===== */
.toast-stack {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  width: min(380px, calc(100vw - 24px));
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(11, 41, 114, 0.16);
  padding: 0.85rem 0.95rem;
  animation: toastIn 0.28s ease;
  font-family: var(--font);
}
.toast.is-out { animation: toastOut 0.22s ease forwards; }
.toast-success { border-left-color: var(--brand-green); }
.toast-error { border-left-color: var(--status-pre); }
.toast-info { border-left-color: var(--status-approved); }
.toast-warn { border-left-color: var(--cta-orange); }
.toast-title {
  font-weight: 650;
  color: var(--brand-navy);
  margin: 0 0 0.25rem;
  font-size: 0.95rem;
}
.toast-msg {
  margin: 0;
  color: var(--text);
  font-size: 0.88rem;
  line-height: 1.4;
}
.toast-actions {
  display: flex;
  gap: 0.45rem;
  margin-top: 0.75rem;
  justify-content: flex-end;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(16px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateX(16px); }
}
.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 2100;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 20px 16px;
  background: rgba(11, 41, 114, 0.28);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.confirm-overlay.is-open { display: flex; }
.confirm-dialog {
  width: min(420px, 100%);
  margin-top: 20px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(11, 41, 114, 0.25);
  padding: 1.15rem 1.2rem 1.2rem;
  animation: modalSlideIn 0.28s ease;
}
.confirm-dialog h3 {
  margin: 0 0 0.4rem;
  color: var(--brand-navy);
  font-size: 1.05rem;
}
.confirm-dialog p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}
.confirm-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1.1rem;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: var(--fs);
  line-height: 1.45;
  color: var(--text);
  background:
    radial-gradient(1100px 480px at 8% -12%, rgba(112, 193, 227, 0.22), transparent 58%),
    radial-gradient(900px 420px at 100% 0%, rgba(197, 160, 70, 0.12), transparent 55%),
    var(--bg);
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.icon { display: inline-block; vertical-align: -0.2em; flex-shrink: 0; }
.page-title {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0;
  font-size: 1.2rem;
  color: var(--brand-navy);
}
.page-title .icon { color: var(--brand-navy); }

.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  background: #FFFFFF;
  color: var(--brand-navy);
  padding: 1rem 0.85rem 1.2rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  box-shadow: 4px 0 24px rgba(43, 61, 126, 0.04);
}
.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.2rem 0.35rem 0.65rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.45rem;
}
.brand img {
  display: block;
  width: min(100%, 148px);
  height: auto;
}
.nav a {
  display: flex; align-items: center; gap: 0.5rem;
  color: var(--brand-navy);
  padding: 0.38rem 0.6rem;
  border-radius: 7px;
  margin-bottom: 0.06rem;
  text-decoration: none;
  font-size: var(--fs-sm);
  font-weight: 500;
  line-height: 1.2;
}
.nav a .icon { color: var(--brand-navy); opacity: 0.85; width: 16px; height: 16px; }
.nav a:hover {
  background: rgba(112, 193, 227, 0.16);
  text-decoration: none;
}
.nav a.active {
  background: rgba(0, 168, 89, 0.12);
  color: var(--brand-green);
  outline: 1px solid rgba(0, 168, 89, 0.28);
  font-weight: 600;
}
.nav a.active .icon { color: var(--brand-green); opacity: 1; }
.nav .section {
  margin: 0.55rem 0.55rem 0.22rem;
  font-size: 0.64rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}
.topbar-user {
  color: var(--muted);
  font-size: 0.88rem;
  text-decoration: none;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-user:hover { color: var(--brand-navy); text-decoration: none; }
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  color: var(--brand-navy);
  background: #EEF2F8;
  text-decoration: none;
}
.btn-icon:hover {
  background: rgba(112, 193, 227, 0.22);
  color: var(--brand-navy);
  text-decoration: none;
}
.topbar-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid rgba(0, 168, 89, 0.35);
  display: inline-flex;
}
.topbar-avatar img { width: 100%; height: 100%; object-fit: cover; }
.conta-avatar-wrap {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}
.conta-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: #EEF2F8;
  color: var(--brand-navy);
  display: grid;
  place-items: center;
  overflow: hidden;
  font-size: 1.6rem;
  font-weight: 700;
  border: 2px solid var(--border);
  flex-shrink: 0;
}
.conta-avatar img { width: 100%; height: 100%; object-fit: cover; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.9rem 1.4rem; background: rgba(255,255,255,0.86);
  border-bottom: 1px solid var(--border); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20;
}
.topbar h1,
.topbar .page-title { margin: 0; font-size: 1.2rem; color: var(--brand-navy); }
.content { padding: 1.2rem 1.4rem 2rem; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.1rem;
}
.grid { display: grid; gap: 1rem; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.kpi { padding: 1rem; }
.kpi .label { color: var(--muted); font-size: 0.85rem; }
.kpi .value { font-size: 1.35rem; font-weight: 700; color: var(--brand-navy); margin-top: 0.25rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  border: none; border-radius: 8px; padding: 0.55rem 0.95rem; cursor: pointer;
  font-family: inherit;
  font-weight: 650;
  font-size: var(--fs);
  line-height: 1.25;
  text-decoration: none;
}
.btn .icon {
  flex-shrink: 0;
  width: 1em;
  height: 1em;
}
.btn span { line-height: 1.2; }
.btn:hover { filter: brightness(1.05); text-decoration: none; }
.btn:disabled,
.btn[disabled] {
  background: #C5CDD8 !important;
  color: #6B778C !important;
  cursor: not-allowed;
  filter: none;
  opacity: 1;
  box-shadow: none;
  pointer-events: none;
}
.btn:disabled:hover,
.btn[disabled]:hover {
  filter: none;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-cta { background: var(--brand-gold); color: #fff; }
.btn-cta:hover { filter: brightness(1.06); }
.btn-pre { background: var(--status-pre); color: #fff; }
.btn-ok { background: var(--status-approved); color: #fff; }
.btn-green { background: var(--brand-green); color: #fff; }
.btn-muted { background: #E8EDF5; color: var(--text); }
.btn-danger { background: #B42318; color: #fff; }
.btn-pdf { background: #C62828; color: #fff; }
.btn-pdf:hover { filter: brightness(1.06); }
.btn-sm { padding: 0.35rem 0.65rem; font-size: var(--fs-sm); }

.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
.table-wrap-clean { overflow: visible; }
table.data { width: 100%; border-collapse: collapse; min-width: 720px; background: #fff; }
table.data.table-clean { min-width: 0; table-layout: fixed; }
table.data.table-clean th,
table.data.table-clean td {
  padding: 0.7rem 0.9rem;
  vertical-align: middle;
}
table.data.table-clean .cell-primary {
  font-weight: 600;
  color: var(--brand-navy);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
table.data.table-clean .cell-meta {
  margin-top: 0.15rem;
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
table.data.table-clean .col-contact {
  width: 9.5rem;
  white-space: nowrap;
  color: var(--text);
}
table.data.table-clean .col-actions {
  width: 11.5rem;
  text-align: right;
}
table.data.table-clean .row-actions {
  display: inline-flex;
  gap: 0.4rem;
  justify-content: flex-end;
  flex-wrap: nowrap;
}
table.data th, table.data td {
  padding: 0.55rem 0.65rem; border-bottom: 1px solid var(--border);
  text-align: left; font-size: var(--fs); white-space: nowrap;
}
table.data th {
  background: #E8ECF1;
  color: #1F2937;
  font-weight: 700;
  position: sticky;
  top: 0;
  z-index: 1;
  border-bottom: 1px solid #D5DBE3;
}
table.data tbody tr:nth-child(odd) td { background: #fff; }
table.data tbody tr:nth-child(even) td { background: #F3F5F8; }
table.data tbody tr:hover td { background: #E9EEF5; }
table.data td.sticky, table.data th.sticky { position: sticky; left: 0; background: inherit; z-index: 2; }

.form-row { display: grid; gap: 0.85rem; margin-bottom: 0.85rem; min-width: 0; }
.form-row > * { min-width: 0; max-width: 100%; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row.cols-4 { grid-template-columns: repeat(4, 1fr); }
.form-row.cols-nome-rg { grid-template-columns: minmax(0, 45fr) minmax(0, 40fr) minmax(0, 15fr); }
label { display: block; font-size: var(--fs-sm); color: var(--muted); margin-bottom: 0.25rem; }
.input, select, textarea, button {
  font-family: inherit;
  font-size: var(--fs);
}
.input, select, textarea {
  width: 100%; max-width: 100%; box-sizing: border-box;
  border: none; border-bottom: 1.5px solid #B7C2D3;
  background: transparent; padding: 0.45rem 0.1rem; color: var(--text);
}
.input:focus, select:focus, textarea:focus {
  outline: none; border-bottom-color: var(--primary);
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  width: max-content;
  max-width: 100%;
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  font-size: var(--fs-xs);
  font-weight: 700;
  line-height: 1.2;
  border: 1px solid transparent;
  overflow: hidden;
  background-clip: padding-box;
  vertical-align: middle;
  box-sizing: border-box;
}
.status-pill {
  gap: 0.4rem;
  padding: 0.32rem 0.7rem 0.32rem 0.5rem;
  border-radius: 999px;
}
.status-pill .icon {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
}
.status-pill-text {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  min-width: 0;
  flex: 0 1 auto;
}
.status-pill-text strong {
  font-size: var(--fs-sm);
  font-weight: 700;
  line-height: 1.15;
  white-space: nowrap;
}
.status-pill-text em {
  display: block;
  font-style: normal;
  font-size: 0.68rem;
  font-weight: 500;
  opacity: 0.88;
  white-space: nowrap;
  line-height: 1.2;
}
.status-pill-extra {
  flex-shrink: 0;
  margin-left: 0.1rem;
  padding-left: 0.45rem;
  border-left: 1px solid currentColor;
  opacity: 0.85;
  font-weight: 650;
  white-space: nowrap;
}
.pill-ok {
  background-color: rgba(0, 168, 89, 0.14);
  color: #067647;
  border-color: rgba(0, 168, 89, 0.28);
}
.pill-pre {
  background-color: rgba(214, 69, 69, 0.12);
  color: #b42318;
  border-color: rgba(214, 69, 69, 0.28);
}
.pill-draft {
  background-color: rgba(43, 61, 126, 0.12);
  color: #2B3D7E;
  border-color: rgba(43, 61, 126, 0.28);
}
.pill-cancel {
  background-color: #F2F4F7;
  color: #667085;
  border-color: #E4E7EC;
}
table.data td .status-pill,
.toolbar .status-pill {
  width: max-content;
  max-width: none;
}
table.data .status-pill-text em {
  display: none;
}
table.data .status-pill {
  padding: 0.22rem 0.55rem;
}

.flash { padding: 0.7rem 0.9rem; border-radius: 8px; margin-bottom: 0.9rem; }
.flash-success { background: #E8F8EF; color: #067647; border: 1px solid #ABEFC6; }
.flash-error { background: #FEF3F2; color: #B42318; border: 1px solid #FECDCA; }

.toolbar {
  display: flex;
  gap: 0.6rem;
  flex-wrap: nowrap;
  align-items: center;
  margin-bottom: 1rem;
  min-width: 0;
}
.filter-bar {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.5rem;
  flex: 1 1 auto;
  min-width: 0;
}
.filter-bar .input,
.filter-bar select {
  flex: 1 1 0;
  min-width: 0;
  width: auto;
}
.filter-bar .btn,
.filter-bar a.btn {
  flex: 0 0 auto;
  white-space: nowrap;
}

/* ===== Tabs ===== */
.tabs {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
  border-bottom: 1px solid var(--border);
}
.tab-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: var(--fs);
  font-weight: 650;
  padding: 0.65rem 0.9rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab-btn:hover { color: var(--brand-navy); }
.tab-btn.is-active {
  color: var(--brand-navy);
  border-bottom-color: var(--brand-green);
}
.tab-panel { display: none; }
.tab-panel.is-active { display: block; }
.footer-actions {
  display: flex; gap: 0.55rem; flex-wrap: wrap; margin-top: 1rem;
  padding-top: 0.9rem; border-top: 1px solid var(--border);
}
.staff-only-note { color: var(--status-pre); font-size: 0.75rem; font-weight: 700; }
.label-with-tip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.field-tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--status-pre);
  cursor: help;
  outline: none;
}
.field-tip .icon {
  width: 14px;
  height: 14px;
}
.field-tip-bubble {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%) translateY(4px);
  min-width: 11rem;
  max-width: 16rem;
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  background: #1F2937;
  color: #fff;
  font-size: var(--fs-xs);
  font-weight: 600;
  line-height: 1.35;
  white-space: nowrap;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.22);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s ease;
  z-index: 40;
}
.field-tip-bubble::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -5px;
  border: 5px solid transparent;
  border-top-color: #1F2937;
}
.field-tip:hover .field-tip-bubble,
.field-tip:focus .field-tip-bubble,
.field-tip:focus-within .field-tip-bubble {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

.login-page {
  min-height: 100vh; display: grid; place-items: center; padding: 1rem;
  background:
    linear-gradient(145deg, rgba(43,61,126,0.94), rgba(43,61,126,0.88) 45%, rgba(0,168,89,0.55)),
    radial-gradient(circle at 18% 18%, rgba(112,193,227,0.35), transparent 42%);
}
.login-card {
  width: min(440px, 100%); background: #fff; border-radius: 16px;
  padding: 1.5rem 1.6rem 1.7rem; box-shadow: 0 24px 55px rgba(20,30,70,0.28);
}
.login-brand {
  display: flex;
  justify-content: center;
  margin-bottom: 1.1rem;
}
.login-brand img {
  width: min(260px, 100%);
  height: auto;
  display: block;
}
.login-card h1 { margin: 0 0 0.2rem; color: var(--brand-navy); }
.login-card .sub { color: var(--brand-green); font-weight: 700; margin-bottom: 1.2rem; }

.menu-toggle { display: none; background: var(--primary); color: #fff; border: 0; border-radius: 8px; padding: 0.45rem 0.7rem; }

@media (max-width: 980px) {
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
  .form-row.cols-4, .form-row.cols-3, .form-row.cols-nome-rg { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 820px) {
  .sidebar {
    position: fixed; left: -280px; z-index: 40; transition: left .2s ease;
  }
  .sidebar.open { left: 0; }
  .menu-toggle { display: inline-flex; }
  .grid-4, .form-row.cols-2, .form-row.cols-3, .form-row.cols-4, .form-row.cols-nome-rg { grid-template-columns: 1fr; }
}

/* ===== WhatsApp conexão ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.28rem 0.7rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
}
.badge-ok { background: rgba(0, 168, 89, 0.12); color: #007a41; }
.badge-warn { background: rgba(197, 160, 70, 0.18); color: #8a6a1a; }
.badge-danger { background: rgba(214, 69, 69, 0.12); color: #b42318; }
.wa-predio-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}
.wa-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}
.wa-connection-hint { font-size: 0.9rem; max-width: 46rem; }
.wa-phone { margin: 0.65rem 0 0; font-size: 0.88rem; }
.wa-error {
  margin: 0.5rem 0 0;
  color: #b42318;
  font-size: 0.85rem;
}
.wa-qr-modal { text-align: center; }
.wa-qr-hint { margin: 0 0 1rem; font-size: 0.9rem; }
.wa-qr-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 260px;
  margin: 0 auto 1rem;
  padding: 1rem;
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
}
.wa-qr-img {
  width: min(240px, 100%);
  height: auto;
  background: #fff;
  padding: 10px;
  border-radius: 10px;
  box-shadow: 0 4px 18px rgba(43, 61, 126, 0.08);
}
.wa-qr-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  color: var(--muted);
  font-size: 0.9rem;
}
.wa-qr-spinner[hidden] { display: none !important; }
.wa-spinner-dot {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--brand-green);
  border-radius: 50%;
  animation: wa-spin 0.7s linear infinite;
}
@keyframes wa-spin { to { transform: rotate(360deg); } }
.wa-qr-status { margin: 0; font-size: 0.9rem; }
.wa-qr-error {
  margin: 0.75rem 0 0;
  color: #b42318;
  font-size: 0.88rem;
}
.wa-qr-error[hidden] { display: none !important; }
.muted { color: var(--muted); }

/* ===== Page loader (AJAX) ===== */
.page-loader {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(43, 61, 126, 0.28);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.page-loader.is-visible { display: flex; }
.page-loader-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
  padding: 1.35rem 1.6rem;
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow);
  min-width: 180px;
}
.page-loader-spin {
  width: 34px;
  height: 34px;
  border: 3px solid var(--border);
  border-top-color: var(--brand-green);
  border-radius: 50%;
  animation: wa-spin 0.7s linear infinite;
}
.page-loader-text {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--brand-navy);
}
body.is-loading { cursor: progress; }

/* ===== Editor de templates (Lembretes / WhatsApp style) ===== */
.wa-lembrete-card .wa-section-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--brand-navy);
}
.wa-ativo-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.wa-ativo-toggle input { accent-color: var(--brand-green); width: 16px; height: 16px; }
.wa-editor {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
}
.wa-toolbar {
  display: flex;
  gap: 0.25rem;
  padding: 0.5rem 0.65rem;
  border-bottom: 1px solid var(--border);
  background: #EEF4FB;
}
.wa-tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--brand-navy);
  cursor: pointer;
}
.wa-tool:hover { background: rgba(43, 61, 126, 0.1); }
.wa-tool .icon { width: 16px; height: 16px; }
.wa-compose {
  min-height: 160px;
  max-height: 340px;
  overflow-y: auto;
  padding: 0.9rem 1rem;
  line-height: 1.55;
  font-size: 0.98rem;
  outline: none;
  white-space: pre-wrap;
  word-break: break-word;
  background: #F7FBFF;
  color: var(--text);
}
.wa-compose:focus {
  box-shadow: inset 0 0 0 2px rgba(112, 193, 227, 0.45);
}
.wa-compose strong,
.wa-compose b { font-weight: 700; }
.wa-compose em,
.wa-compose i { font-style: italic; }
.wa-compose s { text-decoration: line-through; opacity: 0.85; }
.wa-compose code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
  background: rgba(43, 61, 126, 0.08);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}
.wa-tag-chip {
  display: inline-flex;
  align-items: center;
  margin: 0 0.15em;
  padding: 0.12em 0.55em;
  border-radius: 999px;
  background: #D6EBFA;
  color: #1E4F7A;
  font-size: 0.82em;
  font-weight: 600;
  font-style: normal;
  text-decoration: none;
  vertical-align: baseline;
  user-select: none;
  cursor: default;
}
.wa-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  padding: 0.65rem 0.85rem;
  border-top: 1px solid var(--border);
  background: #EEF4FB;
}
.wa-tags-label {
  font-size: 0.78rem;
  color: var(--muted);
  margin-right: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 700;
}
.wa-tags-hint {
  flex: 1 1 100%;
  margin: 0.35rem 0 0;
  font-size: 0.78rem;
}
.wa-tag-btn {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 999px;
  padding: 0.28rem 0.7rem;
  font-size: 0.82rem;
  cursor: pointer;
  line-height: 1.2;
  font-weight: 600;
}
.wa-tag-btn:hover {
  border-color: var(--accent-cyan);
  color: var(--brand-navy);
  background: #F7FBFF;
}
.wa-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.85rem;
}
.wa-form-actions .btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.wa-section-title {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  font-weight: 600;
}

/* ===== Operação: rows compactas (máx. 2 linhas) ===== */
.op-rows-wrap {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: visible;
  margin-bottom: 1rem;
  background: #fff;
  position: relative;
  z-index: 1;
}
.op-rows-head {
  display: grid;
  gap: 0.45rem;
  align-items: center;
  padding: 0.55rem 0.75rem;
  background: #E8ECF1;
  color: #1F2937;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 1px solid #D5DBE3;
}
.op-rows-head.is-cheque {
  grid-template-columns: 7.2rem 6.5rem minmax(8rem, 1.3fr) minmax(7rem, 1.1fr) 5.5rem 5.5rem 4.8rem minmax(11rem, 1fr) 2.4rem;
}
.op-rows-head.is-titulo {
  grid-template-columns: 7.2rem 6.5rem minmax(8rem, 1.3fr) minmax(8rem, 1.1fr) 4.8rem minmax(11rem, 1fr) 2.4rem;
}
.op-rows-head .op-head-metrics { opacity: 0.75; }
.op-itens-lista { display: flex; flex-direction: column; position: relative; }
.op-row {
  position: relative;
  z-index: 1;
  border-bottom: 1px solid #E3E8F0;
  padding: 0.45rem 0.75rem 0.5rem;
}
.op-row:last-child { border-bottom: 0; }
.op-row:nth-child(odd) { background: #fff; }
.op-row:nth-child(even) { background: #F3F5F8; }
.op-row:hover { background: #E9EEF5; }
.op-row:has(.ss-wrap.is-open) {
  z-index: 80;
}
.op-row.is-flash {
  outline: 2px solid rgba(112, 193, 227, 0.55);
  outline-offset: -2px;
}
.op-row-line {
  display: grid;
  gap: 0.45rem;
  align-items: center;
  min-width: 0;
}
.op-row.is-cheque .op-row-line-inputs {
  grid-template-columns: 7.2rem 6.5rem minmax(8rem, 1.3fr) minmax(7rem, 1.1fr) 5.5rem 5.5rem 4.8rem 2.4rem;
}
.op-row.is-titulo .op-row-line-inputs {
  grid-template-columns: 7.2rem 6.5rem minmax(8rem, 1.3fr) minmax(8rem, 1.1fr) 4.8rem 2.4rem;
}
.op-row-line-calc {
  grid-template-columns: auto auto auto 1fr;
  margin-top: 0.35rem;
  padding-top: 0.35rem;
  border-top: 1px dashed #D7DEE8;
}
.op-cell { min-width: 0; }
.op-cell .input,
.op-cell select,
.op-cell .ss-input {
  width: 100%;
  font-size: var(--fs);
  padding: 0.28rem 0.1rem;
  border-bottom-width: 1px;
  background: transparent;
}
.op-cell .ss-wrap { z-index: 2; }
.op-cell .ss-wrap.is-open { z-index: 90; }
.op-cell-action {
  display: flex;
  justify-content: flex-end;
}
.op-cell-action .btn-remove {
  width: 28px;
  height: 28px;
  padding: 0;
  line-height: 1;
}
.op-calc-item {
  display: inline-flex;
  align-items: baseline;
  gap: 0.35rem;
  font-size: 0.82rem;
  min-width: 0;
}
.op-calc-item em {
  font-style: normal;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  font-weight: 700;
}
.op-calc-item strong {
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}
.op-calc-item.is-receive strong { color: var(--brand-green); }
.op-row-index {
  justify-self: end;
  font-size: 0.75rem;
  font-weight: 600;
}
.op-totais {
  position: relative;
  z-index: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.75rem 1.25rem;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  border-radius: 10px;
  background: #F3F5F8;
  border: 1px solid var(--border);
}
.op-metric {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 140px;
}
.op-metric-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 700;
}
.op-metric strong {
  font-size: 0.95rem;
  color: var(--text);
  font-weight: 700;
}
.op-metric-highlight {
  padding: 0.35rem 0.55rem;
  border-radius: 8px;
  background: rgba(0, 168, 89, 0.08);
}
.op-metric-highlight strong { color: var(--brand-green); }
@media (max-width: 1100px) {
  .op-rows-wrap { overflow-x: auto; }
  .op-rows-head,
  .op-row-line-inputs,
  .op-row-line-calc { min-width: 860px; }
}

/* ===== Vencimentos ===== */
.venc-total-bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.venc-total-label {
  font-size: var(--fs-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.venc-total-value {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--brand-navy);
}
.venc-day-card {
  margin-bottom: 0.8rem;
  padding: 0;
  overflow: hidden;
}
.venc-day-head {
  padding: 0.55rem 0.9rem;
  background: #E8ECF1;
  color: #1F2937;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 1px solid #D5DBE3;
}
.venc-day-list { padding: 0 0.9rem; }
.venc-day-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--border);
}
.venc-day-row:last-child { border-bottom: 0; }
.venc-day-value {
  color: var(--text);
  font-weight: 700;
  white-space: nowrap;
}

/* ===== WhatsApp teste ===== */
.wa-test-hint { margin: 0 0 1rem; font-size: 0.9rem; }
.wa-test-label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.wa-test-phones {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  min-height: 48px;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #F7F9FC;
  cursor: text;
}
.wa-test-phones input {
  flex: 1 1 140px;
  min-height: 36px;
  width: auto;
  border: 0 !important;
  border-bottom: 0 !important;
  background: transparent;
  padding: 0.2rem 0.35rem;
  box-shadow: none;
}
.wa-test-phones input:focus { outline: none; }
.wa-test-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: #d1fae5;
  color: #047857;
  border-radius: 999px;
  padding: 0.28rem 0.45rem 0.28rem 0.7rem;
  font-weight: 700;
  font-size: 0.85rem;
}
.wa-test-chip button {
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0 0.15rem;
}
.wa-test-help { margin: 0.45rem 0 0; font-size: 0.78rem; }
.wa-test-warn {
  margin: 0.45rem 0 0;
  color: #b45309;
  font-size: 0.78rem;
  font-weight: 600;
}
.wa-test-warn[hidden] { display: none; }
.wa-test-feedback { min-height: 1.2rem; margin: 0.65rem 0 0; font-size: 0.88rem; font-weight: 700; }
.wa-test-feedback.is-error { color: #B42318; }
.wa-test-feedback.is-ok { color: #067647; }
.wa-test-feedback.is-muted { color: var(--muted); font-weight: 600; }
.wa-test-actions { display: flex; gap: 0.75rem; margin-top: 1.1rem; }
.wa-test-actions .btn { flex: 1; }
.wa-test-preview {
  margin-top: 0.75rem;
  padding: 0.75rem 0.85rem;
  border-radius: 10px;
  background: #F3F5F8;
  border: 1px solid var(--border);
  white-space: pre-wrap;
  font-size: 0.88rem;
  line-height: 1.45;
  max-height: 180px;
  overflow: auto;
}
