/* Finance Settings — page-specific layout on the shared AR shell/card.
   Shell, title, tabs, chips, selects, and modal chrome come from
   v2-shell / v2-ar / v2-tabs / v2-chip / v2-select / ads-theme. */

html, body {
  background: var(--ads-page-bg, var(--bg, #f4f5f7));
}

.fs-card {
  min-width: 0;
}

html[data-theme="ads"] .fs-card > .card-header,
html[data-theme="dark"] .fs-card > .card-header,
html[data-theme="wireframe"] .fs-card > .card-header,
.fs-card > .card-header {
  border-bottom: 0;
}

.fs-card > .fs-panel {
  padding-left: var(--ar-card-inset-x, 23px);
  padding-right: var(--ar-card-inset-x, 23px);
  box-sizing: border-box;
}

.fs-card .ar-header {
  height: 52px;
  align-items: center;
}

.fs-actions .btn-primary[hidden],
.fs-actions .btn-secondary[hidden] {
  display: none !important;
}

.fs-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.fs-card .card-header .tab-bar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  margin-top: 4px;
  border-bottom: 0;
}

.fs-card .card-header .top-tab-bar {
  display: flex;
  align-items: flex-end;
  width: 100%;
  border-bottom: 0;
}

/* ads-theme draws a second selected-tab stripe; the ADS underline is .tab-underline. */
.fs-card .tab-item[role="tab"]::after,
.fs-card .tab-item[role="tab"][aria-selected="true"]::after,
html[data-theme="ads"] .fs-card .tab-item[role="tab"]::after,
html[data-theme="ads"] .fs-card .tab-item[role="tab"][aria-selected="true"]::after {
  content: none;
  display: none;
  height: 0;
  background: transparent;
}

.fs-card .card-header .tab-list.tabs {
  display: flex;
  align-items: flex-start;
  gap: 0;
}

.fs-panel[hidden] { display: none !important; }

.fs-panel {
  padding-top: 0;
  padding-bottom: 0;
}

.fs-table-scroll {
  overflow: auto;
  max-width: 100%;
}

.fs-table-scroll:focus-visible {
  outline: 2px solid var(--ads-brand, #4045c2);
  outline-offset: 2px;
}

.fs-table {
  width: 100%;
  min-width: 1080px;
  border-collapse: collapse;
  table-layout: auto;
}

.fs-table th,
.fs-table td {
  box-sizing: border-box;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--ar-divider, #d4dee3);
}

.fs-table th {
  height: var(--ar-head-h, 32px);
  padding: 0 12px;
  background: #fff;
  white-space: nowrap;
}

.fs-table th .fs-th-label {
  display: inline;
}
.fs-th-info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  margin-left: 4px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ads-gray-100, #51585b);
  cursor: help;
  line-height: 0;
  vertical-align: middle;
}
.fs-th-info svg {
  display: block;
  width: 14px;
  height: 14px;
}
.fs-th-info:hover {
  color: var(--ads-gray-200, #3b4347);
}
.fs-th-info:focus {
  outline: none;
}
.fs-th-info:focus-visible {
  outline: 2px solid var(--ads-brand, #4045c2);
  outline-offset: 2px;
}
.fs-severity-tip {
  position: fixed;
  z-index: 1400;
  box-sizing: border-box;
  max-width: 320px;
  pointer-events: none;
  white-space: normal;
}
.fs-severity-tip[hidden] {
  display: none;
}

.fs-table td {
  height: var(--ar-row-h, 56px);
  padding: 8px 12px;
  color: var(--ar-text-strong, #1e2528);
  font: 400 14px/20px "Open Sans", var(--font-family), sans-serif;
}

.fs-table th:first-child,
.fs-table td:first-child { padding-left: 0; }
.fs-table th:last-child,
.fs-table td:last-child { padding-right: 0; }

#fsRulesTable.fs-table {
  table-layout: fixed;
  width: 100%;
  min-width: 0;
}

#fsRulesTable.fs-table th,
#fsRulesTable.fs-table td {
  overflow: visible;
  white-space: nowrap;
}

.fs-table tbody tr:last-child td { border-bottom: 0; }

.fs-table tbody tr:hover td {
  background: rgba(15, 18, 20, 0.04);
}

.fs-id {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

.fs-mapping {
  max-width: 280px;
  white-space: normal;
  overflow-wrap: anywhere;
}

.fs-name {
  white-space: nowrap;
}

.fs-table .fs-actions-cell {
  white-space: nowrap;
}

.fs-table button.ads-table-link {
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ads-indigo-700, #2d2f8c);
  font: 600 14px/20px "Open Sans", var(--font-family), sans-serif;
  cursor: pointer;
}

.fs-table button.ads-table-link + button.ads-table-link {
  margin-left: 12px;
}

.fs-table button.ads-table-link:hover {
  color: var(--ads-indigo-800, #282a7c);
  text-decoration: underline;
}

.fs-table button.ads-table-link:focus-visible {
  outline: 2px solid var(--ads-brand, #4045c2);
  outline-offset: 2px;
}

.fs-table button.ads-table-link:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#fsUnits .fs-table th:nth-child(3),
#fsUnits .fs-table td:nth-child(3),
#fsUnits .fs-table th:nth-child(4),
#fsUnits .fs-table td:nth-child(4),
#fsUnits .fs-table th:nth-child(5),
#fsUnits .fs-table td:nth-child(5) {
  white-space: nowrap;
}

#fsUnits .fs-table th:nth-child(6) {
  min-width: 200px;
}

#fsRuleOverlay,
#fsUnitOverlay,
#fsRunOverlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  box-sizing: border-box;
  background: var(--ads-scrim, rgba(15, 18, 20, 0.50));
}

#fsRuleOverlay[hidden],
#fsUnitOverlay[hidden],
#fsRunOverlay[hidden] {
  display: none !important;
}

.fs-dialog {
  width: min(560px, calc(100vw - 48px));
  max-height: min(720px, calc(100vh - 48px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.fs-rule-dialog {
  width: min(640px, calc(100vw - 48px));
}

.fs-dialog .edl-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}

.fs-dialog .edl-modal-title {
  margin: 0;
}

.fs-dialog-sub {
  margin: 4px 0 0;
  color: var(--ar-text-rest, #51585b);
  font: 400 12px/18px "Open Sans", var(--font-family), sans-serif;
}

.fs-dialog .edl-modal-content,
.fs-dialog form.edl-modal-content {
  padding: 16px 24px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 0 1 auto;
}

#fsUnitDialog .edl-modal-content,
#fsRuleForm {
  gap: 24px;
}

.fs-form-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.fs-form-fields {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.fs-form-legend {
  margin: 0;
  color: var(--ads-gray-600, #1e2528);
  font: var(--ads-font-body-md-sem, 600 14px/20px "Open Sans", var(--font-family), sans-serif);
  letter-spacing: 0;
  text-transform: none;
}

.fs-form-error {
  margin: 0;
}

.fs-dialog .edl-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  flex-shrink: 0;
}

.fs-dialog .edl-modal-close {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ar-text-rest, #51585b);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}

.fs-dialog .edl-modal-close:hover {
  background: rgba(15, 18, 20, 0.05);
  color: var(--ar-text-strong, #1e2528);
}

.fs-dialog .edl-modal-btn {
  cursor: pointer;
}

.fs-dialog .edl-modal-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.fs-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  position: relative;
}

.fs-field label,
.fs-if {
  color: var(--ads-gray-200, var(--ar-text-muted, #3b4347));
  font: var(--ads-font-body-sm-sem, 600 12px/18px "Open Sans", var(--font-family), sans-serif);
}

.fs-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.fs-readonly {
  margin: 0;
  color: var(--ar-text-strong, #1e2528);
  font: 400 14px/20px "Open Sans", var(--font-family), sans-serif;
}

.fs-input {
  height: 36px;
  width: 100%;
  box-sizing: border-box;
}

.fs-field .ads-select {
  width: 100%;
  --ads-select-height: 36px;
}

.fs-rule-dialog .ads-select-trigger {
  height: auto;
  min-height: var(--ads-select-height);
  align-items: flex-start;
  padding-top: 7px;
  padding-bottom: 7px;
}

.fs-rule-dialog .ads-select-value {
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
}

.fs-rule-dialog .ads-select-chevron {
  margin-top: 2px;
}

.fs-if-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 16px;
  align-items: start;
}

.fs-condition-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.fs-condition-block {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.fs-cond-join {
  display: flex;
  align-items: center;
  min-height: 32px;
}

.fs-join-field {
  width: 104px;
}

.fs-join-echo {
  color: var(--ar-text-rest, #51585b);
  font: 600 12px/18px "Open Sans", var(--font-family), sans-serif;
  letter-spacing: 0.02em;
}

.fs-cond-remove {
  width: 32px;
  height: 32px;
  margin-top: 22px;
  flex: 0 0 auto;
}

.fs-add-condition {
  align-self: flex-start;
  padding: 4px 8px;
}

.fs-field .field-helper,
.fs-field .field-error,
.fs-form-error {
  margin: 0;
}

.fs-field .field-error,
.fs-form-error {
  display: flex;
  align-items: flex-start;
  gap: 4px;
}

.fs-field .field-error::before,
.fs-form-error::before {
  content: "";
  flex: 0 0 12px;
  width: 12px;
  height: 12px;
  margin-top: 3px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 256 256' fill='black'><circle cx='128' cy='128' r='96' fill='none' stroke='black' stroke-width='16'/><line x1='128' y1='80' x2='128' y2='136' fill='none' stroke='black' stroke-linecap='round' stroke-width='16'/><circle cx='128' cy='172' r='12'/></svg>") center / contain no-repeat;
          mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 256 256' fill='black'><circle cx='128' cy='128' r='96' fill='none' stroke='black' stroke-width='16'/><line x1='128' y1='80' x2='128' y2='136' fill='none' stroke='black' stroke-linecap='round' stroke-width='16'/><circle cx='128' cy='172' r='12'/></svg>") center / contain no-repeat;
}

.fs-field .input-field[aria-invalid="true"],
.fs-field input[aria-invalid="true"],
.fs-field .fs-input[aria-invalid="true"] {
  border-color: var(--ads-red-100, #db5461);
}

html[data-theme="ads"] .fs-field input[type="text"][aria-invalid="true"]:focus,
html[data-theme="ads"] .fs-field input[aria-invalid="true"]:focus,
html[data-theme="ads"] .fs-field .input-field[aria-invalid="true"]:focus,
html[data-theme="ads"] .fs-field .fs-input[aria-invalid="true"]:focus {
  outline: none;
  border: 2px solid var(--ads-red-100, #db5461);
  padding: 7px 11px;
  box-shadow: none;
}

.fs-dialog [hidden] {
  display: none !important;
}

@media (max-width: 800px) {
  .fs-card .ar-header { flex-wrap: wrap; }
  .fs-if-row { grid-template-columns: 1fr; }
  .fs-cond-remove { margin-top: 0; }
}

/* Profile dropdown — same chrome AP/AR use, scoped to the shared trigger. */
.pnav-profile-trigger { position: relative; }
.profile-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  width: 260px;
  background: #ffffff;
  border: 1px solid #d6dee8;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  overflow: hidden;
  z-index: 300;
  font-family: var(--font-family);
}
.profile-dd-info { padding: 16px 18px 14px; }
.profile-dd-name { font-size: 14px; line-height: 20px; font-weight: 600; color: #1f2937; }
.profile-dd-email {
  font-size: 13px;
  line-height: 18px;
  color: #6b7f95;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.profile-dd-divider { height: 1px; background: #e1e7ef; margin: 0; border: 0; }
.profile-dd-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 44px;
  padding: 0 18px;
}
.profile-dd-section-label { font-size: 14px; line-height: 20px; color: #1f2937; }
.profile-dd-section-value { font-size: 14px; line-height: 20px; color: #6b7f95; }
.profile-dd-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 44px;
  padding: 0 18px;
  font-size: 14px;
  line-height: 20px;
  color: #1f2937;
  cursor: pointer;
  border: 0;
  background: none;
  width: 100%;
  text-align: left;
  font-family: var(--font-family);
}
.profile-dd-item:hover,
.profile-dd-item:focus-visible { background: #f7f9fc; outline: none; }
.profile-dd-item svg { width: 8px; height: 12px; flex-shrink: 0; color: #6b7f95; }
.profile-dd-theme-wrap { position: relative; }
.profile-dd-submenu {
  position: fixed !important;
  right: auto !important;
  top: auto !important;
  left: 0;
  min-width: 168px;
  background: #ffffff;
  border: 1px solid #d6dee8;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  overflow: hidden;
  z-index: 310;
  pointer-events: auto;
}
.profile-dd-submenu[hidden] { display: none !important; }
.profile-dd-submenu:not([hidden]) { display: block !important; }
.profile-dd-submenu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 42px;
  padding: 0 16px;
  font-size: 14px;
  line-height: 20px;
  color: #1f2937;
  cursor: pointer;
  border: 0;
  background: none;
  text-align: left;
  font-family: var(--font-family);
}
.profile-dd-submenu-item:hover,
.profile-dd-submenu-item:focus-visible { background: #f7f9fc; outline: none; }
.profile-dd-submenu-item.is-selected { font-weight: 600; color: var(--indigo-70, #4045c2); }
.profile-dd-submenu-item.is-selected::after {
  content: "";
  width: 14px;
  height: 14px;
  margin-left: 12px;
  flex-shrink: 0;
  background-color: currentColor;
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14'><path fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='M2 7.5l3.2 3.2L12 4'/></svg>") center / contain no-repeat;
  mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14'><path fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='M2 7.5l3.2 3.2L12 4'/></svg>") center / contain no-repeat;
}
.profile-dd-logout { color: #4b5f73; }

.fs-run-meta {
  margin: 12px 0 0;
  padding: 0 24px 8px;
  font: 400 12px/18px "Open Sans", var(--font-family), sans-serif;
  color: var(--ads-gray-100, #51585b);
}
.fs-run-dialog {
  width: min(480px, calc(100vw - 32px));
}

.fs-run-dialog .field-helper {
  color: var(--ads-gray-100, #51585b);
  font: 400 12px/18px "Open Sans", var(--font-family), sans-serif;
}
.fs-ads-spinner {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  display: inline-block;
  vertical-align: middle;
  margin-right: 8px;
  animation: fs-ads-spin 0.7s linear infinite;
}
.fs-ads-spinner circle {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-dasharray: 28 10;
}
@keyframes fs-ads-spin {
  to { transform: rotate(360deg); }
}

.fs-actions .btn-primary svg {
  flex: 0 0 16px;
}

.fs-table tbody tr.fs-row-added td {
  animation: fs-row-highlight 1.6s ease-out;
}

html[data-theme="ads"] table.v2-data-table.fs-table tbody tr.fs-row-target td,
html[data-theme="ads"] table.v2-data-table.fs-table tbody tr.fs-row-target td:first-child,
table.v2-data-table.fs-table tbody tr.fs-row-target td,
table.v2-data-table.fs-table tbody tr.fs-row-target td:first-child {
  background-color: var(--ads-brand-wash, #e2e3f2);
}

html[data-theme="ads"] table.v2-data-table.fs-table tbody tr.fs-row-target td:first-child,
table.v2-data-table.fs-table tbody tr.fs-row-target td:first-child {
  box-shadow: inset 3px 0 0 var(--ads-brand, #5b5fc7);
}

@keyframes fs-row-highlight {
  from { background-color: var(--ads-indigo-50, #e2e3f2); }
  to { background-color: transparent; }
}
html[data-theme="dark"] .profile-dropdown,
html[data-theme="dark"] .profile-dd-submenu {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4), 0 0 1px rgba(0, 0, 0, 0.3);
}
