.rules-workspace,
.rules-dialog {
  --rule-line: #d3e0e9;
  --rule-soft: #eff5f9;
  --rule-blue: #0875b1;
  --rule-muted: #506575;
}

.rules-workspace { min-width: 0; padding-bottom: 56px; }
.rules-workspace :is(h1,h2,h3,p,dl,dd) { margin: 0; }
.rules-workspace .rules-page-head {
  min-height: 0;
  margin-bottom: 12px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
}
.rules-page-head h1 { font-size: clamp(25px, 3vw, 32px); }
.rules-page-head .rules-icon-only { padding-inline: 10px; }
.rules-workspace header .meta-icon { margin: 0; color: inherit; }
.rules-workspace button, .rules-dialog button { gap: 6px; }
.rules-help-title { display: flex; align-items: center; gap: 6px; min-width: 0; }
.rules-info-wrap { display: inline-flex; flex: none; }
:is(.rules-workspace,.rules-dialog) .rules-info {
  display: inline-grid;
  place-items: center;
  width: 19px;
  min-height: 19px;
  height: 19px;
  padding: 0;
  border: 1px solid #9bb9ca;
  border-radius: 50%;
  color: #075a86;
  background: #f3f8fb;
  font-size: 12px;
  font-weight: 750;
  line-height: 1;
  cursor: help;
}
:is(.rules-workspace,.rules-dialog) .rules-info:is(:hover,:focus-visible) { background: #e1f1fb; border-color: #0875b1; }
.rules-help-popup {
  position: fixed;
  inset: auto;
  z-index: 20;
  width: max-content;
  max-width: min(340px,calc(100vw - 20px));
  max-height: min(380px,calc(100dvh - 20px));
  overflow: auto;
  box-sizing: border-box;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid #b8cdd9;
  border-radius: 8px;
  background: #fff;
  color: #1c2c35;
  font-size: 13px;
  line-height: 1.42;
  overflow-wrap: anywhere;
  box-shadow: 0 5px 18px #203c5128;
}
.rules-help-popup p { margin: 0; }
.rules-help-popup ol { margin: 8px 0; padding-inline-start: 19px; }
.rules-help-popup li + li { margin-top: 5px; }
.rules-help-popup .rules-help-note { margin-top: 8px; padding-top: 7px; border-top: 1px solid #d3e0e9; color: #435968; }
.rules-help-field { display: grid; gap: 4px; min-width: 0; align-content: start; }
.rules-help-field > :is(input,select,textarea) { width: 100%; }
:is(.rules-workspace,.rules-dialog) button[aria-pressed="true"] {
  color: #075a86;
  border-color: #a4cde4;
  background: #e1f1fb;
}

.rules-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.rules-workspace .rules-tabs button {
  justify-content: flex-start;
  gap: 9px;
  padding: 8px 11px;
  min-height: 40px;
  background: var(--rule-soft);
  border-color: #d0dde6;
  border-radius: 7px;
  text-align: start;
}
.rules-tabs button > .mf-icon { flex: none; }
.rules-tabs strong { font-size: 14px; line-height: 1.25; }
.rules-workspace .rules-tabs button[aria-pressed="true"] { background: #fff; box-shadow: inset 0 -2px var(--rule-blue); }
.rules-workspace .rules-overview {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 24px;
  margin-bottom: 12px;
  border: 1px solid var(--rule-line);
  border-radius: 7px;
  padding: 10px 14px;
  background: #fff;
}
.rules-overview > div { display: flex; flex-wrap: wrap; gap: 3px 7px; align-items: baseline; }
.rules-overview dt { color: var(--rule-muted); font-size: 13px; }
.rules-overview dd { font-weight: 700; }
.rules-overview-attention dd { color: #8b411c; }
.rules-panel {
  min-width: 0;
  background: #fff;
  border: 1px solid var(--rule-line);
  border-radius: 9px;
}
.rules-panel-head, .rules-panel-footer, .rules-filters, .rules-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
}
.rules-panel-head h2 { font-size: 18px; }
.rules-panel-footer { justify-content: flex-end; color: var(--rule-muted); font-size: 13px; }
.rules-panel-footer > span:first-child { margin-inline-end: auto; }
.rules-panel-footer label { display: flex; align-items: center; gap: 7px; }
.rules-filters { justify-content: start; align-items: end; background: #f5f8fb; border-bottom: 1px solid #e0e9ef; }
.rules-filters > label { display: grid; gap: 4px; font-size: 12px; min-width: 116px; max-width: 100%; }
.rules-filters > label:first-child { flex: 1 1 190px; }
.rules-list-toolbar { border-radius: 8px 8px 0 0; }
.rules-list-toolbar > label:first-child { flex: 1 1 245px; max-width: min(450px,100%); }
.rules-list-toolbar > label > :is(input,select) { width: 100%; }
#content .rules-list-toolbar input[type='search'] { max-width: none; }
.rules-list-toolbar > label:not(:first-child) { max-width: min(246px,100%); }
.rules-banner + .rules-list-toolbar { border-radius: 0; }
.rules-extra-filters[hidden] { display: none; }
.rules-extra-filters > label:first-child { flex: 0 1 auto; }
.rules-banner { justify-content: start; gap: 12px; background: #fff6e5; color: #745320; border-radius: 8px 8px 0 0; }
.rules-list { padding: 16px; display: grid; gap: 22px; }
.rules-list-section { display: grid; gap: 9px; min-width: 0; }
.rules-list-section h2 { font-size: 16px; }
.rules-group-card { border: 1px solid var(--rule-line); border-radius: 8px; min-width: 0; }
.rules-group-card:focus-within { border-color: #98c2dc; }
.rules-group-card > header {
  display: flex;
  min-height: 0;
  justify-content: space-between;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: #edf5fa;
  border-radius: 7px;
}
.rules-group-card > header > div:first-child { display: grid; min-width: 0; flex: 1 1 220px; gap: 0; }
.rules-group-card:has(.rules-group-toggle[aria-expanded="true"]) > header { border-radius: 7px 7px 0 0; }
.rules-workspace .rules-group-toggle {
  justify-content: start;
  min-width: 0;
  max-width: 100%;
  min-height: 32px;
  gap: 8px;
  padding: 4px;
  border: 0;
  background: transparent;
  text-align: start;
}
.rules-group-toggle > .mf-icon { flex: none; color: var(--rule-muted); }
.rules-group-toggle[aria-expanded="true"] > .mf-icon { transform: rotate(90deg); }
.rules-group-toggle > span, .rules-group-name, .rules-group-summary, .rules-group-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px 10px;
  min-width: 0;
}
.rules-group-name { color: #075f8c; font-size: 15px; overflow-wrap: anywhere; }
.rules-group-name strong { min-width: 0; }
.rules-group-name .mf-icon { flex: none; }
.rules-group-summary, .rules-group-cabinets-summary { color: var(--rule-muted); font-size: 12px; font-weight: 500; }
.rules-group-summary > span + span { border-inline-start: 1px solid #b8cbd8; padding-inline-start: 8px; }
.rules-group-summary .rules-group-attention { color: #8b411c; }
.rules-group-summary .rules-group-running { color: #146248; }
.rules-group-cabinets-summary { display: block; padding-inline-start: 28px; overflow-wrap: anywhere; }
.rules-group-actions { justify-content: end; width: auto; gap: 6px; margin-inline-start: auto; }
.rules-group-members:not([hidden]) { display: grid; gap: 10px; padding: 10px; border-top: 1px solid var(--rule-line); }
.rules-empty-group { display: grid; gap: 4px; padding: 8px; font-size: 13px; }
.rules-empty-group :is(p,small) { color: var(--rule-muted); font-size: 13px; }
.rules-show-more { display: flex; justify-content: center; padding: 3px; }
.rules-account { border: 1px solid var(--rule-line); border-radius: 7px; min-width: 0; }
.rules-account > header {
  display: flex;
  min-height: 0;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  background: var(--rule-soft);
  border-radius: 6px 6px 0 0;
}
.rules-account > header label { display: flex; gap: 7px; align-items: center; }
.rules-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto auto;
  gap: 10px;
  align-items: center;
  min-width: 0;
  padding: 10px 12px;
  border-top: 1px solid #e5edf2;
}
.rules-row:nth-child(odd) { background: #f7f9fb; }
.rules-row:has(> input:checked) { background: #e5f1fa; }
.rules-row > input, .rules-account input[type="checkbox"], .rules-dialog input[type="checkbox"] {
  accent-color: var(--rule-blue);
  min-height: 0;
  width: 15px;
  height: 15px;
}
.rules-row-main { overflow-wrap: anywhere; }
.rules-row h3, .rules-card h3 { font-size: 15px; }
.rules-row p, .rules-card p { font-size: 13px; }
.rules-threshold-summary { font-weight: 650; }
.rules-row small, .rules-card small, .rules-table-scroll small, .rules-account-options small {
  display: block;
  color: var(--rule-muted);
  font-size: 12px;
}
.rules-workspace .rules-rule-name {
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: #075f8c;
  font-weight: 700;
  text-align: start;
  overflow-wrap: anywhere;
}
.rules-rule-name:hover { text-decoration: underline; }
.rules-workspace .rules-row-button { min-height: 34px; padding: 4px 8px; font-size: 13px; }
.rules-menu { position: relative; width: max-content; }
.rules-menu summary {
  cursor: pointer;
  list-style: none;
  display: grid;
  place-items: center;
  width: 34px;
  min-height: 34px;
  border: 1px solid #aebfcd;
  border-radius: 5px;
  background: #fff;
  font-weight: 700;
}
.rules-menu summary::-webkit-details-marker { display: none; }
.rules-menu summary:hover, .rules-menu[open] summary { background: var(--rule-soft); }
.rules-create > summary {
  display: flex;
  align-items: center;
  gap: 7px;
  width: auto;
  min-height: 38px;
  padding: 5px 10px;
  border-color: var(--rule-blue);
  background: var(--rule-blue);
  color: #fff;
}
.rules-create > summary:hover, .rules-create[open] > summary { background: #086698; }
.rules-menu[open] > div {
  position: absolute;
  inset: calc(100% + 5px) 0 auto auto;
  z-index: 5;
  display: grid;
  min-width: 198px;
  border: 1px solid #c7d6df;
  border-radius: 7px;
  padding: 4px;
  box-shadow: 0 6px 18px #203c5125;
  background: #fff;
}
.rules-workspace .rules-menu button {
  justify-content: start;
  border: 0;
  min-height: 34px;
  padding: 5px 8px;
  text-align: start;
}
.rules-workspace .rules-danger-action { color: #961b2b; }
.rules-bulk {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 6px;
  position: fixed;
  inset: auto 12px 12px;
  z-index: 8;
  width: fit-content;
  max-width: calc(100% - 24px);
  margin: auto;
  border-radius: 8px;
  padding: 7px;
  border: 1px solid #afc7d6;
  background: #fff;
  box-shadow: 0 4px 16px #19364326;
}
.rules-card-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(min(250px,100%),1fr)); gap: 10px; padding: 10px 14px 14px; }
.rules-card {
  display: grid;
  align-content: start;
  gap: 4px;
  min-width: 0;
  padding: 13px;
  border: 1px solid var(--rule-line);
  border-radius: 7px;
  overflow-wrap: anywhere;
}
.rules-card-actions { margin-top: 6px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 5px; }
.rules-card-actions > div { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; }
.rules-template-pair {
  grid-template-rows: auto auto 1fr;
  border-color: #b9d5e6;
  background: #f2f8fc;
}
.rules-template-pair .rules-card-actions { align-self: end; }
.rules-empty, .rules-empty-state { padding: 20px 14px; color: var(--rule-muted); text-align: center; }
.rules-empty > button { margin-top: 8px; }
.rules-empty-state { display: grid; justify-items: center; gap: 9px; padding-block: 52px; }
.rules-empty-state > .mf-icon { width: 34px; height: 34px; color: var(--rule-blue); }
.rules-empty-state > h2 { font-size: 20px; color: var(--ink); }
.rules-empty-state > p { max-width: 40ch; }
.rules-empty-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 7px; margin-top: 6px; }
.rules-warning, .rules-row .rules-warning { color: #8b411c; }
.rules-log-context { padding: 10px 14px; color: var(--rule-muted); }
.rules-table-scroll { overflow-x: auto; }
.rules-table-scroll table { min-width: 620px; }
.rules-table-scroll :is(th,td) { text-align: start; }
.rules-table-scroll small { margin-top: 2px; }
.rules-diagnostics { margin: 6px 14px 14px; border: 1px solid var(--rule-line); border-radius: 6px; padding: 8px 11px; }
.rules-diagnostics summary, .rules-disclosure summary { cursor: pointer; color: #075f8c; font-weight: 650; }
.rules-diagnostics p { max-width: 64ch; margin: 8px 0; color: var(--rule-muted); font-size: 13px; }

dialog.rules-dialog { width: min(850px, calc(100vw - 28px)); max-height: 92dvh; padding: 0; }
.rules-dialog .dialogTop { padding: 14px 19px; border-bottom: 1px solid var(--rule-line); margin: 0; }
.rules-dialog .dialogTop h2 { margin: 0; font-size: 20px; }
.rules-dialog #dialogBody { padding: 12px 19px 16px; }
.rules-dialog #dialogBody > .err:empty { display: none; }
.rules-editor-nav, .rules-editor-footer, .rules-durations, .rules-steps, .rules-picker-tools, .rules-editor-sources {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.rules-editor-nav { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); padding-bottom: 10px; }
.rules-editor-nav button { min-height: 36px; padding: 4px 8px; font-size: 13px; }
.rules-editor-nav button[aria-current] { background: #e1f1fb; color: #075a86; border-color: #a4cde4; box-shadow: inset 0 -2px var(--rule-blue); }
.rules-editor-nav button:disabled { cursor: default; }
.rules-editor-scroll {
  display: grid;
  gap: 10px;
  align-content: start;
  max-height: min(62dvh, 630px);
  overflow: auto;
  padding: 12px 2px;
  border-block: 1px solid var(--rule-line);
}
.rules-editor-step-title, .rules-group-body h3 { margin: 0; font-size: 16px; }
.rules-editor-step-title:focus { outline: 0; }
.rules-editor-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(190px,100%),1fr)); gap: 8px; }
.rules-required-name::placeholder { color: #b31224; opacity: 1; }
.rules-threshold-box { padding: 10px; border: 1px solid var(--rule-line); border-radius: 6px; }
.rules-purchase-choice { min-width: 0; margin: 0; padding: 8px 10px 10px; border: 1px solid var(--rule-line); border-radius: 6px; }
.rules-purchase-choice legend { padding-inline: 4px; font-weight: 650; }
.rules-purchase-choice > .rules-hint { margin-top: 6px; }
.rules-group-timing { min-width: 0; margin: 0; padding: 5px 8px 8px; border: 1px solid var(--rule-line); border-radius: 6px; }
.rules-group-timing legend { padding-inline: 4px; font-weight: 650; }
.rules-span { grid-column: 1 / -1; }
.rules-editor-footer { padding-top: 12px; justify-content: flex-end; }
[data-rules-form="editor"] > .rules-editor-footer { justify-content: space-between; }
.rules-editor-footer > div { display: flex; flex-wrap: wrap; gap: 6px; }
.rules-editor-footer button:disabled { cursor: default; }
.rules-dialog :is(input,select,textarea,label) { min-width: 0; }
.rules-dialog label:not(.rules-check) > :is(input:not([type="checkbox"]), select, textarea) { width: 100%; }
.rules-dialog .rules-check { display: flex; align-items: center; gap: 7px; }
.rules-picker { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(225px,100%),1fr)); gap: 8px; }
.rules-picker button { justify-content: start; text-align: start; }
.rules-picker .rules-help-title > button { flex: 1; }
.rules-picker-tools { margin-block: 4px; }
.rules-picker-tools > input[type="search"] { flex: 1 1 170px; }
.rules-count { padding: 4px 8px; color: #075a86; border-radius: 5px; background: #e4f1f9; white-space: nowrap; }
.rules-editor-sources { gap: 6px; }
.rules-editor-sources button { min-height: 33px; }
.rules-account-field > .rules-help-title { font-size: 14px; }
.rules-account-picker { display: grid; gap: 5px; }
.rules-account-options, .rules-object-list {
  display: grid;
  gap: 6px;
  max-height: 218px;
  overflow: auto;
  border: 1px solid var(--rule-line);
  padding: 6px;
  border-radius: 6px;
}
.rules-account-options fieldset, .rules-object-list fieldset { margin: 0; padding: 5px; min-width: 0; border: 1px solid #e0eaf0; border-radius: 5px; }
.rules-account-options label, .rules-object-list label { display: flex; align-items: center; gap: 6px; padding: 4px; cursor: pointer; }
.rules-account-options legend, .rules-object-list legend { padding-inline: 4px; }
.rules-account-name { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.rules-group-cabinets { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.rules-disclosure { border: 1px solid var(--rule-line); border-radius: 6px; padding: 9px 10px; background: #f8fafc; }
.rules-disclosure > div { display: grid; gap: 9px; padding-top: 9px; }
.rules-condition, .rules-condition-group, .rules-condition-primary { min-width: 0; }
.rules-condition-primary { display: grid; gap: 9px; padding: 10px; background: #f5f8fb; border-radius: 6px; border: 1px solid var(--rule-line); }
.rules-condition-primary > .rules-help-field { width: min(100%, 265px); }
.rules-condition { display: grid; grid-template-columns: minmax(132px,1.2fr) auto minmax(100px,1fr) minmax(130px,1fr); align-items: center; gap: 6px; }
.rules-operand, .rules-condition-actions { display: flex; align-items: center; gap: 5px; min-width: 0; }
.rules-condition-actions { grid-column: 1 / -1; justify-content: flex-end; }
.rules-condition-guide { margin-inline-end: auto; color: var(--rule-muted); font-size: 12px; font-weight: 650; }
.rules-operand :is(input,select) { flex: 1; width: 100%; }
.rules-condition :is(input,select,button) { min-height: 34px; }
.rules-condition-actions button, .rules-operand button { padding: 4px 7px; }
.rules-condition-group { display: grid; gap: 8px; border: 1px solid var(--rule-line); border-radius: 6px; padding: 8px; }
.rules-condition-group.is-empty { border: 0; padding: 0; }
.rules-condition-group.is-nested { border-inline-start: 3px solid #94c3df; background: #f7fafc; }
.rules-condition-group > :is(header,footer) { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; font-size: 13px; }
.rules-condition-group > :is(header,footer) :is(button,select) { min-height: 33px; }
.rules-hint { color: var(--rule-muted); font-size: 13px; margin: 0; }
.rules-durations input { width: 86px; }
.rules-protection { padding: 9px 11px; border-radius: 5px; margin: 0; color: #853c1b; background: #fff2e4; }
.rules-review { margin: 0; border: 1px solid var(--rule-line); border-radius: 7px; overflow: hidden; }
.rules-review > div { display: grid; grid-template-columns: minmax(92px,150px) minmax(0,1fr); gap: 8px; padding: 8px 10px; }
.rules-review > div:nth-child(odd) { background: #f2f7fa; }
.rules-review dt { color: var(--rule-muted); }
.rules-review dd { font-weight: 620; margin: 0; overflow-wrap: anywhere; }
.rules-review-activation { display: grid; gap: 8px; }
.rules-details { display: grid; gap: 10px; max-height: 66dvh; overflow-y: auto; }
.rules-detail-status { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; color: var(--rule-muted); }
.rules-detail-error { margin: 0; padding: 8px 10px; border-radius: 6px; color: #8b411c; background: #fff3e3; }
.rules-detail-logic { padding: 9px 12px; border-radius: 6px; background: #f4f8fa; border: 1px solid var(--rule-line); overflow-wrap: anywhere; }
.rules-detail-logic :is(h3,p) { margin: 0; }
.rules-detail-logic h3 { margin-bottom: 5px; font-size: 16px; }
.rules-detail-logic p + p { margin-top: 5px; }
.rules-detail-conditions { margin: 4px 0 8px; padding-inline-start: 18px; }
.rules-steps span { border-radius: 6px; font-size: 13px; padding: 5px 8px; background: #f0f5f8; }
.rules-steps [aria-current="step"] { background: #e1f1fb; color: #075a86; font-weight: 700; }
.rules-group-body { display: grid; gap: 8px; padding: 10px 0; }
.rules-preview-summary { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 7px; padding-bottom: 10px; }
.rules-preview-formula { padding: 0 0 8px; overflow-wrap: anywhere; }
.rules-preview-table { max-height: 42dvh; overflow: auto; }
.rules-blocked-list > div { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; padding: 12px 0; }
.rules-blocked-list > div + div { border-top: 1px solid var(--rule-line); }
.rules-blocked-list small { display: block; margin-top: 4px; color: var(--rule-muted); }
.rules-blocked-actions { display: flex; flex-wrap: wrap; gap: 6px; }

@media (max-width: 680px) {
  .rules-page-head > div { width: auto; }
  .rules-workspace .rules-tabs button { padding-inline: 8px; gap: 5px; }
  .rules-tabs strong { font-size: 13px; }
  .rules-tabs button > .mf-icon { width: 14px; height: 14px; }
  .rules-list { padding: 10px; }
  .rules-list-toolbar > label:first-child { flex-basis: 100%; max-width: 100%; }
  .rules-row { grid-template-columns: auto minmax(0,1fr) auto auto; }
  .rules-row-main { grid-column: span 3; }
  .rules-row > .mf-badge { grid-column: 2; width: fit-content; }
  .rules-editor-nav { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .rules-condition { grid-template-columns: minmax(0,1fr) minmax(0,1fr); }
  .rules-condition-group.is-nested { padding-inline: 5px; }
}
