.remnant-page {
  --remnant-green: var(--console-green, #126b52);
  --remnant-green-dark: var(--console-green-dark, #0a493a);
  --remnant-ink: var(--console-ink, #172820);
  --remnant-muted: var(--console-muted, #66786f);
  --remnant-line: var(--console-line, #d3ded8);
  height: 100%; min-height: 0; display: flex; flex-direction: column; overflow: hidden;
  padding: 9px 12px 12px !important;
}
.remnant-page .workspace-heading { min-height: 47px; margin-bottom: 5px; }
.remnant-heading h1 { margin: 1px 0; color: #132a21; font-size: 19px; line-height: 1.2; }
.remnant-heading p { max-width: 760px; margin: 0; color: var(--remnant-muted); font-size: 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.remnant-heading .workspace-eyebrow { color: var(--remnant-green); font-size: 9px; font-weight: 800; }
.remnant-heading .workspace-heading-actions { display: flex; align-items: center; gap: 6px; }
.remnant-workspace-tabs { flex: 0 0 auto; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
.remnant-workspace-tabs button { flex: 0 0 auto; }
.remnant-workspace-tabs svg { width: 14px; height: 14px; }

.remnant-toolbar { flex: 0 0 auto; min-height: 39px; display: flex; align-items: center; gap: 7px; margin-bottom: 5px; padding: 4px 6px; border: 1px solid var(--remnant-line); border-radius: 4px; background: #fff; }
.remnant-toolbar--inventory { min-height: 48px; margin-bottom: 9px; padding: 7px 9px; }
.remnant-status-tabs { display: flex; align-items: center; gap: 2px; padding: 2px; border: 1px solid #d5e1db; border-radius: 3px; background: #edf2ef; }
.remnant-status-tabs button { min-height: 26px; padding: 3px 10px; border: 0; border-radius: 2px; background: transparent; color: #5c7167; font-size: 10px; font-weight: 700; cursor: pointer; }
.remnant-status-tabs button:hover { background: #fff; color: var(--remnant-green-dark); }
.remnant-status-tabs button.is-active { background: var(--remnant-green); color: #fff; box-shadow: 0 1px 2px rgba(9,57,43,.18); }
.remnant-toolbar .factory-search { min-width: 260px; flex: 1 1 320px; }
.remnant-toolbar > select { width: 120px; height: 32px; border: 1px solid #bdcdc5; background: #fff; color: #30483e; }

.remnant-list-panel { min-height: 0; flex: 1 1 auto; display: flex; flex-direction: column; }
.remnant-list-panel > header { min-height: 40px; flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 10px; border-bottom: 1px solid var(--remnant-line); background: #f5f8f6; }
.remnant-list-panel > header > div { min-width: 0; display: flex; flex-direction: column; }
.remnant-list-panel > header b { color: #263e34; font-size: 12px; }
.remnant-list-panel > header small { color: #74867d; font-size: 9px; }
.remnant-list-panel > header > span { padding: 3px 7px; border: 1px solid #c4d4cc; border-radius: 3px; color: #4f675c; background: #fff; font-size: 9px; }
.remnant-table-scroll { min-height: 0; max-height: none; flex: 1 1 auto; overflow: auto; }
.remnant-table { min-width: 1060px; }
.remnant-table td > b, .remnant-table td > small { display: block; }
.remnant-table td > small { margin-top: 2px; color: #788980; font-size: 9px; }
.remnant-table .table-time { color: #63776d; font-size: 10px; }
.remnant-code { color: #114f3d; font-size: 11px; font-family: "Cascadia Mono", Consolas, monospace; }
.remnant-location { color: #1b644b; }
.remnant-location.is-planned { color: #a15f13; }
.remnant-row-actions { display: flex; align-items: center; gap: 4px; }
.remnant-row-icon { width: 28px; height: 28px; }
.remnant-row-icon svg { width: 14px; height: 14px; }
.factory-status--danger { background: #fbe9e7; color: #a73933; }

.remnant-empty, .remnant-loading, .remnant-error { min-height: 220px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: #74877e; text-align: center; }
.remnant-empty svg, .remnant-error svg { width: 30px; height: 30px; color: #6b9b87; }
.remnant-empty h2 { margin: 0; color: #29463a; font-size: 16px; }
.remnant-empty p { max-width: 500px; margin: 0 0 5px; font-size: 11px; }
.remnant-loading { height: 100%; }
.remnant-loading svg { width: 24px; height: 24px; color: var(--remnant-green); animation: remnant-spin .9s linear infinite; }
.remnant-error svg { color: #b7443c; }
.remnant-error b { color: #873b35; }
@keyframes remnant-spin { to { transform: rotate(360deg); } }

.remnant-modal { display: flex; flex-direction: column; gap: 11px; }
.modal:has(.remnant-modal), .modal:has(.remnant-detail) { display: flex; flex-direction: column; overflow: hidden; }
.modal:has(.remnant-modal) .modal-header, .modal:has(.remnant-modal) .modal-footer,
.modal:has(.remnant-detail) .modal-header, .modal:has(.remnant-detail) .modal-footer { flex: 0 0 auto; }
.modal:has(.remnant-modal) .modal-body, .modal:has(.remnant-detail) .modal-body { min-height: 0; max-height: calc(88vh - 112px); overflow-y: auto; }
.remnant-form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 9px; }
.remnant-form-grid label, .remnant-location-select { min-width: 0; display: flex; flex-direction: column; gap: 5px; color: #526a5f; font-size: 10px; font-weight: 800; }
.remnant-form-grid input, .remnant-form-grid select, .remnant-form-grid textarea, .remnant-location-select select, .remnant-location-scan input { width: 100%; min-width: 0; border: 1px solid #bccdc5; border-radius: 3px; background: #fff; color: #203a2f; box-sizing: border-box; }
.remnant-form-grid input, .remnant-form-grid select, .remnant-location-select select, .remnant-location-scan input { height: 34px; padding: 0 9px; }
.remnant-form-grid textarea { min-height: 54px; padding: 8px 9px; resize: vertical; }
.remnant-form-grid input:focus, .remnant-form-grid select:focus, .remnant-form-grid textarea:focus, .remnant-location-select select:focus, .remnant-location-scan input:focus { border-color: var(--remnant-green); outline: 0; box-shadow: 0 0 0 3px rgba(18,107,82,.12); }
.remnant-form-wide { grid-column: 1/-1; }
.remnant-source-card { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px; padding: 9px 10px; border: 1px solid #c7dbd2; border-left: 3px solid var(--remnant-green); border-radius: 4px; background: #f2f8f5; }
.remnant-source-card > span { width: 31px; height: 31px; display: grid; place-items: center; border-radius: 3px; background: #dcefe6; color: var(--remnant-green-dark); }
.remnant-source-card svg { width: 17px; }
.remnant-source-card div { min-width: 0; display: flex; flex-direction: column; }
.remnant-source-card b { overflow: hidden; color: #214336; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.remnant-source-card small { overflow: hidden; color: #6a7e74; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.remnant-source-card em { padding: 3px 6px; border-radius: 3px; background: #dcefe6; color: #176247; font-size: 9px; font-style: normal; font-weight: 800; }
.remnant-recommendation { min-height: 47px; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid #ead2ab; border-left: 3px solid #bd741d; border-radius: 4px; background: #fff8ed; }
.remnant-recommendation > span { width: 30px; height: 30px; display: grid; place-items: center; color: #9c5c13; }
.remnant-recommendation svg { width: 19px; }
.remnant-recommendation div { min-width: 0; display: flex; flex-direction: column; }
.remnant-recommendation b { color: #74430e; font-size: 11px; }
.remnant-recommendation small { color: #846f55; font-size: 9px; }
.remnant-modal-tools { display: flex; align-items: center; gap: 9px; }
.remnant-modal-tools small, .remnant-form-note { color: #74867d; font-size: 9px; }
.remnant-input-methods { display: grid; gap: 8px; padding: 8px; border: 1px solid #cbded5; border-radius: 4px; background: #f4f9f6; }
.remnant-input-methods label { min-width: 0; display: flex; flex-direction: column; gap: 5px; color: #526a5f; font-size: 10px; font-weight: 800; }
.remnant-input-methods select, .remnant-board-scan input { width: 100%; min-width: 0; height: 33px; padding: 0 9px; border: 1px solid #bccdc5; border-radius: 3px; background: #fff; color: #203a2f; box-sizing: border-box; }
.remnant-input-methods select:focus, .remnant-board-scan input:focus { border-color: var(--remnant-green); outline: 0; box-shadow: 0 0 0 3px rgba(18,107,82,.12); }
.remnant-input-methods small { color: #74867d; font-size: 9px; font-weight: 400; line-height: 1.4; }
.remnant-board-scan > span { display: flex; align-items: center; gap: 5px; color: #255b47; }
.remnant-board-scan > span svg { width: 14px; height: 14px; }
.remnant-board-scan > div { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 6px; align-items: center; }
.remnant-form-note { margin: 0; padding: 7px 9px; border-left: 2px solid #96b5a8; background: #f4f8f6; line-height: 1.55; }
.remnant-putaway-summary { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); overflow: hidden; border: 1px solid var(--remnant-line); border-radius: 4px; }
.remnant-putaway-summary > div { min-width: 0; padding: 9px 10px; border-right: 1px solid #e0e8e4; background: #f8faf9; }
.remnant-putaway-summary > div:last-child { border-right: 0; }
.remnant-putaway-summary span, .remnant-putaway-summary b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.remnant-putaway-summary span { color: #778980; font-size: 9px; }
.remnant-putaway-summary b { margin-top: 3px; color: #244237; font-size: 11px; }
.remnant-location-scan { display: grid; grid-template-columns: 160px 1fr; align-items: center; gap: 8px; padding: 7px; border: 1px solid #145e49; border-radius: 4px; background: #0d4b3b; }
.remnant-location-scan > span { display: flex; align-items: center; gap: 8px; padding: 0 8px; color: #ecf8f3; font-size: 11px; }
.remnant-location-scan svg { width: 17px; color: #66dfb0; }

.remnant-detail > section { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); border: 1px solid var(--remnant-line); border-radius: 4px; overflow: hidden; }
.remnant-detail > section > div { min-width: 0; padding: 9px 10px; border-right: 1px solid #e2e9e5; border-bottom: 1px solid #e2e9e5; }
.remnant-detail > section > div:nth-child(2n) { border-right: 0; }
.remnant-detail > section > div:nth-last-child(-n+2) { border-bottom: 0; }
.remnant-detail span, .remnant-detail b { display: block; }
.remnant-detail span { color: #75877e; font-size: 9px; }
.remnant-detail b { margin-top: 3px; color: #29453a; font-size: 11px; }
.remnant-detail h3 { margin: 14px 0 7px; color: #29453a; font-size: 12px; }
.remnant-detail ol { margin: 0; padding: 0; list-style: none; }
.remnant-detail li { position: relative; display: flex; gap: 9px; padding: 0 0 12px 5px; }
.remnant-detail li::before { content: ""; position: absolute; left: 8px; top: 10px; bottom: -2px; width: 1px; background: #cbdad3; }
.remnant-detail li:last-child::before { display: none; }
.remnant-detail li > i { position: relative; z-index: 1; width: 7px; height: 7px; margin-top: 4px; border: 2px solid #fff; border-radius: 50%; background: var(--remnant-green); box-shadow: 0 0 0 1px var(--remnant-green); }
.remnant-detail li span { display: flex; flex-direction: column; }
.remnant-detail li b { margin: 0; }
.remnant-lineage { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px; border: 1px solid var(--remnant-line); background: #f7faf8; }
.remnant-lineage button, .remnant-lineage span { min-height: 29px; padding: 5px 8px; border: 1px solid #aac2b7; border-radius: 3px; background: #fff; color: #245b47; font-size: 10px; }
.remnant-stocktake-table tbody tr { cursor: pointer; }
.remnant-stocktake-table tbody tr:hover td { background: #edf6f2; }
.remnant-stocktake-detail .factory-table-scroll { max-height: 220px; border: 1px solid var(--remnant-line); }
.remnant-stocktake-detail .factory-table { min-width: 620px; }
.remnant-settings-grid select { width: 100%; min-width: 0; height: 34px; padding: 0 9px; border: 1px solid #bccdc5; border-radius: 3px; background: #fff; box-sizing: border-box; }

.remnant-settings-page { height: 100%; min-height: 0; display: flex; flex-direction: column; gap: 0; overflow: hidden; padding: 9px 12px 12px !important; }
.remnant-settings-page .workspace-tabs { flex: 0 0 auto; }
.remnant-settings-toolbar { flex: 0 0 auto; justify-content: space-between; min-height: 58px; margin-bottom: 10px; }
.remnant-settings-toolbar-copy { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.remnant-settings-toolbar-copy b { color: #23483b; font-size: 13px; }
.remnant-settings-toolbar-copy small { overflow: hidden; color: #7a8b83; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.remnant-settings-toolbar-actions { display: flex; align-items: center; gap: 7px; flex: 0 0 auto; }
.remnant-settings-layout { flex: 1 1 auto; min-width: 0; min-height: 0; display: grid; grid-template-columns: minmax(360px,1.15fr) minmax(240px,.85fr); gap: 7px; padding: 0; overflow: hidden; background: transparent; }
.remnant-settings-form, .remnant-location-settings { min-height: 0; display: flex; flex-direction: column; }
.remnant-settings-form > header, .remnant-location-settings > header { min-height: 43px; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 10px; border-bottom: 1px solid var(--remnant-line); background: #f5f8f6; }
.remnant-settings-form > header > div, .remnant-location-settings > header > div { min-width: 0; display: flex; flex-direction: column; }
.remnant-settings-form header b, .remnant-location-settings header b { color: #263e34; font-size: 12px; }
.remnant-settings-form header small, .remnant-location-settings header small { color: #74867d; font-size: 9px; }
.remnant-settings-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 9px; padding: 12px; overflow: auto; }
.remnant-settings-grid label { min-width: 0; display: flex; flex-direction: column; gap: 5px; color: #526a5f; font-size: 10px; font-weight: 800; }
.remnant-settings-grid input { width: 100%; min-width: 0; height: 34px; padding: 0 9px; border: 1px solid #bccdc5; border-radius: 3px; box-sizing: border-box; }
.remnant-settings-grid label small { color: #809088; font-size: 9px; font-weight: 400; }
.remnant-settings-wide { grid-column: 1/-1; }
.remnant-setting-switches { margin-top: auto; display: grid; gap: 6px; padding: 10px 12px; border-top: 1px solid var(--remnant-line); background: #f7faf8; }
.remnant-setting-switches label { display: flex; align-items: center; gap: 9px; cursor: pointer; }
.remnant-setting-switches input { width: 16px; height: 16px; accent-color: var(--remnant-green); }
.remnant-setting-switches span { display: flex; flex-direction: column; }
.remnant-setting-switches b { color: #344e43; font-size: 10px; }
.remnant-setting-switches small { color: #798b82; font-size: 9px; }
.remnant-location-list { min-height: 0; flex: 1 1 auto; overflow: auto; }
.remnant-location-list > div { min-height: 48px; display: grid; grid-template-columns: minmax(0,1fr) 72px 52px; align-items: center; gap: 8px; padding: 7px 10px; border-bottom: 1px solid #e5ece8; }
.remnant-location-list > div:hover { background: #f1f7f4; }
.remnant-location-list span { min-width: 0; display: flex; flex-direction: column; }
.remnant-location-list b { color: #1f4939; font-size: 11px; font-family: "Cascadia Mono", Consolas, monospace; }
.remnant-location-list small { overflow: hidden; color: #71847a; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.remnant-location-list em { padding: 3px 5px; border-radius: 3px; background: #e7f1ec; color: #2a6950; font-size: 9px; font-style: normal; text-align: center; }
.remnant-location-list strong { color: #455d52; font-size: 10px; text-align: right; }
.remnant-settings-empty { display: flex !important; grid-template-columns: 1fr !important; min-height: 170px !important; align-items: center !important; justify-content: center; color: #788a81; font-size: 11px; text-align: center; }

@media (max-width: 1100px) {
  .remnant-process > div { padding: 7px 8px; gap: 6px; }
  .remnant-process > div > svg { display: none; }
  .remnant-scan-bar > label { grid-template-columns: 160px minmax(160px,1fr); }
}
@media (max-width: 980px) {
  .remnant-settings-layout { grid-template-columns: 1fr; overflow: auto; }
  .remnant-settings-form, .remnant-location-settings { min-height: 360px; }
}
@media (max-width: 760px) {
  .remnant-page { overflow: auto; }
  .remnant-heading p { display: none; }
  .remnant-process { display: flex; overflow-x: auto; }
  .remnant-process > div { min-width: 180px; }
  .remnant-metrics { display: flex; overflow-x: auto; }
  .remnant-metric { min-width: 145px; }
  .remnant-scan-bar > label { grid-template-columns: 1fr; gap: 4px; }
  .remnant-scan-bar > label > span { display: none; }
  .remnant-toolbar { flex-wrap: wrap; }
  .remnant-status-tabs { max-width: 100%; overflow-x: auto; }
  .remnant-toolbar .factory-search { min-width: 100%; flex-basis: 100%; }
  .remnant-list-panel { min-height: 380px; }
}
@media (max-width: 560px) {
  .remnant-settings-toolbar { align-items: flex-start; flex-direction: column; }
  .remnant-settings-toolbar-actions { width: 100%; }
  .remnant-settings-toolbar-actions .factory-button { flex: 1 1 0; }
  .remnant-form-grid, .remnant-putaway-summary, .remnant-detail > section, .remnant-settings-grid { grid-template-columns: 1fr; }
  .remnant-form-wide, .remnant-settings-wide { grid-column: 1; }
  .remnant-putaway-summary > div { border-right: 0; border-bottom: 1px solid #e0e8e4; }
  .remnant-putaway-summary > div:last-child { border-bottom: 0; }
  .remnant-detail > section > div { border-right: 0; border-bottom: 1px solid #e2e9e5 !important; }
  .remnant-detail > section > div:last-child { border-bottom: 0 !important; }
  .remnant-location-scan { grid-template-columns: 1fr; }
  .remnant-location-scan > span { display: none; }
  .modal:has(.remnant-modal) .modal-body, .modal:has(.remnant-detail) .modal-body { max-height: calc(100vh - 118px); }
}
@media (prefers-reduced-motion: reduce) { .remnant-loading svg { animation-duration: .01ms; } }
