.tools-parts-modal .tools-parts-panel {
  width: min(1040px, 100%);
  max-height: calc(100dvh - 32px);
  overflow: hidden;
  background: #fff;
  color: #17231d;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .3);
}

.tools-parts-modal .tools-parts-panel[data-view="home"],
.tools-parts-modal .tools-parts-panel[data-view="borrow"],
.tools-parts-modal .tools-parts-panel[data-view="return-confirm"],
.tools-parts-modal .tools-parts-panel[data-view="inventory"] {
  width: min(560px, 100%);
}

.tools-parts-header {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 38px;
  align-items: center;
  gap: 8px;
  min-height: 58px;
  padding: 0 14px;
  border-bottom: 1px solid #e2ebe6;
  background: #f8fbf9;
}

.tools-parts-header h2 {
  min-width: 0;
  margin: 0;
  color: #123457;
  font-size: 18px;
  line-height: 1.25;
  text-align: center;
}

.tools-parts-back,
.tools-parts-close {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid #d5e1da;
  border-radius: 10px;
  background: #fff;
  color: #365047;
  font-size: 18px;
  cursor: pointer;
}

.tools-parts-back[hidden] { visibility: hidden; display: block; }

.tools-parts-content {
  box-sizing: border-box;
  max-height: calc(100dvh - 106px);
  padding: 18px;
  overflow: auto;
  overscroll-behavior: contain;
}

.tools-parts-loading,
.tools-parts-empty {
  padding: 34px 14px;
  color: #718078;
  text-align: center;
}

.tools-parts-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px;
}

.tools-parts-field {
  display: grid;
  min-width: 0;
  gap: 6px;
  color: #43564d;
  font-size: 12px;
  font-weight: 800;
}

.tools-parts-field.wide { grid-column: 1 / -1; }

.tools-parts-field input,
.tools-parts-field select {
  box-sizing: border-box;
  width: 100%;
  height: 44px;
  min-width: 0;
  padding: 0 11px;
  border: 1px solid #ccdcd3;
  border-radius: 10px;
  background: #fbfdfc;
  color: #17231d;
  -webkit-text-fill-color: #17231d;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
}

.tools-parts-field input[readonly] {
  background: #eef3f0;
  color: #526158;
}

.tools-parts-field input[type="date"],
.tools-parts-field input[type="time"] {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  height: 44px !important;
  min-height: 44px !important;
  max-height: 44px !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  line-height: 42px !important;
  text-align: left !important;
  direction: ltr;
}

.tools-parts-field input[type="date"]::-webkit-date-and-time-value,
.tools-parts-field input[type="time"]::-webkit-date-and-time-value {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  box-sizing: border-box;
  width: 100%;
  height: 42px;
  min-height: 42px;
  margin: 0;
  padding: 0;
  line-height: 42px;
  text-align: left !important;
}

.tools-parts-field input[type="date"]::-webkit-datetime-edit,
.tools-parts-field input[type="time"]::-webkit-datetime-edit {
  display: flex;
  align-items: center;
  height: 42px;
  padding: 0;
  line-height: 42px;
}

.tools-parts-field input[type="date"]::-webkit-calendar-picker-indicator,
.tools-parts-field input[type="time"]::-webkit-calendar-picker-indicator {
  margin: 0 0 0 auto;
}

.tools-parts-barcode-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.tools-parts-barcode-control.is-manual {
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
}

.tools-parts-scan {
  min-width: 88px;
  padding: 0 12px;
  border: 1px solid #1685d4;
  border-radius: 10px;
  background: #eff8ff;
  color: #1169a8;
  font-weight: 800;
  cursor: pointer;
}

.tools-parts-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
  margin-top: 18px;
}

.tools-parts-actions.has-inventory {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.tools-parts-actions.has-inventory .is-history,
.tools-parts-actions.has-inventory .is-inventory {
  grid-column: 1 / -1;
}

.tools-parts-actions.has-inventory .tools-parts-action {
  border: 2px solid var(--k-line, #2f4c7a);
  border-radius: 99px;
  background: var(--k-chip, #e4f1ff);
  color: var(--k-text, #1c2f4d);
}

.tools-parts-action,
.tools-parts-primary,
.tools-parts-secondary,
.tools-parts-return-button,
.tools-parts-confirm-button {
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 10px;
  font-weight: 800;
  cursor: pointer;
}

.tools-parts-action,
.tools-parts-primary {
  border: 1px solid #07894f;
  background: #07894f;
  color: #fff;
}

.tools-parts-action:nth-child(2) {
  border-color: #1685d4;
  background: #1685d4;
}

.tools-parts-action:nth-child(3),
.tools-parts-secondary {
  border: 1px solid #cbdad2;
  background: #fff;
  color: #315046;
}

.tools-parts-action:disabled,
.tools-parts-primary:disabled,
.tools-parts-confirm-button:disabled {
  cursor: not-allowed;
  opacity: .5;
}

.tools-parts-note,
.tools-parts-status {
  margin: 14px 0 0;
  padding: 10px 12px;
  border: 1px solid #dce7e1;
  border-radius: 10px;
  background: #f7faf8;
  color: #526158;
  font-size: 12px;
  line-height: 1.5;
}

.tools-parts-note.is-warning,
.tools-parts-status.is-error {
  border-color: #f2c8a6;
  background: #fff8ef;
  color: #9a4d10;
}

.tools-parts-status.is-success {
  border-color: #9fd4b9;
  background: #eefaf4;
  color: #067342;
}

.tools-parts-return-list {
  display: grid;
  gap: 10px;
}

.tools-parts-return-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid #dce7e1;
  border-radius: 12px;
  background: #f8fbf9;
}

.tools-parts-return-row strong,
.tools-parts-return-row span,
.tools-parts-return-row small {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}

.tools-parts-return-row span { margin-top: 4px; color: #40554b; font-size: 12px; }
.tools-parts-return-row small { margin-top: 3px; color: #718078; }

.tools-parts-return-button,
.tools-parts-confirm-button {
  min-height: 38px;
  border: 1px solid #1685d4;
  background: #fff;
  color: #1169a8;
}

.tools-parts-history-toolbar {
  display: grid;
  grid-template-columns: minmax(170px, 260px) auto minmax(0, 1fr);
  align-items: end;
  gap: 10px;
  margin-bottom: 14px;
}

.tools-parts-history-scope {
  margin: 0;
  color: #718078;
  font-size: 12px;
  text-align: right;
}

.tools-parts-table-wrap {
  width: 100%;
  overflow: auto;
  border: 1px solid #d7e3dc;
  border-radius: 12px;
  background: #fff;
}

.tools-parts-table {
  width: 100%;
  min-width: 1160px;
  border-collapse: collapse;
  color: #253b31;
  font-size: 11px;
}

.tools-parts-table th,
.tools-parts-table td {
  padding: 9px 10px;
  border-right: 1px solid #e3eae6;
  border-bottom: 1px solid #e3eae6;
  vertical-align: middle;
  text-align: left;
  white-space: nowrap;
}

.tools-parts-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eaf4ef;
  color: #123457;
  font-weight: 900;
}

.tools-parts-table tbody tr:nth-child(even) { background: #fafcfb; }
.tools-parts-table tbody tr { height: 44px; }
.tools-parts-table tbody td { padding-top: 6px; padding-bottom: 6px; }
.tools-parts-table td:last-child, .tools-parts-table th:last-child { border-right: 0; }

html body .tools-parts-table button.tools-parts-confirm-button.app-confirm-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: 62px;
  max-width: 100%;
  height: 30px;
  min-height: 30px;
  max-height: 30px;
  padding: 2px 8px;
  border-width: 2px !important;
  font-size: 12px;
  line-height: 1;
  box-shadow: 0 2px 0 #2f4c7a !important;
}

.tools-parts-state {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #fff3da;
  color: #8b5a00;
  font-weight: 800;
}

.tools-parts-state.is-returned { background: #e7f7ef; color: #067342; }
.tools-parts-state.is-confirmed { background: #eaf3ff; color: #0d5d9b; }

.tools-parts-inventory-results {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.tools-parts-inventory-card {
  padding: 10px;
  border: 1px solid #d6dbe4;
  border-radius: 9px;
  background: #fafcfe;
  color: #243554;
}

.tools-parts-inventory-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  text-align: left;
}

.tools-parts-inventory-head strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.tools-parts-inventory-identifiers {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-top: 3px;
  text-align: left;
  font-size: 12px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.tools-parts-inventory-card small {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-top: 4px;
  color: #708098;
  font-size: 10px;
  text-align: left;
  overflow-wrap: anywhere;
}

.tools-parts-inventory-card small span + span {
  margin-left: 2px;
}

.tools-parts-inventory-tag {
  display: inline-block;
  padding: 2px 5px;
  border-radius: 4px;
  background: #eaf1f8;
  color: #143564;
  font-size: 10px;
  white-space: nowrap;
}

.tools-parts-scanner {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 16px;
  border-radius: inherit;
  background: rgba(5, 16, 11, .96);
}

.tools-parts-scanner video {
  width: 100%;
  height: 100%;
  min-height: 300px;
  object-fit: cover;
  border-radius: 12px;
  background: #000;
}

.tools-parts-scanner-footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  color: #fff;
  font-size: 13px;
}

@media (max-width: 640px) {
  .tools-parts-modal { padding: 10px; }
  .tools-parts-modal .tools-parts-panel { max-height: calc(100dvh - 20px); }
  .tools-parts-content { max-height: calc(100dvh - 82px); padding: 14px; }
  .tools-parts-header { min-height: 52px; padding: 0 9px; }
  .tools-parts-header h2 { font-size: 15px; }
  .tools-parts-grid { grid-template-columns: 1fr; }
  .tools-parts-field.wide { grid-column: auto; }
  .tools-parts-actions { gap: 6px; }
  .tools-parts-action { min-width: 0; padding: 7px 4px; font-size: 12px; }
  .tools-parts-history-toolbar { grid-template-columns: minmax(0, 1fr) auto; }
  .tools-parts-history-scope { grid-column: 1 / -1; text-align: left; }
  .tools-parts-return-row { grid-template-columns: 1fr; }
  .tools-parts-return-button { width: 100%; }
  .tools-parts-scanner video { min-height: 220px; }
}
