/* Margin Master UI — the WPF main window as a web page, hosted in Manager.
   Every font size on the screen derives from --mm-font-size, which the shell sets from the user's display
   configuration (DisplayPreferences). The WPF window renders Segoe UI 9pt = 12px, the default. */
:root { --mm-font-size: 12px; --mm-font: "Segoe UI", system-ui, sans-serif; }
.mm-shell code { font-size: calc(var(--mm-font-size) * 0.92); }

.mm-shell { display: flex; flex-direction: column; height: 100vh; margin: 0; font-family: var(--mm-font); font-size: var(--mm-font-size); background: #f3f4f6; color: #1e1e1e; line-height: 1.25; }
.mm-shell *, .mm-shell *::before, .mm-shell *::after { box-sizing: content-box; }
.mm-shell input, .mm-shell select, .mm-shell button { box-sizing: border-box; }
.mm-header { display: flex; align-items: center; justify-content: space-between; padding: 4px 12px; background: #1f3a5f; color: #fff; }
.mm-shell .mm-brand,
.mm-shell .mm-brand:link,
.mm-shell .mm-brand:visited,
.mm-shell .mm-brand:hover,
.mm-shell .mm-brand:focus,
.mm-shell .mm-brand:active { color: inherit; text-decoration: none; cursor: pointer; }
.mm-shell .mm-brand:hover .mm-brand-name,
.mm-shell .mm-brand:focus-visible .mm-brand-name { color: inherit; text-decoration: underline; }
.mm-brand-name { font-weight: 600; font-size: calc(var(--mm-font-size) * 1.25); margin-right: 8px; }
.mm-brand-tag { opacity: .75; font-size: calc(var(--mm-font-size) * 0.92); }
.mm-header-right { display: flex; align-items: center; gap: 8px; }
.mm-db-label { opacity: .8; }
.mm-db-combo { width: 340px; }
.mm-font-combo { width: 64px; }
.mm-server { font-family: Consolas, monospace; opacity: .8; }
.mm-main { flex: 1; min-height: 0; }

/* DevExpress components follow the same variable (their themes otherwise fix their own sizes). */
.mm-shell .dxbl-grid, .mm-shell .dxbl-toolbar, .mm-shell .dxbl-btn, .mm-shell .dxbl-text-edit, .mm-shell .dxbl-combobox,
.mm-shell .dxbl-checkbox, .mm-shell .dxbl-spin-edit, .mm-shell .dxbl-popup, .mm-shell .dxbl-grid-table, .mm-shell .dxbl-grid-header,
.mm-shell .dxbl-grid-footer { font-size: var(--mm-font-size) !important; }
.mm-shell .dxbl-grid { --dxbl-grid-font-size: var(--mm-font-size); }

.mm-page { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: 215px 36px calc(100vh - 32px - 215px - 36px - 230px) 230px; height: 100%; min-height: 0; width: 100%; overflow: hidden; }
.mm-page > section { min-width: 0; }
.mm-row-selections { border-bottom: 1px solid #d0d4da; background: #fff; min-height: 0; overflow: hidden; }
.mm-row-toolbar { background: #fafafa; border-bottom: 1px solid #d0d4da; overflow: hidden; }
.mm-row-grid { min-height: 0; display: flex; flex-direction: column; }
.mm-row-bottom { display: grid; grid-template-columns: minmax(0, 1fr) 386px; border-top: 1px solid #d0d4da; min-height: 0; background: #fff; }
.mm-row-bottom > * { min-width: 0; min-height: 0; }

/* Selections — replica of the WPF DXTabControl + dxlc:GroupBox + ListBox at 96 DPI (Office2019Colorful).
   Metrics are multiples of the font size so the user's font setting scales the boxes the way WPF does. */
.mm-row-selections { height: 222px; }
.wpf-tabcontrol { display: flex; flex-direction: column; height: 100%; background: #f0f0f0; font-family: var(--mm-font); font-size: var(--mm-font-size); color: #1e1e1e; }
.wpf-tabstrip { display: flex; align-items: flex-end; height: calc(var(--mm-font-size) * 2); background: #f3f3f3; border-bottom: 1px solid #c8c8c8; padding-left: 4px; }
.wpf-tab { height: calc(var(--mm-font-size) * 2); padding: 0 12px; margin-bottom: -1px; border: 1px solid transparent; border-bottom: 0; background: transparent; font: calc(var(--mm-font-size) * 1.083) var(--mm-font); color: #1e1e1e; cursor: default; white-space: nowrap; }
.wpf-tab:hover { color: #1b6ec2; }
.wpf-tab:disabled { color: #9a9a9a; }
.wpf-tab-active { background: #fff; color: #1b6ec2; border-color: #c8c8c8; }
.wpf-tabstrip-fill { flex: 1; }
.wpf-controlbox { display: flex; align-items: center; gap: 6px; padding: 0 8px 2px 0; }
.wpf-pill { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border: 1px solid #c8c8c8; border-radius: 10px; background: #fff; font-weight: 600; color: #00008b; font-size: var(--mm-font-size); cursor: pointer; }
.wpf-iconbutton { width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: 3px; background: transparent; cursor: pointer; }
.wpf-iconbutton:hover { background: #e6e6e6; border-color: #aaa; }
.wpf-tabpage { flex: 1; min-height: 0; padding: 2px 12px 6px 12px; background: #f0f0f0; }
.wpf-boxrow { display: grid; grid-auto-flow: column; gap: 6px; height: 100%; overflow-x: auto; }

/* dxlc:GroupBox */
.wpf-groupbox { display: flex; flex-direction: column; min-width: 0; height: 100%; background: #fff; border: 1px solid #bdbdbd; box-sizing: border-box; }
.wpf-groupbox-header { position: relative; height: calc(var(--mm-font-size) * 1.833); line-height: calc(var(--mm-font-size) * 1.75); text-align: center; background: #f3f3f3; border-bottom: 1px solid #c8c8c8; color: #262626; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 6px; }
.wpf-caption-count { position: absolute; right: 6px; top: 0; font-size: calc(var(--mm-font-size) * 0.75); color: gray; }
.wpf-listbox { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 4px 0 0 0; scrollbar-width: auto; }
.wpf-listbox::-webkit-scrollbar, .fp-list::-webkit-scrollbar { width: 16px; }
.wpf-listbox::-webkit-scrollbar-track, .fp-list::-webkit-scrollbar-track { background: #f0f0f0; }
.wpf-listbox::-webkit-scrollbar-thumb, .fp-list::-webkit-scrollbar-thumb { background: #cdcdcd; border: 1px solid #f0f0f0; }
.wpf-listbox::-webkit-scrollbar-button:single-button, .fp-list::-webkit-scrollbar-button:single-button { background: #f0f0f0; height: 16px; }
.wpf-row { display: flex; align-items: center; height: calc(var(--mm-font-size) * 2.333); padding-left: 18px; cursor: default; user-select: none; white-space: nowrap; }
.wpf-row:hover { background: #eef5fc; }
.wpf-check { flex: none; width: 13px; height: 13px; box-sizing: border-box; border: 1px solid #707070; background: #fff; margin-right: 8px; position: relative; }
.wpf-check-on::after { content: ""; position: absolute; left: 3px; top: 0; width: 4px; height: 8px; border: solid #212121; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.wpf-check-null { background: #cfcfcf; border-color: #4a4a4a; }
.wpf-check-null::after { content: ""; position: absolute; left: 2px; top: 5px; width: 7px; height: 2px; background: #212121; }
.wpf-row-excluded .wpf-row-text { text-decoration: line-through; color: #444; }
.wpf-row-text { overflow: hidden; text-overflow: ellipsis; }
.wpf-row-manual-open { background: #fff8d0; }
.wpf-manual-edit { display: block; width: calc(100% - 22px); margin: 1px 4px 3px 18px; height: calc(var(--mm-font-size) * 1.833); box-sizing: border-box; border: 1px solid #7a6a00; background: #fffdf0; text-align: center; font: inherit; }
.wpf-amount { display: block; min-width: 120px; margin: 0 auto 2px auto; height: calc(var(--mm-font-size) * 1.833); box-sizing: border-box; border: 0.5px solid darkgray; text-align: center; font: inherit; }
.wpf-empty { padding: 18px 8px; text-align: center; font-style: italic; }
.wpf-empty-title { font-size: calc(var(--mm-font-size) * 1.167); }
.wpf-empty-subtitle { font-size: calc(var(--mm-font-size) * 0.92); }
.wpf-loading { padding: 12px; color: #666; font-style: italic; }

/* Price / range boxes: GroupBox with a coloured header (Current Price yellow, Future Price green), a left
   TabControlMultiLineView strip with one rotated tab, the comparison list, then the operand lists / editors. */
.wpf-pricebox-cp .wpf-pricebox-header, .wpf-pricebox-cp .wpf-sidetabs-colored { background: #ffff00; }
.wpf-pricebox-fp .wpf-pricebox-header, .wpf-pricebox-fp .wpf-sidetabs-colored { background: #008000; }
.wpf-pricebox-body, .wpf-rangebox-body { display: flex; flex: 1; min-height: 0; background: #fff; }
.wpf-sidetabs { width: 30px; flex: none; background: #f3f3f3; border-right: 1px solid #c8c8c8; display: flex; flex-direction: column; }
.wpf-sidetab { display: flex; align-items: center; justify-content: center; writing-mode: vertical-rl; transform: rotate(180deg); min-height: 70px; padding: 6px 0; font-size: var(--mm-font-size); color: #1b6ec2; background: #fff; border: 1px solid #c8c8c8; border-right: 0; margin: 2px 0 0 2px; }
.wpf-pricebox-lists { display: flex; flex: 1; min-width: 0; }
.wpf-pricebox-lists .wpf-sublist, .wpf-rangebox-body .wpf-sublist { flex: 0 0 38%; min-width: 0; border: 0; border-right: 1px solid #e3e3e3; }
.wpf-pricebox-lists .wpf-sublist:nth-child(2), .wpf-pricebox-lists .wpf-sublist:nth-child(3) { flex: 1 1 0; }
.wpf-sublist .wpf-row { padding-left: 8px; }
.wpf-range-editors { flex: 1; min-width: 0; padding: 2px; }
.wpf-range-label { margin: 2px; height: calc(var(--mm-font-size) * 1.833); line-height: calc(var(--mm-font-size) * 1.667); box-sizing: border-box; border: 1px solid #000; background: #f5f5f5; text-align: center; font-weight: 700; }
.wpf-range-edit { display: block; width: calc(100% - 4px); margin: 2px; height: calc(var(--mm-font-size) * 2); box-sizing: border-box; border: 1px solid #000; background: #fff; text-align: center; font: inherit; }

/* Toolbar */
.mm-record-count { font-weight: 600; padding: 0 8px; }
.mm-sku-type { width: 90px; }
.mm-quickfind { width: 170px; }
.mm-timing { color: #6b7280; font-family: Consolas, monospace; font-size: calc(var(--mm-font-size) * 0.92); }
.mm-status { display: inline-block; max-width: 520px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 1px 8px; margin-right: 10px; background: #fff8e1; border: 1px solid #ffe082; border-radius: 3px; color: #5d4037; }

/* Grid */
.mm-grid { height: calc(100vh - 32px - 215px - 36px - 230px); }
.mm-cell-cp { background-color: #fff59d !important; }
.mm-cell-fp { background-color: #c8e6c9 !important; font-weight: 600; }
.mm-fp-up { color: #1b5e20; }
.mm-fp-up::before { content: "▲ "; font-size: calc(var(--mm-font-size) * 0.75); }
.mm-fp-down { color: #b71c1c; }
.mm-fp-down::before { content: "▼ "; font-size: calc(var(--mm-font-size) * 0.75); }
.mm-cell-lock { text-align: center; font-weight: 700; }
.mm-cell-zone { color: #1565c0; font-weight: 700; }
.mm-fp-input { width: 100%; height: calc(var(--mm-font-size) * 1.667); border: 1px solid #a5d6a7; border-radius: 2px; background: #f1f8e9; font: inherit; font-weight: 600; text-align: right; padding: 0 3px; }
.mm-fp-input:focus { outline: 2px solid #2e7d32; background: #fff; }
.mm-grid .dxbl-grid-table td { padding-top: 1px; padding-bottom: 1px; }

/* Bottom: summary + future price panel */
.mm-summary { display: flex; flex-direction: column; min-height: 0; min-width: 0; overflow: hidden; border-right: 1px solid #d0d4da; }
.mm-summary-header { display: flex; justify-content: space-between; padding: 3px 8px; background: #e9eef5; font-weight: 600; }
.mm-summary-grid { flex: 1; min-height: 0; width: 100%; max-width: 100%; }

/* Future Price panel — replica of the WPF FuturePricePanel (DXTabControl 384 x 223 at 96 DPI). */
.fp-panel { display: flex; flex-direction: column; min-height: 0; height: 100%; margin: 3px; border: 1px solid #c8c8c8; background: #f0f0f0; box-sizing: border-box; font-family: var(--mm-font); font-size: var(--mm-font-size); color: #1e1e1e; }
.fp-tabstrip { padding-left: 0; flex: none; }
.fp-tabstrip .wpf-tab { padding: 0 14px; }
.fp-scheme { margin-left: 4px; }
.fp-scheme-off { opacity: .5; text-decoration: line-through; text-decoration-color: red; }
.fp-dot { display: inline-block; width: 5px; height: 5px; margin: 0 5px; border-radius: 50%; background: green; vertical-align: middle; }
.fp-dirty { width: 12px; height: 12px; margin: 0 6px 6px 0; }
.fp-page { flex: 1; min-height: 0; display: flex; flex-direction: column; background: #f0f0f0; }
.fp-page > .fp-fp, .fp-page > .fp-rounding, .fp-page > .fp-advanced { flex: 1; min-height: 0; }
.fp-fp { display: grid; grid-template-columns: 1fr 1fr; }
.fp-col { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.fp-label { margin: calc(var(--mm-font-size) * 0.9) 10px 2px 10px; height: calc(var(--mm-font-size) * 1.333); line-height: calc(var(--mm-font-size) * 1.333); white-space: nowrap; }
.fp-col-pm .fp-label { margin-left: 5px; }
.fp-list { flex: 1; min-height: 0; margin: 0 2px 0 12px; background: #fff; border: 1px solid #a0a0a0; overflow-y: scroll; overflow-x: hidden; padding: 1px 0; user-select: none; }
.fp-row { display: flex; align-items: center; min-height: calc(var(--mm-font-size) * 1.667); padding-left: 5px; cursor: default; white-space: nowrap; }
.fp-row:hover { background: #eef5fc; }
.fp-row-selected > .fp-text { font-weight: 600; }
.fp-row-unsupported { color: #9a9a9a; }
.fp-row-expanded { align-items: center; padding-bottom: 3px; }
.fp-radio { flex: none; width: 13px; height: 13px; box-sizing: border-box; border: 1px solid #333; border-radius: 50%; background: #fff; margin-right: 5px; position: relative; }
.fp-radio-on { border-color: #1b6ec2; }
.fp-radio-on::after { content: ""; position: absolute; left: 2px; top: 2px; width: 7px; height: 7px; border-radius: 50%; background: #1e1e1e; }
.fp-radio-dim { border-color: #999; background: #d6d6d6; }
.fp-radio-dim::after { background: #d6d6d6; }
.fp-text { overflow: hidden; text-overflow: ellipsis; }
.fp-text-gap { margin-top: 4px; }
.fp-expanded { display: flex; flex-direction: column; flex: 1; min-width: 0; margin-right: 6px; }
.fp-expanded > .fp-text { font-weight: 600; }
.fp-amount-edit { width: 100%; min-width: 120px; height: calc(var(--mm-font-size) * 1.833); box-sizing: border-box; border: 1px solid #7a6a00; background: #fffdf0; text-align: center; font: inherit; font-weight: 400; }
.fp-sku-edit { border-color: #a0a0a0; background: #fff; }
.fp-select { height: calc(var(--mm-font-size) * 1.833); box-sizing: border-box; border: 1px solid #a0a0a0; background: #fff; font: inherit; font-weight: 400; }
.fp-pm { display: flex; justify-content: center; gap: 0; margin: 0 auto; height: calc(var(--mm-font-size) * 1.833); align-items: center; }
.fp-pm-item { display: inline-flex; align-items: center; gap: 4px; width: 38px; cursor: default; }
.fp-spin { position: relative; width: 90px; margin: 0 auto; }
.fp-spin input { width: 100%; height: calc(var(--mm-font-size) * 1.833); box-sizing: border-box; border: 1px solid #a0a0a0; background: #fff; text-align: center; font: inherit; padding-right: 16px; }
.fp-spin-unit { position: absolute; right: 22px; top: 0; line-height: calc(var(--mm-font-size) * 1.833); pointer-events: none; color: #333; }
.fp-units { flex: 1; min-height: 0; overflow-y: auto; margin: 0 2px 0 0; padding: 4px; user-select: none; }
.fp-unit-row { display: flex; align-items: center; height: calc(var(--mm-font-size) * 1.667); padding-left: 3px; cursor: default; white-space: nowrap; }
.fp-unit-row:hover { background: #eef5fc; }
.fp-unit-icon { width: 16px; height: 16px; margin: 0 3px 0 4px; }
.fp-disabled { opacity: .5; pointer-events: none; }
.fp-buttons { flex: none; display: flex; justify-content: center; gap: 10px; padding: 5px 0 12px 0; }
.fp-button { display: inline-flex; align-items: center; justify-content: center; gap: 5px; width: 85px; height: 30px; box-sizing: border-box; border: 1px solid #adadad; background: #e8e8e8; font: inherit; color: #1e1e1e; cursor: default; padding: 0; }
.fp-button:hover:not(:disabled) { background: #dde7f3; border-color: #7eb4ea; }
.fp-button:disabled { opacity: .5; }
.fp-button img, .fp-button svg { width: 24px; height: 24px; }
.fp-button-edit { width: auto; padding: 0 10px; margin: 0 auto; }
.fp-rounding { display: flex; flex-direction: column; align-items: center; gap: 8px; padding-top: 12px; }
.fp-rounding-row { display: flex; align-items: center; gap: 10px; }
.fp-strong { font-weight: 600; }
.fp-scheme-select { width: 160px; }
.fp-check-row { display: inline-flex; align-items: center; gap: 6px; cursor: default; }
.fp-check-row input { margin: 0; width: 13px; height: 13px; }
.fp-check-indent { margin-left: 40px; }
.fp-advanced { display: flex; flex-direction: column; padding: 6px 12px 0 12px; gap: 4px; }
.fp-group { margin: 0; padding: 0 6px 4px 6px; border: 1px solid #c8c8c8; }
.fp-group legend { padding: 0 4px; }
.fp-group-row { display: grid; grid-template-columns: 180px 1fr auto; align-items: center; gap: 6px; }
.fp-info { display: inline-flex; align-items: center; gap: 10px; justify-self: center; }
.fp-minmax-select { width: 100%; }
.fp-edit-icon { width: 16px; height: 16px; display: inline-block; background: linear-gradient(135deg, #f0c060 50%, #888 50%); border-radius: 2px; }
.fp-note { text-align: center; padding: 2px 0; }

/* Dialogs */
.mm-sku-detail { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px 12px; max-height: 60vh; overflow: auto; }
.mm-sku-field { display: flex; justify-content: space-between; gap: 6px; border-bottom: 1px dotted #e0e0e0; padding: 1px 0; }
.mm-sku-caption { color: #6b7280; }
.mm-sku-value { font-weight: 600; text-align: right; }
.mm-edit-columns { display: flex; flex-direction: column; gap: 6px; }
.mm-edit-columns-list { height: 360px; }

.mm-loading, .mm-error { padding: 24px; font-size: calc(var(--mm-font-size) * 1.167); }
.mm-error { color: #b71c1c; }


.mm-readonly-note { padding: 10px 14px; color: #555; font-size: calc(var(--mm-font-size) * 1.0); border: 1px solid #d0d0d0; background: #f6f6f6; align-self: center; }
