:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --line: #d8dde3;
  --text: #17212b;
  --muted: #5b6773;
  --accent: #1246a0;
  --accent-2: #0b2f6b;
  --ok: #1f7a1f;
  --warn: #996f00;
  --soft: #eef3fb;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 Arial, Helvetica, sans-serif; }
a { color: var(--accent); text-decoration: none; }
.wrap { width: min(1380px, 95vw); margin: 0 auto; }
.topbar { background: #101820; color: #fff; padding: 18px 0; box-shadow: 0 2px 8px rgba(0,0,0,.1); }
.topbar h1 { margin: 0 0 4px; font-size: 24px; }
.topbar p { margin: 0; color: #c6d0da; }
.menu { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.menu a { color: #fff; padding: 8px 12px; border-radius: 8px; background: rgba(255,255,255,.08); }
.page { padding: 24px 0 36px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px; box-shadow: 0 4px 16px rgba(17, 24, 39, 0.04); }
.grid { display: grid; gap: 18px; }
.cards-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.two-col { grid-template-columns: 1.1fr .9fr; margin-top: 18px; }
.metric span { display: block; color: var(--muted); margin-bottom: 6px; }
.metric strong { font-size: 28px; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.section-head h2, .card h2 { margin: 0 0 12px; font-size: 20px; }
.btn { display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; background: #fff; color: var(--text); cursor: pointer; }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent-2); }
.btn.danger { background: #8f2020; color: #fff; border-color: #6f1414; }
.btn.small { padding: 7px 10px; font-size: 13px; }
.flash { padding: 12px 14px; border-radius: 10px; margin-bottom: 16px; }
.flash.success { background: #eaf8ea; color: #155d15; }
.flash.error { background: #fdecec; color: #8f2020; }
label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; color: var(--muted); }
label > span { font-size: 12px; }
input, textarea, select { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--text); font: inherit; }
textarea { min-height: 90px; resize: vertical; }
.form-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.stack { display: grid; gap: 12px; }
.gap-lg { gap: 18px; }
.actions { display: flex; justify-content: flex-end; }
.muted { color: var(--muted); }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { border-bottom: 1px solid var(--line); padding: 10px 8px; text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
.inline-form { display: grid; grid-template-columns: 140px 110px 120px 150px 1fr auto; gap: 8px; align-items: center; }
.badge { display: inline-flex; align-items: center; padding: 5px 9px; border-radius: 999px; background: var(--soft); font-size: 12px; font-weight: 700; }
.badge.quitada { color: var(--ok); }
.badge.em-aberto { color: var(--warn); }
.badge.parcial { color: var(--accent); }
.print-page { background: #dfe5eb; }
.paper { width: min(900px, 92vw); margin: 18px auto 40px; background: #fff; padding: 42px 52px; box-shadow: 0 12px 32px rgba(0,0,0,.12); }
.paper h1 { text-align: center; font-size: 24px; margin: 0 0 22px; }
.paper h2 { font-size: 17px; margin-top: 18px; }
.paper p { margin: 8px 0; text-align: justify; }
.signature-space { margin-top: 34px !important; }
.signatures { display: grid; grid-template-columns: repeat(2, 1fr); gap: 36px; margin-top: 48px; }
.signatures.three { grid-template-columns: repeat(2, 1fr); margin-top: 36px; }
.signatures.one { grid-template-columns: 1fr; }
.signature-box { text-align: center; }
.line { border-top: 1px solid #000; margin-bottom: 8px; }
.print-actions { width: min(900px, 92vw); margin: 18px auto 0; display: flex; gap: 10px; justify-content: flex-end; }
.receipt-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin: 16px 0 12px; }
.receipt-grid div { border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: #fafbfd; }
.receipt-grid span { display: block; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; margin-bottom: 6px; }
.receipt-grid strong { font-size: 18px; }
.actions-inline { display: flex; gap: 10px; }
.editor-help { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; color: var(--muted); }
.editor-help code { background: var(--soft); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; color: var(--text); }
.editor-textarea { min-height: 560px; font-family: "Courier New", monospace; font-size: 13px; line-height: 1.45; }
.actions.split { justify-content: space-between; }
.preview-paper { width: 100%; margin: 0; box-shadow: none; padding: 28px 32px; background: #fff; border: 1px solid var(--line); }
.contract-paper h1 { text-align: center; font-size: 24px; margin: 0 0 22px; }
.contract-paper h2 { font-size: 17px; margin-top: 18px; }
.contract-paper p { margin: 8px 0; text-align: justify; }
.subtle-card { background: #fbfcfe; }
.editor-layout { display: grid; grid-template-columns: 300px 1fr; gap: 18px; align-items: start; }
.token-panel.card { padding: 16px; }
.token-panel h3 { margin: 0 0 8px; font-size: 16px; }
.small-note { font-size: 12px; }
.token-list { display: flex; flex-wrap: wrap; gap: 8px; }
.token-btn { justify-content: flex-start; text-align: left; padding: 8px 10px; }
.required-token { border-color: #c48a00; background: #fff8e2; }
.editor-help-box { margin-top: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.editor-help-box ul { margin: 8px 0 0 18px; padding: 0; }
.editor-toolbar { display: flex; gap: 8px; flex-wrap: wrap; }
.rich-editor { min-height: 560px; border: 1px solid var(--line); border-radius: 12px; padding: 16px; background: #fff; line-height: 1.55; }
.rich-editor:focus { outline: 2px solid #d8e4fb; border-color: var(--accent); }
.rich-editor h1, .rich-editor h2, .rich-editor h3 { margin: 0 0 12px; }
.rich-editor p { margin: 0 0 12px; }
.var-chip { display: inline-flex; align-items: center; padding: 3px 8px; border-radius: 999px; background: #eef1f5; border: 1px solid #c9d2dc; color: #22313f; font-weight: 700; white-space: nowrap; margin: 0 2px; }
.compact-grid { margin-top: 18px; }
.top-gap { margin-top: 8px; }
.mini-panel { margin-top: 8px; }
.mini-panel summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.badge.quitada-por-antecipacao { color: #0c5e55; background: #e6fbf7; }
.badge.abatida-parcialmente { color: #7a4c00; background: #fff5db; }
.responsive-head { align-items: start; }
.action-row { margin-bottom: 6px; }
.flow-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; align-items: end; min-width: 0; }
.flow-form > label, .flow-form-actions { min-width: 0; }
.flow-form .wide-field { grid-column: 1 / -1; }
.flow-form-actions { display: flex; align-items: end; justify-content: flex-end; grid-column: 1 / -1; }
.receive-form { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.reopen-form { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.compact-flow { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
@media (max-width: 1080px) {
  .cards-4, .two-col, .form-grid { grid-template-columns: 1fr 1fr; }
  .inline-form { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 980px) { .editor-layout { grid-template-columns: 1fr; } }
@media (max-width: 720px) {
  .cards-4, .two-col, .form-grid, .receipt-grid, .signatures, .flow-form, .compact-flow { grid-template-columns: 1fr; }
  .flow-form .wide-field, .compact-flow .wide-field, .flow-form-actions { grid-column: span 1; }
  .responsive-head { flex-direction: column; }
}
@media print {
  body { background: #fff; }
  .no-print { display: none !important; }
  .paper { width: 100%; margin: 0; box-shadow: none; padding: 10mm 12mm; }
  @page { size: A4; margin: 10mm; }
}

.cards-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.metric-highlight { border-color: #c9d9f2; background: linear-gradient(180deg, #f8fbff 0%, #eef5ff 100%); }
.metric-highlight small { display:block; margin-top:8px; color: var(--muted); font-size: 12px; line-height: 1.4; }
.metric-breakdown h3 { margin: 0 0 10px; font-size: 18px; }
.metric-breakdown ul { margin: 0; padding-left: 18px; display: grid; gap: 8px; }
.metric-breakdown li { color: var(--text); }
@media (max-width: 980px) {
  .cards-2, .cards-4, .two-col, .editor-layout { grid-template-columns: 1fr; }
}

.action-row + .flow-form, .mini-panel .flow-form { margin-right: 0; }
.table-wrap td { min-width: 0; }


.installments-table .installment-summary-row td { border-bottom: none; }
.installments-table .installment-actions-row td { padding-top: 0; }
.parcel-actions-shell {
  display: grid;
  gap: 10px;
  padding: 10px 0 14px;
}
.parcel-actions-top {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}
.parcel-form-grid {
  display: grid;
  grid-template-columns: 1.05fr 1fr 0.9fr 1.1fr;
  gap: 12px;
  align-items: end;
}
.parcel-form-grid > label,
.parcel-form-actions {
  min-width: 0;
}
.parcel-form-grid .span-3 { grid-column: span 3; }
.parcel-form-grid .span-2 { grid-column: span 2; }
.parcel-form-actions {
  display: flex;
  align-items: end;
  justify-content: flex-end;
}
.full-width-panel { width: 100%; }
.full-width-panel summary { margin-bottom: 2px; }
.reopen-grid .parcel-form-actions,
.parcel-form-grid .parcel-form-actions {
  grid-column: auto;
}
@media (max-width: 1180px) {
  .parcel-form-grid {
    grid-template-columns: 1fr 1fr;
  }
  .parcel-form-grid .span-3,
  .parcel-form-grid .span-2 {
    grid-column: span 2;
  }
  .parcel-form-actions {
    grid-column: span 2;
    justify-content: flex-start;
  }
}
@media (max-width: 720px) {
  .parcel-form-grid {
    grid-template-columns: 1fr;
  }
  .parcel-form-grid .span-3,
  .parcel-form-grid .span-2,
  .parcel-form-actions {
    grid-column: span 1;
  }
}


/* v6.5 field sizing refinements */
.receive-grid-v65, .reopen-grid-v65 {
  grid-template-columns: 170px 160px 200px minmax(280px, 1fr);
  gap: 12px;
  align-items: end;
}
.receive-grid-v65 .field-notes, .reopen-grid-v65 .field-notes {
  grid-column: 1 / -2;
}
.receive-grid-v65 .field-submit, .reopen-grid-v65 .field-submit {
  grid-column: -2 / -1;
  justify-content: flex-end;
}
.receive-grid-v65 .field-date, .reopen-grid-v65 .field-date { min-width: 0; }
.receive-grid-v65 .field-money, .reopen-grid-v65 .field-money { min-width: 0; }
.receive-grid-v65 .field-method, .reopen-grid-v65 .field-method { min-width: 0; }
.receive-grid-v65 .field-reference, .reopen-grid-v65 .field-reference { min-width: 0; }
@media (max-width: 1240px) {
  .receive-grid-v65, .reopen-grid-v65 {
    grid-template-columns: 170px 160px 200px 1fr;
  }
}
@media (max-width: 1040px) {
  .receive-grid-v65, .reopen-grid-v65 {
    grid-template-columns: 1fr 1fr;
  }
  .receive-grid-v65 .field-reference, .reopen-grid-v65 .field-reference,
  .receive-grid-v65 .field-notes, .reopen-grid-v65 .field-notes,
  .receive-grid-v65 .field-submit, .reopen-grid-v65 .field-submit {
    grid-column: 1 / -1;
  }
  .receive-grid-v65 .field-submit, .reopen-grid-v65 .field-submit {
    justify-content: flex-start;
  }
}
@media (max-width: 720px) {
  .receive-grid-v65, .reopen-grid-v65 {
    grid-template-columns: 1fr;
  }
}


/* v6.7 compact receive/reopen rows */
.receive-grid-v65 {
  grid-template-columns: 158px 150px 190px 260px minmax(220px, 1fr) auto;
  gap: 12px;
  align-items: end;
}
.receive-grid-v65 .field-date { max-width: 158px; }
.receive-grid-v65 .field-money { max-width: 150px; }
.receive-grid-v65 .field-method { max-width: 190px; }
.receive-grid-v65 .field-reference { max-width: 260px; }
.receive-grid-v65 .field-notes {
  min-width: 180px;
}
.receive-grid-v65 .field-submit {
  grid-column: auto;
  justify-content: flex-end;
  align-self: end;
}
.receive-grid-v65 .field-notes input,
.reopen-grid-v65 .field-notes input,
.reopen-grid-v65 .field-reason input {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.receive-grid-v65 .field-notes input:focus,
.reopen-grid-v65 .field-notes input:focus,
.reopen-grid-v65 .field-reason input:focus {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}

.reopen-grid-v65 {
  grid-template-columns: 158px 150px 190px 240px minmax(220px, 1fr) auto;
  gap: 12px;
  align-items: end;
}
.reopen-grid-v65 .field-date { max-width: 158px; }
.reopen-grid-v65 .field-money { max-width: 150px; }
.reopen-grid-v65 .field-method { max-width: 190px; }
.reopen-grid-v65 .field-reference { max-width: 240px; }
.reopen-grid-v65 .field-reason { min-width: 180px; }
.reopen-grid-v65 .field-submit {
  grid-column: auto;
  justify-content: flex-end;
}
.reopen-grid-v65 .field-notes-full {
  grid-column: 1 / -1;
}

@media (max-width: 1320px) {
  .receive-grid-v65 {
    grid-template-columns: 158px 150px 190px 230px minmax(180px, 1fr) auto;
  }
  .reopen-grid-v65 {
    grid-template-columns: 158px 150px 190px 220px minmax(180px, 1fr) auto;
  }
}

@media (max-width: 1180px) {
  .receive-grid-v65,
  .reopen-grid-v65 {
    grid-template-columns: 1fr 1fr 1fr;
  }
  .receive-grid-v65 .field-reference,
  .receive-grid-v65 .field-notes,
  .receive-grid-v65 .field-submit,
  .reopen-grid-v65 .field-reference,
  .reopen-grid-v65 .field-reason,
  .reopen-grid-v65 .field-submit,
  .reopen-grid-v65 .field-notes-full {
    grid-column: auto;
    max-width: none;
  }
  .receive-grid-v65 .field-submit,
  .reopen-grid-v65 .field-submit {
    justify-content: flex-start;
  }
  .reopen-grid-v65 .field-notes-full {
    grid-column: 1 / -1;
  }
}

@media (max-width: 860px) {
  .receive-grid-v65,
  .reopen-grid-v65 {
    grid-template-columns: 1fr 1fr;
  }
  .receive-grid-v65 .field-reference,
  .receive-grid-v65 .field-notes,
  .receive-grid-v65 .field-submit,
  .reopen-grid-v65 .field-reference,
  .reopen-grid-v65 .field-reason,
  .reopen-grid-v65 .field-submit,
  .reopen-grid-v65 .field-notes-full {
    grid-column: 1 / -1;
  }
}

@media (max-width: 560px) {
  .receive-grid-v65,
  .reopen-grid-v65 {
    grid-template-columns: 1fr;
  }
  .receive-grid-v65 .field-submit,
  .reopen-grid-v65 .field-submit,
  .reopen-grid-v65 .field-notes-full {
    grid-column: 1 / -1;
  }
}


/* v6.8 compact one-line editors with focus expansion */
.receive-grid-v65 {
  grid-template-columns: 150px 138px 190px 240px minmax(240px, 1fr) auto;
  gap: 12px;
  align-items: end;
}
.receive-grid-v65 .field-date { max-width: 150px; }
.receive-grid-v65 .field-money { max-width: 138px; }
.receive-grid-v65 .field-method { max-width: 190px; }
.receive-grid-v65 .field-reference { max-width: 240px; }
.receive-grid-v65 .field-notes { min-width: 220px; }
.receive-grid-v65 .field-submit {
  grid-column: auto;
  justify-content: flex-end;
  align-self: end;
}

.reopen-grid-v65 {
  grid-template-columns: 150px 138px 190px 240px minmax(220px, 1fr) minmax(220px, 1fr) auto;
  gap: 12px;
  align-items: end;
}
.reopen-grid-v65 .field-date { max-width: 150px; }
.reopen-grid-v65 .field-money { max-width: 138px; }
.reopen-grid-v65 .field-method { max-width: 190px; }
.reopen-grid-v65 .field-reference { max-width: 240px; }
.reopen-grid-v65 .field-reason,
.reopen-grid-v65 .field-notes { min-width: 220px; }
.reopen-grid-v65 .field-submit {
  grid-column: auto;
  justify-content: flex-end;
}
.reopen-grid-v65 .field-notes-full { grid-column: auto; }

.expand-edit-field {
  position: relative;
  min-width: 0;
}
.expand-edit-field .inline-expand {
  min-height: 42px;
  height: 42px;
  max-height: 42px;
  resize: none;
  overflow: hidden;
  white-space: nowrap;
  line-height: 20px;
  padding-top: 10px;
  padding-bottom: 10px;
}
.expand-edit-field .inline-expand:focus {
  position: absolute;
  left: 0;
  top: 100%;
  margin-top: 6px;
  width: max(100%, 360px);
  min-height: 118px;
  max-height: 220px;
  height: 118px;
  z-index: 20;
  background: #fff;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  overflow: auto;
  white-space: pre-wrap;
}
.expand-edit-field.field-notes .inline-expand:focus,
.expand-edit-field.field-reason .inline-expand:focus {
  width: max(100%, 420px);
}

@media (max-width: 1280px) {
  .receive-grid-v65 {
    grid-template-columns: 150px 138px 170px 210px minmax(200px, 1fr) auto;
  }
  .reopen-grid-v65 {
    grid-template-columns: 150px 138px 170px 210px minmax(200px, 1fr) minmax(200px, 1fr) auto;
  }
}

@media (max-width: 1120px) {
  .receive-grid-v65,
  .reopen-grid-v65 {
    grid-template-columns: 1fr 1fr 1fr;
  }
  .receive-grid-v65 .field-reference,
  .receive-grid-v65 .field-notes,
  .receive-grid-v65 .field-submit,
  .reopen-grid-v65 .field-reference,
  .reopen-grid-v65 .field-reason,
  .reopen-grid-v65 .field-notes,
  .reopen-grid-v65 .field-submit {
    grid-column: auto;
    max-width: none;
  }
  .receive-grid-v65 .field-submit,
  .reopen-grid-v65 .field-submit {
    justify-content: flex-start;
  }
}
@media (max-width: 860px) {
  .receive-grid-v65,
  .reopen-grid-v65 {
    grid-template-columns: 1fr 1fr;
  }
  .receive-grid-v65 .field-reference,
  .receive-grid-v65 .field-notes,
  .receive-grid-v65 .field-submit,
  .reopen-grid-v65 .field-reference,
  .reopen-grid-v65 .field-reason,
  .reopen-grid-v65 .field-notes,
  .reopen-grid-v65 .field-submit {
    grid-column: 1 / -1;
  }
}
@media (max-width: 560px) {
  .receive-grid-v65,
  .reopen-grid-v65 {
    grid-template-columns: 1fr;
  }
  .receive-grid-v65 .field-submit,
  .reopen-grid-v65 .field-submit {
    grid-column: 1 / -1;
  }
}


/* v6.10 one-line layout with compact labels and stable expanded editor */
.receive-grid-v65 {
  grid-template-columns: 118px 102px 138px 180px minmax(210px, 1fr) auto;
  gap: 10px;
  align-items: end;
}
.receive-grid-v65 .field-date { max-width: 118px; }
.receive-grid-v65 .field-money { max-width: 102px; }
.receive-grid-v65 .field-method { max-width: 138px; }
.receive-grid-v65 .field-reference { max-width: 180px; }
.receive-grid-v65 .field-notes { min-width: 210px; }
.receive-grid-v65 .field-submit { grid-column: auto; justify-content: flex-end; }

.reopen-grid-v65 {
  grid-template-columns: 118px 102px 138px 180px minmax(180px, 1fr) minmax(180px, 1fr) auto;
  gap: 10px;
  align-items: end;
}
.reopen-grid-v65 .field-date { max-width: 118px; }
.reopen-grid-v65 .field-money { max-width: 102px; }
.reopen-grid-v65 .field-method { max-width: 138px; }
.reopen-grid-v65 .field-reference { max-width: 180px; }
.reopen-grid-v65 .field-reason,
.reopen-grid-v65 .field-notes { min-width: 180px; }
.reopen-grid-v65 .field-submit { grid-column: auto; justify-content: flex-end; }
.reopen-grid-v65 .field-notes-full { grid-column: auto; }

.receive-grid-v65 label > span,
.reopen-grid-v65 label > span {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  line-height: 1.15;
}

.expand-edit-field { min-width: 0; }
.expand-shell { position: relative; height: 40px; }
.expand-shell .inline-expand {
  position: absolute;
  inset: 0;
  min-height: 40px;
  height: 40px;
  max-height: 40px;
  resize: none;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  line-height: 18px;
  padding-top: 10px;
  padding-bottom: 10px;
  z-index: 1;
}
.expand-shell .inline-expand:focus {
  width: max(100%, 360px);
  min-height: 118px;
  height: 118px;
  max-height: 220px;
  white-space: pre-wrap;
  overflow: auto;
  text-overflow: clip;
  z-index: 30;
  background: #fff;
  box-shadow: 0 10px 24px rgba(0,0,0,.14);
}
.expand-edit-field.field-notes .inline-expand:focus,
.expand-edit-field.field-reason .inline-expand:focus {
  width: max(100%, 420px);
}

@media (max-width: 1260px) {
  .receive-grid-v65 {
    grid-template-columns: 118px 102px 138px 180px 1fr auto;
  }
  .reopen-grid-v65 {
    grid-template-columns: 118px 102px 138px 180px 1fr 1fr;
  }
  .reopen-grid-v65 .field-submit { grid-column: 1 / -1; justify-content: flex-start; }
}

@media (max-width: 980px) {
  .receive-grid-v65, .reopen-grid-v65 {
    grid-template-columns: 1fr 1fr 1fr;
  }
  .receive-grid-v65 .field-reference,
  .receive-grid-v65 .field-notes,
  .receive-grid-v65 .field-submit,
  .reopen-grid-v65 .field-reference,
  .reopen-grid-v65 .field-reason,
  .reopen-grid-v65 .field-notes,
  .reopen-grid-v65 .field-submit {
    grid-column: 1 / -1;
    max-width: none;
  }
  .receive-grid-v65 .field-submit,
  .reopen-grid-v65 .field-submit {
    justify-content: flex-start;
  }
}

@media (max-width: 640px) {
  .receive-grid-v65, .reopen-grid-v65 {
    grid-template-columns: 1fr;
  }
}


/* v6.12 final receive/reopen row correction */
.receive-grid-v65 {
  grid-template-columns: 118px 110px 150px 190px minmax(220px, 1fr) auto !important;
  gap: 10px !important;
  align-items: end !important;
}
.receive-grid-v65 .field-date,
.receive-grid-v65 .field-money,
.receive-grid-v65 .field-method,
.receive-grid-v65 .field-reference,
.receive-grid-v65 .field-notes,
.receive-grid-v65 .field-submit {
  grid-column: auto !important;
  min-width: 0 !important;
}
.receive-grid-v65 .field-notes { min-width: 220px !important; }
.receive-grid-v65 .field-submit {
  justify-content: flex-end !important;
  align-self: end !important;
}
.receive-grid-v65 .field-submit .btn.small.primary {
  padding: 8px 14px !important;
  min-width: 92px !important;
}
.receive-grid-v65 .field-reference > span,
.receive-grid-v65 .field-notes > span {
  margin-bottom: 6px;
}
.receive-grid-v65 .expand-shell {
  position: relative !important;
  height: 40px !important;
  overflow: visible !important;
}
.receive-grid-v65 .expand-shell .inline-expand {
  position: absolute !important;
  inset: 0 !important;
  min-height: 40px !important;
  height: 40px !important;
  max-height: 40px !important;
  resize: none !important;
  overflow: hidden !important;
  white-space: nowrap !important;
  text-overflow: ellipsis !important;
  line-height: 18px !important;
  padding-top: 10px !important;
  padding-bottom: 10px !important;
  z-index: 1 !important;
  border: 1px solid var(--line) !important;
  border-radius: 10px !important;
  background: #fff !important;
}
.receive-grid-v65 .expand-shell .inline-expand:focus {
  top: 0 !important;
  left: 0 !important;
  margin-top: 0 !important;
  width: max(100%, 320px) !important;
  min-height: 118px !important;
  height: 118px !important;
  max-height: 220px !important;
  white-space: pre-wrap !important;
  overflow: auto !important;
  text-overflow: clip !important;
  z-index: 30 !important;
  background: #fff !important;
  border: 1px solid var(--line) !important;
  border-radius: 10px !important;
  box-shadow: 0 10px 24px rgba(0,0,0,.10) !important;
}
.receive-grid-v65 .field-notes .expand-shell .inline-expand:focus {
  width: max(100%, 420px) !important;
}

/* Reabertura mantém mesma lógica visual, com linha única mais densa */
.reopen-grid-v65 {
  grid-template-columns: 118px 110px 150px 170px 170px minmax(220px, 1fr) auto !important;
  gap: 10px !important;
  align-items: end !important;
}
.reopen-grid-v65 .field-date,
.reopen-grid-v65 .field-money,
.reopen-grid-v65 .field-method,
.reopen-grid-v65 .field-reference,
.reopen-grid-v65 .field-reason,
.reopen-grid-v65 .field-notes,
.reopen-grid-v65 .field-submit {
  grid-column: auto !important;
  min-width: 0 !important;
}
.reopen-grid-v65 .field-submit { justify-content: flex-end !important; align-self: end !important; }
.reopen-grid-v65 .expand-shell {
  position: relative !important;
  height: 40px !important;
  overflow: visible !important;
}
.reopen-grid-v65 .expand-shell .inline-expand {
  position: absolute !important;
  inset: 0 !important;
  min-height: 40px !important;
  height: 40px !important;
  max-height: 40px !important;
  resize: none !important;
  overflow: hidden !important;
  white-space: nowrap !important;
  text-overflow: ellipsis !important;
  line-height: 18px !important;
  padding-top: 10px !important;
  padding-bottom: 10px !important;
  z-index: 1 !important;
  border: 1px solid var(--line) !important;
  border-radius: 10px !important;
  background: #fff !important;
}
.reopen-grid-v65 .expand-shell .inline-expand:focus {
  top: 0 !important;
  left: 0 !important;
  margin-top: 0 !important;
  width: max(100%, 320px) !important;
  min-height: 118px !important;
  height: 118px !important;
  max-height: 220px !important;
  white-space: pre-wrap !important;
  overflow: auto !important;
  text-overflow: clip !important;
  z-index: 30 !important;
  background: #fff !important;
  border: 1px solid var(--line) !important;
  border-radius: 10px !important;
  box-shadow: 0 10px 24px rgba(0,0,0,.10) !important;
}
.reopen-grid-v65 .field-notes .expand-shell .inline-expand:focus,
.reopen-grid-v65 .field-reason .expand-shell .inline-expand:focus {
  width: max(100%, 380px) !important;
}

@media (max-width: 1320px) {
  .receive-grid-v65 {
    grid-template-columns: 118px 110px 150px 170px minmax(180px, 1fr) auto !important;
  }
  .reopen-grid-v65 {
    grid-template-columns: 118px 110px 150px 160px 160px minmax(180px, 1fr) auto !important;
  }
}

@media (max-width: 1160px) {
  .receive-grid-v65,
  .reopen-grid-v65 {
    grid-template-columns: 1fr 1fr 1fr !important;
  }
  .receive-grid-v65 .field-reference,
  .receive-grid-v65 .field-notes,
  .receive-grid-v65 .field-submit,
  .reopen-grid-v65 .field-reference,
  .reopen-grid-v65 .field-reason,
  .reopen-grid-v65 .field-notes,
  .reopen-grid-v65 .field-submit {
    grid-column: 1 / -1 !important;
  }
  .receive-grid-v65 .field-submit,
  .reopen-grid-v65 .field-submit {
    justify-content: flex-start !important;
  }
}


.filter-grid {
  display: grid;
  grid-template-columns: 2fr 1.2fr .8fr 1fr 1fr auto;
  gap: 12px;
  align-items: end;
}
.filter-actions {
  display: flex;
  gap: 8px;
  align-items: end;
  justify-content: flex-end;
}
.pagination-bar {
  margin-top: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
@media (max-width: 1100px) {
  .filter-grid {
    grid-template-columns: 1fr 1fr 1fr;
  }
  .filter-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }
}
@media (max-width: 720px) {
  .filter-grid {
    grid-template-columns: 1fr;
  }
  .pagination-bar {
    flex-direction: column;
    align-items: flex-start;
  }
}

button[disabled]{opacity:.65;cursor:not-allowed;}


/* v6.14.2 validation + receipt layout */
.receipt-summary-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-top: 18px;
}
.receipt-summary-grid .metric { min-width: 0; }
.receipt-list-card { overflow: hidden; }
.receipt-list-table th,
.receipt-list-table td {
  white-space: normal;
  word-break: break-word;
}
.receipt-list-table td:last-child,
.receipt-list-table th:last-child { width: 120px; }
@media (max-width: 900px) {
  .receipt-summary-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .receipt-summary-grid { grid-template-columns: 1fr; }
}


/* v6.14.4 receipt validity list */
.receipt-list-table .status-badge.muted {
  background: #f1f5f9;
  color: #64748b;
}
.receipt-list-table td, .receipt-list-table th {
  vertical-align: middle;
}
.receipt-actions {
  display: inline-flex;
  gap: 8px;
  flex-wrap: nowrap;
}

.receipt-events-table .event-detail { min-width: 260px; white-space: normal; }
.receipt-events-table .status-badge.warning { background:#fff7ed; color:#b45309; }


/* v6.14.6 header cleanup for parcel events */
.page-head.actions-between {
  align-items: flex-start;
  gap: 16px;
}
.page-head.actions-between > div:first-child {
  min-width: 0;
  flex: 1 1 auto;
}
.page-head.actions-between .muted {
  max-width: 760px;
}
.page-head.actions-between .btn {
  white-space: nowrap;
  flex: 0 0 auto;
}
@media (max-width: 900px) {
  .page-head.actions-between {
    align-items: stretch;
  }
  .page-head.actions-between .muted {
    max-width: none;
  }
}

/* v7.0 multi-contrato */
.active-contract {
  margin-top: 6px;
  color: #e2e8f0;
  font-size: 0.92rem;
}
.contract-create-form {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(260px, 1fr) auto;
  gap: 12px;
  align-items: end;
}
.active-row {
  background: #f8fafc;
}
@media (max-width: 900px) {
  .contract-create-form {
    grid-template-columns: 1fr;
  }
}

/* v7.1 */
input[readonly] {
  background: #f8fafc;
  color: #0f172a;
}

/* v8.0 auth */
.auth-card {
  max-width: 760px;
  margin: 0 auto;
}

/* v8.0.1 auth screens */
.password-rules {
  display: grid;
  gap: 6px;
  margin-top: 4px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fafc;
}

.password-rules .rule {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  line-height: 1.3;
}

.password-rules .rule-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  font-weight: 800;
}

.password-rules .rule.bad {
  color: #b91c1c;
}

.password-rules .rule.ok {
  color: #15803d;
}

.password-rules .rule.bad .rule-icon {
  color: #dc2626;
}

.password-rules .rule.ok .rule-icon {
  color: #16a34a;
}

/* v8.1 users */
.temp-password-box code {
  font-size: 15px;
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}
.btn.warn {
  background: #f59e0b;
  color: #111827;
}


/* v8.3.1 - criação de usuários em linha única */
.user-create-grid {
  display: grid;
  grid-template-columns: minmax(190px, 1.1fr) minmax(220px, 1.1fr) minmax(150px, 0.8fr) minmax(210px, 0.9fr) auto;
  gap: 16px;
  align-items: end;
}

.user-create-grid label {
  min-width: 0;
}

.user-create-grid input,
.user-create-grid select {
  width: 100%;
  min-width: 0;
}

.user-create-grid .actions,
.user-create-grid button[type="submit"] {
  white-space: nowrap;
}

@media (max-width: 1100px) {
  .user-create-grid {
    grid-template-columns: 1fr 1fr;
  }
}


.error-page {
  max-width: 720px;
  margin: 32px auto;
  text-align: center;
}

.error-code {
  font-size: 3rem;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 12px;
  color: #334155;
}

.error-page .actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 20px;
}

.error-page .button.secondary {
  background: #64748b;
}
