.rules-dialog {
  --rules-canvas:#fafafa; --rules-surface:#fff; --rules-text:#191919; --rules-muted:#595959;
  --rules-border:#b8b8b8; --rules-subtle:#e5e5e5; --rules-accent:#EF2972;
  --rules-focus:var(--rules-accent); --rules-control:42px; --rules-gap:20px;
  width:min(1240px,96vw); height:min(900px,94dvh); max-height:94dvh; padding:0;
  box-sizing:border-box; background:var(--rules-canvas); color:var(--rules-text);
  border:1px solid var(--rules-border); font:14px/1.6 system-ui,sans-serif; overflow:hidden;
}
.rules-dialog[open] { display:flex; flex-direction:column; }
.rules-dialog::backdrop { background:rgba(0,0,0,.55); }
html:has(.rules-dialog[open]),body:has(.rules-dialog[open]) { overflow:hidden; }
body[data-theme="dark"] .rules-dialog {
  --rules-canvas:#151515; --rules-surface:#1d1d1d; --rules-text:#f5f5f5;
  --rules-muted:#bdbdbd; --rules-border:#6c6c6c; --rules-subtle:#353535;
}
.rules-dialog * { box-sizing:border-box; }
.rules-dialog [hidden] { display:none!important; }
.rules-header { display:flex; justify-content:space-between; align-items:flex-start; gap:20px; padding:20px 24px; border-bottom:1px solid var(--rules-border); flex:none; }
.rules-eyebrow { font:10px/1.5 monospace; letter-spacing:.14em; color:var(--rules-muted); }
.rules-dialog h2 { margin:2px 0 0; font-size:24px; line-height:1.3; }
.rules-dialog h3 { margin:0 0 12px; font-size:20px; }
.rules-dialog h4 { margin:24px 0 8px; }
.rules-dialog p { margin:8px 0 16px; color:var(--rules-muted); overflow-wrap:anywhere; }
.rules-header p { margin:6px 0 0; font-size:12px; font-variant-numeric:tabular-nums; }
.rules-shell { display:grid; grid-template-columns:206px minmax(0,1fr); flex:1; min-height:0; }
.rules-shell nav { padding:18px 10px; border-right:1px solid var(--rules-border); overflow:auto; }
.rules-shell nav button { display:flex; align-items:center; gap:12px; width:100%; text-align:left; border:0; border-left:2px solid transparent; padding:12px 10px; margin-bottom:4px; }
.rules-shell nav small { font:10px monospace; color:var(--rules-muted); }
.rules-shell nav [aria-current="page"] { border-left-color:var(--rules-accent); background:var(--rules-subtle); font-weight:700; }
.rules-workspace { padding:24px; overflow:auto; overscroll-behavior:contain; scrollbar-gutter:stable; min-width:0; }
.rules-notice { border-left:2px solid var(--rules-accent); padding:8px 12px; font-size:12px; }
.rules-dialog fieldset { padding:0; margin:0; border:0; min-width:0; }
.rules-dialog label { display:grid; gap:7px; margin:14px 0; font-size:13px; font-weight:550; }
.rules-dialog input,.rules-dialog textarea,.rules-dialog select {
  width:100%; min-height:var(--rules-control); padding:9px 10px; font:inherit; font-weight:400;
  color:var(--rules-text); background:var(--rules-surface); border:1px solid var(--rules-border); border-radius:2px;
}
.rules-dialog input[type="number"] { font-variant-numeric:tabular-nums; min-width:110px; }
.rules-dialog textarea { resize:vertical; line-height:1.65; }
.rules-dialog button { cursor:pointer; min-height:var(--rules-control); padding:8px 12px; font:inherit; font-size:13px; color:var(--rules-text); background:transparent; border:1px solid var(--rules-border); border-radius:2px; }
.rules-dialog button:hover:not(:disabled) { border-color:var(--rules-accent); background:var(--rules-subtle); }
.rules-dialog button[data-publish],.rules-dialog button[data-confirm-rollback] { background:var(--rules-accent); border-color:var(--rules-accent); color:#101010; font-weight:700; }
.rules-dialog button:disabled { opacity:.5; cursor:not-allowed; }
.rules-dialog :focus-visible { outline:2px solid var(--rules-focus); outline-offset:3px; }
.rules-dialog [aria-invalid="true"] { border:2px solid var(--rules-accent); }
.rules-field-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:0 24px; }
.rules-table-scroll { overflow:auto; max-width:100%; margin:16px 0; border:1px solid var(--rules-border); }
.rules-dialog table { width:100%; border-collapse:collapse; text-align:left; table-layout:auto; background:var(--rules-surface); }
.rules-dialog th,.rules-dialog td { padding:10px 12px; border-bottom:1px solid var(--rules-subtle); font-size:12px; vertical-align:top; overflow-wrap:anywhere; }
.rules-dialog thead th { font-weight:600; background:var(--rules-subtle); white-space:nowrap; }
.rules-dialog td input,.rules-dialog td select { min-width:100px; }
.rules-dialog td button { white-space:nowrap; }
.rules-dialog [data-preview] { border-top:1px solid var(--rules-border); padding-top:24px; margin-top:24px; }
.rules-dialog [data-preview] table { table-layout:fixed; min-width:550px; }
.rules-dialog [data-preview] th { width:30%; }
.rules-dialog details { margin:24px 0; border-top:1px solid var(--rules-border); padding-top:16px; }
.rules-dialog summary { cursor:pointer; font-weight:600; min-height:32px; }
.rules-script { border-top:1px solid var(--rules-subtle); padding-top:12px; }
.rules-catalog dt { font-weight:700; margin-top:20px; }
.rules-catalog dd { margin:6px 0 0; color:var(--rules-muted); }
.rules-footer { flex:none; border-top:1px solid var(--rules-border); background:var(--rules-surface); padding:14px 24px; display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:10px; }
.rules-footer p { flex:1 1 240px; margin:0; font-size:12px; }
.rules-actions { display:flex; flex-wrap:wrap; gap:8px; }
@media(max-width:850px) {
  .rules-shell {grid-template-columns:172px minmax(0,1fr);}
  .rules-workspace {padding:18px;}
  .rules-field-grid {grid-template-columns:minmax(0,1fr);}
}
@media(max-width:600px) {
  .rules-dialog {width:100%;max-width:100%;height:100dvh;max-height:100dvh;margin:0;border:0;}
  .rules-header {padding:14px 16px;}
  .rules-shell {display:flex;flex-direction:column;}
  .rules-shell nav {display:flex;flex-wrap:wrap;gap:4px;padding:8px 12px;flex:none;border-right:0;border-bottom:1px solid var(--rules-border);}
  .rules-shell nav button {width:auto;margin:0;padding:6px 8px;min-height:36px;font-size:12px;}
  .rules-shell nav small {display:none;}
  .rules-workspace {padding:16px;flex:1;}
  .rules-dialog table {min-width:480px;}
  .rules-footer {padding:12px 16px;}
  .rules-actions {width:100%;display:grid;grid-template-columns:1fr 1fr;}
}
@media(prefers-reduced-motion:reduce) {.rules-dialog * {scroll-behavior:auto!important;transition:none!important;}}

/* Three fallback totals fit the operator form even at narrow widths. */
.rules-dialog .rules-fallback-table {min-width:0;table-layout:fixed;}
.rules-dialog .rules-fallback-table th:first-child {width:26%;}
.rules-dialog .rules-fallback-table thead th {white-space:normal;}
.rules-dialog .rules-fallback-table input {min-width:0;width:100%;}
/* Incremental configuration patterns: inherit the current rose theme. */
.rules-actions[hidden],.rules-workspace>.rules-notice[hidden]{display:none!important}
.config-heading,.config-inline{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap}.config-heading h3{margin:0}.config-heading p{margin:6px 0 12px}.config-inline{justify-content:flex-start}.config-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px}.config-grid label{min-width:0}.config-grid input{max-width:100%;box-sizing:border-box}.rules-dialog .config-check,.config-checks label{display:flex;align-items:center;gap:7px}.rules-dialog .config-check input,.config-checks input{width:16px;min-width:16px;height:16px;margin:0}.config-checks{display:flex;align-items:center;flex-wrap:wrap;gap:10px 16px;margin:10px 0}.config-checks>span{font-weight:600;flex-basis:100%}.config-state{display:inline-block;margin-left:10px;font-size:12px;font-weight:600}.temporary-rule-list article{display:flex;justify-content:space-between;gap:16px;padding:16px 0;border-bottom:1px solid var(--line,#ded7dc);flex-wrap:wrap}.temporary-rule-list article p{margin:5px 0}.temporary-rule-list small,.rules-dialog small{overflow-wrap:anywhere}.temporary-rule-editor{margin-top:22px;padding-top:18px;border-top:1px solid var(--line,#ded7dc)}.temporary-rule-editor fieldset{margin:16px 0;padding:16px;border:1px solid var(--line,#ded7dc);border-radius:8px;min-width:0}.temporary-rule-editor legend{font-weight:650;padding:0 6px}.temporary-rule-editor table input{min-width:76px;box-sizing:border-box}.temporary-rule-editor table select{min-width:128px}.rules-dialog [data-error=true]{color:#ad2346;font-weight:600}.fallback-model-layout{display:grid;grid-template-columns:minmax(170px,.7fr) minmax(0,1.3fr);gap:20px;margin-top:18px}.fallback-model-list{display:grid;gap:6px;margin-top:12px}.fallback-model-list button{text-align:left;white-space:normal;overflow-wrap:anywhere;min-height:56px}.fallback-model-list button[aria-pressed=true]{border-color:currentColor;background:#faedf2;color:#a21e4b}.fallback-model-list strong,.fallback-model-list small{display:block}.fallback-model-list small{margin-top:4px;font-size:12px}.fallback-model-layout section{min-width:0}.config-danger{color:#a21e4b}.config-empty{padding:24px 0}.config-primary{font-weight:700}.rules-dialog button:focus-visible,.rules-dialog input:focus-visible,.rules-dialog select:focus-visible{outline:2px solid currentColor;outline-offset:2px}
@media(max-width:700px){.fallback-model-layout,.config-grid{grid-template-columns:1fr}.fallback-model-list{grid-template-columns:repeat(2,minmax(0,1fr))}.config-heading{align-items:flex-start}.temporary-rule-editor fieldset{padding:12px}.temporary-rule-list article>.config-inline{width:100%}.rules-dialog .temporary-rule-editor table{min-width:590px}}
/* On narrow screens a tier becomes a labeled block; no horizontal hunting. */
@media(max-width:700px){.rules-dialog .temporary-rule-editor .rules-table-scroll{overflow:visible}.rules-dialog .temporary-rule-editor table{min-width:0;width:100%}.temporary-rule-editor thead{display:none}.temporary-rule-editor tbody,.temporary-rule-editor tr,.temporary-rule-editor td{display:block;width:100%;box-sizing:border-box}.temporary-rule-editor tr{padding:12px 0;margin:12px 0;border-bottom:1px solid var(--line,#ded7dc)}.temporary-rule-editor td{display:grid;grid-template-columns:95px minmax(0,1fr);align-items:center;gap:8px;padding:6px 0}.temporary-rule-editor td::before{font-size:12px;font-weight:600}.temporary-rule-editor td:nth-child(1)::before{content:'价差从（含）'}.temporary-rule-editor td:nth-child(2)::before{content:'到（不含）'}.temporary-rule-editor td:nth-child(3)::before{content:'加价方式'}.temporary-rule-editor td:nth-child(4)::before{content:'加价金额（元）'}.temporary-rule-editor td:nth-child(5)::before{content:'本档操作'}.temporary-rule-editor table input,.temporary-rule-editor table select{width:100%;min-width:0;box-sizing:border-box}}
