:root {
  color-scheme: light;
  --navy: #17213a;
  --navy-2: #23304f;
  --gold: #8b651f;
  --gold-light: #d9bd7a;
  --paper: #fff;
  --bg: #eef1f5;
  --line: #d9dee7;
  --text: #182033;
  --muted: #667085;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

office-document-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: block;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.5;
}

button, input, select, textarea { font: inherit; }

.topbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 68px;
  padding: 10px 22px;
  border-bottom: 1px solid rgba(255,255,255,.1);
  background: var(--navy);
  color: #fff;
  box-shadow: 0 8px 28px rgba(23,33,58,.18);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}

.brand img {
  width: 40px;
  height: 40px;
  object-fit: contain;
}

.brand h1, .brand small { display: block; }
.brand h1 { margin: 0; font-family: Georgia, serif; font-size: 18px; }
.brand small { margin-top: 2px; color: #c8cfdd; font-size: 11px; }

.top-actions { display: flex; gap: 8px; }

.button, .mode-switch button {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 0 14px;
  font-weight: 750;
  cursor: pointer;
}

.button.primary { background: var(--gold); color: #fff; }
.button.secondary { border-color: rgba(255,255,255,.24); background: transparent; color: #fff; }
.button:hover, .mode-switch button:hover { filter: brightness(1.06); }

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 500px) minmax(520px, 1fr);
  min-height: calc(100vh - 68px);
}

.form-pane {
  padding: 18px;
  border-right: 1px solid var(--line);
  background: #f8f9fb;
  overflow: auto;
}

.mode-switch {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.mode-switch button {
  min-width: 0;
  border-color: transparent;
  padding: 0 8px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
}

.mode-switch button.is-active {
  background: var(--navy);
  color: #fff;
  box-shadow: 0 4px 12px rgba(23,33,58,.18);
}

form { display: grid; gap: 12px; margin-top: 14px; }

fieldset {
  min-width: 0;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

legend {
  padding: 0 7px;
  color: var(--navy);
  font-family: Georgia, serif;
  font-size: 16px;
  font-weight: 700;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 11px;
}

label {
  display: grid;
  gap: 5px;
  min-width: 0;
  color: #344054;
  font-size: 12px;
  font-weight: 650;
}

[hidden] { display: none !important; }

#people-container { display: grid; gap: 12px; }

.person-card {
  display: grid;
  gap: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.person-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.person-card-head strong {
  font-family: Georgia, serif;
  font-size: 16px;
  color: var(--navy);
}

.remove-person {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
  padding: 0;
  cursor: pointer;
}

.remove-person:hover { color: #b3261e; border-color: #b3261e; }

.add-person-btn {
  width: 100%;
  min-height: 40px;
  border: 1px dashed var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--navy);
  font-weight: 750;
  text-align: center;
  padding: 10px 12px;
  cursor: pointer;
}

.add-person-btn:hover { border-color: var(--gold); color: var(--gold); }
.add-person-btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.field-hint {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-left: 4px;
  border-radius: 50%;
  background: var(--gold-light);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  font-style: normal;
  cursor: pointer;
  user-select: none;
}

.field-hint .tip-bubble {
  position: absolute;
  z-index: 30;
  bottom: calc(100% + 7px);
  left: 0;
  width: min(340px, calc(100vw - 48px));
  padding: 8px 10px;
  border-radius: 7px;
  background: var(--navy);
  color: #fff;
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.4;
  box-shadow: 0 8px 20px rgba(23,33,58,.28);
}

.field-hint::after {
  position: absolute;
  z-index: 30;
  bottom: calc(100% + 7px);
  left: 0;
  width: min(340px, calc(100vw - 48px));
  padding: 8px 10px;
  border-radius: 7px;
  background: var(--navy);
  color: #fff;
  content: attr(data-tip);
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.4;
  box-shadow: 0 8px 20px rgba(23,33,58,.28);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.field-hint:hover::after { opacity: 1; visibility: visible; }
.field-hint:has(.tip-bubble)::after { display: none; }

.field-hint .tip-bubble[hidden] { display: none !important; }

.span-2 { grid-column: 1 / -1; }

input, select, textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid #cfd5df;
  border-radius: 6px;
  padding: 8px 10px;
  outline: none;
  background: #fff;
  color: var(--text);
  resize: vertical;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(179,135,49,.12);
}

.sub-legend {
  margin-top: 8px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
  color: var(--navy);
  font-family: Georgia, serif;
  font-size: 13px;
  font-weight: 700;
}

.person-card .sub-legend {
  margin-top: 4px;
  border-top: 0;
  padding-top: 0;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.clauses-toggle {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8f9fb;
  color: var(--navy);
  font-weight: 750;
  text-align: left;
  padding: 10px 12px;
  cursor: pointer;
}

.clauses-toggle:hover { filter: brightness(0.98); }

#clauses-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.clause-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fbfbfc;
}

.clause-head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
}

.clause-head input[type="checkbox"] {
  margin-top: 3px;
  width: 16px;
  height: 16px;
  min-height: 0;
  accent-color: var(--gold);
  flex: none;
}

.clause-head span {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--navy);
  line-height: 1.35;
}

.clause-head small {
  display: block;
  margin-top: 1px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
}

.clause-text {
  display: block;
  margin-top: 8px;
  min-height: 56px;
  font-size: 12.5px;
  line-height: 1.45;
  font-weight: 400;
  color: var(--text);
  border-color: transparent;
  background: transparent;
  padding: 0;
  resize: none;
  cursor: default;
}

.clause-text:focus { box-shadow: none; }

.clause-item.is-editing { background: #fff; border-color: var(--gold-light); }

.clause-item.is-editing .clause-text {
  border-color: #cfd5df;
  background: #fff;
  padding: 8px 10px;
  cursor: text;
  resize: vertical;
}

.clause-item.is-editing .clause-text:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(179,135,49,.12);
}
.clause-item.is-editing .clause-text { display: block; }

.preview-pane {
  position: relative;
  display: grid;
  grid-template-rows: 46px minmax(0, 1fr);
  min-width: 0;
  min-height: calc(100vh - 68px);
  padding: 18px;
  background: #dfe3e9;
}

.preview-pane > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  padding: 0 14px;
  background: #fff;
  color: var(--navy);
}

.preview-pane > header span { color: var(--muted); font-size: 12px; }

#preview {
  width: 100%;
  height: 100%;
  min-height: 720px;
  border: 1px solid var(--line);
  border-radius: 0 0 8px 8px;
  background: #717680;
}

.preview-loading {
  position: absolute;
  inset: 64px 18px 18px;
  display: grid;
  place-items: center;
  border-radius: 0 0 8px 8px;
  background: rgba(255,255,255,.9);
  color: var(--muted);
  font-weight: 700;
}

.preview-loading[hidden] { display: none; }

/* Contrato de honorários: editor financeiro orientado por modalidade. */
.honorarios-page fieldset,
.honorarios-page .person-card,
.honorarios-page .person-card-head strong,
.honorarios-page legend,
.honorarios-page .sub-legend {
  font-family: inherit;
}

.honorarios-page legend,
.honorarios-page .person-card-head strong {
  font-size: 15px;
  font-weight: 750;
  letter-spacing: -0.01em;
}

.honorarios-page fieldset {
  display: grid;
  gap: 14px;
}

.honorarios-page .section-intro {
  margin: -3px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.honorarios-page .sub-legend {
  margin-top: 0;
  color: var(--navy);
  font-size: 13px;
  font-weight: 750;
}

.honorarios-page .agreement-editor {
  display: grid;
  gap: 12px;
  min-width: 0;
  border: 1px solid #d8c18e;
  border-radius: 10px;
  padding: 14px;
  background: #fcfaf6;
}

.honorarios-page .agreement-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.honorarios-page .agreement-heading h3,
.honorarios-page .agreement-heading p {
  margin: 0;
}

.honorarios-page .agreement-heading h3 {
  color: var(--navy);
  font-size: 15px;
  line-height: 1.3;
}

.honorarios-page .agreement-heading p,
.honorarios-page .block-heading small,
.honorarios-page .stage-heading small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.35;
}

.honorarios-page .agreement-summary {
  flex: none;
  max-width: 190px;
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  color: #475467;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1.35;
  text-align: right;
}

.honorarios-page .agreement-grid,
.honorarios-page .agreement-block {
  min-width: 0;
}

.honorarios-page .block-heading {
  margin-bottom: 9px;
  color: var(--navy);
}

.honorarios-page .stage-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
  color: var(--navy);
}

.honorarios-page .inline-action {
  min-height: 34px;
  border: 1px solid #d8c18e;
  border-radius: 7px;
  padding: 7px 10px;
  background: #fff;
  color: var(--navy);
  font-size: 11px;
  font-weight: 750;
  cursor: pointer;
}

.honorarios-page .inline-action:hover {
  border-color: var(--gold);
  color: var(--gold);
}

.honorarios-page .stage-list {
  display: grid;
  gap: 8px;
}

.honorarios-page .stage-row {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(90px, .55fr) minmax(125px, .7fr) 34px;
  gap: 7px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
  background: #fff;
}

.honorarios-page .stage-row input {
  min-width: 0;
}

.honorarios-page .remove-stage {
  width: 34px;
  min-height: 40px;
  border: 1px solid #efc6c2;
  border-radius: 7px;
  background: #fff;
  color: #a53028;
  font-size: 18px;
  cursor: pointer;
}

.honorarios-page .remove-stage:hover {
  background: #fff4f3;
}

@media (max-width: 980px) {
  .workspace { grid-template-columns: 1fr; }
  .form-pane { border-right: 0; border-bottom: 1px solid var(--line); }
  .preview-pane { min-height: 820px; }
}

@media (max-width: 560px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .top-actions, .top-actions .button { width: 100%; }
  .top-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(58px, 1fr));
    gap: 6px;
  }
  .top-actions .button {
    min-width: 0;
    padding: 0 6px;
    font-size: 11px;
  }
  .top-actions office-app-switcher { justify-self: end; }
  .field-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .mode-switch { grid-template-columns: 1fr; }
  .workspace { min-height: auto; }
  .honorarios-page .agreement-heading,
  .honorarios-page .stage-heading { align-items: stretch; flex-direction: column; }
  .honorarios-page .agreement-summary { max-width: none; text-align: left; }
  .honorarios-page .stage-row { grid-template-columns: 1fr; }
  .honorarios-page .remove-stage { width: 100%; }
}
