.rg-dialog {
  width: min(1200px, calc(100vw - 40px));
  max-width: 1200px;
  color: var(--sfa-text, #19304b);
  background: var(--sfa-card, #fff);
}
.rg-dialog {
  padding: 24px;
}
.rg-intro {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 18px 20px;
  background: var(--sfa-soft, #f5f7fb);
  border: 1px solid var(--sfa-border, #d6e1f2);
  border-radius: 8px;
  margin-bottom: 20px;
}
.rg-intro > svg {
  color: #208a7c;
  flex-shrink: 0;
}
.rg-intro h3 {
  font-size: 18px;
  margin: 0 0 6px;
}
.rg-intro p,
.rg-explanation,
.rg-note {
  font-size: 13px;
  line-height: 1.8;
  margin: 0;
  color: var(--sfa-sub, #5c7090);
}
.rg-toolbar,
.rg-add {
  display: flex;
  gap: 14px;
  align-items: end;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.rg-toolbar label,
.rg-add label {
  display: grid;
  gap: 7px;
  font-size: 12px;
  font-weight: 600;
}
.rg-toolbar input,
.rg-toolbar select,
.rg-add select {
  min-height: 40px;
  padding: 8px 12px;
  min-width: 150px;
  border: 1px solid var(--sfa-border, #d6e1f2);
  border-radius: 6px;
  background: var(--sfa-card, #fff);
  color: inherit;
  font: inherit;
}
.rg-toolbar > button {
  margin-left: auto;
}
.rg-totals {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
}
.rg-totals > div {
  padding: 14px;
  border: 1px solid var(--sfa-border, #d6e1f2);
  border-radius: 7px;
}
.rg-totals span {
  display: block;
  font-size: 12px;
  color: var(--sfa-sub, #5c7090);
}
.rg-totals strong {
  display: block;
  margin-top: 6px;
  font-size: 20px;
  font-variant-numeric: tabular-nums;
}
.rg-totals strong small {
  font-size: 12px;
  font-weight: 500;
  margin-left: 5px;
}
.rg-explanation {
  margin: 12px 0;
}
.rg-note {
  padding: 10px 14px;
  background: var(--sfa-soft, #f5f7fb);
  border-radius: 6px;
  margin: 10px 0;
}
.rg-table-scroll {
  overflow: auto;
  max-height: 44vh;
  border: 1px solid var(--sfa-border, #d6e1f2);
  border-radius: 7px;
}
.rg-table {
  width: 100%;
  min-width: 960px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}
.rg-table th,
.rg-table td {
  padding: 12px 10px;
  text-align: left;
  border-bottom: 1px solid var(--sfa-border, #d6e1f2);
  vertical-align: middle;
}
.rg-table thead th {
  position: sticky;
  top: 0;
  background: var(--sfa-soft, #f5f7fb);
  z-index: 1;
  font-size: 12px;
}
.rg-table th small {
  display: block;
  font-weight: 400;
  margin-top: 4px;
  color: var(--sfa-sub, #5c7090);
  font-size: 11px;
}
.rg-table tbody th {
  min-width: 160px;
}
.rg-table td {
  font-variant-numeric: tabular-nums;
}
.rg-table td input {
  width: 100%;
  min-width: 80px;
  padding: 9px 8px;
  text-align: right;
  border: 1px solid var(--sfa-border, #d6e1f2);
  border-radius: 5px;
  background: var(--sfa-card, #fff);
  color: inherit;
  font: inherit;
  font-variant-numeric: tabular-nums;
}
.rg-table td input[aria-invalid="true"] {
  border: 2px solid #c64956;
}
.rg-table td input:focus-visible,
.rg-dialog select:focus-visible,
.rg-dialog button:focus-visible,
.rg-dialog input:focus-visible {
  outline: 3px solid #829de3;
  outline-offset: 2px;
}
.rg-table del {
  color: var(--sfa-sub, #5c7090);
  font-size: 11px;
}
.rg-empty {
  text-align: center;
  padding: 24px;
  color: var(--sfa-sub, #5c7090);
}
.rg-add {
  margin: 18px 0 0;
}
.rg-remove {
  background: transparent;
  border: 0;
  color: var(--sfa-sub, #5c7090);
  font: inherit;
  cursor: pointer;
}
.rg-review-title {
  font-size: 16px;
}
.rg-review-title span {
  font-size: 13px;
  color: var(--sfa-sub, #5c7090);
  margin-left: 12px;
}
.rg-footer {
  display: flex;
  gap: 16px;
  justify-content: space-between;
  align-items: center;
  padding-top: 20px;
  margin-top: 20px;
  border-top: 1px solid var(--sfa-border, #d6e1f2);
}
.rg-footer > span {
  font-size: 12px;
  color: var(--sfa-sub, #5c7090);
}
.rg-footer > div {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}
.rg-footer .primary {
  background: #3264df;
  color: #fff;
  border-color: #3264df;
}
.rg-footer button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.rg-error,
.rg-success {
  padding: 12px 14px;
  border: 1px solid;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.8;
}
.rg-error {
  color: #b53345;
  background: #fff5f5;
}
.rg-success {
  display: flex;
  gap: 8px;
  align-items: center;
  color: #167253;
  background: #eaf7f0;
}
.rg-discard {
  padding: 16px;
  margin-top: 16px;
  border: 1px solid #c99c35;
  border-radius: 7px;
  background: var(--sfa-soft, #f5f7fb);
  font-size: 14px;
}
.rg-discard p {
  margin: 8px 0;
}
.rg-discard button + button {
  margin-left: 10px;
}
.rg-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}
html[data-theme="dark"] .rg-error {
  background: #3b222e;
  color: #ffb4bf;
}
html[data-theme="dark"] .rg-success {
  background: #183c33;
  color: #94e0bd;
}
@media (max-width: 700px) {
  .rg-dialog {
    width: calc(100vw - 20px);
  }
  .rg-dialog {
    padding: 14px;
  }
  .rg-totals {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .rg-toolbar > button {
    margin-left: 0;
  }
  .rg-footer {
    align-items: stretch;
    flex-direction: column;
  }
  .rg-footer > div {
    justify-content: flex-end;
  }
  .rg-table-scroll {
    max-height: 40vh;
  }
  .rg-intro {
    padding: 14px;
  }
  .rg-add label {
    flex: 1;
    min-width: 140px;
  }
}

.ar-page-tools:has(.rg-dialog),
.ar-page-tools {
  gap: 10px;
}

/* KPI action and form controls share a 42px baseline. Chevron inset is 14px. */
.ar-page-tools .sfa-btn.rg-launch {
  min-height: 48px;
  min-width: 152px;
  padding: 12px 22px;
  font-size: 15px;
  font-weight: 700;
  border: 1px solid #12786e;
  background: #137d73;
  color: #fff;
  box-shadow: 0 3px 10px #167c731b;
  gap: 9px;
}
.ar-page-tools .sfa-btn.rg-launch:hover {
  background: #0c695f;
  border-color: #0c695f;
}
html[data-theme="dark"] .ar-page-tools .sfa-btn.rg-launch {
  background: #247b70;
  color: #fff;
  border-color: #53b6a7;
}
.rg-toolbar label,
.rg-add label {
  margin: 0;
  line-height: 1.4;
}
.rg-toolbar input,
.rg-toolbar select,
.rg-add select {
  height: 42px;
  min-height: 42px;
  margin: 0;
  box-sizing: border-box;
}
.ar-page .rg-dialog select,
.rg-dialog select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='m3 4.5 3 3 3-3' stroke='%23556980' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-position: right 14px center;
  background-size: 12px 12px;
  background-repeat: no-repeat;
}
html[data-theme="dark"] .ar-page .rg-dialog select,
html[data-theme="dark"] .rg-dialog select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='m3 4.5 3 3 3-3' stroke='%23c2d2e6' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.rg-toolbar > button {
  height: 42px;
  min-height: 42px;
  margin: 0;
  box-sizing: border-box;
  align-self: end;
}
.rg-toolbar > button:last-child {
  margin-left: auto;
}
.rg-add {
  display: grid;
  grid-template-columns: minmax(150px, 220px) minmax(150px, 240px) minmax(
      140px,
      180px
    ) max-content;
  gap: 14px;
  align-items: end;
}
.rg-add select {
  width: 100%;
  min-width: 0;
}
.rg-add > button {
  height: 42px;
  min-height: 42px;
  margin: 0;
  box-sizing: border-box;
  align-self: end;
}
.rg-voice {
  padding: 18px;
  margin: 0 0 18px;
  border: 1px solid #90bfb5;
  border-radius: 8px;
  background: var(--sfa-soft, #f6f8fc);
  font-size: 14px;
}
.rg-voice header,
.rg-voice header > div {
  display: flex;
  align-items: center;
  gap: 9px;
  justify-content: space-between;
}
.rg-voice header > button {
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
}
.rg-voice header strong {
  font-size: 16px;
}
.rg-voice > p {
  font-size: 13px;
  color: var(--sfa-sub, #5c7090);
  line-height: 1.8;
}
.rg-voice-label {
  display: grid;
  gap: 8px;
  margin: 14px 0 10px;
  font-size: 13px;
}
.rg-voice textarea {
  width: 100%;
  padding: 12px;
  font: inherit;
  font-size: 14px;
  line-height: 1.7;
  color: var(--sfa-text, #19304b);
  background: var(--sfa-card, #fff);
  border: 1px solid var(--sfa-border, #d6e1f2);
  border-radius: 6px;
  resize: vertical;
}
.rg-voice-actions {
  display: flex;
  gap: 9px;
  align-items: center;
  flex-wrap: wrap;
}
.rg-voice .rg-voice-mic {
  border-color: #408f82;
  color: #176f63;
  background: var(--sfa-card, #fff);
}
.rg-voice .is-recording {
  color: #c64956;
  border-color: #c64956;
}
.rg-voice-file {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: transparent;
  color: var(--sfa-sub, #5c7090);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  padding: 8px;
}
.rg-voice-question {
  padding: 14px;
  background: var(--sfa-card, #fff);
  border-radius: 6px;
  border: 1px solid var(--sfa-border, #d6e1f2);
  line-height: 1.7;
}
.rg-voice-question > div {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.rg-voice-question button {
  padding: 8px 12px;
  border: 1px solid var(--sfa-border, #d6e1f2);
  border-radius: 6px;
  background: var(--sfa-soft, #f5f7fb);
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.rg-voice-transcript {
  margin: 10px 0;
  font-size: 13px;
  color: var(--sfa-sub, #5c7090);
}
.rg-voice-transcript summary {
  cursor: pointer;
}
.rg-voice-transcript p {
  white-space: pre-wrap;
  line-height: 1.8;
  padding: 10px;
}
html[data-theme="dark"] .rg-voice .rg-voice-mic {
  color: #93dac8;
  border-color: #549e8e;
}
@media (max-width: 700px) {
  .rg-add {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .rg-add label {
    min-width: 0;
  }
  .rg-add > button {
    width: 100%;
  }
  .rg-toolbar > button:last-child {
    margin-left: 0;
  }
  .ar-page-tools .sfa-btn.rg-launch {
    min-width: 140px;
    min-height: 46px;
    font-size: 14px;
  }
}

.ta-select {
  display: block;
  min-width: 0;
}
.ta-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-width: 0;
  height: 42px;
  padding: 8px 14px 8px 12px;
  border: 1px solid var(--sfa-border, #d6e1f2);
  border-radius: 6px;
  background: var(--sfa-card, #fff);
  color: var(--sfa-text, #19304b);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.ta-select-trigger > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ta-select-trigger > svg {
  flex-shrink: 0;
  color: var(--sfa-sub, #5c7090);
}
.ta-select-trigger:focus-visible {
  outline: 2px solid #3568c7;
  outline-offset: 2px;
}
.ta-select-trigger[aria-expanded="true"] {
  border-color: #208a7c;
}
.ta-select-trigger:disabled {
  opacity: 0.6;
  cursor: default;
}
.ta-select-menu[popover] {
  position: fixed;
  inset: auto;
  margin: 0;
  box-sizing: border-box;
  padding: 4px;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid #cbd9e8;
  border-radius: 8px;
  background: #fff;
  color: #19304b;
  box-shadow: 0 8px 24px #18304b26;
  font-family: inherit;
  font-size: 14px;
  line-height: 20px;
  scrollbar-width: thin;
  z-index: 10000;
}
.ta-select-menu > [role="option"] {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 38px;
  box-sizing: border-box;
  padding: 8px 10px;
  border-radius: 5px;
  font-weight: 500;
  cursor: pointer;
}
.ta-select-menu > [role="option"] > span {
  overflow-wrap: anywhere;
}
.ta-select-menu > [role="option"] > svg {
  flex-shrink: 0;
}
.ta-select-menu > [aria-selected="true"] {
  color: #13786d;
  font-weight: 700;
}
.ta-select-menu > [data-active="true"] {
  background: #e8f4f0;
}
html[data-theme="dark"] .ta-select-menu[popover] {
  background: #142338;
  color: #e9f0fa;
  border-color: #526681;
  box-shadow: 0 8px 28px #0006;
}
html[data-theme="dark"] .ta-select-menu > [aria-selected="true"] {
  color: #8bdcc6;
}
html[data-theme="dark"] .ta-select-menu > [data-active="true"] {
  background: #24433f;
}
