:root {
    --ink: #242a27;
    --muted: #606963;
    --line: #dfe4e0;
    --line-strong: #bcc7c0;
    --canvas: #f5f6f5;
    --surface: #ffffff;
    --surface-soft: #f0f3f1;
    --surface-hover: #f6f8f6;
    --platform-dark: #19231e;
    --sidebar-surface: #fcfdfc;
    --sidebar-width: 224px;
    --brand-green: #0a9f47;
    --brand-green-deep: #087338;
    /* Compatibility aliases for existing pages; never a blue/navy brand. */
    --navy: var(--platform-dark);
    --navy-soft: #29362e;
    --accent: var(--brand-green);
    --accent-deep: var(--brand-green-deep);
    --accent-wash: #e8f6ed;
    --success: #157347;
    --success-wash: #eaf7f0;
    --danger: #b4232e;
    --danger-wash: #fff0f1;
    --warning: #8c5d08;
    --warning-wash: #fff7df;
    --focus: #0a9f47;
    --shadow: 0 12px 32px rgb(25 35 30 / .08);
    --radius: 9px;
    --text: var(--ink);
    --border: var(--line);
    --brand-deep: var(--brand-green-deep);
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--ink);
    background: var(--canvas);
    font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--canvas); }
body { margin: 0; min-height: 100vh; color: var(--ink); background: var(--canvas); }
button, input, select { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }

:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--focus) 78%, transparent);
    outline-offset: 2px;
}

.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;
}
.skip-link {
    position: fixed; top: 8px; left: 8px; z-index: 1000; padding: 8px 12px;
    color: white; background: var(--navy); border-radius: 5px; transform: translateY(-150%);
}
.skip-link:focus { transform: translateY(0); }

.login-layout {
    min-height: 100vh; display: grid; grid-template-columns: minmax(320px, 46%) minmax(420px, 54%);
    align-items: center; background: var(--surface);
}
.login-layout::before {
    content: ""; position: absolute; inset: 0 54% 0 0; pointer-events: none;
    background:
        linear-gradient(145deg, #24382c, var(--platform-dark));
}
.login-brand {
    position: relative; z-index: 1; display: flex; align-items: center; gap: 18px;
    justify-self: center; color: white;
}
.brand-mark {
    display: grid; place-items: center; width: 58px; height: 58px; border: 2px solid var(--accent);
    border-radius: 15px; color: var(--accent); font-size: 30px; line-height: 1; font-weight: 900;
    transform: skew(-4deg);
}
.brand-mark.small { width: 38px; height: 38px; border-radius: 10px; font-size: 20px; }
.brand-name, .brand-product { display: block; letter-spacing: .12em; }
.brand-name { font-size: 24px; font-weight: 900; line-height: 1; }
.brand-product { margin-top: 5px; color: #c4cec7; font-size: 10px; font-weight: 700; }
.login-card {
    position: relative; width: min(410px, calc(100vw - 48px)); justify-self: center;
    padding: 42px 44px; background: white; border: 1px solid var(--line); border-radius: 16px;
    box-shadow: var(--shadow);
}
.eyebrow { margin: 0 0 7px; color: var(--accent-deep); font-size: 11px; font-weight: 800; letter-spacing: .13em; }
.login-card h1 { margin: 0; font-size: 28px; letter-spacing: -.025em; }
.login-copy { margin: 12px 0 28px; color: var(--muted); font-size: 14px; line-height: 1.55; }
.field { display: grid; gap: 6px; margin: 15px 0; }
.field label { color: var(--ink); font-size: 12px; font-weight: 650; }
.field input, .field select {
    width: 100%; height: 42px; padding: 0 12px; color: var(--ink); background: white;
    border: 1px solid var(--line-strong); border-radius: 7px;
}
.field input:hover, .field select:hover { border-color: #859d8d; }
.login-button { width: 100%; margin-top: 10px; }
.secure-note { margin: 17px 0 0; color: var(--muted); text-align: center; font-size: 11px; }
.form-error { margin: 10px 0; padding: 9px 11px; color: var(--danger); background: var(--danger-wash); border-radius: 6px; font-size: 12px; }
.form-error:empty { display: none; }

.button, .icon-button, .text-button, .filter-tab, .sort-button, .nav-item, .back-button, .dialog-close {
    cursor: pointer; border: 0;
}
.button {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none;
    min-height: 36px; padding: 0 14px; border-radius: 7px; font-size: 12px; font-weight: 750;
    transition: background-color .15s, border-color .15s, transform .08s;
}
.button:active:not(:disabled) { transform: translateY(1px); }
.button:disabled { cursor: not-allowed; opacity: .5; }
.button.primary { color: white; background: var(--accent-deep); }
.button.primary:hover:not(:disabled) { background: #065d2c; }
.button.secondary { color: var(--ink); background: white; border: 1px solid var(--line-strong); }
.button.secondary:hover:not(:disabled), .button.quiet:hover:not(:disabled) { background: var(--surface-soft); }
.button.quiet { color: var(--muted); background: transparent; }
.button.danger { color: white; background: var(--danger); }
.button.danger:hover:not(:disabled) { background: #941923; }
.button.compact { min-height: 30px; padding: 0 11px; font-size: 11px; }

.portal-shell { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); }
.sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 20; width: var(--sidebar-width); display: flex; flex-direction: column;
    padding: 18px 12px 12px; color: var(--ink); background: var(--sidebar-surface); border-right: 1px solid var(--line);
}
.sidebar-brand { display: flex; align-items: center; gap: 9px; padding: 0 0 16px; border-bottom: 1px solid var(--line); }
.sidebar-brand .brand-name { font-size: 13px; letter-spacing: .07em; }
.sidebar-brand .brand-product { font-size: 9px; color: var(--muted); letter-spacing: .04em; }
.sidebar nav { margin-top: 12px; }
.sidebar nav { min-height: 0; overflow-y: auto; scrollbar-width: thin; }
.nav-item {
    width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 11px; color: var(--muted);
    background: transparent; border-radius: 7px; text-align: left; text-decoration: none; font-size: 13px; font-weight: 600;
}
.nav-item:hover { color: var(--ink); background: var(--surface-soft); }
.nav-item.active { color: var(--brand-green-deep); background: var(--accent-wash); box-shadow: inset 3px 0 var(--accent); font-weight: 750; }
.nav-icon { font-size: 16px; color: currentColor; }
.sidebar-account {
    display: flex; gap: 9px; align-items: center; margin-top: auto; padding: 14px 7px 3px;
    border-top: 1px solid var(--line);
}
.account-avatar { display: grid; place-items: center; width: 32px; height: 32px; flex: 0 0 auto; border-radius: 50%; color: var(--brand-green-deep); background: var(--accent-wash); font-size: 12px; font-weight: 750; }
.account-summary { min-width: 0; display: grid; }
.account-summary strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.account-summary small { margin-top: 2px; color: var(--muted); font-size: 11px; }

main { grid-column: 2; min-width: 0; }
.topbar {
    height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 20px;
    padding: 0 26px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.business-heading { display: grid; gap: 2px; }
.business-heading strong { font-size: 13px; }
.business-label { color: var(--muted); font-size: 8px; font-weight: 800; letter-spacing: .12em; }
.topbar-actions { display: flex; align-items: center; gap: 11px; }
.sync-state { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 10px; }
.sync-dot { width: 7px; height: 7px; border-radius: 50%; background: #2ca66f; box-shadow: 0 0 0 3px #def3e8; }
.sync-state.offline .sync-dot { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-wash); }

.workspace { padding: 20px 26px 28px; }
.page-heading { min-height: 55px; display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 15px; }
.page-heading h1 { margin: 0; font-size: 24px; letter-spacing: -.025em; }
.heading-actions { display: flex; gap: 8px; }
.page-copy { margin: 7px 0 0; color: var(--muted); font-size: 12px; }
.catalog-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 10px; }
.search-box {
    width: min(510px, 48vw); height: 36px; display: flex; align-items: center; gap: 8px; padding: 0 10px;
    color: var(--muted); background: white; border: 1px solid var(--line-strong); border-radius: 7px;
}
.search-box:focus-within { border-color: var(--focus); box-shadow: 0 0 0 2px rgb(10 159 71 / .15); }
.search-box input { min-width: 0; flex: 1; height: 32px; padding: 0; color: var(--ink); background: transparent; border: 0; outline: 0; font-size: 12px; }
.search-box kbd { padding: 1px 6px; color: var(--muted); background: var(--surface-soft); border: 1px solid var(--line); border-radius: 4px; font-size: 10px; }
.filter-tabs { display: flex; padding: 3px; background: var(--surface-soft); border-radius: 7px; }
.filter-tab { min-height: 29px; padding: 0 10px; color: var(--muted); background: transparent; border-radius: 5px; font-size: 11px; font-weight: 700; }
.filter-tab span { display: inline-block; min-width: 16px; margin-left: 3px; padding: 1px 4px; color: var(--muted); background: rgba(255,255,255,.5); border-radius: 8px; font-size: 9px; }
.filter-tab.active { color: var(--ink); background: white; box-shadow: 0 1px 3px rgba(20,31,49,.12); }

.selection-bar {
    min-height: 42px; display: flex; align-items: center; gap: 13px; margin-bottom: 8px; padding: 6px 9px 6px 13px;
    color: var(--ink); background: var(--accent-wash); border: 1px solid var(--brand-green-deep); border-radius: 7px; font-size: 11px;
}
.selection-bar strong { font-size: 11px; }
.selection-spacer { flex: 1; }
.text-button { padding: 2px; color: var(--brand-green-deep); background: transparent; font-size: 11px; font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }

.table-card { overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 2px 5px rgba(22,31,46,.04); }
.table-scroller { overflow: auto; max-height: calc(100vh - 244px); min-height: 260px; }
.item-table { width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed; font-size: 11px; }
.item-table thead { position: sticky; top: 0; z-index: 5; }
.item-table th { height: 34px; padding: 0 9px; color: var(--muted); background: var(--surface-soft); border-bottom: 1px solid var(--line-strong); text-align: left; font-size: 9px; font-weight: 800; letter-spacing: .045em; text-transform: uppercase; }
.item-table td { height: 40px; padding: 4px 9px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.item-table tbody tr:last-child td { border-bottom: 0; }
.item-table tbody tr:hover td { background: var(--surface-hover); }
.item-table tbody tr.selected td { background: var(--accent-wash); }
.item-table tbody tr.saving td { opacity: .58; }
.item-table tbody tr.context-row td { color: var(--muted); background: var(--surface-hover); }
.item-table tbody tr.context-row .system-name-button { color: var(--muted); }
.select-column { width: 38px; text-align: center !important; }
.qb-column { width: 29%; }
.system-column { width: 29%; }
.visible-column { width: 90px; }
.status-column { width: 104px; }
.type-column { width: 120px; }
input[type="checkbox"] { width: 14px; height: 14px; accent-color: var(--accent-deep); cursor: pointer; }
.item-primary { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); font-weight: 700; }
.tree-name {
    min-width: 0; display: flex; align-items: center; gap: 4px;
    padding-left: calc(var(--tree-depth, 0) * 18px);
    background-image: repeating-linear-gradient(to right, transparent 0 17px, var(--line) 17px 18px);
    background-size: calc(var(--tree-depth, 0) * 18px) 100%; background-repeat: no-repeat;
}
.tree-name .item-primary { min-width: 0; }
.tree-toggle {
    width: 18px; height: 22px; flex: 0 0 18px; padding: 0; color: var(--muted);
    background: transparent; border: 0; border-radius: 4px; cursor: pointer; font-size: 12px;
}
.tree-toggle:hover { color: var(--accent-deep); background: var(--accent-wash); }
.tree-leaf { width: 18px; flex: 0 0 18px; color: var(--line-strong); text-align: center; }
.tree-path { padding-left: calc(var(--tree-depth, 0) * 18px + 22px); }
.item-path { display: block; overflow: hidden; margin-top: 1px; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; font-size: 9px; }
.system-name-button { width: 100%; padding: 4px 5px; overflow: hidden; color: var(--ink); background: transparent; border: 1px solid transparent; border-radius: 5px; text-align: left; text-overflow: ellipsis; white-space: nowrap; cursor: text; font-size: 11px; }
.system-name-button:hover { background: white; border-color: var(--line-strong); }
.system-name-button.default { color: var(--muted); }
.inline-edit { display: flex; gap: 4px; }
.inline-edit input { min-width: 0; width: 100%; height: 29px; padding: 0 7px; border: 1px solid var(--focus); border-radius: 5px; font-size: 11px; }
.inline-edit button { width: 28px; border: 0; border-radius: 5px; cursor: pointer; font-weight: 800; }
.inline-save { color: white; background: var(--success); }
.inline-cancel { color: var(--muted); background: var(--line); }
.sort-button { padding: 0; color: inherit; background: transparent; font: inherit; text-transform: inherit; letter-spacing: inherit; }
.sort-button.sorted { color: var(--ink); }
.sort-button.sorted span::after { content: "\2191"; margin-left: 3px; }
.sort-button.sorted.desc span::after { content: "\2193"; }
.switch { position: relative; width: 34px; height: 19px; display: inline-flex; padding: 2px; border: 0; border-radius: 10px; background: var(--line-strong); cursor: pointer; vertical-align: middle; }
.switch::after { content: ""; width: 15px; height: 15px; border-radius: 50%; background: white; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .14s; }
.switch.on { background: var(--success); }
.switch.on::after { transform: translateX(15px); }
.switch:disabled { cursor: not-allowed; opacity: .48; }
.status-chip { display: inline-flex; align-items: center; min-height: 20px; padding: 0 7px; border-radius: 10px; font-size: 8px; font-weight: 850; letter-spacing: .055em; }
.status-chip.active { color: var(--success); background: var(--success-wash); }
.status-chip.inactive { color: var(--danger); background: var(--danger-wash); }
.status-chip.attention { margin-left: 5px; color: var(--warning); background: var(--warning-wash); }
.type-label { color: var(--muted); font-size: 9px; }
.table-message { padding: 60px 20px; color: var(--muted); text-align: center; font-size: 12px; }
.table-footer { min-height: 42px; display: flex; align-items: center; gap: 16px; padding: 5px 9px 5px 13px; color: var(--muted); background: var(--surface-hover); border-top: 1px solid var(--line); font-size: 10px; }
.table-footer > :first-child { flex: 1; }
.continuous-footer > :last-child { white-space: nowrap; }

.portal-grid { display: grid; gap: 14px; }
.portal-grid.two-column { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.full-span { grid-column: 1 / -1; }
.settings-card {
    min-width: 0; padding: 14px; background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: 0 2px 5px rgba(22,31,46,.04);
}
.settings-card.narrow-card { max-width: 520px; }
.settings-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 9px; }
.settings-heading > div { display: grid; gap: 3px; }
.settings-heading strong { color: var(--ink); font-size: 13px; }
.settings-heading span, .settings-meta { color: var(--muted); font-size: 10px; line-height: 1.45; }
.settings-message { padding: 22px; color: var(--muted); text-align: center; font-size: 11px; }
.compact-list { display: grid; }
.compact-row, .stock-rule-row {
    min-height: 44px; display: flex; align-items: center; gap: 9px; padding: 6px 3px;
    border-bottom: 1px solid var(--line);
}
.compact-row:last-child, .stock-rule-row:last-child { border-bottom: 0; }
.compact-row-copy { min-width: 0; flex: 1; display: grid; gap: 2px; }
.compact-row-copy strong { overflow: hidden; color: var(--ink); text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.compact-row-copy small { overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; font-size: 9px; }
.settings-actions {
    min-height: 42px; display: flex; align-items: center; justify-content: flex-end; gap: 8px;
    margin: 10px -14px -14px; padding: 6px 14px; color: var(--muted); background: var(--surface-hover);
    border-top: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius); font-size: 10px;
}
.settings-actions > :first-child { margin-right: auto; }
.branch-config-row { align-items: flex-start; }
.setting-toggle { min-height: 48px; display: flex; align-items: center; gap: 12px; padding: 7px 2px; border-bottom: 1px solid var(--line); }
.setting-toggle > span { min-width: 0; flex: 1; display: grid; gap: 2px; }
.setting-toggle strong { color: var(--ink); font-size: 11px; }
.setting-toggle small { color: var(--muted); font-size: 9px; line-height: 1.35; }
.setting-toggle input, .inline-toggle input { accent-color: var(--accent-deep); }
.compact-grid { gap: 10px; }
.policy-card { padding-bottom: 14px; }
.policy-grid > div:first-child { padding-right: 14px; border-right: 1px solid var(--line); }
.inline-toggle { color: var(--muted); font-size: 10px; font-weight: 700; white-space: nowrap; }
.compact-row select, .stock-rule-row select { height: 30px; border: 1px solid var(--line-strong); border-radius: 5px; background: white; font-size: 10px; }
.stock-rule-row { display: grid; grid-template-columns: minmax(150px,1fr) auto 100px 105px auto; }
.account-scroller { max-height: calc(100vh - 190px); }
.accounts-table th:nth-child(1) { width: 27%; }
.accounts-table th:nth-child(2), .accounts-table th:nth-child(3) { width: 14%; }
.accounts-table th:nth-child(4) { width: 18%; }
.accounts-table th:nth-child(5) { width: 12%; }

.branch-dialog .dialog-shell { width: min(760px, calc(100vw - 30px)); }
.settings-fieldset { margin: 13px 0; padding: 10px 12px 13px; border: 1px solid var(--line); border-radius: 8px; }
.settings-fieldset legend { padding: 0 5px; color: var(--ink); font-size: 11px; font-weight: 800; }
.schedule-grid { display: grid; gap: 4px; margin: 8px 0 11px; }
.schedule-row { display: grid; grid-template-columns: minmax(120px, 1fr) 125px 125px; align-items: center; gap: 8px; min-height: 34px; }
.schedule-row input[type="time"] { height: 30px; padding: 0 6px; border: 1px solid var(--line-strong); border-radius: 5px; }
.schedule-day { color: var(--ink); font-size: 10px; font-weight: 700; }
.page-size { display: flex; align-items: center; gap: 5px; }
.page-size select { height: 27px; border: 1px solid var(--line-strong); border-radius: 5px; background: white; font-size: 10px; }
.pagination { display: flex; align-items: center; gap: 7px; }
.icon-button { width: 28px; height: 28px; display: grid; place-items: center; background: white; border: 1px solid var(--line-strong); border-radius: 5px; font-size: 18px; line-height: 1; }
.icon-button:hover:not(:disabled) { background: var(--surface-soft); }
.icon-button:disabled { cursor: not-allowed; opacity: .42; }

.assembly-heading { align-items: center; }
.back-button { display: block; margin: 0 0 10px; padding: 0; color: var(--muted); background: transparent; font-size: 11px; font-weight: 700; }
.assembly-card { background: white; border: 1px solid var(--line); border-radius: var(--radius); }
.assembly-list { padding: 8px; }
.assembly-row {
    min-height: 49px; display: grid; grid-template-columns: 32px minmax(0, 1fr) auto auto auto; align-items: center; gap: 8px;
    padding: 5px 9px; background: white; border-bottom: 1px solid var(--line);
}
.assembly-row:last-child { border-bottom: 0; }
.assembly-row.dragging { opacity: .45; background: var(--accent-wash); }
.drag-handle { color: var(--muted); border: 0; background: transparent; cursor: grab; font-size: 18px; letter-spacing: -4px; }
.drag-handle:active { cursor: grabbing; }
.assembly-name { min-width: 0; }
.assembly-name strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.assembly-name small { display: block; overflow: hidden; margin-top: 2px; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; font-size: 9px; }
.row-action { min-height: 29px; padding: 0 9px; color: var(--muted); background: transparent; border: 1px solid var(--line); border-radius: 5px; cursor: pointer; font-size: 9px; font-weight: 800; text-transform: uppercase; }
.row-action:hover { background: var(--surface-soft); }
.row-action.remove { color: var(--danger); }
.row-actions { display: flex; gap: 5px; }
.move-buttons { display: flex; gap: 3px; }
.move-buttons button { width: 26px; height: 26px; padding: 0; color: var(--muted); background: var(--surface-soft); border: 0; border-radius: 4px; cursor: pointer; }
.move-buttons button:disabled { cursor: not-allowed; opacity: .35; }
.empty-panel { display: grid; place-items: center; gap: 5px; min-height: 180px; padding: 30px; color: var(--muted); text-align: center; font-size: 11px; }
.empty-panel strong { color: var(--ink); font-size: 13px; }
.commit-bar { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 15px; color: var(--muted); background: var(--surface-hover); border-top: 1px solid var(--line); font-size: 10px; }
.commit-bar > div { display: flex; gap: 7px; }

.earnings-heading { align-items: center; }
.section-tabs { display: flex; gap: 3px; margin-bottom: 10px; padding: 3px; background: var(--surface-soft); border-radius: 7px; width: fit-content; max-width: 100%; }
.section-tab { min-height: 31px; padding: 0 13px; color: var(--muted); background: transparent; border: 0; border-radius: 5px; cursor: pointer; font-size: 11px; font-weight: 750; }
.section-tab.active { color: var(--brand-green-deep); background: var(--accent-wash); box-shadow: inset 0 -2px var(--brand-green); }
.panel-heading { min-height: 51px; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.panel-heading > div { display: grid; gap: 2px; }
.panel-heading strong { font-size: 13px; }
.panel-heading span { color: var(--muted); font-size: 10px; }
.earnings-scroller { max-height: calc(100vh - 259px); }
.earnings-table { table-layout: auto; min-width: 930px; }
.earnings-table th, .earnings-table td { white-space: nowrap; }
.earnings-table td { height: 42px; }
.earnings-table .actions-column { width: 145px; }
.earnings-trigger { display: grid; max-width: 320px; }
.earnings-trigger strong { overflow: hidden; text-overflow: ellipsis; }
.earnings-trigger small { overflow: hidden; color: var(--muted); text-overflow: ellipsis; font-size: 9px; }
.kind-chip { display: inline-flex; width: fit-content; margin-right: 5px; padding: 1px 5px; color: var(--muted); background: var(--surface-soft); border-radius: 4px; font-size: 8px; font-weight: 850; letter-spacing: .04em; }
.money-cell { font-variant-numeric: tabular-nums; font-weight: 750; }
.muted-cell { color: var(--muted); font-size: 10px; }
.action-set { display: flex; gap: 5px; }
.criterion-copy { margin: 7px 0 14px; padding: 9px 11px; color: var(--muted); background: var(--surface-soft); border-radius: 6px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.optional { color: var(--muted); font-weight: 500; }
.check-field { display: flex; align-items: center; gap: 8px; margin: 13px 0; color: var(--muted); font-size: 11px; }
.picker-choice { width: 100%; min-height: 50px; display: grid; gap: 2px; padding: 8px 11px; color: var(--ink); background: white; border: 1px solid var(--line-strong); border-radius: 7px; cursor: pointer; text-align: left; }
.picker-choice:hover { border-color: var(--line-strong); background: var(--surface-hover); }
.picker-choice span { font-size: 12px; font-weight: 750; }
.picker-choice small { overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; font-size: 9px; }
.rule-dialog { width: min(700px, calc(100vw - 32px)); }
.history-filters { display: grid; grid-template-columns: repeat(6, minmax(105px, 1fr)) auto; align-items: end; gap: 7px; margin: 10px 0; padding: 10px; background: white; border: 1px solid var(--line); border-radius: var(--radius); }
.history-filters label { display: grid; gap: 4px; color: var(--muted); font-size: 9px; font-weight: 750; }
.history-filters input, .history-filters select { min-width: 0; width: 100%; height: 31px; padding: 0 7px; color: var(--ink); background: white; border: 1px solid var(--line-strong); border-radius: 5px; font-size: 10px; }
.history-export-actions { display: flex; gap: 2px; }
.history-summary { min-height: 33px; display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 10px; }
.history-summary strong { color: var(--ink); font-size: 14px; font-variant-numeric: tabular-nums; }
.earnings-history-scroller { max-height: calc(100vh - 347px); }
.adjustment-amount { color: var(--danger); }
.positive-amount { color: var(--success); }

.dialog { width: min(540px, calc(100vw - 32px)); padding: 0; color: var(--ink); background: white; border: 0; border-radius: 12px; box-shadow: var(--shadow); }
.dialog::backdrop { background: rgba(10,18,31,.58); backdrop-filter: blur(1px); }
.dialog > form, .dialog-shell { margin: 0; padding: 24px; }
.dialog header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.dialog h2 { margin: 0; font-size: 19px; letter-spacing: -.015em; }
.dialog p { color: var(--muted); font-size: 12px; line-height: 1.5; }
.dialog-close { width: 30px; height: 30px; flex: 0 0 auto; color: var(--muted); background: var(--surface-soft); border-radius: 50%; font-size: 19px; }
.dialog-actions, .dialog footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }
.picker-dialog, .detail-dialog { width: min(700px, calc(100vw - 32px)); }
.dialog-search { width: 100%; margin: 18px 0 10px; }
.picker-results { max-height: min(440px, 58vh); overflow: auto; border: 1px solid var(--line); border-radius: 7px; }
.picker-row { min-height: 47px; display: flex; align-items: center; gap: 10px; padding: 7px 9px; border-bottom: 1px solid var(--line); }
.picker-row:last-child { border-bottom: 0; }
.picker-row:hover { background: var(--surface-hover); }
.picker-row > div { min-width: 0; flex: 1; }
.picker-row strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.picker-row small { display: block; overflow: hidden; margin-top: 2px; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; font-size: 9px; }
.picker-message { padding: 40px 15px; color: var(--muted); text-align: center; font-size: 11px; }
.detail-dialog header p { margin: 4px 0 0; }
.subassembly-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 20px 0 5px; }
.subassembly-heading > div { display: grid; gap: 2px; }
.subassembly-heading strong { font-size: 12px; }
.subassembly-heading span { color: var(--muted); font-size: 10px; }
.subassembly-list { min-height: 70px; padding: 0; border: 1px solid var(--line); border-radius: 7px; }
.compact-empty { min-height: 70px; border: 1px dashed var(--line-strong); border-radius: 7px; }
.breadcrumbs { display: flex; flex-wrap: wrap; gap: 4px; margin: 5px 0 9px; }
.breadcrumb { padding: 3px 6px; color: var(--muted); background: var(--surface-soft); border: 0; border-radius: 4px; cursor: pointer; font-size: 9px; }
.breadcrumb:not(:last-child)::after { content: " /"; color: var(--muted); }
.import-history { margin: 14px 0; padding: 10px 12px; color: var(--muted); background: var(--surface-soft); border-radius: 7px; font-size: 10px; line-height: 1.5; }
.import-dialog input[type="file"] { height: auto; padding: 9px; }

.toast-region { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: grid; gap: 8px; width: min(360px, calc(100vw - 36px)); }
.toast { padding: 11px 13px; color: white; background: var(--ink); border-radius: 7px; box-shadow: 0 8px 24px rgb(25 35 30 / .2); font-size: 11px; line-height: 1.4; animation: toast-in .18s ease-out; }
.toast.error { background: #8f2029; }
.toast.success { background: #176944; }
@keyframes toast-in { from { opacity: 0; transform: translateY(7px); } }
.noscript { position: fixed; inset: auto 0 0; z-index: 1000; padding: 10px; color: white; background: var(--danger); text-align: center; }

@media (max-width: 900px) {
    .portal-shell { grid-template-columns: 62px minmax(0, 1fr); }
    .sidebar { width: 62px; padding: 14px 9px; }
    .sidebar-brand > div:last-child, .nav-item:not(.active)::after, .nav-item { font-size: 0; }
    .sidebar-brand { justify-content: center; padding-inline: 0; }
    .brand-mark.small { width: 36px; height: 36px; }
    .nav-item { justify-content: center; padding: 10px; }
    .nav-icon { font-size: 17px; }
    .account-summary { display: none; }
    .sidebar-account { justify-content: center; padding-inline: 0; }
    main { grid-column: 2; }
    .workspace { padding-inline: 16px; }
    .topbar { padding-inline: 16px; }
    .type-column, .item-table td:last-child { display: none; }
    .qb-column, .system-column { width: 35%; }
    .history-filters { grid-template-columns: repeat(3, minmax(120px, 1fr)); }
    .portal-grid.two-column { grid-template-columns: 1fr; }
    .policy-grid > div:first-child { padding-right: 0; padding-bottom: 12px; border-right: 0; border-bottom: 1px solid var(--line); }
}

@media (max-width: 680px) {
    .login-layout { display: flex; justify-content: center; padding: 28px 0; background: var(--canvas); }
    .login-layout::before, .login-brand { display: none; }
    .login-card { padding: 30px 26px; }
    .topbar { height: 52px; }
    .sync-state { display: none; }
    .workspace { padding: 15px 10px 22px; }
    .page-heading { align-items: flex-start; flex-direction: column; }
    .heading-actions { width: 100%; }
    .heading-actions .button { flex: 1; }
    .catalog-toolbar { align-items: stretch; flex-direction: column; }
    .search-box { width: 100%; }
    .filter-tabs { align-self: flex-start; }
    .selection-bar { align-items: stretch; flex-wrap: wrap; }
    .selection-spacer { flex-basis: 100%; height: 0; }
    .table-scroller { max-height: calc(100vh - 330px); }
    .item-table { min-width: 650px; }
    .table-footer { flex-wrap: wrap; }
    .assembly-row { grid-template-columns: 28px minmax(0, 1fr) auto; }
    .assembly-row .move-buttons { display: none; }
    .commit-bar { align-items: flex-start; flex-direction: column; }
    .commit-bar > div { width: 100%; justify-content: flex-end; }
    .section-tabs { width: 100%; overflow-x: auto; }
    .section-tab { flex: 1 0 auto; }
    .panel-heading { align-items: flex-start; flex-direction: column; padding: 8px 0; }
    .form-grid { grid-template-columns: 1fr; gap: 0; }
    .history-filters { grid-template-columns: 1fr 1fr; }
    .history-export-actions { grid-column: 1 / -1; }
    .schedule-row { grid-template-columns: 1fr 105px 105px; }
    .stock-rule-row { grid-template-columns: 1fr auto 90px; }
    .stock-rule-row [data-stock-weekday] { grid-column: 2 / 3; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* Additive provisioning surfaces; shared portal typography and controls. */
.registration-layout { min-height:100vh; display:grid; place-items:center; padding:24px; background:var(--canvas); }
.registration-layout .login-card { width:min(500px, calc(100vw - 48px)); }
.registration-layout #join-error { color:var(--danger, #a82027); }
.provision-tabs, .provision-actions { display:flex; flex-wrap:wrap; gap:8px; margin:12px 0; }
.provision-tabs [aria-pressed="true"] { border-color:var(--accent); box-shadow:inset 0 -2px var(--accent); }
.provision-pane h2 { margin:24px 0 10px; font-size:18px; }
.provision-pane > p, .provision-form p { color:var(--muted); font-size:13px; line-height:1.6; }
.provision-table { width:100%; border-collapse:collapse; font-size:13px; }
.provision-table th { text-align:left; background:var(--surface-soft); color:var(--muted); font-size:11px; letter-spacing:.025em; }
.provision-table th, .provision-table td { padding:9px 10px; border-bottom:1px solid var(--line); vertical-align:middle; overflow-wrap:anywhere; }
.provision-table tbody tr:last-child td { border-bottom:0; }
.provision-table tbody tr:hover { background:var(--surface-hover); }
.provision-table .person-link, .provision-table .item-secondary { display:block; }
.provision-table .item-secondary { margin-top:3px; color:var(--muted); font-size:11px; overflow-wrap:anywhere; }
.provision-table .provision-actions { margin:0; gap:5px; flex-wrap:nowrap; }
.provision-table .button.compact { min-height:32px; padding:6px 8px; white-space:nowrap; font-size:12px; }
.provision-table td:first-child { min-width:150px; }
.provision-table .person-link { color:var(--brand-green-deep); }
.provision-pane td details small { display:block; max-width:340px; white-space:normal; overflow-wrap:anywhere; }
.provision-dialog { width:min(740px, calc(100vw - 32px)); max-height:90vh; overflow:auto; padding:24px; border:1px solid var(--line); border-radius:12px; color:var(--ink); background:#fff; }
.provision-dialog::backdrop { background:rgba(15,23,42,.5); }
.provision-dialog h2 { margin:0 0 20px; font-size:22px; }
.provision-fields { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:14px; }
.provision-fields > p, .provision-fields > h3, .provision-fields > details, .provision-fields > .provision-day { grid-column:1 / -1; }
.provision-fields .field { min-width:0; display:flex; flex-direction:column; gap:6px; font-size:13px; }
.provision-fields input, .provision-fields select, #sales-pricing-card select { width:100%; min-width:0; padding:9px; border:1px solid var(--line-strong); border-radius:6px; background:#fff; color:inherit; }
.provision-fields input[type="checkbox"] { width:18px; height:18px; accent-color:var(--brand-green-deep); }
.provision-dialog textarea { width:100%; min-height:90px; overflow-wrap:anywhere; padding:12px; border:1px solid var(--line-strong); border-radius:6px; }
.provision-day { display:grid; grid-template-columns:minmax(100px,1fr) 1fr 1fr; gap:12px; align-items:center; }
.capability-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; padding-top:12px; }
.capability-grid label { display:flex; gap:8px; align-items:center; font-size:12px; overflow-wrap:anywhere; }
.capability-grid input { flex:none; }
.capability-picker summary { cursor:pointer; font-size:14px; }
#sales-pricing-card { margin-bottom:20px; }
#sales-pricing-card h2 { margin-top:0; font-size:18px; }
#sales-pricing-card .field { max-width:460px; }
@media (max-width:600px) { .provision-fields, .capability-grid { grid-template-columns:1fr; } .provision-dialog { padding:16px; } }
