@media screen{
 #contractStageEditor{position:fixed;inset:auto;margin:0;padding:0;border:0;max-width:none;max-height:none;overflow:hidden;background:transparent;color:var(--ink);font-family:SPTThai,Tahoma,sans-serif;overscroll-behavior:none;touch-action:pan-y;overflow-anchor:none}
 #contractStageEditor::backdrop{background:rgba(7,24,16,.5);backdrop-filter:blur(3px);transition:background 400ms ease,backdrop-filter 400ms ease}
 #contractStageEditor.stage-focus-closing::backdrop{background:transparent;backdrop-filter:blur(0)}
 #contractStageEditor .stage-focus-row{height:100%;width:100%;margin:0;display:flex;flex-direction:column;overflow:hidden;border:1px solid var(--spt-gold,#b99758);border-radius:16px;background:var(--spt-surface,#fff);box-shadow:0 12px 60px #0005}
 #contractStageEditor .contract-entry-heading{flex:none;background:var(--spt-surface,#fff)}
 #contractStageEditor .contract-entry-bar{background:transparent;color:var(--ink);cursor:default}
 #contractStageEditor .contract-entry-bar:disabled{opacity:1}
 #contractStageEditor .contract-entry-bar>strong{font-size:17px;line-height:1.5}
 #stageFocusTitle:focus{outline:none}
 #contractStageEditor :is(.contract-entry-delete,.stage-heading),#contractStageEditor .contract-entry-bar>small{display:none}
 #contractStageEditor .contract-entry-panel{display:flex;flex-direction:column;flex:1;min-height:0;padding:0;border-radius:0;overflow:hidden;background:var(--spt-surface-alt,#f7f9f6)}
 .stage-editor-scroll{min-height:0;overflow:auto;overscroll-behavior:none;-webkit-overflow-scrolling:touch;overflow-anchor:none;touch-action:pan-y;padding:18px}
 #contractStageEditor .stage-editor-scroll{flex:1}
 #contractStageEditor :is(input,textarea,select){font-size:16px;scroll-margin:12px}
 #contractStageEditor textarea{min-height:110px;max-height:240px;resize:vertical;overscroll-behavior-y:auto}
 #contractStageEditor .contract-fields{align-content:start}
 .stage-editor-actions{flex:none;position:relative;padding:12px 18px calc(12px + env(safe-area-inset-bottom));border-top:1px solid var(--border);background:var(--spt-surface,#fff)}
 .stage-editor-actions>div{display:flex;gap:12px}
 #contractStageEditor .stage-editor-actions button{flex:1;min-height:48px;min-width:0;font-size:16px;margin:0;align-self:stretch}
 .stage-editor-actions [data-stage-message]{font-size:14px;line-height:1.5;color:var(--spt-danger,#a83135);margin:0 0 10px}
 .stage-focus-field-error{display:block;font-size:14px;line-height:1.5;color:var(--spt-danger,#a83135)}
 .stage-focus-placeholder{position:relative;flex:none;margin:14px 0;overflow-anchor:none}
 .contract-entry-row.stage-save-complete .contract-entry-heading{animation:stageSaveGlow 2s ease-out both}
 .contract-entry-row.stage-save-complete .contract-entry-edited{color:var(--spt-gold,#94702d);font-weight:700}
 @keyframes stageSaveGlow{0%,35%{background:var(--spt-warning-bg,#fff0cb);box-shadow:inset 3px 0 0 var(--spt-gold,#c5a15e),inset 0 0 0 1px var(--spt-gold,#c5a15e)}100%{background:transparent;box-shadow:inset 3px 0 0 transparent,inset 0 0 0 1px transparent}}
 @media(max-height:460px){#contractStageEditor .contract-entry-bar{padding:9px 14px}#contractStageEditor .contract-entry-bar .contract-entry-edited{display:none}.stage-editor-actions{padding:8px 12px calc(8px + env(safe-area-inset-bottom))}.stage-editor-scroll{padding:12px}}
 @media(prefers-reduced-motion:reduce){#contractStageEditor::backdrop{transition:none}.contract-entry-row.stage-save-complete .contract-entry-heading{animation:none;background:var(--spt-warning-bg,#fff0cb)}}
}

@media screen{
 #contractStageList>.contract-entry-row{margin:8px 0}
 #contractStageList .contract-entry-heading{gap:0;padding:0 2px 0 0}
 :is(#contractStageList,#contractStageEditor) .stage-summary-bar{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:4px 12px;padding:12px;min-height:80px;align-items:start;flex:1;line-height:1.5}
 :is(#contractStageList,#contractStageEditor) .stage-summary-bar>strong{display:flex;align-items:start;gap:8px;font-size:16px;min-width:0;grid-column:1;grid-row:1;line-height:1.5}
 .stage-number{display:grid;place-items:center;flex:none;min-width:28px;height:28px;border-radius:8px;background:var(--spt-surface-tint,#edf4ef);color:var(--spt-accent,#173e32);font-size:14px;font-variant-numeric:tabular-nums}
 .stage-name{min-width:0;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;overflow-wrap:anywhere}
 :is(#contractStageList,#contractStageEditor) .stage-summary-bar>.stage-summary-amount{display:block;grid-column:2;grid-row:1;font-size:16px;font-weight:700;text-align:right;white-space:nowrap;color:var(--spt-ink,#233b34);line-height:1.7;font-variant-numeric:tabular-nums}
 .stage-summary-amount small{font-size:12px;font-weight:400;color:var(--spt-muted,#62766b)}
 :is(#contractStageList,#contractStageEditor) .stage-summary-bar>.stage-summary-percent{display:block;grid-column:1;grid-row:2;font-size:14px;padding-left:36px;color:var(--spt-muted,#62766b)}
 :is(#contractStageList,#contractStageEditor) .stage-summary-bar>.contract-entry-edited{display:block;grid-column:2;grid-row:2;text-align:right;font-size:14px;white-space:nowrap;color:var(--spt-muted,#62766b)}
 #contractStageList .contract-entry-delete{width:44px;padding:10px 4px;align-self:stretch;font-size:14px}
 #contractStageList .contract-entry-recent{box-shadow:inset 2px 0 var(--spt-gold,#b99758);background:transparent;border-radius:10px}
 #contractStageEditor .stage-name{display:block;-webkit-line-clamp:unset;overflow:visible}
 #contractStageEditor .stage-summary-bar{grid-template-columns:minmax(0,1fr) auto}
 #contractStageEditor .contract-entry-heading{padding:0}
 #contractStageEditor .stage-summary-bar>.stage-summary-amount{font-size:16px}
 @media(max-width:370px){:is(#contractStageList,#contractStageEditor) .stage-summary-bar{gap:4px 8px;padding:10px}.stage-summary-amount small{display:none}:is(#contractStageList,#contractStageEditor) .stage-summary-bar>.stage-summary-amount{font-size:15px}}
}

@media screen{
 #contractStageList .stage-summary-bar,#contractStageList .stage-drag-handle{-webkit-touch-callout:none;user-select:none;-webkit-user-select:none}
 #contractStageList .stage-row-tools,.stage-floating-row .stage-row-tools{display:flex;flex-direction:column;justify-content:flex-start;align-self:stretch;flex:none;width:44px}
 #contractStageList .stage-drag-handle,.stage-floating-row .stage-drag-handle{display:grid;place-items:center;width:44px;min-height:36px;padding:4px;border:0;background:transparent;color:var(--spt-muted,#62766b);cursor:grab;touch-action:pan-y}
 /* Hide only the visual grip; the original 44px drag button remains interactive. */
 #contractStageList .stage-drag-handle svg,.stage-floating-row .stage-drag-handle svg{visibility:hidden}
 /* The delete button is behind the card and only exposed by a left swipe. */
 #contractStageList .stage-swipe,.stage-floating-row .stage-swipe,#contractStageEditor .stage-swipe{margin:0;border-radius:0;min-width:0}
 #contractStageList .stage-swipe>.swipe-content,.stage-floating-row .stage-swipe>.swipe-content{background:var(--spt-surface,#fff);transition:transform 180ms ease,background-color .22s ease,color .22s ease}
 #contractStageList .stage-swipe>.contract-entry-recent,.stage-floating-row .stage-swipe>.contract-entry-recent{background:var(--spt-surface-tint,#edf5f0)}
 #contractStageList .stage-swipe.swiping>.swipe-content{transition:none}
 #contractStageList .stage-swipe>.swipe-delete{width:88px;height:100%;margin:0;opacity:0;pointer-events:none}
 #contractStageList .stage-swipe:is(.revealed,.swiping)>.swipe-delete,#contractStageList .stage-swipe>.swipe-delete:focus-visible{opacity:1}
 #contractStageList .stage-swipe.revealed>.swipe-delete,#contractStageList .stage-swipe>.swipe-delete:focus-visible{pointer-events:auto}
 #contractStageList .stage-swipe:has(>.swipe-delete:focus-visible){--shift:-88px}
 #contractStageEditor .stage-swipe,.stage-floating-row .stage-swipe{background:var(--spt-surface,#fff);flex:none;--shift:0px}
 #contractStageEditor .stage-swipe>.swipe-content,.stage-floating-row .stage-swipe>.swipe-content{transform:none}
 .stage-floating-row .stage-swipe>.swipe-delete{display:none}
 .stage-floating-row .stage-swipe{height:100%}
 @media(prefers-reduced-motion:reduce){#contractStageList .stage-swipe>.swipe-content{transition:none!important}}
 #contractStageEditor .stage-row-tools{display:none}
 #contractEditor.stage-reordering{overscroll-behavior:none;scroll-behavior:auto}
 #contractEditor.stage-reordering .contract-toolbar,#contractEditor.stage-reordering .contract-wizard-navigation{pointer-events:none}
 #contractStageList .stage-reorder-placeholder{opacity:.25;border:1px dashed var(--spt-gold,#b99758);background:var(--spt-surface-tint,#edf4ef)}
 #contractEditor .stage-floating-row{z-index:1000;box-shadow:0 12px 30px #0004;border:1px solid var(--spt-gold,#b99758);background:var(--spt-surface,#fff);will-change:transform;transform-origin:center}
 #contractEditor .stage-floating-row .contract-entry-heading{height:100%;gap:0;padding:0 2px 0 0}
 #contractEditor .stage-floating-row .stage-summary-bar{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:4px 12px;padding:12px;min-height:80px;align-items:start;flex:1;line-height:1.5}
 #contractEditor .stage-floating-row .stage-summary-bar>strong{display:flex;align-items:start;gap:8px;font-size:16px;min-width:0;grid-column:1;grid-row:1;line-height:1.5}
 #contractEditor .stage-floating-row .stage-summary-amount{grid-column:2;grid-row:1;text-align:right;font-size:16px;font-weight:700;white-space:nowrap}
 #contractEditor .stage-floating-row .stage-summary-percent{grid-column:1;grid-row:2;padding-left:36px;font-size:14px}
 #contractEditor .stage-floating-row .contract-entry-edited{grid-column:2;grid-row:2;text-align:right;font-size:14px;white-space:nowrap}
 #contractStageList .stage-reorder-complete .contract-entry-heading{animation:stageSaveGlow 2s ease-out both}
 @media(prefers-reduced-motion:reduce){#contractStageList .stage-reorder-complete .contract-entry-heading{animation:none;background:var(--spt-warning-bg,#fff0cb)}}
}
