.fba-rules-workbench {
    --rule-blue: #3478ed;
    --rule-ink: #263c59;
    --rule-muted: #7c8da4;
    --rule-line: #e5ebf3;
    box-sizing: border-box;
    width: min(1480px, calc(100vw - 40px));
    height: min(940px, calc(100dvh - 40px));
    max-height: calc(100dvh - 40px);
    padding: 0;
    border: 1px solid #dce4ef;
    border-radius: 12px;
    overflow: hidden;
    color: var(--rule-ink);
    background: #fff;
    box-shadow: 0 24px 80px #1a335440;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}
.fba-rules-workbench::backdrop { background: #182d4c66; }
.fba-rules-workbench > form { display: flex; flex-direction: column; height: 100%; min-height: 0; margin: 0; }
.fba-rules-workbench .fba-rules-top { flex: 0 0 56px; box-sizing: border-box; padding: 0 24px; gap: 18px; border-bottom: 1px solid var(--rule-line); }
.fba-rules-workbench h2 { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: .3px; }
.fba-rules-top > span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--rule-muted); font-size: 12px; }
.fba-rules-workbench .fba-rules-close { display: grid; place-items: center; width: 30px; height: 30px; padding: 0; border-radius: 6px; color: #8a9bb2; line-height: 1; }
.fba-rules-workbench .fba-rules-close:hover { background: #f1f5fb; color: #425e82; }
.fba-rule-tabs { display: flex; align-items: stretch; gap: 28px; flex: 0 0 46px; padding: 0 24px; border-bottom: 1px solid var(--rule-line); background: #fff; }
.fba-rule-tabs button { position: relative; padding: 0 4px; border: 0; background: none; color: #687c96; cursor: pointer; font: inherit; font-size: 13px; }
.fba-rule-tabs button::after { position: absolute; bottom: -1px; left: 0; right: 0; height: 3px; border-radius: 3px 3px 0 0; background: transparent; content: ''; }
.fba-rule-tabs button.active { color: var(--rule-blue); font-weight: 600; }
.fba-rule-tabs button.active::after { background: var(--rule-blue); }
.fba-rule-tabs > span { margin-left: auto; align-self: center; padding: 5px 9px; border: 1px solid #e3ebf8; border-radius: 5px; background: #f7faff; color: #8193ad; font-size: 11px; }
.fba-sales-layout { display: grid; grid-template-columns: minmax(0, 55%) minmax(0, 45%); flex: 1; min-height: 0; background: #f5f7fb; }
.fba-sales-config, .fba-sales-analysis { min-width: 0; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #d1dbe9 transparent; overscroll-behavior: contain; }
.fba-sales-config { padding: 18px 9px 18px 18px; }
.fba-sales-analysis { padding: 18px 18px 18px 9px; }
.fba-rule-card, .fba-analysis-card { margin: 0 0 16px; border: 1px solid var(--rule-line); border-radius: 8px; background: #fff; box-shadow: 0 2px 5px #223b5c03; overflow: hidden; }
.fba-rule-card:last-child, .fba-analysis-card:last-child { margin-bottom: 0; }
.fba-rule-card h3, .fba-analysis-card > h3 { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 10px; margin: 0; padding: 15px 18px; border: 0; border-bottom: 1px solid var(--rule-line); color: var(--rule-ink); font-size: 13px; font-weight: 600; line-height: 1.6; }
.fba-rule-card h3 small { color: #8292a8; font-size: 11px; font-weight: 400; }
.fba-rule-card-body { padding: 18px; }
.fba-rules-workbench em { color: #e87984; font-style: normal; }
.fba-help { color: #99abc1; font-size: 12px; cursor: help; font-weight: 400; }
.fba-rules-workbench input, .fba-rules-workbench select { box-sizing: border-box; height: 34px; min-width: 0; border: 1px solid #d6dfec; border-radius: 5px; padding: 0 10px; background: #fff; color: var(--rule-ink); font: inherit; font-size: 12px; transition: border-color .15s, box-shadow .15s; }
.fba-rules-workbench input:hover, .fba-rules-workbench select:hover { border-color: #afc3e1; }
.fba-rules-workbench input:focus, .fba-rules-workbench select:focus { outline: none; border-color: #729eef; box-shadow: 0 0 0 3px #3478ed12; }
.fba-rules-workbench input[type=number] { appearance: textfield; -moz-appearance: textfield; }
.fba-rules-workbench input[type=number]::-webkit-inner-spin-button { appearance: none; }
.fba-rules-workbench input[type=date] { padding: 0 7px; font-size: 11px; }
.fba-rule-default { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; padding: 0 0 18px; background: #fff; }
.fba-rule-default > label, .fba-rule-default > div { display: grid; grid-template-rows: 22px 38px; align-items: center; gap: 6px; min-width: 0; color: #687d98; font-size: 12px; }
.fba-rule-default > label > select, .fba-rule-default > label > input { width: 100%; height: 38px; }
.fba-rule-default > div { padding: 0 12px; border-radius: 6px; background: #f1f6ff; }
.fba-rule-default output { align-self: start; color: #2b6dd6; font-size: 24px; font-weight: 600; line-height: 1.5; }
.fba-rule-default output::after { margin-left: 5px; content: '件/天'; font-size: 10px; color: #7e9bc3; font-weight: 400; white-space: nowrap; }
.fba-history-period { margin-bottom: 14px; padding: 10px 12px; background: #f7f9fc; border-radius: 5px; }
.fba-history-period label { display: flex; align-items: center; gap: 12px; font-size: 12px; color: #71849f; }
.fba-rule-table { width: 100%; border-spacing: 0; border-collapse: separate; font-size: 12px; text-align: left; white-space: nowrap; }
.fba-rule-table th { padding: 11px 12px; border-bottom: 1px solid var(--rule-line); background: #f4f7fb; color: #6e829d; font-weight: 500; }
.fba-rule-table td { padding: 11px 12px; border-bottom: 1px solid #edf1f6; color: #364f70; }
.fba-rule-table tr:last-child td { border-bottom: 0; }
.fba-rule-table tbody tr:hover { background: #fafcff; }
.fba-weight-wrap { padding: 0; overflow-x: auto; }
.fba-weight-table { min-width: 510px; border: 1px solid var(--rule-line); border-radius: 6px; table-layout: fixed; overflow: hidden; }
.fba-weight-table th, .fba-weight-table td { padding: 10px 6px; border-right: 1px solid #edf1f6; text-align: center; }
.fba-weight-table th:first-child { width: 80px; text-align: left; padding-left: 10px; }
.fba-weight-table th:last-child, .fba-weight-table td:last-child { border-right: 0; }
.fba-weight-table tbody th { background: #fafbfd; color: #7b8ca4; font-weight: 400; }
.fba-weight-table tbody tr:last-child th { border-bottom: 0; }
.fba-weight-input { position: relative; }
.fba-weight-input input { width: 100%; height: 32px; padding: 0 20px 0 6px; text-align: center; border-color: #dde5f0; }
.fba-weight-input span { position: absolute; right: 7px; top: 9px; color: #8ca1bc; font-size: 10px; pointer-events: none; }
.fba-weight-wrap > small { display: block; margin-top: 10px; text-align: right; font-size: 11px; color: #7c8fa8; }
.fba-weight-wrap > small.invalid { color: #cf586a; }
.fba-rule-info { display: flex; align-items: flex-start; gap: 9px; margin-bottom: 22px; padding: 12px; border: 1px solid #e0ebfc; border-radius: 6px; background: #f3f7ff; color: #6b82a4; font-size: 11px; line-height: 1.8; }
.fba-rule-info b { display: grid; place-items: center; flex: 0 0 14px; height: 14px; margin-top: 3px; border-radius: 50%; background: #6499ed; color: #fff; font-size: 10px; }
.fba-rule-info button { margin-left: auto; padding: 0 2px; border: 0; background: none; color: #97aac4; font-size: 17px; cursor: pointer; }
.fba-custom-section + .fba-custom-section { margin-top: 24px; padding-top: 22px; border-top: 1px solid #edf1f7; }
.fba-custom-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.fba-custom-heading h4 { margin: 0; padding-left: 9px; border-left: 3px solid #7ba5f0; color: #435d7d; font-size: 12px; font-weight: 500; }
.fba-calendar-switch { display: inline-flex; padding: 3px; border-radius: 6px; background: #f1f4f9; }
.fba-calendar-switch button { height: 27px; padding: 0 11px; border: 0; border-radius: 4px; background: transparent; color: #7d8fa8; font: inherit; font-size: 11px; cursor: pointer; }
.fba-calendar-switch button.active { background: #fff; color: var(--rule-blue); box-shadow: 0 1px 4px #294d7814; }
.fba-custom-table-wrap, .fba-forecast-wrap { overflow: auto; border: 1px solid var(--rule-line); border-radius: 6px; scrollbar-width: thin; scrollbar-color: #d1dbe9 transparent; }
.fba-custom-table { min-width: 560px; table-layout: fixed; }
.fba-custom-table th:nth-child(1) { width: 21%; }
.fba-custom-table th:nth-child(2) { width: 29%; }
.fba-custom-table th:nth-child(3) { width: 20%; }
.fba-custom-table th:nth-child(4) { width: 19%; }
.fba-custom-table th:nth-child(5) { width: 11%; }
.fba-custom-table th, .fba-custom-table td { box-sizing: border-box; padding: 10px 8px; }
.fba-custom-table input, .fba-custom-table select { width: 100%; }
.fba-custom-table select, .fba-rule-range input + input { margin-top: 6px; }
.fba-custom-table th:nth-last-child(2), .fba-custom-table td:nth-last-child(2) { text-align: right; }
.fba-custom-table th:last-child, .fba-custom-table td:last-child { text-align: center; }
.fba-rule-table .fba-rule-empty { height: 86px; text-align: center; color: #93a3b8; font-size: 12px; background: #fff; }
.fba-rule-link { padding: 2px 4px; border: 0; border-radius: 3px; background: none; color: var(--rule-blue); cursor: pointer; font: inherit; font-size: 12px; }
.fba-rule-link:hover { background: #edf4ff; }
.fba-rule-add { width: 100%; height: 35px; border: 0; border-top: 1px solid var(--rule-line); background: #fafcff; color: #5784c9; cursor: pointer; font-size: 12px; }
.fba-rule-add:hover { background: #f0f6ff; }
.fba-chart-toolbar { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; margin: 16px 16px 22px; }
.fba-chart-toolbar > div { display: flex; }
.fba-chart-toolbar button { height: 31px; padding: 0 10px; border: 1px solid #d6dfec; background: #fff; color: #667f9f; font: inherit; font-size: 11px; cursor: pointer; }
.fba-chart-toolbar button:first-child { border-radius: 5px 0 0 5px; }
.fba-chart-toolbar button:last-child { margin-left: -1px; border-radius: 0 5px 5px 0; }
.fba-chart-toolbar button:hover { position: relative; color: var(--rule-blue); border-color: #aac5f1; background: #f7faff; }
.fba-chart-dates { align-items: center; gap: 4px; padding: 0 5px; border: 1px solid #d6dfec; border-radius: 5px; }
.fba-chart-dates input { width: 123px; height: 29px; border: 0; background: transparent; }
.fba-chart-dates > span { color: #97a7be; }
.fba-chart-legend { display: flex; justify-content: center; flex-wrap: wrap; gap: 18px; margin: 0 16px 12px; color: #7b8ba2; font-size: 11px; }
.fba-chart-legend > span { display: flex; align-items: center; gap: 6px; }
.fba-chart-legend i { width: 18px; border-top: 2px solid #2cb0ff; }
.fba-chart-legend i.forecast { border-top-style: dashed; }
.fba-chart-legend i.smoothed { border-top-color: #85d75a; }
.fba-sales-chart { display: block; width: calc(100% - 18px); margin: 0 9px; height: auto; min-height: 250px; }
.fba-sales-chart text { font-size: 11px; fill: #8d9db4; }
.fba-sales-chart .fba-chart-today { fill: #fff; font-size: 12px; }
.fba-analysis-note { margin: 12px 16px 16px; color: #8b9bb1; font-size: 11px; line-height: 1.8; }
.fba-analysis-card > .fba-rules-error { margin: 12px 16px; line-height: 1.6; }
.fba-forecast-wrap { margin: 16px; max-height: 320px; }
.fba-forecast-table { min-width: 470px; }
.fba-forecast-table th { position: sticky; top: 0; z-index: 1; padding: 12px 9px; font-size: 11px; }
.fba-forecast-table td { padding: 14px 9px; font-size: 11px; }
.fba-forecast-table th:nth-child(n+3), .fba-forecast-table tbody td:nth-child(n+3) { text-align: right; }
.fba-forecast-table small { display: block; max-width: 110px; overflow: hidden; text-overflow: ellipsis; margin-top: 5px; color: #8ea0b8; font-size: 10px; }
.fba-forecast-table tfoot td { position: sticky; bottom: 0; background: #f6f9fe; border-top: 1px solid var(--rule-line); font-weight: 600; color: #5174a5; }
.fba-forecast-table tfoot td:not(:first-child) { text-align: right; }
.fba-calendar-heading { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 12px; }
.fba-calendar-heading strong { font-size: 12px; font-weight: 500; color: #5b7391; }
.fba-calendar-heading button { width: 30px; height: 28px; border: 1px solid #dce4f0; border-radius: 5px; background: #fff; color: #7490b4; cursor: pointer; }
.fba-calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; }
.fba-calendar-grid > span { padding: 8px; text-align: center; color: #8c9db5; font-size: 11px; }
.fba-calendar-grid button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px; height: 60px; border: 1px solid #e9eef6; border-radius: 6px; background: #fff; color: #667e9c; font: inherit; font-size: 11px; cursor: pointer; }
.fba-calendar-grid button.today { border-color: #90b4f1; background: #f4f8ff; color: var(--rule-blue); }
.fba-calendar-grid button:hover:enabled { border-color: #a9c5f3; background: #edf4ff; }
.fba-calendar-grid button:disabled { opacity: .4; cursor: default; background: #fafbfd; }
.fba-calendar-grid small { color: #4281e5; font-size: 11px; }
.fba-rule-calendar p { margin-bottom: 0; font-size: 11px; color: #8c9db3; }
.fba-stock-rule-body { flex: 1; min-height: 0; padding: 24px; overflow: auto; background: #f5f7fb; }
.fba-stock-rule-body .fba-rule-card { max-width: 780px; }
.fba-stock-rule-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; padding: 10px 22px 24px; }
.fba-stock-rule-fields label { color: #657e9f; font-size: 12px; }
.fba-stock-rule-fields .fba-rule-input { padding-right: 10px; border: 1px solid #d6dfec; border-radius: 5px; gap: 0; }
.fba-stock-rule-fields .fba-rule-input input { border: 0; height: 38px; }
.fba-stock-rule-fields small { color: #8c9db3; font-size: 11px; }
.fba-rule-save-error { padding: 10px 24px; background: #fff5f6; border-top: 1px solid #f7e1e5; color: #ca5b6c; font-size: 12px; }
.fba-rules-workbench > form > footer { position: relative; flex: 0 0 auto; gap: 10px; padding: 14px 24px; border-top: 1px solid var(--rule-line); background: #fff; box-shadow: 0 -3px 12px #25436405; }
.fba-rules-workbench > form > footer > span { margin-right: auto; color: #8a9bb1; font-size: 11px; }
.fba-rules-workbench > form > footer > button { min-width: 78px; height: 34px; padding: 0 18px; border-radius: 5px; border-color: #d7e1ed; color: #667f9e; font-size: 12px; }
.fba-rules-workbench > form > footer > button.primary { border-color: var(--rule-blue); background: var(--rule-blue); color: #fff; box-shadow: 0 2px 5px #3478ed1c; }
.fba-rules-workbench > form > footer > button:hover { filter: brightness(.98); }
.fba-rules-workbench button:focus-visible { outline: 2px solid #7ca5ef; outline-offset: 2px; }
@media (max-width: 1150px) {
    .fba-rules-workbench { width: calc(100vw - 24px); height: calc(100dvh - 24px); max-height: calc(100dvh - 24px); }
    .fba-sales-layout { display: block; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
    .fba-sales-config, .fba-sales-analysis { overflow: visible; padding: 16px; }
    .fba-sales-analysis { padding-top: 0; }
    .fba-sales-chart { max-height: 340px; }
    .fba-forecast-wrap { max-height: none; }
}
@media (max-width: 600px) {
    .fba-rules-workbench { width: calc(100vw - 12px); height: calc(100dvh - 12px); max-height: calc(100dvh - 12px); border-radius: 8px; }
    .fba-rules-workbench .fba-rules-top { padding: 0 14px; gap: 10px; }
    .fba-rules-workbench h2 { font-size: 14px; }
    .fba-rules-top > span { font-size: 11px; }
    .fba-rule-tabs { padding: 0 14px; gap: 16px; }
    .fba-rule-tabs > span { max-width: 105px; padding: 3px 6px; font-size: 10px; line-height: 1.5; }
    .fba-sales-config, .fba-sales-analysis { padding: 10px; }
    .fba-sales-analysis { padding-top: 0; }
    .fba-rule-card-body { padding: 12px; }
    .fba-rule-card h3, .fba-analysis-card > h3 { padding: 12px; }
    .fba-rule-card h3 small { flex-basis: 100%; line-height: 1.8; }
    .fba-rule-default { grid-template-columns: 1fr 1fr; gap: 12px; }
    .fba-rule-default > div { grid-column: 1 / -1; grid-template-columns: 1fr auto; grid-template-rows: 52px; }
    .fba-rule-default output { align-self: center; }
    .fba-rule-info { margin-bottom: 18px; padding: 10px; }
    .fba-calendar-switch button { padding: 0 8px; }
    .fba-chart-toolbar { margin: 12px; justify-content: flex-start; }
    .fba-chart-dates { flex: 1; }
    .fba-chart-dates input { flex: 1; width: 0; min-width: 103px; padding: 0 3px; }
    .fba-sales-chart { min-height: 190px; }
    .fba-stock-rule-body { padding: 12px; }
    .fba-stock-rule-fields { grid-template-columns: 1fr; gap: 0; padding: 8px 16px 20px; }
    .fba-rules-workbench > form > footer { padding: 12px 14px; }
    .fba-rules-workbench > form > footer > span { max-width: 120px; line-height: 1.5; }
    .fba-rules-workbench > form > footer > button { min-width: 65px; }
}
@media (prefers-reduced-motion: reduce) {
    .fba-rules-workbench input, .fba-rules-workbench select { transition: none; }
}

/* Keep native scrolling and use the same quiet treatment on both axes. */
:is(.fba-table-wrap, .fba-sales-layout, .fba-sales-config, .fba-sales-analysis, .fba-stock-rule-body, .fba-weight-wrap, .fba-custom-table-wrap, .fba-forecast-wrap) {
    --fba-scroll-thumb: #d2dbe7;
    scrollbar-width: thin;
    scrollbar-color: var(--fba-scroll-thumb) transparent;
}
:is(.fba-table-wrap, .fba-sales-layout, .fba-sales-config, .fba-sales-analysis, .fba-stock-rule-body, .fba-weight-wrap, .fba-custom-table-wrap, .fba-forecast-wrap):is(:hover, :focus-within) {
    --fba-scroll-thumb: #a9bad0;
}
:is(.fba-sales-config, .fba-sales-analysis, .fba-stock-rule-body) {
    scrollbar-gutter: stable;
}
@supports selector(::-webkit-scrollbar) {
    :is(.fba-table-wrap, .fba-sales-layout, .fba-sales-config, .fba-sales-analysis, .fba-stock-rule-body, .fba-weight-wrap, .fba-custom-table-wrap, .fba-forecast-wrap) {
        scrollbar-width: auto;
        scrollbar-color: auto;
    }
    :is(.fba-table-wrap, .fba-sales-layout, .fba-sales-config, .fba-sales-analysis, .fba-stock-rule-body, .fba-weight-wrap, .fba-custom-table-wrap, .fba-forecast-wrap)::-webkit-scrollbar {
        width: 8px;
        height: 8px;
    }
    :is(.fba-table-wrap, .fba-sales-layout, .fba-sales-config, .fba-sales-analysis, .fba-stock-rule-body, .fba-weight-wrap, .fba-custom-table-wrap, .fba-forecast-wrap)::-webkit-scrollbar-thumb {
        min-height: 36px;
        min-width: 36px;
        border: 2px solid transparent;
        border-radius: 8px;
        background: var(--fba-scroll-thumb);
        background-clip: padding-box;
    }
    :is(.fba-table-wrap, .fba-sales-layout, .fba-sales-config, .fba-sales-analysis, .fba-stock-rule-body, .fba-weight-wrap, .fba-custom-table-wrap, .fba-forecast-wrap)::-webkit-scrollbar-thumb:hover {
        background-color: #8fa5c1;
    }
    :is(.fba-table-wrap, .fba-sales-layout, .fba-sales-config, .fba-sales-analysis, .fba-stock-rule-body, .fba-weight-wrap, .fba-custom-table-wrap, .fba-forecast-wrap)::-webkit-scrollbar-thumb:active {
        background-color: #6889b4;
    }
    :is(.fba-table-wrap, .fba-sales-layout, .fba-sales-config, .fba-sales-analysis, .fba-stock-rule-body, .fba-weight-wrap, .fba-custom-table-wrap, .fba-forecast-wrap)::-webkit-scrollbar-track,
    :is(.fba-table-wrap, .fba-sales-layout, .fba-sales-config, .fba-sales-analysis, .fba-stock-rule-body, .fba-weight-wrap, .fba-custom-table-wrap, .fba-forecast-wrap)::-webkit-scrollbar-corner {
        background: transparent;
    }
    :is(.fba-table-wrap, .fba-sales-layout, .fba-sales-config, .fba-sales-analysis, .fba-stock-rule-body, .fba-weight-wrap, .fba-custom-table-wrap, .fba-forecast-wrap)::-webkit-scrollbar-button {
        display: none;
        width: 0;
        height: 0;
    }
}
@media (max-width: 1150px) {
    .fba-sales-config, .fba-sales-analysis { scrollbar-gutter: auto; }
    .fba-sales-layout { scrollbar-gutter: stable; }
}
@media (forced-colors: active), (pointer: coarse) {
    :is(.fba-table-wrap, .fba-sales-layout, .fba-sales-config, .fba-sales-analysis, .fba-stock-rule-body, .fba-weight-wrap, .fba-custom-table-wrap, .fba-forecast-wrap) {
        scrollbar-width: auto;
        scrollbar-color: auto;
    }
    :is(.fba-table-wrap, .fba-sales-layout, .fba-sales-config, .fba-sales-analysis, .fba-stock-rule-body, .fba-weight-wrap, .fba-custom-table-wrap, .fba-forecast-wrap)::-webkit-scrollbar {
        width: 12px;
        height: 12px;
    }
}
@media (forced-colors: active) {
    :is(.fba-table-wrap, .fba-sales-layout, .fba-sales-config, .fba-sales-analysis, .fba-stock-rule-body, .fba-weight-wrap, .fba-custom-table-wrap, .fba-forecast-wrap) { --fba-scroll-thumb: ButtonText; }
}

.fba-rules-controls{display:contents}.fba-rule-message{margin:0;padding:10px 24px;background:#edf4ff;color:#426088;font-size:12px}.fba-rules-dialog button:disabled{cursor:not-allowed;opacity:.55}.fba-bulk-bar{display:flex;align-items:center;gap:16px;padding:10px 20px;border-top:1px solid #e4ebf5;font-size:12px}.fba-save-notice{margin:0;padding:8px 20px;color:#168451;font-size:12px}
