:root {
  --sml-bg: #eef2f6;
  --sml-surface: #ffffff;
  --sml-surface-subtle: #f7f9fc;
  --sml-border: #cbd5e1;
  --sml-border-strong: #aebdcd;
  --sml-text: #17212b;
  --sml-text-muted: #65758b;
  --sml-primary: #1769d2;
  --sml-primary-soft: #eaf3ff;
  --sml-success: #087a45;
  --sml-success-soft: #ddf5e8;
  --sml-warning: #9a5a00;
  --sml-warning-soft: #fff0ca;
  --sml-danger: #b4232c;
  --sml-danger-soft: #fde7e9;
  --storage-border: var(--sml-border);
  --storage-text: var(--sml-text);
  --storage-muted: var(--sml-text-muted);
  --storage-blue: var(--sml-primary);
  --storage-green: var(--sml-success);
  --storage-red: var(--sml-danger);
}

.storage-page {
  min-width: 0;
  margin: 0;
  background: var(--sml-bg);
  color: var(--sml-text);
  font-family: Inter, Geist, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.4;
  letter-spacing: 0;
}

.storage-page svg { width: 16px; height: 16px; flex: 0 0 auto; }
.storage-page button,
.storage-page .ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  border-radius: 8px;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
}
.storage-page button:focus-visible,
.storage-page .ghost:focus-visible,
.storage-page a:focus-visible,
.storage-page input:focus-visible,
.storage-page select:focus-visible,
.storage-page summary:focus-visible {
  outline: 0;
  border-color: var(--sml-primary) !important;
  box-shadow: 0 0 0 3px rgba(23, 105, 210, .16);
}
.storage-page .primary { background: var(--sml-primary); border-color: var(--sml-primary); }
.storage-page .primary:hover:not(:disabled) { background: #1259b4; }

.storage-page .top {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto minmax(240px, 1fr);
  align-items: center;
  min-height: 44px;
  padding: 4px 12px;
  background: var(--sml-surface);
  border-bottom: 1px solid var(--sml-border);
  position: sticky;
  top: 0;
  z-index: 80;
}
.storage-page .top-left,
.storage-page .top-right { display: flex; align-items: center; gap: 8px; min-width: 0; }
.storage-page .top-right { justify-content: flex-end; }
.storage-page .top-right .ghost { min-height: 34px; padding: 5px 10px; white-space: nowrap; }
.storage-page-identity > svg { width: 18px; height: 18px; color: var(--sml-primary); }
.storage-page-identity > b { font-size: 15px; white-space: nowrap; }
.top-section { padding-left: 8px; border-left: 1px solid var(--sml-border); color: var(--sml-text-muted); font-weight: 700; }

.storage-product-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid #dbe2ea;
  border-radius: 8px;
  background: #f3f6f9;
}
.storage-product-nav a {
  min-width: 104px;
  padding: 5px 12px;
  border-radius: 6px;
  color: #526174;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
}
.storage-product-nav a:hover { color: var(--sml-primary); }
.storage-product-nav a.active { background: #fff; color: #145cb8; box-shadow: 0 1px 2px rgba(15, 23, 42, .08); }

.storage-page .settings-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 38px;
  padding: 4px 12px;
  border-bottom: 1px solid var(--sml-border);
  background: #fff;
  position: sticky;
  top: 44px;
  z-index: 70;
}
.storage-page .settings-tabs > span { margin-right: 4px; color: var(--sml-text-muted); font-size: 12px; font-weight: 700; }
.storage-page .settings-tabs a {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 3px 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: #455468;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}
.storage-page .settings-tabs a:hover { background: #f0f5fa; }
.storage-page .settings-tabs a.active { border-color: #a9c8f1; background: var(--sml-primary-soft); color: #145cb8; }

.storage-main,
.storage-settings-main { width: 100%; max-width: 1920px; margin: 0 auto; padding: 12px; }
.storage-settings-main { min-height: calc(100vh - 82px); height: auto; display: block; overflow: visible; padding-bottom: 64px; }

.sml-action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.storage-action-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 54px; margin-bottom: 8px; }
.storage-action-bar h1 { margin: 0; font-size: 23px; line-height: 30px; }
.storage-action-bar p,
.storage-band-head p { margin: 1px 0 0; color: var(--sml-text-muted); font-size: 12px; }
.storage-primary-action { min-height: 38px !important; padding: 7px 14px !important; white-space: nowrap; }

.storage-message { margin: 0 0 8px; border-radius: 8px; font-size: 13px !important; line-height: 18px; }
.storage-message:not(:empty) { min-height: 38px; padding: 9px 12px !important; border-left-width: 4px !important; }
.storage-message.ok { background: var(--sml-success-soft); border-color: var(--sml-success); color: #075f38; }
.storage-message.err { background: var(--sml-danger-soft); border-color: var(--sml-danger); color: #8e1821; }
.storage-message.wait { background: var(--sml-warning-soft); border-color: #d28b00; color: #714600; }

.storage-metrics,
.storage-summary-rail {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 10px;
  overflow: hidden;
  background: var(--sml-surface);
  border: 1px solid var(--sml-border);
  border-radius: 8px;
}
.storage-summary-rail { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.storage-metrics > div,
.storage-summary-rail > div { display: grid; gap: 1px; min-width: 0; min-height: 52px; padding: 7px 12px; border-right: 1px solid var(--sml-border); }
.storage-metrics > div:last-child,
.storage-summary-rail > div:last-child { border-right: 0; }
.storage-metrics span,
.storage-summary-rail span { color: var(--sml-text-muted); font-size: 12px; font-weight: 600; }
.storage-metrics strong,
.storage-summary-rail strong { overflow: hidden; font-size: 19px; line-height: 26px; text-overflow: ellipsis; white-space: nowrap; }
.metric-danger { color: var(--sml-danger); }

.storage-band {
  width: 100%;
  margin: 0 0 10px;
  overflow: visible;
  background: var(--sml-surface);
  border: 1px solid var(--sml-border);
  border-radius: 8px;
  box-shadow: none;
}
.storage-band-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--sml-border);
}
.storage-band-head h1,
.storage-band-head h2 { margin: 0; font-size: 17px; line-height: 22px; }
.storage-count { flex: 0 0 auto; padding: 3px 8px; border-radius: 5px; background: #edf1f5; color: #536277; font-size: 12px; font-weight: 700; }

.run-filters {
  display: grid;
  grid-template-columns: 170px 170px minmax(190px, 240px) 1fr;
  gap: 8px;
  align-items: end;
  padding: 8px 12px;
  border-bottom: 1px solid var(--sml-border);
  background: var(--sml-surface-subtle);
}
.run-filters label { display: grid; gap: 3px; color: #526174; font-size: 11px; font-weight: 800; }
.run-filters input,
.run-filters select { width: 100%; min-height: 34px; padding: 4px 9px; border: 1px solid var(--sml-border-strong); border-radius: 7px; background: #fff; color: var(--sml-text); font: inherit; }
.run-filter-actions { display: flex; justify-content: flex-end; gap: 8px; }
.run-filter-actions button { min-height: 34px; padding: 5px 12px; }

.storage-search { position: relative; display: block; width: min(320px, 34vw); }
.storage-search input { width: 100%; min-height: 34px; padding: 4px 10px 4px 34px; border: 1px solid var(--sml-border-strong); border-radius: 7px; background: #fff; color: var(--sml-text); font: inherit; }
.storage-search > svg { position: absolute; top: 9px; left: 10px; color: var(--sml-text-muted); pointer-events: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.storage-table-wrap { width: 100%; min-width: 0; overflow: visible; }
.storage-table { width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed; }
.storage-table th {
  height: 36px;
  padding: 6px 10px;
  background: #edf2f7;
  border-right: 1px solid var(--sml-border);
  border-bottom: 1px solid var(--sml-border);
  color: #435267;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  line-height: 14px;
  text-align: left;
  text-transform: uppercase;
}
.storage-table td { height: 44px; padding: 7px 10px; border-right: 1px solid var(--sml-border); border-bottom: 1px solid #dce3eb; vertical-align: middle; overflow-wrap: anywhere; }
.storage-table th:last-child,
.storage-table td:last-child { border-right: 0; }
.storage-table tbody tr:last-child td { border-bottom: 0; }
.storage-table tbody tr:not(.run-details):hover { background: #f8fbff; }
.storage-table .numeric { text-align: right; }
.storage-table th[data-rule-sort],
.storage-table th[data-settings-sort] { cursor: pointer; user-select: none; }
[data-rule-sort-icon], [data-settings-sort-icon] { color: #8492a5; }
[data-rule-sort-icon].active, [data-settings-sort-icon].active { color: var(--sml-primary); }
.storage-table .empty-cell { height: 104px; padding: 18px; text-align: center; color: var(--sml-text-muted); }
.sml-empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; }
.sml-empty-state > svg { width: 22px; height: 22px; margin-bottom: 3px; }
.sml-empty-state strong { color: #334155; }
.sml-empty-state span { font-size: 12px; }

.status-pill { display: inline-flex; align-items: center; min-height: 24px; padding: 2px 7px; border-radius: 5px; font-size: 11px; font-weight: 800; white-space: nowrap; }
.status-pill.created,
.status-pill.enabled { background: var(--sml-success-soft); color: #07683d; }
.status-pill.missing_volume,
.status-pill.error { background: var(--sml-danger-soft); color: #991c25; }
.status-pill.no_stock,
.status-pill.disabled,
.status-pill.neutral { background: #edf1f5; color: #596779; }
.status-pill.running { background: var(--sml-warning-soft); color: #805000; }

.runs-table th { position: sticky; top: 44px; z-index: 5; }
.runs-table th:nth-child(1) { width: 13%; }
.runs-table th:nth-child(2) { width: 15%; }
.runs-table th:nth-child(3) { width: 18%; }
.runs-table th:nth-child(4) { width: 10%; }
.runs-table th:nth-child(5) { width: 10%; }
.runs-table th:nth-child(6) { width: 10%; }
.runs-table th:nth-child(7) { width: 12%; }
.runs-table th:nth-child(8) { width: 9%; }
.runs-table th:nth-child(9) { width: 42px; }
.runs-table td:first-child { white-space: nowrap; }
.runs-table tbody > tr.run-created td:first-child { box-shadow: inset 3px 0 var(--sml-success); }
.runs-table tbody > tr.run-missing_volume td:first-child,
.runs-table tbody > tr.run-error td:first-child { box-shadow: inset 3px 0 var(--sml-danger); }
.runs-table tbody > tr.run-running td:first-child { box-shadow: inset 3px 0 #d28b00; }
.runs-table td:nth-child(2) strong,
.fact-cell strong { display: block; }
.runs-table td small,
.fact-cell small { display: block; color: var(--sml-text-muted); font-size: 10px; font-weight: 600; line-height: 14px; }
.run-mode { display: inline-flex; align-items: center; gap: 6px; color: #526174; white-space: nowrap; }
.run-mode svg { width: 14px; height: 14px; }
.run-link { display: inline-flex; align-items: center; gap: 5px; color: #0b60b8; font-weight: 800; text-decoration: none; white-space: nowrap; }
.run-link:hover { text-decoration: underline; }
.run-link svg { width: 13px; height: 13px; }
.details-button,
.icon-button,
.delete-rule { width: 32px; height: 32px; min-height: 32px !important; padding: 0 !important; border: 1px solid var(--sml-border-strong); border-radius: 7px; background: #fff; color: #526174; cursor: pointer; }
.details-button svg { transition: transform .15s; }
.details-button.expanded svg { transform: rotate(180deg); }
.run-details td { height: auto; padding: 0; background: #fff8f8; }
.run-error-box { padding: 10px 12px; border-left: 3px solid var(--sml-danger); }
.run-error-summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.run-error-summary > div { display: grid; gap: 1px; }
.run-error-summary strong { color: #971d25; }
.run-error-summary span { color: var(--sml-text-muted); font-size: 12px; }
.missing-list { display: grid; gap: 1px; overflow: hidden; border: 1px solid #d9e0e8; border-radius: 6px; background: #d9e0e8; }
.missing-item { display: grid; grid-template-columns: minmax(240px, 1fr) minmax(160px, .7fr) minmax(130px, .5fr) 90px; gap: 12px; align-items: center; padding: 7px 10px; background: #fff; }
.missing-item > strong,
.missing-item > span > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.missing-item > span { display: grid; min-width: 0; color: var(--sml-text-muted); font-size: 12px; }
.missing-item > span b { color: #8390a2; font-size: 10px; text-transform: uppercase; }

.storage-stores { display: flex; align-items: center; gap: 5px; min-width: 0; }
.storage-chip { display: inline-block; max-width: 180px; min-height: 24px; padding: 3px 7px; overflow: hidden; border: 1px solid #bfd0e4; border-radius: 5px; background: #eef5fc; color: #245277; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.storage-chip-more { flex: 0 0 auto; background: #f2f5f8; color: #526174; }

/* Ручной расчёт */
.sml-modal,
.storage-manual-dialog { width: min(720px, calc(100vw - 32px)); max-width: 720px; max-height: min(820px, calc(100vh - 32px)); margin: auto; padding: 0; overflow: hidden; border: 1px solid var(--sml-border-strong); border-radius: 10px; background: #fff; color: var(--sml-text); box-shadow: 0 20px 50px rgba(15, 23, 42, .24); }
.sml-modal::backdrop,
.storage-manual-dialog::backdrop { background: rgba(15, 23, 42, .48); }
.sml-modal-shell,
.storage-modal-shell { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; max-height: min(820px, calc(100vh - 32px)); }
.sml-modal-head,
.storage-modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--sml-border); }
.sml-modal-head h2,
.storage-modal-head h2 { margin: 0; font-size: 18px; line-height: 24px; }
.sml-modal-head p,
.storage-modal-head p { margin: 2px 0 0; color: var(--sml-text-muted); font-size: 12px; }
.sml-modal-body,
.storage-modal-body { overflow-y: auto; padding: 14px 16px; }
.sml-modal-footer,
.storage-modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--sml-border); background: var(--sml-surface-subtle); }
.sml-modal-footer button,
.storage-modal-footer button { min-height: 38px; padding: 7px 13px; }
.manual-moment-grid { display: grid; grid-template-columns: 1fr 1fr auto; gap: 12px; }
.manual-moment-grid label { display: grid; gap: 4px; color: #526174; font-size: 12px; font-weight: 800; }
.manual-moment-grid input { width: 100%; min-height: 38px; padding: 5px 10px; border: 1px solid var(--sml-border-strong); border-radius: 7px; color: var(--sml-text); font: inherit; }
.manual-agents-section { margin-top: 14px; border: 1px solid var(--sml-border); border-radius: 8px; }
.manual-agents-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border-bottom: 1px solid var(--sml-border); }
.manual-agents-head h3 { margin: 0; font-size: 15px; }
.manual-agents-head p { margin: 1px 0 0; color: var(--sml-text-muted); font-size: 12px; }
.manual-select-all { display: inline-flex; align-items: center; gap: 7px; color: #334155; font-size: 12px; font-weight: 700; white-space: nowrap; }
.manual-agent-search { width: auto; margin: 8px; }
.manual-agent-list { max-height: 230px; overflow-y: auto; border-top: 1px solid #e4eaf0; }
.manual-quick-dates { display: flex; align-items: flex-end; gap: 6px; }
.manual-quick-dates button { min-height: 32px; padding: 4px 9px; }
.manual-agent-option,
.manual-agent-list > label { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 9px; align-items: center; min-height: 44px; padding: 6px 10px; border-bottom: 1px solid #edf1f5; cursor: pointer; }
.manual-agent-option:last-child,
.manual-agent-list > label:last-child { border-bottom: 0; }
.manual-agent-option:hover,
.manual-agent-list > label:hover { background: #f4f8fd; }
.manual-agent-option > span,
.manual-agent-list > label > span { display: grid; }
.manual-agent-option small,
.manual-agent-list > label small { color: var(--sml-text-muted); font-size: 11px; }
.field-error { color: var(--sml-danger) !important; font-weight: 700; }
.storage-inline-note { display: flex; align-items: flex-start; gap: 7px; margin-top: 12px; padding: 9px 10px; border-left: 3px solid #d28b00; border-radius: 6px; background: #fff8e7; color: #6f4700; font-size: 12px; }
.manual-error { margin-top: 8px; padding: 8px 10px; border-left: 3px solid var(--sml-danger); border-radius: 6px; background: var(--sml-danger-soft); color: #8e1821; font-size: 12px; font-weight: 700; }
.manual-error[hidden] { display: none; }
.button-spinner { width: 15px; height: 15px; border: 2px solid rgba(255,255,255,.45); border-top-color: #fff; border-radius: 50%; animation: storage-spin .7s linear infinite; }
@keyframes storage-spin { to { transform: rotate(360deg); } }

/* Настройки */
.storage-config-head h1 { margin: 0; font-size: 18px; line-height: 24px; }
.storage-toggle { display: inline-flex; align-items: center; gap: 7px; color: #344256; font-weight: 800; cursor: pointer; white-space: nowrap; }
.storage-toggle input { appearance: none; width: 34px; height: 19px; margin: 0; border: 1px solid #a8b5c4; border-radius: 10px; background: #dbe2e9; position: relative; cursor: pointer; transition: background .15s, border-color .15s; }
.storage-toggle input::after { content: ''; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(15, 23, 42, .25); transition: transform .15s; }
.storage-toggle input:checked { border-color: var(--sml-success); background: var(--sml-success); }
.storage-toggle input:checked::after { transform: translateX(15px); }
.storage-form-group { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 12px; align-items: start; padding: 8px 12px; }
.storage-form-group + .storage-form-group { border-top: 1px solid var(--sml-border); }
.storage-form-group-title { display: grid; gap: 1px; padding-top: 19px; }
.storage-form-group-title strong { color: #3f4e61; font-size: 12px; text-transform: uppercase; }
.storage-form-group-title span { color: var(--sml-text-muted); font-size: 11px; }
.storage-form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 8px; align-items: start; }
.storage-form-grid > label,
.storage-radio-field { display: grid; gap: 4px; min-width: 0; color: #475569; font-size: 12px; font-weight: 700; }
.storage-form-grid > label > span,
.storage-radio-field > span { min-height: 17px; color: #526174; font-size: 11px; font-weight: 800; }
.storage-form-grid input:not([type="radio"]),
.storage-form-grid select { width: 100%; min-width: 0; min-height: 36px; padding: 5px 9px; border: 1px solid var(--sml-border-strong); border-radius: 7px; background: #fff; color: var(--sml-text); font: inherit; }
.storage-form-grid input:disabled { background: #f2f5f8; color: #405066; opacity: 1; }
.storage-form-grid [aria-invalid="true"] { border-color: #d36a72; background: #fffafa; }
.storage-calculation-grid .storage-field-time { grid-column: span 2; }
.storage-calculation-grid .storage-service-field { grid-column: span 7; }
.storage-calculation-grid .storage-field-uom { grid-column: span 3; }
.storage-document-grid .storage-field-org { grid-column: span 3; }
.storage-document-grid .storage-field-store { grid-column: span 4; }
.storage-document-grid .storage-field-state { grid-column: span 3; }
.storage-document-grid .storage-field-mode { grid-column: span 2; }
.storage-segmented { display: grid; grid-template-columns: 1fr 1fr; min-height: 36px; overflow: hidden; border: 1px solid var(--sml-border-strong); border-radius: 7px; background: #eef2f6; }
.storage-segmented label { display: block; min-width: 0; cursor: pointer; }
.storage-segmented label + label { border-left: 1px solid var(--sml-border-strong); }
.storage-segmented input { position: absolute; opacity: 0; pointer-events: none; }
.storage-segmented span { display: flex; align-items: center; justify-content: center; height: 100%; padding: 0 6px; color: #526174; font-size: 11px; font-weight: 800; }
.storage-segmented input:checked + span { background: #fff; color: #145cb8; box-shadow: inset 0 -2px var(--sml-primary); }
.storage-config-note { min-height: 34px; padding: 8px 12px 8px 164px; border-top: 1px solid var(--sml-border); color: #526174; font-size: 12px; }
.storage-config-note.warning { border-left: 3px solid #d28b00; background: #fff9eb; color: #754a00; }
.storage-config-note.success { border-left: 3px solid var(--sml-success); background: #f0faf5; color: #07683d; }

.storage-combobox { position: relative; }
.storage-service-field { position: relative; z-index: 20; }
.storage-combobox input[type="search"] { padding-right: 34px !important; }
.storage-combobox-icon { position: absolute; top: 10px; right: 10px; width: 15px !important; height: 15px !important; color: var(--sml-text-muted); pointer-events: none; }
.storage-combobox-menu { position: absolute; z-index: 60; top: calc(100% + 4px); left: 0; right: 0; max-height: 300px; overflow-y: auto; border: 1px solid #8fa4ba; border-radius: 8px; background: #fff; box-shadow: 0 10px 26px rgba(20, 35, 50, .16); }
.storage-combobox-option { display: grid !important; justify-content: stretch !important; gap: 2px !important; width: 100%; min-height: 42px !important; padding: 7px 10px !important; border: 0; border-bottom: 1px solid #e2e8f0; border-radius: 0 !important; background: #fff; color: var(--sml-text); text-align: left; cursor: pointer; }
.storage-combobox-option:last-child { border-bottom: 0; }
.storage-combobox-option:hover,
.storage-combobox-option.active { background: var(--sml-primary-soft); }
.storage-combobox-option.selected { box-shadow: inset 3px 0 var(--sml-primary); }
.storage-combobox-option strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.storage-combobox-option span { color: var(--sml-text-muted); font-size: 11px; }
.storage-combobox-empty { padding: 18px 10px; color: var(--sml-text-muted); text-align: center; }

.rule-add-row { display: grid; grid-template-columns: minmax(320px, 1fr) auto; gap: 8px; align-items: center; padding: 7px 12px; border-bottom: 1px solid var(--sml-border); background: var(--sml-surface-subtle); }
.rule-agent-field,
.storage-agent-combobox { min-width: 0; }
.storage-agent-combobox { z-index: 25; }
.rule-agent-field input { width: 100%; min-height: 36px; padding: 5px 34px 5px 10px; border: 1px solid var(--sml-border-strong); border-radius: 7px; color: var(--sml-text); font: inherit; }
.storage-page .rule-add-button.primary { min-height: 36px; padding: 5px 12px; color: #fff; }
.storage-rules-band { min-height: 0; display: block; overflow: visible; }
.storage-rules-band .storage-table-wrap { min-height: 0; overflow: visible; }
.storage-rules-band .storage-table th { position: sticky; top: 82px; z-index: 4; box-shadow: 0 1px 0 var(--sml-border); }
.storage-rules-band .storage-table td { height: 44px; padding: 5px 10px; }
.settings-rules-table th:nth-child(1) { width: 24%; }
.settings-rules-table th:nth-child(2) { width: 138px; }
.settings-rules-table th:nth-child(4) { width: 104px; }
.settings-rules-table th:nth-child(5) { width: 44px; }
.settings-rules-table input[type="number"] { width: 100%; min-height: 34px; padding: 4px 7px; border: 1px solid var(--sml-border-strong); border-radius: 7px; font: inherit; text-align: right; }
.settings-rules-table tbody tr.rule-disabled { background: #f5f7f9; opacity: .72; }
.rule-rate-control { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 5px; }
.rule-rate-control span { color: var(--sml-text-muted); font-size: 11px; font-weight: 800; white-space: nowrap; }
.rule-store-picker { position: relative; min-width: 0; }
.rule-store-selected { display: flex; align-items: center; gap: 6px; min-width: 0; }
.rule-store-chip-list { display: flex; align-items: center; gap: 5px; min-width: 0; overflow: hidden; }
.rule-store-chip,
.rule-store-more,
.rule-store-add { min-height: 28px !important; border-radius: 6px !important; font-size: 11px !important; font-weight: 800 !important; cursor: pointer; white-space: nowrap; }
.rule-store-chip { display: inline-flex; max-width: 180px; padding: 3px 6px 3px 7px !important; border: 1px solid #9dbde5; background: var(--sml-primary-soft); color: #145cae; }
.rule-store-chip span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.rule-store-chip svg { width: 13px; height: 13px; color: #627b9a; }
.rule-store-chip:hover { border-color: #d07b82; background: #fff4f4; color: #9c242b; }
.rule-store-more { flex: 0 0 auto; padding: 3px 7px !important; border: 1px solid #c6d2df; background: #f4f7fa; color: #526174; }
.rule-store-add { flex: 0 0 auto; padding: 3px 8px !important; border: 1px solid #8eb5e8; background: #fff; color: #145fb9; }
.rule-store-add svg { width: 13px; height: 13px; }
.rule-store-empty { min-width: 0; overflow: hidden; color: var(--sml-text-muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.rule-store-popover { position: absolute; z-index: 40; top: calc(100% + 5px); right: 0; width: min(380px, 100%); min-width: 300px; padding: 6px; border: 1px solid #91a6bd; border-radius: 8px; background: #fff; box-shadow: 0 10px 24px rgba(20, 35, 50, .15); }
.rule-store-popover[hidden] { display: none; }
.rule-store-search-wrap { padding-bottom: 6px; }
.settings-rules-table .rule-store-search { width: 100%; min-height: 34px; padding: 4px 9px; border: 1px solid var(--sml-border-strong); border-radius: 7px; font: inherit; }
.rule-store-option-list { max-height: 240px; overflow-y: auto; border-top: 1px solid #e2e8f0; }
.rule-store-option { display: grid !important; grid-template-columns: 20px minmax(0, 1fr); justify-content: stretch !important; gap: 7px !important; width: 100%; min-height: 34px !important; padding: 5px 7px !important; border: 0; border-bottom: 1px solid #edf1f5; border-radius: 0 !important; background: #fff; color: #273548; text-align: left; cursor: pointer; }
.rule-store-option:hover { background: #f1f6fc; }
.rule-store-option.selected { background: var(--sml-primary-soft); color: #145cae; font-weight: 800; }
.rule-store-check { display: inline-flex; align-items: center; justify-content: center; width: 17px; height: 17px; border: 1px solid var(--sml-border-strong); border-radius: 4px; color: #fff; font-size: 11px; }
.rule-store-option.selected .rule-store-check { border-color: var(--sml-primary); background: var(--sml-primary); }
.rule-enabled-toggle { justify-content: flex-start; }
.rule-actions { text-align: center; }
.delete-rule { border-color: #e0aeb2; color: var(--sml-danger); }

.storage-save-bar { position: fixed; z-index: 90; right: 0; bottom: 0; left: 0; display: flex; align-items: center; justify-content: space-between; min-height: 50px; padding: 7px 12px; border-top: 1px solid var(--sml-border-strong); background: #fff; box-shadow: 0 -4px 14px rgba(15, 23, 42, .06); }
.storage-save-bar .save-note { display: inline-flex; align-items: center; gap: 7px; color: var(--sml-text-muted); font-size: 12px; font-weight: 700; }
.storage-save-bar .save-note svg { color: var(--sml-success); }
.storage-save-bar .primary { min-height: 36px; padding: 5px 14px; }
.storage-save-bar.storage-save-dirty { border-top-color: #d99a12; background: #fffbeb; }
.storage-save-bar.storage-save-dirty .save-note { color: #8a5700; }
.storage-save-bar.storage-save-dirty .save-note svg { color: #d99000; }

@media (max-width: 1100px) {
  .storage-page .top { grid-template-columns: minmax(200px, 1fr) auto minmax(80px, 1fr); }
  .storage-page .top-right .ghost span { display: none; }
  .storage-page .top-right .ghost { width: 34px; padding: 0; }
  .storage-form-group { grid-template-columns: 120px minmax(0, 1fr); }
  .storage-config-note { padding-left: 144px; }
  .storage-calculation-grid .storage-field-time { grid-column: span 3; }
  .storage-calculation-grid .storage-service-field { grid-column: span 6; }
  .storage-calculation-grid .storage-field-uom { grid-column: span 3; }
  .storage-document-grid .storage-field-org,
  .storage-document-grid .storage-field-store,
  .storage-document-grid .storage-field-state,
  .storage-document-grid .storage-field-mode { grid-column: span 3; }
  .storage-summary-rail strong { font-size: 17px; }
  .runs-table .run-mode-col { display: none; }
  .runs-table th:nth-child(1) { width: 14%; }
  .runs-table th:nth-child(2) { width: 16%; }
  .runs-table th:nth-child(3) { width: 19%; }
  .runs-table th:nth-child(5) { width: 12%; }
  .runs-table th:nth-child(6) { width: 11%; }
  .runs-table th:nth-child(7) { width: 16%; }
  .runs-table th:nth-child(8) { width: 10%; }
  .runs-table .status-pill { font-size: 10px; }
  .runs-table .run-link { font-size: 12px; }
}

@media (max-width: 900px) {
  .storage-page .settings-tabs { top: 44px; }
  .storage-settings-main { min-height: calc(100vh - 82px); }
  .storage-rules-band .storage-table th { top: 82px; }
  .runs-table th { top: 44px; }
  .run-filters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .run-filter-actions { grid-column: 1 / -1; }
  .storage-form-group { grid-template-columns: 1fr; gap: 5px; }
  .storage-form-group-title { display: flex; gap: 8px; padding-top: 0; }
  .storage-config-note { padding-left: 12px; }
  .runs-table th:nth-child(5), .runs-table td:nth-child(5) { display: none; }
}

@media (max-width: 680px) {
  .storage-main, .storage-settings-main { padding: 8px; }
  .storage-page .top { position: static; min-height: 44px; padding: 5px 8px; }
  .storage-page-identity .status-pill { display: none; }
  .storage-product-nav { width: 100%; }
  .storage-product-nav a { flex: 1; min-width: 0; }
  .storage-page .settings-tabs { position: static; overflow-x: auto; }
  .storage-action-bar { align-items: flex-start; flex-direction: column; }
  .storage-primary-action { width: 100%; }
  .storage-metrics,
  .storage-summary-rail { grid-template-columns: 1fr 1fr; }
  .storage-metrics > div:nth-child(2) { border-right: 0; }
  .storage-metrics > div:nth-child(-n+2) { border-bottom: 1px solid var(--sml-border); }
  .storage-summary-rail > div { border-bottom: 1px solid var(--sml-border); }
  .storage-summary-rail > div:nth-child(2n) { border-right: 0; }
  .storage-summary-rail > div:last-child { grid-column: 1 / -1; border-bottom: 0; }
  .storage-band-head { align-items: flex-start; }
  .storage-section-title { flex-direction: column; }
  .storage-search { width: 100%; }
  .run-filters { grid-template-columns: 1fr 1fr; }
  .run-filter-status { grid-column: 1 / -1; }
  .storage-table-wrap { overflow-x: auto; }
  .runs-table { min-width: 760px; }
  .runs-table th { position: static; }
  .manual-moment-grid { grid-template-columns: 1fr; }
  .manual-agents-head { align-items: flex-start; flex-direction: column; }
  .missing-item { grid-template-columns: 1fr 1fr; }
  .storage-form-grid { grid-template-columns: 1fr 1fr; }
  .storage-form-grid > *,
  .storage-calculation-grid .storage-field-time,
  .storage-calculation-grid .storage-service-field,
  .storage-calculation-grid .storage-field-uom,
  .storage-document-grid .storage-field-org,
  .storage-document-grid .storage-field-store,
  .storage-document-grid .storage-field-state,
  .storage-document-grid .storage-field-mode { grid-column: 1 / -1; }
  .rule-add-row { grid-template-columns: 1fr; }
  .rule-add-button { width: 100%; }
  .storage-rules-band .storage-table-wrap { overflow: visible; }
  .settings-rules-table,
  .settings-rules-table tbody,
  .settings-rules-table tr,
  .settings-rules-table td { display: block; width: 100%; }
  .settings-rules-table thead { display: none; }
  .settings-rules-table tbody tr { position: relative; padding: 8px 42px 8px 8px; border-bottom: 1px solid var(--sml-border); }
  .storage-rules-band .settings-rules-table td { display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: 8px; align-items: center; height: auto; padding: 4px 0; border: 0; }
  .settings-rules-table td::before { content: attr(data-label); color: var(--sml-text-muted); font-size: 10px; font-weight: 800; text-transform: uppercase; }
  .settings-rules-table td.rule-actions { position: absolute; top: 7px; right: 7px; display: block; width: 32px; }
  .settings-rules-table td.rule-actions::before,
  .settings-rules-table .empty-cell::before { display: none; }
  .rule-store-selected { align-items: flex-start; }
  .rule-store-chip-list { flex-wrap: wrap; overflow: visible; }
  .rule-store-popover { left: 0; right: auto; width: min(380px, calc(100vw - 70px)); min-width: 0; }
  .storage-save-bar { gap: 8px; }
  .storage-save-bar .save-note { min-width: 0; }
  .storage-save-bar .primary { flex: 0 0 auto; }
}

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